diff --git a/.gitignore b/.gitignore index 6f291dc917b87..cf615c6e922f5 100644 --- a/.gitignore +++ b/.gitignore @@ -96,6 +96,8 @@ stamp-h.in scan_makefile_in.awk TSRM/tsrm_config.h Zend/zend_config.h +Zend/zend_dtrace_gen.h +Zend/zend_dtrace_gen.hbak Zend/zend_ini_parser.c Zend/zend_ini_parser.h Zend/zend_ini_parser.output diff --git a/.travis.yml b/.travis.yml index a375a359dd158..2939e3e92a150 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,18 @@ php: notifications: email: false -script: exit 0 +env: + - REPORT_EXIT_STATUS=1 TEST_PHP_EXECUTABLE=./sapi/cli/php + +before_script: + # Compile PHP + - ./travis/compile.sh + # Setup Extensions + - . ./travis/ext/mysql/setup.sh + - . ./travis/ext/mysqli/setup.sh + - . ./travis/ext/pdo_mysql/setup.sh + - . ./travis/ext/pgsql/setup.sh + - . ./travis/ext/pdo_pgsql/setup.sh + +# Run PHPs run-tests.php +script: ./sapi/cli/php run-tests.php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" diff --git a/LICENSE b/LICENSE index 3cc8b777b7725..42536af320686 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -------------------------------------------------------------------- The PHP License, version 3.01 -Copyright (c) 1999 - 2010 The PHP Group. All rights reserved. +Copyright (c) 1999 - 2012 The PHP Group. All rights reserved. -------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without diff --git a/Makefile.frag b/Makefile.frag index c8b3cb2d8062a..12646c20add75 100644 --- a/Makefile.frag +++ b/Makefile.frag @@ -7,7 +7,7 @@ $(builddir)/zend_language_scanner.lo: $(srcdir)/zend_language_parser.h $(builddir)/zend_ini_scanner.lo: $(srcdir)/zend_ini_parser.h $(srcdir)/zend_language_scanner.c: $(srcdir)/zend_language_scanner.l - @(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l) + @(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l) $(srcdir)/zend_language_parser.h: $(srcdir)/zend_language_parser.c $(srcdir)/zend_language_parser.c: $(srcdir)/zend_language_parser.y @@ -18,6 +18,6 @@ $(srcdir)/zend_ini_parser.c: $(srcdir)/zend_ini_parser.y @$(YACC) -p ini_ -v -d $(srcdir)/zend_ini_parser.y -o $@ $(srcdir)/zend_ini_scanner.c: $(srcdir)/zend_ini_scanner.l - @(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l) + @(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l) $(builddir)/zend_indent.lo $(builddir)/zend_highlight.lo $(builddir)/zend_compile.lo: $(srcdir)/zend_language_parser.h diff --git a/Makefile.gcov b/Makefile.gcov index 946f539d10335..79d7a6d7190cd 100644 --- a/Makefile.gcov +++ b/Makefile.gcov @@ -3,6 +3,8 @@ # LCOV # +LCOV_INCLUDE="." + lcov: lcov-html lcov-test: lcov-clean-data test @@ -12,7 +14,7 @@ php_lcov.info: lcov-test @rm -rf lcov_data/ @$(mkinstalldirs) lcov_data/ @echo - -@files=`find . -name \*.gcda -o -name \*.gcno -o -name \*.da -o -name \*.h | sed -e 's/^\.\///' | sed -e 's/\.gcda//g' -e 's/\.gcno//g' -e 's/\.da//g' | uniq` ;\ + -@files=`find . -name \*.gcda -o -name \*.gcno -o -name \*.da -o -name \*.h | sed -e 's/^\.\///' | sed -e 's/\.gcda//g' -e 's/\.gcno//g' -e 's/\.da//g' | $(EGREP) $(LCOV_INCLUDE) | uniq` ;\ for x in $$files; do \ echo -n . ;\ y=`echo $$x | sed -e 's!\.libs/!!'`; \ @@ -39,14 +41,26 @@ php_lcov.info: lcov-test if test -f "$(top_builddir)/$$y.c"; then \ ln -f -s $(top_builddir)/$$y.c lcov_data/$$y.c; \ fi; \ - test -f "$$x.gcno" && cp $$x.gcno lcov_data/$$y.gcno ; \ - test -f "$$x.gcda" && cp $$x.gcda lcov_data/$$y.gcda ; \ - test -f "$$x.da" && cp $$x.da lcov_data/$$y.da ; \ - test -f "$$x.bb" && cp $$x.bb lcov_data/$$y.bb ; \ - test -f "$$x.bbg" && cp $$x.bbg lcov_data/$$y.bbg ; \ - done + if test -f "$$x.gcno"; then \ + cp $$x.gcno lcov_data/$$y.gcno ; \ + fi; \ + if test -f "$$x.gcda"; then \ + cp $$x.gcda lcov_data/$$y.gcda ; \ + fi; \ + if test -f "$$x.da"; then \ + cp $$x.da lcov_data/$$y.da ; \ + fi; \ + if test -f "$$x.bb"; then \ + cp $$x.bb lcov_data/$$y.bb ; \ + fi; \ + if test -f "$$x.bbg"; then \ + cp $$x.bbg lcov_data/$$y.bbg ; \ + fi; \ + done; \ for dir in ext/bcmath/libbcmath ext/fileinfo/libmagic ext/gd/libgd ext/mbstring/libmbfl ext/mbstring/oniguruma ext/pcre/pcrelib ext/pdo_sqlite/libsqlite ext/sqlite/libsqlite ext/sqlite3/libsqlite ext/xmlrpc/libxmlrpc ext/zip/lib; do \ - test -d lcov_data/$$dir && rm -rf lcov_data/$$dir ; \ + if test -d lcov_data/$$dir; then \ + rm -rf lcov_data/$$dir ; \ + fi; \ done @echo @echo "Generating $@" diff --git a/Makefile.global b/Makefile.global index b30c318fc4d94..5118de83fe453 100644 --- a/Makefile.global +++ b/Makefile.global @@ -86,7 +86,7 @@ PHP_TEST_SHARED_EXTENSIONS = ` \ PHP_DEPRECATED_DIRECTIVES_REGEX = '^(magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*=' test: all - -@if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \ + @if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \ INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \ if test "$$INI_FILE"; then \ $(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \ @@ -102,7 +102,9 @@ test: all TEST_PHP_SRCDIR=$(top_srcdir) \ CC="$(CC)" \ $(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \ + TEST_RESULT_EXIT_CODE=$$?; \ rm $(top_builddir)/tmp-php.ini; \ + exit $$TEST_RESULT_EXIT_CODE; \ else \ echo "ERROR: Cannot run tests without CLI sapi."; \ fi diff --git a/NEWS b/NEWS index 2aff180fa9b7c..f753a83ba80c3 100644 --- a/NEWS +++ b/NEWS @@ -1,7826 +1,5 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? 2012, PHP 5.4.13 +?? ??? 201?, PHP 5.6.0 -- CLI server: - . Fixed bug #64128 (buit-in web server is broken on ppc64). (Remi) - -?? ??? 2012, PHP 5.4.12 - -- Core: - . Fixed bug #64099 (Wrong TSRM usage in zend_Register_class alias). (Johannes) - . Fixed bug #64011 (get_html_translation_table() output incomplete with - HTML_ENTITIES and ISO-8859-1). (Gustavo) - . Fixed bug #63982 (isset() inconsistently produces a fatal error on - protected property). (Stas) - . Fixed bug #63943 (Bad warning text from strpos() on empty needle). - (Laruence) - . Fixed bug #63899 (Use after scope error in zend_compile). (Laruence) - . Fixed bug #63893 (Poor efficiency of strtr() using array with keys of very - different length). (Gustavo) - . Fixed bug #63882 (zend_std_compare_objects crash on recursion). (Dmitry) - . Fixed bug #63462 (Magic methods called twice for unset protected - properties). (Stas) - . Fixed bug #62524 (fopen follows redirects for non-3xx statuses). - (Wes Mason) - . Support BITMAPV5HEADER in getimagesize(). (AsamK, Lars) - -- Date: - . Fixed bug #63699 (Performance improvements for various ext/date functions). - (Lars, original patch by njaguar at gmail dot com) - . Fixed bug #55397: Comparsion of incomplete DateTime causes SIGSEGV. - (Derick) - -- FPM: - . Fixed bug #63999 (php with fpm fails to build on Solaris 10 or 11). (Adam) - -- Litespeed: - . Fixed bug #63228 (-Werror=format-security error in lsapi code). (George) - -- ext/sqlite3: - . Fixed bug #63921 (sqlite3::bindvalue and relative PHP functions aren't - using sqlite3_*_int64 API). (srgoogleguy, Lars) - -- PDO_OCI - . Fixed bug #57702 (Multi-row BLOB fetches). (hswong3i, Laruence) - . Fixed bug #52958 (Segfault in PDO_OCI on cleanup after running a long - testsuite). (hswong3i, Lars) - -- PDO_sqlite: - . Fixed bug #63916 (PDO::PARAM_INT casts to 32bit int internally even - on 64bit builds in pdo_sqlite). (srgoogleguy, Lars) - -- OpenSSL: - . New SSL stream context option to prevent CRIME attack vector. (Daniel Lowrey, - Lars) - -17 Jan 2012, PHP 5.4.11 - -- Core: - . Fixed bug #63762 (Sigsegv when Exception::$trace is changed by user). - (Johannes) - . Fixed bug #43177 (Errors in eval()'ed code produce status code 500). - (Todd Ruth, Stas). - -- Filter: - . Fixed bug #63757 (getenv() produces memory leak with CGI SAPI). (Dmitry) - . Fixed bug #54096 (FILTER_VALIDATE_INT does not accept +0 and -0). - (martin at divbyzero dot net, Lars) - -- JSON: - . Fixed bug #63737 (json_decode does not properly decode with options - parameter). (Adam) - -- CLI server - . Update list of common mime types. Added webm, ogv, ogg. (Lars, - pascalc at gmail dot com) - -- cURL extension: - . Fixed bug (segfault due to libcurl connection caching). (Pierrick) - . Fixed bug #63859 (Memory leak when reusing curl-handle). (Pierrick) - . Fixed bug #63795 (CURL >= 7.28.0 no longer support value 1 for - CURLOPT_SSL_VERIFYHOST). (Pierrick) - . Fixed bug #63352 (Can't enable hostname validation when using curl stream - wrappers). (Pierrick) - . Fixed bug #55438 (Curlwapper is not sending http header randomly). - (phpnet@lostreality.org, Pierrick) - -20 Dec 2012, PHP 5.4.10 - -- Core: - . Fixed bug #63726 (Memleak with static properties and internal/user - classes). (Laruence) - . Fixed bug #63635 (Segfault in gc_collect_cycles). (Dmitry) - . Fixed bug #63512 (parse_ini_file() with INI_SCANNER_RAW removes quotes - from value). (Pierrick) - . Fixed bug #63468 (wrong called method as callback with inheritance). - (Laruence) - . Fixed bug #63451 (config.guess file does not have AIX 7 defined, - shared objects are not created). (kemcline at au1 dot ibm dot com) - . Fixed bug #61557 (Crasher in tt-rss backend.php). - (i dot am dot jack dot mail at gmail dot com) - . Fixed bug #61272 (ob_start callback gets passed empty string). - (Mike, casper at langemeijer dot eu) - -- Date: - . Fixed bug #63666 (Poor date() performance). (Paul Taulborg). - . Fixed bug #63435 (Datetime::format('u') sometimes wrong by 1 microsecond). - (Remi) - -- Imap: - . Fixed bug #63126 (DISABLE_AUTHENTICATOR ignores array). (Remi) - -- Json: - . Fixed bug #63588 (use php_next_utf8_char and remove duplicate - implementation). (Remi) - -- MySQLi: - . Fixed bug #63361 (missing header). (Remi) - -- MySQLnd: - . Fixed bug #63398 (Segfault when polling closed link). (Laruence) - -- Fileinfo: - . Fixed bug #63590 (Different results in TS and NTS under Windows). - (Anatoliy) - -- FPM: - . Fixed bug #63581 Possible null dereference and buffer overflow (Remi) - -- Pdo_sqlite: - . Fixed Bug #63149 getColumnMeta should return the table name - when system SQLite used. (Remi) - -- Apache2 Handler SAPI: - . Enabled Apache 2.4 configure option for Windows (Pierre, Anatoliy) - -- Reflection: - . Fixed Bug #63614 (Fatal error on Reflection). (Laruence) - -- SOAP - . Fixed bug #63271 (SOAP wsdl cache is not enabled after initial requests). - (John Jawed, Dmitry) - -- Sockets - . Fixed bug #49341 (Add SO_REUSEPORT support for socket_set_option()). - (Igor Wiedler, Lars) - -- SPL - . Fixed bug #63680 (Memleak in splfixedarray with cycle reference). (Laruence) - -22 Nov 2012, PHP 5.4.9 - -- Core: - . Fixed bug #63305 (zend_mm_heap corrupted with traits). (Dmitry, Laruence) - . Fixed bug #63369 ((un)serialize() leaves dangling pointers, causes crashes). - (Tony, Andrew Sitnikov) - . Fixed bug #63241 (PHP fails to open Windows deduplicated files). - (daniel dot stelter-gliese at innogames dot de) - . Fixed bug #62444 (Handle leak in is_readable on windows). - (krazyest at seznam dot cz) - -- Curl: - . Fixed bug #63363 (Curl silently accepts boolean true for SSL_VERIFYHOST). - Patch by John Jawed GitHub PR #221 (Anthony) - -- Fileinfo: - . Fixed bug #63248 (Load multiple magic files from a directory under Windows). - (Anatoliy) - -- Libxml - . Fixed bug #63389 (Missing context check on libxml_set_streams_context() - causes memleak). (Laruence) - -- Mbstring: - . Fixed bug #63447 (max_input_vars doesn't filter variables when - mbstring.encoding_translation = On). (Laruence) - -- OCI8: - . Fixed bug #63265 (Add ORA-00028 to the PHP_OCI_HANDLE_ERROR macro) - (Chris Jones) - -- PCRE: - . Fixed bug #63180 (Corruption of hash tables). (Dmitry) - . Fixed bug #63055 (Segfault in zend_gc with SF2 testsuite). - (Dmitry, Laruence) - . Fixed bug #63284 (Upgrade PCRE to 8.31). (Anatoliy) - -- PDO: - . Fixed bug #63235 (buffer overflow in use of SQLGetDiagRec). - (Martin Osvald, Remi) - -- PDO_pgsql: - . Fixed bug #62593 (Emulate prepares behave strangely with PARAM_BOOL). - (Will Fitch) - -- Phar: - . Fixed bug #63297 (Phar fails to write an openssl based signature). - (Anatoliy) - -- Streams: - . Fixed bug #63240 (stream_get_line() return contains delimiter string). - (Tjerk, Gustavo) - -- Reflection: - . Fixed bug #63399 (ReflectionClass::getTraitAliases() incorrectly resolves - traitnames). (Laruence) - -18 Oct 2012, PHP 5.4.8 - -- CLI server: - . Implemented FR #63242 (Default error page in PHP built-in web server uses - outdated html/css). (pascal.chevrel@free.fr) - . Changed response to unknown HTTP method to 501 according to RFC. - (Niklas Lindgren). - . Support HTTP PATCH method. Patch by Niklas Lindgren, GitHub PR #190. - (Lars) - -- Core: - . Fixed bug #63219 (Segfault when aliasing trait method when autoloader - throws excpetion). (Laruence) - . Added optional second argument for assert() to specify custom message. Patch - by Lonny Kapelushnik (lonny@lonnylot.com). (Lars) - . Support building PHP with the native client toolchain. (Stuart Langley) - . Added --offline option for tests. (Remi) - . Fixed bug #63162 (parse_url does not match password component). (husman) - . Fixed bug #63111 (is_callable() lies for abstract static method). (Dmitry) - . Fixed bug #63093 (Segfault while load extension failed in zts-build). - (Laruence) - . Fixed bug #62976 (Notice: could not be converted to int when comparing - some builtin classes). (Laruence) - . Fixed bug #62955 (Only one directive is loaded from "Per Directory Values" - Windows registry). (aserbulov at parallels dot com) - . Fixed bug #62907 (Double free when use traits). (Dmitry) - . Fixed bug #61767 (Shutdown functions not called in certain error - situation). (Dmitry) - . Fixed bug #60909 (custom error handler throwing Exception + fatal error - = no shutdown function). (Dmitry) - . Fixed bug #60723 (error_log error time has changed to UTC ignoring default - timezone). (Laruence) - -- cURL: - . Fixed bug #62085 (file_get_contents a remote file by Curl wrapper will - cause cpu Soaring). (Pierrick) - -- Date: - . Fixed bug #62896 ("DateTime->modify('+0 days')" modifies DateTime object) - (Lonny Kapelushnik) - . Fixed bug #62561 (DateTime add 'P1D' adds 25 hours). (Lonny Kapelushnik) - -- DOM: - . Fixed bug #63015 (Incorrect arginfo for DOMErrorHandler). (Rob) - -- FPM: - . Fixed bug #62954 (startup problems fpm / php-fpm). (fat) - . Fixed bug #62886 (PHP-FPM may segfault/hang on startup). (fat) - . Fixed bug #63085 (Systemd integration and daemonize). (remi, fat) - . Fixed bug #62947 (Unneccesary warnings on FPM). (fat) - . Fixed bug #62887 (Only /status?plain&full gives "last request cpu"). (fat) - . Fixed bug #62216 (Add PID to php-fpm init.d script). (fat) - -- OCI8: - . Fixed bug #60901 (Improve "tail" syntax for AIX installation) (Chris Jones) - -- OpenSSL: - . Implemented FR #61421 (OpenSSL signature verification missing RMD160, - SHA224, SHA256, SHA384, SHA512). (Mark Jones) - -- PDO: - . Fixed bug #63258 (seg fault with PDO and dblib using DBSETOPT(H->link, - DBQUOTEDIDENT, 1)). (Laruence) - . Fixed bug #63235 (buffer overflow in use of SQLGetDiagRec). - (Martin Osvald, Remi) - -- PDO Firebird: - . Fixed bug #63214 (Large PDO Firebird Queries). - (james at kenjim dot com) - -- SOAP - . Fixed bug #50997 (SOAP Error when trying to submit 2nd Element of a choice). - (Dmitry) - -- SPL: - . Bug #62987 (Assigning to ArrayObject[null][something] overrides all - undefined variables). (Laruence) - -- mbstring: - . Allow passing null as a default value to mb_substr() and mb_strcut(). Patch - by Alexander Moskaliov via GitHub PR #133. (Lars) - -- Filter extension: - . Bug #49510: Boolean validation fails with FILTER_NULL_ON_FAILURE with empty - string or false. (Lars) - -- Sockets - . Fixed bug #63000 (MCAST_JOIN_GROUP on OSX is broken, merge of PR 185 by - Igor Wiedler). (Lars) - -13 Sep 2012, PHP 5.4.7 - -- Core: - . Fixed bug (segfault while build with zts and GOTO vm-kind). (Laruence) - . Fixed bug #62844 (parse_url() does not recognize //). (Andrew Faulds). - . Fixed bug #62829 (stdint.h included on platform where HAVE_STDINT_H is not - set). (Felipe) - . Fixed bug #62763 (register_shutdown_function and extending class). - (Laruence) - . Fixed bug #62725 (Calling exit() in a shutdown function does not return - the exit value). (Laruence) - . Fixed bug #62744 (dangling pointers made by zend_disable_class). (Laruence) - . Fixed bug #62716 (munmap() is called with the incorrect length). - (slangley@google.com) - . Fixed bug #62358 (Segfault when using traits a lot). (Laruence) - . Fixed bug #62328 (implementing __toString and a cast to string fails) - (Laruence) - . Fixed bug #51363 (Fatal error raised by var_export() not caught by error - handler). (Lonny Kapelushnik) - . Fixed bug #40459 (Stat and Dir stream wrapper methods do not call - constructor). (Stas) - -- CURL: - . Fixed bug #62912 (CURLINFO_PRIMARY_* AND CURLINFO_LOCAL_* not exposed). - (Pierrick) - . Fixed bug #62839 (curl_copy_handle segfault with CURLOPT_FILE). (Pierrick) - -- Intl: - . Fixed Spoofchecker not being registered on ICU 49.1. (Gustavo) - . Fix bug #62933 (ext/intl compilation error on icu 3.4.1). (Gustavo) - . Fix bug #62915 (defective cloning in several intl classes). (Gustavo) - -- Installation: - . Fixed bug #62460 (php binaries installed as binary.dSYM). (Reeze Xia) - -- PCRE: - . Fixed bug #55856 (preg_replace should fail on trailing garbage). - (reg dot php at alf dot nu) - -- PDO: - . Fixed bug #62685 (Wrong return datatype in PDO::inTransaction()). (Laruence) - -- Reflection: - . Fixed bug #62892 (ReflectionClass::getTraitAliases crashes on importing - trait methods as private). (Felipe) - . Fixed bug #62715 (ReflectionParameter::isDefaultValueAvailable() wrong - result). (Laruence) - -- Session: - . Fixed bug (segfault due to retval is not initialized). (Laruence) - . Fixed bug (segfault due to PS(mod_user_implemented) not be reseted - when close handler call exit). (Laruence) - -- SOAP - . Fixed bug #50997 (SOAP Error when trying to submit 2nd Element of a choice). - (Dmitry) - -- SPL: - . Fixed bug #62904 (Crash when cloning an object which inherits SplFixedArray) - (Laruence) - . Implemented FR #62840 (Add sort flag to ArrayObject::ksort). (Laruence) - -- Standard: - . Fixed bug #62836 (Seg fault or broken object references on unserialize()). - (Laruence) - -- FPM: - . Merged PR 121 by minitux to add support for slow request counting on PHP - FPM status page. (Lars) - -16 Aug 2012, PHP 5.4.6 - -- CLI Server: - . Implemented FR #62700 (have the console output 'Listening on - http://localhost:8000'). (pascal.chevrel@free.fr) - -- Core: - . Fixed bug #62661 (Interactive php-cli crashes if include() is used in - auto_prepend_file). (Laruence) - . Fixed bug #62653: (unset($array[$float]) causes a crash). (Nikita Popov, - Laruence) - . Fixed bug #62565 (Crashes due non-initialized internal properties_table). - (Felipe) - . Fixed bug #60194 (--with-zend-multibyte and --enable-debug reports LEAK - with run-test.php). (Laruence) - -- CURL: - . Fixed bug #62499 (curl_setopt($ch, CURLOPT_COOKIEFILE, "") returns false). - (r.hampartsumyan@gmail.com, Laruence) - -- DateTime: - . Fixed Bug #62500 (Segfault in DateInterval class when extended). (Laruence) - -- Fileinfo: - . Fixed bug #61964 (finfo_open with directory causes invalid free). - (reeze.xia@gmail.com) - -- Intl: - . Fixed bug #62564 (Extending MessageFormatter and adding property causes - crash). (Felipe) - -- MySQLnd: - . Fixed bug #62594 (segfault in mysqlnd_res_meta::set_mode). (Laruence) - -- readline: - . Fixed bug #62612 (readline extension compilation fails with - sapi/cli/cli.h: No such file). (Johannes) - -- Reflection: - . Implemented FR #61602 (Allow access to name of constant used as default - value). (reeze.xia@gmail.com) - -- SimpleXML: - . Implemented FR #55218 Get namespaces from current node. (Lonny) - -- SPL: - . Fixed bug #62616 (ArrayIterator::count() from IteratorIterator instance - gives Segmentation fault). (Laruence, Gustavo) - . Fixed bug #61527 (ArrayIterator gives misleading notice on next() when - moved to the end). (reeze.xia@gmail.com) - -- Streams: - . Fixed bug #62597 (segfault in php_stream_wrapper_log_error with ZTS build). - (Laruence) - -- Zlib: - . Fixed bug #55544 (ob_gzhandler always conflicts with - zlib.output_compression). (Laruence) - -19 Jul 2012, PHP 5.4.5 - -- Core: - . Fixed bug #62443 (Crypt SHA256/512 Segfaults With Malformed - Salt). (Anthony Ferrara) - . Fixed bug #62432 (ReflectionMethod random corrupt memory on high - concurrent). (Johannes) - . Fixed bug #62373 (serialize() generates wrong reference to the object). - (Moriyoshi) - . Fixed bug #62357 (compile failure: (S) Arguments missing for built-in - function __memcmp). (Laruence) - . Fixed bug #61998 (Using traits with method aliases appears to result in - crash during execution). (Dmitry) - . Fixed bug #51094 (parse_ini_file() with INI_SCANNER_RAW cuts a value that - includes a semi-colon). (Pierrick) - . Fixed potential overflow in _php_stream_scandir (CVE-2012-2688). - (Jason Powell, Stas) - -- EXIF: - . Fixed information leak in ext exif (discovered by Martin Noga, - Matthew "j00ru" Jurczyk, Gynvael Coldwind) - -- FPM: - . Fixed bug #62205 (php-fpm segfaults (null passed to strstr)). (fat) - . Fixed bug #62160 (Add process.priority to set nice(2) priorities). (fat) - . Fixed bug #62153 (when using unix sockets, multiples FPM instances - . Fixed bug #62033 (php-fpm exits with status 0 on some failures to start). - (fat) - . Fixed bug #61839 (Unable to cross-compile PHP with --enable-fpm). (fat) - . Fixed bug #61835 (php-fpm is not allowed to run as root). (fat) - . Fixed bug #61295 (php-fpm should not fail with commented 'user' - . Fixed bug #61218 (FPM drops connection while receiving some binary values - in FastCGI requests). (fat) - . Fixed bug #61045 (fpm don't send error log to fastcgi clients). (fat) - for non-root start). (fat) - . Fixed bug #61026 (FPM pools can listen on the same address). (fat) - can be launched without errors). (fat) - -- Iconv: - . Fix bug #55042 (Erealloc in iconv.c unsafe). (Stas) - -- Intl: - . Fixed bug #62083 (grapheme_extract() memory leaks). (Gustavo) - . ResourceBundle constructor now accepts NULL for the first two arguments. - (Gustavo) - . Fixed bug #62081 (IntlDateFormatter constructor leaks memory when called - twice). (Gustavo) - . Fixed bug #62070 (Collator::getSortKey() returns garbage). (Gustavo) - . Fixed bug #62017 (datefmt_create with incorrectly encoded timezone leaks - pattern). (Gustavo) - . Fixed bug #60785 (memory leak in IntlDateFormatter constructor). (Gustavo) - -- JSON: - . Fixed bug #61359 (json_encode() calls too many reallocs). (Stas) - -- libxml: - . Fixed bug #62266 (Custom extension segfaults during xmlParseFile with FPM - SAPI). (Gustavo) - -- Phar: - . Fixed bug #62227 (Invalid phar stream path causes crash). (Felipe) - -- Readline: - . Fixed bug #62186 (readline fails to compile - void function should not - return a value). (Johannes) - -- Reflection: - . Fixed bug #62384 (Attempting to invoke a Closure more than once causes - segfault). (Felipe) - . Fixed bug #62202 (ReflectionParameter::getDefaultValue() memory leaks - with constant). (Laruence) - -- Sockets: - . Fixed bug #62025 (__ss_family was changed on AIX 5.3). (Felipe) - -- SPL: - . Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to - dot files). (Laruence) - . Fixed bug #62262 (RecursiveArrayIterator does not implement Countable). - (Nikita Popov) - -- XML Writer: - . Fixed bug #62064 (memory leak in the XML Writer module). - (jean-pierre dot lozi at lip6 dot fr) - -- Zip: - . Upgraded libzip to 0.10.1 (Anatoliy) - -14 Jun 2012, PHP 5.4.4 - -- COM: - . Fixed bug #62146 com_dotnet cannot be built shared. (Johannes) - -- CLI Server: - . Implemented FR #61977 (Need CLI web-server support for files with .htm & - svg extensions). (Sixd, Laruence) - . Improved performance while sending error page, this also fixed - bug #61785 (Memory leak when access a non-exists file without router). - (Laruence) - . Fixed bug #61546 (functions related to current script failed when chdir() - in cli sapi). (Laruence, reeze.xia@gmail.com) - -- Core: - . Fixed missing bound check in iptcparse(). (chris at chiappa.net) - . Fixed CVE-2012-2143. (Solar Designer) - . Fixed bug #62097 (fix for for bug #54547). (Gustavo) - . Fixed bug #62005 (unexpected behavior when incrementally assigning to a - member of a null object). (Laruence) - . Fixed bug #61978 (Object recursion not detected for classes that implement - JsonSerializable). (Felipe) - . Fixed bug #61991 (long overflow in realpath_cache_get()). (Anatoliy) - . Fixed bug #61922 (ZTS build doesn't accept zend.script_encoding config). - (Laruence) - . Fixed bug #61827 (incorrect \e processing on Windows) (Anatoliy) - . Fixed bug #61782 (__clone/__destruct do not match other methods when checking - access controls). (Stas) - . Fixed bug #61764 ('I' unpacks n as signed if n > 2^31-1 on LP64). (Gustavo) - . Fixed bug #61761 ('Overriding' a private static method with a different - signature causes crash). (Laruence) - . Fixed bug #61730 (Segfault from array_walk modifying an array passed by - reference). (Laruence) - . Fixed bug #61728 (PHP crash when calling ob_start in request_shutdown - phase). (Laruence) - . Fixed bug #61713 (Logic error in charset detection for htmlentities). - (Anatoliy) - . Fixed bug #61660 (bin2hex(hex2bin($data)) != $data). (Nikita Popov) - . Fixed bug #61650 (ini parser crashes when using ${xxxx} ini variables - (without apache2)). (Laruence) - . Fixed bug #61605 (header_remove() does not remove all headers). (Laruence) - . Fixed bug #54547 (wrong equality of string numbers). (Gustavo) - . Fixed bug #54197 ([PATH=] sections incompatibility with user_ini.filename - set to null). (Anatoliy) - . Changed php://fd to be available only for CLI. - -- CURL: - . Fixed bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction). - (Laruence) - -- Fileinfo - . Fixed bug #61812 (Uninitialised value used in libmagic). - (Laruence, Gustavo) - . Fixed bug #61566 failure caused by the posix lseek and read versions - under windows in cdf_read(). (Anatoliy) - . Fixed bug #61565 where php_stream_open_wrapper_ex tries to open a - directory descriptor under windows. (Anatoliy) - -- Intl - . Fixed bug #62082 (Memory corruption in internal function - get_icu_disp_value_src_php()). (Gustavo) - -- Libxml: - . Fixed bug #61617 (Libxml tests failed(ht is already destroyed)). - (Laruence) - -- PDO: - . Fixed bug #61755 (A parsing bug in the prepared statements can lead to - access violations). (Johannes) - -- Phar: - . Fixed bug #61065 (Secunia SA44335, CVE-2012-2386). (Rasmus) - -- Pgsql: - . Added pg_escape_identifier/pg_escape_literal. (Yasuo Ohgaki) - -- Streams: - . Fixed bug #61961 (file_get_contents leaks when access empty file with - maxlen set). (Reeze) - -- Zlib: - . Fixed bug #61820 (using ob_gzhandler will complain about headers already - sent when no compression). (Mike) - . Fixed bug #61443 (can't change zlib.output_compression on the fly). (Mike) - . Fixed bug #60761 (zlib.output_compression fails on refresh). (Mike) - -08 May 2012, PHP 5.4.3 - -- CGI - . Re-Fix PHP-CGI query string parameter vulnerability, CVE-2012-1823. - (Stas) - . Fix bug #61807 - Buffer Overflow in apache_request_headers. - (nyt-php at countercultured dot net). - -03 May 2012, PHP 5.4.2 - -- Fix PHP-CGI query string parameter vulnerability, CVE-2012-1823. (Rasmus) - -26 Apr 2012, PHP 5.4.1 - -- CLI Server: - . Fixed bug #61461 (missing checks around malloc() calls). (Ilia) - . Implemented FR #60850 (Built in web server does not set - $_SERVER['SCRIPT_FILENAME'] when using router). (Laruence) - . "Connection: close" instead of "Connection: closed" (Gustavo) - -- Core: - . Fixed crash in ZTS using same class in many threads. (Johannes) - . Fixed bug #61374 (html_entity_decode tries to decode code points that don't - exist in ISO-8859-1). (Gustavo) - . Fixed bug #61273 (call_user_func_array with more than 16333 arguments - leaks / crashes). (Laruence) - . Fixed bug #61225 (Incorrect lexing of 0b00*+). (Pierrick) - . Fixed bug #61165 (Segfault - strip_tags()). (Laruence) - . Fixed bug #61106 (Segfault when using header_register_callback). (Nikita - Popov) - . Fixed bug #61087 (Memory leak in parse_ini_file when specifying - invalid scanner mode). (Nikic, Laruence) - . Fixed bug #61072 (Memory leak when restoring an exception handler). - (Nikic, Laruence) - . Fixed bug #61058 (array_fill leaks if start index is PHP_INT_MAX). - (Laruence) - . Fixed bug #61052 (Missing error check in trait 'insteadof' clause). (Stefan) - . Fixed bug #61011 (Crash when an exception is thrown by __autoload - accessing a static property). (Laruence) - . Fixed bug #61000 (Exceeding max nesting level doesn't delete numerical - vars). (Laruence) - . Fixed bug #60978 (exit code incorrect). (Laruence) - . Fixed bug #60911 (Confusing error message when extending traits). (Stefan) - . Fixed bug #60801 (strpbrk() mishandles NUL byte). (Adam) - . Fixed bug #60717 (Order of traits in use statement can cause a fatal - error). (Stefan) - . Fixed bug #60573 (type hinting with "self" keyword causes weird errors). - (Laruence) - . Fixed bug #60569 (Nullbyte truncates Exception $message). (Ilia) - . Fixed bug #52719 (array_walk_recursive crashes if third param of the - function is by reference). (Nikita Popov) - . Improve performance of set_exception_handler while doing reset (Laruence) - -- fileinfo: - . Fix fileinfo test problems. (Anatoliy Belsky) - -- FPM - . Fixed bug #61430 (Transposed memset() params in sapi/fpm/fpm/fpm_shm.c). - (michaelhood at gmail dot com, Ilia) - -- Ibase - . Fixed bug #60947 (Segmentation fault while executing ibase_db_info). - (Ilia) - -- Installation - . Fixed bug #61172 (Add Apache 2.4 support). (Chris Jones) - -- Intl: - . Fixed bug #61487 (Incorrent bounds checking in grapheme_strpos). - (Stas) - -- mbstring: - . MFH mb_ereg_replace_callback() for security enhancements. (Rui) - -- mysqli - . Fixed bug #61003 (mysql_stat() require a valid connection). (Johannes). - -- mysqlnd - . Fixed bug #61704 (Crash apache, phpinfo() threading issue). (Johannes) - . Fixed bug #60948 (mysqlnd FTBFS when -Wformat-security is enabled). - (Johannes) - -- PDO - . Fixed bug #61292 (Segfault while calling a method on an overloaded PDO - object). (Laruence) - -- PDO_mysql - . Fixed bug #61207 (PDO::nextRowset() after a multi-statement query doesn't - always work). (Johannes) - . Fixed bug #61194 (PDO should export compression flag with myslqnd). - (Johannes) - -- PDO_odbc - . Fixed bug #61212 (PDO ODBC Segfaults on SQL_SUCESS_WITH_INFO). (Ilia) - -- Phar - . Fixed bug #61184 (Phar::webPhar() generates headers with trailing NUL - bytes). (Nikita Popov) - -- Readline: - . Fixed bug #61088 (Memory leak in readline_callback_handler_install). - (Nikic, Laruence) - -- Reflection: - . Implemented FR #61602 (Allow access to the name of constant - used as function/method parameter's default value). (reeze.xia@gmail.com) - . Fixed bug #60968 (Late static binding doesn't work with - ReflectionMethod::invokeArgs()). (Laruence) - -- Session - . Fixed bug #60634 (Segmentation fault when trying to die() in - SessionHandler::write()). (Ilia) - -- SOAP - . Fixed bug #61423 (gzip compression fails). (Ilia) - . Fixed bug #60887 (SoapClient ignores user_agent option and sends no - User-Agent header). (carloschilazo at gmail dot com) - . Fixed bug #60842, #51775 (Chunked response parsing error when - chunksize length line is > 10 bytes). (Ilia) - . Fixed bug #49853 (Soap Client stream context header option ignored). - (Dmitry) - -- SPL: - . Fixed bug #61453 (SplObjectStorage does not identify objects correctly). - (Gustavo) - . Fixed bug #61347 (inconsistent isset behavior of Arrayobject). (Laruence) - -- Standard: - . Fixed memory leak in substr_replace. (Pierrick) - . Make max_file_uploads ini directive settable outside of php.ini (Rasmus) - . Fixed bug #61409 (Bad formatting on phpinfo()). (Jakub Vrana) - . Fixed bug #60222 (time_nanosleep() does validate input params). (Ilia) - . Fixed bug #60106 (stream_socket_server silently truncates long unix socket - paths). (Ilia) - -- XMLRPC: - . Fixed bug #61264 (xmlrpc_parse_method_descriptions leaks temporary - variable). (Nikita Popov) - . Fixed bug #61097 (Memory leak in xmlrpc functions copying zvals). (Nikita - Popov) - -- Zlib: - . Fixed bug #61306 (initialization of global inappropriate for ZTS). (Gustavo) - . Fixed bug #61287 (A particular string fails to decompress). (Mike) - . Fixed bug #61139 (gzopen leaks when specifying invalid mode). (Nikita Popov) - -01 Mar 2012, PHP 5.4.0 - -- Installation: - . autoconf 2.59+ is now supported (and required) for generating the - configure script with ./buildconf. Autoconf 2.60+ is desirable - otherwise the configure help order may be incorrect. (Rasmus, Chris Jones) - -- Removed legacy features: - . break/continue $var syntax. (Dmitry) - . Safe mode and all related php.ini options. (Kalle) - . register_globals and register_long_arrays php.ini options. (Kalle) - . import_request_variables(). (Kalle) - . allow_call_time_pass_reference. (Pierrick) - . define_syslog_variables php.ini option and its associated function. (Kalle) - . highlight.bg php.ini option. (Kalle) - . safe_mode, safe_mode_gid, safe_mode_include_dir, - safe_mode_exec_dir, safe_mode_allowed_env_vars and - safe_mode_protected_env_vars php.ini options. - . zend.ze1_compatibility_mode php.ini option. - . Session bug compatibility mode (session.bug_compat_42 and - session.bug_compat_warn php.ini options). (Kalle) - . session_is_registered(), session_register() and session_unregister() - functions. (Kalle) - . y2k_compliance php.ini option. (Kalle) - . magic_quotes_gpc, magic_quotes_runtime and magic_quotes_sybase - php.ini options. get_magic_quotes_gpc, get_magic_quotes_runtime are kept - but always return false, set_magic_quotes_runtime raises an - E_CORE_ERROR. (Pierrick, Pierre) - . Removed support for putenv("TZ=..") for setting the timezone. (Derick) - . Removed the timezone guessing algorithm in case the timezone isn't set with - date.timezone or date_default_timezone_set(). Instead of a guessed - timezone, "UTC" is now used instead. (Derick) - -- Moved extensions to PECL: - . ext/sqlite. (Note: the ext/sqlite3 and ext/pdo_sqlite extensions are - not affected) (Johannes) - -- General improvements: - . Added short array syntax support ([1,2,3]), see UPGRADING guide for full - details. (rsky0711 at gmail . com, sebastian.deutsch at 9elements . com, - Pierre) - . Added binary number format (0b001010). (Jonah dot Harris at gmail dot com) - . Added support for Class::{expr}() syntax (Pierrick) - . Added multibyte support by default. Previously PHP had to be compiled - with --enable-zend-multibyte. Now it can be enabled or disabled through - the zend.multibyte directive in php.ini. (Dmitry) - . Removed compile time dependency from ext/mbstring (Dmitry) - . Added support for Traits. (Stefan, with fixes by Dmitry and Laruence) - . Added closure $this support back. (Stas) - . Added array dereferencing support. (Felipe) - . Added callable typehint. (Hannes) - . Added indirect method call through array. FR #47160. (Felipe) - . Added DTrace support. (David Soria Parra) - . Added class member access on instantiation (e.g. (new foo)->bar()) support. - (Felipe) - . ). (Etienne) - . Fixed bug #60965 (Buffer overflow on htmlspecialchars/entities with - $double=false). (Gustavo) - . Fixed bug #60895 (Possible invalid handler usage in windows random - functions). (Pierre) - . Fixed bug #60879 (unserialize() Does not invoke __wakeup() on object). - (Pierre, Steve) - . Fixed bug #60825 (Segfault when running symfony 2 tests). - (Dmitry, Laruence) - . Fixed bug #60627 (httpd.worker segfault on startup with php_value). - . Fixed bug #60613 (Segmentation fault with $cls->{expr}() syntax). (Dmitry) - . Fixed bug #60611 (Segmentation fault with Cls::{expr}() syntax). (Laruence) - (Laruence) - . Fixed bug #60558 (Invalid read and writes). (Laruence) - . Fixed bug #60444 (Segmentation fault with include & class extending). - (Laruence, Dmitry). - . Fixed bug #60362 (non-existent sub-sub keys should not have values). - (Laruence, alan_k, Stas) - . Fixed bug #60350 (No string escape code for ESC (ascii 27), normally \e). - (php at mickweiss dot com) - . Fixed bug #60321 (ob_get_status(true) no longer returns an array when - buffer is empty). (Pierrick) - . Fixed bug #60282 (Segfault when using ob_gzhandler() with open buffers). - (Laruence) - . Fixed bug #60240 (invalid read/writes when unserializing specially crafted - strings). (Mike) - . Fixed bug #60227 (header() cannot detect the multi-line header with - CR(0x0D)). (rui) - . Fixed bug #60174 (Notice when array in method prototype error). - (Laruence) - . Fixed bug #60169 (Conjunction of ternary and list crashes PHP). - (Laruence) - . Fixed bug #60038 (SIGALRM cause segfault in php_error_cb). (Laruence) - (klightspeed at netspace dot net dot au) - . Fixed bug #55871 (Interruption in substr_replace()). (Stas) - . Fixed bug #55801 (Behavior of unserialize has changed). (Mike) - . Fixed bug #55758 (Digest Authenticate missed in 5.4) . (Laruence) - . Fixed bug #55748 (multiple NULL Pointer Dereference with zend_strndup()) - (CVE-2011-4153). (Stas) - . Fixed bug #55124 (recursive mkdir fails with current (dot) directory in path). - (Pierre) - . Fixed bug #55084 (Function registered by header_register_callback is - called only once per process). (Hannes) - . Implement FR #54514 (Get php binary path during script execution). - (Laruence) - . Fixed bug #52211 (iconv() returns part of string on error). (Felipe) - . Fixed bug #51860 (Include fails with toplevel symlink to /). (Dmitry) - -- Improved generic SAPI support: - . Added $_SERVER['REQUEST_TIME_FLOAT'] to include microsecond precision. - (Patrick) - . Added header_register_callback() which is invoked immediately - prior to the sending of headers and after default headers have - been added. (Scott) - . Added http_response_code() function. FR #52555. (Paul Dragoonis, Kalle) - . Fixed bug #55500 (Corrupted $_FILES indices lead to security concern). - (CVE-2012-1172). (Stas) - . Fixed bug #54374 (Insufficient validating of upload name leading to - corrupted $_FILES indices). (CVE-2012-1172). (Stas, lekensteyn at gmail dot com) - -- Improved CLI SAPI: - . Added built-in web server that is intended for testing purpose. - (Moriyoshi, Laruence, and fixes by Pierre, Derick, Arpad, - chobieee at gmail dot com) - . Added command line option --rz which shows information of the - named Zend extension. (Johannes) - . Interactive readline shell improvements: (Johannes) - . Added "cli.pager" php.ini setting to set a pager for output. - . Added "cli.prompt" php.ini setting to configure the shell prompt. - . Added shortcut #inisetting=value to change php.ini settings at run-time. - . Changed shell not to terminate on fatal errors. - . Interactive shell works with shared readline extension. FR #53878. - -- Improved CGI/FastCGI SAPI: (Dmitry) - . Added apache compatible functions: apache_child_terminate(), - getallheaders(), apache_request_headers() and apache_response_headers() - . Improved performance of FastCGI request parsing. - . Fixed reinitialization of SAPI callbacks after php_module_startup(). - (Dmitry) - -- Improved PHP-FPM SAPI: - . Removed EXPERIMENTAL flag. (fat) - . Fixed bug #60659 (FPM does not clear auth_user on request accept). - (bonbons at linux-vserver dot org) - -- Improved Litespeed SAPI: - . Fixed bug #55769 (Make Fails with "Missing Separator" error). (Adam) - -- Improved Date extension: - . Added the + modifier to parseFromFormat to allow trailing text in the - string to parse without throwing an error. (Stas, Derick) - -- Improved DBA extension: - . Added Tokyo Cabinet abstract DB support. (Michael Maclean) - . Added Berkeley DB 5 support. (Johannes, Chris Jones) - -- Improved DOM extension: - . Added the ability to pass options to loadHTML (Chregu, fxmulder at gmail dot com) - -- Improved filesystem functions: - . scandir() now accepts SCANDIR_SORT_NONE as a possible sorting_order value. - FR #53407. (Adam) - -- Improved HASH extension: - . Added Jenkins's one-at-a-time hash support. (Martin Jansen) - . Added FNV-1 hash support. (Michael Maclean) - . Made Adler32 algorithm faster. FR #53213. (zavasek at yandex dot ru) - . Removed Salsa10/Salsa20, which are actually stream ciphers (Mike) - . Fixed bug #60221 (Tiger hash output byte order) (Mike) - -- Improved intl extension: - . Added Spoofchecker class, allows checking for visibly confusable characters and - other security issues. (Scott) - . Added Transliterator class, allowing transliteration of strings. - (Gustavo) - . Added support for UTS #46. (Gustavo) - . Fixed build on Fedora 15 / Ubuntu 11. (Hannes) - . Fixed bug #55562 (grapheme_substr() returns false on big length). (Stas) - -- Improved JSON extension: - . Added new json_encode() option JSON_UNESCAPED_UNICODE. FR #53946. - (Alexander, Gwynne) - . Added JsonSerializable interface. (Sara) - . Added JSON_BIGINT_AS_STRING, extended json_decode() sig with $options. - (Sara) - . Added support for JSON_NUMERIC_CHECK option in json_encode() that converts - numeric strings to integers. (Ilia) - . Added new json_encode() option JSON_UNESCAPED_SLASHES. FR #49366. (Adam) - . Added new json_encode() option JSON_PRETTY_PRINT. FR #44331. (Adam) - -- Improved LDAP extension: - . Added paged results support. FR #42060. (ando@OpenLDAP.org, - iarenuno@eteo.mondragon.edu, jeanseb@au-fil-du.net, remy.saissy@gmail.com) - -- Improved mbstring extension: - . Added Shift_JIS/UTF-8 Emoji (pictograms) support. (Rui) - . Added JIS X0213:2004 (Shift_JIS-2004, EUC-JP-2004, ISO-2022-JP-2004) - support. (Rui) - . Ill-formed UTF-8 check for security enhancements. (Rui) - . Added MacJapanese (Shift_JIS) and gb18030 encoding support. (Rui) - . Added encode/decode in hex format to mb_[en|de]code_numericentity(). (Rui) - . Added user JIS X0213:2004 (Shift_JIS-2004, EUC-JP-2004, ISO-2022-JP-2004) - support. (Rui) - . Added the user defined area for CP936 and CP950 (Rui). - . Fixed bug #60306 (Characters lost while converting from cp936 to utf8). - (Laruence) - -- Improved MySQL extensions: - . MySQL: Deprecated mysql_list_dbs(). FR #50667. (Andrey) - . mysqlnd: Added named pipes support. FR #48082. (Andrey) - . MySQLi: Added iterator support in MySQLi. mysqli_result implements - Traversable. (Andrey, Johannes) - . PDO_mysql: Removed support for linking with MySQL client libraries older - than 4.1. (Johannes) - . ext/mysql, mysqli and pdo_mysql now use mysqlnd by default. (Johannes) - . Fixed bug #55473 (mysql_pconnect leaks file descriptors on reconnect). - (Andrey, Laruence) - . Fixed bug #55653 (PS crash with libmysql when binding same variable as - param and out). (Laruence) - -- Improved OpenSSL extension: - . Added AES support. FR #48632. (yonas dot y at gmail dot com, Pierre) - . Added no padding option to openssl_encrypt()/openssl_decrypt(). (Scott) - . Use php's implementation for Windows Crypto API in - openssl_random_pseudo_bytes. (Pierre) - . On error in openssl_random_pseudo_bytes() made sure we set strong result - to false. (Scott) - . Fixed possible attack in SSL sockets with SSL 3.0 / TLS 1.0. - CVE-2011-3389. (Scott) - . Fixed bug #61124 (Crash when decoding an invalid base64 encoded string). - (me at ktamura dot com, Scott) - -- Improved PDO: - . Fixed PDO objects binary incompatibility. (Dmitry) - -- PDO DBlib driver: - . Added nextRowset support. - . Fixed bug #50755 (PDO DBLIB Fails with OOM). - -- Improved PostgreSQL extension: - . Added support for "extra" parameter for PGNotify(). - (r dot i dot k at free dot fr, Ilia) - -- Improved PCRE extension: - . Changed third parameter of preg_match_all() to optional. FR #53238. (Adam) - -- Improved Readline extension: - . Fixed bug #54450 (Enable callback support when built against libedit). - (fedora at famillecollet dot com, Hannes) - -- Improved Reflection extension: - . Added ReflectionClass::newInstanceWithoutConstructor() to create a new - instance of a class without invoking its constructor. FR #55490. - (Sebastian) - . Added ReflectionExtension::isTemporary() and - ReflectionExtension::isPersistent() methods. (Johannes) - . Added ReflectionZendExtension class. (Johannes) - . Added ReflectionClass::isCloneable(). (Felipe) - -- Improved Session extension: - . Expose session status via new function, session_status (FR #52982) (Arpad) - . Added support for object-oriented session handlers. (Arpad) - . Added support for storing upload progress feedback in session data. (Arnaud) - . Changed session.entropy_file to default to /dev/urandom or /dev/arandom if - either is present at compile time. (Rasmus) - . Fixed bug #60860 (session.save_handler=user without defined function core - dumps). (Felipe) - . Implement FR #60551 (session_set_save_handler should support a core's - session handler interface). (Arpad) - . Fixed bug #60640 (invalid return values). (Arpad) - -- Improved SNMP extension (Boris Lytochkin): - . Added OO API. FR #53594 (php-snmp rewrite). - . Sanitized return values of existing functions. Now it returns FALSE on - failure. - . Allow ~infinite OIDs in GET/GETNEXT/SET queries. Autochunk them to max_oids - upon request. - . Introducing unit tests for extension with ~full coverage. - . IPv6 support. (FR #42918) - . Way of representing OID value can now be changed when SNMP_VALUE_OBJECT - is used for value output mode. Use or'ed SNMP_VALUE_LIBRARY(default if - not specified) or SNMP_VALUE_PLAIN. (FR #54502) - . Fixed bug #60749 (SNMP module should not strip non-standard SNMP port - from hostname). (Boris Lytochkin) - . Fixed bug #60585 (php build fails with USE flag snmp when IPv6 support - is disabled). (Boris Lytochkin) - . Fixed bug #53862 (snmp_set_oid_output_format does not allow returning to default) - . Fixed bug #46065 (snmp_set_quick_print() persists between requests) - . Fixed bug #45893 (Snmp buffer limited to 2048 char) - . Fixed bug #44193 (snmp v3 noAuthNoPriv doesn't work) - -- Improved SOAP extension: - . Added new SoapClient option "keep_alive". FR #60329. (Pierrick) - . Fixed basic HTTP authentication for WSDL sub requests. (Dmitry) - -- Improved SPL extension: - . Added RegexIterator::getRegex() method. (Joshua Thijssen) - . Added SplObjectStorage::getHash() hook. (Etienne) - . Added CallbackFilterIterator and RecursiveCallbackFilterIterator. (Arnaud) - . Added missing class_uses(..) as pointed out by #55266 (Stefan) - . Immediately reject wrong usages of directories under Spl(Temp)FileObject - and friends. (Etienne, Pierre) - . FilesystemIterator, GlobIterator and (Recursive)DirectoryIterator now use - the default stream context. (Hannes) - . Fixed bug #60201 (SplFileObject::setCsvControl does not expose third - argument via Reflection). (Peter) - . Fixed bug #55287 (spl_classes() not includes CallbackFilter classes) - (sasezaki at gmail dot com, salathe) - -- Improved Sysvshm extension: - . Fixed bug #55750 (memory copy issue in sysvshm extension). - (Ilia, jeffhuang9999 at gmail dot com) - -- Improved Tidy extension: - . Fixed bug #54682 (Tidy::diagnose() NULL pointer dereference). - (Maksymilian Arciemowicz, Felipe) - -- Improved Tokenizer extension: - . Fixed bug #54089 (token_get_all with regards to __halt_compiler is - not binary safe). (Nikita Popov) - -- Improved XSL extension: - . Added XsltProcessor::setSecurityPrefs($options) and getSecurityPrefs() to - define forbidden operations within XSLT stylesheets, default is not to - enable write operations from XSLT. Bug #54446 (Chregu, Nicolas Gregoire) - . XSL doesn't stop transformation anymore, if a PHP function can't be called - (Christian) - -- Improved ZLIB extension: - . Re-implemented non-file related functionality. (Mike) - . Fixed bug #55544 (ob_gzhandler always conflicts with zlib.output_compression). - (Mike) - -14 Jun 2012, PHP 5.3.14 - -- CLI SAPI: - . Fixed bug #61546 (functions related to current script failed when chdir() - in cli sapi). (Laruence, reeze.xia@gmail.com) - -- CURL: - . Fixed bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction). - (Laruence) - -- COM: - . Fixed bug #62146 com_dotnet cannot be built shared. (Johannes) - -- Core: - . Fixed CVE-2012-2143. (Solar Designer) - . Fixed missing bound check in iptcparse(). (chris at chiappa.net) - . Fixed bug #62373 (serialize() generates wrong reference to the object). - (Moriyoshi) - . Fixed bug #62005 (unexpected behavior when incrementally assigning to a - member of a null object). (Laruence) - . Fixed bug #61991 (long overflow in realpath_cache_get()). (Anatoliy) - . Fixed bug #61764 ('I' unpacks n as signed if n > 2^31-1 on LP64). (Gustavo) - . Fixed bug #61730 (Segfault from array_walk modifying an array passed by - reference). (Laruence) - . Fixed bug #61713 (Logic error in charset detection for htmlentities). - (Anatoliy) - . Fixed bug #54197 ([PATH=] sections incompatibility with user_ini.filename - set to null). (Anatoliy) - . Changed php://fd to be available only for CLI. - -- Fileinfo: - . Fixed bug #61812 (Uninitialised value used in libmagic). - (Laruence, Gustavo) - -- Iconv extension: - . Fixed a bug that iconv extension fails to link to the correct library - when another extension makes use of a library that links to the iconv - library. See https://bugs.gentoo.org/show_bug.cgi?id=364139 for detail. - (Moriyoshi) - -- Intl: - . Fixed bug #62082 (Memory corruption in internal function - get_icu_disp_value_src_php()). (Gustavo) - -- JSON - . Fixed bug #61537 (json_encode() incorrectly truncates/discards - information). (Adam) - -- PDO: - . Fixed bug #61755 (A parsing bug in the prepared statements can lead to - access violations). (Johannes) - -- Phar: - . Fix bug #61065 (Secunia SA44335). (Rasmus) - -- Streams: - . Fixed bug #61961 (file_get_contents leaks when access empty file with - maxlen set). (Reeze) - -08 May 2012, PHP 5.3.13 -- CGI - . Improve fix for PHP-CGI query string parameter vulnerability, CVE-2012-2311. - (Stas) - -03 May 2012, PHP 5.3.12 -- Fix PHP-CGI query string parameter vulnerability, CVE-2012-1823. (Rasmus) - -26 Apr 2012, PHP 5.3.11 - -- Core: - . Fixed bug #61605 (header_remove() does not remove all headers). - (Laruence) - . Fixed bug #61541 (Segfault when using ob_* in output_callback). - (reeze.xia@gmail.com) - . Fixed bug #61273 (call_user_func_array with more than 16333 arguments - leaks / crashes). (Laruence) - . Fixed bug #61165 (Segfault - strip_tags()). (Laruence) - . Improved max_input_vars directive to check nested variables (Dmitry). - . Fixed bug #61095 (Incorect lexing of 0x00*+). (Etienne) - . Fixed bug #61087 (Memory leak in parse_ini_file when specifying - invalid scanner mode). (Nikic, Laruence) - . Fixed bug #61072 (Memory leak when restoring an exception handler). - (Nikic, Laruence) - . Fixed bug #61058 (array_fill leaks if start index is PHP_INT_MAX). - (Laruence) - . Fixed bug #61043 (Regression in magic_quotes_gpc fix for CVE-2012-0831). - (Ondřej Surý) - . Fixed bug #61000 (Exceeding max nesting level doesn't delete numerical - vars). (Laruence) - . Fixed bug #60895 (Possible invalid handler usage in windows random - functions). (Pierre) - . Fixed bug #60825 (Segfault when running symfony 2 tests). - (Dmitry, Laruence) - . Fixed bug #60801 (strpbrk() mishandles NUL byte). (Adam) - . Fixed bug #60569 (Nullbyte truncates Exception $message). (Ilia) - . Fixed bug #60227 (header() cannot detect the multi-line header with CR). - (rui, Gustavo) - . Fixed bug #60222 (time_nanosleep() does validate input params). (Ilia) - . Fixed bug #54374 (Insufficient validating of upload name leading to - corrupted $_FILES indices). (CVE-2012-1172). (Stas, lekensteyn at - gmail dot com, Pierre) - . Fixed bug #52719 (array_walk_recursive crashes if third param of the - function is by reference). (Nikita Popov) - . Fixed bug #51860 (Include fails with toplevel symlink to /). (Dmitry) - -- DOM - . Added debug info handler to DOM objects. (Gustavo, Joey Smith) - -- FPM - . Fixed bug #61430 (Transposed memset() params in sapi/fpm/fpm/fpm_shm.c). - (michaelhood at gmail dot com, Ilia) - -- Ibase - . Fixed bug #60947 (Segmentation fault while executing ibase_db_info). - (Ilia) - -- Installation - . Fixed bug #61172 (Add Apache 2.4 support). (Chris Jones) - -- Fileinfo - . Fixed bug #61173 (Unable to detect error from finfo constructor). (Gustavo) - -- Firebird Database extension (ibase): - . Fixed bug #60802 (ibase_trans() gives segfault when passing params). - -- Libxml: - . Fixed bug #61617 (Libxml tests failed(ht is already destroyed)). - (Laruence) - . Fixed bug #61367 (open_basedir bypass using libxml RSHUTDOWN). - (Tim Starling) - -- mysqli - . Fixed bug #61003 (mysql_stat() require a valid connection). (Johannes). - -- PDO_mysql - . Fixed bug #61207 (PDO::nextRowset() after a multi-statement query doesn't - always work). (Johannes) - . Fixed bug #61194 (PDO should export compression flag with myslqnd). - (Johannes) - -- PDO_odbc - . Fixed bug #61212 (PDO ODBC Segfaults on SQL_SUCESS_WITH_INFO). (Ilia) - -- PDO_pgsql - . Fixed bug #61267 (pdo_pgsql's PDO::exec() returns the number of SELECTed - rows on postgresql >= 9). (ben dot pineau at gmail dot com) - -- PDO_Sqlite extension: - . Add createCollation support. (Damien) - -- Phar: - . Fixed bug #61184 (Phar::webPhar() generates headers with trailing NUL - bytes). (Nikic) - -- PHP-FPM SAPI: - . Fixed bug #60811 (php-fpm compilation problem). (rasmus) - -- Readline: - . Fixed bug #61088 (Memory leak in readline_callback_handler_install). - (Nikic, Laruence) - . Add open_basedir checks to readline_write_history and readline_read_history. - (Rasmus, reported by Mateusz Goik) - -- Reflection: - . Fixed bug #61388 (ReflectionObject:getProperties() issues invalid reads - when get_properties returns a hash table with (inaccessible) dynamic - numeric properties). (Gustavo) - . Fixed bug #60968 (Late static binding doesn't work with - ReflectionMethod::invokeArgs()). (Laruence) - -- SOAP - . Fixed basic HTTP authentication for WSDL sub requests. (Dmitry) - . Fixed bug #60887 (SoapClient ignores user_agent option and sends no - User-Agent header). (carloschilazo at gmail dot com) - . Fixed bug #60842, #51775 (Chunked response parsing error when - chunksize length line is > 10 bytes). (Ilia) - . Fixed bug #49853 (Soap Client stream context header option ignored). - (Dmitry) - -- SPL - . Fixed memory leak when calling SplFileInfo's constructor twice. (Felipe) - . Fixed bug #61418 (Segmentation fault when DirectoryIterator's or - FilesystemIterator's iterators are requested more than once without - having had its dtor callback called in between). (Gustavo) - . Fixed bug #61347 (inconsistent isset behavior of Arrayobject). (Laruence) - . Fixed bug #61326 (ArrayObject comparison). (Gustavo) - -- SQLite3 extension: - . Add createCollation() method. (Brad Dewar) - -- Session: - . Fixed bug #60860 (session.save_handler=user without defined function core - dumps). (Felipe) - . Fixed bug #60634 (Segmentation fault when trying to die() in - SessionHandler::write()). (Ilia) - -- Streams: - . Fixed bug #61371 (stream_context_create() causes memory leaks on use - streams_socket_create). (Gustavo) - . Fixed bug #61253 (Wrappers opened with errors concurrency problem on ZTS). - (Gustavo) - . Fixed bug #61115 (stream related segfault on fatal error in - php_stream_context_link). (Gustavo) - . Fixed bug #60817 (stream_get_line() reads from stream even when there is - already sufficient data buffered). stream_get_line() now behaves more like - fgets(), as is documented. (Gustavo) - . Further fix for bug #60455 (stream_get_line misbehaves if EOF is not - detected together with the last read). (Gustavo) - . Fixed bug #60106 (stream_socket_server silently truncates long unix - socket paths). (Ilia) - -- Tidy: - . Fixed bug #54682 (tidy null pointer dereference). (Tony, David Soria Parra) - -- XMLRPC: - . Fixed bug #61264 (xmlrpc_parse_method_descriptions leaks temporary - variable). (Nikita Popov) - . Fixed bug #61097 (Memory leak in xmlrpc functions copying zvals). (Nikic) - -- Zlib: - . Fixed bug #61139 (gzopen leaks when specifying invalid mode). (Nikic) - -02 Feb 2012, PHP 5.3.10 - -- Core: - . Fixed arbitrary remote code execution vulnerability reported by Stefan - Esser, CVE-2012-0830. (Stas, Dmitry) - -10 Jan 2012, PHP 5.3.9 - -- Core: - . Added max_input_vars directive to prevent attacks based on hash collisions - (CVE-2011-4885) (Dmitry). - . Fixed bug #60205 (possible integer overflow in content_length). (Laruence) - . Fixed bug #60139 (Anonymous functions create cycles not detected by the - GC). (Dmitry) - . Fixed bug #60138 (GC crash with referenced array in RecursiveArrayIterator) - (Dmitry). - . Fixed bug #60120 (proc_open's streams may hang with stdin/out/err when - the data exceeds or is equal to 2048 bytes). (Pierre, Pascal Borreli) - . Fixed bug #60099 (__halt_compiler() works in braced namespaces). (Felipe) - . Fixed bug #60019 (Function time_nanosleep() is undefined on OS X). (Ilia) - . Fixed bug #55874 (GCC does not provide __sync_fetch_and_add on some archs). - (klightspeed at netspace dot net dot au) - . Fixed bug #55798 (serialize followed by unserialize with numeric object - prop. gives integer prop). (Gustavo) - . Fixed bug #55749 (TOCTOU issue in getenv() on Windows builds). (Pierre) - . Fixed bug #55707 (undefined reference to `__sync_fetch_and_add_4' on Linux - parisc). (Felipe) - . Fixed bug #55674 (fgetcsv & str_getcsv skip empty fields in some - tab-separated records). (Laruence) - . Fixed bug #55649 (Undefined function Bug()). (Laruence) - . Fixed bug #55622 (memory corruption in parse_ini_string). (Pierre) - . Fixed bug #55576 (Cannot conditionally move uploaded file without race - condition). (Gustavo) - . Fixed bug #55510: $_FILES 'name' missing first character after upload. - (Arpad) - . Fixed bug #55509 (segfault on x86_64 using more than 2G memory). (Laruence) - . Fixed bug #55504 (Content-Type header is not parsed correctly on - HTTP POST request). (Hannes) - . Fixed bug #55475 (is_a() triggers autoloader, new optional 3rd argument to - is_a and is_subclass_of). (alan_k) - . Fixed bug #52461 (Incomplete doctype and missing xmlns). - (virsacer at web dot de, Pierre) - . Fixed bug #55366 (keys lost when using substr_replace an array). (Arpad) - . Fixed bug #55273 (base64_decode() with strict rejects whitespace after - pad). (Ilia) - . Fixed bug #52624 (tempnam() by-pass open_basedir with nonnexistent - directory). (Felipe) - . Fixed bug #50982 (incorrect assumption of PAGE_SIZE size). (Dmitry) - . Fixed invalid free in call_user_method() function. (Felipe) - . Fixed bug #43200 (Interface implementation / inheritence not possible in - abstract classes). (Felipe) - - -- BCmath: - . Fixed bug #60377 (bcscale related crashes on 64bits platforms). (shm) - -- Calendar: - . Fixed bug #55797 (Integer overflow in SdnToGregorian leads to segfault (in - optimized builds). (Gustavo) - -- cURL: - . Fixed bug #60439 (curl_copy_handle segfault when used with - CURLOPT_PROGRESSFUNCTION). (Pierrick) - . Fixed bug #54798 (Segfault when CURLOPT_STDERR file pointer is closed - before calling curl_exec). (Hannes) - . Fixed issues were curl_copy_handle() would sometimes lose copied - preferences. (Hannes) - -- DateTime: - . Fixed bug #60373 (Startup errors with log_errors on cause segfault). - (Derick) - . Fixed bug #60236 (TLA timezone dates are not converted properly from - timestamp). (Derick) - . Fixed bug #55253 (DateTime::add() and sub() result -1 hour on objects with - time zone type 2). (Derick) - . Fixed bug #54851 (DateTime::createFromFormat() doesn't interpret "D"). - (Derick) - . Fixed bug #53502 (strtotime with timezone memory leak). (Derick) - . Fixed bug #52062 (large timestamps with DateTime::getTimestamp and - DateTime::setTimestamp). (Derick) - . Fixed bug #51994 (date_parse_from_format is parsing invalid date using 'yz' - format). (Derick) - . Fixed bug #52113 (Seg fault while creating (by unserialization) - DatePeriod). (Derick) - . Fixed bug #48476 (cloning extended DateTime class without calling - parent::__constr crashed PHP). (Hannes) - -- EXIF: - . Fixed bug #60150 (Integer overflow during the parsing of invalid exif - header). (CVE-2011-4566) (Stas, flolechaud at gmail dot com) - -- Fileinfo: - . Fixed bug #60094 (C++ comment fails in c89). (Laruence) - . Fixed possible memory leak in finfo_open(). (Felipe) - . Fixed memory leak when calling the Finfo constructor twice. (Felipe) - -- Filter: - . Fixed Bug #55478 (FILTER_VALIDATE_EMAIL fails with internationalized - domain name addresses containing >1 -). (Ilia) - -- FTP: - . Fixed bug #60183 (out of sync ftp responses). (bram at ebskamp dot me, - rasmus) - -- Gd: - . Fixed bug #60160 (imagefill() doesn't work correctly - for small images). (Florian) - . Fixed potential memory leak on a png error (Rasmus, Paul Saab) - -- Intl: - . Fixed bug #60192 (SegFault when Collator not constructed - properly). (Florian) - . Fixed memory leak in several Intl locale functions. (Felipe) - -- Json: - . Fixed bug #55543 (json_encode() with JSON_NUMERIC_CHECK fails on objects - with numeric string properties). (Ilia, dchurch at sciencelogic dot com) - -- Mbstring: - . Fixed possible crash in mb_ereg_search_init() using empty pattern. (Felipe) - -- MS SQL: - . Fixed bug #60267 (Compile failure with freetds 0.91). (Felipe) - -- MySQL: - . Fixed bug #55550 (mysql.trace_mode miscounts result sets). (Johannes) - -- MySQLi extension: - . Fixed bug #55859 (mysqli->stat property access gives error). (Andrey) - . Fixed bug #55582 (mysqli_num_rows() returns always 0 for unbuffered, when - mysqlnd is used). (Andrey) - . Fixed bug #55703 (PHP crash when calling mysqli_fetch_fields). - (eran at zend dot com, Laruence) - -- mysqlnd - . Fixed bug #55609 (mysqlnd cannot be built shared). (Johannes) - . Fixed bug #55067 (MySQL doesn't support compression - wrong config option). - (Andrey) - -- NSAPI SAPI: - . Don't set $_SERVER['HTTPS'] on unsecure connection (bug #55403). (Uwe - Schindler) - -- OpenSSL: - . Fixed bug #60279 (Fixed NULL pointer dereference in - stream_socket_enable_crypto, case when ssl_handle of session_stream is not - initialized.) (shm) - . Fix segfault with older versions of OpenSSL. (Scott) - -- Oracle Database extension (OCI8): - . Fixed bug #59985 (show normal warning text for OCI_NO_DATA). - (Chris Jones) - . Increased maximum Oracle error message buffer length for new 11.2.0.3 size. - (Chris Jones) - . Improve internal initalization failure error messages. (Chris Jones) - -- PDO - . Fixed bug #55776 (PDORow to session bug). (Johannes) - -- PDO Firebird: - . Fixed bug #48877 ("bindValue" and "bindParam" do not work for PDO Firebird). - (Mariuz) - . Fixed bug #47415 (PDO_Firebird segfaults when passing lowercased column name to bindColumn). - . Fixed bug #53280 (PDO_Firebird segfaults if query column count less than param count). - (Mariuz) - -- PDO MySQL driver: - . Fixed bug #60155 (pdo_mysql.default_socket ignored). (Johannes) - . Fixed bug #55870 (PDO ignores all SSL parameters when used with mysql - native driver). (Pierre) - . Fixed bug #54158 (MYSQLND+PDO MySQL requires #define - MYSQL_OPT_LOCAL_INFILE). (Andrey) - -- PDO OCI driver: - . Fixed bug #55768 (PDO_OCI can't resume Oracle session after it's been - killed). (mikhail dot v dot gavrilov at gmail dot com, Chris Jones, Tony) - -- Phar: - . Fixed bug #60261 (NULL pointer dereference in phar). (Felipe) - . Fixed bug #60164 (Stubs of a specific length break phar_open_from_fp - scanning for __HALT_COMPILER). (Ralph Schindler) - . Fixed bug #53872 (internal corruption of phar). (Hannes) - . Fixed bug #52013 (Unable to decompress files in a compressed phar). (Hannes) - -- PHP-FPM SAPI: - . Dropped restriction of not setting the same value multiple times, the last - one holds. (giovanni at giacobbi dot net, fat) - . Added .phar to default authorized extensions. (fat) - . Fixed bug #60659 (FPM does not clear auth_user on request accept). - (bonbons at linux-vserver dot org) - . Fixed bug #60629 (memory corruption when web server closed the fcgi fd). - (fat) - . Enhance error log when the primary script can't be open. FR #60199. (fat) - . Fixed bug #60179 (php_flag and php_value does not work properly). (fat) - . Fixed bug #55577 (status.html does not install). (fat) - . Fixed bug #55533 (The -d parameter doesn't work). (fat) - . Fixed bug #55526 (Heartbeat causes a lot of unnecessary events). (fat) - . Fixed bug #55486 (status show BIG processes number). (fat) - . Enhanced security by limiting access to user defined extensions. - FR #55181. (fat) - . Added process.max to control the number of process FPM can fork. FR #55166. - (fat) - . Implemented FR #54577 (Enhanced status page with full status and details - about each processes. Also provide a web page (status.html) for - real-time FPM status. (fat) - . Lowered default value for Process Manager. FR #54098. (fat) - . Implemented FR #52569 (Add the "ondemand" process-manager - to allow zero children). (fat) - . Added partial syslog support (on error_log only). FR #52052. (fat) - -- Postgres: - . Fixed bug #60244 (pg_fetch_* functions do not validate that row param - is >0). (Ilia) - . Added PGSQL_LIBPQ_VERSION/PGSQL_LIBPQ_VERSION_STR constants. (Yasuo) - -- Reflection: - . Fixed bug #60367 (Reflection and Late Static Binding). (Laruence) - -- Session: - . Fixed bug #55267 (session_regenerate_id fails after header sent). (Hannes) - -- SimpleXML: - . Reverted the SimpleXML->query() behaviour to returning empty arrays - instead of false when no nodes are found as it was since 5.3.3 - (bug #48601). (chregu, rrichards) - -- SOAP - . Fixed bug #54911 (Access to a undefined member in inherit SoapClient may - cause Segmentation Fault). (Dmitry) - . Fixed bug #48216 (PHP Fatal error: SOAP-ERROR: Parsing WSDL: - Extra content at the end of the doc, when server uses chunked transfer - encoding with spaces after chunk size). (Dmitry) - . Fixed bug #44686 (SOAP-ERROR: Parsing WSDL with references). (Dmitry) - -- Sockets: - . Fixed bug #60048 (sa_len a #define on IRIX). (china at thewrittenword dot - com) - -- SPL: - . Fixed bug #60082 (Crash in ArrayObject() when using recursive references). - (Tony) - . Fixed bug #55807 (Wrong value for splFileObject::SKIP_EMPTY). - (jgotti at modedemploi dot fr, Hannes) - . Fixed bug #54304 (RegexIterator::accept() doesn't work with scalar values). - (Hannes) - -- Streams: - . Fixed bug #60455 (stream_get_line misbehaves if EOF is not detected together - with the last read). (Gustavo) - -- Tidy: - . Fixed bug #54682 (Tidy::diagnose() NULL pointer dereference). - (Maksymilian Arciemowicz, Felipe) - -- XSL: - . Added xsl.security_prefs ini option to define forbidden operations within - XSLT stylesheets, default is not to enable write operations. This option - won't be in 5.4, since there's a new method. Fixes Bug #54446. (Chregu, - Nicolas Gregoire) - -23 Aug 2011, PHP 5.3.8 - -- Core: - . Fixed bug #55439 (crypt() returns only the salt for MD5). (Stas) - -- OpenSSL: - . Reverted a change in timeout handling restoring PHP 5.3.6 behavior, - as the new behavior caused mysqlnd SSL connections to hang (#55283). - (Pierre, Andrey, Johannes) - -18 Aug 2011, PHP 5.3.7 -- Upgraded bundled SQLite to version 3.7.7.1. (Scott) -- Upgraded bundled PCRE to version 8.12. (Scott) - -- Zend Engine: - . Fixed bug #55156 (ReflectionClass::getDocComment() returns comment even - though the class has none). (Felipe) - . Fixed bug #55007 (compiler fail after previous fail). (Felipe) - . Fixed bug #54910 (Crash when calling call_user_func with unknown function - name). (Dmitry) - . Fixed bug #54804 (__halt_compiler and imported namespaces). - (Pierrick, Felipe) - . Fixed bug #54624 (class_alias and type hint). (Felipe) - . Fixed bug #54585 (track_errors causes segfault). (Dmitry) - . Fixed bug #54423 (classes from dl()'ed extensions are not destroyed). - (Tony, Dmitry) - . Fixed bug #54372 (Crash accessing global object itself returned from its - __get() handle). (Dmitry) - . Fixed bug #54367 (Use of closure causes problem in ArrayAccess). (Dmitry) - . Fixed bug #54358 (Closure, use and reference). (Dmitry) - . Fixed bug #54262 (Crash when assigning value to a dimension in a non-array). - (Dmitry) - . Fixed bug #54039 (use() of static variables in lambda functions can break - staticness). (Dmitry) - -- Core - . Updated crypt_blowfish to 1.2. ((CVE-2011-2483) (Solar Designer) - . Removed warning when argument of is_a() or is_subclass_of() is not - a known class. (Stas) - . Fixed crash in error_log(). (Felipe) Reported by Mateusz Kocielski. - . Added PHP_MANDIR constant telling where the manpages were installed into, - and an --man-dir argument to php-config. (Hannes) - . Fixed a crash inside dtor for error handling. (Ilia) - . Fixed buffer overflow on overlog salt in crypt(). (Clément LECIGNE, Stas) - . Implemented FR #54459 (Range function accuracy). (Adam) - - . Fixed bug #55399 (parse_url() incorrectly treats ':' as a valid path). - (Ilia) - . Fixed bug #55339 (Segfault with allow_call_time_pass_reference = Off). - (Dmitry) - . Fixed bug #55295 [NEW]: popen_ex on windows, fixed possible heap overflow - (Pierre) - . Fixed bug #55258 (Windows Version Detecting Error). - ( xiaomao5 at live dot com, Pierre) - . Fixed bug #55187 (readlink returns weird characters when false result). - (Pierre) - . Fixed bug #55082 (var_export() doesn't escape properties properly). - (Gustavo) - . Fixed bug #55014 (Compile failure due to improper use of ctime_r()). (Ilia) - . Fixed bug #54939 (File path injection vulnerability in RFC1867 File upload - filename). (Felipe) Reported by Krzysztof Kotowicz. (CVE-2011-2202) - . Fixed bug #54935 php_win_err can lead to crash. (Pierre) - . Fixed bug #54924 (assert.* is not being reset upon request shutdown). (Ilia) - . Fixed bug #54895 (Fix compiling with older gcc version without need for - membar_producer macro). (mhei at heimpold dot de) - . Fixed bug #54866 (incorrect accounting for realpath_cache_size). - (Dustin Ward) - . Fixed bug #54723 (getimagesize() doesn't check the full ico signature). - (Scott) - . Fixed bug #54721 (Different Hashes on Windows, BSD and Linux on wrong Salt - size). (Pierre, os at irj dot ru) - . Fixed bug #54580 (get_browser() segmentation fault when browscap ini - directive is set through php_admin_value). (Gustavo) - . Fixed bug #54332 (Crash in zend_mm_check_ptr // Heap corruption). (Dmitry) - . Fixed bug #54305 (Crash in gc_remove_zval_from_buffer). (Dmitry) - . Fixed bug #54238 (use-after-free in substr_replace()). (Stas) - (CVE-2011-1148) - . Fixed bug #54204 (Can't set a value with a PATH section in php.ini). - (Pierre) - . Fixed bug #54180 (parse_url() incorrectly parses path when ? in fragment). - (tomas dot brastavicius at quantum dot lt, Pierrick) - . Fixed bug #54137 (file_get_contents POST request sends additional line - break). (maurice-php at mertinkat dot net, Ilia) - . Fixed bug #53848 (fgetcsv() ignores spaces at beginnings of fields). (Ilia) - . Alternative fix for bug #52550, as applied to the round() function (signed - overflow), as the old fix impacted the algorithm for numbers with magnitude - smaller than 0. (Gustavo) - . Fixed bug #53727 (Inconsistent behavior of is_subclass_of with interfaces) - (Ralph Schindler, Dmitry) - . Fixed bug #52935 (call exit in user_error_handler cause stream relate - core). (Gustavo) - . Fixed bug #51997 (SEEK_CUR with 0 value, returns a warning). (Ilia) - . Fixed bug #50816 (Using class constants in array definition fails). - (Pierrick, Dmitry) - . Fixed bug #50363 (Invalid parsing in convert.quoted-printable-decode - filter). (slusarz at curecanti dot org) - . Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using - TMPDIR on Windows). (Pierre) - -- Apache2 Handler SAPI: - . Fixed bug #54529 (SAPI crashes on apache_config.c:197). - (hebergement at riastudio dot fr) - -- CLI SAPI: - . Fixed bug #52496 (Zero exit code on option parsing failure). (Ilia) - -- cURL extension: - . Added ini option curl.cainfo (support for custom cert db). (Pierre) - . Added CURLINFO_REDIRECT_URL support. (Daniel Stenberg, Pierre) - . Added support for CURLOPT_MAX_RECV_SPEED_LARGE and - CURLOPT_MAX_SEND_SPEED_LARGE. FR #51815. (Pierrick) - -- DateTime extension: - . Fixed bug where the DateTime object got changed while using date_diff(). - (Derick) - . Fixed bug #54340 (DateTime::add() method bug). (Adam) - . Fixed bug #54316 (DateTime::createFromFormat does not handle trailing '|' - correctly). (Adam) - . Fixed bug #54283 (new DatePeriod(NULL) causes crash). (Felipe) - . Fixed bug #51819 (Case discrepancy in timezone names cause Uncaught - exception and fatal error). (Hannes) - -- DBA extension: - . Supress warning on non-existent file open with Berkeley DB 5.2. (Chris Jones) - . Fixed bug #54242 (dba_insert returns true if key already exists). (Felipe) - -- Exif extesion: - . Fixed bug #54121 (error message format string typo). (Ilia) - -- Fileinfo extension: - . Fixed bug #54934 (Unresolved symbol strtoull in HP-UX 11.11). (Felipe) - -- Filter extension: - . Added 3rd parameter to filter_var_array() and filter_input_array() - functions that allows disabling addition of empty elements. (Ilia) - . Fixed bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented). (Ilia) - -- Interbase extension: - . Fixed bug #54269 (Short exception message buffer causes crash). (Felipe) - -- intl extension: - . Implemented FR #54561 (Expose ICU version info). (David Zuelke, Ilia) - . Implemented FR #54540 (Allow loading of arbitrary resource bundles when - fallback is disabled). (David Zuelke, Stas) - -- Imap extension: - . Fixed bug #55313 (Number of retries not set when params specified). - (kevin at kevinlocke dot name) - -- json extension: - . Fixed bug #54484 (Empty string in json_decode doesn't reset - json_last_error()). (Ilia) - -- LDAP extension: - . Fixed bug #53339 (Fails to build when compilng with gcc 4.5 and DSO - libraries). (Clint Byrum, Raphael) - -- libxml extension: - . Fixed bug #54601 (Removing the doctype node segfaults). (Hannes) - . Fixed bug #54440 (libxml extension ignores default context). (Gustavo) - -- mbstring extension: - . Fixed bug #54494 (mb_substr() mishandles UTF-32LE and UCS-2LE). (Gustavo) - -- MCrypt extension: - . Change E_ERROR to E_WARNING in mcrypt_create_iv when not enough data - has been fetched (Windows). (Pierre) - . Fixed bug #55169 (mcrypt_create_iv always fails to gather sufficient random - data on Windows). (Pierre) - -- mysqlnd - . Fixed crash when using more than 28,000 bound parameters. Workaround is to - set mysqlnd.net_cmd_buffer_size to at least 9000. (Andrey) - . Fixed bug #54674 mysqlnd valid_sjis_(head|tail) is using invalid operator - and range). (nihen at megabbs dot com, Andrey) - -- MySQLi extension: - . Fixed bug #55283 (SSL options set by mysqli_ssl_set ignored for MySQLi - persistent connections). (Andrey) - . Fixed Bug #54221 (mysqli::get_warnings segfault when used in multi queries). - (Andrey) - -- OpenSSL extension: - . openssl_encrypt()/openssl_decrypt() truncated keys of variable length - ciphers to the OpenSSL default for the algorithm. (Scott) - . On blocking SSL sockets respect the timeout option where possible. - (Scott) - . Fixed bug #54992 (Stream not closed and error not returned when SSL - CN_match fails). (Gustavo, laird_ngrps at dodo dot com dot au) - -- Oracle Database extension (OCI8): - . Added oci_client_version() returning the runtime Oracle client library - version. (Chris Jones) - -. PCRE extension: - . Increased the backtrack limit from 100000 to 1000000 (Rasmus) - -- PDO extension: - . Fixed bug #54929 (Parse error with single quote in sql comment). (Felipe) - . Fixed bug #52104 (bindColumn creates Warning regardless of ATTR_ERRMODE - settings). (Ilia) - -- PDO DBlib driver: - . Fixed bug #54329 (MSSql extension memory leak). - (dotslashpok at gmail dot com) - . Fixed bug #54167 (PDO_DBLIB returns null on SQLUNIQUE field). - (mjh at hodginsmedia dot com, Felipe) - -- PDO ODBC driver: - . Fixed data type usage in 64bit. (leocsilva at gmail dot com) - -- PDO MySQL driver: - . Fixed bug #54644 (wrong pathes in php_pdo_mysql_int.h). (Tony, Johannes) - . Fixed bug #53782 (foreach throws irrelevant exception). (Johannes, Andrey) - . Implemented FR #48587 (MySQL PDO driver doesn't support SSL connections). - (Rob) - -- PDO PostgreSQL driver: - . Fixed bug #54318 (Non-portable grep option used in PDO pgsql - configuration). (bwalton at artsci dot utoronto dot ca) - -- PDO Oracle driver: - . Fixed bug #44989 (64bit Oracle RPMs still not supported by pdo-oci). - (jbnance at tresgeek dot net) - -- Phar extension: - . Fixed bug #54395 (Phar::mount() crashes when calling with wrong parameters). - (Felipe) - -- PHP-FPM SAPI: - . Implemented FR #54499 (FPM ping and status_path should handle HEAD request). (fat) - . Implemented FR #54172 (Overriding the pid file location of php-fpm). (fat) - . Fixed missing Expires and Cache-Control headers for ping and status pages. - (fat) - . Fixed memory leak. (fat) Reported and fixed by Giovanni Giacobbi. - . Fixed wrong value of log_level when invoking fpm with -tt. (fat) - . Added xml format to the status page. (fat) - . Removed timestamp in logs written by children processes. (fat) - . Fixed exit at FPM startup on fpm_resources_prepare() errors. (fat) - . Added master rlimit_files and rlimit_core in the global configuration - settings. (fat) - . Removed pid in debug logs written by chrildren processes. (fat) - . Added custom access log (also added per request %CPU and memory - mesurement). (fat) - . Added a real scoreboard and several improvements to the status page. (fat) - -- Reflection extension: - . Fixed bug #54347 (reflection_extension does not lowercase module function - name). (Felipe, laruence at yahoo dot com dot cn) - -- SOAP extension: - . Fixed bug #55323 (SoapClient segmentation fault when XSD_TYPEKIND_EXTENSION - contains itself). (Dmitry) - . Fixed bug #54312 (soap_version logic bug). (tom at samplonius dot org) - -- Sockets extension: - . Fixed stack buffer overflow in socket_connect(). (CVE-2011-1938) - Found by Mateusz Kocielski, Marek Kroemeke and Filip Palian. (Felipe) - . Changed socket_set_block() and socket_set_nonblock() so they emit warnings - on error. (Gustavo) - . Fixed bug #51958 (socket_accept() fails on IPv6 server sockets). (Gustavo) - -- SPL extension: - . Fixed bug #54971 (Wrong result when using iterator_to_array with use_keys - on true). (Pierrick) - . Fixed bug #54970 (SplFixedArray::setSize() isn't resizing). (Felipe) - . Fixed bug #54609 (Certain implementation(s) of SplFixedArray cause hard - crash). (Felipe) - . Fixed bug #54384 (Dual iterators, GlobIterator, SplFileObject and - SplTempFileObject crash when user-space classes don't call the paren - constructor). (Gustavo) - . Fixed bug #54292 (Wrong parameter causes crash in - SplFileObject::__construct()). (Felipe) - . Fixed bug #54291 (Crash iterating DirectoryIterator for dir name starting - with \0). (Gustavo) - . Fixed bug #54281 (Crash in non-initialized RecursiveIteratorIterator). - (Felipe) - -- Streams: - . Fixed bug #54946 (stream_get_contents infinite loop). (Hannes) - . Fixed bug #54623 (Segfault when writing to a persistent socket after - closing a copy of the socket). (Gustavo) - . Fixed bug #54681 (addGlob() crashes on invalid flags). (Felipe) - - -17 Mar 2011, PHP 5.3.6 -- Upgraded bundled Sqlite3 to version 3.7.4. (Ilia) -- Upgraded bundled PCRE to version 8.11. (Ilia) - -- Zend Engine: - . Indirect reference to $this fails to resolve if direct $this is never used - in method. (Scott) - . Added options to debug backtrace functions. (Stas) - . Fixed bug numerous crashes due to setlocale (crash on error, pcre, mysql - etc.) on Windows in thread safe mode. (Pierre) - . Fixed Bug #53971 (isset() and empty() produce apparently spurious runtime - error). (Dmitry) - . Fixed Bug #53958 (Closures can't 'use' shared variables by value and by - reference). (Dmitry) - . Fixed Bug #53629 (memory leak inside highlight_string()). (Hannes, Ilia) - . Fixed Bug #51458 (Lack of error context with nested exceptions). (Stas) - . Fixed Bug #47143 (Throwing an exception in a destructor causes a fatal - error). (Stas) - . Fixed bug #43512 (same parameter name can be used multiple times in - method/function definition). (Felipe) - -- Core: - . Added ability to connect to HTTPS sites through proxy with basic - authentication using stream_context/http/header/Proxy-Authorization (Dmitry) - . Changed default value of ini directive serialize_precision from 100 to 17. - (Gustavo) - . Fixed bug #54055 (buffer overrun with high values for precision ini - setting). (Gustavo) - . Fixed bug #53959 (reflection data for fgetcsv out-of-date). (Richard) - . Fixed bug #53577 (Regression introduced in 5.3.4 in open_basedir with a - trailing forward slash). (lekensteyn at gmail dot com, Pierre) - . Fixed bug #53682 (Fix compile on the VAX). (Rasmus, jklos) - . Fixed bug #48484 (array_product() always returns 0 for an empty array). - (Ilia) - . Fixed bug #48607 (fwrite() doesn't check reply from ftp server before - exiting). (Ilia) - - -- Calendar extension: - . Fixed bug #53574 (Integer overflow in SdnToJulian, sometimes leading to - segfault). (Gustavo) - -- DOM extension: - . Implemented FR #39771 (Made DOMDocument::saveHTML accept an optional DOMNode - like DOMDocument::saveXML). (Gustavo) - -- DateTime extension: - . Fixed a bug in DateTime->modify() where absolute date/time statements had - no effect. (Derick) - . Fixed bug #53729 (DatePeriod fails to initialize recurrences on 64bit - big-endian systems). (Derick, rein@basefarm.no) - . Fixed bug #52808 (Segfault when specifying interval as two dates). (Stas) - . Fixed bug #52738 (Can't use new properties in class extended from - DateInterval). (Stas) - . Fixed bug #52290 (setDate, setISODate, setTime works wrong when DateTime - created from timestamp). (Stas) - . Fixed bug #52063 (DateTime constructor's second argument doesn't have a - null default value). (Gustavo, Stas) - -- Exif extension: - . Fixed bug #54002 (crash on crafted tag, reported by Luca Carettoni). - (Pierre) (CVE-2011-0708) - -- Filter extension: - . Fixed bug #53924 (FILTER_VALIDATE_URL doesn't validate port number). - (Ilia, Gustavo) - . Fixed bug #53150 (FILTER_FLAG_NO_RES_RANGE is missing some IP ranges). - (Ilia) - . Fixed bug #52209 (INPUT_ENV returns NULL for set variables (CLI)). (Ilia) - . Fixed bug #47435 (FILTER_FLAG_NO_RES_RANGE don't work with ipv6). - (Ilia, valli at icsurselva dot ch) - -- Fileinfo extension: - . Fixed bug #54016 (finfo_file() Cannot determine filetype in archives). - (Hannes) - -- Gettext - . Fixed bug #53837 (_() crashes on Windows when no LANG or LANGUAGE - environment variable are set). (Pierre) - -- IMAP extension: - . Implemented FR #53812 (get MIME headers of the part of the email). (Stas) - . Fixed bug #53377 (imap_mime_header_decode() doesn't ignore \t during long - MIME header unfolding). (Adam) - -- Intl extension: - . Fixed bug #53612 (Segmentation fault when using cloned several intl - objects). (Gustavo) - . Fixed bug #53512 (NumberFormatter::setSymbol crash on bogus $attr values). - (Felipe) - . Implemented clone functionality for number, date & message formatters. - (Stas). - -- JSON extension: - . Fixed bug #53963 (Ensure error_code is always set during some failed - decodings). (Scott) - -- mysqlnd - . Fixed problem with always returning 0 as num_rows for unbuffered sets. - (Andrey, Ulf) - -- MySQL Improved extension: - . Added 'db' and 'catalog' keys to the field fetching functions (FR #39847). - (Kalle) - . Fixed buggy counting of affected rows when using the text protocol. The - collected statistics were wrong when multi_query was used with mysqlnd - (Andrey) - . Fixed bug #53795 (Connect Error from MySqli (mysqlnd) when using SSL). - (Kalle) - . Fixed bug #53503 (mysqli::query returns false after successful LOAD DATA - query). (Kalle, Andrey) - . Fixed bug #53425 (mysqli_real_connect() ignores client flags when built to - call libmysql). (Kalle, tre-php-net at crushedhat dot com) - -- OpenSSL extension: - . Fixed stream_socket_enable_crypto() not honoring the socket timeout in - server mode. (Gustavo) - . Fixed bug #54060 (Memory leaks when openssl_encrypt). (Pierre) - . Fixed bug #54061 (Memory leaks when openssl_decrypt). (Pierre) - . Fixed bug #53592 (stream_socket_enable_crypto() busy-waits in client mode). - (Gustavo) - . Implemented FR #53447 (Cannot disable SessionTicket extension for servers - that do not support it) by adding a no_ticket SSL context option. (Adam, - Tony) - -- PDO MySQL driver: - . Fixed bug #53551 (PDOStatement execute segfaults for pdo_mysql driver). - (Johannes) - . Implemented FR #47802 (Support for setting character sets in DSN strings). - (Kalle) - -- PDO Oracle driver: - . Fixed bug #39199 (Cannot load Lob data with more than 4000 bytes on - ORACLE 10). (spatar at mail dot nnov dot ru) - -- PDO PostgreSQL driver: - . Fixed bug #53517 (segfault in pgsql_stmt_execute() when postgres is down). - (gyp at balabit dot hu) - -- Phar extension: - . Fixed bug #54247 (format-string vulnerability on Phar). (Felipe) - (CVE-2011-1153) - . Fixed bug #53541 (format string bug in ext/phar). - (crrodriguez at opensuse dot org, Ilia) - . Fixed bug #53898 (PHAR reports invalid error message, when the directory - does not exist). (Ilia) - -- PHP-FPM SAPI: - . Enforce security in the fastcgi protocol parsing. - (ef-lists at email dotde) - . Fixed bug #53777 (php-fpm log format now match php_error log format). (fat) - . Fixed bug #53527 (php-fpm --test doesn't set a valuable return value). (fat) - . Fixed bug #53434 (php-fpm slowlog now also logs the original request). (fat) - -- Readline extension: - . Fixed bug #53630 (Fixed parameter handling inside readline() function). - (jo at feuersee dot de, Ilia) - -- Reflection extension: - . Fixed bug #53915 (ReflectionClass::getConstant(s) emits fatal error on - constants with self::). (Gustavo) - -- Shmop extension: - . Fixed bug #54193 (Integer overflow in shmop_read()). (Felipe) - Reported by Jose Carlos Norte (CVE-2011-1092) - -- SNMP extension: - . Fixed bug #51336 (snmprealwalk (snmp v1) does not handle end of OID tree - correctly). (Boris Lytochkin) - -- SOAP extension: - . Fixed possible crash introduced by the NULL poisoning patch. - (Mateusz Kocielski, Pierre) - -- SPL extension: - . Fixed memory leak in DirectoryIterator::getExtension() and - SplFileInfo::getExtension(). (Felipe) - . Fixed bug #53914 (SPL assumes HAVE_GLOB is defined). (Chris Jones) - . Fixed bug #53515 (property_exists incorrect on ArrayObject null and 0 - values). (Felipe) - . Fixed bug #49608 (Using CachingIterator on DirectoryIterator instance - segfaults). (Felipe) - - . Added SplFileInfo::getExtension(). FR #48767. (Peter Cowburn) - -- SQLite3 extension: - . Fixed memory leaked introduced by the NULL poisoning patch. - (Mateusz Kocielski, Pierre) - . Fixed memory leak on SQLite3Result and SQLite3Stmt when assigning to a - reference. (Felipe) - . Add SQlite3_Stmt::readonly() for checking if a statement is read only. - (Scott) - . Implemented FR #53466 (SQLite3Result::columnType() should return false after - all of the rows have been fetched). (Scott) - -- Streams: - . Fixed bug #54092 (Segmentation fault when using HTTP proxy with the FTP - wrapper). (Gustavo) - . Fixed bug #53913 (Streams functions assume HAVE_GLOB is defined). (Chris - Jones) - . Fixed bug #53903 (userspace stream stat callback does not separate the - elements of the returned array before converting them). (Gustavo) - . Implemented FR #26158 (open arbitrary file descriptor with fopen). (Gustavo) - -- Tokenizer Extension - . Fixed bug #54089 (token_get_all() does not stop after __halt_compiler). - (Nikita Popov, Ilia) - -- XSL extension: - . Fixed memory leaked introduced by the NULL poisoning patch. - (Mateusz Kocielski, Pierre) - -- Zip extension: - . Added the filename into the return value of stream_get_meta_data(). (Hannes) - . Fixed bug #53923 (Zip functions assume HAVE_GLOB is defined). (Adam) - . Fixed bug #53893 (Wrong return value for ZipArchive::extractTo()). (Pierre) - . Fixed bug #53885 (ZipArchive segfault with FL_UNCHANGED on empty archive). - (Stas, Maksymilian Arciemowicz). (CVE-2011-0421) - . Fixed bug #53854 (Missing constants for compression type). (Richard, Adam) - . Fixed bug #53603 (ZipArchive should quiet stat errors). (brad dot froehle at - gmail dot com, Gustavo) - . Fixed bug #53579 (stream_get_contents() segfaults on ziparchive streams). - (Hannes) - . Fixed bug #53568 (swapped memset arguments in struct initialization). - (crrodriguez at opensuse dot org) - . Fixed bug #53166 (Missing parameters in docs and reflection definition). - (Richard) - . Fixed bug #49072 (feof never returns true for damaged file in zip). - (Gustavo, Richard Quadling) - -06 Jan 2011, PHP 5.3.5 -- Fixed Bug #53632 (infinite loop with x87 fpu). (CVE-2010-4645) (Scott, - Rasmus) - -09 Dec 2010, PHP 5.3.4 -- Upgraded bundled Sqlite3 to version 3.7.3. (Ilia) -- Upgraded bundled PCRE to version 8.10. (Ilia) - -- Security enhancements: - . Fixed crash in zip extract method (possible CWE-170). - (Maksymilian Arciemowicz, Pierre) - . Paths with NULL in them (foo\0bar.txt) are now considered as invalid. - (Rasmus) - . Fixed a possible double free in imap extension (Identified by Mateusz - Kocielski). (CVE-2010-4150). (Ilia) - . Fixed NULL pointer dereference in ZipArchive::getArchiveComment. - (CVE-2010-3709). (Maksymilian Arciemowicz) - . Fixed possible flaw in open_basedir (CVE-2010-3436). (Pierre) - . Fixed MOPS-2010-24, fix string validation. (CVE-2010-2950). (Pierre) - . Fixed symbolic resolution support when the target is a DFS share. (Pierre) - . Fixed bug #52929 (Segfault in filter_var with FILTER_VALIDATE_EMAIL with - large amount of data) (CVE-2010-3710). (Adam) - -- General improvements: - . Added stat support for zip stream. (Pierre) - . Added follow_location (enabled by default) option for the http stream - support. (Pierre) - . Improved support for is_link and related functions on Windows. (Pierre) - . Added a 3rd parameter to get_html_translation_table. It now takes a charset - hint, like htmlentities et al. (Gustavo) - -- Implemented feature requests: - . Implemented FR #52348, added new constant ZEND_MULTIBYTE to detect - zend multibyte at runtime. (Kalle) - . Implemented FR #52173, added functions pcntl_get_last_error() and - pcntl_strerror(). (nick dot telford at gmail dot com, Arnaud) - . Implemented symbolic links support for open_basedir checks. (Pierre) - . Implemented FR #51804, SplFileInfo::getLinkTarget on Windows. (Pierre) - . Implemented FR #50692, not uploaded files don't count towards - max_file_uploads limit. As a side improvement, temporary files are not - opened for empty uploads and, in debug mode, 0-length uploads. (Gustavo) - -- Improved MySQLnd: - . Added new character sets to mysqlnd, which are available in MySQL 5.5 - (Andrey) - -- Improved PHP-FPM SAPI: - . Added '-p/--prefix' to php-fpm to use a custom prefix and run multiple - instances. (fat) - . Added custom process title for FPM. (fat) - . Added '-t/--test' to php-fpm to check and validate FPM conf file. (fat) - . Added statistics about listening socket queue length for FPM. - (andrei dot nigmatulin at gmail dot com, fat) - -- Core: - . Fixed extract() to do not overwrite $GLOBALS and $this when using - EXTR_OVERWRITE. (jorto at redhat dot com) - . Fixed bug in the Windows implementation of dns_get_record, where the two - last parameters wouldn't be filled unless the type were DNS_ANY (Gustavo). - . Changed the $context parameter on copy() to actually have an effect. (Kalle) - . Fixed htmlentities/htmlspecialchars accepting certain ill-formed UTF-8 - sequences. (Gustavo) - . Fixed bug #53409 (sleep() returns NULL on Windows). (Pierre) - . Fixed bug #53319 (strip_tags() may strip '
' incorrectly). (Felipe) - . Fixed bug #53304 (quot_print_decode does not handle lower-case hex digits). - (Ilia, daniel dot mueller at inexio dot net) - . Fixed bug #53248 (rawurlencode RFC 3986 EBCDIC support misses tilde char). - (Justin Martin) - . Fixed bug #53226 (file_exists fails on big filenames). (Adam) - . Fixed bug #53198 (changing INI setting "from" with ini_set did not have any - effect). (Gustavo) - . Fixed bug #53180 (post_max_size=0 not disabling the limit when the content - type is application/x-www-form-urlencoded or is not registered with PHP). - (gm at tlink dot de, Gustavo) - . Fixed bug #53141 (autoload misbehaves if called from closing session). - (ladislav at marek dot su) - . Fixed bug #53021 (In html_entity_decode, failure to convert numeric entities - with ENT_NOQUOTES and ISO-8859-1). Fixed and extended the fix of - ENT_NOQUOTES in html_entity_decode that had introduced the bug (rev - #185591) to other encodings. Additionaly, html_entity_decode() now doesn't - decode " if ENT_NOQUOTES is given. (Gustavo) - . Fixed bug #52931 (strripos not overloaded with function overloading - enabled). (Felipe) - . Fixed bug #52772 (var_dump() doesn't check for the existence of - get_class_name before calling it). (Kalle, Gustavo) - . Fixed bug #52534 (var_export array with negative key). (Felipe) - . Fixed bug #52327 (base64_decode() improper handling of leading padding in - strict mode). (Ilia) - . Fixed bug #52260 (dns_get_record fails with non-existing domain on Windows). - (a_jelly_doughnut at phpbb dot com, Pierre) - . Fixed bug #50953 (socket will not connect to IPv4 address when the host has - both IPv4 and IPv6 addresses, on Windows). (Gustavo, Pierre) - . Fixed bug #50524 (proc_open on Windows does not respect cwd as it does on - other platforms). (Pierre) - . Fixed bug #49687 (utf8_decode vulnerabilities and deficiencies in the number - of reported malformed sequences). (CVE-2010-3870) (Gustavo) - . Fixed bug #49407 (get_html_translation_table doesn't handle UTF-8). - (Gustavo) - . Fixed bug #48831 (php -i has different output to php --ini). (Richard, - Pierre) - . Fixed bug #47643 (array_diff() takes over 3000 times longer than php 5.2.4). - (Felipe) - . Fixed bug #47168 (printf of floating point variable prints maximum of 40 - decimal places). (Ilia) - . Fixed bug #46587 (mt_rand() does not check that max is greater than min). - (Ilia) - . Fixed bug #29085 (bad default include_path on Windows). (Pierre) - . Fixed bug #25927 (get_html_translation_table calls the ' ' instead of - '). (Gustavo) - -- Zend engine: - . Reverted fix for bug #51176 (Static calling in non-static method behaves - like $this->). (Felipe) - . Changed deprecated ini options on startup from E_WARNING to E_DEPRECATED. - (Kalle) - . Fixed NULL dereference in lex_scan on zend multibyte builds where the script - had a flex incompatible encoding and there was no converter. (Gustavo) - . Fixed covariance of return-by-ref constraints. (Etienne) - . Fixed bug #53305 (E_NOTICE when defining a constant starts with - __COMPILER_HALT_OFFSET__). (Felipe) - . Fixed bug #52939 (zend_call_function does not respect ZEND_SEND_PREFER_REF). - (Dmitry) - . Fixed bug #52879 (Objects unreferenced in __get, __set, __isset or __unset - can be freed too early). (mail_ben_schmidt at yahoo dot com dot au, Dmitry) - . Fixed bug #52786 (PHP should reset section to [PHP] after ini sections). - (Fedora at famillecollet dot com) - . Fixed bug #52508 (newline problem with parse_ini_file+INI_SCANNER_RAW). - (Felipe) - . Fixed bug #52484 (__set() ignores setting properties with empty names). - (Felipe) - . Fixed bug #52361 (Throwing an exception in a destructor causes invalid - catching). (Dmitry) - . Fixed bug #51008 (Zend/tests/bug45877.phpt fails). (Dmitry) - -- Build issues: - . Fixed bug #52436 (Compile error if systems do not have stdint.h) - (Sriram Natarajan) - . Fixed bug #50345 (nanosleep not detected properly on some solaris versions). - (Ulf, Tony) - . Fixed bug #49215 (make fails on glob_wrapper). (Felipe) - -- Calendar extension: - . Fixed bug #52744 (cal_days_in_month incorrect for December 1 BCE). - (gpap at internet dot gr, Adam) - -- cURL extension: - . Fixed bug #52828 (curl_setopt does not accept persistent streams). - (Gustavo, Ilia) - . Fixed bug #52827 (cURL leaks handle and causes assertion error - (CURLOPT_STDERR)). (Gustavo) - . Fixed bug #52202 (CURLOPT_PRIVATE gets corrupted). (Ilia) - . Fixed bug #50410 (curl extension slows down PHP on Windows). (Pierre) - -- DateTime extension: - . Fixed bug #53297 (gettimeofday implementation in php/win32/time.c can return - 1 million microsecs). (ped at 7gods dot org) - . Fixed bug #52668 (Iterating over a dateperiod twice is broken). (Derick) - . Fixed bug #52454 (Relative dates and getTimestamp increments by one day). - (Derick) - . Fixed bug #52430 (date_parse parse 24:xx:xx as valid time). (Derick) - . Added support for the ( and ) delimiters/separators to - DateTime::createFromFormat(). (Derick) - -- DBA extension: - . Added Berkeley DB 5.1 support to the DBA extension. (Oracle Corp.) - -- DOM extension: - . Fixed bug #52656 (DOMCdataSection does not work with splitText). (Ilia) - -- Filter extension: - . Fixed the filter extension accepting IPv4 octets with a leading 0 as that - belongs to the unsupported "dotted octal" representation. (Gustavo) - . Fixed bug #53236 (problems in the validation of IPv6 addresses with leading - and trailing :: in the filter extension). (Gustavo) - . Fixed bug #50117 (problems in the validation of IPv6 addresses with IPv4 - addresses and ::). (Gustavo) - -- GD extension: - . Fixed bug #53492 (fix crash if anti-aliasing steps are invalid). (Pierre) - -- GMP extension: - . Fixed bug #52906 (gmp_mod returns negative result when non-negative is - expected). (Stas) - . Fixed bug #52849 (GNU MP invalid version match). (Adam) - -- Hash extension: - . Fixed bug #51003 (unaligned memory access in ext/hash/hash_tiger.c). - (Mike, Ilia) - -- Iconv extension: - . Fixed bug #52941 (The 'iconv_mime_decode_headers' function is skipping - headers). (Adam) - . Fixed bug #52599 (iconv output handler outputs incorrect content type - when flags are used). (Ilia) - . Fixed bug #51250 (iconv_mime_decode() does not ignore malformed Q-encoded - words). (Ilia) - -- Intl extension: - . Fixed crashes on invalid parameters in intl extension. (CVE-2010-4409). - (Stas, Maksymilian Arciemowicz) - . Added support for formatting the timestamp stored in a DateTime object. - (Stas) - . Fixed bug #50590 (IntlDateFormatter::parse result is limited to the integer - range). (Stas) - -- Mbstring extension: - . Fixed bug #53273 (mb_strcut() returns garbage with the excessive length - parameter). (CVE-2010-4156) (Mateusz Kocielski, Pierre, Moriyoshi) - . Fixed bug #52981 (Unicode casing table was out-of-date. Updated with - UnicodeData-6.0.0d7.txt and included the source of the generator program - with the distribution) (Gustavo). - . Fixed bug #52681 (mb_send_mail() appends an extra MIME-Version header). - (Adam) - -- MSSQL extension: - . Fixed possible crash in mssql_fetch_batch(). (Kalle) - . Fixed bug #52843 (Segfault when optional parameters are not passed in to - mssql_connect). (Felipe) - -- MySQL extension: - . Fixed bug #52636 (php_mysql_fetch_hash writes long value into int). - (Kalle, rein at basefarm dot no) - -- MySQLi extension: - . Fixed bug #52891 (Wrong data inserted with mysqli/mysqlnd when using - mysqli_stmt_bind_param and value> PHP_INT_MAX). (Andrey) - . Fixed bug #52686 (mysql_stmt_attr_[gs]et argument points to incorrect type). - (rein at basefarm dot no) - . Fixed bug #52654 (mysqli doesn't install headers with structures it uses). - (Andrey) - . Fixed bug #52433 (Call to undefined method mysqli::poll() - must be static). - (Andrey) - . Fixed bug #52417 (MySQLi build failure with mysqlnd on MacOS X). (Andrey) - . Fixed bug #52413 (MySQLi/libmysql build failure on OS X, FreeBSD). (Andrey) - . Fixed bug #52390 (mysqli_report() should be per-request setting). (Kalle) - . Fixed bug #52302 (mysqli_fetch_all does not work with MYSQLI_USE_RESULT). - (Andrey) - . Fixed bug #52221 (Misbehaviour of magic_quotes_runtime (get/set)). (Andrey) - . Fixed bug #45921 (Can't initialize character set hebrew). (Andrey) - -- MySQLnd: - . Fixed bug #52613 (crash in mysqlnd after hitting memory limit). (Andrey) - -- ODBC extension: - - Fixed bug #52512 (Broken error handling in odbc_execute). - (mkoegler at auto dot tuwien dot ac dot at) - -- Openssl extension: - . Fixed possible blocking behavior in openssl_random_pseudo_bytes on Windows. - (Pierre) - . Fixed bug #53136 (Invalid read on openssl_csr_new()). (Felipe) - . Fixed bug #52947 (segfault when ssl stream option capture_peer_cert_chain - used). (Felipe) - -- Oracle Database extension (OCI8): - . Fixed bug #53284 (Valgrind warnings in oci_set_* functions) (Oracle Corp.) - . Fixed bug #51610 (Using oci_connect causes PHP to take a long time to - exit). Requires Oracle 11.2.0.2 client libraries (or Oracle bug fix - 9891199) for this patch to have an effect. (Oracle Corp.) - -- PCNTL extension: - . Fixed bug #52784 (Race condition when handling many concurrent signals). - (nick dot telford at gmail dot com, Arnaud) - -- PCRE extension: - . Fixed bug #52971 (PCRE-Meta-Characters not working with utf-8). (Felipe) - . Fixed bug #52732 (Docs say preg_match() returns FALSE on error, but it - returns int(0)). (slugonamission at gmail dot com) - -- PHAR extension: - . Fixed bug #50987 (unaligned memory access in phar.c). - (geissert at debian dot org, Ilia) - -- PHP-FPM SAPI: - . Fixed bug #53412 (segfault when using -y). (fat) - . Fixed inconsistent backlog default value (-1) in FPM on many systems. (fat) - . Fixed bug #52501 (libevent made FPM crashed when forking -- libevent has - been removed). (fat) - . Fixed bug #52725 (gcc builtin atomic functions were sometimes used when they - were not available). (fat) - . Fixed bug #52693 (configuration file errors are not logged to stderr). (fat) - . Fixed bug #52674 (FPM Status page returns inconsistent Content-Type - headers). (fat) - . Fixed bug #52498 (libevent was not only linked to php-fpm). (fat) - -- PDO: - . Fixed bug #52699 (PDO bindValue writes long int 32bit enum). - (rein at basefarm dot no) - . Fixed bug #52487 (PDO::FETCH_INTO leaks memory). (Felipe) - -- PDO DBLib driver: - . Fixed bug #52546 (pdo_dblib segmentation fault when iterating MONEY values). - (Felipe) - -- PDO Firebird driver: - . Restored firebird support (VC9 builds only). (Pierre) - . Fixed bug #53335 (pdo_firebird did not implement rowCount()). - (preeves at ibphoenix dot com) - . Fixed bug #53323 (pdo_firebird getAttribute() crash). - (preeves at ibphoenix dot com) - -- PDO MySQL driver: - . Fixed bug #52745 (Binding params doesn't work when selecting a date inside a - CASE-WHEN). (Andrey) - -- PostgreSQL extension: - . Fixed bug #47199 (pg_delete() fails on NULL). (ewgraf at gmail dot com) - -- Reflection extension: - . Fixed ReflectionProperty::isDefault() giving a wrong result for properties - obtained with ReflectionClass::getProperties(). (Gustavo) -- Reflection extension: - . Fixed bug #53366 (Reflection doesnt get dynamic property value from - getProperty()). (Felipe) - . Fixed bug #52854 (ReflectionClass::newInstanceArgs does not work for classes - without constructors). (Johannes) - -- SOAP extension: - . Fixed bug #44248 (RFC2616 transgression while HTTPS request through proxy - with SoapClient object). (Dmitry) - -- SPL extension: - . Fixed bug #53362 (Segmentation fault when extending SplFixedArray). (Felipe) - . Fixed bug #53279 (SplFileObject doesn't initialise default CSV escape - character). (Adam) - . Fixed bug #53144 (Segfault in SplObjectStorage::removeAll()). (Felipe) - . Fixed bug #53071 (SPLObjectStorage defeats gc_collect_cycles). (Gustavo) - . Fixed bug #52573 (SplFileObject::fscanf Segmentation fault). (Felipe) - . Fixed bug #51763 (SplFileInfo::getType() does not work symbolic link - and directory). (Pierre) - . Fixed bug #50481 (Storing many SPLFixedArray in an array crashes). (Felipe) - . Fixed bug #50579 (RegexIterator::REPLACE doesn't work). (Felipe) - -- SQLite3 extension: - . Fixed bug #53463 (sqlite3 columnName() segfaults on bad column_number). - (Felipe) - -- Streams: - . Fixed forward stream seeking emulation in streams that don't support seeking - in situations where the read operation gives back less data than requested - and when there was data in the buffer before the emulation started. Also - made more consistent its behavior -- should return failure every time less - data than was requested was skipped. (Gustavo) - . Fixed bug #53241 (stream casting that relies on fdopen/fopencookie fails - with streams opened with, inter alia, the 'xb' mode). (Gustavo) - . Fixed bug #53006 (stream_get_contents has an unpredictable behavior when the - underlying stream does not support seeking). (Gustavo) - . Fixed bug #52944 (Invalid write on second and subsequent reads with an - inflate filter fed invalid data). (Gustavo) - . Fixed bug #52820 (writes to fopencookie FILE* not commited when seeking the - stream). (Gustavo) - -- WDDX extension: - . Fixed bug #52468 (wddx_deserialize corrupts integer field value when left - empty). (Felipe) - -- Zlib extension: - . Fixed bug #52926 (zlib fopen wrapper does not use context). (Gustavo) - -22 Jul 2010, PHP 5.3.3 -- Upgraded bundled sqlite to version 3.6.23.1. (Ilia) -- Upgraded bundled PCRE to version 8.02. (Ilia) - -- Added support for JSON_NUMERIC_CHECK option in json_encode() that converts - numeric strings to integers. (Ilia) -- Added stream_set_read_buffer, allows to set the buffer for read operation. - (Pierre) -- Added stream filter support to mcrypt extension (ported from - mcrypt_filter). (Stas) -- Added full_special_chars filter to ext/filter. (Rasmus) -- Added backlog socket context option for stream_socket_server(). (Mike) -- Added fifth parameter to openssl_encrypt()/openssl_decrypt() - (string $iv) to use non-NULL IV. - Made implicit use of NULL IV a warning. (Sara) -- Added openssl_cipher_iv_length(). (Sara) -- Added FastCGI Process Manager (FPM) SAPI. (Tony) -- Added recent Windows versions to php_uname and fix undefined windows - version support. (Pierre) -- Added Berkeley DB 5 support to the DBA extension. (Johannes, Chris Jones) -- Added support for copy to/from array/file for pdo_pgsql extension. - (Denis Gasparin, Ilia) -- Added inTransaction() method to PDO, with specialized support for Postgres. - (Ilia, Denis Gasparin) - -- Changed namespaced classes so that the ctor can only be named - __construct now. (Stas) -- Reset error state in PDO::beginTransaction() reset error state. (Ilia) - -- Implemented FR#51295 (SQLite3::busyTimeout not existing). (Mark) -- Implemented FR#35638 (Adding udate to imap_fetch_overview results). - (Charles_Duffy at dell dot com ) -- Rewrote var_export() to use smart_str rather than output buffering, prevents - data disclosure if a fatal error occurs (CVE-2010-2531). (Scott) -- Fixed possible buffer overflows in mysqlnd_list_fields, mysqlnd_change_user. - (Andrey) -- Fixed possible buffer overflows when handling error packets in mysqlnd. - Reported by Stefan Esser. (Andrey) -- Fixed very rare memory leak in mysqlnd, when binding thousands of columns. - (Andrey) -- Fixed a crash when calling an inexistent method of a class that inherits - PDOStatement if instantiated directly instead of doing by the PDO methods. - (Felipe) - -- Fixed memory leak on error in mcrypt_create_iv on Windows. (Pierre) -- Fixed a possible crash because of recursive GC invocation. (Dmitry) -- Fixed a possible resource destruction issues in shm_put_var(). - Reported by Stefan Esser. (Dmitry) -- Fixed a possible information leak because of interruption of XOR operator. - Reported by Stefan Esser. (Dmitry) -- Fixed a possible memory corruption because of unexpected call-time pass by - refernce and following memory clobbering through callbacks. - Reported by Stefan Esser. (Dmitry) -- Fixed a possible memory corruption in ArrayObject::uasort(). Reported by - Stefan Esser. (Dmitry) -- Fixed a possible memory corruption in parse_str(). Reported by Stefan Esser. - (Dmitry) -- Fixed a possible memory corruption in pack(). Reported by Stefan Esser. - (Dmitry) -- Fixed a possible memory corruption in substr_replace(). Reported by Stefan - Esser. (Dmitry) -- Fixed a possible memory corruption in addcslashes(). Reported by Stefan - Esser. (Dmitry) -- Fixed a possible stack exhaustion inside fnmatch(). Reported by Stefan - Esser. (Ilia) -- Fixed a possible dechunking filter buffer overflow. Reported by Stefan Esser. - (Pierre) -- Fixed a possible arbitrary memory access inside sqlite extension. Reported - by Mateusz Kocielski. (Ilia) -- Fixed string format validation inside phar extension. Reported by Stefan - Esser. (Ilia) -- Fixed handling of session variable serialization on certain prefix - characters. Reported by Stefan Esser. (Ilia) -- Fixed a NULL pointer dereference when processing invalid XML-RPC - requests (Fixes CVE-2010-0397, bug #51288). (Raphael Geissert) -- Fixed 64-bit integer overflow in mhash_keygen_s2k(). (Clément LECIGNE, Stas) -- Fixed SplObjectStorage unserialization problems (CVE-2010-2225). (Stas) -- Fixed the mail.log ini setting when no filename was given. (Johannes) - -- Fixed bug #52317 (Segmentation fault when using mail() on a rhel 4.x (only 64 - bit)). (Adam) -- Fixed bug #52262 (json_decode() shows no errors on invalid UTF-8). - (Scott) -- Fixed bug #52240 (hash_copy() does not copy the HMAC key, causes wrong - results and PHP crashes). (Felipe) -- Fixed bug #52238 (Crash when an Exception occured in iterator_to_array). - (Johannes) -- Fixed bug #52193 (converting closure to array yields empty array). (Felipe) -- Fixed bug #52183 (Reflectionfunction reports invalid number of arguments for - function aliases). (Felipe) -- Fixed bug #52162 (custom request header variables with numbers are removed). - (Sriram Natarajan) -- Fixed bug #52160 (Invalid E_STRICT redefined constructor error). (Felipe) -- Fixed bug #52138 (Constants are parsed into the ini file for section names). - (Felipe) -- Fixed bug #52115 (mysqli_result::fetch_all returns null, not an empty array). - (Andrey) -- Fixed bug #52101 (dns_get_record() garbage in 'ipv6' field on Windows). - (Pierre) -- Fixed bug #52082 (character_set_client & character_set_connection reset after - mysqli_change_user()). (Andrey) -- Fixed bug #52043 (GD doesn't recognize latest libJPEG versions). - (php at group dot apple dot com, Pierre) -- Fixed bug #52041 (Memory leak when writing on uninitialized variable returned - from function). (Dmitry) -- Fixed bug #52060 (Memory leak when passing a closure to method_exists()). - (Felipe) -- Fixed bug #52057 (ReflectionClass fails on Closure class). (Felipe) -- Fixed bug #52051 (handling of case sensitivity of old-style constructors - changed in 5.3+). (Felipe) -- Fixed bug #52037 (Concurrent builds fail in install-programs). (seanius at - debian dot org, Kalle) -- Fixed bug #52019 (make lcov doesn't support TESTS variable anymore). (Patrick) -- Fixed bug #52010 (open_basedir restrictions mismatch on vacuum command). - (Ilia) -- Fixed bug #52001 (Memory allocation problems after using variable variables). - (Dmitry) -- Fixed bug #51991 (spl_autoload and *nix support with namespace). (Felipe) -- Fixed bug #51943 (AIX: Several files are out of ANSI spec). (Kalle, - coreystup at gmail dot com) -- Fixed bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with - constant array). (Felipe) -- Fixed bug #51905 (ReflectionParameter fails if default value is an array - with an access to self::). (Felipe) -- Fixed bug #51899 (Parse error in parse_ini_file() function when empy value - followed by no newline). (Felipe) -- Fixed bug #51844 (checkdnsrr does not support types other than MX). (Pierre) -- Fixed bug #51827 (Bad warning when register_shutdown_function called with - wrong num of parameters). (Felipe) -- Fixed bug #51822 (Segfault with strange __destruct() for static class - variables). (Dmitry) -- Fixed bug #51791 (constant() aborts execution when fail to check undefined - constant). (Felipe) -- Fixed bug #51732 (Fileinfo __construct or open does not work with NULL). - (Pierre) -- Fixed bug #51725 (xmlrpc_get_type() returns true on invalid dates). (Mike) -- Fixed bug #51723 (Content-length header is limited to 32bit integer with - Apache2 on Windows). (Pierre) -- Fixed bug #51721 (mark DOMNodeList and DOMNamedNodeMap as Traversable). - (David Zuelke) -- Fixed bug #51712 (Test mysql_mysqlnd_read_timeout_long must fail on MySQL4). - (Andrey) -- Fixed bug #51697 (Unsafe operations in free_storage of SPL iterators, - causes crash during shutdown). (Etienne) -- Fixed bug #51690 (Phar::setStub looks for case-sensitive - __HALT_COMPILER()). (Ilia) -- Fixed bug #51688 (ini per dir crashes when invalid document root are given). - (Pierre) -- Fixed bug #51671 (imagefill does not work correctly for small images). - (Pierre) -- Fixed bug #51670 (getColumnMeta causes segfault when re-executing query - after calling nextRowset). (Pierrick) -- Fixed bug #51647 Certificate file without private key (pk in another file) - doesn't work. (Andrey) -- Fixed bug #51629 (CURLOPT_FOLLOWLOCATION error message is misleading). - (Pierre) -- Fixed bug #51627 (script path not correctly evaluated). - (russell dot tempero at rightnow dot com) -- Fixed bug #51624 (Crash when calling mysqli_options()). (Felipe) -- Fixed bug #51615 (PHP crash with wrong HTML in SimpleXML). (Felipe) -- Fixed bug #51609 (pg_copy_to: Invalid results when using fourth parameter). - (Felipe) -- Fixed bug #51608 (pg_copy_to: WARNING: nonstandard use of \\ in a string - literal). (cbandy at jbandy dot com) -- Fixed bug #51607 (pg_copy_from does not allow schema in the tablename - argument). (cbandy at jbandy dot com) -- Fixed bug #51605 (Mysqli - zombie links). (Andrey) -- Fixed bug #51604 (newline in end of header is shown in start of message). - (Daniel Egeberg) -- Fixed bug #51590 (JSON_ERROR_UTF8 is undefined). (Felipe) -- Fixed bug #51583 (Bus error due to wrong alignment in mysqlnd). (Rainer Jung) -- Fixed bug #51582 (Don't assume UINT64_C it's ever available). - (reidrac at usebox dot net, Pierre) -- Fixed bug #51577 (Uninitialized memory reference with oci_bind_array_by_name) - (Oracle Corp.) -- Fixed bug #51562 (query timeout in mssql can not be changed per query). - (ejsmont dot artur at gmail dot com) -- Fixed bug #51552 (debug_backtrace() causes segmentation fault and/or memory - issues). (Dmitry) -- Fixed bug #51445 (var_dump() invalid/slow *RECURSION* detection). (Felipe) -- Fixed bug #51435 (Missing ifdefs / logic bug in crypt code cause compile - errors). (Felipe) -- Fixed bug #51424 (crypt() function hangs after 3rd call). (Pierre, Sriram) -- Fixed bug #51394 (Error line reported incorrectly if error handler throws an - exception). (Stas) -- Fixed bug #51393 (DateTime::createFromFormat() fails if format string contains - timezone). (Adam) -- Fixed bug #51347 (mysqli_close / connection memory leak). (Andrey, Johannes) -- Fixed bug #51338 (URL-Rewriter is still enabled if use_only_cookies is - on). (Ilia, j dot jeising at gmail dot com) -- Fixed bug #51291 (oci_error doesn't report last error when called two times) - (Oracle Corp.) -- Fixed bug #51276 (php_load_extension() is missing when HAVE_LIBDL is - undefined). (Tony) -- Fixed bug #51273 (Faultstring property does not exist when the faultstring is - empty) (Ilia, dennis at transip dot nl) -- Fixed bug #51269 (zlib.output_compression Overwrites Vary Header). (Adam) -- Fixed bug #51257 (CURL_VERSION_LARGEFILE incorrectly used after libcurl - version 7.10.1). (aron dot ujvari at microsec dot hu) -- Fixed bug #51242 (Empty mysql.default_port does not default to 3306 anymore, - but 0). (Adam) -- Fixed bug #51237 (milter SAPI crash on startup). (igmar at palsenberg dot com) -- Fixed bug #51213 (pdo_mssql is trimming value of the money column). (Ilia, - alexr at oplot dot com) -- Fixed bug #51190 (ftp_put() returns false when transfer was successful). - (Ilia) -- Fixed bug #51183 (ext/date/php_date.c fails to compile with Sun Studio). - (Sriram Natarajan) -- Fixed bug #51176 (Static calling in non-static method behaves like $this->). - (Felipe) -- Fixed bug #51171 (curl_setopt() doesn't output any errors or warnings when - an invalid option is provided). (Ilia) -- Fixed bug #51128 (imagefill() doesn't work with large images). (Pierre) -- Fixed bug #51096 ('last day' and 'first day' are handled incorrectly when - parsing date strings). (Derick) -- Fixed bug #51086 (DBA DB4 doesn't work with Berkeley DB 4.8). (Chris Jones) -- Fixed bug #51062 (DBA DB4 uses mismatched headers and libraries). (Chris - Jones) -- Fixed bug #51026 (mysqli_ssl_set not working). (Andrey) -- Fixed bug #51023 (filter doesn't detect int overflows with GCC 4.4). - (Raphael Geissert) -- Fixed bug #50999 (unaligned memory access in dba_fetch()). (Felipe) -- Fixed bug #50976 (Soap headers Authorization not allowed). - (Brain France, Dmitry) -- Fixed bug #50828 (DOMNotation is not subclass of DOMNode). (Rob) -- Fixed bug #50810 (property_exists does not work for private). (Felipe) -- Fixed bug #50762 (in WSDL mode Soap Header handler function only being called - if defined in WSDL). (mephius at gmail dot com) -- Fixed bug #50731 (Inconsistent namespaces sent to functions registered with - spl_autoload_register). (Felipe) -- Fixed bug #50563 (removing E_WARNING from parse_url). (ralph at smashlabs dot - com, Pierre) -- Fixed bug #50578 (incorrect shebang in phar.phar). (Fedora at FamilleCollet - dot com) -- Fixed bug #50392 (date_create_from_format enforces 6 digits for 'u' format - character). (Derick) -- Fixed bug #50383 (Exceptions thrown in __call / __callStatic do not include - file and line in trace). (Felipe) -- Fixed bug #50358 (Compile failure compiling ext/phar/util.lo). (Felipe) -- Fixed bug #50101 (name clash between global and local variable). - (patch by yoarvi at gmail dot com) -- Fixed bug #50055 (DateTime::sub() allows 'relative' time modifications). - (Derick) -- Fixed bug #51002 (fix possible memory corruption with very long names). - (Pierre) -- Fixed bug #49893 (Crash while creating an instance of Zend_Mail_Storage_Pop3). - (Dmitry) -- Fixed bug #49819 (STDOUT losing data with posix_isatty()). (Mike) -- Fixed bug #49778 (DateInterval::format("%a") is always zero when an interval - is created from an ISO string). (Derick) -- Fixed bug #49700 (memory leaks in php_date.c if garbage collector is - enabled). (Dmitry) -- Fixed bug #49576 (FILTER_VALIDATE_EMAIL filter needs updating) (Rasmus) -- Fixed bug #49490 (XPath namespace prefix conflict). (Rob) -- Fixed bug #49429 (odbc_autocommit doesn't work). (Felipe) -- Fixed bug #49320 (PDO returns null when SQLite connection fails). (Felipe) -- Fixed bug #49234 (mysqli_ssl_set not found). (Andrey) -- Fixed bug #49216 (Reflection doesn't seem to work properly on MySqli). - (Andrey) -- Fixed bug #49192 (PHP crashes when GC invoked on COM object). (Stas) -- Fixed bug #49081 (DateTime::diff() mistake if start in January and interval > - 28 days). (Derick) -- Fixed bug #49059 (DateTime::diff() repeats previous sub() operation). - (yoarvi@gmail.com, Derick) -- Fixed bug #48983 (DomDocument : saveHTMLFile wrong charset). (Rob) -- Fixed bug #48930 (__COMPILER_HALT_OFFSET__ incorrect in PHP >= 5.3). (Felipe) -- Fixed bug #48902 (Timezone database fallback map is outdated). (Derick) -- Fixed bug #48781 (Cyclical garbage collector memory leak). (Dmitry) -- Fixed bug #48601 (xpath() returns FALSE for legitimate query). (Rob) -- Fixed bug #48361 (SplFileInfo::getPathInfo should return the - parent dir). (Etienne) -- Fixed bug #48289 (iconv_mime_encode() quoted-printable scheme is broken). - (Adam, patch from hiroaki dot kawai at gmail dot com). -- Fixed bug #47842 (sscanf() does not support 64-bit values). (Mike) -- Fixed bug #46111 (Some timezone identifiers can not be parsed). (Derick) -- Fixed bug #45808 (stream_socket_enable_crypto() blocks and eats CPU). - (vincent at optilian dot com) -- Fixed bug #43233 (sasl support for ldap on Windows). (Pierre) -- Fixed bug #35673 (formatOutput does not work with saveHTML). (Rob) -- Fixed bug #33210 (getimagesize() fails to detect width/height on certain - JPEGs). (Ilia) - -04 Mar 2010, PHP 5.3.2 - -- Upgraded bundled sqlite to version 3.6.22. (Ilia) -- Upgraded bundled libmagic to version 5.03. (Mikko) -- Upgraded bundled PCRE to version 8.00. (Scott) -- Updated timezone database to version 2010.3. (Derick) - -- Improved LCG entropy. (Rasmus, Samy Kamkar) -- Improved crypt support for edge cases (UFC compatibility). (Solar Designer, - Joey, Pierre) - -- Reverted fix for bug #49521 (PDO fetchObject sets values before calling - constructor). (Pierrick, Johannes) - -- Changed gmp_strval() to use full range from 2 to 62, and -2 to -36. FR #50283 - (David Soria Parra) -- Changed "post_max_size" php.ini directive to allow unlimited post size by - setting it to 0. (Rasmus) -- Changed tidyNode class to disallow manual node creation. (Pierrick) - -- Removed automatic file descriptor unlocking happening on shutdown and/or - stream close (on all OSes). (Tony, Ilia) - -- Added libpng 1.4.0 support. (Pierre) -- Added support for DISABLE_AUTHENTICATOR for imap_open. (Pierre) -- Added missing host validation for HTTP urls inside FILTER_VALIDATE_URL. - (Ilia) -- Added stream_resolve_include_path(). (Mikko) -- Added INTERNALDATE support to imap_append. (nick at mailtrust dot com) -- Added support for SHA-256 and SHA-512 to php's crypt. (Pierre) -- Added realpath_cache_size() and realpath_cache_get() functions. (Stas) -- Added FILTER_FLAG_STRIP_BACKTICK option to the filter extension. (Ilia) -- Added protection for $_SESSION from interrupt corruption and improved - "session.save_path" check. (Stas) -- Added LIBXML_PARSEHUGE constant to override the maximum text size of a - single text node when using libxml2.7.3+. (Kalle) -- Added ReflectionMethod::setAccessible() for invoking non-public methods - through the Reflection API. (Sebastian) -- Added Collator::getSortKey for intl extension. (Stas) -- Added support for CURLOPT_POSTREDIR. FR #49571. (Sriram Natarajan) -- Added support for CURLOPT_CERTINFO. FR #49253. - (Linus Nielsen Feltzing ) -- Added client-side server name indication support in openssl. (Arnaud) - -- Improved fix for bug #50006 (Segfault caused by uksort()). (Stas) - -- Fixed mysqlnd hang when queries exactly 16777214 bytes long are sent. (Andrey) -- Fixed incorrect decoding of 5-byte BIT sequences in mysqlnd. (Andrey) -- Fixed error_log() to be binary safe when using message_type 3. (Jani) -- Fixed unnecessary invocation of setitimer when timeouts have been disabled. - (Arvind Srinivasan) -- Fixed memory leak in extension loading when an error occurs on Windows. - (Pierre) -- Fixed safe_mode validation inside tempnam() when the directory path does - not end with a /). (Martin Jansen) -- Fixed a possible open_basedir/safe_mode bypass in session extension - identified by Grzegorz Stachowiak. (Ilia) -- Fixed possible crash when a error/warning is raised during php startup. - (Pierre) -- Fixed possible bad behavior of rename on windows when used with symbolic - links or invalid paths. (Pierre) -- Fixed error output to stderr on Windows. (Pierre) -- Fixed memory leaks in is_writable/readable/etc on Windows. (Pierre) -- Fixed memory leaks in the ACL function on Windows. (Pierre) -- Fixed memory leak in the realpath cache on Windows. (Pierre) -- Fixed memory leak in zip_close. (Pierre) -- Fixed crypt's blowfish sanity check of the "setting" string, to reject - iteration counts encoded as 36 through 39. (Solar Designer, Joey, Pierre) - -- Fixed bug #51059 (crypt crashes when invalid salt are given). (Pierre) -- Fixed bug #50952 (allow underscore _ in constants parsed in php.ini files). - (Jani) -- Fixed bug #50940 (Custom content-length set incorrectly in Apache SAPIs). - (Brian France, Rasmus) -- Fixed bug #50930 (Wrong date by php_date.c patch with ancient gcc/glibc - versions). (Derick) -- Fixed bug #50907 (X-PHP-Originating-Script adding two new lines in *NIX). - (Ilia) -- Fixed bug #50859 (build fails with openssl 1.0 due to md2 deprecation). - (Ilia, hanno at hboeck dot de) -- Fixed bug #50847 (strip_tags() removes all tags greater then 1023 bytes - long). (Ilia) -- Fixed bug #50829 (php.ini directive pdo_mysql.default_socket is ignored). - (Ilia) -- Fixed bug #50832 (HTTP fopen wrapper does not support passwordless HTTP - authentication). (Jani) -- Fixed bug #50787 (stream_set_write_buffer() has no effect on socket streams). - (vnegrier at optilian dot com, Ilia) -- Fixed bug #50761 (system.multiCall crashes in xmlrpc extension). - (hiroaki dot kawai at gmail dot com, Ilia) -- Fixed bug #50756 (CURLOPT_FTP_SKIP_PASV_IP does not exist). (Sriram) -- Fixed bug #50732 (exec() adds single byte twice to $output array). (Ilia) -- Fixed bug #50728 (All PDOExceptions hardcode 'code' property to 0). - (Joey, Ilia) -- Fixed bug #50723 (Bug in garbage collector causes crash). (Dmitry) -- Fixed bug #50690 (putenv does not set ENV when the value is only one char). - (Pierre) -- Fixed bug #50680 (strtotime() does not support eighth ordinal number). (Ilia) -- Fixed bug #50661 (DOMDocument::loadXML does not allow UTF-16). (Rob) -- Fixed bug #50657 (copy() with an empty (zero-byte) HTTP source succeeds but - returns false). (Ilia) -- Fixed bug #50636 (MySQLi_Result sets values before calling constructor). - (Pierrick) -- Fixed bug #50632 (filter_input() does not return default value if the - variable does not exist). (Ilia) -- Fixed bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect). (Pierrick) -- Fixed bug #50558 (Broken object model when extending tidy). (Pierrick) -- Fixed bug #50540 (Crash while running ldap_next_reference test cases). - (Sriram) -- Fixed bug #50519 (segfault in garbage collection when using set_error_handler - and DomDocument). (Dmitry) -- Fixed bug #50508 (compile failure: Conflicting HEADER type declarations). - (Jani) -- Fixed bug #50496 (Use of is valid only in a c99 compilation - environment. (Sriram) -- Fixed bug #50464 (declare encoding doesn't work within an included file). - (Felipe) -- Fixed bug #50458 (PDO::FETCH_FUNC fails with Closures). (Felipe, Pierrick) -- Fixed bug #50445 (PDO-ODBC stored procedure call from Solaris 64-bit causes - seg fault). (davbrown4 at yahoo dot com, Felipe) -- Fixed bug #50416 (PROCEDURE db.myproc can't return a result set in the given - context). (Andrey) -- Fixed bug #50394 (Reference argument converted to value in __call). (Stas) -- Fixed bug #50351 (performance regression handling objects, ten times slower - in 5.3 than in 5.2). (Dmitry) -- Fixed bug #50392 (date_create_from_format() enforces 6 digits for 'u' - format character). (Ilia) -- Fixed bug #50345 (nanosleep not detected properly on some solaris versions). - (Jani) -- Fixed bug #50340 (php.ini parser does not allow spaces in ini keys). (Jani) -- Fixed bug #50334 (crypt ignores sha512 prefix). (Pierre) -- Fixed bug #50323 (Allow use of ; in values via ;; in PDO DSN). - (Ilia, Pierrick) -- Fixed bug #50285 (xmlrpc does not preserve keys in encoded indexed arrays). - (Felipe) -- Fixed bug #50282 (xmlrpc_encode_request() changes object into array in - calling function). (Felipe) -- Fixed bug #50267 (get_browser(null) does not use HTTP_USER_AGENT). (Jani) -- Fixed bug #50266 (conflicting types for llabs). (Jani) -- Fixed bug #50261 (Crash When Calling Parent Constructor with - call_user_func()). (Dmitry) -- Fixed bug #50255 (isset() and empty() silently casts array to object). - (Felipe) -- Fixed bug #50240 (pdo_mysql.default_socket in php.ini shouldn't used - if it is empty). (foutrelis at gmail dot com, Ilia) -- Fixed bug #50231 (Socket path passed using --with-mysql-sock is ignored when - mysqlnd is enabled). (Jani) -- Fixed bug #50219 (soap call Segmentation fault on a redirected url). - (Pierrick) -- Fixed bug #50212 (crash by ldap_get_option() with LDAP_OPT_NETWORK_TIMEOUT). - (Ilia, shigeru_kitazaki at cybozu dot co dot jp) -- Fixed bug #50209 (Compiling with libedit cannot find readline.h). - (tcallawa at redhat dot com) -- Fixed bug #50207 (segmentation fault when concatenating very large strings on - 64bit linux). (Ilia) -- Fixed bug #50196 (stream_copy_to_stream() produces warning when source is - not file). (Stas) -- Fixed bug #50195 (pg_copy_to() fails when table name contains schema. (Ilia) -- Fixed bug #50185 (ldap_get_entries() return false instead of an empty array - when there is no error). (Jani) -- Fixed bug #50174 (Incorrectly matched docComment). (Felipe) -- Fixed bug #50168 (FastCGI fails with wrong error on HEAD request to - non-existant file). (Dmitry) -- Fixed bug #50162 (Memory leak when fetching timestamp column from Oracle - database). (Felipe) -- Fixed bug #50159 (wrong working directory in symlinked files). (Dmitry) -- Fixed bug #50158 (FILTER_VALIDATE_EMAIL fails with valid addresses - containing = or ?). (Pierrick) -- Fixed bug #50152 (ReflectionClass::hasProperty behaves like isset() not - property_exists). (Felipe) -- Fixed bug #50146 (property_exists: Closure object cannot have properties). - (Felipe) -- Fixed bug #50145 (crash while running bug35634.phpt). (Felipe) -- Fixed bug #50140 (With default compilation option, php symbols are unresolved - for nsapi). (Uwe Schindler) -- Fixed bug #50087 (NSAPI performance improvements). (Uwe Schindler) -- Fixed bug #50073 (parse_url() incorrect when ? in fragment). (Ilia) -- Fixed bug #50023 (pdo_mysql doesn't use PHP_MYSQL_UNIX_SOCK_ADDR). (Ilia) -- Fixed bug #50005 (Throwing through Reflection modified Exception object - makes segmentation fault). (Felipe) -- Fixed bug #49990 (SNMP3 warning message about security level printed twice). - (Jani) -- Fixed bug #49985 (pdo_pgsql prepare() re-use previous aborted - transaction). (ben dot pineau at gmail dot com, Ilia, Matteo) -- Fixed bug #49938 (Phar::isBuffering() returns inverted value). (Greg) -- Fixed bug #49936 (crash with ftp stream in php_stream_context_get_option()). - (Pierrick) -- Fixed bug #49921 (Curl post upload functions changed). (Ilia) -- Fixed bug #49866 (Making reference on string offsets crashes PHP). (Dmitry) -- Fixed bug #49855 (import_request_variables() always returns NULL). (Ilia, - sjoerd at php dot net) -- Fixed bug #49851, #50451 (http wrapper breaks on 1024 char long headers). - (Ilia) -- Fixed bug #49800 (SimpleXML allow (un)serialize() calls without warning). - (Ilia, wmeler at wp-sa dot pl) -- Fixed bug #49719 (ReflectionClass::hasProperty returns true for a private - property in base class). (Felipe) -- Fixed bug #49677 (ini parser crashes with apache2 and using ${something} - ini variables). (Jani) -- Fixed bug #49660 (libxml 2.7.3+ limits text nodes to 10MB). (Felipe) -- Fixed bug #49647 (DOMUserData does not exist). (Rob) -- Fixed bug #49600 (imageTTFText text shifted right). (Takeshi Abe) -- Fixed bug #49585 (date_format buffer not long enough for >4 digit years). - (Derick, Adam) -- Fixed bug #49560 (oci8: using LOBs causes slow PHP shutdown). (Oracle Corp.) -- Fixed bug #49521 (PDO fetchObject sets values before calling constructor). - (Pierrick) -- Fixed bug #49472 (Constants defined in Interfaces can be overridden). - (Felipe) -- Fixed bug #49463 (setAttributeNS fails setting default namespace). (Rob) -- Fixed bug #49244 (Floating point NaN cause garbage characters). (Sjoerd) -- Fixed bug #49224 (Compile error due to old DNS functions on AIX systems). - (Scott) -- Fixed bug #49174 (crash when extending PDOStatement and trying to set - queryString property). (Felipe) -- Fixed bug #48811 (Directives in PATH section do not get applied to - subdirectories). (Patch by: ct at swin dot edu dot au) -- Fixed bug #48590 (SoapClient does not honor max_redirects). (Sriram) -- Fixed bug #48190 (Content-type parameter "boundary" is not case-insensitive - in HTTP uploads). (Ilia) -- Fixed bug #47848 (importNode doesn't preserve attribute namespaces). (Rob) -- Fixed bug #47409 (extract() problem with array containing word "this"). - (Ilia, chrisstocktonaz at gmail dot com) -- Fixed bug #47281 ($php_errormsg is limited in size of characters) - (Oracle Corp.) -- Fixed bug #46478 (htmlentities() uses obsolete mapping table for character - entity references). (Moriyoshi) -- Fixed bug #45599 (strip_tags() truncates rest of string with invalid - attribute). (Ilia, hradtke) -- Fixed bug #45120 (PDOStatement->execute() returns true then false for same - statement). (Pierrick) -- Fixed bug #44827 (define() allows :: in constant names). (Ilia) -- Fixed bug #44098 (imap_utf8() returns only capital letters). - (steffen at dislabs dot de, Pierre) -- Fixed bug #34852 (Failure in odbc_exec() using oracle-supplied odbc - driver). (tim dot tassonis at trivadis dot com) - -19 Nov 2009, PHP 5.3.1 -- Upgraded bundled sqlite to version 3.6.19. (Scott) -- Updated timezone database to version 2009.17 (2009q). (Derick) - -- Changed ini file directives [PATH=](on Win32) and [HOST=](on all) to be case - insensitive. (garretts) - -- Restored shebang line check to CGI sapi (not checked by scanner anymore). - (Jani) - -- Added "max_file_uploads" INI directive, which can be set to limit the - number of file uploads per-request to 20 by default, to prevent possible - DOS via temporary file exhaustion. (Ilia) -- Added missing sanity checks around exif processing. (Ilia) -- Added error constant when json_encode() detects an invalid UTF-8 sequence. - (Scott) -- Added support for ACL on Windows for thread safe SAPI (Apache2 for example) - and fix its support on NTS. (Pierre) - -- Improved symbolic, mounted volume and junctions support for realpath on - Windows. (Pierre) -- Improved readlink on Windows, suppress \??\ and use the drive syntax only. - (Pierre) -- Improved dns_get_record() AAAA support on windows. Always available when - IPv6 is support is installed, format is now the same than on unix. (Pierre) -- Improved the DNS functions on OSX to use newer APIs, also use Bind 9 API - where available on other platforms. (Scott) -- Improved shared extension loading on OSX to use the standard Unix dlopen() - API. (Scott) - -- Fixed crash in com_print_typeinfo when an invalid typelib is given. (Pierre) -- Fixed a safe_mode bypass in tempnam() identified by Grzegorz Stachowiak. - (Rasmus) -- Fixed a open_basedir bypass in posix_mkfifo() identified by Grzegorz - Stachowiak. (Rasmus) -- Fixed certificate validation inside php_openssl_apply_verification_policy - (Ryan Sleevi, Ilia) -- Fixed crash in SQLiteDatabase::ArrayQuery() and SQLiteDatabase::SingleQuery() - when calling using Reflection. (Felipe) -- Fixed crash when instantiating PDORow and PDOStatement through Reflection. - (Felipe) -- Fixed sanity check for the color index in imagecolortransparent. (Pierre) -- Fixed scandir/readdir when used mounted points on Windows. (Pierre) -- Fixed zlib.deflate compress filter to actually accept level parameter. (Jani) -- Fixed leak on error in popen/exec (and related functions) on Windows. - (Pierre) -- Fixed possible bad caching of symlinked directories in the realpath cache - on Windows. (Pierre) -- Fixed atime and mtime in stat related functions on Windows. (Pierre) -- Fixed spl_autoload_unregister/spl_autoload_functions wrt. Closures and - Functors. (Christian Seiler) -- Fixed open_basedir circumvention for "mail.log" ini directive. - (Maksymilian Arciemowicz, Stas) -- Fixed signature generation/validation for zip archives in ext/phar. (Greg) -- Fixed memory leak in stream_is_local(). (Felipe, Tony) -- Fixed BC break in mime_content_type(), removes the content encoding. (Scott) - -- Fixed PECL bug #16842 (oci_error return false when NO_DATA_FOUND is raised). - (Chris Jones) - -- Fixed bug #50063 (safe_mode_include_dir fails). (Johannes, christian at - elmerot dot se) -- Fixed bug #50052 (Different Hashes on Windows and Linux on wrong Salt size). - (Pierre) -- Fixed bug #49986 (Missing ICU DLLs on windows package). (Pierre) -- Fixed bug #49910 (no support for ././@LongLink for long filenames in phar - tar support). (Greg) -- Fixed bug #49908 (throwing exception in __autoload crashes when interface - is not defined). (Felipe) -- Fixed bug #49847 (exec() fails to return data inside 2nd parameter, given - output lines >4095 bytes). (Ilia) -- Fixed bug #49809 (time_sleep_until() is not available on OpenSolaris). (Jani) -- Fixed bug #49757 (long2ip() can return wrong value in a multi-threaded - applications). (Ilia, Florian Anderiasch) -- Fixed bug #49738 (calling mcrypt after mcrypt_generic_deinit crashes). - (Sriram Natarajan) -- Fixed bug #49732 (crashes when using fileinfo when timestamp conversion - fails). (Pierre) -- Fixed bug #49698 (Unexpected change in strnatcasecmp()). (Rasmus) -- Fixed bug #49630 (imap_listscan function missing). (Felipe) -- Fixed bug #49572 (use of C++ style comments causes build failure). - (Sriram Natarajan) -- Fixed bug #49531 (CURLOPT_INFILESIZE sometimes causes warning "CURLPROTO_FILE - cannot be set"). (Felipe) -- Fixed bug #49517 (cURL's CURLOPT_FILE prevents file from being deleted after - fclose). (Ilia) -- Fixed bug #49470 (FILTER_SANITIZE_EMAIL allows disallowed characters). - (Ilia) -- Fixed bug #49447 (php engine need to correctly check for socket API - return status on windows). (Sriram Natarajan) -- Fixed bug #49391 (ldap.c utilizing deprecated ldap_modify_s). (Ilia) -- Fixed bug #49372 (segfault in php_curl_option_curl). (Pierre) -- Fixed bug #49361 (wordwrap() wraps incorrectly on end of line boundaries). - (Ilia, code-it at mail dot ru) -- Fixed bug #49306 (inside pdo_mysql default socket settings are ignored). - (Ilia) -- Fixed bug #49289 (bcmath module doesn't compile with phpize configure). - (Jani) -- Fixed bug #49286 (php://input (php_stream_input_read) is broken). (Jani) -- Fixed bug #49269 (Ternary operator fails on Iterator object when used inside - foreach declaration). (Etienne, Dmitry) -- Fixed bug #49236 (Missing PHP_SUBST(PDO_MYSQL_SHARED_LIBADD)). (Jani) -- Fixed bug #49223 (Inconsistency using get_defined_constants). (Garrett) -- Fixed bug #49193 (gdJpegGetVersionString() inside gd_compact identifies - wrong type in declaration). (Ilia) -- Fixed bug #49183 (dns_get_record does not return NAPTR records). (Pierre) -- Fixed bug #49144 (Import of schema from different host transmits original - authentication details). (Dmitry) -- Fixed bug #49142 (crash when exception thrown from __tostring()). - (David Soria Parra) -- Fixed bug #49132 (posix_times returns false without error). - (phpbugs at gunnu dot us) -- Fixed bug #49125 (Error in dba_exists C code). (jdornan at stanford dot edu) -- Fixed bug #49122 (undefined reference to mysqlnd_stmt_next_result on compile - with --with-mysqli and MySQL 6.0). (Jani) -- Fixed bug #49108 (2nd scan_dir produces segfault). (Felipe) -- Fixed bug #49098 (mysqli segfault on error). (Rasmus) -- Fixed bug #49095 (proc_get_status['exitcode'] fails on win32). (Felipe) -- Fixed bug #49092 (ReflectionFunction fails to work with functions in fully - qualified namespaces). (Kalle, Jani) -- Fixed bug #49074 (private class static fields can be modified by using - reflection). (Jani) -- Fixed bug #49072 (feof never returns true for damaged file in zip). (Pierre) -- Fixed bug #49065 ("disable_functions" php.ini option does not work on - Zend extensions). (Stas) -- Fixed bug #49064 (--enable-session=shared does not work: undefined symbol: - php_url_scanner_reset_vars). (Jani) -- Fixed bug #49056 (parse_ini_file() regression in 5.3.0 when using non-ASCII - strings as option keys). (Jani) -- Fixed bug #49052 (context option headers freed too early when using - --with-curlwrappers). (Jani) -- Fixed bug #49047 (The function touch() fails on directories on Windows). - (Pierre) -- Fixed bug #49032 (SplFileObject::fscanf() variables passed by reference). - (Jani) -- Fixed bug #49027 (mysqli_options() doesn't work when using mysqlnd). (Andrey) -- Fixed bug #49026 (proc_open() can bypass safe_mode_protected_env_vars - restrictions). (Ilia) -- Fixed bug #49020 (phar misinterprets ustar long filename standard). - (Greg) -- Fixed bug #49018 (phar tar stores long filenames wit prefix/name reversed). - (Greg) -- Fixed bug #49014 (dechunked filter broken when serving more than 8192 bytes - in a chunk). (andreas dot streichardt at globalpark dot com, Ilia) -- Fixed bug #49012 (phar tar signature algorithm reports as Unknown (0) in - getSignature() call). (Greg) -- Fixed bug #49000 (PHP CLI in Interactive mode (php -a) crashes - when including files from function). (Stas) -- Fixed bug #48994 (zlib.output_compression does not output HTTP headers when - set to a string value). (Jani) -- Fixed bug #48980 (Crash when compiling with pdo_firebird). (Felipe) -- Fixed bug #48962 (cURL does not upload files with specified filename). - (Ilia) -- Fixed bug #48929 (Double \r\n after HTTP headers when "header" context - option is an array). (David Zülke) -- Fixed bug #48913 (Too long error code strings in pdo_odbc driver). - (naf at altlinux dot ru, Felipe) -- Fixed bug #48912 (Namespace causes unexpected strict behaviour with - extract()). (Dmitry) -- Fixed bug #48909 (Segmentation fault in mysqli_stmt_execute()). (Andrey) -- Fixed bug #48899 (is_callable returns true even if method does not exist in - parent class). (Felipe) -- Fixed bug #48893 (Problems compiling with Curl). (Felipe) -- Fixed bug #48880 (Random Appearing open_basedir problem). (Rasmus, Gwynne) -- Fixed bug #48872 (string.c: errors: duplicate case values). (Kalle) -- Fixed bug #48854 (array_merge_recursive modifies arrays after first one). - (Felipe) -- Fixed bug #48805 (IPv6 socket transport is not working). (Ilia) -- Fixed bug #48802 (printf() returns incorrect outputted length). (Jani) -- Fixed bug #48791 (open office files always reported as corrupted). (Greg) -- Fixed bug #48788 (RecursiveDirectoryIterator doesn't descend into symlinked - directories). (Ilia) -- Fixed bug #48783 (make install will fail saying phar file exists). (Greg) -- Fixed bug #48774 (SIGSEGVs when using curl_copy_handle()). - (Sriram Natarajan) -- Fixed bug #48771 (rename() between volumes fails and reports no error on - Windows). (Pierre) -- Fixed bug #48768 (parse_ini_*() crash with INI_SCANNER_RAW). (Jani) -- Fixed bug #48763 (ZipArchive produces corrupt archive). (dani dot church at - gmail dot com, Pierre) -- Fixed bug #48762 (IPv6 address filter still rejects valid address). (Felipe) -- Fixed bug #48757 (ReflectionFunction::invoke() parameter issues). (Kalle) -- Fixed bug #48754 (mysql_close() crash php when no handle specified). - (Johannes, Andrey) -- Fixed bug #48752 (Crash during date parsing with invalid date). (Pierre) -- Fixed bug #48746 (Unable to browse directories within Junction Points). - (Pierre, Kanwaljeet Singla) -- Fixed bug #48745 (mysqlnd: mysql_num_fields returns wrong column count for - mysql_list_fields). (Andrey) -- Fixed bug #48740 (PHAR install fails when INSTALL_ROOT is not the final - install location). (james dot cohen at digitalwindow dot com, Greg) -- Fixed bug #48733 (CURLOPT_WRITEHEADER|CURLOPT_FILE|CURLOPT_STDERR warns on - files that have been opened with r+). (Ilia) -- Fixed bug #48719 (parse_ini_*(): scanner_mode parameter is not checked for - sanity). (Jani) -- Fixed bug #48718 (FILTER_VALIDATE_EMAIL does not allow numbers in domain - components). (Ilia) -- Fixed bug #48681 (openssl signature verification for tar archives broken). - (Greg) -- Fixed bug #48660 (parse_ini_*(): dollar sign as last character of value - fails). (Jani) -- Fixed bug #48645 (mb_convert_encoding() doesn't understand hexadecimal - html-entities). (Moriyoshi) -- Fixed bug #48637 ("file" fopen wrapper is overwritten when using - --with-curlwrappers). (Jani) -- Fixed bug #48608 (Invalid libreadline version not detected during configure). - (Jani) -- Fixed bug #48400 (imap crashes when closing stream opened with - OP_PROTOTYPE flag). (Jani) -- Fixed bug #48377 (error message unclear on converting phar with existing - file). (Greg) -- Fixed bug #48247 (Infinite loop and possible crash during startup with - errors when errors are logged). (Jani) -- Fixed bug #48198 error: 'MYSQLND_LLU_SPEC' undeclared. Cause for #48780 and - #46952 - both fixed too. (Andrey) -- Fixed bug #48189 (ibase_execute error in return param). (Kalle) -- Fixed bug #48182 (ssl handshake fails during asynchronous socket connection). - (Sriram Natarajan) -- Fixed bug #48116 (Fixed build with Openssl 1.0). (Pierre, - Al dot Smith at aeschi dot ch dot eu dot org) -- Fixed bug #48057 (Only the date fields of the first row are fetched, others - are empty). (info at programmiernutte dot net) -- Fixed bug #47481 (natcasesort() does not sort extended ASCII characters - correctly). (Herman Radtke) -- Fixed bug #47351 (Memory leak in DateTime). (Derick, Tobias John) -- Fixed bug #47273 (Encoding bug in SoapServer->fault). (Dmitry) -- Fixed bug #46682 (touch() afield returns different values on windows). - (Pierre) -- Fixed bug #46614 (Extended MySQLi class gives incorrect empty() result). - (Andrey) -- Fixed bug #46020 (with Sun Java System Web Server 7.0 on HPUX, #define HPUX). - (Uwe Schindler) -- Fixed bug #45905 (imagefilledrectangle() clipping error). - (markril at hotmail dot com, Pierre) -- Fixed bug #45554 (Inconsistent behavior of the u format char). (Derick) -- Fixed bug #45141 (setcookie will output expires years of >4 digits). (Ilia) -- Fixed bug #44683 (popen crashes when an invalid mode is passed). (Pierre) -- Fixed bug #43510 (stream_get_meta_data() does not return same mode as used - in fopen). (Jani) -- Fixed bug #42434 (ImageLine w/ antialias = 1px shorter). (wojjie at gmail dot - com, Kalle) -- Fixed bug #40013 (php_uname() does not return nodename on Netware (Guenter - Knauf) -- Fixed bug #38091 (Mail() does not use FQDN when sending SMTP helo). - (Kalle, Rick Yorgason) -- Fixed bug #28038 (Sent incorrect RCPT TO commands to SMTP server) (Garrett) -- Fixed bug #27051 (Impersonation with FastCGI does not exec process as - impersonated user). (Pierre) - - -30 Jun 2009, PHP 5.3.0 -- Upgraded bundled PCRE to version 7.9. (Nuno) -- Upgraded bundled sqlite to version 3.6.15. (Scott) - -- Moved extensions to PECL (Derick, Lukas, Pierre, Scott): - . ext/dbase - . ext/fbsql - . ext/fdf - . ext/ncurses - . ext/mhash (BC layer is now entirely within ext/hash) - . ext/ming - . ext/msql - . ext/sybase (not maintained anymore, sybase_ct has to be used instead) - -- Removed the experimental RPL (master/slave) functions from mysqli. (Andrey) -- Removed zend.ze1_compatibility_mode. (Dmitry) -- Removed all zend_extension_* php.ini directives. Zend extensions are now - always loaded using zend_extension directive. (Derick) -- Removed special treatment of "/tmp" in sessions for open_basedir. - Note: This undocumented behaviour was introduced in 5.2.2. (Alexey) -- Removed shebang line check from CGI sapi (checked by scanner). (Dmitry) - -- Changed PCRE, Reflection and SPL extensions to be always enabled. (Marcus) -- Changed md5() to use improved implementation. (Solar Designer, Dmitry) -- Changed HTTP stream wrapper to accept any code between and including - 200 to 399 as successful. (Mike, Noah Fontes) -- Changed __call() to be invoked on private/protected method access, similar to - properties and __get(). (Andrei) -- Changed dl() to be disabled by default. Enabled only when explicitly - registered by the SAPI. Currently enabled with cli, cgi and embed SAPIs. - (Dmitry) -- Changed opendir(), dir() and scandir() to use default context when no context - argument is passed. (Sara) -- Changed open_basedir to allow tightening in runtime contexts. (Sara) -- Changed PHP/Zend extensions to use flexible build IDs. (Stas) -- Changed error level E_ERROR into E_WARNING in Soap extension methods - parameter validation. (Felipe) -- Changed openssl info to show the shared library version number. (Scott) -- Changed floating point behaviour to consistently use double precision on all - platforms and with all compilers. (Christian Seiler) -- Changed round() to act more intuitively when rounding to a certain precision - and round very large and very small exponents correctly. (Christian Seiler) -- Changed session_start() to return false when session startup fails. (Jani) -- Changed property_exists() to check the existence of a property independent of - accessibility (like method_exists()). (Felipe) -- Changed array_reduce() to allow mixed $initial (Christian Seiler) - -- Improved PHP syntax and semantics: - . Added lambda functions and closures. (Christian Seiler, Dmitry) - . Added "jump label" operator (limited "goto"). (Dmitry, Sara) - . Added NOWDOC syntax. (Gwynne Raskind, Stas, Dmitry) - . Added HEREDOC syntax with double quotes. (Lars Strojny, Felipe) - . Added support for using static HEREDOCs to initialize static variables and - class members or constants. (Matt) - . Improved syntax highlighting and consistency for variables in double-quoted - strings and literal text in HEREDOCs and backticks. (Matt) - . Added "?:" operator. (Marcus) - . Added support for namespaces. (Dmitry, Stas, Gregory, Marcus) - . Added support for Late Static Binding. (Dmitry, Etienne Kneuss) - . Added support for __callStatic() magic method. (Sara) - . Added forward_static_call(_array) to complete LSB. (Mike Lively) - . Added support for dynamic access of static members using $foo::myFunc(). - (Etienne Kneuss) - . Improved checks for callbacks. (Marcus) - . Added __DIR__ constant. (Lars Strojny) - . Added new error modes E_USER_DEPRECATED and E_DEPRECATED. - E_DEPRECATED is used to inform about stuff being scheduled for removal - in future PHP versions. (Lars Strojny, Felipe, Marcus) - . Added "request_order" INI variable to control specifically $_REQUEST - behavior. (Stas) - . Added support for exception linking. (Marcus) - . Added ability to handle exceptions in destructors. (Marcus) - -- Improved PHP runtime speed and memory usage: - . Substitute global-scope, persistent constants with their values at compile - time. (Matt) - . Optimized ZEND_SIGNED_MULTIPLY_LONG(). (Matt) - . Removed direct executor recursion. (Dmitry) - . Use fastcall calling convention in executor on x86. (Dmitry) - . Use IS_CV for direct access to $this variable. (Dmitry) - . Use ZEND_FREE() opcode instead of ZEND_SWITCH_FREE(IS_TMP_VAR). (Dmitry) - . Lazy EG(active_symbol_table) initialization. (Dmitry) - . Optimized ZEND_RETURN opcode to not allocate and copy return value if it is - not used. (Dmitry) - . Replaced all flex based scanners with re2c based scanners. - (Marcus, Nuno, Scott) - . Added garbage collector. (David Wang, Dmitry). - . Improved PHP binary size and startup speed with GCC4 visibility control. - (Nuno) - . Improved engine stack implementation for better performance and stability. - (Dmitry) - . Improved memory usage by moving constants to read only memory. - (Dmitry, Pierre) - . Changed exception handling. Now each op_array doesn't contain - ZEND_HANDLE_EXCEPTION opcode in the end. (Dmitry) - . Optimized require_once() and include_once() by eliminating fopen(3) on - second usage. (Dmitry) - . Optimized ZEND_FETCH_CLASS + ZEND_ADD_INTERFACE into single - ZEND_ADD_INTERFACE opcode. (Dmitry) - . Optimized string searching for a single character. - (Michal Dziemianko, Scott) - . Optimized interpolated strings to use one less opcode. (Matt) - -- Improved php.ini handling: (Jani) - . Added ".htaccess" style user-defined php.ini files support for CGI/FastCGI. - . Added support for special [PATH=/opt/httpd/www.example.com/] and - [HOST=www.example.com] sections. Directives set in these sections can - not be overridden by user-defined ini-files or during runtime. - . Added better error reporting for php.ini syntax errors. - . Allowed using full path to load modules using "extension" directive. - . Allowed "ini-variables" to be used almost everywhere ini php.ini files. - . Allowed using alphanumeric/variable indexes in "array" ini options. - . Added 3rd optional parameter to parse_ini_file() to specify the scanning - mode of INI_SCANNER_NORMAL or INI_SCANNER_RAW. In raw mode option values - and section values are treated as-is. - . Fixed get_cfg_var() to be able to return "array" ini options. - . Added optional parameter to ini_get_all() to only retrieve the current - value. (Hannes) - -- Improved Windows support: - . Update all libraries to their latest stable version. (Pierre, Rob, Liz, - Garrett). - . Added Windows support for stat(), touch(), filemtime(), filesize() and - related functions. (Pierre) - . Re-added socket_create_pair() for Windows in sockets extension. (Kalle) - . Added inet_pton() and inet_ntop() also for Windows platforms. - (Kalle, Pierre) - . Added mcrypt_create_iv() for Windows platforms. (Pierre) - . Added ACL Cache support on Windows. - (Kanwaljeet Singla, Pierre, Venkat Raman Don) - . Added constants based on Windows' GetVersionEx information. - PHP_WINDOWS_VERSION_* and PHP_WINDOWS_NT_*. (Pierre) - . Added support for ACL (is_writable, is_readable, reports now correct - results) on Windows. (Pierre, Venkat Raman Don, Kanwaljeet Singla) - . Added support for fnmatch() on Windows. (Pierre) - . Added support for time_nanosleep() and time_sleep_until() on Windows. - (Pierre) - . Added support for symlink(), readlink(), linkinfo() and link() on Windows. - They are available only when the running platform supports them. (Pierre) - . the GMP extension now relies on MPIR instead of the GMP library. (Pierre) - . Added Windows support for stream_socket_pair(). (Kalle) - . Drop all external dependencies for the core features. (Pierre) - . Drastically improve the build procedure (Pierre, Kalle, Rob): - . VC9 (Visual C++ 2008) or later support - . Initial experimental x64 support - . MSI installer now supports all recent Windows versions, including - Windows 7. (John, Kanwaljeet Singla) - -- Improved and cleaned CGI code: - . FastCGI is now always enabled and cannot be disabled. - See sapi/cgi/CHANGES for more details. (Dmitry) - . Added CGI SAPI -T option which can be used to measure execution - time of script repeated several times. (Dmitry) - -- Improved streams: - . Fixed confusing error message on failure when no errors are logged. (Greg) - . Added stream_supports_lock() function. (Benjamin Schulz) - . Added context parameter for copy() function. (Sara) - . Added "glob://" stream wrapper. (Marcus) - . Added "params" as optional parameter for stream_context_create(). (Sara) - . Added ability to use stream wrappers in include_path. (Gregory, Dmitry) - -- Improved DNS API - . Added Windows support for dns_check_record(), dns_get_mx(), checkdnsrr() and - getmxrr(). (Pierre) - . Added support for old style DNS functions (supports OSX and FBSD). (Scott) - . Added a new "entries" array in dns_check_record() containing the TXT - elements. (Felipe, Pierre) - -- Improved hash extension: - . Changed mhash to be a wrapper layer around the hash extension. (Scott) - . Added hash_copy() function. (Tony) - . Added sha224 hash algorithm to the hash extension. (Scott) - -- Improved IMAP support (Pierre): - . Added imap_gc() to clear the imap cache - . Added imap_utf8_to_mutf7() and imap_mutf7_to_utf8() - -- Improved mbstring extension: - . Added "mbstring.http_output_conv_mimetypes" INI directive that allows - common non-text types such as "application/xhtml+xml" to be converted - by mb_output_handler(). (Moriyoshi) - -- Improved OCI8 extension (Chris Jones/Oracle Corp.): - . Added Database Resident Connection Pooling (DRCP) and Fast - Application Notification (FAN) support. - . Added support for Oracle External Authentication (not supported - on Windows). - . Improve persistent connection handling of restarted DBs. - . Added SQLT_AFC (aka CHAR datatype) support to oci_bind_by_name. - . Fixed bug #45458 (Numeric keys for associative arrays are not - handled properly) - . Fixed bug #41069 (Segmentation fault with query over DB link). - . Fixed define of SQLT_BDOUBLE and SQLT_BFLOAT constants with Oracle - 10g ORACLE_HOME builds. - . Changed default value of oci8.default_prefetch from 10 to 100. - . Fixed PECL Bug #16035 (OCI8: oci_connect without ORACLE_HOME defined causes - segfault) (Chris Jones/Oracle Corp.) - . Fixed PECL Bug #15988 (OCI8: sqlnet.ora isn't read with older Oracle - libraries) (Chris Jones/Oracle Corp.) - . Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an - Instant Client RPM install) (Chris Jones/Oracle Corp.) - . Fixed PECL bug #12431 (OCI8 ping functionality is broken). - . Allow building (e.g from PECL) the PHP 5.3-based OCI8 code with - PHP 4.3.9 onwards. - . Provide separate extensions for Oracle 11g and 10g on Windows. - (Pierre, Chris) - -- Improved OpenSSL extension: - . Added support for OpenSSL digest and cipher functions. (Dmitry) - . Added access to internal values of DSA, RSA and DH keys. (Dmitry) - . Fixed a memory leak on openssl_decrypt(). (Henrique) - . Fixed segfault caused by openssl_pkey_new(). (Henrique) - . Fixed bug caused by uninitilized variables in openssl_pkcs7_encrypt() and - openssl_pkcs7_sign(). (Henrique) - . Fixed error message in openssl_seal(). (Henrique) - -- Improved pcntl extension: (Arnaud) - . Added pcntl_signal_dispatch(). - . Added pcntl_sigprocmask(). - . Added pcntl_sigwaitinfo(). - . Added pcntl_sigtimedwait(). - -- Improved SOAP extension: - . Added support for element names in context of XMLSchema's . (Dmitry) - . Added ability to use Traversable objects instead of plain arrays. - (Joshua Reese, Dmitry) - . Fixed possible crash bug caused by an uninitialized value. (Zdash Urf) - -- Improved SPL extension: - . Added SPL to list of standard extensions that cannot be disabled. (Marcus) - . Added ability to store associative information with objects in - SplObjectStorage. (Marcus) - . Added ArrayAccess support to SplObjectStorage. (Marcus) - . Added SplDoublyLinkedList, SplStack, SplQueue classes. (Etienne) - . Added FilesystemIterator. (Marcus) - . Added GlobIterator. (Marcus) - . Added SplHeap, SplMinHeap, SplMaxHeap, SplPriorityQueue classes. (Etienne) - . Added new parameter $prepend to spl_autoload_register(). (Etienne) - . Added SplFixedArray. (Etienne, Tony) - . Added delaying exceptions in SPL's autoload mechanism. (Marcus) - . Added RecursiveTreeIterator. (Arnaud, Marcus) - . Added MultipleIterator. (Arnaud, Marcus, Johannes) - -- Improved Zend Engine: - . Added "compact" handler for Zend MM storage. (Dmitry) - . Added "+" and "*" specifiers to zend_parse_parameters(). (Andrei) - . Added concept of "delayed early binding" that allows opcode caches to - perform class declaration (early and/or run-time binding) in exactly - the same order as vanilla PHP. (Dmitry) - -- Improved crypt() function: (Pierre) - . Added Blowfish and extended DES support. (Using Blowfish implementation - from Solar Designer). - . Made crypt features portable by providing our own implementations - for crypt_r and the algorithms which are used when OS does not provide - them. PHP implementations are always used for Windows builds. - -- Deprecated session_register(), session_unregister() and - session_is_registered(). (Hannes) -- Deprecated define_syslog_variables(). (Kalle) -- Deprecated ereg extension. (Felipe) - -- Added new extensions: - . Added Enchant extension as a way to access spell checkers. (Pierre) - . Added fileinfo extension as replacement for mime_magic extension. (Derick) - . Added intl extension for Internationalization. (Ed B., Vladimir I., - Dmitry L., Stanislav M., Vadim S., Kirti V.) - . Added mysqlnd extension as replacement for libmysql for ext/mysql, mysqli - and PDO_mysql. (Andrey, Johannes, Ulf) - . Added phar extension for handling PHP Archives. (Greg, Marcus, Steph) - . Added SQLite3 extension. (Scott) - -- Added new date/time functionality: (Derick) - . date_parse_from_format(): Parse date/time strings according to a format. - . date_create_from_format()/DateTime::createFromFormat(): Create a date/time - object by parsing a date/time string according to a given format. - . date_get_last_errors()/DateTime::getLastErrors(): Return a list of warnings - and errors that were found while parsing a date/time string through: - . strtotime() / new DateTime - . date_create_from_format() / DateTime::createFromFormat() - . date_parse_from_format(). - . support for abbreviation and offset based timezone specifiers for - the 'e' format specifier, DateTime::__construct(), DateTime::getTimeZone() - and DateTimeZone::getName(). - . support for selectively listing timezone identifiers by continent or - country code through timezone_identifiers_list() / - DateTimezone::listIdentifiers(). - . timezone_location_get() / DateTimezone::getLocation() for retrieving - location information from timezones. - . date_timestamp_set() / DateTime::setTimestamp() to set a Unix timestamp - without invoking the date parser. (Scott, Derick) - . date_timestamp_get() / DateTime::getTimestamp() to retrieve the Unix - timestamp belonging to a date object. - . two optional parameters to timezone_transitions_get() / - DateTimeZone::getTranstions() to limit the range of transitions being - returned. - . support for "first/last day of " style texts. - . support for date/time strings returned by MS SQL. - . support for serialization and unserialization of DateTime objects. - . support for diffing date/times through date_diff() / DateTime::diff(). - . support for adding/subtracting weekdays with strtotime() and - DateTime::modify(). - . DateInterval class to represent the difference between two date/times. - . support for parsing ISO intervals for use with DateInterval. - . date_add() / DateTime::add(), date_sub() / DateTime::sub() for applying an - interval to an existing date/time. - . proper support for "this week", "previous week"/"last week" and "next week" - phrases so that they actually mean the week and not a seven day period - around the current day. - . support for " of" and "last of" phrases to be used - with months - like in "last saturday of februari 2008". - . support for "back of " and "front of " phrases that are used in - Scotland. - . DatePeriod class which supports iterating over a DateTime object applying - DateInterval on each iteration, up to an end date or limited by maximum - number of occurences. - -- Added compatibility mode in GD, imagerotate, image(filled)ellipse - imagefilter, imageconvolution and imagecolormatch are now always enabled. - (Pierre) -- Added array_replace() and array_replace_recursive() functions. (Matt) -- Added ReflectionProperty::setAccessible() method that allows non-public - property's values to be read through ::getValue() and set through - ::setValue(). (Derick, Sebastian) -- Added msg_queue_exists() function to sysvmsg extension. (Benjamin Schulz) -- Added Firebird specific attributes that can be set via PDO::setAttribute() - to control formatting of date/timestamp columns: PDO::FB_ATTR_DATE_FORMAT, - PDO::FB_ATTR_TIME_FORMAT and PDO::FB_ATTR_TIMESTAMP_FORMAT. (Lars W) -- Added gmp_testbit() function. (Stas) -- Added icon format support to getimagesize(). (Scott) -- Added LDAP_OPT_NETWORK_TIMEOUT option for ldap_set_option() to allow - setting network timeout (FR #42837). (Jani) -- Added optional escape character parameter to fgetcsv(). (David Soria Parra) -- Added an optional parameter to strstr() and stristr() for retrieval of either - the part of haystack before or after first occurrence of needle. - (Johannes, Felipe) -- Added xsl->setProfiling() for profiling stylesheets. (Christian) -- Added long-option feature to getopt() and made getopt() available also on - win32 systems by adding a common getopt implementation into core. - (David Soria Parra, Jani) -- Added support for optional values, and = as separator, in getopt(). (Hannes) -- Added lcfirst() function. (David C) -- Added PREG_BAD_UTF8_OFFSET_ERROR constant. (Nuno) -- Added native support for asinh(), acosh(), atanh(), log1p() and expm1(). - (Kalle) -- Added LIBXML_LOADED_VERSION constant (libxml2 version currently used). (Rob) -- Added JSON_FORCE_OBJECT flag to json_encode(). (Scott, Richard Quadling) -- Added timezone_version_get() to retrieve the version of the used timezone - database. (Derick) -- Added 'n' flag to fopen to allow passing O_NONBLOCK to the underlying - open(2) system call. (Mikko) -- Added "dechunk" filter which can decode HTTP responses with chunked - transfer-encoding. HTTP streams use this filter automatically in case - "Transfer-Encoding: chunked" header is present in response. It's possible to - disable this behaviour using "http"=>array("auto_decode"=>0) in stream - context. (Dmitry) -- Added support for CP850 encoding in mbstring extension. - (Denis Giffeler, Moriyoshi) -- Added stream_cast() and stream_set_options() to user-space stream wrappers, - allowing stream_select(), stream_set_blocking(), stream_set_timeout() and - stream_set_write_buffer() to work with user-space stream wrappers. (Arnaud) -- Added header_remove() function. (chsc at peytz dot dk, Arnaud) -- Added stream_context_get_params() function. (Arnaud) -- Added optional parameter "new" to sybase_connect(). (Timm) -- Added parse_ini_string() function. (grange at lemonde dot fr, Arnaud) -- Added str_getcsv() function. (Sara) -- Added openssl_random_pseudo_bytes() function. (Scott) -- Added ability to send user defined HTTP headers with SOAP request. - (Brian J.France, Dmitry) -- Added concatenation option to bz2.decompress stream filter. - (Keisial at gmail dot com, Greg) -- Added support for using compressed connections with PDO_mysql. (Johannes) -- Added the ability for json_decode() to take a user specified depth. (Scott) -- Added support for the mysql_stmt_next_result() function from libmysql. - (Andrey) -- Added function preg_filter() that does grep and replace in one go. (Marcus) -- Added system independent realpath() implementation which caches intermediate - directories in realpath-cache. (Dmitry) -- Added optional clear_realpath_cache and filename parameters to - clearstatcache(). (Jani, Arnaud) -- Added litespeed SAPI module. (George Wang) -- Added ext/hash support to ext/session's ID generator. (Sara) -- Added quoted_printable_encode() function. (Tony) -- Added stream_context_set_default() function. (Davey Shafik) -- Added optional "is_xhtml" parameter to nl2br() which makes the function - output
when false and
when true (FR #34381). (Kalle) -- Added PHP_MAXPATHLEN constant (maximum length of a path). (Pierre) -- Added support for SSH via libssh2 in cURL. (Pierre) -- Added support for gray levels PNG image with alpha in GD extension. (Pierre) -- Added support for salsa hashing functions in HASH extension. (Scott) -- Added DOMNode::getLineNo to get line number of parsed node. (Rob) -- Added table info to PDO::getColumnMeta() with SQLite. (Martin Jansen, Scott) -- Added mail logging functionality that allows logging of mail sent via - mail() function. (Ilia) -- Added json_last_error() to return any error information from json_decode(). - (Scott) -- Added gethostname() to return the current system host name. (Ilia) -- Added shm_has_var() function. (Mike) -- Added depth parameter to json_decode() to lower the nesting depth from the - maximum if required. (Scott) -- Added pixelation support in imagefilter(). (Takeshi Abe, Kalle) -- Added SplObjectStorage::addAll/removeAll. (Etienne) - -- Implemented FR #41712 (curl progress callback: CURLOPT_PROGRESSFUNCTION). - (sdteffen[at]gmail[dot].com, Pierre) -- Implemented FR #47739 (Missing cURL option do disable IPv6). (Pierre) -- Implemented FR #39637 (Missing cURL option CURLOPT_FTP_FILEMETHOD). (Pierre) - -- Fixed an issue with ReflectionProperty::setAccessible(). - (Sebastian, Roman Borschel) -- Fixed html_entity_decode() incorrectly converting numeric html entities - to different characters with cp1251 and cp866. (Scott) -- Fixed an issue in date() where a : was printed for the O modifier after a P - modifier was used. (Derick) -- Fixed exec() on Windows to not eat the first and last double quotes. (Scott) -- Fixed readlink on Windows in thread safe SAPI (apache2.x etc.). (Pierre) -- Fixed a bug causing miscalculations with the "last of month" - relative time string. (Derick) -- Fixed bug causing the algorithm parameter of mhash() to be modified. (Scott) -- Fixed invalid calls to free when internal fileinfo magic file is used. (Scott) -- Fixed memory leak inside wddx_add_vars() function. (Felipe) -- Fixed check in recode extension to allow builing of recode and mysql - extensions when using a recent libmysql. (Johannes) - -- Fixed PECL bug #12794 (PDOStatement->nextRowset() doesn't work). (Johannes) -- Fixed PECL bug #12401 (Add support for ATTR_FETCH_TABLE_NAMES). (Johannes) - -- Fixed bug #48696 (ldap_read() segfaults with invalid parameters). (Felipe) -- Fixed bug #48643 (String functions memory issue). (Dmitry) -- Fixed bug #48641 (tmpfile() uses old parameter parsing). - (crrodriguez at opensuse dot org) -- Fixed bug #48624 (.user.ini never gets parsed). (Pierre) -- Fixed bug #48620 (X-PHP-Originating-Script assumes no trailing CRLF in - existing headers). (Ilia) -- Fixed bug #48578 (Can't build 5.3 on FBSD 4.11). (Rasmus) -- Fixed bug #48535 (file_exists returns false when impersonate is used). - (Kanwaljeet Singla, Venkat Raman Don) -- Fixed bug #48493 (spl_autoload_register() doesn't work correctly when - prepending functions). (Scott) -- Fixed bug #48215 (Calling a method with the same name as the parent class - calls the constructor). (Scott) -- Fixed bug #48200 (compile failure with mbstring.c when - --enable-zend-multibyte is used). (Jani) -- Fixed bug #48188 (Cannot execute a scrollable cursors twice with PDO_PGSQL). - (Matteo) -- Fixed bug #48185 (warning: value computed is not used in - pdo_sqlite_stmt_get_col line 271). (Matteo) -- Fixed bug #48087 (call_user_method() invalid free of arguments). (Felipe) -- Fixed bug #48060 (pdo_pgsql - large objects are returned as empty). (Matteo) -- Fixed bug #48034 (PHP crashes when script is 8192 (8KB) bytes long). (Dmitry) -- Fixed bug #48004 (Error handler prevents creation of default object). (Dmitry) -- Fixed bug #47880 (crashes in call_user_func_array()). (Dmitry) -- Fixed bug #47856 (stristr() converts needle to lower-case). (Ilia) -- Fixed bug #47851 (is_callable throws fatal error). (Dmitry) -- Fixed bug #47816 (pcntl tests failing on NetBSD). (Matteo) -- Fixed bug #47779 (Wrong value for SIG_UNBLOCK and SIG_SETMASK constants). - (Matteo) -- Fixed bug #47771 (Exception during object construction from arg call calls - object's destructor). (Dmitry) -- Fixed bug #47767 (include_once does not resolve windows symlinks or junctions) - (Kanwaljeet Singla, Venkat Raman Don) -- Fixed bug #47757 (rename JPG to JPEG in phpinfo). (Pierre) -- Fixed bug #47745 (FILTER_VALIDATE_INT doesn't allow minimum integer). (Dmitry) -- Fixed bug #47714 (autoloading classes inside exception_handler leads to - crashes). (Dmitry) -- Fixed bug #47671 (Cloning SplObjectStorage instances). (Etienne) -- Fixed bug #47664 (get_class returns NULL instead of FALSE). (Dmitry) -- Fixed bug #47662 (Support more than 127 subpatterns in preg_match). (Nuno) -- Fixed bug #47596 (Bus error on parsing file). (Dmitry) -- Fixed bug #47572 (Undefined constant causes segmentation fault). (Felipe) -- Fixed bug #47560 (explode()'s limit parameter odd behaviour). (Matt) -- Fixed bug #47549 (get_defined_constants() return array with broken array - categories). (Ilia) -- Fixed bug #47535 (Compilation failure in ps_fetch_from_1_to_8_bytes()). - (Johannes) -- Fixed bug #47534 (RecursiveDiteratoryIterator::getChildren ignoring - CURRENT_AS_PATHNAME). (Etienne) -- Fixed bug #47443 (metaphone('scratch') returns wrong result). (Felipe) -- Fixed bug #47438 (mysql_fetch_field ignores zero offset). (Johannes) -- Fixed bug #47398 (PDO_Firebird doesn't implements quoter correctly). (Felipe) -- Fixed bug #47390 (odbc_fetch_into - BC in php 5.3.0). (Felipe) -- Fixed bug #47359 (Use the expected unofficial mimetype for bmp files). (Scott) -- Fixed bug #47343 (gc_collect_cycles causes a segfault when called within a - destructor in one case). (Dmitry) -- Fixed bug #47320 ($php_errormsg out of scope in functions). (Dmitry) -- Fixed bug #47318 (UMR when trying to activate user config). (Pierre) -- Fixed bug #47243 (OCI8: Crash at shutdown on Windows) (Chris Jones/Oracle - Corp.) -- Fixed bug #47231 (offsetGet error using incorrect offset). (Etienne) -- Fixed bug #47229 (preg_quote() should escape the '-' char). (Nuno) -- Fixed bug #47165 (Possible memory corruption when passing return value by - reference). (Dmitry) -- Fixed bug #47087 (Second parameter of mssql_fetch_array()). (Felipe) -- Fixed bug #47085 (rename() returns true even if the file in PHAR does not - exist). (Greg) -- Fixed bug #47050 (mysqli_poll() modifies improper variables). (Johannes) -- Fixed bug #47045 (SplObjectStorage instances compared with ==). (Etienne) -- Fixed bug #47038 (Memory leak in include). (Dmitry) -- Fixed bug #47031 (Fix constants in DualIterator example). (Etienne) -- Fixed bug #47021 (SoapClient stumbles over WSDL delivered with - "Transfer-Encoding: chunked"). (Dmitry) -- Fixed bug #46994 (OCI8: CLOB size does not update when using CLOB IN OUT param - in stored procedure) (Chris Jones/Oracle Corp.) -- Fixed bug #46979 (use with non-compound name *has* effect). (Dmitry) -- Fixed bug #46957 (The tokenizer returns deprecated values). (Felipe) -- Fixed bug #46944 (UTF-8 characters outside the BMP aren't encoded correctly). - (Scott) -- Fixed bug #46897 (ob_flush() should fail to flush unerasable buffers). - (David C.) -- Fixed bug #46849 (Cloning DOMDocument doesn't clone the properties). (Rob) -- Fixed bug #46847 (phpinfo() is missing some settings). (Hannes) -- Fixed bug #46844 (php scripts or included files with first line starting - with # have the 1st line missed from the output). (Ilia) -- Fixed bug #46817 (tokenizer misses last single-line comment (PHP 5.3+, with - re2c lexer)). (Matt, Shire) -- Fixed bug #46811 (ini_set() doesn't return false on failure). (Hannes) -- Fixed bug #46763 (mb_stristr() wrong output when needle does not exist). - (Henrique M. Decaria) -- Fixed bug #46755 (warning: use statement with non-compound name). (Dmitry) -- Fixed bug #46746 (xmlrpc_decode_request outputs non-suppressable error when - given bad data). (Ilia) -- Fixed bug #46738 (Segfault when mb_detect_encoding() fails). (Scott) -- Fixed bug #46731 (Missing validation for the options parameter of the - imap_fetch_overview() function). (Ilia) -- Fixed bug #46711 (cURL curl_setopt leaks memory in foreach loops). (magicaltux - [at] php [dot] net) -- Fixed bug #46701 (Creating associative array with long values in the key fails - on 32bit linux). (Shire) -- Fixed bug #46681 (mkdir() fails silently on PHP 5.3). (Hannes) -- Fixed bug #46653 (can't extend mysqli). (Johannes) -- Fixed bug #46646 (Restrict serialization on some internal classes like Closure - and SplFileInfo using exceptions). (Etienne) -- Fixed bug #46623 (OCI8: phpinfo doesn't show compile time ORACLE_HOME with - phpize) (Chris Jones/Oracle Corp.) -- Fixed bug #46578 (strip_tags() does not honor end-of-comment when it - encounters a single quote). (Felipe) -- Fixed bug #46546 (Segmentation fault when using declare statement with - non-string value). (Felipe) -- Fixed bug #46542 (Extending PDO class with a __call() function doesn't work as - expected). (Johannes) -- Fixed bug #46421 (SplFileInfo not correctly handling /). (Etienne) -- Fixed bug #46347 (parse_ini_file() doesn't support * in keys). (Nuno) -- Fixed bug #46268 (DateTime::modify() does not reset relative time values). - (Derick) -- Fixed bug #46241 (stacked error handlers, internal error handling in general). - (Etienne) -- Fixed bug #46238 (Segmentation fault on static call with empty string method). - (Felipe) -- Fixed bug #46192 (ArrayObject with objects as storage serialization). - (Etienne) -- Fixed bug #46185 (importNode changes the namespace of an XML element). (Rob) -- Fixed bug #46178 (memory leak in ext/phar). (Greg) -- Fixed bug #46160 (SPL - Memory leak when exception is thrown in offsetSet). - (Felipe) -- Fixed Bug #46147 (after stream seek, appending stream filter reads incorrect - data). (Greg) -- Fixed bug #46127 (php_openssl_tcp_sockop_accept forgets to set context on - accepted stream) (Mark Karpeles, Pierre) -- Fixed bug #46115 (Memory leak when calling a method using Reflection). - (Dmitry) -- Fixed bug #46110 (XMLWriter - openmemory() and openuri() leak memory on - multiple calls). (Ilia) -- Fixed bug #46108 (DateTime - Memory leak when unserializing). (Felipe) -- Fixed bug #46106 (Memory leaks when using global statement). (Dmitry) -- Fixed bug #46099 (Xsltprocessor::setProfiling - memory leak). (Felipe, Rob). -- Fixed bug #46087 (DOMXPath - segfault on destruction of a cloned object). - (Ilia) -- Fixed bug #46048 (SimpleXML top-level @attributes not part of iterator). - (David C.) -- Fixed bug #46044 (Mysqli - wrong error message). (Johannes) -- Fixed bug #46042 (memory leaks with reflection of mb_convert_encoding()). - (Ilia) -- Fixed bug #46039 (ArrayObject iteration is slow). (Arnaud) -- Fixed bug #46033 (Direct instantiation of SQLite3stmt and SQLite3result cause - a segfault.) (Scott) -- Fixed bug #45991 (Ini files with the UTF-8 BOM are treated as invalid). - (Scott) -- Fixed bug #45989 (json_decode() doesn't return NULL on certain invalid - strings). (magicaltux, Scott) -- Fixed bug #45976 (Moved SXE from SPL to SimpleXML). (Etienne) -- Fixed bug #45928 (large scripts from stdin are stripped at 16K border). - (Christian Schneider, Arnaud) -- Fixed bug #45911 (Cannot disable ext/hash). (Arnaud) -- Fixed bug #45907 (undefined reference to 'PHP_SHA512Init'). (Greg) -- Fixed bug #45826 (custom ArrayObject serialization). (Etienne) -- Fixed bug #45820 (Allow empty keys in ArrayObject). (Etienne) -- Fixed bug #45791 (json_decode() doesn't convert 0e0 to a double). (Scott) -- Fixed bug #45786 (FastCGI process exited unexpectedly). (Dmitry) -- Fixed bug #45757 (FreeBSD4.11 build failure: failed include; stdint.h). - (Hannes) -- Fixed bug #45743 (property_exists fails to find static protected member in - child class). (Felipe) -- Fixed bug #45717 (Fileinfo/libmagic build fails, missing err.h and getopt.h). - (Derick) -- Fixed bug #45706 (Unserialization of classes derived from ArrayIterator - fails). (Etienne, Dmitry) -- Fixed bug #45696 (Not all DateTime methods allow method chaining). (Derick) -- Fixed bug #45682 (Unable to var_dump(DateInterval)). (Derick) -- Fixed bug #45447 (Filesystem time functions on Vista and server 2008). - (Pierre) -- Fixed bug #45432 (PDO: persistent connection leak). (Felipe) -- Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit). (Ilia) -- Fixed bug #45384 (parse_ini_file will result in parse error with no trailing - newline). (Arnaud) -- Fixed bug #45382 (timeout bug in stream_socket_enable_crypto). (vnegrier at - optilian dot com, Ilia) -- Fixed bug #45044 (relative paths not resolved correctly). (Dmitry) -- Fixed bug #44861 (scrollable cursor don't work with pgsql). (Matteo) -- Fixed bug #44842 (parse_ini_file keys that start/end with underscore). - (Arnaud) -- Fixed bug #44575 (parse_ini_file comment # line problems). (Arnaud) -- Fixed bug #44409 (PDO::FETCH_SERIALIZE calls __construct()). (Matteo) -- Fixed bug #44173 (PDO->query() parameter parsing/checking needs an update). - (Matteo) -- Fixed bug #44154 (pdo->errorInfo() always have three elements in the returned - array). (David C.) -- Fixed bug #44153 (pdo->errorCode() returns NULL when there are no errors). - (David C.) -- Fixed bug #44135 (PDO MySQL does not support CLIENT_FOUND_ROWS). (Johannes, - chx1975 at gmail dot com) -- Fixed bug #44100 (Inconsistent handling of static array declarations with - duplicate keys). (Dmitry) -- Fixed bug #43831 ($this gets mangled when extending PDO with persistent - connection). (Felipe) -- Fixed bug #43817 (opendir() fails on Windows directories with parent directory - unaccessible). (Dmitry) -- Fixed bug #43069 (SoapClient causes 505 HTTP Version not supported error - message). (Dmitry) -- Fixed bug #43008 (php://filter uris ignore url encoded filternames and can't - handle slashes). (Arnaud) -- Fixed bug #42362 (HTTP status codes 204 and 304 should not be gzipped). - (Scott, Edward Z. Yang) -- Fixed bug #41874 (separate STDOUT and STDERR in exec functions). (Kanwaljeet - Singla, Venkat Raman Don, Pierre) -- Fixed bug #41534 (SoapClient over HTTPS fails to reestablish connection). - (Dmitry) -- Fixed bug #38802 (max_redirects and ignore_errors). (patch by - datibbaw@php.net) -- Fixed bug #35980 (touch() works on files but not on directories). (Pierre) - -17 Jun 2009, PHP 5.2.10 -- Updated timezone database to version 2009.9 (2009i) (Derick) - -- Added "ignore_errors" option to http fopen wrapper. (David Zulke, Sara) -- Added new CURL options CURLOPT_REDIR_PROTOCOLS, CURLOPT_PROTOCOLS, - and CURLPROTO_* for redirect fixes in CURL 7.19.4. (Yoram Bar Haim, Stas) -- Added support for Sun CC (FR #46595 and FR #46513). (David Soria Parra) - -- Changed default value of array_unique()'s optional sorting type parameter - back to SORT_STRING to fix backwards compatibility breakage introduced in - PHP 5.2.9. (Moriyoshi) - -- Fixed memory corruptions while reading properties of zip files. (Ilia) -- Fixed memory leak in ob_get_clean/ob_get_flush. (Christian) -- Fixed segfault on invalid session.save_path. (Hannes) -- Fixed leaks in imap when a mail_criteria is used. (Pierre) -- Fixed missing erealloc() in fix for Bug #40091 in spl_autoload_register. (Greg) - -- Fixed bug #48562 (Reference recursion causes segfault when used in - wddx_serialize_vars()). (Felipe) -- Fixed bug #48557 (Numeric string keys in Apache Hashmaps are not cast to - integers). (David Zuelke) -- Fixed bug #48518 (curl crashes when writing into invalid file handle). (Tony) -- Fixed bug #48514 (cURL extension uses same resource name for simple and - multi APIs). (Felipe) -- Fixed bug #48469 (ldap_get_entries() leaks memory on empty search - results). (Patrick) -- Fixed bug #48456 (CPPFLAGS not restored properly in phpize.m4). (Jani, - spisek at kerio dot com) -- Fixed bug #48448 (Compile failure under IRIX 6.5.30 building cast.c). - (Kalle) -- Fixed bug #48441 (ldap_search() sizelimit, timelimit and deref options - persist). (Patrick) -- Fixed bug #48434 (Improve memory_get_usage() accuracy). (Arnaud) -- Fixed bug #48416 (Force a cache limit in ereg() to stop excessive memory - usage). (Scott) -- Fixed bug #48409 (Crash when exception is thrown while passing function - arguments). (Arnaud) -- Fixed bug #48378 (exif_read_data() segfaults on certain corrupted .jpeg - files). (Pierre) -- Fixed bug #48359 (Script hangs on snmprealwalk if OID is not increasing). - (Ilia, simonov at gmail dot com) -- Fixed bug #48336 (ReflectionProperty::getDeclaringClass() does not work - with redeclared property). - (patch by Markus dot Lidel at shadowconnect dot com) -- Fixed bug #48326 (constant MSG_DONTWAIT not defined). (Arnaud) -- Fixed bug #48313 (fgetcsv() does not return null for empty rows). (Ilia) -- Fixed bug #48309 (stream_copy_to_stream() and fpasstru() do not update - stream position of plain files). (Arnaud) -- Fixed bug #48307 (stream_copy_to_stream() copies 0 bytes when $source is a - socket). (Arnaud) -- Fixed bug #48273 (snmp*_real_walk() returns SNMP errors as values). - (Ilia, lytboris at gmail dot com) -- Fixed bug #48256 (Crash due to double-linking of history.o). - (tstarling at wikimedia dot org) -- Fixed bug #48248 (SIGSEGV when access to private property via &__get). - (Felipe) -- Fixed bug #48247 (Crash on errors during startup). (Stas) -- Fixed bug #48240 (DBA Segmentation fault dba_nextkey). (Felipe) -- Fixed bug #48224 (Incorrect shuffle in array_rand). (Etienne) -- Fixed bug #48221 (memory leak when passing invalid xslt parameter). - (Felipe) -- Fixed bug #48207 (CURLOPT_(FILE|WRITEHEADER options do not error out when - working with a non-writable stream). (Ilia) -- Fixed bug #48206 (Iterating over an invalid data structure with - RecursiveIteratorIterator leads to a segfault). (Scott) -- Fixed bug #48204 (xmlwriter_open_uri() does not emit warnings on invalid - paths). (Ilia) -- Fixed bug #48203 (Crash when CURLOPT_STDERR is set to regular file). (Jani) -- Fixed bug #48202 (Out of Memory error message when passing invalid file - path) (Pierre) -- Fixed bug #48156 (Added support for lcov v1.7). (Ilia) -- Fixed bug #48132 (configure check for curl ssl support fails with - --disable-rpath). (Jani) -- Fixed bug #48131 (Don't try to bind ipv4 addresses to ipv6 ips via bindto). - (Ilia) -- Fixed bug #48070 (PDO_OCI: Segfault when using persistent connection). - (Pierre, Matteo, jarismar dot php at gmail dot com) -- Fixed bug #48058 (Year formatter goes wrong with out-of-int range). (Derick) -- Fixed bug #48038 (odbc_execute changes variables used to form params array). - (Felipe) -- Fixed bug #47997 (stream_copy_to_stream returns 1 on empty streams). (Arnaud) -- Fixed bug #47991 (SSL streams fail if error stack contains items). (Mikko) -- Fixed bug #47981 (error handler not called regardless). (Hannes) -- Fixed bug #47969 (ezmlm_hash() returns different values depend on OS). (Ilia) -- Fixed bug #47946 (ImageConvolution overwrites background). (Ilia) -- Fixed bug #47940 (memory leaks in imap_body). (Pierre, Jake Levitt) -- Fixed bug #47937 (system() calls sapi_flush() regardless of output - buffering). (Ilia) -- Fixed bug #47903 ("@" operator does not work with string offsets). (Felipe) -- Fixed bug #47893 (CLI aborts on non blocking stdout). (Arnaud) -- Fixed bug #47849 (Non-deep import loses the namespace). (Rob) -- Fixed bug #47845 (PDO_Firebird omits first row from query). (Lars W) -- Fixed bug #47836 (array operator [] inconsistency when the array has - PHP_INT_MAX index value). (Matt) -- Fixed bug #47831 (Compile warning for strnlen() in main/spprintf.c). - (Ilia, rainer dot jung at kippdata dot de) -- Fixed bug #47828 (openssl_x509_parse() segfaults when a UTF-8 conversion - fails). (Scott, Kees Cook, Pierre) -- Fixed bug #47818 (Segfault due to bound callback param). (Felipe) -- Fixed bug #47801 (__call() accessed via parent:: operator is provided - incorrect method name). (Felipe) -- Fixed bug #47769 (Strange extends PDO). (Felipe) -- Fixed bug #47745 (FILTER_VALIDATE_INT doesn't allow minimum integer). - (Dmitry) -- Fixed bug #47721 (Alignment issues in mbstring and sysvshm extension). - (crrodriguez at opensuse dot org, Ilia) -- Fixed bug #47704 (PHP crashes on some "bad" operations with string - offsets). (Dmitry) -- Fixed bug #47695 (build error when xmlrpc and iconv are compiled against - different iconv versions). (Scott) -- Fixed bug #47667 (ZipArchive::OVERWRITE seems to have no effect). - (Mikko, Pierre) -- Fixed bug #47644 (Valid integers are truncated with json_decode()). (Scott) -- Fixed bug #47639 (pg_copy_from() WARNING: nonstandard use of \\ in a - string literal). (Ilia) -- Fixed bug #47616 (curl keeps crashing). (Felipe) -- Fixed bug #47598 (FILTER_VALIDATE_EMAIL is locale aware). (Ilia) -- Fixed bug #47566 (pcntl_wexitstatus() returns signed status). - (patch by james at jamesreno dot com) -- Fixed bug #47564 (unpacking unsigned long 32bit bit endian returns wrong - result). (Ilia) -- Fixed bug #47487 (performance degraded when reading large chunks after - fix of bug #44607). (Arnaud) -- Fixed bug #47468 (enable cli|cgi-only extensions for embed sapi). (Jani) -- Fixed bug #47435 (FILTER_FLAG_NO_PRIV_RANGE does not work with ipv6 - addresses in the filter extension). (Ilia) -- Fixed bug #47430 (Errors after writing to nodeValue parameter of an absent - previousSibling). (Rob) -- Fixed bug #47365 (ip2long() may allow some invalid values on certain 64bit - systems). (Ilia) -- Fixed bug #47254 (Wrong Reflection for extends class). (Felipe) -- Fixed bug #47042 (cgi sapi is incorrectly removing SCRIPT_FILENAME). - (Sriram Natarajan, David Soria Parra) -- Fixed bug #46882 (Serialize / Unserialize misbehaviour under OS with - different bit numbers). (Matt) -- Fixed bug #46812 (get_class_vars() does not include visible private variable - looking at subclass). (Arnaud) -- Fixed bug #46386 (Digest authentication with SOAP module fails against MSSQL - SOAP services). (Ilia, lordelph at gmail dot com) -- Fixed bug #46109 (Memory leak when mysqli::init() is called multiple times). - (Andrey) -- Fixed bug #45997 (safe_mode bypass with exec/system/passthru (windows only)). - (Pierre) -- Fixed bug #45877 (Array key '2147483647' left as string). (Matt) -- Fixed bug #45822 (Near infinite-loops while parsing huge relative offsets). - (Derick, Mike Sullivan) -- Fixed bug #45799 (imagepng() crashes on empty image). - (Martin McNickle, Takeshi Abe) -- Fixed bug #45622 (isset($arrayObject->p) misbehaves with - ArrayObject::ARRAY_AS_PROPS set). (robin_fernandes at uk dot ibm dot com, Arnaud) -- Fixed bug #45614 (ArrayIterator::current(), ::key() can show 1st private prop - of wrapped object). (robin_fernandes at uk dot ibm dot com, Arnaud) -- Fixed bug #45540 (stream_context_create creates bad http request). (Arnaud) -- Fixed bug #45202 (zlib.output_compression can not be set with ini_set()). - (Jani) -- Fixed bug #45191 (error_log ignores date.timezone php.ini val when setting - logging timestamps). (Derick) -- Fixed bug #45092 (header HTTP context option not being used when compiled - using --with-curlwrappers). (Jani) -- Fixed bug #44996 (xmlrpc_decode() ignores time zone on iso8601.datetime). - (Ilia, kawai at apache dot org) -- Fixed bug #44827 (define() is missing error checks for class constants). - (Ilia) -- Fixed bug #44214 (Crash using preg_replace_callback() and global variables). - (Nuno, Scott) -- Fixed bug #43073 (TrueType bounding box is wrong for angle<>0). - (Martin McNickle) -- Fixed bug #42663 (gzinflate() try to allocate all memory with truncated - data). (Arnaud) -- Fixed bug #42414 (some odbc_*() functions incompatible with Oracle ODBC - driver). (jhml at gmx dot net) -- Fixed bug #42362 (HTTP status codes 204 and 304 should not be gzipped). - (Scott, Edward Z. Yang) -- Fixed bug #42143 (The constant NAN is reported as 0 on Windows) - (Kanwaljeet Singla, Venkat Raman Don) -- Fixed bug #38805 (PDO truncates text from SQL Server text data type field). - (Steph) - -26 Feb 2009, PHP 5.2.9 -- Changed __call() to be invoked on private/protected method access, similar to - properties and __get(). (Andrei) - -- Added optional sorting type flag parameter to array_unique(). Default is - SORT_REGULAR. (Andrei) - -- Fixed a crash on extract in zip when files or directories entry names contain - a relative path. (Pierre) -- Fixed error conditions handling in stream_filter_append(). (Arnaud) -- Fixed zip filename property read. (Pierre) -- Fixed explode() behavior with empty string to respect negative limit. (Shire) -- Fixed security issue in imagerotate(), background colour isn't validated - correctly with a non truecolour image. Reported by Hamid Ebadi, - APA Laboratory (Fixes CVE-2008-5498). (Scott) -- Fixed a segfault when malformed string is passed to json_decode(). (Scott) -- Fixed bug in xml_error_string() which resulted in messages being - off by one. (Scott) - -- Fixed bug #47422 (modulus operator returns incorrect results on 64 bit - linux). (Matt) -- Fixed bug #47399 (mb_check_encoding() returns true for some illegal SJIS - characters). (for-bugs at hnw dot jp, Moriyoshi) -- Fixed bug #47353 (crash when creating a lot of objects in object - destructor). (Tony) -- Fixed bug #47322 (sscanf %d doesn't work). (Felipe) -- Fixed bug #47282 (FILTER_VALIDATE_EMAIL is marking valid email addresses - as invalid). (Ilia) -- Fixed bug #47220 (segfault in dom_document_parser in recovery mode). (Rob) -- Fixed bug #47217 (content-type is not set properly for file uploads). (Ilia) -- Fixed bug #47174 (base64_decode() interprets pad char in mid string as - terminator). (Ilia) -- Fixed bug #47165 (Possible memory corruption when passing return value by - reference). (Dmitry) -- Fixed bug #47152 (gzseek/fseek using SEEK_END produces strange results). - (Felipe) -- Fixed bug #47131 (SOAP Extension ignores "user_agent" ini setting). (Ilia) -- Fixed bug #47109 (Memory leak on $a->{"a"."b"} when $a is not an object). - (Etienne, Dmitry) -- Fixed bug #47104 (Linking shared extensions fails with icc). (Jani) -- Fixed bug #47049 (SoapClient::__soapCall causes a segmentation fault). - (Dmitry) -- Fixed bug #47048 (Segfault with new pg_meta_data). (Felipe) -- Fixed bug #47042 (PHP cgi sapi is removing SCRIPT_FILENAME for non - apache). (Sriram Natarajan) -- Fixed bug #47037 (No error when using fopen with empty string). (Cristian - Rodriguez R., Felipe) -- Fixed bug #47035 (dns_get_record returns a garbage byte at the end of a - TXT record). (Felipe) -- Fixed bug #47027 (var_export doesn't show numeric indices on ArrayObject). - (Derick) -- Fixed bug #46985 (OVERWRITE and binary mode does not work, regression - introduced in 5.2.8). (Pierre) -- Fixed bug #46973 (IPv6 address filter rejects valid address). (Felipe) -- Fixed bug #46964 (Fixed pdo_mysql build with older version of MySQL). (Ilia) -- Fixed bug #46959 (Unable to disable PCRE). (Scott) -- Fixed bug #46918 (imap_rfc822_parse_adrlist host part not filled in - correctly). (Felipe) -- Fixed bug #46889 (Memory leak in strtotime()). (Derick) -- Fixed bug #46887 (Invalid calls to php_error_docref()). (oeriksson at - mandriva dot com, Ilia) -- Fixed bug #46873 (extract($foo) crashes if $foo['foo'] exists). (Arnaud) -- Fixed bug #46843 (CP936 euro symbol is not converted properly). (ty_c at - cybozuy dot co dot jp, Moriyoshi) -- Fixed bug #46798 (Crash in mssql extension when retrieving a NULL value - inside a binary or image column type). (Ilia) -- Fixed bug #46782 (fastcgi.c parse error). (Matt) -- Fixed bug #46760 (SoapClient doRequest fails when proxy is used). (Felipe) -- Fixed bug #46748 (Segfault when an SSL error has more than one error). - (Scott) -- Fixed bug #46739 (array returned by curl_getinfo should contain - content_type key). (Mikko) -- Fixed bug #46699 (xml_parse crash when parser is namespace aware). (Rob) -- Fixed bug #46419 (Elements of associative arrays with NULL value are - lost). (Dmitry) -- Fixed bug #46282 (Corrupt DBF When Using DATE). (arne at bukkie dot nl) -- Fixed bug #46026 (bz2.decompress/zlib.inflate filter tries to decompress - after end of stream). (Greg) -- Fixed bug #46005 (User not consistently logged under Apache2). (admorten - at umich dot edu, Stas) -- Fixed bug #45996 (libxml2 2.7 causes breakage with character data in - xml_parse()). (Rob) -- Fixed bug #45940 (MySQLI OO does not populate connect_error property on - failed connect). (Johannes) -- Fixed bug #45923 (mb_st[r]ripos() offset not handled correctly). (Moriyoshi) -- Fixed bug #45327 (memory leak if offsetGet throws exception). (Greg) -- Fixed bug #45239 (Encoding detector hangs with mbstring.strict_detection - enabled). (Moriyoshi) -- Fixed bug #45161 (Reusing a curl handle leaks memory). (Mark Karpeles, Jani) -- Fixed bug #44336 (Improve pcre UTF-8 string matching performance). (frode - at coretrek dot com, Nuno) -- Fixed bug #43841 (mb_strrpos() offset is byte count for negative values). - (Moriyoshi) -- Fixed bug #37209 (mssql_execute with non fatal errors). (Kalle) -- Fixed bug #35975 (Session cookie expires date format isn't the most - compatible. Now matches that of setcookie()). (Scott) - - -08 Dec 2008, PHP 5.2.8 -- Reverted bug fix #42718 that broke magic_quotes_gpc (Scott) - -04 Dec 2008, PHP 5.2.7 -- Upgraded PCRE to version 7.8 (Fixes CVE-2008-2371). (Ilia) -- Updated timezone database to version 2008.9. (Derick) -- Upgraded bundled libzip to 0.9.0. (Pierre) - -- Added logging option for error_log to send directly to SAPI. (Stas) -- Added PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, - PHP_EXTRA_VERSION, PHP_VERSION_ID, PHP_ZTS and PHP_DEBUG constants. (Pierre) -- Added "PHP_INI_SCAN_DIR" environment variable which can be used to - either disable or change the compile time ini scan directory (FR #45114). - (Jani) - -- Fixed missing initialization of BG(page_uid) and BG(page_gid), - reported by Maksymilian Arciemowicz. (Stas) -- Fixed memory leak inside sqlite_create_aggregate(). (Felipe) -- Fixed memory leak inside PDO sqlite's sqliteCreateAggregate() method. - (Felipe) -- Fixed a crash inside gd with invalid fonts (Fixes CVE-2008-3658). (Pierre) -- Fixed a possible overflow inside memnstr (Fixes CVE-2008-3659). - (LaurentGaffie) -- Fixed incorrect php_value order for Apache configuration, reported by - Maksymilian Arciemowicz. (Stas) -- Fixed memory leak inside readline_callback_handler_remove() function. - (Felipe) -- Fixed sybase_fetch_*() to continue reading after CS_ROW_FAIL status (Timm) -- Fixed a bug inside dba_replace() that could cause file truncation - withinvalid keys. (Ilia) -- Fixed memory leak inside readline_callback_handler_install() function.(Ilia) -- Fixed memory leak inside readline_completion_function() function. (Felipe) -- Fixed stream_get_contents() when using $maxlength and socket is notclosed. - indeyets [at] php [dot] net on #46049. (Arnaud) -- Fixed stream_get_line() to behave as documented on non-blocking streams. - (Arnaud) -- Fixed endless loop in PDOStatement::debugDumpParams(). - (jonah.harris at gmail dot com) -- Fixed ability to use "internal" heaps in extensions. (Arnaud, Dmitry) -- Fixed weekdays adding/subtracting algorithm. (Derick) -- Fixed some ambiguities in the date parser. (Derick) -- Fixed a bug with the YYYY-MM format not resetting the day correctly. - (Derick) -- Fixed a bug in the DateTime->modify() methods, it would not use the advanced - relative time strings. (Derick) -- Fixed extraction of zip files or directories when the entry name is a - relative path. (Pierre) -- Fixed read or write errors for large zip archives. (Pierre) -- Fixed security issues detailed in CVE-2008-2665 and CVE-2008-2666. - (Christian Hoffmann) -- Fixed simplexml asXML() not to lose encoding when dumping entire - document to file. (Ilia) -- Fixed a crash inside PDO when trying instantiate PDORow manually. - (Felipe) -- Fixed build failure of ext/mysqli with libmysql 6.0 - missing - rplfunctions. (Andrey) -- Fixed a regression when using strip_tags() and < is within an - attribute.(Scott) -- Fixed a crash on invalid method in ReflectionParameter constructor. - (Christian Seiler) -- Reverted fix for bug #44197 due to behaviour change in minor version. - (Felipe) - -- Fixed bug #46732 (mktime.year description is wrong). (Derick) -- Fixed bug #46696 (cURL fails in upload files with specified content-type). - (Ilia) -- Fixed bug #46673 (stream_lock call with wrong parameter). (Arnaud) -- Fixed bug #46649 (Setting array element with that same array produces - inconsistent results). (Arnaud) -- Fixed bug #46626 (mb_convert_case does not handle apostrophe correctly). - (Ilia) -- Fixed bug #46543 (ibase_trans() memory leaks when using wrong parameters). - (Felipe) -- Fixed bug #46521 (Curl ZTS OpenSSL, error in config.m4 fragment). - (jd at cpanel dot net) -- Fixed bug #46496 (wddx_serialize treats input as ISO-8859-1). (Mark Karpeles) -- Fixed bug #46427 (SoapClient() stumbles over its "stream_context" parameter). - (Dmitry, Herman Radtke) -- Fixed bug #46426 (offset parameter of stream_get_contents() does not - workfor "0"). (Felipe) -- Fixed bug #46406 (Unregistering nodeclass throws E_FATAL). (Rob) -- Fixed bug #46389 (NetWare needs small patch for _timezone). - (patch by guenter@php.net) -- Fixed bug #46388 (stream_notification_callback inside of object destroys - object variables). (Felipe) -- Fixed bug #46381 (wrong $this passed to internal methods causes segfault). - (Tony) -- Fixed bug #46379 (Infinite loop when parsing '#' in one line file). (Arnaud) -- Fixed bug #46366 (bad cwd with / as pathinfo). (Dmitry) -- Fixed bug #46360 (TCP_NODELAY constant for socket_{get,set}_option). - (bugs at trick dot vanstaveren dot us) -- Fixed bug #46343 (IPv6 address filter accepts invalid address). (Ilia) -- Fixed bug #46335 (DOMText::splitText doesn't handle multibyte characters). - (Rob) -- Fixed bug #46323 (compilation of simplexml for NetWare breaks). - (Patch by guenter [at] php [dot] net) -- Fixed bug #46319 (PHP sets default Content-Type header for HTTP 304 - response code, in cgi sapi). (Ilia) -- Fixed bug #46313 (Magic quotes broke $_FILES). (Arnaud) -- Fixed bug #46308 (Invalid write when changing property from inside getter). - (Dmitry) -- Fixed bug #46292 (PDO::setFetchMode() shouldn't requires the 2nd arg when - using FETCH_CLASSTYPE). (Felipe) -- Fixed bug #46274, #46249 (pdo_pgsql always fill in NULL for empty BLOB and - segfaults when returned by SELECT). (Felipe) -- Fixed bug #46271 (local_cert option is not resolved to full path). (Ilia) -- Fixed bug #46247 (ibase_set_event_handler() is allowing to pass callback - without event). (Felipe) -- Fixed bug #46246 (difference between call_user_func(array($this, $method)) - and $this->$method()). (Dmitry) -- Fixed bug #46222 (ArrayObject EG(uninitialized_var_ptr) overwrite). - (Etienne) -- Fixed bug #46215 (json_encode mutates its parameter and has some - class-specific state). (Felipe) -- Fixed bug #46206 (pg_query_params/pg_execute convert passed values to - strings). (Ilia) -- Fixed bug #46191 (BC break: DOMDocument saveXML() doesn't accept null). - (Rob) -- Fixed bug #46164 (stream_filter_remove() closes the stream). (Arnaud) -- Fixed bug #46157 (PDOStatement::fetchObject prototype error). (Felipe) -- Fixed bug #46147 (after stream seek, appending stream filter reads - incorrect data). (Greg) -- Fixed bug #46139 (PDOStatement->setFetchMode() forgets FETCH_PROPS_LATE). - (chsc at peytz dot dk, Felipe) -- Fixed bug #46127 (php_openssl_tcp_sockop_accept forgets to set context - on accepted stream) (Mark Karpeles, Pierre) -- Fixed bug #46110 (XMLWriter - openmemory() and openuri() leak memory on - multiple calls). (Ilia) -- Fixed bug #46088 (RegexIterator::accept - segfault). (Felipe) -- Fixed bug #46082 (stream_set_blocking() can cause a crash in some - circumstances). (Felipe) -- Fixed bug #46064 (Exception when creating ReflectionProperty object - on dynamicly created property). (Felipe) -- Fixed bug #46059 (Compile failure under IRIX 6.5.30 building posix.c). - (Arnaud) -- Fixed bug #46053 (SplFileObject::seek - Endless loop). (Arnaud) -- Fixed bug #46051 (SplFileInfo::openFile - memory overlap). (Arnaud) -- Fixed bug #46047 (SimpleXML converts empty nodes into object with - nested array). (Rob) -- Fixed bug #46031 (Segfault in AppendIterator::next). (Arnaud) -- Fixed bug #46029 (Segfault in DOMText when using with Reflection). (Rob) -- Fixed bug #46026 (bzip2.decompress/zlib.inflate filter tries to decompress - after end of stream). (Keisial at gmail dot com, Greg) -- Fixed bug #46024 (stream_select() doesn't return the correct number). - (Arnaud) -- Fixed bug #46010 (warnings incorrectly generated for iv in ecb mode). - (Felipe) -- Fixed bug #46003 (isset on nonexisting node return unexpected results). (Rob) -- Fixed bug #45956 (parse_ini_file() does not return false with syntax errors - in parsed file). (Jani) -- Fixed bug #45901 (wddx_serialize_value crash with SimpleXMLElement object). - (Rob) -- Fixed bug #45862 (get_class_vars is inconsistent with 'protected' and - 'private' variables). (ilewis at uk dot ibm dot com, Felipe) -- Fixed bug #45860 (header() function fails to correctly replace all Status - lines). (Dmitry) -- Fixed bug #45805 (Crash on throwing exception from error handler). (Dmitry) -- Fixed bug #45765 (ReflectionObject with default parameters of self::xxx cause - an error). (Felipe) -- Fixed bug #45751 (Using auto_prepend_file crashes (out of scope stack address - use)). (basant dot kukreja at sun dot com) -- Fixed bug #45722 (mb_check_encoding() crashes). (Moriyoshi) -- Fixed bug #45705 (rfc822_parse_adrlist() modifies passed address parameter). - (Jani) -- Fixed bug #45691 (Some per-dir or runtime settings may leak into other - requests). (Moriyoshi) -- Fixed bug #45581 (htmlspecialchars() double encoding &#x hex items). (Arnaud) -- Fixed bug #45580 (levenshtein() crashes with invalid argument). (Ilia) -- Fixed bug #45575 (Segfault with invalid non-string as event handler callback). - (Christian Seiler) -- Fixed bug #45568 (ISAPI doesn't properly clear auth_digest in header). - (Patch by: navara at emclient dot com) -- Fixed bug #45556 (Return value from callback isn't freed). (Felipe) -- Fixed bug #45555 (Segfault with invalid non-string as - register_introspection_callback). (Christian Seiler) -- Fixed bug #45553 (Using XPath to return values for attributes with a - namespace does not work). (Rob) -- Fixed bug #45529 (new DateTimeZone() and date_create()->getTimezone() behave - different). (Derick) -- Fixed bug #45522 (FCGI_GET_VALUES request does not return supplied values). - (Arnaud) -- Fixed bug #45486 (mb_send_mail(); header 'Content-Type: text/plain; charset=' - parsing incorrect). (Felipe) -- Fixed bug #45485 (strip_tags and ). (Dmitry) -- Fixed bug #43668 (Added odbc.default_cursortype to control the ODBCcursor - model). (Patrick) -- Fixed bug #43666 (Fixed code to use ODBC 3.52 datatypes for 64bit - systems). (Patrick) -- Fixed bug #43540 (rfc1867 handler newlength problem). (Arnaud) -- Fixed bug #43452 (strings containing a weekday, or a number plus weekday - behaved incorrect of the current day-of-week was the same as the one in the - phrase). (Derick) -- Fixed bug #43353 (wrong detection of 'data' wrapper causes notice). - (gk at gknw dot de, Arnaud) -- Fixed bug #43053 (Regression: some numbers shown in scientific notation). - (int-e at gmx dot de) -- Fixed bug #43045 (SOAP encoding violation on "INF" for type double/float). - (Dmitry) -- Fixed bug #42862 (IMAP toolkit crash: rfc822.c legacy routine buffer - overflow). (Fixes CVE-2008-2829) (Dmitry) -- Fixed bug #42855 (dns_get_record() doesn't return all text from TXT record). - (a dot u dot savchuk at gmail dot com) -- Fixed bug #42737 (preg_split('//u') triggers a E_NOTICE with newlines). - (Nuno) -- Fixed bug #42718 (FILTER_UNSAFE_RAW not applied when configured as default - filter). (Arnaud) -- Fixed bug #42604 ("make test" fails with --with-config-file-scan-dir=path). - (Jani) -- Fixed bug #42473 (ob_start php://output and headers). (Arnaud) -- Fixed bug #42318 (problem with nm on AIX, not finding object files). - (Dmitry) -- Fixed bug #42294 (Unified solution for round() based on C99 round). (Ilia) -- Fixed bug #42078 (pg_meta_data mix tables metadata from different schemas). - (Felipe) -- Fixed bug #41348 (OCI8: allow compilation with Oracle 8.1). (Chris Jones) -- Fixed bug #41033 (enable signing with DSA keys. - (gordyf at google dot com, Pierre) -- Fixed bug #37100 (data is returned truncated with BINARY CURSOR). (Tony) -- Fixed bug #30312 (crash in sybase_unbuffered_query() function). (Timm) -- Fixed bug #24679 (pg_* functions doesn't work using schema). (Felipe) -- Fixed bug #14962 (PECL) (::extractTo 2nd argument is not really optional) - (Mark van Der Velden) -- Fixed bug #14032 (Mail() always returns false but mail is sent). (Mikko) - - -01 May 2008, PHP 5.2.6 -- Fixed two possible crashes inside posix extension (Tony) -- Fixed incorrect heredoc handling when label is used within the block. - (Matt) -- Fixed possible stack buffer overflow in FastCGI SAPI. (Andrei Nigmatulin) -- Fixed sending of uninitialized paddings which may contain some information. (Andrei Nigmatulin) -- Fixed a bug in formatting timestamps when DST is active in the default timezone (Derick) -- Properly address incomplete multibyte chars inside escapeshellcmd() (Ilia, Stefan Esser) -- Fix integer overflow in printf(). (Stas, Maksymilian Aciemowicz) -- Fixed security issue detailed in CVE-2008-0599. (Rasmus) -- Fixed potential memleak in stream filter parameter for zlib filter. (Greg) -- Added Reflection API metadata for the methods of the DOM classes. (Sebastian) -- Fixed weird behavior in CGI parameter parsing. (Dmitry, Hannes Magnusson) -- Fixed a safe_mode bypass in cURL identified by Maksymilian Arciemowicz. - (Ilia) -- Fixed a bug with PDO::FETCH_COLUMN|PDO::FETCH_GROUP mode when a column # by - which to group by data is specified. (Ilia) -- Fixed segfault in filter extension when using callbacks. (Arnar Mar Sig, - Felipe) -- Fixed faulty fix for bug #40189 (endless loop in zlib.inflate stream filter). (Greg) -- Upgraded PCRE to version 7.6 (Nuno) - -- Fixed bug #44742 (timezone_offset_get() causes segmentation faults). (Derick) -- Fixed bug #44720 (Prevent crash within session_register()). (Scott) -- Fixed bug #44703 (htmlspecialchars() does not detect bad character set argument). (Andy Wharmby) -- Fixed bug #44673 (With CGI argv/argc starts from arguments, not from script) (Dmitry) -- Fixed bug #44667 (proc_open() does not handle pipes with the mode 'wb' correctly). (Jani) -- Fixed bug #44663 (Crash in imap_mail_compose if "body" parameter invalid). (Ilia) -- Fixed bug #44650 (escaepshellscmd() does not check arg count). (Ilia) -- Fixed bug #44613 (Crash inside imap_headerinfo()). (Ilia, jmessa) -- Fixed bug #44603 (Order issues with Content-Type/Length headers on POST). (Ilia) -- Fixed bug #44594 (imap_open() does not validate # of retries parameter). (Ilia) -- Fixed bug #44591 (imagegif's filename parameter). (Felipe) -- Fixed bug #44557 (Crash in imap_setacl when supplied integer as username) (Thomas Jarosch) -- Fixed bug #44487 (call_user_method_array issues a warning when throwing an exception). (David Soria Parra) -- Fixed bug #44478 (Inconsistent behaviour when assigning new nodes). (Rob, Felipe) -- Fixed bug #44445 (email validator does not handle domains starting/ending with a -). (Ilia) -- Fixed bug #44440 (st_blocks undefined under BeOS). (Felipe) -- Fixed bug #44394 (Last two bytes missing from output). (Felipe) -- Fixed bug #44388 (Crash inside exif_read_data() on invalid images) (Ilia) -- Fixed bug #44373 (PDO_OCI extension compile failed). (Felipe) -- Fixed bug #44333 (SEGFAULT when using mysql_pconnect() with client_flags). (Felipe) -- Fixed bug #44306 (Better detection of MIPS processors on Windows). (Ilia) -- Fixed bug #44242 (metaphone('CMXFXM') crashes PHP). (Felipe) -- Fixed bug #44233 (MSG_PEEK undefined under BeOS R5). (jonathonfreeman at gmail dot com, Ilia) -- Fixed bug #44216 (strftime segfaults on large negative value). (Derick) -- Fixed bug #44209 (strtotime() doesn't support 64 bit timestamps on 64 bit platforms). (Derick) -- Fixed bug #44206 (OCI8 selecting ref cursors leads to ORA-1000 maximum open cursors reached). (Oracle Corp.) -- Fixed bug #44200 (A crash in PDO when no bound targets exists and yet bound parameters are present). (Ilia) -- Fixed bug #44197 (socket array keys lost on socket_select). (Felipe) -- Fixed bug #44191 (preg_grep messes up array index). (Felipe) -- Fixed bug #44189 (PDO setAttribute() does not properly validate values for native numeric options). (Ilia) -- Fixed bug #44184 (Double free of loop-variable on exception). (Dmitry) -- Fixed bug #44171 (Invalid FETCH_COLUMN index does not raise an error). (Ilia) -- Fixed bug #44166 (Parameter handling flaw in PDO::getAvailableDrivers()). (Ilia) -- Fixed bug #44159 (Crash: $pdo->setAttribute(PDO::STATEMENT_ATTR_CLASS, NULL)). (Felipe) -- Fixed bug #44152 (Possible crash with syslog logging on ZTS builds). (Ilia) -- Fixed bug #44141 (private parent constructor callable through static function). (Dmitry) -- Fixed bug #44113 (OCI8 new collection creation can fail with OCI-22303). (Oracle Corp.) -- Fixed bug #44069 (Huge memory usage with concatenation using . instead of .=). (Dmitry) -- Fixed bug #44046 (crash inside array_slice() function with an invalid by-ref offset). (Ilia) -- Fixed bug #44028 (crash inside stream_socket_enable_crypto() when enabling encryption without crypto type). (Ilia) -- Fixed bug #44018 (RecursiveDirectoryIterator options inconsistancy). (Marcus) -- Fixed bug #44008 (OCI8 incorrect usage of OCI-Lob->close crashes PHP). (Oracle Corp.) -- Fixed bug #43998 (Two error messages returned for incorrect encoding for mb_strto[upper|lower]). (Rui) -- Fixed bug #43994 (mb_ereg 'successfully' matching incorrect). (Rui) -- Fixed bug #43954 (Memory leak when sending the same HTTP status code multiple times). (Scott) -- Fixed bug #43927 (koi8r is missing from html_entity_decode()). (andy at demos dot su, Tony) -- Fixed bug #43912 (Interbase column names are truncated to 31 characters). (Ilia) -- Fixed bug #43875 (Two error messages returned for $new and $flag argument in mysql_connect()). (Hannes) -- Fixed bug #43863 (str_word_count() breaks on cyrillic "ya" in locale cp1251). (phprus at gmail dot com, Tony) -- Fixed bug #43841 (mb_strrpos offset is byte count for negative values). (Rui) -- Fixed bug #43840 (mb_strpos bounds check is byte count rather than a character count). (Rui) -- Fixed bug #43808 (date_create never fails (even when it should)). (Derick) -- Fixed bug #43793 (zlib filter is unable to auto-detect gzip/zlib file headers). (Greg) -- Fixed bug #43703 (Signature compatibility check broken). (Dmitry) -- Fixed bug #43677 (Inconsistent behaviour of include_path set with php_value). (manuel at mausz dot at) -- Fixed bug #43663 (Extending PDO class with a __call() function doesn't work). (David Soria Parra) -- Fixed bug #43647 (Make FindFile use PATH_SEPARATOR instead of ";"). (Ilia) -- Fixed bug #43635 (mysql extension ingores INI settings on NULL values passed to mysql_connect()). (Ilia) -- Fixed bug #43620 (Workaround for a bug inside libcurl 7.16.2 that can result in a crash). (Ilia) -- Fixed bug #43614 (incorrect processing of numerical string keys of array in arbitrary serialized data). (Dmitriy Buldakov, Felipe) -- Fixed bug #43606 (define missing depencies of the exif extension). (crrodriguez at suse dot de) -- Fixed bug #43589 (a possible infinite loop in bz2_filter.c). (Greg) -- Fixed bug #43580 (removed bogus declaration of a non-existent php_is_url() function). (Ilia) -- Fixed bug #43559 (array_merge_recursive() doesn't behave as expected with duplicate NULL values). (Felipe, Tony) -- Fixed bug #43533 (escapeshellarg('') returns null). (Ilia) -- Fixed bug #43527 (DateTime created from a timestamp reports environment timezone). (Derick) -- Fixed bug #43522 (stream_get_line() eats additional characters). (Felipe, Ilia, Tony) -- Fixed bug #43507 (SOAPFault HTTP Status 500 - would like to be able to set the HTTP Status). (Dmitry) -- Fixed bug #43505 (Assign by reference bug). (Dmitry) -- Fixed bug #43498 (file_exists() on a proftpd server got SIZE not allowed in ASCII mode). (Ilia, crrodriguez at suse dot de) -- Fixed bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory). (Chris) -- Fixed bug #43495 (array_merge_recursive() crashes with recursive arrays). (Ilia) -- Fixed bug #43493 (pdo_pgsql does not send username on connect when password is not available). (Ilia) -- Fixed bug #43491 (Under certain conditions, file_exists() never returns). (Dmitry) -- Fixed bug #43483 (get_class_methods() does not list all visible methods). (Dmitry) -- Fixed bug #43482 (array_pad() does not warn on very small pad numbers). (Ilia) -- Fixed bug #43457 (Prepared statement with incorrect parms doesn't throw exception with pdo_pgsql driver). (Ilia) -- Fixed bug #43450 (Memory leak on some functions with implicit object __toString() call). (David C.) -- Fixed bug #43386 (array_globals not reset to 0 properly on init). (Ilia) -- Fixed bug #43377 (PHP crashes with invalid argument for DateTimeZone). (Ilia) -- Fixed bug #43373 (pcntl_fork() should not raise E_ERROR on error). (Ilia) -- Fixed bug #43364 (recursive xincludes don't remove internal xml nodes properly). (Rob, patch from ddb@bitxtender.de) -- Fixed bug #43301 (mb_ereg*_replace() crashes when replacement string is invalid PHP expression and 'e' option is used). (Jani) -- Fixed bug #43295 (crash because of uninitialized SG(sapi_headers).mimetype). (Dmitry) -- Fixed bug #43293 (Multiple segfaults in getopt()). (Hannes) -- Fixed bug #43279 (pg_send_query_params() converts all elements in 'params' to strings). (Ilia) -- Fixed bug #43276 (Incomplete fix for bug #42739, mkdir() under safe_mode). (Ilia) -- Fixed bug #43248 (backward compatibility break in realpath()). (Dmitry) -- Fixed bug #43221 (SimpleXML adding default namespace in addAttribute). (Rob) -- Fixed bug #43216 (stream_is_local() returns false on "file://"). (Dmitry) -- Fixed bug #43201 (Crash on using uninitialized vals and __get/__set). (Dmitry) -- Fixed bug #43182 (file_put_contents() LOCK_EX does not work properly on file truncation). (Ilia) -- Fixed bug #43175 (__destruct() throwing an exception with __call() causes segfault). (Dmitry) -- Fixed bug #43128 (Very long class name causes segfault). (Dmitry) -- Fixed bug #43105 (PHP seems to fail to close open files). (Hannes) -- Fixed bug #43092 (curl_copy_handle() crashes with > 32 chars long URL). (Jani) -- Fixed bug #43003 (Invalid timezone reported for DateTime objects constructed using a timestamp). (Derick) -- Fixed bug #42978 (mismatch between number of bound params and values causes a crash in pdo_pgsql). (Ilia) -- Fixed bug #42945 (preg_split() swallows part of the string). (Nuno) -- Fixed bug #42937 (__call() method not invoked when methods are called on parent from child class). (Dmitry) -- Fixed bug #42841 (REF CURSOR and oci_new_cursor() crash PHP). (Chris) -- Fixed bug #42838 (Wrong results in array_diff_uassoc) (Felipe) -- Fixed bug #42779 (Incorrect forcing from HTTP/1.0 request to HTTP/1.1 response). (Ilia) -- Fixed bug #42736 (xmlrpc_server_call_method() crashes). (Tony) -- Fixed bug #42692 (Procedure 'int1' not present with doc/lit SoapServer). (Dmitry) -- Fixed bug #42548 (mysqli PROCEDURE calls can't return result sets). (Hartmut) -- Fixed bug #42505 (new sendmail default breaks on Netware platform) (Guenter Knauf) -- Fixed bug #42369 (Implicit conversion to string leaks memory). (David C., Rob). -- Fixed bug #42272 (var_export() incorrectly escapes char(0)). (Derick) -- Fixed bug #42261 (Incorrect lengths for date and boolean data types). (Ilia) -- Fixed bug #42190 (Constructing DateTime with TimeZone Indicator invalidates DateTimeZone). (Derick) -- Fixed bug #42177 (Warning "array_merge_recursive(): recursion detected" comes again...). (Felipe) -- Fixed bug #41941 (oci8 extension not lib64 savvy). (Chris) -- Fixed bug #41828 (Failing to call RecursiveIteratorIterator::__construct() causes a sefault). (Etienne) -- Fixed bug #41599 (setTime() fails after modify() is used). (Derick) -- Fixed bug #41562 (SimpleXML memory issue). (Rob) -- Fixed bug #40013 (php_uname() does not return nodename on Netware (Guenter Knauf) -- Fixed bug #38468 (Unexpected creation of cycle). (Dmitry) -- Fixed bug #32979 (OpenSSL stream->fd casts broken in 64-bit build) (stotty at tvnet dot hu) - -08 Nov 2007, PHP 5.2.5 -- Upgraded PCRE to version 7.3 (Nuno) -- Added optional parameter $provide_object to debug_backtrace(). (Sebastian) -- Added alpha support for imagefilter() IMG_FILTER_COLORIZE. (Pierre) -- Added ability to control memory consumption between request using - ZEND_MM_COMPACT environment variable. (Dmitry) - -- Improved speed of array_intersect_key(), array_intersect_assoc(), - array_uintersect_assoc(), array_diff_key(), array_diff_assoc() and - array_udiff_assoc(). (Dmitry) - -- Fixed move_uploaded_file() to always set file permissions of resulting file - according to UMASK. (Andrew Sitnikov) -- Fixed possible crash in ext/soap because of uninitialized value. (Zdash Urf) -- Fixed regression in glob() when enforcing safe_mode/open_basedir checks on - paths containing '*'. (Ilia) -- Fixed "mail.force_extra_parameters" php.ini directive not to be modifiable - in .htaccess due to the security implications - reported by SecurityReason. - (Stas) -- Fixed PDO crash when driver returns empty LOB stream. (Stas) -- Fixed dl() to only accept filenames - reported by Laurent Gaffie. (Stas) -- Fixed dl() to limit argument size to MAXPATHLEN (CVE-2007-4887). - (Christian Hoffmann) -- Fixed iconv_*() functions to limit argument sizes as workaround to libc - bug (CVE-2007-4783, CVE-2007-4840 by Laurent Gaffie). - (Christian Hoffmann, Stas) -- Fixed missing brackets leading to build warning and error in the log. - Win32 code. (Andrey) -- Fixed leaks with multiple connects on one mysqli object. (Andrey) -- Fixed endianness detection on MacOS when building universal binary. - (Uwe Schindler, Christian Speich, Tony) -- Fixed possible triggering of buffer overflows inside glibc - implementations of the fnmatch(), setlocale() and glob() functions. - Reported by Laurent Gaffie. (Ilia) -- Fixed imagerectangle regression with 1x1 rectangle (libgd #106). (Pierre) -- Fixed htmlentities/htmlspecialchars not to accept partial multibyte - sequences. (Stas) - -- Fixed bug #43196 (array_intersect_assoc() crashes with non-array input). - (Jani) -- Fixed bug #43139 (PDO ignores ATTR_DEFAULT_FETCH_MODE in some cases with - fetchAll()). (Ilia) -- Fixed bug #43137 (rmdir() and rename() do not clear statcache). (Jani) -- Fixed bug #43130 (Bound parameters cannot have - in their name). (Ilia) -- Fixed bug #43099 (XMLWriter::endElement() does not check # of params). - (Ilia) -- Fixed bug #43020 (Warning message is missing with shuffle() and more - than one argument). (Scott) -- Fixed bug #42976 (Crash when constructor for newInstance() or - newInstanceArgs() fails) (Ilia) -- Fixed bug #42943 (ext/mssql: Move *timeout initialization from RINIT - to connect time). (Ilia) -- Fixed bug #42917 (PDO::FETCH_KEY_PAIR doesn't work with setFetchMode). - (Ilia) -- Fixed bug #42890 (Constant "LIST" defined by mysqlclient and c-client). - (Andrey) -- Fixed bug #42869 (automatic session id insertion adds sessions id to - non-local forms). (Ilia) -- Fixed bug #42818 ($foo = clone(array()); leaks memory). (Dmitry) -- Fixed bug #42817 (clone() on a non-object does not result in a fatal - error). (Ilia) -- Fixed bug #42785 (json_encode() formats doubles according to locale rather - then following standard syntax). (Ilia) -- Fixed bug #42783 (pg_insert() does not accept an empty list for - insertion). (Ilia) -- Fixed bug #42773 (WSDL error causes HTTP 500 Response). (Dmitry) -- Fixed bug #42772 (Storing $this in a static var fails while handling a cast - to string). (Dmitry) -- Fixed bug #42767 (highlight_string() truncates trailing comment). (Ilia) -- Fixed bug #42739 (mkdir() doesn't like a trailing slash when safe_mode is - enabled). (Ilia) -- Fixed bug #42703 (Exception raised in an iterator::current() causes segfault - in FilterIterator) (Marcus) -- Fixed bug #42699 (PHP_SELF duplicates path). (Dmitry) -- Fixed bug #42654 (RecursiveIteratorIterator modifies only part of leaves) - (Marcus) -- Fixed bug #42643 (CLI segfaults if using ATTR_PERSISTENT). (Ilia) -- Fixed bug #42637 (SoapFault : Only http and https are allowed). (Bill Moran) -- Fixed bug #42629 (Dynamically loaded PHP extensions need symbols exported - on MacOSX). (jdolecek at NetBSD dot org) -- Fixed bug #42627 (bz2 extension fails to build with -fno-common). - (dolecek at netbsd dot org) -- Fixed Bug #42596 (session.save_path MODE option does not work). (Ilia) -- Fixed bug #42590 (Make the engine recognize \v and \f escape sequences). - (Ilia) -- Fixed bug #42587 (behavior change regarding symlinked .php files). (Dmitry) -- Fixed bug #42579 (apache_reset_timeout() does not exist). (Jani) -- Fixed bug #42549 (ext/mysql failed to compile with libmysql 3.23). (Scott) -- Fixed bug #42523 (PHP_SELF duplicates path). (Dmitry) -- Fixed bug #42512 (ip2long('255.255.255.255') should return 4294967295 on - 64-bit PHP). (Derick) -- Fixed bug #42506 (php_pgsql_convert() timezone parse bug) (nonunnet at - gmail dot com, Ilia) -- Fixed bug #42496 (OCI8 cursor is not closed when using 2 clobs in a select - query). (Oracle Corp.) -- Fixed bug #42462 (Segmentation when trying to set an attribute in a - DOMElement). (Rob) -- Fixed bug #42453 (CGI SAPI does not shut down cleanly with -i/-m/-v cmdline - options). (Dmitry) -- Fixed bug #42452 (PDO classes do not expose Reflection API information). - (Hannes) -- Fixed bug #42468 (Write lock on file_get_contents fails when using a - compression stream). (Ilia) -- Fixed bug #42488 (SoapServer reports an encoding error and the error itself - breaks). (Dmitry) -- Fixed bug #42378 (mysqli_stmt_bind_result memory exhaustion). (Andrey) -- Fixed bug #42359 (xsd:list type not parsed). (Dmitry) -- Fixed bug #42326 (SoapServer crash). (Dmitry) -- Fixed bug #42214 (SoapServer sends clients internal PHP errors). (Dmitry) -- Fixed bug #42189 (xmlrpc_set_type() crashes php on invalid datetime - values). (Ilia) -- Fixed bug #42139 (XMLReader option constants are broken using XML()). (Rob) -- Fixed bug #42086 (SoapServer return Procedure '' not present for WSIBasic - compliant wsdl). (Dmitry) -- Fixed bug #41822 (Relative includes broken when getcwd() fails). (Ab5602, - Jani) -- Fixed bug #41561 (Values set with php_admin_* in httpd.conf can be overwritten - with ini_set()). (Stas, Jani) -- Fixed bug #39651 (proc_open() append mode doesn't work on windows). (Nuno) - -30 Aug 2007, PHP 5.2.4 -- Removed --enable-versioning configure option. (Jani) - -- Upgraded PCRE to version 7.2 (Nuno) -- Updated timezone database to version 2007.6. (Derick) - -- Improved openssl_x509_parse() to return extensions in readable form. (Dmitry) - -- Enabled changing the size of statement cache for non-persistent OCI8 - connections. (Chris Jones, Tony) - -- Changed "display_errors" php.ini option to accept "stderr" as value which - makes the error messages to be outputted to STDERR instead of STDOUT with - CGI and CLI SAPIs (FR #22839). (Jani) -- Changed error handler to send HTTP 500 instead of blank page on PHP errors. - (Dmitry, Andrei Nigmatulin) -- Changed mail() function to be always available. (Johannes) - -- Added check for unknown options passed to configure. (Jani) -- Added persistent connection status checker to pdo_pgsql. - (Elvis Pranskevichus, Ilia) -- Added support for ATTR_TIMEOUT inside pdo_pgsql driver. (Ilia) -- Added php_ini_loaded_file() function which returns the path to the actual - php.ini in use. (Jani) -- Added GD version constants GD_MAJOR_VERSION, GD_MINOR_VERSION, - GD_RELEASE_VERSION, GD_EXTRA_VERSION and GD_VERSION_STRING. (Pierre) -- Added missing open_basedir checks to CGI. - (anight at eyelinkmedia dot com, Tony) -- Added missing format validator to unpack() function. (Ilia) -- Added missing error check inside bcpowmod(). (Ilia) -- Added CURLOPT_PRIVATE & CURLINFO_PRIVATE constants. - (Andrey A. Belashkov, Tony) -- Added missing MSG_EOR and MSG_EOF constants to sockets extension. (Jani) -- Added PCRE_VERSION constant. (Tony) -- Added ReflectionExtension::info() function to print the phpinfo() - block for an extension. (Johannes) - -- Implemented FR #41884 (ReflectionClass::getDefaultProperties() does not - handle static attributes). (Tony) - -- Fixed "Floating point exception" inside wordwrap(). - (Mattias Bengtsson, Ilia) -- Fixed several integer overflows in ImageCreate(), ImageCreateTrueColor(), - ImageCopyResampled() and ImageFilledPolygon() reported by Mattias Bengtsson. - (Tony) -- Fixed size calculation in chunk_split(). (Stas) -- Fixed integer overflow in str[c]spn(). (Stas) -- Fixed money_format() not to accept multiple %i or %n tokens. - (Stas, Ilia) -- Fixed zend_alter_ini_entry() memory_limit interruption - vulnerability. (Ilia) -- Fixed INFILE LOCAL option handling with MySQL extensions not to be - allowed when open_basedir or safe_mode is active. (Stas) -- Fixed session.save_path and error_log values to be checked against - open_basedir and safe_mode (CVE-2007-3378) (Stas, Maksymilian Arciemowicz) -- Fixed possible invalid read in glob() win32 implementation (CVE-2007-3806). - (Tony) -- Improved fix for MOPB-03-2007. (Ilia) -- Corrected fix for CVE-2007-2872. (Ilia) - -- Fixed possible crash in imagepsloadfont(), work around a bug in the pslib on - Windows. (Pierre) -- Fixed oci8 and PDO_OCI extensions to allow configuring with Oracle 11g - client libraries. (Chris Jones) -- Fixed EOF handling in case of reading from file opened in write only mode. - (Dmitry) -- Fixed var_export() to use the new H modifier so that it can generate - parseable PHP code for floats, independent of the locale. (Derick) -- Fixed regression introduced by the fix for the libgd bug #74. (Pierre) -- Fixed SimpleXML's behavior when used with empty(). (Sara) -- Fixed crash in OpenSSL extension because of non-string passphrase. (Dmitry) - -- Fixed PECL Bug #11345 (PDO_OCI crash after National language Support "NLS" - environment initialization error). (Chris Jones) -- Fixed PECL bug #11216 (crash in ZipArchive::addEmptyDir when a directory - already exists). (Pierre) - -- Fixed bug #43926 (isInstance() isn't equivalent to instanceof operator). (Marcus) -- Fixed bug #42368 (Incorrect error message displayed by pg_escape_string). - (Ilia) -- Fixed bug #42365 (glob() crashes and/or accepts way too many flags). - (Jani) -- Fixed Bug #42364 (Crash when using getRealPath with DirectoryIterator). - (Johannes) -- Fixed bug #42292 ($PHP_CONFIG not set for phpized builds). (Jani) -- Fixed bug #42261 (header wrong for date field). - (roberto at spadim dot com dot br, Ilia) -- Fixed bug #42259 (SimpleXMLIterator loses ancestry). (Rob) -- Fixed bug #42247 (ldap_parse_result() not defined under win32). (Jani) -- Fixed bug #42243 (copy() does not output an error when the first arg is a - dir). (Ilia) -- Fixed bug #42242 (sybase_connect() crashes). (Ilia) -- Fixed bug #42237 (stream_copy_to_stream returns invalid values for mmaped - streams). (andrew dot minerd at sellingsource dot com, Ilia) -- Fixed bug #42233 (Problems with æøå in extract()). (Jani) -- Fixed bug #42222 (possible buffer overflow in php_openssl_make_REQ). (Pierre) -- Fixed bug #42211 (property_exists() fails to find protected properties - from a parent class). (Dmitry) -- Fixed bug #42208 (substr_replace() crashes when the same array is passed - more than once). (crrodriguez at suse dot de, Ilia) -- Fixed bug #42198 (SCRIPT_NAME and PHP_SELF truncated when inside a userdir - and using PATH_INFO). (Dmitry) -- Fixed bug #42195 (C++ compiler required always). (Jani) -- Fixed bug #42183 (classmap causes crash in non-wsdl mode). (Dmitry) -- Fixed bug #42173 (oci8 INTERVAL and TIMESTAMP type fixes). (Chris) -- Fixed bug #42151 (__destruct functions not called after catching a SoapFault - exception). (Dmitry) -- Fixed bug #42142 (substr_replace() returns FALSE when length > string length). - (Ilia) -- Fixed bug #42135 (Second call of session_start() causes creation of SID). - (Ilia) -- Fixed bug #42134 (oci_error() returns false after oci_new_collection() fails). - (Tony) -- Fixed bug #42119 (array_push($arr,&$obj) doesn't work with - zend.ze1_compatibility_mode On). (Dmitry) -- Fixed bug #42117 (bzip2.compress loses data in internal buffer). - (Philip, Ilia) -- Fixed bug #42112 (deleting a node produces memory corruption). (Rob) -- Fixed bug #42107 (sscanf broken when using %2$s format parameters). (Jani) -- Fixed bug #42090 (json_decode causes segmentation fault). (Hannes) -- Fixed bug #42082 (NodeList length zero should be empty). (Hannes) -- Fixed bug #42072 (No warning message for clearstatcache() with arguments). - (Ilia) -- Fixed bug #42071 (ini scanner allows using NULL as option name). (Jani) -- Fixed bug #42027 (is_file() / is_dir() matches file/dirnames with wildcard char - or trailing slash in Windows). (Dmitry) -- Fixed bug #42019 (configure option --with-adabas=DIR does not work). (Jani) -- Fixed bug #42015 (ldap_rename(): server error "DSA is unwilling to perform"). - (bob at mroczka dot com, Jani) -- Fixed bug #42009 (is_a() and is_subclass_of() should NOT call autoload, in the - same way as "instanceof" operator). (Dmitry) -- Fixed bug #41989 (move_uploaded_file() & relative path in ZTS mode). (Tony) -- Fixed bug #41984 (Hangs on large SoapClient requests). (Dmitry) -- Fixed bug #41983 (Error Fetching http headers terminated by '\n'). (Dmitry) -- Fixed bug #41973 (--with-ldap=shared fails with LDFLAGS="-Wl,--as-needed"). (Nuno) -- Fixed bug #41971 (PDOStatement::fetch and PDOStatement::setFetchMode causes - unexpected behavior). (Ilia) -- Fixed bug #41964 (strtotime returns a timestamp for non-time string of - pattern '(A|a) .+'). (Derick) -- Fixed bug #41961 (Ensure search for hidden private methods does not stray from - class hierarchy). (robin_fernandes at uk dot ibm dot com) -- Fixed bug #41947 (SimpleXML incorrectly registers empty strings asnamespaces). - (Rob) -- Fixed bug #41929 (Foreach on object does not iterate over all visible properties). - (Dmitry) -- Fixed bug #41919 (crash in string to array conversion). - (judas dot iscariote at gmail dot com, Ilia) -- Fixed bug #41909 (var_export() is locale sensitive when exporting float - values). (Derick) -- Fixed bug #41908 (CFLAGS="-Os" ./configure --enable-debug fails). - (christian at hoffie dot info, Tony) -- Fixed bug #41904 (proc_open(): empty env array should cause empty environment - to be passed to process). (Jani) -- Fixed bug #41867 (SimpleXML: getName is broken). (Rob) -- Fixed bug #41865 (fputcsv(): 2nd parameter is not optional). (Jani) -- Fixed bug #41861 (SimpleXML: getNamespaces() returns the namespaces of a node's - siblings). (Rob) -- Fixed bug #41845 (pgsql extension does not compile with PostgreSQL <7.4). (Ilia) -- Fixed bug #41844 (Format returns incorrect number of digits for negative years - -0001 to -0999). (Derick) -- Fixed bug #41842 (Cannot create years < 0100 & negative years with date_create - or new DateTime). (Derick) -- Fixed bug #41833 (addChild() on a non-existent node, no node created, - getName() segfaults). (Rob) -- Fixed bug #41831 (pdo_sqlite prepared statements convert resources to - strings). (Ilia) -- Fixed bug #41815 (Concurrent read/write fails when EOF is reached). (Sascha) -- Fixed bug #41813 (segmentation fault when using string offset as an object). - (judas dot iscariote at gmail dot com, Tony) -- Fixed bug #41795 (checkdnsrr does not support DNS_TXT type). - (lucas at facebook dot com, Tony) -- Fixed bug #41773 (php_strip_whitespace() sends headers with errors - suppressed). (Tony) -- Fixed bug #41770 (SSL: fatal protocol error due to buffer issues). (Ilia) -- Fixed bug #41765 (Recode crashes/does not work on amd64). - (nexus at smoula dot net, Stas) -- Fixed bug #41724 (libxml_get_last_error() - errors service request scope). - (thekid at php dot net, Ilia) -- Fixed bug #41717 (imagepolygon does not respect thickness). (Pierre) -- Fixed bug #41713 (Persistent memory consumption on win32 since 5.2). (Dmitry) -- Fixed bug #41711 (NULL temporary lobs not supported in OCI8). - (Chris Jones, Tony) -- Fixed bug #41709 (strtotime() does not handle 00.00.0000). (Derick) -- Fixed bug #41698 (float parameters truncated to integer in prepared - statements). (Ilia) -- Fixed bug #41692 (ArrayObject shows weird behavior in respect to - inheritance). (Tony) -- Fixed bug #41691 (ArrayObject::exchangeArray hangs Apache). (Tony) -- Fixed bug #41686 (Omitting length param in array_slice not possible). (Ilia) -- Fixed bug #41685 (array_push() fails to warn when next index is - already occupied). (Ilia) -- Fixed bug #41655 (open_basedir bypass via glob()). (Ilia) -- Fixed bug #41640 (get_class_vars produces error on class constants). - (Johannes) -- Fixed bug #41635 (SoapServer and zlib.output_compression with FastCGI - result in major slowdown). (Dmitry) -- Fixed bug #41633 (Crash instantiating classes with self-referencing - constants). (Dmitry) -- Fixed bug #41630 (segfault when an invalid color index is present in the - image data). (Reported by Elliot ) (Pierre) -- Fixed bug #41628 (PHP settings leak between Virtual Hosts in Apache 1.3). - (Scott, manuel at mausz dot at) -- Fixed bug #41608 (segfault on a weird code with objects and switch()). - (Tony) -- Fixed bug #41600 (url rewriter tags doesn't work with namespaced tags). - (Ilia) -- Fixed bug #41596 (Fixed a crash inside pdo_pgsql on some non-well-formed - SQL queries). (Ilia) -- Fixed bug #41594 (OCI8 statement cache is flushed too frequently). (Tony) -- Fixed bug #41582 (SimpleXML crashes when accessing newly created element). - (Tony) -- Fixed bug #41576 (configure failure when using --without-apxs or some other - SAPIs disabling options). (Jani) -- Fixed bug #41567 (json_encode() double conversion is inconsistent with PHP). - (Lucas, Ilia) -- Fixed bug #41566 (SOAP Server not properly generating href attributes). - (Dmitry) -- Fixed bug #41555 (configure failure: regression caused by fix for #41265). - (Jani) -- Fixed bug #41527 (WDDX deserialize numeric string array key). - (Matt, Ilia) -- Fixed bug #41523 (strtotime('0000-00-00 00:00:00') is parsed as 1999-11-30). - (Derick) -- Fixed bug #41518 (file_exists() warns of open_basedir restriction on - non-existent file). (Tony) -- Fixed bug #41445 (parse_ini_file() has a problem with certain types of - integer as sections). (Tony) -- Fixed bug #41433 (DBA: configure fails to include correct db.h for db4). - (Jani) -- Fixed bug #41372 (Internal pointer of source array resets during array - copying). (Dmitry) -- Fixed bug #41350 (my_thread_global_end() error during request shutdown on - Windows). (Scott, Andrey) -- Fixed bug #41278 (get_loaded_extensions() should list Zend extensions). - (Johannes) -- Fixed bug #41127 (Memory leak in ldap_{first|next}_attribute functions). - (Jani) -- Fixed bug #40757 (get_object_vars get nothing in child class). (Dmitry) -- Fixed bug #40705 (Iterating within function moves original array pointer). - (Dmitry) -- Fixed bug #40509 (key() function changed behaviour if global array is used - within function). (Dmitry) -- Fixed bug #40419 (Trailing slash in CGI request does not work). (Dmitry) -- Fixed bug #39330 (apache2handler does not call shutdown actions before - apache child die). (isk at ecommerce dot com, Gopal, Tony) -- Fixed bug #39291 (ldap_sasl_bind() misses the sasl_authc_id parameter). - (diafour at gmail dot com, Jani) -- Fixed bug #37715 (array pointers resetting on copy). (Dmitry) -- Fixed bug #37273 (Symlinks and mod_files session handler allow open_basedir - bypass). (Ilia) -- Fixed bug #36492 (Userfilters can leak buckets). (Sara) -- Fixed bugs #36796, #36918, #41371 (stream_set_blocking() does not work). - (Jani) -- Fixed bug #35981 (pdo-pgsql should not use pkg-config when not present). - (Jani) -- Fixed bug #31892 (PHP_SELF incorrect without cgi.fix_pathinfo, but turning on - screws up PATH_INFO). (Dmitry) -- Fixed bug #21197 (socket_read() outputs error with PHP_NORMAL_READ). - (Nuno, Jani) - -31 May 2007, PHP 5.2.3 -- Changed CGI install target to php-cgi and 'make install' to install CLI - when CGI is selected. (Jani) -- Changed JSON maximum nesting depth from 20 to 128. (Rasmus) - -- Improved compilation of heredocs and interpolated strings. (Matt, Dmitry) -- Optimized out a couple of per-request syscalls. (Rasmus) -- Optimized digest generation in md5() and sha1() functions. (Ilia) -- Upgraded bundled SQLite 3 to version 3.3.17. (Ilia) - -- Added "max_input_nesting_level" php.ini option to limit nesting level of - input variables. Fix for MOPB-03-2007. (Stas) -- Added a 4th parameter flag to htmlspecialchars() and htmlentities() that - makes the function not encode existing html entities. (Ilia) -- Added PDO::FETCH_KEY_PAIR mode that will fetch a 2 column result set into - an associated array. (Ilia) -- Added CURLOPT_TIMEOUT_MS and CURLOPT_CONNECTTIMEOUT_MS cURL constants. (Sara) -- Added --ini switch to CLI that prints out configuration file names. (Marcus) -- Added mysql_set_charset() to allow runtime altering of connection encoding. - (Scott) - -- Implemented FR #41416 (getColumnMeta() should also return table name). (Tony) - -- Fixed an integer overflow inside chunk_split(). Identified by Gerhard Wagner. - (Ilia) -- Fixed SOAP extension's handler() to work even when - "always_populate_raw_post_data" is off. (Ilia) -- Fixed possible infinite loop in imagecreatefrompng. (libgd #86) - (by Xavier Roche, CVE-2007-2756). (Pierre) -- Fixed ext/filter Email Validation Vulnerability (MOPB-45 by Stefan Esser). - (Ilia) -- Fixed altering $this via argument named "this". (Dmitry) -- Fixed PHP CLI usage of php.ini from the binary location. (Hannes) -- Fixed segfault in strripos(). (Tony, Joxean Koret) -- Fixed bug #41693 (scandir() allows empty directory names). (Ilia) -- Fixed bug #41673 (json_encode breaks large numbers in arrays). (Ilia) -- Fixed bug #41525 (ReflectionParameter::getPosition() not available). (Marcus) -- Fixed bug #41511 (Compile failure under IRIX 6.5.30 building md5.c). (Jani) -- Fixed bug #41504 (json_decode() incorrectly decodes JSON arrays with empty - string keys). (Ilia) -- Fixed bug #41492 (open_basedir/safe_mode bypass inside realpath()). (Ilia) -- Fixed bug #41477 (no arginfo about SoapClient::__soapCall()). (Ilia) -- Fixed bug #41455 (ext/dba/config.m4 pollutes global $LIBS and $LDFLAGS). - (mmarek at suse dot cz, Tony) -- Fixed bug #41442 (imagegd2() under output control). (Tony) -- Fixed bug #41430 (Fatal error with negative values of maxlen parameter of - file_get_contents()). (Tony) -- Fixed bug #41423 (PHP assumes wrongly that certain ciphers are enabled in - OpenSSL). (Pierre) -- Fixed bug #41421 (Uncaught exception from a stream wrapper segfaults). - (Tony, Dmitry) -- Fixed bug #41403 (json_decode cannot decode floats if localeconv - decimal_point is not '.'). (Tony) -- Fixed bug #41401 (wrong unary operator precedence). (Stas) -- Fixed bug #41394 (dbase_create creates file with corrupted header). (Tony) -- Fixed bug #41390 (Clarify error message with invalid protocol scheme). - (Scott) -- Fixed bug #41378 (fastcgi protocol lacks support for Reason-Phrase in - "Status:" header). (anight at eyelinkmedia dot com, Dmitry) -- Fixed bug #41374 (whole text concats values of wrong nodes). (Rob) -- Fixed bug #41358 (configure cannot determine SSL lib with libcurl >= 7.16.2). - (Mike) -- Fixed bug #41353 (crash in openssl_pkcs12_read() on invalid input). (Ilia) -- Fixed bug #41351 (Invalid opcode with foreach ($a[] as $b)). (Dmitry, Tony) -- Fixed bug #41347 (checkdnsrr() segfaults on empty hostname). (Scott) -- Fixed bug #41337 (WSDL parsing doesn't ignore non soap bindings). (Dmitry) -- Fixed bug #41326 (Writing empty tags with Xmlwriter::WriteElement[ns]) - (Pierre) -- Fixed bug #41321 (downgrade read errors in getimagesize() to E_NOTICE). - (Ilia) -- Fixed bug #41304 (compress.zlib temp files left). (Dmitry) -- Fixed bug #41293 (Fixed creation of HTTP_RAW_POST_DATA when there is no - default post handler). (Ilia) -- Fixed bug #41291 (FastCGI does not set SO_REUSEADDR). - (fmajid at kefta dot com, Dmitry) -- Fixed gd build when used with freetype 1.x (Pierre, Tony) -- Fixed bug #41287 (Namespace functions don't allow xmlns definition to be - optional). (Rob) -- Fixed bug #41285 (Improved fix for CVE-2007-1887 to work with non-bundled - sqlite2 lib). (Ilia) -- Fixed bug #41283 (Bug with deserializing array key that are doubles or - floats in wddx). (Ilia) -- Fixed bug #41257 (lookupNamespaceURI does not work as expected). (Rob) -- Fixed bug #41236 (Regression in timeout handling of non-blocking SSL - connections during reads and writes). (Ilia) -- Fixed bug #41134 (zend_ts_hash_clean not thread-safe). - (marco dot cova at gmail dot com, Tony) -- Fixed bug #41097 (ext/soap returning associative array as indexed without - using WSDL). (Dmitry) -- Fixed bug #41004 (minOccurs="0" and null class member variable). (Dmitry) -- Fixed bug #39542 (Behavior of require/include different to < 5.2.0). - (Dmitry) - -03 May 2007, PHP 5.2.2 -- Improved bundled GD - . Sync to 2.0.35 - . Added imagegrabwindow and imagegrabscreen, capture a screen or a - window using its handle (Pierre) - . colors allocated henceforth from the resulting image overwrite the palette - colors (Rob Leslie) - . Improved thread safety of the gif support (Roman Nemecek, Nuno, Pierre) - . Use the dimension of the GIF frame to create the destination image (Pierre) - . Load only once the local color map from a GIF data (Pierre) - . Improved thread safety of the freetype cache (Scott MacVicar, Nuno, Pierre) - . imagearc huge CPU usage with large angles, libgd bug #74 (Pierre) -- Improved FastCGI SAPI to support external pipe and socket servers on win32. - (Dmitry) -- Improved Zend Memory Manager - . guarantee of reasonable time for worst cases of best-fit free block - searching algorithm. (Dmitry) - . better cache usage and less fragmentation on erealloc() (Tony, Dmitry) -- Improved SPL (Marcus) - . Added SplFileInfo::getBasename(), DirectoryIterator::getBasename(). - . Added SplFileInfo::getLinkTarget(), SplFileInfo::getRealPath(). - . Made RecursiveFilterIterator::accept() abstract as stated in documentation. -- Improved SOAP - . Added ability to encode arrays with "SOAP-ENC:Array" type instead of WSDL - type. To activate the ability use "feature"=>SOAP_USE_XSI_ARRAY_TYPE - option in SoapClient/SoapServer constructors. (Rob, Dmitry) - -- Added GMP_VERSION constant. (Tony) -- Added --ri switch to CLI which allows to check extension information. (Marcus) -- Added tidyNode::getParent() method (John, Nuno) -- Added openbasedir and safemode checks in zip:// stream wrapper and - ZipArchive::open (Pierre) -- Added php_pdo_sqlite_external.dll, a version of the PDO SQLite driver that - links against an external sqlite3.dll. This provides Windows users to upgrade - their sqlite3 version outside of the PHP release cycle. (Wez, Edin) -- Added linenumbers to array returned by token_get_all(). (Johannes) - -- Upgraded SQLite 3 to version 3.3.16 (Ilia) -- Upgraded libraries bundled in the Windows distribution. (Edin) - . c-client (imap) to version 2006e - . libpq (PostgreSQL) to version 8.2.3 - . libmysql (MySQL) to version 5.0.37 - . openssl to version 0.9.8e -- Upgraded PCRE to version 7.0 (Nuno) - -- Updated timezone database to version 2007.5. (Derick) - -- Fixed commandline handling for CLI and CGI. (Marcus, Johannes) -- Fixed iterator_apply() with a callback using __call(). (Johannes) -- Fixed possible multi bytes issues in openssl csr parser (Pierre) -- Fixed shmop_open() with IPC_CREAT|IPC_EXCL flags on Windows. - (Vladimir Kamaev, Tony). -- Fixed possible leak in ZipArchive::extractTo when safemode checks fails (Ilia) -- Fixed possible relative path issues in zip_open and TS mode (old API) (Pierre) -- Fixed zend_llist_remove_tail (Michael Wallner, Dmitry) -- Fixed a thread safety issue in gd gif read code (Nuno, Roman Nemecek) -- Fixed CVE-2007-1001, GD wbmp used with invalid image size (Pierre) -- Fixed unallocated memory access/double free in in array_user_key_compare() - (MOPB-24 by Stefan Esser) (Stas) -- Fixed wrong length calculation in unserialize S type - (MOPB-29 by Stefan Esser) (Stas) - -- Fixed bug #41215 (setAttribute return code reversed). (Ilia) -- Fixed bug #41192 (Per Directory Values only work for one key). (Dmitry) -- Fixed bug #41175 (addAttribute() fails to add an attribute with an empty - value). (Ilia) -- Fixed bug #41159 (mysql_pconnect() hash does not account for connect - flags). (Ilia) -- Fixed bug #41121 (range() overflow handling for large numbers on 32bit - machines). (Ilia) -- Fixed bug #41118 (PHP does not handle overflow of octal integers). (Tony) -- Fixed bug #41109 (recursiveiterator.inc says "implements" Iterator instead of - "extends"). (Marcus) -- Fixed bug #40130 (TTF usage doesn't work properly under Netware). (Scott, - gk at gknw dot de) -- Fixed bug #41093 (magic_quotes_gpc ignores first arrays keys). (Arpad, Ilia) -- Fixed bug #41075 (memleak when creating default object caused exception). - (Dmitry) -- Fixed bug #41067 (json_encode() problem with UTF-16 input). (jp at df5ea - dot net. Ilia) -- Fixed bug #41063 (chdir doesn't like root paths). (Dmitry) -- Fixed bug #41061 ("visibility error" in ReflectionFunction::export()). - (Johannes) -- Fixed bug #41043 (pdo_oci crash when freeing error text with persistent - connection). (Tony) -- Fixed bug #41037 (unregister_tick_function() inside the tick function crash PHP). - (Tony) -- Fixed bug #41034 (json_encode() ignores null byte started keys in arrays). - (Ilia) -- Fixed bug #41026 (segfault when calling "self::method()" in shutdown functions). - (Tony) -- Fixed bug #40999 (mcrypt_create_iv() not using random seed). (Ilia) -- Fixed bug #40998 (long session array keys are truncated). (Tony) -- Implement feature request #40947, allow a single filter as argument - for filter_var_array (Pierre) -- Fixed bug #40935 (pdo_mysql does not raise an exception on empty - fetchAll()). (Ilia) -- Fixed bug #40931 (open_basedir bypass via symlink and move_uploaded_file()). - (Tony) -- Fixed bug #40921 (php_default_post_reader crashes when post_max_size is - exceeded). (trickie at gmail dot com, Ilia) -- Fixed bug #40915 (addcslashes unexpected behavior with binary input). (Tony) -- Fixed bug #40899 (memory leak when nesting list()). (Dmitry) -- Fixed bug #40897 (error_log file not locked). (Ilia) -- Fixed bug #40883 (mysql_query() is allocating memory incorrectly). (Tony) -- Fixed bug #40872 (inconsistency in offsetSet, offsetExists treatment of - string enclosed integers). (Marcus) -- Fixed bug #40861 (strtotime() doesn't handle double negative relative time - units correctly). (Derick, Ilia) -- Fixed bug #40854 (imap_mail_compose() creates an invalid terminator for - multipart e-mails). (Ilia) -- Fixed bug #40848 (sorting issue on 64-bit Solaris). (Wez) -- Fixed bug #40836 (Segfault in ext/dom). (Rob) -- Fixed bug #40833 (Crash when using unset() on an ArrayAccess object retrieved - via __get()). (Dmitry) -- Fixed bug #40822 (pdo_mysql does not return rowCount() on select). (Ilia) -- Fixed bug #40815 (using strings like "class::func" and static methods in - set_exception_handler() might result in crash). (Tony) -- Fixed bug #40809 (Poor performance of ".="). (Dmitry) -- Fixed bug #40805 (Failure executing function ibase_execute()). (Tony) -- Fixed bug #40800 (cannot disable memory_limit with -1). (Dmitry, Tony) -- Fixed bug #40794 (ReflectionObject::getValues() may crash when used with - dynamic properties). (Tony) -- Fixed bug #40784 (Case sensitivity in constructor's fallback). (Tony) -- Fixed bug #40770 (Apache child exits when PHP memory limit reached). (Dmitry) -- Fixed bug #40764 (line thickness not respected for horizontal and vertical - lines). (Pierre) -- Fixed bug #40758 (Test fcgi_is_fastcgi() is wrong on windows). (Dmitry) -- Fixed bug #40754 (added substr() & substr_replace() overflow checks). (Ilia) -- Fixed bug #40752 (parse_ini_file() segfaults when a scalar setting is - redeclared as an array). (Tony) -- Fixed bug #40750 (openssl stream wrapper ignores default_stream_timeout). - (Tony) -- Fixed bug #40727 (segfault in PDO when failed to bind parameters). (Tony) -- Fixed bug #40709 (array_reduce() behaves strange with one item stored arrays). - (Ilia) -- Fixed bug #40703 (Resolved a possible namespace conflict between libxmlrpc - and MySQL's NDB table handler). (Ilia) -- Fixed bug #40961 (Incorrect results of DateTime equality check). (Mike) -- Fixed bug #40678 (Cross compilation fails). (Tony) -- Fixed bug #40621 (Crash when constructor called inappropriately). (Tony) -- Fixed bug #40609 (Segfaults when using more than one SoapVar in a request). - (Rob, Dmitry) -- Fixed bug #40606 (umask is not being restored when request is finished). - (Tony) -- Fixed bug #40598 (libxml segfault). (Rob) -- Fixed bug #40591 (list()="string"; gives invalid opcode). (Dmitry) -- Fixed bug #40578 (imagettftext() multithreading issue). (Tony, Pierre) -- Fixed bug #40576 (double values are truncated to 6 decimal digits when - encoding). (Tony) -- Fixed bug #40560 (DIR functions do not work on root UNC path). (Dmitry) -- Fixed bug #40548 (SplFileInfo::getOwner/getGroup give a warning on broken - symlink). (Marcus) -- Fixed bug #40546 (SplFileInfo::getPathInfo() throws an exception if directory - is in root dir). (Marcus) -- Fixed bug #40545 (multithreading issue in zend_strtod()). (Tony) -- Fixed bug #40503 (json_encode() value corruption on 32bit systems with - overflown values). (Ilia) -- Fixed bug #40467 (Partial SOAP request sent when XSD sequence or choice - include minOccurs=0). (Dmitry) -- Fixed bug #40465 (Ensure that all PHP elements are printed by var_dump). - (wharmby at uk dot ibm dot com, Ilia) -- Fixed bug #40464 (session.save_path wont use default-value when safe_mode - or open_basedir is enabled). (Ilia) -- Fixed bug #40455 (proc_open() uses wrong command line when safe_mode_exec_dir - is set). (Tony) -- Fixed bug #40432 (strip_tags() fails with greater than in attribute). (Ilia) -- Fixed bug #40431 (dynamic properties may cause crash in ReflectionProperty - methods). (Tony) -- Fixed bug #40451 (addAttribute() may crash when used with non-existent child - node). (Tony) -- Fixed bug #40442 (ArrayObject::offsetExists broke in 5.2.1, works in 5.2.0). - (olivier at elma dot fr, Marcus) -- Fixed bug #40428 (imagepstext() doesn't accept optional parameter). (Pierre) -- Fixed bug #40417 (Allow multiple instances of the same named PDO token in - prepared statement emulation code). (Ilia) -- Fixed bug #40414 (possible endless fork() loop when running fastcgi). - (Dmitry) -- Fixed bug #40410 (ext/posix does not compile on MacOS 10.3.9). (Tony) -- Fixed bug #40392 (memory leaks in PHP milter SAPI). - (tuxracer69 at gmail dot com, Tony) -- Fixed bug #40371 (pg_client_encoding() not working on Windows). (Edin) -- Fixed bug #40352 (FCGI_WEB_SERVER_ADDRS function get lost). (Dmitry) -- Fixed bug #40290 (strtotime() returns unexpected result with particular - timezone offset). (Derick) -- Fixed bug #40286 (PHP fastcgi with PHP_FCGI_CHILDREN don't kill children when - parent is killed). (Dmitry) -- Fixed bug #40261 (Extremely slow data handling due to memory fragmentation). - (Dmitry) -- Fixed bug #40236 (php -a function allocation eats memory). (Dmitry) -- Fixed bug #40109 (iptcembed fails on non-jfif jpegs). (Tony) -- Fixed bug #39965 (Latitude and longitude are backwards in date_sun_info()). - (Derick) -- Implement #39867 (openssl PKCS#12 support) (Marc Delling, Pierre) -- Fixed bug #39836 (SplObjectStorage empty after unserialize). (Marcus) -- Fixed bug #39416 (Milliseconds in date()). (Derick) -- Fixed bug #39396 (stream_set_blocking crashes on Win32). (Ilia, maurice at - iceblog dot de) -- Fixed bug #39351 (relative include fails on Solaris). (Dmitry, Tony) -- Fixed bug #39322 (proc_terminate() destroys process resource). (Nuno) -- Fixed bug #38406 (crash when assigning objects to SimpleXML attributes). (Tony) -- Fixed bug #37799 (ftp_ssl_connect() falls back to non-ssl connection). (Nuno) -- Fixed bug #36496 (SSL support in imap_open() not working on Windows). (Edin) -- Fixed bug #36226 (Inconsistent handling when passing nillable arrays). - (Dmitry) -- Fixed bug #35872 (Avoid crash caused by object store being referenced during - RSHUTDOWN). (Andy) -- Fixed bug #34794 (proc_close() hangs when used with two processes). - (jdolecek at netbsd dot org, Nuno) -- Fixed PECL bug #10194 (crash in Oracle client when memory limit reached in - the callback). (Tony) -- Fixed substr_compare and substr_count information leak (MOPB-14) (Stas, Ilia) -- Fixed crash on op-assign where argument is string offset (Brian, Stas) -- Fixed bug #38710 (data leakage because of nonexisting boundary checking in - statements in mysqli) (Stas) -- Fixed bug #37386 (autocreating element doesn't assign value to first node). - (Rob) -- Fixed bug #37013 (server hangs when returning circular object references). - (Dmitry) -- Fixed bug #33664 Console window appears when using exec() - (Richard Quadling, Stas) - - -08 Feb 2007, PHP 5.2.1 -- Added read-timeout context option "timeout" for HTTP streams. (Hannes, Ilia). -- Added CURLOPT_TCP_NODELAY constant to Curl extension. (Sara) -- Added support for hex numbers of any size. (Matt) -- Added function stream_socket_shutdown(). It is a wrapper for system - shutdown() function, that shut downs part of a full-duplex connection. - (Dmitry) -- Added internal heap protection (Dmitry) - . memory-limit is always enabled (--enable-memory-limit removed) - . default value if memory-limit is set to 128M - . safe unlinking - . cookies - . canary protection (debug build only) - . random generation of cookies and canaries -- Added forward support for 'b' prefix in front of string literals. (Andrei) -- Added three new functions to ext/xmlwriter (Rob, Ilia) - . xmlwriter_start_dtd_entity() - . xmlwriter_end_dtd_entity() - . xmlwriter_write_dtd_entity() -- Added a meta tag to phpinfo() output to prevent search engines from indexing - the page. (Ilia) -- Added new function, sys_get_temp_dir(). (Hartmut) -- Added missing object support to file_put_contents(). (Ilia) -- Added support for md2, ripemd256 and ripemd320 algos to hash(). (Sara) -- Added forward support for (binary) cast. (Derick) -- Added optimization for imageline with horizontal and vertical lines (Pierre) - -- Removed dependency from SHELL32.DLL. (Dmitry) -- Removed double "wrong parameter count" warnings in various functions. - (Hannes) -- Moved extensions to PECL: - . ext/informix (Derick, Tony) - -- Changed double-to-string utilities to use BSD implementation. (Dmitry, Tony) -- Updated bundled libcURL to version 7.16.0 in the Windows distro. (Edin) -- Updated timezone database to version 2006.16. (Derick) -- cgi.* and fastcgi.* directives are moved to INI subsystem. The new directive - cgi.check_shebang_line can be used to omitting check for "#! /usr/bin/php" - line. (Dmitry). -- Improved proc_open(). Now on Windows it can run external commands not - through CMD.EXE. (Dmitry) -- VCWD_REALPATH() is improved to use realpath cache without VIRTUAL_DIR. - (Dmitry) -- ext/bcmath initialization code is moved from request startup to module - startup. (Dmitry) -- Zend Memory Manager Improvements (Dmitry) - . use HeapAlloc() instead of VirtualAlloc() - . use "win32" storage manager (instead of "malloc") on Windows by default -- Zip Extension Improvements (Pierre) - . Fixed leak in statName and stateIndex - . Fixed return setComment (Hannes) - . Added addEmptyDir method -- Filter Extension Improvements (Ilia, Pierre) - . Fixed a bug when callback function returns a non-modified value. - . Added filter support for $_SERVER in cgi/apache2 sapis. - . Make sure PHP_SELF is filtered in Apache 1 sapi. - . Fixed bug #39358 (INSTALL_HEADERS contains incorrect reference to - php_filter.h). - . Added "default" option that allows a default value to be set for an - invalid or missing value. - . Invalid filters fails instead of returning unsafe value - . Fixed possible double encoding problem with sanitizing filters - . Make use of space-strict strip_tags() function - . Fixed whitespace trimming - . Added support for FastCGI environment variables. (Dmitry) -- PDO_MySQL Extension Improvements (Ilia) - . Enabled buffered queries by default. - . Enabled prepared statement emulation by default. - -- Small optimization of the date() function. (Matt,Ilia) -- Optimized the internal is_numeric_string() function. (Matt,Ilia) -- Optimized array functions utilizing php_splice(). (Ilia) -- Windows related optimizations (Dmitry, Stas) - . COM initialization/deinitialization are done only if necessary - . removed unnecessary checks for ISREG file and corresponding stat() calls - . opendir() is reimplementation using GetFistFile/GetNextFile those are - faster then _findfirst/_findnext - . implemented registry cache that prevent registry lookup on each request. - In case of modification of corresponding registry-tree PHP will reload it - automatic - . start timeout thread only if necessary - . stat() is reimplementation using GetFileAttributesEx(). The new - implementation is faster then implementation in MS VC CRT, but it doesn't - support Windows 95. -- Streams optimization (Dmitry) - . removed unnecessary ftell() calls (one call for each included PHP file) - . disabled calls to read() after EOF - -- Fixed incorrect function names on FreeBSD where inet_pton() was named - __inet_pton() and inet_ntop() was named __inet_ntop(). (Hannes) -- Fixed FastCGI impersonation for persistent connections on Windows. (Dmitry) -- Fixed wrong signature initialization in imagepng (Takeshi Abe) -- Fixed ftruncate() with negative size on FreeBSD. (Hannes) -- Fixed segfault in RegexIterator when given invalid regex. (Hannes) -- Fixed segfault in SplFileObject->openFile()->getPathname(). (Hannes) -- Fixed segfault in ZTS mode when OCI8 statements containing sub-statements - are destroyed in wrong order. (Tony) -- Fixed the validate email filter so that the letter "v" can also be used in - the user part of the email address. (Derick) -- Fixed bug #40297 (compile failure in ZTS mode when collections support is - missing). (Tony) -- Fixed bug #40285 (The PDO prepare parser goes into an infinite loop in - some instances). (Ilia) -- Fixed bug #40274 (Sessions fail with numeric root keys). (Ilia) -- Fixed bug #40259 (ob_start call many times - memory error). (Dmitry) -- Fixed bug #40231 (file_exists incorrectly reports false). (Dmitry) -- Fixed bug #40228 (ZipArchive::extractTo does create empty directories - recursively). (Pierre) -- Fixed bug #40200 (The FastCgi version has different realpath results than - thread safe version). (Dmitry) -- Fixed bug #40191 (use of array_unique() with objects triggers segfault). - (Tony) -- Fixed bug #40189 (possible endless loop in zlib.inflate stream filter). - (Greg, Tony) -- Fixed bug #40169 (CURLOPT_TCP_NODELAY only available in curl >= 7.11.2). - (Tony) -- Fixed bug #40129 (iconv extension doesn't compile with CodeWarrior on - Netware). (gk at gknw dot de, Tony) -- Fixed bug #40127 (apache2handler doesn't compile on Netware). - (gk at gknw dot de) -- Fixed bug #40121 (PDO_DBLIB driver wont free statements). (Ilia) -- Fixed bug #40098 (php_fopen_primary_script() not thread safe). (Ilia) -- Fixed bug #40092 (chroot() doesn't clear realpath cache). (Dmitry) -- Fixed bug #40091 (spl_autoload_register with 2 instances of the same class). - (Ilia) -- Fixed bug #40083 (milter SAPI functions always return false/null). (Tony) -- Fixed bug #40079 (php_get_current_user() not thread safe). - (Ilia, wharmby at uk dot ibm dot com) -- Fixed bug #40078 (ORA-01405 when fetching NULL values using - oci_bind_array_by_name()). (Tony) -- Fixed bug #40076 (zend_alloc.c: Value of enumeration constant must be in - range of signed integer). (Dmitry) -- Fixed bug #40073 (exif_read_data dies on certain images). (Tony, Marcus) -- Fixed bug #40036 (empty() does not work correctly with ArrayObject when - using ARRAY_AS_PROPS). (Ilia) -- Fixed bug #40012 (php_date.c doesn't compile on Netware). - (gk at gknw dot de, Derick) -- Fixed bug #40009 (http_build_query(array()) returns NULL). (Ilia) -- Fixed bug #40002 (Try/Catch performs poorly). (Dmitry) -- Fixed bug #39993 (tr_TR.UTF-8 locale has problems with PHP). (Ilia) -- Fixed bug #39990 (Cannot "foreach" over overloaded properties). (Dmitry) -- Fixed bug #39988 (type argument of oci_define_by_name() is ignored). - (Chris Jones, Tony) -- Fixed bug #39984 (redirect response code in header() could be ignored - in CGI sapi). (Ilia) -- Fixed bug #39979 (PGSQL_CONNECT_FORCE_NEW will causes next connect to - establish a new connection). (Ilia) -- Fixed bug #39971 (pg_insert/pg_update do not allow now() to be used - for timestamp fields). (Ilia) -- Fixed bug #39969 (ini setting short_open_tag has no effect when using - --enable-maintainer-zts). (Dmitry) -- Fixed bug #39952 (zip ignoring --with-libdir on zlib checks) - (judas dot iscariote at gmail dot com) -- Fixed bug #39944 (References broken). (Dmitry) -- Fixed bug #39935 (Extensions tidy,mcrypt,mhash,pdo_sqlite ignores - --with-libdir). (judas dot iscariote at gmail dot com, Derick) -- Fixed bug #39903 (Notice message when executing __halt_compiler() more than - once). (Tony) -- Fixed bug #39898 (FILTER_VALIDATE_URL validates \r\n\t etc). (Ilia) -- Fixed bug #39890 (using autoconf 2.6x and --with-layout=GNU breaks PEAR - install path). (Tony) -- Fixed bug #39884 (ReflectionParameter::getClass() throws exception for - type hint self). (thekid at php dot net) -- Fixed bug #39878 (CURL doesn't compile on Sun Studio Pro). (Ilia) -- Fixed bug #39873 (number_format() breaks with locale & decimal points). - (Ilia) -- Fixed bug #39869 (safe_read does not initialize errno). - (michiel at boland dot org, Dmitry) -- Fixed bug #39850 (SplFileObject throws contradictory/wrong error messages - when trying to open "php://wrong"). (Tony) -- Fixed bug #39846 (Invalid IPv4 treated as valid). (Ilia) -- Fixed bug #39845 (Persistent connections generate a warning in pdo_pgsql). - (Ilia) -- Fixed bug #39832 (SOAP Server: parameter not matching the WSDL specified - type are set to 0). (Dmitry) -- Fixed bug #39825 (foreach produces memory error). (Dmitry) -- Fixed bug #39816 (apxs2filter ignores httpd.conf & .htaccess php config - settings). (Ilia) -- Fixed bug #39815 (SOAP double encoding is not locale-independent). (Dmitry) -- Fixed bug #39797 (virtual() does not reset changed INI settings). (Ilia) -- Fixed bug #39795 (build fails on AIX because crypt_r() uses different - data struct). (Tony) -- Fixed bug #39791 (Crash in strtotime() on overly long relative date - multipliers). (Ilia) -- Fixed bug #39787 (PHP doesn't work with Apache 2.3). - (mv at binarysec dot com). -- Fixed bug #39782 (setTime() on a DateTime constructed with a Weekday - yields incorrect results). (Ilia) -- Fixed bug #39780 (PNG image with CRC/data error raises fatal error) (Pierre) -- Fixed bug #39779 (Enable AUTH PLAIN mechanism in underlying libc-client). - (michael dot heimpold at s2000 dot tu-chemnitz dot de, Ilia) -- Fixed bug #39775 ("Indirect modification ..." message is not shown). - (Dmitry) -- Fixed bug #39763 (magic quotes are applied twice by ext/filter in - parse_str()). (Ilia) -- Fixed bug #39760 (cloning fails on nested SimpleXML-Object). (Rob) -- Fixed bug #39759 (Can't use stored procedures fetching multiple result - sets in pdo_mysql). (Ilia) -- Fixed bug #39754 (Some POSIX extension functions not thread safe). - (Ilia, wharmby at uk dot ibm dot com) -- Fixed bug #39751 (putenv crash on Windows). (KevinJohnHoffman at gmail.com) -- Fixed bug #39732 (oci_bind_array_by_name doesn't work on Solaris 64bit). - (Tony) -- Fixed bug #39724 (Broken build due to spl/filter usage of pcre extension). - (Tony, Ilia) -- Fixed bug #39718 (possible crash if assert.callback is set in ini). (Ilia) -- Fixed bug #39702 (php crashes in the allocator on linux-m68k). (Dmitry) -- Fixed bug #39685 (iconv() - undefined function). (Hannes) -- Fixed bug #39673 (file_get_contents causes bus error on certain offsets). - (Tony) -- Fixed bug #39663 (Memory leak in pg_get_notify() and a possible memory - corruption on Windows in pgsql and pdo_pgsql extensions). - (Ilia, matteo at beccati dot com) -- Fixed bug #39662 (Segfault when calling asXML() of a cloned - SimpleXMLElement). (Rob, Tony) -- Fixed bug #39656 (crash when calling fetch() on a PDO statment object after - closeCursor()). (Ilia, Tony) -- Fixed bug #39653 (ext/dba doesn't check for db-4.5 and db-4.4 when db4 - support is enabled). (Tony) -- Fixed bug #39652 (Wrong negative results from memory_get_usage()). (Dmitry) -- Fixed bug #39648 (Implementation of PHP functions chown() and chgrp() are - not thread safe). (Ilia, wharmby at uk dot ibm dot com) -- Fixed bug #39640 (Segfault with "Allowed memory size exhausted"). (Dmitry) -- Fixed bug #39625 (Apache crashes on importStylesheet call). (Rob) -- Fixed bug #39623 (thread safety fixes on *nix for putenv() & mime_magic). - (Ilia, wharmby at uk dot ibm dot com) -- Fixed bug #39621 (str_replace() is not binary safe on strings with equal - length). (Tony) -- Fixed bug #39613 (Possible segfault in imap initialization due to missing - module dependency). (wharmby at uk dot ibm dot com, Tony) -- Fixed bug #39606 (Use of com.typelib_file in PHP.ini STILL causes A/V). (Rob) -- Fixed bug #39602 (Invalid session.save_handler crashes PHP). (Dmitry) -- Fixed bug #39596 (Creating Variant of type VT_ARRAY). (Rob) -- Fixed bug #39583 (ftp_put() does not change transfer mode to ASCII). (Tony) -- Fixed bug #39576 (array_walk() doesn't separate user data zval). (Tony) -- Fixed bug #39575 (move_uploaded_file() no longer working (safe mode - related)). (Tony) -- Fixed bug #39571 (timeout ssl:// connections). (Ilia) -- Fixed bug #39564 (PDO::errorInfo() returns inconsistent information when - sqlite3_step() fails). (Tony) -- Fixed bug #39548 (ZMSG_LOG_SCRIPT_NAME not routed to OutputDebugString() - on Windows). (Dmitry) -- Fixed bug #39538 (fgetcsv can't handle starting newlines and trailing odd - number of backslashes). (David Soria Parra, Pierre) -- Fixed bug #39534 (Error in maths to calculate of - ZEND_MM_ALIGNED_MIN_HEADER_SIZE). (wharmby at uk dot ibm dot com, Dmitry) -- Fixed bug #39527 (Failure to retrieve results when multiple unbuffered, - prepared statements are used in pdo_mysql). (Ilia) -- Fixed bug #39508 (imagefill crashes with small images 3 pixels or less). - (Pierre) -- Fixed bug #39506 (Archive corrupt with ZipArchive::addFile method). (Pierre) -- Fixed bug #39504 (xmlwriter_write_dtd_entity() creates Attlist tag, not - entity). (Hannes) -- Fixed bug #39483 (Problem with handling of \ char in prepared statements). - (Ilia, suhachov at gmail dot com) -- Fixed bug #39458 (ftp_nlist() returns false on empty dirs). (Nuno) -- Fixed bug #39454 (Returning a SOAP array segfaults PHP). (Dmitry) -- Fixed bug #39450 (getenv() fills other super-globals). (Ilia, Tony) -- Fixed bug #39449 (Overloaded array properties do not work correctly). - (Dmitry) -- Fixed bug #39445 (Calling debug_backtrace() in the __toString() - function produces a crash). (Dmitry) -- Fixed bug #39438 (Fatal error: Out of memory). (Dmitry) -- Fixed bug #39435 ('foo' instanceof bar gives invalid opcode error). (Sara) -- Fixed bug #39414 (Syntax error while compiling with Sun Workshop Complier). - (Johannes) -- Fixed bug #39398 (Booleans are not automatically translated to integers). - (Ilia) -- Fixed bug #39394 (Missing check for older variants of openssl). (Ilia) -- Fixed bug #39367 (clearstatcache() doesn't clear realpath cache). - (j at pureftpd dot org, Dmitry) -- Fixed bug #39366 (imagerotate does not use alpha with angle > 45 degrees) - (Pierre) -- Fixed bug #39364 (Removed warning on empty haystack inside mb_strstr()). - (Ilia) -- Fixed bug #39362 (Added an option to imap_open/imap_reopen to control the - number of connection retries). (Ilia) -- Fixed bugs #39361 & #39400 (mbstring function overloading problem). (Seiji) -- Fixed bug #39354 (Allow building of curl extension against libcurl - 7.16.0). (Ilia) -- Fixed bug #39350 (crash with implode("\n", array(false))). (Ilia) -- Fixed bug #39344 (Unnecessary calls to OnModify callback routine for - an extension INI directive). (wharmby at uk dot ibm dot com, Dmitry) -- Fixed bug #39320 (ZEND_HASH_APPLY_STOP causes deletion). (Marcus) -- Fixed bug #39313 (spl_autoload triggers Fatal error). (Marcus) -- Fixed bug #39300 (make install fails if wget is not available). (Tony) -- Fixed bug #39297 (Memory corruption because of indirect modification of - overloaded array). (Dmitry) -- Fixed bug #39286 (misleading error message when invalid dimensions are - given) (Pierre) -- Fixed bug #39273 (imagecopyresized may ignore alpha channel) (Pierre) -- Fixed bug #39265 (Fixed path handling inside mod_files.sh). - (michal dot taborsky at gmail dot com, Ilia) -- Fixed bug #39217 (serialNumber might be -1 when the value is too large). - (Pierre, Tony) -- Fixed bug #39215 (Inappropriate close of stdin/stdout/stderr). (Wez, Ilia) -- Fixed bug #39201 (Possible crash in Apache 2 with 413 ErrorHandler). (Ilia) -- Fixed bug #39151 (Parse error in recursiveiteratoriterator.php). (Marcus) -- Fixed bug #39121 (Incorrect return array handling in non-wsdl soap client). - (Dmitry) -- Fixed bug #39090 (DirectoryFilterDots doxygen docs and example is wrong). - (Marcus) -- Fixed bug #38852 (XML-RPC Breaks iconv). (Hannes) -- Fixed bug #38770 (unpack() broken with longs on 64 bit machines). - (Ilia, David Soria Parra). -- Fixed bug #38698 (for some keys cdbmake creates corrupted db and cdb can't - read valid db). (Marcus) -- Fixed bug #38680 (Added missing handling of basic types in json_decode). - (Ilia) -- Fixed bug #38604 (Fixed request time leak inside foreach() when iterating - through virtual properties). (Dmitry) -- Fixed bug #38602 (header( "HTTP/1.0 ..." ) does not change proto version). - (Ilia) -- Fixed bug #38542 (proc_get_status() returns wrong PID on windows). (Nuno) -- Fixed bug #38536 (SOAP returns an array of values instead of an object). - (Dmitry) -- Fixed bug #38456 (Apache2 segfaults when virtual() is called in .php - ErrorDocument). (Ilia) -- Fixed bug #38325 (spl_autoload_register() gives wrong line for "class not - found"). (Ilia) -- Fixed bug #38319 (Remove bogus warnings from persistent PDO connections). - (Ilia) -- Fixed bug #38274 (Memlimit fatal error sent to "wrong" stderr when using - fastcgi). (Dmitry) -- Fixed bug #38252 (Incorrect PDO error message on invalid default fetch - mode). (Ilia) -- Fixed bug #37927 (Prevent trap when COM extension processes argument of - type VT_DISPATCH|VT_REF) (Andy) -- Fixed bug #37773 (iconv_substr() gives "Unknown error" when string - length = 1"). (Ilia) -- Fixed bug #37627 (session save_path check checks the parent directory). - (Ilia) -- Fixed bug #37619 (proc_open() closes stdin on fork() failure). - (jdolecek at NetBSD dot org, Nuno) -- Fixed bug #37588 (COM Property propputref converts to PHP function - and can't be accesed). (Rob) -- Fixed bug #36975 (natcasesort() causes array_pop() to misbehave). - (Hannes) -- Fixed bug #36812 (pg_execute() modifies input array). (Ilia) -- Fixed bug #36798 (Error parsing named parameters with queries containing - high-ascii chars). (Ilia) -- Fixed bug #36644 (possible crash in variant_date_from_timestamp()). (Ilia) -- Fixed bug #36427 (proc_open() / proc_close() leak handles on windows). - (jdolecek at NetBSD dot org, Nuno) -- Fixed bug #36392 (wrong number of decimal digits with %e specifier in - sprintf). (Matt,Ilia) -- Fixed bug #36214 (__get method works properly only when conditional - operator is used). (Dmitry) -- Fixed bug #35634 (Erroneous "Class declarations may not be nested" - error raised). (Carl P. Corliss, Dmitry) -- Fixed bug #35106 (nested foreach fails when array variable has a - reference). (Dmitry) -- Fixed bug #34564 (COM extension not returning modified "out" argument) (Andy) -- Fixed bug #33734 (Something strange with COM Object). (Rob) -- Fixed bug #33386 (ScriptControl only sees last function of class). (Rob) -- Fixed bug #33282 (Re-assignment by reference does not clear the is_ref - flag) (Ilia, Dmitry, Matt Wilmas) -- Fixed bug #30074 (apparent symbol table error with - extract($blah, EXTR_REFS)) (Brian) -- Fixed bug #29840 (is_executable() does not honor safe_mode_exec_dir - setting). (Ilia) -- Fixed PECL bug #7295 (ORA-01405: fetched column value is NULL on LOB - fields). (Tony) - -02 Nov 2006, PHP 5.2.0 -- Updated bundled OpenSSL to version 0.9.8d in the Windows distro. (Edin) -- Updated Postgresql client libraries to 8.1.4 in the Windows distro. (Edin) -- Updated PCRE to version 6.7. (Ilia) -- Updated libsqlite in ext/pdo_sqlite to 3.3.7. (Ilia) -- Updated bundled MySQL client library to version 5.0.22 in the Windows - distribution. (Edin) -- Updated timezonedb to version 2006.7. (Derick) - -- Added ability to make SOAP call userspace PHP<->XML converters. (Dmitry) -- Added support for character sets in pg_escape_string() for PostgreSQL 8.1.4 - and higher. (Ilia) -- Added support for character sets in PDO quote() method for PostgreSQL 8.1.4 - and higher. (Ilia) -- Added DSA key generation support to openssl_pkey_new(), FR #38731 (marci - at balabit dot hu, Tony) -- Added SoapServer::setObject() method (it is a simplified version of - SoapServer::setClass() method). (Dmitry) -- Added support for hexadecimal entity in imagettftext() for the bundled GD. - (Pierre) -- Added support for httpOnly flag for session extension and cookie setting - functions. (Scott MacVicar, Ilia) -- Added version specific registry keys to allow different configurations for - different php version. (Richard, Dmitry) -- Added "PHPINIDir" Apache directive to apache and apache_hooks SAPIs. - (Dmitry) -- Added an optional boolean parameter to memory_get_usage() and - memory_get_peak_usage() to get memory size allocated by emalloc() or real - size of memory allocated from system. (Dmitry) -- Added Zip Archive extension. (Pierre) -- Added RFC1867 fileupload processing hook. (Stefan E.) -- Added JSON and Filter extensions. (Derick, Rasmus) -- Added error messages to disk_free_space() and disk_total_space() functions. - FR #37971 (Tony) -- Added PATHINFO_FILENAME option to pathinfo() to get the filename. - (Toby S. and Christian S.) -- Added array_fill_keys() function. (Marcus, Matt Wilmas) -- Added posix_initgroups() function. (Ilia) -- Added an optional parameter to parse_url() to allow retrieval of distinct - URL components. (Ilia) -- Added optional parameter to http_build_query() to allow specification of - string separator. (Ilia) -- Added image_type_to_extension() function. (Hannes, Ilia) -- Added allow_url_include ini directive to complement allow_url_fopen. (Rasmus) -- Added automatic module globals management. (Dmitry) -- Added RFC2397 (data: stream) support. (Marcus) -- Added new error mode E_RECOVERABLE_ERROR. (Derick, Marcus, Tony) -- Added support for getenv() input filtering. (Rasmus) -- Added support for constructors in interfaces to force constructor signature - checks in implementations. (Marcus) -- Added memory_get_peak_usage() function for retrieving peak memory usage of - a PHP script. (Ilia) -- Added pg_field_table() function. (Edin) -- Added SimpleXMLElement::saveXML() as an alias for SimpleXMLElement::asXML(). - (Hannes) -- Added DOMNode::getNodePath() for getting an XPath for a node. (Christian) -- Added gmp_nextprime() function. (ants dot aasma at gmail dot com, Tony) -- Added error_get_last() function. (Mike) - -- Removed current working directory from the php.ini search path for CLI and - re-added it for other SAPIs (restore to pre 5.1.x behavior). (Edin) -- Moved extensions to PECL: - . ext/filepro (Derick, Tony) - . ext/hwapi (Derick, Tony) -- Disabled CURLOPT_FOLLOWLOCATION in curl when open_basedir or - safe_mode are enabled. (Stefan E., Ilia) - -- Increased default memory limit to 16 megabytes to accommodate for a more - accurate memory utilization measurement. -- In addition to path to php.ini, PHPRC now may specify full file name. - (Dmitry) - -- Optimized array/HashTable copying. (Matt Wilmas, Dmitry) -- Optimized zend_try/zend_catch macros by eliminating memcpy(3). (Dmitry) -- Optimized require_once() and include_once() by eliminating fopen(3) on - second usage. (Dmitry) -- Optimized request shutdown sequence. Restoring ini directives now iterates - only over modified directives instead of all. (Dmitry) - -- Changed priority of PHPRC environment variable on win32 to be higher then - value from registry. (Dmitry) -- Changed __toString() to be called wherever applicable. (Marcus) -- Changed E_ALL error reporting mode to include E_RECOVERABLE_ERROR. (Marcus) -- Changed realpath cache to be disabled when "open_basedir" or "safe_mode" - are enabled on per-request basis. (Ilia) - -- Improved SNMP extension: (Jani) - . Renamed snmp_set_oid_numeric_print() to snmp_set_oid_output_format(). - . Added 2 new constants: SNMP_OID_OUTPUT_FULL and SNMP_OID_OUTPUT_NUMERIC - . Fixed bug #37564 (AES privacy encryption not possible due to net-snmp 5.2 - compatibility issue). (Patch: scott dot moynes+php at gmail dot com) -- Improved OpenSSL extension: (Pierre) - . Added support for all supported algorithms in openssl_verify - . Added openssl_pkey_get_details, returns the details of a key - . Added x509 v3 extensions support - . Added openssl_csr_get_subject() and openssl_csr_get_public_key() - . Added 3 new constants OPENSSL_VERSION_TEXT and OPENSSL_VERSION_NUMBER and - OPENSSL_KEYTYPE_EC -- Improved the Zend memory manager: (Dmitry) - . Removed unnecessary "--disable-zend-memory-manager" configure option. - . Added "--enable-malloc-mm" configure option which is enabled by default in - debug builds to allow using internal and external memory debuggers. - . Allow tweaking the memory manager with ZEND_MM_MEM_TYPE and ZEND_MM_SEG_SIZE - environment variables. - . For more information: Zend/README.ZEND_MM -- Improved safe_mode check for the error_log() function. (Ilia) -- Improved the error reporting in SOAP extension on request failure. (Ilia) -- Improved crypt() on win32 to be about 10 times faster and to have friendlier - license. (Frank, Dmitry) -- Improved performance of the implode() function on associated arrays. (Ilia) -- Improved performance of str_replace() when doing 1 char to 1 char or 1 char - to many chars replacement. (Ilia) -- Improved apache2filter SAPI: - . Allowed PHP to be an arbitrary filter in the chain and read the script from - the Apache stream. (John) - . Added support for apache2filter in the Windows build including binary - support for both Apache 2.0.x (php5apache2_filter.dll) and Apache 2.2.x - (php5apache2_2_filter.dll). (Edin) -- Improved apache2handler SAPI: - . Changed ap_set_content_type() to be called only once. (Mike) - . Added support for Apache 2.2 handler in the Windows distribution. (Edin) -- Improved FastCGI SAPI: (Dmitry) - . Removed source compatibility with libfcgi. - . Optimized access to FastCGI environment variables by using HashTable - instead of linear search. - . Allowed PHP_FCGI_MAX_REQUESTS=0 that assumes no limit. - . Allowed PHP_FCGI_CHILDREN=0 that assumes no worker children. (FastCGI - requests are handled by main process itself) -- Improved CURL: - . Added control character checks for "open_basedir" and "safe_mode" checks. - (Ilia) - . Added implementation of curl_multi_info_read(). (Brian) -- Improved PCRE: (Andrei) - . Added run-time configurable backtracking/recursion limits. - . Added preg_last_error(). (Andrei) -- Improved PDO: - . Added new attribute ATTR_DEFAULT_FETCH_MODE. (Pierre) - . Added FETCH_PROPS_LATE. (Marcus) -- Improved SPL: (Marcus) - . Made most iterator code exception safe. - . Added RegExIterator and RecursiveRegExIterator. - . Added full caching support and ArrayAccess to CachingIterator. - . Added array functions to ArrayObject/ArrayIterator and made them faster. - . Added support for reading csv and skipping empty lines in SplFileObject. - . Added CachingIterator::TOSTRING_USE_INNER, calls inner iterator __toString. - . Added ability to set the CSV separator per SplFileObject. -- Improved xmlReader: (Rob) - . Added readInnerXml(), xmlReader::setSchema(). - . Added readInnerXML(), readOuterXML(), readString(), setSchema(). (2.6.20+) - . Changed to passing libxml options when loading reader. - -- Fixed invalid read in imagecreatefrompng when an empty file is given - (Pierre, Tony) -- Fixed infinite loop when a wrong color index is given to imagefill (Pierre) -- Fixed mess with CGI/CLI -d option (now it works with cgi; constants are - working exactly like in php.ini; with FastCGI -d affects all requests). - (Dmitry) -- Fixed missing open_basedir check inside chdir() function. (Ilia) -- Fixed overflow on 64bit systems in str_repeat() and wordwrap(). (Stefan E.) -- Fixed XSLTProcessor::importStylesheet() to return TRUE on success - (Christian) -- Fixed leaks in openssl_csr_sign and openssl_csr_new (Pierre) -- Fixed phpinfo() cutoff of variables at \0. (Ilia) -- Fixed a bug in the filter extension that prevented magic_quotes_gpc from - being applied when RAW filter is used. (Ilia) -- Fixed memory leaks in openssl streams context options. (Pierre) -- Fixed handling of extremely long paths inside tempnam() function. (Ilia) -- Fixed bug #39721 (Runtime inheritance causes data corruption). (Dmitry) -- Fixed bug #39304 (Segmentation fault with list unpacking of string offset). - (Dmitry) -- Fixed bug #39192 (Not including nsapi.h properly with SJSWS 7). This will - make PHP 5.2 compatible to new Sun Webserver. (Uwe) -- Fixed bug #39140 (Uncaught exception may cause crash). (Dmitry) -- Fixed bug #39125 (Memleak when reflecting non-existing class/method). (Tony) -- Fixed bug #39067 (getDeclaringClass() and private properties). (Tony) -- Fixed bug #39039 (SSL: fatal protocol error when fetching HTTPS from servers - running Google web server). (Ilia) -- Fixed bug #39035 (Compatibility issue between DOM and - zend.ze1_compatibility_mode). (Rob) -- Fixed bug #39034 (curl_exec() with return transfer returns TRUE on empty - files). (Ilia) -- Fixed bug #39032 (strcspn() stops on null character). (Tony) -- Fixed bug #39020 (PHP in FastCGI server mode crashes). (Dmitry) -- Fixed bug #39017 (foreach(($obj = new myClass) as $v); echo $obj; - segfaults). (Dmitry) -- Fixed bug #39004 (Fixed generation of config.nice with autoconf 2.60). (Ilia) -- Fixed bug #39003 (__autoload() is called for type hinting). (Dmitry, Tony) -- Fixed bug #39001 (ReflectionProperty returns incorrect declaring class for - protected properties). (Tony) -- Fixed bug #38996 (PDO_MYSQL doesn't check connections for liveness). (Tony) -- Fixed bug #38993 (Fixed safe_mode/open_basedir checks for session.save_path, - allowing them to account for extra parameters). (Ilia) -- Fixed bug #38989 (Absolute path with slash at beginning doesn't work on win). - (Dmitry) -- Fixed bug #38985 (Can't cast COM objects). (Wez) -- Fixed bug #38981 (using FTP URLs in get_headers() causes crash). (Tony) -- Fixed bug #38963 (Fixed a possible open_basedir bypass in tempnam()). (Ilia) -- Fixed bug #38961 (metaphone() results in segmentation fault on NetBSD). - (Tony) -- Fixed bug #38949 (Cannot get xmlns value attribute). (Rob) -- Fixed bug #38942 (Double old-style-ctor inheritance). (Dmitry) -- Fixed bug #38941 (imap extension does not compile against new version of the - imap library). (Ilia) -- Fixed bug #38934 (move_uploaded_file() cannot read uploaded file outside of - open_basedir). (Ilia) -- Fixed bug #38904 (apache2filter changes cwd to /). (Ilia, Hannes) -- Fixed bug #38891 (get_headers() do not work with curl-wrappers). (Ilia) -- Fixed bug #38882 (ldap_connect causes segfault with newer versions of - OpenLDAP). (Tony) -- Fixed bug #38859 (parse_url() fails if passing '@' in passwd). (Tony) -- Fixed bug #38850 (lookupNamespaceURI doesn't return default namespace). (Rob) -- Fixed bug #38844 (curl_easy_strerror() is defined only since cURL 7.12.0). - (Tony) -- Fixed bug #38813 (DOMEntityReference->__construct crashes when called - explicitly). (Rob) -- Fixed bug #38808 ("maybe ref" issue for current() and others). (Dmitry) -- Fixed bug #38779 (engine crashes when require()'ing file with syntax error - through userspace stream wrapper). (Tony, Dmitry) -- Fixed bug #38772 (inconsistent overriding of methods in different visibility - contexts). (Dmitry) -- Fixed bug #38759 (PDO sqlite2 empty query causes segfault). (Tony) -- Fixed bug #38721 (Invalid memory read in date_parse()). (Tony, Derick) -- Fixed bug #38700 (SoapClient::__getTypes never returns). (Dmitry) -- Fixed bug #38693 (curl_multi_add_handle() set curl handle to null). (Ilia) -- Fixed bug #38687 (sockaddr local storage insufficient for all sock families). - (Sara) -- Fixed bug #38661 (mixed-case URL breaks url-wrappers). (Ilia) -- Fixed bug #38653 (memory leak in ReflectionClass::getConstant()). (Tony) -- Fixed bug #38649 (uninit'd optional arg in stream_socket_sendto()). (Sara) -- Fixed bug #38637 (curl_copy_handle() fails to fully copy the cURL handle). - (Tony, Ilia) -- Fixed bug #38624 (Strange warning when incrementing an object property and - exception is thrown from __get method). (Tony) -- Fixed bug #38623 (leaks in a tricky code with switch() and exceptions). - (Dmitry) -- Fixed bug #38579 (include_once() may include the same file twice). (Dmitry) -- Fixed bug #38574 (missing curl constants and improper constant detection). - (Ilia) -- Fixed bug #38543 (shutdown_executor() may segfault when memory_limit is too - low). (Dmitry) -- Fixed bug #38535 (memory corruption in pdo_pgsql driver on error retrieval - inside a failed query executed via query() method). (Ilia) -- Fixed bug #38534 (segfault when calling setlocale() in userspace session - handler). (Tony) -- Fixed bug #38524 (strptime() does not initialize the internal date storage - structure). (Ilia) -- Fixed bug #38511, #38473, #38263 (Fixed session extension request shutdown - order to ensure it is shutdown before the extensions it may depend on). - (Ilia) -- Fixed bug #38488 (Access to "php://stdin" and family crashes PHP on win32). - (Dmitry) -- Fixed bug #38474 (getAttribute select attribute by order, even when - prefixed). (Rob) -- Fixed bug #38467 (--enable-versioning causes make fail on OS X). (Tony) -- Fixed bug #38465 (ReflectionParameter fails if default value is an access - to self::). (Johannes) -- Fixed bug #38464 (array_count_values() mishandles numeric strings). - (Matt Wilmas, Ilia) -- Fixed bug #38461 (setting private attribute with __set() produces - segfault). (Tony) -- Fixed bug #38458, PECL bug #8944, PECL bug #7775 (error retrieving columns - after long/text columns with PDO_ODBC). (Wez) -- Fixed bug #38454 (warning upon disabling handler via - xml_set_element_handler). (dtorop933 at gmail dot com, Rob) -- Fixed bug #38451 (PDO_MYSQL doesn't compile on Solaris). (Tony) -- Fixed bug #38450 (constructor is not called for classes used in userspace - stream wrappers). (Tony) -- Fixed bug #38438 (DOMNodeList->item(0) segfault on empty NodeList). (Ilia) -- Fixed bug #38431 (xmlrpc_get_type() crashes PHP on objects). (Tony) -- Fixed bug #38427 (unicode causes xml_parser to misbehave). (Rob) -- Fixed bug #38424 (Different attribute assignment if new or existing). (Rob) -- Fixed bug #38400 (Use of com.typelib_file may cause a crash). (Ilia) -- Fixed bug #38394 (PDO fails to recover from failed prepared statement - execution). (Ilia) -- Fixed bug #38377 (session_destroy() gives warning after - session_regenerate_id()). (Ilia) -- Implemented #38357 (dbase_open can't open DBase 3 dbf file). - (rodrigo at fabricadeideias dot com, Mike) -- Fixed bug #38354 (Unwanted reformatting of XML when using AsXML). (Christian) -- Fixed bug #38347 (Segmentation fault when using foreach with an unknown/empty - SimpleXMLElement). (Tony) -- Fixed bug #38322 (reading past array in sscanf() leads to arbitrary code - execution). (Tony) -- Fixed bug #38315 (Constructing in the destructor causes weird behavior). - (Dmitry) -- Fixed bug #38303 (spl_autoload_register() suppress all errors silently). - (Ilia) -- Fixed bug #38290 (configure script ignores --without-cdb,inifile,flatfile). - (Marcus) -- Fixed bug #38289 (segfault in session_decode() when _SESSION is NULL). - (Tony) -- Fixed bug #38287 (static variables mess up global vars). (Dmitry) -- Fixed bug #38278 (session_cache_expire()'s value does not match phpinfo's - session.cache_expire). (Tony) -- Fixed bug #38276 (file_exists() works incorrectly with long filenames - on Windows). (Ilia, Tony) -- Fixed bug #38269 (fopen wrapper doesn't fail on invalid hostname with - curlwrappers enabled). (Tony) -- Fixed bug #38265 (heap corruption). (Dmitry) -- Fixed bug #38261 (openssl_x509_parse() leaks with invalid cert) (Pierre) -- Fixed bug #38255 (openssl possible leaks while passing keys) (Pierre) -- Fixed bug #38253 (PDO produces segfault with default fetch mode). (Tony) -- Fixed bug #38251 (socket_select() and invalid arguments). (Tony) -- Fixed bug #38236 (Binary data gets corrupted on multipart/formdata POST). - (Ilia) -- Fixed bug #38234 (Exception in __clone makes memory leak). (Dmitry, Nuno) -- Fixed bug #38229 (strtotime() does not parse YYYY-MM format). (Ilia) -- Fixed bug #38224 (session extension can't handle broken cookies). (Ilia) -- Fixed bug #38220 (Crash on some object operations). (Dmitry) -- Fixed bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too - much memory). (Tony) -- Fixed bug #38214 (gif interlace output cannot work). (Pierre) -- Fixed bug #38213, #37611, #37571 (wddx encoding fails to handle certain - characters). (Ilia) -- Fixed bug #38212 (Segfault on invalid imagecreatefromgd2part() parameters). - (Pierre) -- Fixed bug #38211 (variable name and cookie name match breaks script - execution). (Dmitry) -- Fixed bug #38199 (fclose() unable to close STDOUT and STDERR). (Tony) -- Fixed bug #38198 (possible crash when COM reports an exception). (Ilia) -- Fixed bug #38194 (ReflectionClass::isSubclassOf() returns TRUE for the - class itself). (Ilia) -- Fixed bug #38183 (disable_classes=Foobar causes disabled class to be - called Foo). (Jani) -- Fixed bug #38179 (imagecopy from a palette to a truecolor image loose alpha - channel) (Pierre) -- Fixed bug #38173 (Freeing nested cursors causes OCI8 to segfault). (Tony) -- Fixed bug #38168 (Crash in pdo_pgsql on missing bound parameters). (Ilia) -- Fixed bug #38161 (oci_bind_by_name() returns garbage when Oracle didn't set - the variable). (Tony) -- Fixed bug #38146 (Cannot use array returned from foo::__get('bar') in write - context). (Dmitry) -- Fixed bug #38132 (ReflectionClass::getStaticProperties() retains \0 in key - names). (Ilia) -- Fixed bug #38125 (undefined reference to spl_dual_it_free_storage). (Marcus) -- Fixed bug #38112 (corrupted gif segfaults) (Pierre) -- Fixed bug #38096 (large timeout values ignored on 32bit machines in - stream_socket_accept() and stream_socket_client()). (Ilia) -- Fixed bug #38086 (stream_copy_to_stream() returns 0 when maxlen is bigger - than the actual length). (Tony) -- Fixed bug #38072 (boolean arg for mysqli_autocommit() is always true on - Solaris). (Tony) -- Fixed bug #38067 (Parameters are not decoded from utf-8 when using encoding - option). (Dmitry) -- Fixed bug #38064 (ignored constructor visibility). (Marcus) -- Fixed bug #38055 (Wrong interpretation of boolean parameters). (Dmitry) -- Fixed bug #38047 ("file" and "line" sometimes not set in backtrace from - inside error handler). (Dmitry) -- Fixed bug #38019 (segfault extending mysqli class). (Dmitry) -- Fixed bug #38005 (SoapFault faultstring doesn't follow encoding rules). - (Dmitry) -- Fixed bug #38004 (Parameters in SoapServer are decoded twice). (Dmitry) -- Fixed bug #38003 (in classes inherited from MySQLi it's possible to call - private constructors from invalid context). (Tony) -- Fixed bug #37987 (invalid return of file_exists() in safe mode). (Ilia) -- Fixed bug #37947 (zend_ptr_stack reallocation problem). (Dmitry) -- Fixed bug #37945 (pathinfo() cannot handle argument with special characters - like German "Umlaut"). (Mike) -- Fixed bug #37931 (possible crash in OCI8 after database restart - when using persistent connections). (Tony) -- Fixed bug #37923 (Display constant value in reflection::export). (Johannes) -- Fixed bug #37920 (compilation problems on z/OS). (Tony) -- Fixed bug #37870 (pgo_pgsql tries to de-allocate unused statements). - (Ilia, ce at netage dot bg) -- Fixed bug #37864 (file_get_contents() leaks on empty file). (Hannes) -- Fixed bug #37862 (Integer pointer comparison to numeric value). - (bugs-php at thewrittenword dot com) -- Fixed bug #37846 (wordwrap() wraps incorrectly). (ddk at krasn dot ru, Tony) -- Fixed bug #37816 (ReflectionProperty does not throw exception when accessing - protected attribute). (Marcus) -- Fixed bug #37811 (define not using toString on objects). (Marcus) -- Fixed bug #37807 (segmentation fault during SOAP schema import). (Tony) -- Fixed bug #37806 (weird behavior of object type and comparison). (Marcus) -- Fixed bug #37780 (memory leak trying to execute a non existing file (CLI)). - (Mike) -- Fixed bug #37779 (empty include_path leads to search for files inside /). - (jr at terragate dot net, Ilia) -- Fixed bug #37747 (strtotime segfaults when given "nextyear"). (Derick) -- Fixed bug #37720 (merge_php_config scrambles values). - (Mike, pumuckel at metropolis dot de) -- Fixed bug #37709 (Possible crash in PDO::errorCode()). (Ilia) -- Fixed bug #37707 (clone without assigning leaks memory). (Ilia, Nuno, Dmitri) -- Fixed bug #37705 (Semaphore constants not available). (Ilia) -- Fixed bug #37671 (MySQLi extension fails to recognize BIT column). (Ilia) -- Fixed bug #37667 (Object is not added into array returned by __get). (Marcus) -- Fixed bug #37635 (parameter of pcntl signal handler is trashed). (Mike) -- Fixed bug #37632 (Protected method access problem). (Marcus) -- Fixed bug #37630 (MySQL extensions should link against thread safe client - libs if built with ZTS). (Mike) -- Fixed bug #37620 (mysqli_ssl_set validation is inappropriate). (Georg) -- Fixed bug #37616 (DATE_RFC822 does not product RFC 822 dates). - (Hannes Magnusson, Derick) -- Fixed bug #37614 (Class name lowercased in error message). (Johannes) -- Fixed bug #37587 (var without attribute causes segfault). (Marcus) -- Fixed bug #37586 (Bumped minimum PCRE version to 6.6, needed for recursion - limit support). (Ilia) -- Fixed bug #37581 (oci_bind_array_by_name clobbers input array when using - SQLT_AFC, AVC). (Tony) -- Fixed bug #37569 (WDDX incorrectly encodes high-ascii characters). (Ilia) -- Fixed bug #37565 (Using reflection::export with simplexml causing a crash). - (Marcus) -- Fixed bug #37564 (AES privacy encryption not possible due to net-snmp 5.2 - compatibility issue). (Jani, patch by scott dot moynes+php at gmail dot com) -- Fixed bug #37563 (array_key_exists performance is poor for &$array). (Ilia) -- Fixed bug #37558 (timeout functionality doesn't work after a second PHP - start-up on the same thread). (p dot desarnaud at wanadoo dot fr) -- Fixed bug #37531 (oci8 persistent connection corruption). (Tony) -- Fixed bug #37523 (namespaces added too late, leads to missing xsi:type - attributes. Incompatibility with libxml2-2.6.24). (Dmitry) -- Fixed bug #37514 (strtotime doesn't assume year correctly). (Derick) -- Fixed bug #37510 (session_regenerate_id changes session_id() even on - failure). (Hannes) -- Fixed bug #37505 (touch() truncates large files). (Ilia) -- Fixed bug #37499 (CLI segmentation faults during cleanup with sybase-ct - extension enabled). (Tony) -- Fixed bug #37496 (FastCGI output buffer overrun). (Piotr, Dmitry) -- Fixed bug #37487 (oci_fetch_array() array-type should always default to - OCI_BOTH). (Tony) -- Fixed bug #37457 (Crash when an exception is thrown in accept() method of - FilterIterator). (Marcus) -- Fixed bug #37456 (DOMElement->setAttribute() loops forever). (Rob) -- Fixed bug #37445 (Fixed crash in pdo_mysql resulting from premature object - destruction). (Ilia) -- Fixed bug #37428 (PHP crashes on windows if there are start-up errors and - event log is used for logging them). (Edin) -- Fixed bug #37418 (tidy module crashes on shutdown). (Tony) -- Fixed bug #37416 (iterator_to_array() hides exceptions thrown in rewind() - method). (Tony) -- Fixed bug #37413 (Rejected versions of flex that don't work). (Ilia) -- Fixed bug #37395 (recursive mkdir() fails to create nonexistent directories - in root dir). (Tony) -- Fixed bug #37394 (substr_compare() returns an error when offset equals - string length). (Ilia) -- Fixed bug #37392 (Unnecessary call to OCITransRollback() at the end of - request). (Tony) -- Fixed bug #37376 (fastcgi.c compile fail with gcc 2.95.4). (Ilia) -- Fixed bug #37368 (Incorrect timestamp returned for strtotime()). (Derick) -- Fixed bug #37363 (PDO_MYSQL does not build if no other mysql extension is - enabled). (Mike) -- Fixed bug #37348 (make PEAR install ignore open_basedir). (Ilia) -- Fixed bug #37341 ($_SERVER in included file is shortened to two entries, - if $_ENV gets used). (Dmitry) -- Fixed bug #37313 (sigemptyset() used without including ). - (jdolecek) -- Fixed bug #37306 (max_execution_time = max_input_time). (Dmitry) -- Fixed bug #37278 (SOAP not respecting uri in __soapCall). (Dmitry) -- Fixed bug #37265 (Added missing safe_mode & open_basedir checks to - imap_body()). (Ilia) -- Fixed bug #37262 (var_export() does not escape \0 character). (Ilia) -- Fixed bug #37256 (php-fastcgi doesn't handle connection abort). (Dmitry) -- Fixed bug #37244 (Added strict flag to base64_decode() that enforces - RFC3548 compliance). (Ilia) -- Fixed bug #37144 (PHP crashes trying to assign into property of dead object). - (Dmitry) -- Fixed bug #36949 (invalid internal mysqli objects dtor). (Mike) -- Implement #36732 (req/x509 extensions support for openssl_csr_new and - openssl_csr_sign) (ben at psc dot edu, Pierre) -- Fixed bug #36759 (Objects destructors are invoked in wrong order when script - is finished). (Dmitry) -- Fixed bug #36681 (pdo_pgsql driver incorrectly ignored some errors). - (Wez, Ilia) -- Fixed bug #36630 (umask not reset at the end of the request). (Ilia) -- Fixed bug #36515 (Unlinking buckets from non-existent brigades). (Sara) -- Fixed bug #35973 (Error ORA-24806 occurs when trying to fetch a NCLOB - field). (Tony) -- Fixed bug #35886 (file_get_contents() fails with some combinations of - offset & maxlen). (Nuno) -- Fixed bug #35512 (Lack of read permission on main script results in - E_WARNING rather then E_ERROR). (Ilia) -- Fixed bug #34180 (--with-curlwrappers causes PHP to disregard some HTTP - stream context options). (Mike) -- Fixed bug #34066 (recursive array_walk causes segfault). (Tony) -- Fixed bug #34065 (throw in foreach causes memory leaks). (Dmitry) -- Fixed bug #34005 (oci_password_change() fails). - (pholdaway at technocom-wireless dot com, Tony) -- Fixed bug #33895 (Missing math constants). (Hannes) -- Fixed bug #33770 (https:// or ftps:// do not work when --with-curlwrappers - is used and ssl certificate is not verifiable). (Ilia) -- Fixed bug #29538 (number_format and problem with 0). (Matt Wilmas) -- Implement #28382 (openssl_x509_parse() extensions support) (Pierre) -- Fixed PECL bug #9061 (oci8 might reuse wrong persistent connection). (Tony) -- Fixed PECL bug #8816 (issue in php_oci_statement_fetch with more than one - piecewise column) (jeff at badtz-maru dot com, Tony) -- Fixed PECL bug #8112 (OCI8 persistent connections misbehave when Apache - process times out). (Tony) -- Fixed PECL bug #7755 (error selecting DOUBLE fields with PDO_ODBC). - ("slaws", Wez) - - -04 May 2006, PHP 5.1.4 -- Added "capture_peer_cert" and "capture_peer_cert_chain" context options - for SSL streams. (Wez). -- Added PDO::PARAM_EVT_* family of constants. (Sara) -- Fixed possible crash in highlight_string(). (Dmitry) -- Fixed bug #37291 (FastCGI no longer works with isapi_fcgi.dll). (Dmitry) -- Fixed bug #37277 (cloning Dom Documents or Nodes does not work). (Rob) -- Fixed bug #37276 (problems with $_POST array). (Dmitry) -- Fixed bug #36632 (bad error reporting for pdo_odbc exec UPDATE). (Wez). -- Fixed bug #35552 (crash when pdo_odbc prepare fails). (Wez). - -28 Apr 2006, PHP 5.1.3 -- Updated bundled PCRE library to version 6.6. (Andrei) -- Moved extensions to PECL: - . ext/msession (Derick) -- Reimplemented FastCGI interface. (Dmitry) -- Improved SPL: (Marcus) - - Fixed issues with not/double calling of constructors of SPL iterators. - - Fixed issues with info-class/file-class in SPL directory handling classes. - - Fixed ArrayIterator::seek(). - - Added SimpleXMLIterator::count(). - - Dropped erroneous RecursiveDirectoryIterator::getSubPathInfo(). -- Improved SimpleXML: (Marcus, Rob) - . Added SimpleXMLElement::getName() to retrieve name of element. - . Added ability to create elements on the fly. - . Added addChild() method for element creation supporting namespaces. - . Added addAttribute() method for attribute creation supporting namespaces. - . Added ability to delete specific elements and attributes by offset. -- Improved Reflection API: (Marcus) - . Added ReflectionClass::newInstanceArgs($args). - . Added ability to analyze extension dependency. - . Added ReflectionFunction::isDeprecated() and constant IS_DEPRECATED. - . Added ReflectionParameter::getDeclaringClass(). - . Changed reflection constants to be prefixed with IS_. (Johannes) -- Improved cURL extension: (Ilia) - . Added curl_setopt_array() function that allows setting of multiple - options via an associated array. - . Added the ability to retrieve the request message sent to the server. -- Improved GD extension: (Pierre) - . Added a weak/tolerant mode to the JPEG loader. - . Added filtering mode option to imagepng() to allow reducing file size. - . Fixed imagecolorallocate() and imagecolorallocatelapha() to return FALSE - on error. -- Changed get_headers() to retrieve headers also from non-200 responses. - (Ilia) -- Changed get_headers() to use the default context. (Ilia) -- Added lchown() and lchgrp() to change user/group ownership of symlinks. - (Derick) -- Added support for exif date format in strtotime(). (Derick) -- Added a check for special characters in the session name. (Ilia) -- Added "consumed" stream filter. (Marcus) -- Added new mysqli constants for BIT and NEW_DECIMAL field types: - MYSQLI_TYPE_NEWDECIMAL and MYSQLI_TYPE_BIT. FR #36007. (Georg) -- Added imap_savebody() that allows message body to be written to a - file. (Mike) -- Added overflow checks to wordwrap() function. (Ilia) -- Added support for BINARY_DOUBLE and BINARY_FLOAT to PDO_OCI and OCI8 - (also fixes bug #36764). (Tony) -- Eliminated run-time constant fetching for TRUE, FALSE and NULL. (Dmitry) -- Removed the E_STRICT deprecation notice from "var". (Ilia) -- Fixed reading stream filters never notified about EOF. (Mike) -- Fixed tempnam() 2nd parameter to be checked against path components. (Ilia) -- Fixed a bug that would not fill in the fifth argument to preg_replace() - properly, if the variable was not declared previously. (Andrei) -- Fixed safe_mode check for source argument of the copy() function. (Ilia) -- Fixed mysqli bigint conversion under Windows (Georg) -- Fixed XSS inside phpinfo() with long inputs. (Ilia) -- Fixed Apache2 SAPIs header handler modifying header strings. (Mike) -- Fixed 'auto_globals_jit' to work together with 'register_argc_argv'. (Dmitry) -- Fixed offset/length parameter validation in substr_compare() function. (Ilia) -- Fixed debug_zval_dump() to support private and protected members. (Dmitry) -- Fixed SoapFault::getMessage(). (Dmitry) -- Fixed issue with iconv_mime_decode where the "encoding" would only allow - upper case specifiers. (Derick) -- Fixed tiger hash algorithm generating wrong results on big endian platforms. - (Mike) -- Fixed crash with DOMImplementation::createDocumentType("name:"). (Mike) -- Fixed bug #37205 (Serving binary content/images fails with "comm with server - aborted" FastCGI err). (Dmitry) -- Fixed bug #37192 (cc may complain about non-constant initializers in - hash_adler.c). (Mike) -- Fixed bug #37191 (chmod takes off sticky bit when safe_mode is On). (Tony) -- Fixed bug #37167 (PDO segfaults when throwing exception from the - fetch handler). (Tony) -- Fixed bug #37162 (wddx does not build as a shared extension). - (jdolecek at NetBSD dot org, Ilia) -- Fixed bug #37158 (fread behavior changes after calling - stream_wrapper_register). (Wez) -- Fixed bug #37138 (__autoload tries to load callback'ed self and parent). - (Dmitry) -- Fixed bug #37103 (libmbfl headers not installed). (Jani) -- Fixed bug #37062 (compile failure on ARM architecture). (Tony) -- Fixed bug #37061 (curl_exec() doesn't zero-terminate binary strings). (Tony) -- Fixed bug #37060 (Type of retval of Countable::count() is not checked). - (Johannes) -- Fixed bug #37059 (oci_bind_by_name() doesn't support RAW and LONG RAW - fields). (Tony) -- Fixed bug #37057 (xmlrpc_decode() may produce arrays with numeric strings, - which are unaccessible). (Tony) -- Fixed bug #37055 (incorrect reference counting for persistent OCI8 - connections). (Tony) -- Fixed bug #37054 (SoapClient Error Fetching http headers). (Dmitry) -- Fixed bug #37053 (html_errors with internal classes produces wrong links). - (Tony) -- Fixed bug #37046 (foreach breaks static scope). (Dmitry) -- Fixed bug #37045 (Fixed check for special chars for http redirects). (Ilia) -- Fixed bug #37017 (strtotime fails before 13:00:00 with some time zones - identifiers). (Derick) -- Fixed bug #37002 (Have to quote literals in INI when concatenating with - vars). (Dmitry)z -- Fixed bug #36988 (mktime freezes on long numbers). (Derick) -- Fixed bug #36981 (SplFileObject->fgets() ignores max_length). (Tony) -- Fixed bug #36957 (serialize() does not handle recursion). (Ilia) -- Fixed bug #36944 (strncmp & strncasecmp do not return false on negative - string length). (Tony) -- Fixed bug #36941 (ArrayIterator does not clone itself). (Marcus) -- Fixed bug #36934 (OCILob->read() doesn't move internal pointer when - reading 0's). (Tony) -- Fixed bug #36908 (wsdl default value overrides value in soap request). - (Dmitry) -- Fixed bug #36898 (__set() leaks in classes extending internal ones). - (Tony, Dmitry) -- Fixed bug #36886 (User filters can leak buckets in some situations). (Ilia) -- Fixed bug #36878 (error messages are printed even though an exception has - been thrown). (Tony) -- Fixed bug #36875 (is_*() functions do not account for open_basedir). (Ilia) -- Fixed bug #36872 (session_destroy() fails after call to - session_regenerate_id(true)). (Ilia) -- Fixed bug #36869 (memory leak in output buffering when using chunked - output). (Tony) -- Fixed bug #36859 (DOMElement crashes when calling __construct when - cloning). (Tony) -- Fixed bug #36857 (Added support for partial content fetching to the - HTTP streams wrapper). (Ilia) -- Fixed bug #36851 (Documentation and code discrepancies for NULL - data in oci_fetch_*() functions). (Tony) -- Fixed bug #36825 (Exceptions thrown in ArrayObject::offsetGet cause - segfault). (Tony) -- Fixed bug #36820 (Privileged connection with an Oracle password file - fails). (Tony) -- Fixed bug #36809 (__FILE__ behavior changed). (Dmitry) -- Fixed bug #36808 (syslog ident becomes garbage between requests). (Tony) -- Fixed bug #36802 (mysqli_set_charset() crash with a non-open connection). - (Ilia) -- Fixed bug #36756 (DOMDocument::removeChild corrupts node). (Rob) -- Fixed bug #36749 (SOAP: 'Error Fetching http body' when using HTTP Proxy). - (Dmitry) -- Fixed bug #36745 (No error message when load data local file isn't found). - (Georg) -- Fixed bug #36743 (In a class extending XMLReader array properties are not - writable). (Tony) -- Fixed bug #36727 (segfault in pdo_pgsql bindValue() when no parameters are - defined). (Tony) -- Fixed bug #36721 (The SoapServer is not able to send a header that it didn't - receive). (Dmitry) -- Fixed bug #36697 (Transparency is lost when using imagecreatetruecolor). - (Pierre) -- Fixed bug #36689 (Removed arbitrary limit on the length of syslog messages). - (Ilia) -- Fixed bug #36656 (http_build_query generates invalid URIs due to use of - square brackets). (Mike) -- Fixed bug #36638 (strtotime() returns false when 2nd argument < 1). (Derick) -- Fixed bug #36629 (SoapServer::handle() exits on SOAP faults). (Dmitry) -- Fixed bug #36625 (pg_trace() does not work). (iakio at mono-space dot net) -- Fixed bug #36614 (Segfault when using Soap). (Dmitry) -- Fixed bug #36611 (assignment to SimpleXML object attribute changes argument - type to string). (Tony) -- Fixed bug #36606 (pg_query_params() changes arguments type to string). (Tony) -- Fixed bug #36599 (DATE_W3C format constant incorrect). (Derick) -- Fixed bug #36575 (SOAP: Incorrect complex type instantiation with - hierarchies). (Dmitry) -- Fixed bug #36572 (Added PDO::MYSQL_ATTR_DIRECT_QUERY constant that should - be set when executing internal queries like "show master status" via MySQL). - (Ilia) -- Fixed bug #36568 (memory_limit setting on win32 has no effect). (Dmitry) -- Fixed bug #36513 (comment will be outputted in last line). (Dmitry) -- Fixed bug #36510 (strtotime() fails to parse date strings with tabs). - (Ilia, Derick) -- Fixed bug #36459 (Incorrect adding PHPSESSID to links, which contains \r\n). - (Ilia) -- Fixed bug #36458 (sleep() accepts negative values). (Ilia) -- Fixed bug #36436 (DBA problem with Berkeley DB4). (Marcus) -- Fixed bug #36434 (Improper resolution of declaring class name of an - inherited property). (Ilia) -- Fixed bug #36420 (segfault when access result->num_rows after calling - result->close()). (Ilia,Tony) -- Fixed bug #36403 (oci_execute() no longer supports OCI_DESCRIBE_ONLY). (Tony) -- Fixed bug #36400 (Custom 5xx error does not return correct HTTP response error - code). (Tony) -- Fixed bug #36396 (strtotime() fails to parse dates in dd-mm-yyyy format). - (Derick) -- Fixed bug #36388 (ext/soap crashes when throwing exception and session - persistence). (David) -- Fixed bug #36382 (PDO/PgSQL's getColumnMeta() crashes). (Derick) -- Fixed bug #36359 (splFileObject::fwrite() doesn't write when no data - length specified). (Tony) -- Fixed bug #36351 (parse_url() does not parse numeric paths properly). (Ilia) -- Fixed bug #36345 (PDO/MySQL problem loading BLOB over 1MB). (Ilia) -- Fixed bug #36337 (ReflectionProperty fails to return correct visibility). - (Ilia) -- Fixed bug #36334 (Added missing documentation about realpath cache INI - settings). (Ilia) -- Fixed bug #36308 (ReflectionProperty::getDocComment() does not reflect - extended class commentary). (Ilia) -- Fixed bug #36306 (crc32() differ on 32-bit and 64-bit platforms) - (anight@eyelinkmedia dot com, Pierre) -- Fixed bug #36303 (foreach on error_zval produces segfault). (Dmitry) -- Fixed bug #36295 (typo in SplFileObject::flock() parameter name). (Tony) -- Fixed bug #36287 (Segfault with SplFileInfo conversion). (Marcus) -- Fixed bug #36283 (SOAPClient Compression Broken). (Dmitry) -- Fixed bug #36268 (Object destructors called even after fatal errors). (Dmitry) -- Fixed bug #36258 (SplFileObject::getPath() may lead to segfault). (Tony) -- Fixed bug #36250 (PHP causes ORA-07445 core dump in Oracle server 9.2.x). - (Tony) -- Fixed bug #36242 (Possible memory corruption in stream_select()). (Tony) -- Fixed bug #36235 (ocicolumnname returns false before a successful fetch). - (Tony) -- Fixed bug #36226 (Inconsistent handling when passing potential arrays). - (Dmitry) -- Fixed bug #36224 (date(DATE_ATOM) gives wrong results). - (Derick, Hannes Magnusson) -- Fixed bug #36222 (errorInfo in PDOException is always NULL). (Ilia) -- Fixed bug #36208 (symbol namespace conflicts using bundled gd). (Jakub Moc) -- Fixed bug #36205 (Memory leaks on duplicate cookies). (Dmitry) -- Fixed bug #36185 (str_rot13() crash on non-string parameter). (Pierre) -- Fixed bug #36176 (PDO_PGSQL - PDO::exec() does not return number of rows - affected by the operation). (Ilia) -- Fixed bug #36158 (SIGTERM is not handled correctly when running as a - FastCGI server). (Dmitry) -- Fixed bug #36152 (problems with curl+ssl and pgsql+ssl in same PHP). (Mike) -- Fixed bug #36148 (unpack("H*hex", $data) is adding an extra character to - the end of the string). (Ilia) -- Fixed bug #36134 (DirectoryIterator constructor failed to detect empty - directory names). (Ilia) -- Fixed bug #36113 (Reading records of unsupported type causes segfault). - (Tony) -- Fixed bug #36096 (oci_result() returns garbage after oci_fetch() failed). - (Tony) -- Fixed bug #36083 (SoapClient waits for responses on one-way operations). - (Dmitry) -- Fixed bug #36071 (Engine Crash related with 'clone'). (Dmitry) -- Fixed bug #36055 (possible OCI8 crash in multi-threaded environment). (Tony) -- Fixed bug #36046 (parse_ini_file() miscounts lines in multi-line values). - (Ilia) -- Fixed bug #36038 (ext/hash compile failure on Mac OSX). (Tony) -- Fixed bug #36037 (heredoc adds extra line number). (Dmitry) -- Fixed bug #36016 (realpath cache memleaks). (Dmitry, Nuno) -- Fixed bug #36011 (Strict errormsg wrong for call_user_func() and the likes). - (Marcus) -- Fixed bug #36010 (Segfault when re-creating and re-executing statements with - bound parameters). (Tony) -- Fixed bug #36006 (Problem with $this in __destruct()). (Dmitry) -- Fixed bug #35999 (recursive mkdir() does not work with relative path - like "foo/bar"). (Tony) -- Fixed bug #35998 (SplFileInfo::getPathname() returns unix style filenames - in win32). (Marcus) -- Fixed bug #35988 (Unknown persistent list entry type in module shutdown). - (Dmitry) -- Fixed bug #35954 (Fatal com_exception casting object). (Rob) -- Fixed bug #35900 (stream_select() should warning when tv_sec is negative). - (Ilia) -- Fixed bug #35785 (SimpleXML causes memory read error zend engine). (Marcus) -- Fixed bug #34272 (empty array onto COM object blows up). (Rob) -- Fixed bug #33292 (apache_get_modules() crashes on Windows). (Edin) -- Fixed bug #29476 (sqlite_fetch_column_types() locks the database forever). - (Ilia) - -12 Jan 2006, PHP 5.1.2 -- Updated libsqlite in ext/sqlite to 2.8.17. (Ilia) -- Updated libsqlite in ext/pdo_sqlite to 3.2.8. (Ilia) -- Updated to libxml2-2.6.22 and libxslt-1.1.15 in the win32 bundle. (Rob) -- Added new extensions: (Ilia, Wez) - . XMLWriter - . Hash -- Added PNG compression support to GD extension. (Pierre) -- Added reflection constants as class constants. (Johannes) -- Added --enable-gcov configure option to enable C-level code coverage. - (John, Jani, Ilia, Marcus) -- Added missing support for 'B' format identifier to date() function. (Ilia) -- Changed reflection to be an extension. (Marcus) -- Improved SPL extension: (Marcus) - . Added class SplFileInfo as root class for DirectoryIterator and - SplFileObject - . Added SplTempFileObject -- Improved SimpleXML extension: (Marcus) - . Fixed memleaks - . Fixed var_dump() - . Fixed isset/empty/(bool) behavior - . Fixed iterator edge cases - . Added methods getNamespaces(), getDocNamespaces() -- Upgraded pear to version 1.4.6. (Greg) -- Added constants for libxslt and libexslt versions: LIBXSLT_VERSION, - LIBXSLT_DOTTED_VERSION, LIBEXSLT_VERSION and LIBEXSLT_DOTTED_VERSION. (Pierre) -- Fixed possible crash in apache_getenv()/apache_setenv() on invalid parameters. - (Ilia) -- Changed errors to warnings in imagecolormatch(). (Pierre) -- Fixed segfault/leak in imagecolormatch(). (Pierre) -- Fixed small leak in mysqli_stmt_fetch() when bound variable was empty string. - (Andrey) -- Fixed prepared statement name conflict handling in PDO_PGSQL. (Thies, Ilia) -- Fixed memory corruption when PDO::FETCH_LAZY mode is being used. (Ilia) -- Fixed possible leaks in imagecreatefromstring() with invalid data. (Pierre) -- Fixed possible memory corruption inside mb_strcut(). (Ilia) -- Fixed possible header injection by limiting each header to a single line. - (Ilia) -- Fixed possible XSS inside error reporting functionality. (Ilia) -- Fixed many bugs in OCI8. (Tony) -- Fixed crash and leak in mysqli when using 4.1.x client libraries and - connecting to 5.x server. (Andrey) -- Fixed bug #35916 (Duplicate calls to stream_bucket_append() lead to a crash). - (Ilia) -- Fixed bug #35908 (curl extension uses undefined GCRY_THREAD_OPTIONS_USER). - (Ilia) -- Fixed bug #35907 (PDO_OCI uses hardcoded lib path $ORACLE_HOME/lib). (Tony) -- Fixed bug #35887 (wddx_deserialize not parsing dateTime fields properly). - (Derick) -- Fixed bug #35885 (strtotime("NOW") no longer works). (Derick) -- Fixed bug #35821 (array_map() segfaults when exception is throwed from - the callback). (Tony) -- Fixed bug #35817 (unpack() does not decode odd number of hexadecimal values). - (Ilia) -- Fixed bug #35797 (segfault on PDOStatement::execute() with - zend.ze1_compatibility_mode = On). (Tony, Ilia) -- Fixed bug #35781 (stream_filter_append() can cause segfault). (Tony) -- Fixed bug #35760 (sybase_ct doesn't compile on Solaris using old gcc). (Tony) -- Fixed bug #35759 (mysqli_stmt_bind_result() makes huge allocation when - column empty). (Andrey) -- Fixed bug #35751 (using date with a timestamp makes httpd segfault). (Derick) -- Fixed bug #35740 (memory leak when including a directory). (Tony) -- Fixed bug #35730 (ext/mssql + freetds: Use correct character encoding - and allow setting it). (Frank) -- Fixed bug #35723 (xmlrpc_introspection.c fails compile per C99 std). (Jani) -- Fixed bug #35720 (A final constructor can be overwritten). (Marcus) -- Fixed bug #35713 (getopt() returns array with numeric strings when passed - options like '-1'). (Tony) -- Fixed bug #35705 (strtotime() fails to parse soap date format without TZ). - (Ilia) -- Fixed bug #35699 (date() can't handle leap years before 1970). (Derick) -- Fixed bug #35694 (Improved error message for invalid fetch mode). (Ilia) -- Fixed bug #35692 (iconv_mime_decode() segmentation fault; with libiconv - only). (Tony) -- Fixed bug #35690 (pack() tries to allocate huge memory block when packing - float values to strings). (Tony) -- Fixed bug #35669 (imap_mail_compose() crashes with - multipart-multiboundary-email). (Ilia) -- Fixed bug #35660 (AIX TZ variable format not understood, yields UTC - timezone). (Derick) -- Fixed bug #35655 (whitespace following end of heredoc is lost). (Ilia) -- Fixed bug #35630 (strtotime() crashes on certain relative identifiers). - (Ilia) -- Fixed bug #35629 (crash in http:// wrapper on multiple redirects). (Ilia) -- Fixed bug #35624 (strtotime() does not handle 3 character weekdays). (Ilia) -- Fixed bug #35612 (iis6 Access Violation crash). (Dmitry, alacn.uhahaa) -- Fixed bug #35594 (Multiple calls to getopt() may result in a crash). - (rabbitt at gmail dot com, Ilia) -- Fixed bug #35571 (Fixed crash in Apache 2 SAPI when more then one php - script is loaded via SSI include). (Ilia) -- Fixed bug #35570 (segfault when re-using soap client object). (Dmitry) -- Fixed bug #35558 (mktime() interpreting 3 digit years incorrectly). (Ilia) -- Fixed bug #35543 (php crash when calling non existing method of a class - that extends PDO). (Tony) -- Fixed bug #35539 (typo in error message for ErrorException). (Tony) -- FIxed bug #35536 (mysql_field_type() doesn't handle NEWDECIMAL). (Tony) -- Fixed bug #35517 (mysql_stmt_fetch returns NULL on data truncation). (Georg) -- Fixed bug #35509 (string constant as array key has different behavior inside - object). (Dmitry) -- Fixed bug #35508 (PDO fails when unknown fetch mode specified). (Tony) -- Fixed bug #35499 (strtotime() does not handle whitespace around the date - string). (Ilia) -- Fixed bug #35496 (Crash in mcrypt_generic()/mdecrypt_generic() without - proper init). (Ilia) -- Fixed bug #35490 (socket_sendto() unable to handle IPv6 addresses). (Tony) -- Fixed bug #35461 (Ming extension fails to compile with ming 0.3beta1). (Jani) -- Fixed bug #35437 (Segfault or Invalid Opcode 137/1/4). (Dmitry) -- Fixed bug #35470 (Assigning global using variable name from array doesn't - function). (Dmitry) -- Fixed bug #35456 (+ 1 [time unit] format did not work). (Ilia) -- Fixed bug #35447 (xml_parse_into_struct() chokes on the UTF-8 BOM). (Rob) -- Fixed bug #35431 (PDO crashes when using LAZY fetch with fetchAll). (Wez) -- Fixed bug #35430 (PDO crashes on incorrect FETCH_FUNC use). (Tony) -- Fixed bug #35427 (str_word_count() handles '-' incorrectly). (Ilia) -- Fixed bug #35425 (idate() function ignores timezone settings). (Ilia) -- Fixed bug #35422 (strtotime() does not parse times with UTC as timezone). - (Ilia) -- Fixed bug #35414 (strtotime() no longer works with ordinal suffix). (Ilia) -- Fixed bug #35410 (wddx_deserialize() doesn't handle large ints as keys - properly). (Ilia) -- Fixed bug #35409 (undefined reference to 'rl_completion_matches'). (Jani) -- Fixed bug #35399 (Since fix of bug #35273 SOAP decoding of - soapenc:base64binary fails). (Dmitry) -- Fixed bug #35393 (changing static protected members from outside the class, - one more reference issue). (Dmitry) -- Fixed bug #35381 (ssl library is not initialized properly). (Alan) -- Fixed bug #35377 (PDO_SQLITE: undefined reference to "fdatasync"). - (Nuno, Jani) -- Fixed bug #35373 (HP-UX "alias not allowed in this configuration"). (Dmitry) -- Fixed bug #35288 (iconv() function defined as libiconv()). (Nuno) -- Fixed bug #35103 (mysqli handles bad unsigned (big)int incorrectly).(Andrey) -- Fixed bug #35062 (socket_read() produces warnings on non blocking sockets). - (Nuno, Ilia) -- Fixed bug #35028 (SimpleXML object fails FALSE test). (Marcus) -- Fixed bug #34729 (Crash in ZTS mode under Apache). (Dmitry, Zeev) -- Fixed bug #34429 (Output buffering cannot be turned off with FastCGI). - (Dmitry, Ilya) -- Fixed bug #34359 (Possible crash inside fopen http wrapper). (Ilia,Sara,Nuno) -- Fixed bug #33789 (Many Problems with SunFuncs). (Derick) -- Fixed bug #33671 (sun_rise and sun_set don't return a GMT timestamp if one - passes an offset). (Derick) -- Fixed bug #32820 (date_sunrise and date_sunset don't handle GMT offset - well). (Derick) -- Fixed bug #31347 (is_dir and is_file (incorrectly) return true for any string - greater then 255 characters). (Nuno,Ilia) -- Fixed bug #30937 (date_sunrise() & date_sunset() don't handle endless - day/night at high latitudes). (Derick) -- Fixed bug #30760 (Remove MessageBox on win32 for E_CORE errors if - display_startup_error is off). (Ilia) -- Fixed bug #29955 (mb_strtoupper() / lower() broken with Turkish encoding). - (Rui) -- Fixed bug #28899 (mb_substr() and substr() behave differently when - "mbstring.func_overload" is enabled). (Rui) -- Fixed bug #27678 (number_format() crashes with large numbers). (Marcus) - -28 Nov 2005, PHP 5.1.1 -- Disabled native date class to prevent pear::date conflict. (Ilia) -- Changed reflection constants be both PHP and class constants. (Johannes) -- Added an additional field $frame['object'] to the result array of - debug_backtrace() that contains a reference to the respective object when the - frame was called from an object. (Sebastian) -- Fixed bug #35423 (RecursiveDirectoryIterator doesnt appear to recurse with - RecursiveFilterIterator). (Marcus) -- Fixed bug #35413 (Removed -dev flag from Zend Engine version). (Ilia) -- Fixed bug #35411 (Regression with \{$ handling). (Ilia) -- Fixed bug #35406 (eval hangs when evall'ed code ends with comment w/o - newline). (Marcus) -- Fixed bug #35391 (pdo_mysql::exec does not return number of affected rows). - (Tony) -- Fixed bug #35382 (Comment in end of file produces fatal error). (Ilia) -- Fixed bug #35360 (exceptions in interactive mode (php -a) may cause crash). - (Dmitry) -- Fixed bug #35358 (Incorrect error messages for PDO class constants). (Ilia) -- Fixed bug #35338 (pdo_pgsql does not handle binary bound params). (Wez) -- Fixed bug #35316 (Application exception trying to create COM object). (Rob) -- Fixed bug #35170 (PHP_AUTH_DIGEST differs under Apache 1.x and 2.x). (Ilia) - -24 Nov 2005, PHP 5.1 -- Added support for class constants and static members for internal classes. - (Dmitry, Michael Wallner) -- Added "new_link" parameter to mssql_connect() (Bug #34369). (Frank) -- Added missing safe_mode checks for image* functions and cURL. (Ilia) -- Added missing safe_mode/open_basedir checks for file uploads. (Ilia) -- Added PDO_MYSQL_ATTR_USE_BUFFERED_QUERY parameter for pdo_mysql. (Ilia) -- Added date_timezone_set() function to set the timezone that the date - function will use. (Derick) -- Added pg_fetch_all_columns() function to fetch all values of a column from a - result cursor. (Ilia) -- Added support for LOCK_EX flag for file_put_contents(). (Ilia) -- Added bindto socket context option. (Ilia) -- Added offset parameter to the stream_copy_to_stream() function. (Ilia) -- Added offset & length parameters to substr_count() function. (Ilia) -- Added man pages for "phpize" and "php-config" scripts. (Jakub Vrana) -- Added support for .cc files in extensions. (Brian) -- Added PHP_INT_MAX and PHP_INT_SIZE as predefined constants. (Andrey) -- Added user opcode API that allow overloading of opcode handlers. (Dmitry) -- Added an optional remove old session parameter to session_regenerate_id(). - (Ilia) -- Added array type hinting. (Dmitry) -- Added the tidy_get_opt_doc() function to return documentation for - configuration options in tidy. (Patch by: nlopess@php.net) -- Added support for .cc files in extensions. (Brian) -- Added imageconvolution() function which can be used to apply a custom 3x3 - matrix convolution to an image. (Pierre) -- Added optional first parameter to XsltProcessor::registerPHPFunctions to - only allow certain functions to be called from XSLT. (Christian) -- Added the ability to override the autotools executables used by the - buildconf script via the PHP_AUTOCONF and PHP_AUTOHEADER environmental - variables. (Jon) -- Added several new functions to support the PostgreSQL v3 protocol introduced - in PostgreSQL 7.4. (Christopher) - . pg_transaction_status() - in-transaction status of a database connection. - . pg_query_params() - execution of parameterized queries. - . pg_prepare() - prepare named queries. - . pg_execute() - execution of named prepared queries. - . pg_send_query_params() - async equivalent of pg_query_params(). - . pg_send_prepare() - async equivalent of pg_prepare(). - . pg_send_execute() - async equivalent of pg_execute(). - . pg_result_error_field() - highly detailed error information, most - importantly - the SQLSTATE error code. - . pg_set_error_verbosity() - set verbosity of errors. -- Added optional fifth parameter "count" to preg_replace_callback() and - preg_replace() to count the number of replacements made. FR #32275. (Andrey) -- Added optional third parameter "charlist" to str_word_count() which contains - characters to be considered as word part. FR #31560. (Andrey, Ilia) -- Added interface Serializable. (Stanislav, Marcus) -- Added pg_field_type_oid() PostgreSQL function. (mauroi at digbang dot com) -- Added zend_declare_property_...() and zend_update_property_...() API - functions for bool, double and binary safe strings. (Hartmut) -- Added possibility to access INI variables from within .ini file. (Andrei) -- Added variable $_SERVER['REQUEST_TIME'] containing request start time. - (Ilia) -- Added optional float parameter to gettimeofday(). (Ilia) -- Added apache_reset_timeout() Apache1 function. (Rasmus) -- Added sqlite_fetch_column_types() 3rd argument for arrays. (Ilia) -- Added optional offset parameter to stream_get_contents() and - file_get_contents(). (Ilia) -- Added optional maxlen parameter to file_get_contents(). (Ilia) -- 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) - . array_product() (Andrey) - . DomDocumentFragment::appendXML() (Christian) - . fputcsv() (David Sklar) - . htmlspecialchars_decode() (Ilia) - . inet_pton() (Sara) - . inet_ntop() (Sara) - . mysqli::client_info property (Georg) - . posix_access() (Magnus) - . posix_mknod() (Magnus) - . SimpleXMLElement::registerXPathNamespace() (Christian) - . stream_context_get_default() (Wez) - . stream_socket_enable_crypto() (Wez) - . stream_wrapper_unregister() (Sara) - . stream_wrapper_restore() (Sara) - . stream_filter_remove() (Sara) - . time_sleep_until() (Ilia) -- 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 max_redirects context option that specifies how many HTTP - redirects to follow. (Ilia) -- Added support of parameter=>value arrays to - xsl_xsltprocessor_set_parameter(). (Tony) - -- PHP extension loading mechanism with support for module - dependencies and conflicts. (Jani, Dmitry) -- Improved interactive mode of PHP CLI (php -a). (Johannes, Marcus) -- 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) -- Improved support for embedded server in mysqli. (Georg) -- Improved mysqli extension. (Georg) - . added constructor for mysqli_stmt and mysqli_result classes - . added new function mysqli_get_charset() - . added new function mysqli_set_charset() - . added new class mysqli_driver - . added new class mysqli_warning - . added new class mysqli_exception - . added new class mysqli_sql_exception -- Improved SPL extension. (Marcus) - . Moved RecursiveArrayIterator from examples into extension - . Moved RecursiveFilterIterator from examples into extension - . Added SplObjectStorage - . Made all SPL constants class constants - . Renamed CachingRecursiveIterator to RecursiveCachingIterator to follow - Recursive<*>Iterator naming scheme. - . added standard hierarchy of Exception classes - . added interface Countable - . added interfaces Subject and SplObserver - . added spl_autoload*() functions - . converted several 5.0 examples into c code - . added class SplFileObject - . added possibility to use a string with class_parents() and - class_implements(). (Andrey) - -- Changed type hints to allow "null" as default value for class and array. - (Marcus, Derick, Dmitry) -- Changed SQLite extension to be a shared module in Windows distribution. - (Edin) -- Changed "instanceof" and "catch" operators, is_a() and is_subclass_of() - functions to not call __autoload(). (Dmitry) -- Changed sha1_file() and md5_file() functions to use streams instead of low - level IO. (Uwe) -- Changed abstract private methods to be not allowed anymore. (Stas) -- Changed stream_filter_(ap|pre)pend() to return resource. (Sara) -- Changed mysqli_exception and sqlite_exception to use RuntimeException as - base if SPL extension is present. (Georg, Marcus) - -- Upgraded bundled libraries: - . PCRE library to version 6.2. (Andrei) - . SQLite 3 library in ext/pdo_sqlite to 3.2.7. (Ilia) - . SQLite 2 library in ext/sqlite to 2.8.16. (Ilia) -- Upgraded bundled libraries in Windows distribution. (Edin) - . zlib 1.2.3 - . curl 7.14.0 - . openssl 0.9.8 - . ming 0.3b - . libpq (PostgreSQL) 8.0.1 - -- Implemented feature request #33452 (Year belonging to ISO week). (Derick) -- Allowed return by reference from internal functions. (Marcus, Andi, Dmitry) -- Rewrote strtotime() with support for timezones and many new formats. - Implements feature requests #21399, #26694, #28088, #29150, #29585 and - #29595. (Derick) - -- Moved extensions to PECL: - . ext/cpdf (Tony, Derick) - . ext/dio (Jani, Derick) - . ext/fam (Jani, Derick) - . ext/ingres_ii (Jani, Derick) - . ext/mnogosearch (Jani, Derick) - . ext/w32api (Jani, Derick) - . ext/yp (Jani, Derick) - . ext/mcve (Jani, Derick, Pierre) - . ext/oracle (Jani, Derick) - . ext/ovrimos (Jani, Derick, Pierre) - . ext/pfpro (Jani, Derick, Pierre) - . ext/dbx (Jani, Derick) - . ext/ircg (Jani, Derick) - -- Removed php_check_syntax() function which never worked properly. (Ilia) -- Removed garbage manager in Zend Engine which results in more aggressive - freeing of data. (Dmitry, Andi) - -- Fixed "make test" to work for phpized extensions. (Hartmut, Jani) -- Fixed Apache 2 regression with sub-request handling on non-linux systems. - (Ilia, Tony) -- Fixed PDO shutdown problem (possible infinite loop running rollback on - shutdown). (Wez) -- Fixed PECL bug #3714 (PDO: beginTransaction doesn't work if you're in - auto-commit mode). (Wez) -- Fixed ZTS destruction. (Marcus) -- Fixed __get/__set to allow recursive calls for different properties. (Dmitry) -- Fixed a bug where stream_get_meta_data() did not return the "uri" element - for files opened with tmpname(). (Derick) -- Fixed a problem with SPL iterators aggregating the inner iterator. (Marcus) -- Fixed an error in mysqli_fetch_fields (returned NULL instead of an array - when row number > field_count). (Georg) -- Fixed bug in mysql::client_version(). (Georg) -- Fixed bug in mysqli extension with unsigned int(11) being represented as - signed integer in PHP instead of string in 32bit systems. (Andrey) -- Fixed bug with $HTTP_RAW_POST_DATA not getting set. (Brian) -- Fixed crash inside stream_get_line() when length parameter equals 0. (Ilia) -- Fixed ext/mysqli to allocate less memory when fetching bound params of type - (MEDIUM|LONG)BLOB/(MEDIUM|LONG)TEXT. (Andrey) -- Fixed extension initialization to respect dependencies between extensions. - (Wez) -- Fixed failing queries (FALSE returned) with mysqli_query() on 64 bit systems. - (Andrey) -- Fixed fgetcsv() and fputcsv() inconsistency. (Dmitry) -- Fixed inheritance check to control return by reference and pass by - reference correctly (ArrayAccess can no longer support references correctly). - (Marcus, Andi, Dmitry) -- Fixed initializing and argument checking for posix_mknod(). (Derick) -- Fixed memory corruption in ImageTTFText() with 64bit systems. (Andrey) -- Fixed memory corruption in pg_copy_from() in case the as_null parameter was - passed. (Derick) -- Fixed memory corruption in stristr(). (Derick) -- Fixed possible GLOBALS variable override when register_globals are ON. - (Ilia, Stefan) -- Fixed possible INI setting leak via virtual() in Apache 2 sapi. (Ilia) -- Fixed possible register_globals toggle via parse_str(). (Ilia, Stefan) -- Fixed potential GLOBALS overwrite via import_request_variables() and - possible crash and/or memory corruption. (Ilia) -- Fixed segfaults when CURL callback functions throw exception. (Tony) -- Fixed support for shared extensions on AIX. (Dmitry) -- Fixed bug #35342 (isset(DOMNodeList->length) returns false). (Rob) -- Fixed bug #35341 (Fix for bug #33760 breaks build with older curl). (Tony) -- Fixed bug #35336 (crash on PDO::FETCH_CLASS + __set()). (Tony) -- Fixed bug #35303 (PDO prepare() crashes with invalid parameters). (Ilia) -- Fixed bug #35293 (PDO segfaults when using persistent connections). (Tony) -- Fixed bug #35278 (Multiple virtual() calls crash Apache 2 php module). (Ilia) -- Fixed bug #35273 (Error in mapping soap - java types). (Dmitry) -- Fixed bug #35249 (compile failure when ext/readline is compiled as shared). - (Jani) -- Fixed bug #35248 (sqlite_query() doesn't set error_msg when return value is - being used). (Ilia) -- Fixed bug #35243 (php_mblen() crashes when compiled with thread-safety on - Linux). (Patch: shulmanb at il dot ibm dot com, Jani) -- Fixed bug #35239 (Objects can lose references). (Dmitry) -- Fixed bug #35229 (call_user_func() crashes when argument_stack is nearly - full). (Dmitry) -- Fixed bug #35197 (Destructor is not called). (Tony) -- Fixed bug #35179 (tokenizer extension needs T_HALT_COMPILER). (Greg) -- Fixed bug #35176 (include()/require()/*_once() produce wrong error messages - about main()). (Dmitry) -- Fixed bug #35147 (__HALT_COMPILER() breaks with --enable-zend-multibyte). - (Dmitry, Moriyoshi) -- Fixed bug #35143 (gettimeofday() ignores current time zone). (Derick) -- Fixed bug #35142 (SOAP Client/Server Complex Object Support). (Dmitry) -- Fixed bug #35135 (PDOStatment without related PDO object may crash). (Ilia) -- Fixed bug #35091 (SoapClient leaks memory). (Dmitry) -- Fixed bug #35079 (stream_set_blocking(true) toggles, not enables blocking). - (askalski at gmail dot com, Tony) -- Fixed bug #35078 (configure does not find ldap_start_tls_s). (Jani) -- Fixed bug #35046 (phpinfo() uses improper css enclosure). (Ilia) -- Fixed bugs #35022, #35019 (Regression in the behavior of key() and - current() functions). (Ilia) -- Fixed bug #35017 (Exception thrown in error handler may cause unexpected - behavior). (Dmitry) -- Fixed bug #35014 (array_product() always returns 0). (Ilia) -- Fixed bug #35009 (ZTS: Persistent resource destruct crashes when extension - is compiled as shared). (Dmitry) -- Fixed bug #34996 (ImageTrueColorToPalette() crashes when ncolors is zero). - (Tony) -- Fixed bug #34982 (array_walk_recursive() modifies elements outside function - scope). (Dmitry) -- Fixed bug #34977 (Compile failure on MacOSX due to use of varargs.h). (Tony) -- Fixed bug #34968 (bz2 extension fails on to build on some win32 setups). - (Ilia) -- Fixed bug #34965 (tidy is not binary safe). (Mike) -- Fixed bug #34957 (PHP doesn't respect ACLs for access checks). (Wez) -- Fixed bug #34950 (Unable to get WSDL through proxy). (Dmitry) -- Fixed bug #34938 (dns_get_record() doesn't resolve long hostnames and - leaks). (Tony) -- Fixed bug #34905 (Digest authentication does not work with Apache 1). (Ilia) -- Fixed bug #34902 (mysqli::character_set_name() - undefined method). (Tony) -- Fixed bug #34899 (Fixed sqlite extension compile failure). (Ilia) -- Fixed bug #34893 (PHP5.1 overloading, Cannot access private property). - (Dmitry) -- Fixed bug #34884 (Possible crash in ext/sqlite when sqlite.assoc_case is - being used). (Tony, Ilia) -- Fixed bug #34879 (str_replace, array_map corrupt negative array indexes on - 64-bit platforms). (Dmitry) -- Fixed bug #34873 (Segmentation Fault on foreach in object). (Dmitry) -- Fixed bug #34856 (configure fails to detect libiconv's type). (Tony) -- Fixed bug #34855 (ibase_service_attach() segfault on AMD64). - (irie at gmx dot de, Tony) -- Fixed bug #34851 (SO_RECVTIMEO and SO_SNDTIMEO socket options expect - integer parameter on Windows). (Mike) -- Fixed bug #34850 (--program-suffix and --program-prefix not included in - man page names). (Jani) -- Fixed bug #34821 (zlib encoders fail on widely varying binary data on - windows). (Mike, Ilia) -- Fixed bug #34818 (several functions crash when invalid mysqli_link object - is passed). (Tony) -- Fixed bug #34810 (mysqli::init() and others use wrong $this pointer without - checks). (Tony) -- Fixed bug #34809 (FETCH_INTO in PDO crashes without a destination object). - (Ilia) -- Fixed bug #34802 (Fixed crash on object instantiation failure). (Ilia) -- Fixed bug #34796 (missing SSL linking in ext/ftp when configured as shared). - (Jani) -- Fixed bug #34790 (preg_match_all(), named capturing groups, variable - assignment/return => crash). (Dmitry) -- Fixed bug #34788 (SOAP Client not applying correct namespace to generated - values). (Dmitry) -- Fixed bug #34787 (SOAP Client not handling boolean types correctly). (Dmitry) -- Fixed bug #34786 (2 @ results in change to error_reporting() to random - value) (Dmitry, Tony) -- Fixed bug #34785 (subclassing of mysqli_stmt does not work). (Georg) -- Fixed bug #34782 (token_get_all() gives wrong result). (Dmitry) -- Fixed bug #34777 (Crash in dblib when fetching non-existent error info). - (Ilia) -- Fixed bug #34771 (strtotime() fails with 1-12am/pm). (Derick) -- Fixed bug #34767 (Zend Engine 1 Compatibility not copying objects - correctly). (Dmitry) -- Fixed bug #34758 (PDO_DBLIB did not implement rowCount()). (Ilia) -- Fixed bug #34757 (iconv_substr() gives "Unknown error" when offset > string - length). (Tony) -- Fixed bug #34742 (ftp wrapper failures caused from segmented command - transfer). (Ilia) -- Fixed bug #34725 (CLI segmentation faults during cleanup). (Dmitry) -- Fixed bug #34723 (array_count_values() strips leading zeroes). (Tony) -- Fixed bug #34712 (zend.ze1_compatibility_mode = on segfault). (Dmitry) -- Fixed bug #34704 (Infinite recursion due to corrupt JPEG). (Marcus) -- Fixed bug #34678 (__call(), is_callable() and static methods). (Dmitry) -- Fixed bug #34676 (missing support for strtotime("midnight") and - strtotime("noon")). (Derick) -- Fixed bug #34645 (ctype corrupts memory when validating large numbers). - (Ilia) -- Fixed bug #34643 (wsdl default value has no effect). (Dmitry) -- Fixed bug #34623 (Crash in pdo_mysql on longtext fields). (Ilia) -- Fixed bug #34617 (zend_deactivate: objects_store used after - zend_objects_store_destroy is called). (Dmitry) -- Fixed bug #34590 (User defined PDOStatement class can't implement - methods). (Marcus) -- Fixed bug #34584 (Segfault with SPL autoload handler). (Marcus) -- Fixed bug #34581 (crash with mod_rewrite). (Tony, Ilia) -- Fixed bug #34565 (mb_send_mail does not fetch - mail.force_extra_parameters). (Marco, Ilia) -- Fixed bug #34557 (php -m exits with "error" 1). (Johannes) -- Fixed bug #34518 (Unset doesn't separate container in CV). (Dmitry) -- Fixed bug #34505 (Possible memory corruption when unmangling properties - with empty names). (Tony) -- Fixed bug #34478 (Incorrect parsing of url's fragment (#...)). (Dmitry) -- Fixed bug #34467 (foreach + __get + __set inconsistency). (Dmitry) -- Fixed bug #34456 (Possible crash inside pspell extension). (Ilia) -- Fixed bug #34453 (parsing http://www.w3.org/2001/xml.xsd exception). (Dmitry) -- Fixed bug #34450 (Segfault when calling mysqli_close() in destructor). (Tony) -- Fixed bug #34449 (ext/soap: XSD_ANYXML functionality not exposed). (Dmitry) -- Fixed bug #34420 (Possible crash inside curl_multi_remove_handle()). (Ilia) -- Fixed bug #34358 (Fatal error: Cannot re-assign $this). (Dmitry) -- Fixed bug #34331 (php crashes when variables_order is empty). (Ilia) -- Fixed bug #34321 (Possible crash in filter code). (Ilia) -- Fixed bug #34311 (unserialize() crashes with chars above 191 dec). (Nuno) -- Fixed bug #34310 (foreach($arr as $c->d => $x) crashes). (Dmitry) -- Fixed bug #34307 (on_modify handler not called to set the default value if - setting from php.ini was invalid). (Andrei) -- Fixed bug #34306 (wddx_serialize_value() crashes with long array keys). - (Jani) -- Fixed bug #34304 (date() doesn't have a modifier for ISO Week Day). (Derick) -- Fixed bug #34302 (date('W') do not return leading zeros for week 1 to 9). - (Derick) -- Fixed bug #34299 (ReflectionClass::isInstantiable() returns true for abstract - classes). (Marcus) -- Fixed bug #34284 (CLI phpinfo showing html on _SERVER["argv"]). (Jani) -- Fixed bug #34277 (array_filter() crashes with references and objects). - (Dmitry) -- Fixed bug #34276 (setAttributeNS doesn't work with default namespace). - (Rob) -- Fixed bug #34260 (Segfault with callbacks (array_map) + overloading). - (Dmitry) -- Fixed bug #34257 (lib64 not handled correctly in ming extension). (Marcus) -- Fixed bug #34221 (Compiling xmlrpc as shared fails other parts). (Jani) -- Fixed bug #34216 (Segfault with autoload). (Marcus) -- Fixed bug #34199 (if($obj)/if(!$obj) inconsistency because of cast handler). - (Dmitry, Alex) -- Fixed bug #34191 (ob_gzhandler does not enforce trailing \0). (Ilia) -- Fixed bug #34156 (memory usage remains elevated after memory limit is - reached). (Ilia) -- Fixed bug #34148 (+,- and . not supported as parts of scheme). (Ilia) -- Fixed bug #34137 (assigning array element by reference causes binary mess). - (Dmitry) -- Fixed bug #34103 (line numbering not maintained in dom document). (Rob) -- Fixed bug #34078 (Reflection API problems in methods with boolean or - null default values). (Tony) -- Fixed bug #34068 (Numeric string as array key not cast to integer in - wddx_deserialize()). (Ilia) -- Fixed bug #34064 (arr[] as param to function in class gives invalid - opcode). (Dmitry) -- Fixed bug #34062 (Crash in catch block when many arguments are used). - (Dmitry) -- Fixed bug #34052 (date('U') returns %ld not unix timestamp). (Nuno) -- Fixed bug #34045 (Buffer overflow with serialized object). (Dmitry) -- Fixed bug #34001 (pdo_mysql truncates numeric fields at 4 chars). (Ilia) -- Fixed bug #33999 (object remains object when cast to int). (Dmitry) -- Fixed bug #33996 (No information given for fatal error on passing invalid - value to typed argument). (Dmitry) -- Fixed bug #33989 (extract($GLOBALS,EXTR_REFS) crashes PHP). (Dmitry) -- Fixed bug #33987 (php script as ErrorDocument causes crash in Apache 2). - (Ilia) -- Fixed bug #33967 (misuse of Exception constructor doesn't display - errorfile). (Jani) -- Fixed bug #33966 (Wrong use of reflectionproperty causes a segfault). (Tony) -- Fixed bug #33963 (mssql_bind() fails on input parameters). (Frank) -- Fixed bug #33958 (duplicate cookies and magic_quotes=off may cause a crash). - (Ilia) -- Fixed bug #33957 (gmdate('W')/date('W') sometimes returns wrong week number). - (Derick) -- Fixed bug #33940 (array_map() fails to pass by reference when called - recursively). (Dmitry) -- Fixed bug #33917 (number_format() output with > 1 char separators). (Jani) -- Fixed bug #33904 (input array keys being escaped when magic quotes is off). - (Ilia) -- Fixed bug #33903 (spl_autoload_register class method). (Marcus) -- Fixed bug #33899 (CLI: setting extension_dir=some/path extension=foobar.so - does not work). (Jani) -- Fixed bug #33882 (CLI was looking for php.ini in wrong path). (Hartmut) -- Fixed bug #33869 (strtotime() problem with "+1days" format). (Ilia) -- Fixed bug #33841 (pdo sqlite driver forgets to update affected column - count on execution of prepared statments). (Ilia) -- Fixed bug #33837 (Informix ESQL version numbering schema changed). (Jani) -- Fixed bug #33829 (mime_content_type() returns text/plain for gzip and bzip - files). (Derick) -- Fixed bug #33802 (throw Exception in error handler causes crash). (Dmitry) -- Fixed bug #33771 (error_reporting falls to 0 when @ was used inside - try/catch block). (Tony) -- Fixed bug #33760 (cURL needs to implement CRYPTO_callback functions to - prevent locking). (Mike, Ilia) -- Fixed bug #33732 (Wrong behavior of constants in class and interface - extending). (Dmitry) -- Fixed bug #33723 (php_value overrides php_admin_value). (Dmitry) -- Fixed bug #33720 (mb_encode_mimeheader does not work for multibyte - chars). (Rui) -- Fixed bug #33710 (ArrayAccess objects does not initialize $this). (Dmitry) -- Fixed bug #33690 (Crash setting some ini directives in httpd.conf). (Rasmus) -- Fixed bug #33673 (Added detection for partially uploaded files). (Ilia) -- Fixed bug #33605 (substr_compare() crashes with negative offset and length). - (Tony) -- Fixed bug #33597 (setcookie() "expires" date format doesn't comply with RFC). - (Tony) -- Fixed bug #33588 (LDAP: RootDSE query not possible). (Jani) -- Fixed bug #33578 (strtotime() problem with "Oct17" format). (Derick) -- Fixed bug #33578 (strtotime() doesn't understand "11 Oct" format). (Derick) -- Fixed bug #33562 (date("") crashes). (Derick) -- Fixed bug #33558 (warning with nested calls to functions returning by - reference). (Dmitry) -- Fixed bug #33536 (strtotime() defaults to now even on non time string). - (Derick) -- Fixed bug #33532 (Different output for strftime() and date()). (Derick) -- Fixed bug #33523 (Memory leak in xmlrpc_encode_request()). (Ilia) -- Fixed bug #33520 (crash if safe_mode is on and session.save_path is changed). - (Dmitry) -- Fixed bug #33512 (Add missing support for isset()/unset() overloading to - complement the property get/set methods). (Dmitry) -- Fixed bug #33491 (crash after extending MySQLi internal class). (Tony) -- Fixed bug #33475 (cURL handle is not closed on curl_close(). (Ilia) -- Fixed bug #33469 (Compile error undefined reference to ifx_checkAPI). (Jani) -- Fixed bug #33433 (strtoll not available on Tru64). (Jani, Derick) -- Fixed bug #33427 (ext/odbc: check if unixODBC header file exists). (Jani) -- Fixed bug #33415 (strtotime() related bugs). (Derick) -- Fixed bug #33414 (Comprehensive list of incorrect days returned after - strtotime() / date() tests). (Derick) -- Fixed bug #33389 (double free() when exporting a ReflectionClass). (Marcus) -- Fixed bug #33383 (crash when retrieving empty LOBs). (Tony) -- Fixed bug #33382 (array_reverse() fails after *sort()), introduced by - zend_hash_sort() optimizations in HEAD. (Tony) -- Fixed bug #33340 (CLI Crash when calling php:function from XSLT). (Rob) -- Fixed bug #33326 (Cannot build extensions with phpize on Macosx). (Jani) -- Fixed bug #33318 (throw 1; results in Invalid opcode 108/1/8). (Dmitry) -- Fixed bug #33312 (ReflectionParameter methods do not work correctly). - (Dmitry) -- Fixed bug #33299 (php:function no longer handles returned dom objects). - (Rob, Joe Orton) -- Fixed bug #33286 (nested array_walk() calls and user array compare functions - broken; FCI cache). (Andrei, patch from m.bretz@metropolis-ag.de) -- Fixed bug #33277 (private method accessed by child class). (Dmitry) -- Fixed bug #33268 (iconv_strlen() works only with a parameter of < 3 in - length). (Ilia) -- Fixed bug #33257 (array_splice() inconsistent when passed function instead of - variable). (Dmitry) -- Fixed bug #33243 (ze1_compatibility_mode does not work as expected). (Dmitry) -- Fixed bug #33242 (Mangled error message when stream fails). (Derick) -- Fixed bug #33222 (segfault when CURL handle is closed in a callback). (Tony) -- Fixed bug #33214 (odbc_next_result does not signal SQL errors with - 2-statement SQL batches). (rich at kastle dot com, Tony) -- Fixed bug #33212 ([GCC 4]: 'zend_error_noreturn' aliased to external symbol - 'zend_error'). (Dmitry) -- Fixed bug #33210 (relax jpeg recursive loop protection). (Ilia) -- Fixed bug #33201 (Crash when fetching some data types). (Frank) -- Fixed bug #33200 (preg_replace(): magic_quotes_sybase=On makes 'e' modifier - misbehave). (Jani) -- Fixed bug #33185 (--enable-session=shared does not build). (Jani) -- Fixed bug #33171 (foreach enumerates private fields declared in base - classes). (Dmitry) -- Fixed bug #33167 (Possible crash inside pg_fetch_array()). (Ilia) -- Fixed bug #33164 (Soap extension incorrectly detects HTTP/1.1). (Ilia) -- Fixed bug #33156 (cygwin version of setitimer doesn't accept ITIMER_PROF). - (Nuno) -- Fixed bug #33153 (crash in mssql_next result). (Frank) -- Fixed bug #33150 (shtool: insecure temporary file creation). (Jani) -- Fixed bug #33136 (method offsetSet in class extended from ArrayObject crash - PHP). (Marcus) -- Fixed bug #33125 (imagecopymergegray() produces mosaic rainbow effect). - (Pierre) -- Fixed bug #33116 (crash when assigning class name to global variable in - __autoload). (Dmitry) -- Fixed bug #33090 (mysqli_prepare() doesn't return an error). (Georg) -- Fixed bug #33076 (str_ireplace() incorrectly counts result string length - and may cause segfault). (Tony) -- Fixed bug #33072 (Add a safemode/open_basedir check for runtime - "session.save_path" change using session_save_path() function). (Rasmus) -- Fixed bug #33070 (Improved performance of bzdecompress() by several orders - of magnitude). (Ilia) -- Fixed bug #33059 (crash when moving xml attribute set in dtd). (Ilia) -- Fixed bug #33057 (Don't send extraneous entity-headers on a 304 as per - RFC 2616 section 10.3.5) (Rasmus, Choitel) -- Fixed bug #33019 (socket errors cause memory leaks in php_strerror()). - (jwozniak23 at poczta dot onet dot pl, Tony). -- Fixed bug #33017 ("make distclean" gives an error with VPATH build). (Jani) -- Fixed bug #33013 ("next month" was handled wrong while parsing dates). - (Derick) -- Fixed bug #32993 (implemented Iterator function current() don't throw - exception). (Dmitry) -- Fixed bug #32981 (ReflectionMethod::getStaticVariables() causes apache2.0.54 - seg fault). (Dmitry) -- Fixed bug #32956 (mysql_bind_result() doesn't support MYSQL_TYPE_NULL). - (Georg) -- Fixed bug #32947 (Incorrect option for mysqli default password). (Georg) -- Fixed bug #32944 (Disabling session.use_cookies doesn't prevent reading - session cookies). (Jani, Tony) -- Fixed bug #32941 (Sending structured SOAP fault kills a php). (Dmitry) -- Fixed bug #32937 (open_basedir looses trailing / in the limiter). - (Adam Conrad) -- Fixed bug #32936 (http redirects URLs are not checked for control chars). - (Ilia) -- Fixed bug #32933 (Cannot extend class "SQLiteDatabase"). (Marcus) -- Fixed bug #32932 (Oracle LDAP: ldap_get_entries(), invalid pointer). (Jani) -- Fixed bug #32930 (class extending DOMDocument doesn't clone properly). (Rob) -- Fixed bug #32924 (file included with "auto_prepend_file" can be included - with require_once() or include_once()). (Stas) -- Fixed bug #32904 (pg_get_notify() ignores result_type parameter). (Tony) -- Fixed bug #32852 (Crash with singleton and __destruct when - zend.ze1_compatibility_mode = On). (Dmitry) -- Fixed bug #32833 (Invalid opcode). (Dmitry) -- Fixed bug #32813 (parse_url() does not handle scheme-only urls properly). - (Ilia) -- Fixed bug #32810 (temporary files not using plain file wrapper). (Ilia) -- Fixed bug #32809 (Missing T1LIB support on Windows). (Edin) -- Fixed bug #32802 (General cookie overrides more specific cookie). (Ilia) -- Fixed bugs #32800, #32830 (ext/odbc: Problems with 64bit systems). (Jani) -- Fixed bug #32799 (crash: calling the corresponding global var during the - destruct). (Dmitry) -- Fixed bug #32776 (SOAP doesn't support one-way operations). (Dmitry) -- Fixed bug #32773 (GMP functions break when second parameter is 0). (Stas) -- Fixed bug #32759 (incorrect determination of default value (COM)). (Wez) -- Fixed bug #32758 (Cannot access safearray properties in VB6 objects). (Wez) -- Fixed bug #32755 (Segfault in replaceChild() when DocumentFragment has no - children). (Rob) -- Fixed bug #32753 (Undefined constant SQLITE_NOTADB). (Ilia) -- Fixed bug #32742 (segmentation fault when the stream with a wrapper - is not closed). (Tony, Dmitry) -- Fixed bug #32699 (pg_affected_rows() was defined when it was not available). - (Derick) -- Fixed bug #32686 (Require/include file in destructor causes segfault). - (Marcus) -- Fixed bug #32682 (ext/mssql: Error on module shutdown when called from - activescript). (Frank) -- Fixed bug #32674 (exception in iterator causes crash). (Dmitry) -- Fixed bug #32660 (Assignment by reference causes crash when field access is - overloaded (__get)). (Dmitry) -- Fixed bug #32647 (Using register_shutdown_function() with invalid callback - can crash PHP). (Jani) -- Fixed bug #32615 (Segfault in replaceChild() using fragment when - previousSibling is NULL). (Rob) -- Fixed bug #32613 (ext/snmp: use of snmp_shutdown() causes snmpapp.conf - access errors). (Jani, ric at arizona dot edu) -- Fixed bug #32608 (html_entity_decode() converts single quotes even if - ENT_NOQUOTES is given). (Ilia) -- Fixed bug #32596 (Segfault/Memory Leak by getClass (etc) in __destruct). - (Dmitry) -- Fixed bug #32591 (ext/mysql: Unsatisfied symbol: ntohs with HP-UX). (Jani) -- Fixed bug #32589 (possible crash inside imap_mail_compose() function). - (Ilia) -- Fixed bug #32589 (Possible crash inside imap_mail_compose, with charsets). - (Ilia) -- Fixed bug #32587 (Apache2: errors sent to error_log do not include - timestamps). (Jani) -- Fixed bug #32560 (configure looks for incorrect db2 library). (Tony) -- Fixed bug #32553 (mmap loads only the 1st 2000000 bytes on Win32). (Ilia) -- Fixed bug #32533 (proc_get_status() returns the incorrect process status). - (Ilia) -- Fixed bug #32530 (chunk_split() does not append endstr if chunklen is - longer then the original string). (Ilia) -- Fixed bug #32491 (File upload error - unable to create a temporary file). - (Uwe Schindler) -- Fixed bug #32455 (wrong setting property to unset value). (Dmitry) -- Fixed bug #32429 (method_exists() always return TRUE if __call method - exists). (Dmitry) -- Fixed bug #32428 (The @ warning error suppression operator is broken). - (Dmitry) -- Fixed bug #32427 (Interfaces are not allowed 'static' access modifier). - (Dmitry) -- Fixed bug #32405 (mysqli::fetch() returns bad data - 64bit problem). - (Andrey) -- Fixed bug #32296 (get_class_methods() output has changed between 5.0.2 and - 5.0.3). (Dmitry) -- Fixed bug #32282 (Segfault in mysqli_fetch_array on 64-bit). (Georg) -- Fixed bug #32245 (xml_parser_free() in a function assigned to the xml - parser gives a segfault). (Rob) -- Fixed bug #32179 (xmlrpc_encode() segfaults with recursive references). - (Tony) -- Fixed bug #32171 (Userspace stream wrapper crashes PHP). (Tony, Dmitry) -- Fixed bug #32160 (copying a file into itself leads to data loss). (Ilia) -- Fixed bug #32139 (SOAP client does not auto-handle base64 encoding). (Ilia) -- Fixed bug #32109 ($_POST is not populated in multi-threaded environment). - (Moriyoshi) -- Fixed bug #32080 (segfault when assigning object to itself with - zend.ze1_compatibility_mode=On). (Dmitry) -- Fixed bug #32021 (Crash caused by range('', 'z')). (Derick) -- Fixed bug #32013 (ext/mysqli bind_result causes fatal error: memory limit). - (Andrey) -- Fixed bug #32010 (Memory leak in mssql_fetch_batch). (fmk) -- Fixed bug #32009 (crash when mssql_bind() is called more than once). (Frank) -- Fixed bug #31971 (ftp_login fails on some SSL servers). - (frantisek at augusztin dot com) -- Fixed bug #31887 (ISAPI: Custom 5xx error does not return correct HTTP - response message). (Jani) -- Fixed bug #31828 (Crash with zend.ze1_compatibility_mode=On). (Dmitry) -- Fixed bug #31668 (multi_query works exactly every other time - multi query - d/e flag global and not per connection). (Andrey) -- Fixed bug #31636 (another crash when echoing a COM object). (Wez) -- Fixed bug #31583 (php_std_date() uses short day names in non-y2k_compliance - mode). (mike at php dot net) -- Fixed bug #31525 (object reference being dropped. $this getting lost). - (Stas, Dmitry) -- Fixed bug #31502 (Wrong deserialization from session when using WDDX - serializer). (Dmitry) -- Fixed bug #31478 (segfault with empty() / isset()). (Moriyoshi) -- Fixed bug #31465 (False warning in unpack() when working with *). (Ilia) -- Fixed bug #31363 (broken non-blocking flock()). (ian at snork dot net) -- Fixed bug #31358 (Older GCC versions do not provide portable va_copy()). - (Jani) -- Fixed bug #31341 (escape on curly inconsistent). (Dmitry) -- Fixed bug #31256 (PHP_EVAL_LIBLINE configure macro does not handle - -pthread). (Jani) -- Fixed bug #31213 (Side effects caused by fix of bug #29493). (Dmitry) -- Fixed bug #31177 (memory leaks and corruption because of incorrect - refcounting). (Dmitry) -- Fixed bug #31158 (array_splice on $GLOBALS crashes). (Dmitry) -- Fixed bug #31054 (safe_mode & open_basedir checks only check first - include_path value). (Ilia) -- Fixed bug #31033 (php:function(string, nodeset) with xsl:key crashes PHP). - (Rob) -- Fixed bug #30961 (Wrong line number in ReflectionClass getStartLine()). - (Dmitry) -- Fixed bug #30889 (Conflict between __get/__set and ++ operator). (Dmitry) -- Fixed bug #30833 (array_count_values() modifying input array). (Tony) -- Fixed bug #30828 (debug_backtrace() reports incorrect class in overridden - methods). (Dmitry) -- Fixed bug #30820 (static member conflict with $this->member silently - ignored). (Dmitry) -- Fixed bug #30819 (Better support for LDAP SASL bind). (Jani) -- Fixed bug #30791 (magic methods (__sleep/__wakeup/__toString) call - __call if object is overloaded). (Dmitry) -- Fixed bug #30707 (Segmentation fault on exception in method). - (Stas, Dmitry) -- Fixed bug #30702 (cannot initialize class variable from class constant). - (Dmitry) -- Fixed bug #30578 (Output buffers flushed before calling __destruct() - functions). (Jani) -- Fixed bug #30519 (Interface not existing says Class not found). (Dmitry) -- Fixed bug #30407 (Strange behavior of default arguments). (Dmitry) -- Fixed bug #30394 (Assignment operators yield wrong result with __get/__set). - (Dmitry) -- Fixed bug #30332 (zend.ze1_compatibility_mode isn't fully compatible with - array_push()). (Dmitry) -- Fixed bug #30162 (Catching exception in constructor causes lose of - $this). (Dmitry) -- Fixed bug #30140 (Problem with array in static properties). (Dmitry) -- Fixed bug #30126 (Enhancement for error message for abstract classes). - (Marcus) -- Fixed bug #30096 (gmmktime does not return the current time). (Derick) -- Fixed bug #30080 (Passing array or non array of objects). (Dmitry) -- Fixed bug #30052 (Crash on shutdown after odbc_pconnect()). (Edin) -- Fixed bug #29983 (PHP does not explicitly set mime type & charset). (Ilia) -- Fixed bug #29975 (memory leaks when set_error_handler() is used inside error - handler). (Tony) -- Fixed bug #29971 (variables_order behavior). (Dmitry) -- Fixed bug #29944 (Function defined in switch, crashes). (Dmitry) -- Fixed bug #29896 (Backtrace argument list out of sync). (Dmitry) -- Fixed bug #29728 (Reflection API Feature: Default parameter value). (Marcus) -- Fixed bug #29689 (default value of protected member overrides default value - of private and other private variable problems in inherited classes). (Stas) -- Fixed bug #29683 (headers_list() returns empty array). (Tony) -- Fixed bug #29583 (crash when echoing a COM object). (M.Sisolak, Wez) -- Fixed bug #29522 (accessing properties without connection). (Georg) -- Fixed bug #29361 (var_export() producing invalid code). (Derick) -- Fixed bug #29338 (unencoded spaces get ignored after certain tags). (Ilia) -- Fixed bug #29335 (fetch functions now use MYSQLI_BOTH as default). (Georg) -- Fixed bug #29334 (win32 mail() provides incorrect Date: header). (Jani) -- Fixed bug #29311 (calling parent constructor in mysqli). (Georg) -- Fixed bug #29268 (__autoload() not called with Reflection->getClass()). - (Dmitry) -- Fixed bug #29256 (SOAP HTTP Error when envelop size is more than 24345 - bytes). (Dmitry, Wez) -- Fixed bug #29253 (array_diff with $GLOBALS argument fails). (Dmitry) -- Fixed bug #29236 (memory error when wsdl-cache is enabled). (Dmitry) -- Fixed bug #29210 (Function: is_callable - no support for private and - protected classes). (Dmitry) -- Fixed bug #29109 (SoapFault exception: [WSDL] Out of memory). (Dmitry) -- Fixed bug #29104 (Function declaration in method doesn't work). (Dmitry) -- Fixed bug #29061 (soap extension segfaults). (Dmitry) -- Fixed bug #29015 (Incorrect behavior of member vars(non string ones)-numeric - mem vars and others). (Dmitry) -- Fixed bug #28985 (__getTypes() returning nothing on complex WSDL). (Dmitry) -- Fixed bug #28969 (Wrong data encoding of special characters). (Dmitry) -- Fixed bug #28839 (SIGSEGV in interactive mode (php -a)). - (kameshj at fastmail dot fm) -- Fixed bug #28605 (Need to use -[m]ieee option for Alpha CPUs). (Jani) -- Fixed bug #28568 (SAPI::known_post_content_types is not thread safe). - (Moriyoshi) -- Fixed bug #28377 (debug_backtrace is intermittently passing args). (Dmitry) -- Fixed bug #28355 (glob wont error if dir is not readable). (Hartmut) -- Fixed bug #28072 (static array with some constant keys will be incorrectly - ordered). (Dmitry) -- Fixed bug #27908 (xml default_handlers not being called). (Rob) -- Fixed bug #27598 (list() array key assignment causes HUGE memory leak). - (Dmitry) -- Fixed bug #27268 (Bad references accentuated by clone). (Dmitry) -- Fixed bug #26456 (Wrong results from Reflection-API getDocComment() when - called via STDIN). (Dmitry) -- Fixed bug #25922 (In error handler, modifying 5th arg (errcontext) may - result in seg fault). (Dmitry) -- Fixed bug #25359 (array_multisort() doesn't work in a function if array is - global or reference). (Dmitry) -- Fixed bug #22836 (returning reference to uninitialized variable). (Dmitry) -- Fixed bug #21306 (ext/sesssion: catch bailouts of write handler during - RSHUTDOWN). (Jani, Xuefer at 21cn dot com) -- Fixed bug #15854 (boolean ini options may be incorrectly displayed as Off - when they are On). (Tony) -- Fixed bugs #14561, #20382, #26090, #26320, #28024, #30532, #32086, #32270, - #32555, #32588, #33056 (strtotime() related bugs). (Derick) - -31 Mar 2005, PHP 5.0.4 -- Added SNMPv2 support. (harrie) -- Added Oracle Instant Client support. (cjbj at hotmail dot com, Tony) -- Added length and charsetnr for field array and object in mysqli. (Georg) -- Added checks for negative values to gmp_sqrt(), gmp_powm(), gmp_sqrtrem() - and gmp_fact() to prevent SIGFPE. (Tony) -- Changed foreach() to throw an exception if IteratorAggregate::getIterator() - does not return an Iterator. (Marcus) -- Changed phpize not to require libtool. (Jani) -- Updated bundled oniguruma library (used for multibyte regular expression) - to 3.7.0. (Moriyoshi) -- Updated bundled libmbfl library (used for multibyte functions). (Moriyoshi) - Fixed bugs: - . Bug #32311 (mb_encode_mimeheader() does not properly escape characters) - . Bug #32063 (mb_convert_encoding ignores named entity 'alpha') - . Bug #31911 (mb_decode_mimeheader() is case-sensitive to hex escapes) - . bug #30573 (compiler warnings in libmbfl due to invalid type cast) - . Bug #30549 (incorrect character translations for some ISO8859 charsets). -- Fixed bug preventing from building oci8 as shared. - (stanislav dot voroniy at portavita dot nl, Tony) -- Fixed a bug in mysql_affected_rows and mysql_stmt_affected_rows when the - api function returns -1 (Georg) -- Fixed several leaks in ext/browscap and sapi/embed. (Andrei) -- Fixed several leaks in ext/filepro. (Tony) -- Fixed build system to always use bundled libtool files. (Jani) -- Fixed a bug in mysqli_stmt_execute() (type conversion with NULL values). - (Georg) -- Fixed segfault in mysqli_fetch_field_direct() when invalid field offset - is passed. (Tony) -- Fixed posix_getsid() & posix_getpgid() to return sid & pgid instead - of true. (Tony) -- Fixed bug #32394 (offsetUnset() segfaults in a foreach). (Marcus) -- Fixed bug #32373 (segfault in bzopen() if supplied path to non-existent - file). (Tony) -- Fixed bug #32326 (Check values of Connection/Transfer-Encoding - case-incentively in SOAP extension). (Ilia) -- Fixed bug #32290 (call_user_func_array() calls wrong class method within - child class). (Marcus) -- Fixed bug #32238 (spl_array.c: void function cannot return value). (Johannes) -- Fixed bug #32210 (proc_get_status() sets "running" always to true). (Ilia) -- Fixed bug #32200 (Prevent using both --with-apxs2 and --with-apxs2filter). - (Jani) -- Fixed bug #32134 (Overloading offsetGet/offsetSet). (Marcus) -- Fixed bug #32130 (ArrayIterator::seek() does not throw an Exception on - invalid index). (Marcus) -- Fixed bug #32115 (dateTime SOAP encoding of timezone incorrect). (Dmitry) -- Fixed bug #32081 (in mysqli default socket value is not being used). (Ilia) -- Fixed bug #32021 (Crash caused by range('', 'z')). (Derick) -- Fixed bug #32011 (Fragments which replaced Nodes are not globaly useable). - (Rob) -- Fixed bug #32001 (xml_parse_into_struct() function exceeds maximum - execution time). (Rob, Moriyoshi) -- Fixed bug #31980 (Unicode exif data not available on Windows). (Edin) -- Fixed bug #31960 (msql_fetch_row() and msql_fetch_array() dropping columns - with NULL values). (Daniel Convissor) -- Fixed bug #31878 (Segmentation fault using clone keyword on nodes). (Rob) -- Fixed bug #31858 (--disable-cli does not force --without-pear). (Jani) -- Fixed bug #31842 (*date('r') does not return RFC2822 conforming date string). - (Jani) -- Fixed bug #31832 (SOAP encoding problem with complex types in WSDL mode with - multiple parts). (Dmitry) -- Fixed bug #31797 (exif_read_data() uses too low nesting limit). (Ilia) -- Fixed bug #31796 (readline completion handler does not handle empty return - values). (Ilia) -- Fixed bug #31792 (getrusage() does not provide ru_nswap value). (Ilia) -- Fixed bug #31755 (Cannot create SOAP header in no namespace). (Dmitry) -- Fixed bug #31754 (dbase_open() fails for mode = 1). (Mehdi, Derick) -- Fixed bug #31751 (pg_parameter_status() missing on Windows). (Edin) -- Fixed bug #31747 (SOAP Digest Authentication doesn't work with - "HTTP/1.1 100 Continue" response). (Dmitry) -- Fixed bug #31732 (mb_get_info() causes segfault when no parameters - specified). (Tony) -- Fixed bug #31710 (Wrong return values for mysqli_autocommit/commit/rollback). - (Georg) -- Fixed bug #31705 (parse_url() does not recognize http://foo.com#bar). (Ilia) -- Fixed bug #31695 (Cannot redefine endpoint when using WSDL). (Dmitry) -- Fixed bug #31684 (dio_tcsetattr(): misconfigured termios settings). - (elod at itfais dot com) -- Fixed bug #31683 (changes to $name in __get($name) override future - parameters) (Dmitry) -- Fixed bug #31699 (unserialize() float problem on non-English locales). (Ilia) -- Fixed bug #31562 (__autoload() problem with static variables). (Marcus) -- Fixed bug #31651 (ReflectionClass::getDefaultProperties segfaults with arrays). - (Marcus) -- Fixed bug #31623 (OCILogin does not support password grace period). - (daniel dot beet at accuratesoftware dot com, Tony) -- Fixed bug #31527 (crash in msg_send() when non-string is stored without - being serialized). (Ilia) -- Fixed bug #31515 (Improve performance of scandir() by factor of 10 or so). (Ilia) -- Fixed bug #31514 (open_basedir uses path_translated rather then cwd for . - translation). (Ilia) -- Fixed bug #31480 (Possible infinite loop in imap_mail_compose()). (Ilia) -- Fixed bug #31479 (Fixed crash in chunk_split(), when chunklen > strlen). (Ilia) -- Fixed bug #31454 (session_set_save_handler crashes PHP when supplied - non-existent object ref). (Tony) -- Fixed bug #31444 (Memory leak in zend_language_scanner.c). - (hexer at studentcenter dot org) -- Fixed bug #31442 (unserialize broken on 64-bit systems). (Marcus) -- Fixed bug #31440 ($GLOBALS can be overwritten via GPC when register_globals - is enabled). (Ilia) -- Fixed bug #31422 (No Error-Logging on SoapServer-Side). (Dmitry) -- Fixed bug #31413 (curl POSTFIELDS crashes on 64-bit platforms). (Joe) -- Fixed bug #31396 (compile fails with gd 2.0.33 without freetype). (Jani) -- Fixed bug #31371 (highlight_file() trims new line after heredoc). (Ilia) -- Fixed bug #31361 (simplexml/domxml segfault when adding node twice). (Rob) -- Fixed bug #31348 (CachingIterator::rewind() leaks). (Marcus) -- Fixed bug #31346 (ArrayIterator::next segfaults). (Marcus) -- Fixed bug #31190 (Unexpected warning then exception is thrown from - call_user_func_array()). (phpbugs at domain51 dot net, Dmitry) -- Fixed bug #31142 (imap_mail_compose() fails to generate correct output). (Ilia) -- Fixed bug #31139 (XML Parser Functions seem to drop & when parsing). (Rob) -- Fixed bug #31398 (When magic_guotes_gpc are enabled filenames with ' get cutoff). - (Ilia) -- Fixed bug #31288 (Possible crash in mysql_fetch_field(), if mysql_list_fields() - was not called previously). (Ilia) -- Fixed bug #31107, #31110, #31111, #31249 (Compile failure of zend_strtod.c). - (Jani) -- Fixed bug #31110 (PHP 4.3.10 does not compile on Tru64 UNIX 5.1B). (Derick) -- Fixed bug #31107 (Compile failure on Solaris 9 (Intel) and gcc 3.4.3). (Derick) -- Fixed bug #31103 (Better error message when c-client cannot be found). (Ilia) -- Fixed bug #31101 (missing kerberos header file path with --with-openssl). (Jani) -- Fixed bug #31098 (isset() / empty() incorrectly return true in dereference of - a string type). (Moriyoshi) -- Fixed bug #31087 (broken php_url_encode_hash macro). (Ilia) -- Fixed bug #31072 (var_export() does not output an array element with an empty - string key). (Derick) -- Fixed bug #31060 (imageftbbox() does not use linespacing parameter). (Jani) -- Fixed bug #31056 (php_std_date() returns invalid formatted date if - y2k_compliance is On). (Ilia) -- Fixed bug #31055 (apache2filter: per request leak proportional to the full - path of the request URI). (kameshj at fastmail dot fm) -- Fixed bug #30901 (can't send cookies with soap envelop). (Dmitry) -- Fixed bug #30871 (Misleading warning message for array_combine()). (Andrey) -- Fixed bug #30868 (evaluated pointer comparison in mbregex causes compile - failure). (Moriyoshi) -- Fixed bug #30862 (Static array with boolean indexes). (Marcus) -- Fixed bug #30726 (-.1 like numbers are not being handled correctly). (Ilia) -- Fixed bug #30725 (PHP segfaults when an exception is thrown in getIterator() - within foreach). (Marcus) -- Fixed bug #30609 (cURL functions bypass open_basedir). (Jani) -- Fixed bug #30446 (apache2handler: virtual() includes files out of sequence) -- Fixed bug #30430 (odbc_next_result() doesn't bind values and that results - in segfault). (pdan-php at esync dot org, Tony) -- Fixed bug #30266 (Invalid opcode 137/1/8). (Marcus) -- Fixed bug #30120 imagettftext() and imagettfbbox() accept too many - parameters). (Jani) -- Fixed bug #30106 (SOAP cannot not parse 'ref' element. Causes Uncaught - SoapFault exception). (Dmitry) -- Fixed bug #29989 (type re_registers redefined in oniguruma.h). (Moriyoshi) -- Fixed bug #28803 (enabled debug causes bailout errors with CLI on AIX - because of fflush() called on already closed filedescriptor). (Tony) -- Fixed bug #29767 (Weird behaviour of __set($name, $value)). (Dmitry) -- Fixed bug #29733 (printf() handles repeated placeholders wrong). - (bugs dot php dot net at bluetwanger dot de, Ilia) -- Fixed bug #29424 (width and height inverted for JPEG2000 files). (Ilia) -- Fixed bug #29329 (configure for mysqli with shared doesn't work). (Georg) -- Fixed bug #29136 (make test - libtool failure on MacOSX). (Jani) -- Fixed bug #28976 (mail(): use "From:" from headers if sendmail_from is empty). - (Jani) -- Fixed bug #28930 (PHP sources pick wrong header files generated by bison). - (eggert at gnu dot org, Jani) -- Fixed bug #28840 (__destruct of a class that extends mysqli not called). - (Marcus) -- Fixed bug #28804 (ini-file section parsing pattern is buggy). - (wendland at scan-plus dot de) -- Fixed bug #28451 (corrupt EXIF headers have unlimited recursive IFD directory - entries). (Andrei) -- Fixed bug #28444 (Cannot access undefined property for object with overloaded - property access). (Dmitry) -- Fixed bug #28442 (Changing a static variables in a class changes it across - sub/super classes.) (Marcus) -- Fixed bug #28324 (HTTP_SESSION_VARS appear when register_long_arrays is - Off). (Tony) -- Fixed bug #28074 (FastCGI: stderr should be written in a FCGI stderr stream). - (chris at ex-parrot dot com) -- Fixed bug #28067 (partially incorrect utf8 to htmlentities mapping). (Derick, - Benjamin Greiner) -- Fixed bug #28041 (SOAP HTTP Digest Access Authentication). (Dmitry) -- Fixed bug #27633 (Double \r problem on ftp_get in ASCII mode on Win32). (Ilia) -- Fixed bug #18613 (Multiple OUs in x509 certificate not handled properly). - (Jani) - -15 Dec 2004, PHP 5.0.3 -- Added the %F modifier to *printf to render a non-locale-aware representation - of a float with the . as decimal seperator. (Derick) -- Fixed error handling in mysqli_multi_query. (Georg) -- Extended the functionality of is_subclass_of() to accept either a class name - or an object as first parameter. (Andrey) -- Fixed potential problems with unserializing invalid serialize data. (Marcus) -- Fixed bug #32076 (ReflectionMethod::isDestructor() always return true). - (Derick, Tony) -- Fixed bug #31034 (Problem with non-existing iconv header file). (Derick) -- Fixed bug #30995 (snmp extension does not build with net-snmp 5.2). (Ilia) -- Fixed bug #30994 (SOAP server unable to handle request with references). - (Dmitry) -- Fixed bug #30990 (allow popen() on *NIX to accept 'b' flag). (Ilia) -- Fixed bug #30967 (properties in extended mysqli classes don't work). (Georg) -- Fixed bug #30928 (When Using WSDL, SoapServer doesn't handle private or - protected properties). (Dmitry) -- Fixed bug #30922 (reflective functions crash PHP when interfaces extend - themselves). (Tony, Dmitry) -- Fixed bug #30904 (segfault when recording soapclient into session). (Tony, - Dmitry) -- Fixed bug #30890 (MySQLi testsuite) -- Fixed bug #30856 (ReflectionClass::getStaticProperties segfaults). (Marcus) -- Fixed bug #30832 ("!" stripped off comments in xml parser). (Rob) -- Fixed bug #30799 (SoapServer doesn't handle private or protected properties). - (Dmitry) -- Fixed bug #30783 (Apache crash when using ReflectionFunction:: - getStaticVariables()). (Marcus) -- Fixed bug #30750 (Meaningful error message when upload directory is not - accessible). (Ilia) -- Fixed bug #30685 (Malformed SOAPClient http header reequest). (Dmitry) -- Fixed bug #30672 (Problem handling exif data in jpeg images at unusual - places). (Marcus) -- Fixed bug #30658 (Ensure that temporary files created by GD are removed). - (Ilia) -- Fixed bug #30645 (def. multi result set support for mysql_connect). (Georg) -- Fixed bug #30637 (compile with pear error). (Antony) -- Fixed bug #30587 (array_multisort doesn't separate zvals before - changing them). (Tony) -- Fixed bug #30572 (crash when comparing SimpleXML attribute to a boolean). - (Andi) -- Fixed bug #30566 (attribute namespace URIs are inconsistent when parsing). - (Rob) -- Fixed bug #30490 (PEAR installation fails). (Antony) -- Fixed bug #30475 (curl_getinfo() may crash in some situations). (Ilia) -- Fixed bug #30442 (segfault when parsing ?getvariable[][ ). (Tony) -- Fixed bug #30388 (rename across filesystems loses ownership and - permission info). (Tony) -- Fixed bug #30387 (stream_socket_client async connect was broken). - (vnegrier at esds dot com, Wez). -- Fixed bug #30381 (Strange results with get_class_vars()). (Marcus) -- Fixed bug #30375 (cal_info() does not work without a parameter). (Ilia) -- Fixed bug #30362 (stream_get_line() not handling end string correctly). - (Ilia) -- Fixed bug #30359 (SOAP client requests have no port in "Host" field). - (Dmitry) -- Fixed bug #30356 (str_ireplace() does not work on all strings). (Ilia) -- Fixed bug #30344 (Reflection::getModifierNames() returns too long strings). - (Marcus) -- Fixed bug #30329 (Error Fetching http body, No Content-Length, connection - closed or chunked data). (Dmitry) -- Fixed bug #30282 (segfault when using unknown/unsupported - session.save_handler and/or session.serialize_handler). (Tony) -- Fixed bug #30281 (Prevent non-wbmp images from being detected as such). - (Ilia) -- Fixed bug #30276 (Possible crash in ctype_digit on large numbers). (Ilia) -- Fixed bug #30230 (exception handler not working with objects). (Marcus) -- Fixed bug #30224 (Sybase date strings are sometimes not null terminated). - (Ilia) -- Fixed bug #30175 (SOAP results aren't parsed correctly). (Dmitry) -- Fixed bug #30147 (OO sqlite_fetch_object did not reset error handler). (Wez) -- Fixed bug #30133 (get_current_user() crashes on Windows). (Edin) -- Fixed bug #30061 (xml_set_start_namespace_decl_handler not called). (Rob) -- Fixed bug #30057 (did not detect IPV6 on FreeBSD 4.1). (Wez) -- Fixed bug #30042 (strtotime does not use second param). (Derick) -- Fixed bug #30027 (Possible crash inside ftp_get()). - (cfield at affinitysolutions dot com) -- Fixed bug #29954 (array_reduce segfaults when initial value is array). (Tony) -- Fixed bug #29883 (isset gives invalid values on strings). (Tony, Dmitry) -- Fixed bug #29801 (Set limit on the size of mmapable data). (Ilia) -- Fixed bug #29557 (strtotime error). (Derick) -- Fixed bug #29418 (double free when openssl_csr_new fails). - (Kamesh Jayachandran). -- Fixed bug #29385 (Soapserver always uses std class). (David, Dmitry) -- Fixed bug #29211 (SoapClient doesn't request wsdl through proxy). (Rob) -- Fixed bug #28817 (Var problem when extending domDocument). (Georg) -- Fixed bug #28599 (strtotime fails with zero base time). (Derick) -- Fixed bug #28598 (Lost support for MS Symbol fonts). (Pierre) -- Fixed bug #28220 (mb_strwidth() returns wrong width values for some hangul - characters). (Moriyoshi) -- Fixed bug #28228 (NULL decimal separator is not being handled correctly). - (Ilia) -- Fixed bug #28209 (strtotime("now")). (Derick) -- Fixed bug #27798 (private / protected variables not exposed by - get_object_vars() inside class). (Marcus) -- Fixed bug #27728 (Can't return within a zend_try {} block or the previous - bailout state isn't restored. (Andi) -- Fixed bug #27183 (Userland stream wrapper segfaults on stream_write). - (Christian) - -23 Sep 2004, PHP 5.0.2 -- Added new boolean (fourth) parameter to array_slice() that turns on the - preservation of keys in the returned array. (Derick) -- Added the sorting flag SORT_LOCALE_STRING to the sort() functions which makes - them sort based on the current locale. (Derick) -- Added interface_exists() and make class_exists() only return true for real - classes. (Andrey) -- Added PHP_EOL constant that contains the OS way of representing newlines. - (Paul Hudson, Derick) -- Implemented periodic PCRE compiled regexp cache cleanup, to avoid memory - exhaustion. (Andrei) -- Renamed SoapClient->__call() to SoapClinet->__soapCall(). (Dmitry) -- Fixed bug with raw_post_data not getting set (Brian) -- Fixed a file-descriptor leak with phpinfo() and other 'special' URLs (Zeev) -- Fixed bug #30209 (ReflectionClass::getMethod() lowercases attribute). - (Marcus) -- Fixed bug #30182 (SOAP module processing WSDL file dumps core). (Dmitry) -- Fixed bug #30045 (Cannot pass big integers (> 2147483647) in SOAP requests). - (Dmitry) -- Fixed bug #29985 (unserialize()/ __PHP_Incomplete_class does not report - correctly class name). (Marcus, Tony) -- Fixed bug #29945 (simplexml_load_file URL limitation 255 char). (Rob) -- Fixed bug #29873 (No defines around pcntl_*priority definitions). (Derick) -- Fixed bug #29844 (SOAP doesn't return the result of a valid SOAP request). - (Dmitry) -- Fixed bug #29842 (soapclient return null value). (Dmitry) -- Fixed bug #29839 (incorrect convert (xml:lang to lang)). (Dmitry) -- Fixed bug #29830 (SoapServer::setClass() should not export non-public - methods). (Dmitry) -- Fixed bug #29828 (Interfaces no longer work). (Marcus) -- Fixed bug #29821 (Fixed possible crashes in convert_uudecode() on invalid - data). (Ilia) -- Fixed bug #29808 (array_count_values() breaks with numeric strings). (Ilia) -- Fixed bug #29805 (HTTP Authentication Issues). (Uwe Schindler) -- Fixed bug #29795 (SegFault with Soap and Amazon's Web Services). (Dmitry) -- Fixed bug #29737 (ip2long should return -1 if IP is 255.255.255.255 and FALSE - on error). (Tony) -- Fixed bug #29711 (Changed ext/xml to default to UTF-8 output). (Rob) -- Fixed bug #29678 (opendir() with ftp:// wrapper segfaults if path does not - have trailing slash). (Ilia) -- Fixed bug #29657 (xml_* functions throw non descriptive error). - (Christian, Rob) -- Fixed bug #29656 (segfault on result and statement properties). (Georg) -- Fixed bug #29566 (foreach/string handling strangeness (crash)). (Dmitry) -- Fixed bug #29447 (Reflection API issues). (Marcus) -- Fixed bug #29296 (Added sslv2 and sslv3 transports). (Wez) -- Fixed bug #29283 (Invalid statement handle in mysqli on execute). (Georg) -- Fixed bug #29913 (parse_url() is now binary safe). (Ilia) -- Fixed bug #27994 (segfault with Soapserver when WSDL-Cache is enabled). - (Dmitry) -- Fixed bug #27791 (Apache 2.0 SAPI build against Apache 2 HEAD). (Joe Orton, - Derick) -- Fixed bug #26737 (private/protected properties not serialized when user - declared method __sleep() exists). E_NOTICE thrown when __sleep() returns - name of non-existing member. (Andrey, Curt) - -12 Aug 2004, PHP 5.0.1 -- Changed destructor mechanism so that destructors are called prior to request - shutdown. (Marcus) -- Rewritten UNIX and Windows install help files. (Documentation Team) -- Updated several libraries bundled with the windows release which now - includes libxml2-2.6.11, libxslt-1.1.7 and iconv-1.9.1. (Rob, Edin) -- Improved and moved ActiveScript SAPI to PECL. (Wez) -- Fixed bug #29606 (php_strip_whitespace() prints to stdout rather then - returning the value). (Ilia) -- Fixed bug #29577 (MYSQLI_CLIENT_FOUND_ROWS undefined) (Georg) -- Fixed bug #29573 (Segmentation fault, when exception thrown within - PHP function called from XSLT). (Christian) -- Fixed bug #29522 (accessing properties without connection) (Georg) -- Fixed bug #29505 (get_class_vars() severely broken when used with arrays). - (Marcus) -- Fixed bug #29490 (.Net object instantiation failed). (Michael Sisolak). -- Fixed bug #29474 (win32: usleep() doesn't work). (Wez) -- Fixed bug #29449 (win32: feof() hangs on empty tcp stream). (Wez) -- Fixed bug #29437 (Possible crash inside array_walk_recursive()). (Ilia) -- Fixed bug #29431 (crash when parsing invalid address; invalid address - returned by stream_socket_recvfrom(), stream_socket_getname()). (Wez) -- Fixed bug #29409 (Segfault in PHP functions called from XSLT). (Rob) -- Fixed unloading of dynamically loaded extensions. - (Marcus, kameshj at fastmail dot fm) -- Fixed bug #29395 (sqlite_escape_string() returns bogus data on empty - strings). (Ilia, Tony) -- Fixed bug #29392 (com_dotnet crashes when echo'ing an object). (Wez) -- Fixed bug #29368 (The destructor is called when an exception is thrown from - the constructor). (Marcus) -- Fixed bug #29354 (Exception constructor marked as both public and protected). - (Marcus) -- Fixed bug #29342 (strtotime() does not handle empty date string properly). - (Ilia) -- Fixed bug #29340 (win32 build produces invalid php_ifx.dll). (Edin) -- Fixed bug #29335 (fetch functions now use MYSQLI_BOTH as default) (Georg) -- Fixed bug #29291 (get_class_vars() return names with NULLs). (Marcus) -- Fixed bug #29264 (gettext extension not working). (Edin) -- Fixed bug #29258 (variant_date_from_timestamp() does not honour - timezone). (Wez) -- Fixed bug #29256 (error when sending large packets on a socket). (Dmitry) -- Fixed bug #29236 (memory error when wsdl-cache is enabled). (Dmitry) -- Fixed bug #29147 (Compile Error in mnoGoSearch functions). (Sergey, Antony) -- Fixed bug #29132 ($_SERVER["PHP_AUTH_USER"] isn't defined). (Stefan) -- Fixed bug #29119 (html_entity_decode() misbehaves with UTF-8). (Moriyoshi) -- 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) -- Fixed bug #28895 (ReflectionClass::isAbstract always returns false). (Marcus) -- Fixed bug #28829 (Thread-unsafety in bcmath elementary values). (Sara) -- Fixed bug #28464 (catch() does not catch exceptions by interfaces). (Marcus) -- Fixed bug #27669 (PHP 5 didn't support all possibilities for calling static - methods dynamically). (Dmitry) -- Fixed ReflectionClass::getMethod() and ReflectionClass::getProperty() to - raise an ReflectionException instead of returning NULL on failure. - (Sebastian) -- Fixed convert.* filters to consume remaining buckets_in on flush. (Sara) -- Fixed bug in mysqli->client_version. (Georg) - -13 Jul 2004, PHP 5.0.0 -- 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 #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 strip_tags() to correctly handle '\0' characters. (Stefan) +<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>> diff --git a/README.GIT-RULES b/README.GIT-RULES index 289a4e743f07e..90e0d83cbed42 100644 --- a/README.GIT-RULES +++ b/README.GIT-RULES @@ -45,14 +45,16 @@ Currently we have the following branches in use:: master The active development branch. - PHP-5.4 Is used to release the PHP 5.4.x series. It still allows for - larger enhancements. + PHP-5.5 Is used to release the PHP 5.5.x series. It allows for larger + enhancements. + + PHP-5.4 Is used to release the PHP 5.4.x series. This is current + stable version and is open for bugfixes only. PHP-5.3 Is used to release the PHP 5.3.x series. This is current stable version and is open for bugfixes only. - PHP-5.2 Is used to release the PHP 5.2.x series. It is closed for - changes now. + PHP-5.2 This branch is closed. PHP-5.1 This branch is closed. diff --git a/README.PARAMETER_PARSING_API b/README.PARAMETER_PARSING_API index 927e48188cc93..edcee0f2eaa09 100644 --- a/README.PARAMETER_PARSING_API +++ b/README.PARAMETER_PARSING_API @@ -28,6 +28,17 @@ Both functions return SUCCESS or FAILURE depending on the result. The auto-conversions are performed as necessary. Arrays, objects, and resources cannot be auto-converted. +PHP 5.5 includes a new function: + +int zend_parse_parameter(int flags, int arg_num TSRMLS_DC, zval **arg, const char *spec, ...); + +This function behaves like zend_parse_parameters_ex() except that instead of +reading the arguments from the stack, it receives a single zval to convert +(passed with double indirection). The passed zval may be changed in place as +part of the conversion process. + +See also https://wiki.php.net/rfc/zpp_improv#expose_zend_parse_arg_as_zend_parse_parameter + Type specifiers --------------- @@ -65,9 +76,13 @@ Type specifiers will not be touched by the parsing function if they are not passed to it. / - use SEPARATE_ZVAL_IF_NOT_REF() on the parameter it follows - ! - the parameter it follows can be of specified type or NULL (applies - to all specifiers except for 'b', 'l', and 'd'). If NULL is passed, the - results pointer is set to NULL as well. + ! - the parameter it follows can be of specified type or NULL. If NULL is + passed and the output for such type is a pointer, then the output + pointer is set to a native NULL pointer. + For 'b', 'l' and 'd', an extra argument of type zend_bool* must be + passed after the corresponding bool*, long* or double* arguments, + respectively. A non-zero value will be written to the zend_bool iif a + PHP NULL is passed. Note on 64bit compatibility diff --git a/README.RELEASE_PROCESS b/README.RELEASE_PROCESS index 3fa944ee3b2ea..2512d3a8b5284 100644 --- a/README.RELEASE_PROCESS +++ b/README.RELEASE_PROCESS @@ -64,9 +64,9 @@ Do not use abbreviations for alpha and beta. ``git push --tags origin HEAD`` 8. run: ``./makedist 5.4.2RC2``, this will export the tree, create configure -and build two tarballs (one gz and one bz2). +and build three tarballs (gz,bz2 and xz). -9. Copy those two tarballs to www.php.net, in your homedir there should be a +9. Copy those three tarballs to www.php.net, in your homedir there should be a directory "downloads/". Copy them into there, so that the system can generate MD5 sums. If you do not have this directory, talk to Derick. diff --git a/README.md b/README.md new file mode 100644 index 0000000000000..51973854db86f --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +The PHP Interpreter +=================== + +This is the github mirror of the official PHP repository located at +http://git.php.net. + +[![Build Status](https://secure.travis-ci.org/php/php-src.png?branch=master)](http://travis-ci.org/php/php-src) + +Pull Requests +============= +PHP accepts pull requests via github. Discussions are done on github, but +depending on the topic can also be relayed to the official PHP developer +mailinglist internals@lists.php.net. + +New features require an RFC and must be accepted by the developers. +See https://wiki.php.net/rfc and https://wiki.php.net/rfc/voting for more +information on the process. + +Bug fixes **do not** require an RFC, but require a bugtracker ticket. Always +open a ticket at http://bugs.php.net and reference the bug id using #NNNNNN. + + Fix #55371: get_magic_quotes_gpc() throws deprecation warning + + After removing magic quotes, the get_magic_quotes_gpc function caused + a deprecate warning. get_magic_quotes_gpc can be used to detected + the magic_quotes behavior and therefore should not raise a warning at any + time. The patch removes this warning + +We do not merge pull requests directly on github. All PRs will be +pulled and pushed through http://git.php.net. diff --git a/UPGRADING b/UPGRADING index 0293a6a660f3e..f7eda53519ca1 100755 --- a/UPGRADING +++ b/UPGRADING @@ -1,817 +1,79 @@ $Id$ -PHP 5.4 UPGRADE NOTES +PHP X.Y UPGRADE NOTES + +1. Backward Incompatible Changes +2. New Features +2. Changes in SAPI modules +3. Deprecated Functionality +4. Changed Functions +5. New Functions +6. New Classes and Interfaces +7. Removed Extensions +8. Other Changes to Extensions +9. New Global Constants +10. Changes to INI File Handling +11. Other Changes -=========== -0. Contents -=========== - -1. Changes to INI directives -2. Changes to reserved words and classes -3. Changes to engine behavior -4. Changes to existing functions -5. Changes to existing classes -6. Changes to existing methods -7. Deprecated Functionality -8. Removed Functionality - a. Removed features - b. Removed functions - c. Removed syntax - d. Removed hash algorithms -9. Extension Changes: - a. Extensions no longer maintained - b. Extensions with changed behavior -10. Changes in SAPI support -11. Windows support -12. New in PHP 5.4: - a. New features - b. Syntax additions - c. New functions - d. New global constants - e. New classes - f. New methods - g. New hash algorithms - -============================= -1. Changes to INI directives -============================= - -- PHP 5.4 now checks at compile time if /dev/urandom or /dev/arandom - are present. If either is available, session.entropy_file now - defaults to that file and session.entropy_length defaults to 32. - This provides non-blocking entropy to session id generation. If you - do not want extra entropy for your session ids, add: - - session.entropy_file= - session.entropy_length=0 - - to your php.ini to preserve pre-PHP 5.4 behavior. - -- Deprecated php.ini directives will now throw an E_CORE_WARNING's - instead of the previous E_WARNING's. - -- The following php.ini directives are no longer available in PHP 5.4 - and will now throw an E_CORE_ERROR upon startup: - - allow_call_time_pass_reference - - define_syslog_variables - - highlight.bg - - magic_quotes_gpc - - magic_quotes_runtime - - magic_quotes_sybase - - register_globals - - register_long_arrays - - safe_mode - - safe_mode_gid - - safe_mode_include_dir - - safe_mode_exec_dir - - safe_mode_allowed_env_vars - - safe_mode_protected_env_vars - - session.bug_compat_42 - - session.bug_compat_warn - - y2k_compliance - - zend.ze1_compatibility_mode - -- the following new php.ini directives were added: - - max_input_vars - specifies how many GET/POST/COOKIE input - variables may be accepted. The default value is 1000. - -- E_ALL now includes E_STRICT. - -- The recommended production value for error_reporting changed to E_ALL & - ~E_DEPRECATED & ~E_STRICT. - -- Added new session support directives: - session.upload_progress.enabled - session.upload_progress.cleanup - session.upload_progress.prefix - session.upload_progress.name - session.upload_progress.freq - session.upload_progress.min_freq - -- Added a zend.multibyte directive as a replacement of the PHP compile time - configuration option --enable-zend-multibyte. Now the Zend Engine always - contains code for multibyte support, which can be enabled or disabled at - runtime. Note: It doesn't make a lot of sense to enable this option if - ext/mbstring is not enabled, because most functionality is implemented by - mbstrings callbacks. - -- Added zend.script_encoding. This value will be used unless a - "declare(encoding=...)" directive appears at the top of the script. - -- Added zend.signal_check to check for replaced signal handlers on shutdown - -- Added enable_post_data_reading, which is enabled by default. When it's - disabled, the POST data is not read (or processed); the behavior is similar - to that of other request methods with body, like PUT. This allows reading - the raw POST data in multipart requests and reading/processing the POST data - in a stream fashion (through php://input) without having it copied in memory - multiple times. - -- Added windows_show_crt_warning. This directive shows the CRT warnings when - enabled. These warnings were displayed by default until now. It is disabled - by default. - -- Added cli.pager to set a pager for CLI interactive shell output. - -- Added cli.prompt to configure the CLI interactive shell prompt. - -- Added cli_server.color to enable the CLI web server to use ANSI color coding - in terminal output. ======================================== -2. Changes to reserved words and classes +1. Backward Incompatible Changes ======================================== -- "callable", "insteadof" and "trait" are now reserved words. - -============================= -3. Changes to engine behavior -============================= - -- The __construct arguments of an extended abstract constructor must - now match: - - abstract class Base - { - abstract public function __construct(); - } - class Foo extends Base - { - public function __construct($bar) {} - } - - This now emits a Fatal error due the incompatible declaration. - -- In previous versions, superglobal names could be used for parameter - names, thereby shadowing the corresponding superglobal. In PHP 5.4 - this now causes a fatal error such as "Cannot re-assign auto-global - variable GLOBALS". - -- Turning null, false or an empty string into an object by adding a - property will now emit a warning instead of an E_STRICT error. - - $test = null; - $test->baz = 1; - - To create a generic object you can use StdClass: - - $test = new StdClass; - $test->baz = 1; - -- Converting an array to a string now will cause an E_NOTICE warning. - -- Non-numeric string offsets, e.g. $a['foo'] where $a is a string, now - return false on isset() and true on empty(), and produce warning if - trying to use them. Offsets of types double, bool and null produce - notice. Numeric strings ($a['2']) still work as before. - - Note that offsets like '12.3' and '5 and a half' are considered - non-numeric and produce warning, but are converted to 12 and 5 - respectively for backwards compatibility reasons. - -- Long numeric strings that do not fit in integer or double (such as - "92233720368547758070") are compared using string comparison if - they could otherwise result in precision loss - since 5.4.4. - -- Closures now support scopes and $this and can be rebound to - objects using Closure::bind() and Closure::bindTo(). - -- 1; it doesn't merely - decrement the resource refcount. - -- socket_set_options() and socket_get_options() now support multicast options. - -- The raw data parameter in openssl_encrypt() and openssl_decrypt() is now an - options integer rather than a boolean. A value of true produces the same - behavior. - -- Write operations within XSLT (for example with the extension sax:output) are - disabled by default. You can define what is forbidden with the method - XsltProcess::setSecurityPrefs($options). - -- Added AES support to OpenSSL. - -- openssl_csr_new() expects the textual data to be in UTF-8. - -- Added no-padding option to openssl_encrypt() and openssl_decrypt(). - -- Added a "no_ticket" SSL context option to disable the SessionTicket TLS - extension. - -- Added new json_encode() options: JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, - JSON_NUMERIC_CHECK, JSON_BIGINT_AS_STRING, JSON_UNESCAPED_UNICODE. - -- Added Tokyo Cabinet and Berkley DB 5 support to DBA extension. - -- Added support for CURLOPT_MAX_SEND_SPEED_LARGE and CURLOPT_MAX_RECV_SPEED_LARGE - to cURL. - -- Added optional argument to debug_backtrace() and debug_print_backtrace() - to limit the amount of stack frames returned. - -- Fixed crypt_blowfish handling of 8-bit characters. crypt() in Blowfish mode - now supports hashes marked $2a$, $2x$, $2y$ and $2z$. - -- mbstring now supports following encodings: Shift_JIS/UTF-8 Emoji, - JIS X0213:2004 (Shift_JIS-2004, EUC-JP-2004, ISO-2022-JP-2004), - MacJapanese (Shift_JIS), gb18030. - -- Added encode and decode in hex format to mb_encode_numericentity() and - mb_decode_numericentity(). - -- Added support for SORT_NATURAL and SORT_FLAG_CASE in array sort functions: - sort(), rsort(), ksort(), krsort(), asort(), arsort() and array_multisort(). - -- is_a() and is_subclass_of() now have third boolean parameter, which specifies - if the first argument can be a string class name. Default if false for is_a - and true for is_subclass_of() for BC reasons. - -- ob_start() will now treat a chunk size of 1 as meaning 1 byte, rather than - the previous special case behavior of treating it as 4096 bytes. - -- idn_to_ascii() and idn_to_utf8() now take two extra parameters, one indicating - the variant (IDNA 2003 or UTS #46) and another, passed by reference, to return - details about the operation in case UTS #46 is chosen. - -- gzencode() used with FORCE_DEFLATE now generates RFC1950 compliant data. - -- ob_start() no longer starts multiple output buffers when passed - array("callback1", "callback2", "callback3", ...). - -- Since 5.4.4, "php://fd" stream syntax is available only in CLI build. - -- Since 5.4.5, resourcebundle_create() accepts null for the first two arguments. - -- Since 5.4.6, SimpleXMLElement::getDocNamespaces() has and extra parameter which - allows for toggling if the list of namespaces starts from the document root - or from the node you call the method on - -- Since 5.4.7, ctor is always called when new user stream wrapper object is created. - Before, it was called only when stream_open was called. - -============================== -5. Changes to existing classes -============================== - -- Classes that implement stream wrappers can define a method called - stream_truncate that will respond to truncation, e.g. through ftruncate. - Strictly speaking, this is an addition to the user-space stream wrapper - template, not a change to an actual class. - -- Classes that implement stream wrappers can define a method called - stream_metadata that will be called on touch(), chmod(), chgrp(), chown(). - -- Arrays cast from SimpleXMLElement now always contain all nodes instead of - just the first matching node. -- All SimpleXMLElement children are now always printed when using var_dump(), - var_export(), and print_r(). - -- Added iterator support in MySQLi. mysqli_result implements Traversable. - -============================== -6. Changes to existing methods -============================== - -- DateTime::parseFromFormat() now has a "+" modifier to allow trailing text in - the string to parse without throwing an error. - -- Added the ability to pass options to DOMDocument::loadHTML(). - -- FilesystemIterator, GlobIterator and (Recursive)DirectoryIterator now use - the default stream context. - -- Since 5.4.5, the constructor of ResourceBundle accepts NULL for the first two - arguments. - -=========================== -7. Deprecated Functionality -=========================== - -- The following functions are deprecated in PHP 5.4: - - mcrypt_generic_end(): use mcrypt_generic_deinit() instead - - mysql_list_dbs() - -======================== -8. Removed Functionality -======================== - -a. Removed features - - The following features have been removed from PHP 5.4: - - - Magic quotes - - Register globals - - Safe mode - - Session extension bug compatibility mode - - Y2K compliance mode - -b. Removed functions - - The following functions are no longer available in PHP 5.4: - - - define_syslog_variables() - - import_request_variables() - - session_is_registered() - - session_register() - - session_unregister() - - set_magic_quotes_runtime() - - mysqli_bind_param() (alias of mysqli_stmt_bind_param()) - - mysqli_bind_result() (alias of mysqli_stmt_bind_result()) - - mysqli_client_encoding() (alias of mysqli_character_set_name()) - - mysqli_fetch() (alias of mysqli_stmt_fetch()) - - mysqli_param_count() (alias of mysqli_stmt_param_count()) - - mysqli_get_metadata() (alias of mysqli_stmt_result_metadata()) - - mysqli_send_long_data() (alias of mysqli_stmt_send_long_data()) - - mysqli::client_encoding() (alias of mysqli::character_set_name) - - mysqli_stmt::stmt() (never worked/always throws, undocumented) - -c. Removed syntax - - - break $var; - - continue $var; - -d. Removed hash algorithms - - - Salsa10 and Salsa20, which are actually stream ciphers - -==================== -9. Extension Changes -==================== - -a. Extensions no longer maintained - - - ext/sqlite is no longer part of the base distribution and has been moved - to PECL. Use sqlite3 or PDO_SQLITE instead. - -b. Extensions with changed behavior - - - The MySQL extensions (ext/mysql, mysqli and PDO_MYSQL) use mysqlnd - as the default library now. It is still possible to use libmysql by - specifying a path to the configure options. - - - PDO_MYSQL: Support for linking with MySQL client libraries older - than 4.1 is removed. - - - The session extension now can hook into the file upload feature - in order to provide upload progress information through session - variables. - - - SNMP extension - - Functions in SNMP extension now returns FALSE on every error - condition including SNMP-related (no such instance, end of MIB, - etc). Thus, in patricular, breaks previous behavior of get/walk - functions returning an empty string on SNMP-related errors. - - Multi OID get/getnext/set queries are now supported. - - New constants added for use in snmp_set_oid_output_format() - function. - - Function snmp_set_valueretrieval() changed it's behavior: - SNMP_VALUE_OBJECT can be combined with one of - SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY resulting OID value - changes. When no SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY - is supplied with SNMP_VALUE_OBJECT, SNMP_VALUE_LIBRARY is used. - Prior to 5.4.0 when no SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY - was supplied with SNMP_VALUE_OBJECT, SNMP_VALUE_PLAIN was used. - - Added feature-rich OO API (SNMP class) - - Dropped UCD-SNMP compatibility code. Consider upgrading to - net-snmp v5.3+. Net-SNMP v5.4+ is required for Windows version. - - In sake of adding support for IPv6 DNS name resolution of - remote SNMP agent (peer) is done by extension now, not by Net-SNMP - library anymore. - - - Date extension - - Setting the timezone with the TZ environment variable is no longer - supported, instead date.timezone and/or date_default_timezone_set() - have to be used. - - The extension will no longer guess the default timezone if none - is set with date.timezone and/or date_default_timezone_set(). - Instead it will always fall back to "UTC". - - - Hash extension - - the output of the tiger hash family has been corrected, see - https://bugs.php.net/61307 - -=========================== -10. Changes in SAPI support -=========================== - -- A REQUEST_TIME_FLOAT value returns a floating point number indicating the - time with microsecond precision. All SAPIs providing this value should be - returning float and not time_t. - -- apache_child_terminate(), getallheaders(), apache_request_headers() - and apache_response_headers() are now supported on FastCGI. - -- The interactive shell allows a shortcut #inisetting=value to change php.ini - settings at run-time. - -- The interactive shell now works with the shared readline extension. - -- The interactive shell no longer terminates on fatal errors. - -- A new PHP CLI command line option --rz shows information about the - named Zend extension. - -=================== -11. Windows support -=================== - -- is_link now works properly for symbolic links on Windows Vista - or later. Earlier systems do not support symbolic links. - -- As of PHP 5.4.5 and above the COM extension isn't compiled statically in PHP - anymore but shared. It'll still be delivered with the standard PHP release but - must be activated manually with the "extension = php_com_dotnet.dll" directive - in php.ini. - -- Apache 2.4 handler is supported as of PHP 5.4.9 - -================== -12. New in PHP 5.4 -================== - -a. New Features - - - A built-in CLI web server for testing purposes is now available: - $ php -S 127.0.0.1:8888 - - - File Upload Progress support is implemented in the Session extension. - -b. Syntax additions - - - Traits: - trait HelloWorld { - public function sayHello() { - echo 'Hello World!'; - } - } - - class CanIGetHello { - use HelloWorld; - } - - $hello = new CanIGetHello(); - $hello->sayHello(); - - - Function call result array access, e.g.: - foo()[0] - $foo->bar()[0] - - - Callable typehint indicating argument must be callable: - function foo(callable $do) { - } - foo("strcmp"); - foo(function() {}); - $o = new ArrayObject(); - foo(array($o, "count")); - - - Short array syntax: - $a = [1, 2, 3, 4]; - $a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4]; - $a = ['one' => 1, 2, 'three' => 3, 4]; - - - Binary number format: - 0b00100 0b010101 - - - Chained string array offsets now work. - $a = "abc"; - echo $a[0][0]; - - - Anonymous functions now support using $this and class scope. - Anonymous function can be declared as "static" to ignore the scope. - - - Class::{expr}() syntax is now supported: - class A { - static function foo() { - echo "Hello world!\n"; - } - } - $x = "f"; - $y = "o"; - A::{$x.$y.$y}(); - - - Class member access on instantiation: - (new foo)->method() - (new foo)->property - (new foo)[0] - - -c. New functions - - - Core: - - get_declared_traits() - - getimagesizefromstring() - - hex2bin() - - header_register_callback() - - http_response_code() - - stream_set_chunk_size() - - socket_import_stream() - - trait_exists() - - - Intl: - - transliterator_create() - - transliterator_create_from_rules() - - transliterator_create_inverse() - - transliterator_get_error_code() - - transliterator_get_error_message() - - transliterator_list_ids() - - transliterator_transliterate() - - - LDAP: - - ldap_control_paged_result() - - ldap_control_paged_result_response() - - - libxml: - - libxml_set_external_entity_loader() - - - mysqli: - - mysqli_error_list() - - mysqli_stmt_error_list() - - - pgsql - - pg_escape_identifier() (5.4.4) - - pg_escape_literal() (5.4.4) +======================================== +2. New Features +======================================== - - Session: - - session_register_shutdown() - - session_status() - - SPL - - class_uses() +======================================== +2. Changes in SAPI modules +======================================== -d. New global constants - - CURLOPT_MAX_RECV_SPEED_LARGE - - CURLOPT_MAX_SEND_SPEED_LARGE - - ENT_DISALLOWED - - ENT_HTML401 - - ENT_HTML5 - - ENT_SUBSTITUTE - - ENT_XHTML - - ENT_XML1 - - IPPROTO_IP - - IPPROTO_IPV6 - - IPV6_MULTICAST_HOPS - - IPV6_MULTICAST_IF - - IPV6_MULTICAST_LOOP - - IP_MULTICAST_IF - - IP_MULTICAST_LOOP - - IP_MULTICAST_TTL - - JSON_BIGINT_AS_STRING - - JSON_OBJECT_AS_ARRAY - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_UNESCAPED_UNICODE - - LIBXML_HTML_NODEFDTD - - LIBXML_HTML_NOIMPLIED - - LIBXML_PEDANTIC - - MCAST_JOIN_GROUP - - MCAST_LEAVE_GROUP - - MCAST_BLOCK_SOURCE - - MCAST_UNBLOCK_SOURCE - - MCAST_JOIN_SOURCE_GROUP - - MCAST_LEAVE_SOURCE_GROUP - - OPENSSL_CIPHER_AES_128_CBC - - OPENSSL_CIPHER_AES_192_CBC - - OPENSSL_CIPHER_AES_256_CBC - - OPENSSL_RAW_DATA - - OPENSSL_ZERO_PADDING - - PHP_OUTPUT_HANDLER_CLEAN - - PHP_OUTPUT_HANDLER_CLEANABLE - - PHP_OUTPUT_HANDLER_DISABLED - - PHP_OUTPUT_HANDLER_FINAL - - PHP_OUTPUT_HANDLER_FLUSH - - PHP_OUTPUT_HANDLER_FLUSHABLE - - PHP_OUTPUT_HANDLER_REMOVABLE - - PHP_OUTPUT_HANDLER_STARTED - - PHP_OUTPUT_HANDLER_STDFLAGS - - PHP_OUTPUT_HANDLER_WRITE - - PHP_QUERY_RFC1738 - - PHP_QUERY_RFC3986 - - PHP_SESSION_ACTIVE - - PHP_SESSION_DISABLED - - PHP_SESSION_NONE - - SCANDIR_SORT_ASCENDING - - SCANDIR_SORT_DESCENDING - - SCANDIR_SORT_NONE - - SORT_FLAG_CASE - - SORT_NATURAL - - STREAM_META_ACCESS - - STREAM_META_GROUP - - STREAM_META_GROUP_NAME - - STREAM_META_OWNER - - STREAM_META_OWNER_NAME - - STREAM_META_TOUCH - - T_CALLABLE - - T_INSTEADOF - - T_TRAIT - - T_TRAIT_C - - ZLIB_ENCODING_DEFLATE - - ZLIB_ENCODING_GZIP - - ZLIB_ENCODING_RAW - - U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR - - IDNA_CHECK_BIDI - - IDNA_CHECK_CONTEXTJ - - IDNA_NONTRANSITIONAL_TO_ASCII - - IDNA_NONTRANSITIONAL_TO_UNICODE - - INTL_IDNA_VARIANT_2003 - - INTL_IDNA_VARIANT_UTS46 - - IDNA_ERROR_EMPTY_LABEL - - IDNA_ERROR_LABEL_TOO_LONG - - IDNA_ERROR_DOMAIN_NAME_TOO_LONG - - IDNA_ERROR_LEADING_HYPHEN - - IDNA_ERROR_TRAILING_HYPHEN - - IDNA_ERROR_HYPHEN_3_4 - - IDNA_ERROR_LEADING_COMBINING_MARK - - IDNA_ERROR_DISALLOWED - - IDNA_ERROR_PUNYCODE - - IDNA_ERROR_LABEL_HAS_DOT - - IDNA_ERROR_INVALID_ACE_LABEL - - IDNA_ERROR_BIDI - - IDNA_ERROR_CONTEXTJ +======================================== +3. Deprecated Functionality +======================================== -e. New classes - - Reflection: - - ReflectionZendExtension +======================================== +4. Changed Functions +======================================== - - Intl: - - Transliterator - - Spoofchecker +- cURL: + CURLOPT_SAFE_UPLOAD is now turned on by default and uploads with @file + do not work unless it is explicitly set to false. - - JSON: - - JsonSerializable +======================================== +5. New Functions +======================================== - - Session: - - SessionHandler - - SNMP: - - SNMP +======================================== +6. New Classes and Interfaces +======================================== - - SPL: - - CallbackFilterIterator - - RecursiveCallbackFilterIterator -f. New methods +======================================== +7. Removed Extensions +======================================== - - Closure: - - Closure::bind() - - Closure::bindTo() - - Reflection: - - ReflectionClass::getTraitAliases() - - ReflectionClass::getTraitNames() - - ReflectionClass::getTraits() - - ReflectionClass::isCloneable() - - ReflectionClass::isTrait() - - ReflectionClass::newInstanceWithoutConstructor() - - ReflectionExtension::isPersistent() - - ReflectionExtension::isTemporary() - - ReflectionFunction::getClosure() - - ReflectionFunction::getClosureScopeClass() - - ReflectionFunction::getClosureThis() - - ReflectionFunctionAbstract::getClosureScopeClass() - - ReflectionFunctionAbstract::getClosureThis() - - ReflectionMethod::getClosure() - - ReflectionMethod::getClosureScopeClass() - - ReflectionMethod::getClosureThis() - - ReflectionObject::getTraitAliases() - - ReflectionObject::getTraitNames() - - ReflectionObject::getTraits() - - ReflectionObject::isCloneable() - - ReflectionObject::isTrait() - - ReflectionObject::newInstanceWithoutConstructor() - - ReflectionParameter::canBePassedByValue() - - ReflectionParameter::isCallable() +======================================== +8. Other Changes to Extensions +======================================== - - PDO_DBLIB: - - PDO::newRowset() - - SPL: - - DirectoryIterator::getExtension() - - RegexIterator::getRegex() - - SplDoublyLinkedList::serialize() - - SplDoublyLinkedList::unserialize() - - SplFileInfo::getExtension() - - SplFileObject::fputcsv() - - SplObjectStorage::getHash() - - SplQueue::serialize - - SplQueue::unserialize - - SplStack::serialize - - SplStack::unserialize - - SplTempFileObject::fputcsv +======================================== +9. New Global Constants +======================================== - - XSLT: - - XsltProcessor::setSecurityPrefs() - - XsltProcessor::getSecurityPrefs() +======================================== +10. Changes to INI File Handling +======================================== - - Zlib: - - zlib_decode() - - zlib_encode() -g. New Hash algorithms +======================================== +11. Other Changes +======================================== - - fnv132 - - fnv164 - - joaat diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index e9d0adf5541f6..90c7a4394fd5d 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -3,15 +3,8 @@ $Id$ UPGRADE NOTES - PHP X.Y 1. Internal API changes - a. virtual_file_ex - b. stat/lstat support - c. readlink support - d. layout of some core ZE structures (zend_op_array, zend_class_entry, ...) - e. Zend\zend_fast_cache.h has been removed - f. streams that enclose private streams - g. leak_variable - h. API Signature changes - i. new TSRM function expand_filepath_with_mode + a. Streams pooling API + b. Lowercasing and locales 2. Build system changes a. Unix build system changes @@ -22,186 +15,51 @@ UPGRADE NOTES - PHP X.Y 1. Internal API changes ======================== - a. virtual_file_ex + a. Streams pooling API -virtual_file_ex takes now a TSRM context as last parameter: -CWD_API int virtual_file_ex(cwd_state *state, const char *path, - verify_path_func verify_path, int use_realpath TSRLS_DC); +The streams pooling API has been removed. The following functions no longer +exist: +PHPAPI int php_stream_context_get_link(php_stream_context *context, + const char *hostent, php_stream **stream); +PHPAPI int php_stream_context_set_link(php_stream_context *context, + const char *hostent, php_stream *stream); +PHPAPI int php_stream_context_del_link(php_stream_context *context, + php_stream *stream); - b. stat/lstat support + b. Lowercasing and locales -lstat is now available on all platforms. On unix-like platform -php_sys_lstat is an alias to lstat (when avaible). On Windows it is now -available using php_sys_lstat. php_sys_stat and php_sys_lstat usage is recommended -instead of calling lstat directly, to ensure portability. +The lowercasing functions in zend_operators.c were split into those that do +lowercasing according to locale rules and those that do ASCII lowercasing. +ASCII: + zend_str_tolower_copy + zend_str_tolower_dup + zend_str_tolower + zend_binary_strcasecmp + zend_binary_strncasecmp - c. readlink support +Locale-based: + zend_binary_strncasecmp_l + zend_binary_strcasecmp_l + zend_binary_zval_strcasecmp + zend_binary_zval_strncasecmp + string_compare_function_ex + string_case_compare_function -readlink is now available on all platforms. On unix-like platform -php_sys_readlink is an alias to readlink (when avaible). On Windows it is now -available using php_sys_readlink. php_sys_readlink usage is recommended -instead of calling readlink directly, to ensure portability. +Internal engine lowercasing will be using ASCII-only rules. User-facing functions, +such as strcasecmp, will be using locale rules. - - d. layout of some core ZE structures (zend_op_array, zend_class_entry, ...) - -. zend_function.pass_rest_by_reference is replaced by - ZEND_ACC_PASS_REST_BY_REFERENCE in zend_function.fn_flags -. zend_function.return_reference is replaced by ZEND_ACC_RETURN_REFERENCE - in zend_function.fn_flags -. zend_arg_info.required_num_args removed. it was needed only for internal - functions. Now the first arg_info for internal function (which has special - meaning) is represented by zend_internal_function_info structure. -. zend_op_array.size, size_var, size_literal, current_brk_cont, - backpatch_count moved into CG(context), because they are used only during - compilation. -. zend_op_array.start_op is moved into EG(start_op), because it's used - only for 'interactive' execution of single top-level op-array. -. zend_op_array.done_pass_two is replaced by ZEND_ACC_DONE_PASS_TWO in - zend_op_array.fn_flags. -. op_array.vars array is trimmed (reallocated) during pass_two. -. zend_class_entry.constants_updated is replaced by - ZEND_ACC_CONSTANTS_UPDATED in zend_class_entry.ce_flags -. the size of zend_class_entry is reduced by sharing the same memory space - by different information for internal and user classes. - See zend_class_inttry.info union. - - - e. Zend\zend_fast_cache.h - -It should not have been used anymore since php5, but now this header has -been removed. The following macros are not available anymore: - -ZEND_FAST_ALLOC(p, type, fc_type) -ZEND_FAST_FREE(p, fc_type) -ZEND_FAST_ALLOC_REL(p, type, fc_type) -ZEND_FAST_FREE_REL(p, fc_type) - -Use emalloc, emalloc_rel, efree or efree_rel instead. - - - f. Streams that enclose private streams - -Some streams, like the temp:// stream, may enclose private streams. If the -outer stream leaks due to a programming error or is not exposed through a -zval (and therefore is not deleted when all the zvals are gone), it will -be destroyed on shutdown. -The problem is that the outer usually wants itself to close the inner stream, -so that it may do any other shutdown action that requires the inner stream to -be live (e.g. commit data to it). If the outer stream is exposed through a -zval and the inner one isn't, this is not a problem because the outer stream -will be freed when the zval is destroyed, which happens before the resources -are destroyed on shutdown. -On resource list shutdown, the cleanup happens in reverse order of resource -creation, so if the inner stream was created in the opener of the outer stream, -it will be destroyed first. -The following functions were added to the streams API to force a predictable -destruction order: - -PHPAPI php_stream *php_stream_encloses(php_stream *enclosing, php_stream *enclosed); -#define php_stream_free_enclosed(stream_enclosed, close_options) -PHPAPI int _php_stream_free_enclosed(php_stream *stream_enclosed, int close_options TSRMLS_DC); - -Additionally, the following member was added to php_stream: - - struct _php_stream *enclosing_stream; - -and the following macro was added: - -#define PHP_STREAM_FREE_IGNORE_ENCLOSING 32 - -The function php_stream_encloses declares the first stream encloses the second. -This has the effect that, when the inner stream is closed from a resource -destructor it will abort and try to free its enclosing stream instead. -To prevent this from happening when the inner stream is freed from the outer -stream, the macro php_stream_free_enclosed should be used instead of -php_stream_free/php_stream_close/php_stream_pclose, or the flag -PHP_STREAM_FREE_IGNORE_ENCLOSING should be directly passed to php_stream_free. -The outer stream cannot abstain, in its close callback, from closing the inner -stream or clear the enclosing_stream pointer in its enclosed stream by calling -php_stream_encloses with the 2nd argument NULL. If this is not done, there will -be problems, so observe this requirement when using php_stream_encloses. - - - g. leak_variable - -The function leak_variable(variable [, leak_data]) was added. It is only -available on debug builds. It increments the refcount of a zval or, if the -second argument is true and the variable is either an object or a resource -it increments the refcounts of those objects instead. - - - h. API Signature changes - -. zend_list_insert - ZEND_API int zend_list_insert(void *ptr, int type TSRMLS_DC); - call: zend_list_insert(a, SOMETYPE TSRMLS_CC); - NB: If zend_list_insert is used to register a resource, - ZEND_REGISTER_RESOURCE could be used instead. - -. php_le_stream_context(TSRMLS_C) - PHPAPI php_stream_context *php_stream_context_alloc(TSRMLS_D) - call: context = php_stream_context_alloc(TSRMLS_C); - -. php_stream_context_alloc - PHPAPI php_stream_context *php_stream_context_alloc(TSRMLS_D); - call: context = php_stream_context_alloc(TSRMLS_C); - -. sapi_get_request_time(TSRMLS_D); - SAPI_API double sapi_get_request_time(TSRMLS_D); - -. sapi_register_default_post_reader - SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D) TSRMLS_DC); - -. sapi_register_treat_data - SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC) TSRMLS_DC); - -. sapi_register_input_filter - SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC), unsigned int (*input_filter_init)(TSRMLS_D) TSRMLS_DC); - -. tsrm_win32_access - TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC); - -. popen_ex (win32) - TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env TSRMLS_DC); - -. php_get_current_user - PHPAPI php_get_current_user(TSRMLS_D) - Call: char *user = php_get_current_user(TSRMLS_C); - -. php_idate - PHPAPI php_idate(char format, time_t ts, int localtime TSRMLS_DC) - Call: int ret = php_idate(format, ts, localtime TSRMLS_CC) - -. php_escape_html_entities - (size_t parameters were ints, previous "quote_style" (now flags) has expanded meaning) - PHPAPI char *php_escape_html_entities(unsigned char *old, size_t oldlen, size_t *newlen, int all, int flags, char *hint_charset TSRMLS_DC); - -. php_escape_html_entities_ex - PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size_t *newlen, int all, int flags, char *hint_charset, zend_bool double_encode TSRMLS_DC); - -. php_unescape_html_entities - PHPAPI char *php_unescape_html_entities(unsigned char *old, size_t oldlen, size_t *newlen, int all, int flags, char *hint_charset TSRMLS_DC); - - i. - PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len, int realpath_mode TSRMLS_DC); - expand_filepath_with_mode lets define how realpath will behave, using one of the existing mode: CWD_EXPAND , CWD_FILEPATH or CWD_REALPATH. +Two new functions - zend_binary_strncasecmp_l and zend_binary_strcasecmp_l - added as +locale-based counterparts to zend_binary_strcasecmp and zend_binary_strncasecmp. ======================== 2. Build system changes ======================== a. Unix build system changes - - - Changes in SAPI module build: - . When adding new binary SAPI (executable, like CLI/CGI/FPM) use CLI config.m4 and Makefile.frag files as templates and replace CLI/cli with your SAPI name. - - - New macros: - . PHP_INIT_DTRACE(providerdesc, header-file, sources [, module]) - + - b. Windows build system changes - - + - Drop Windows XP and 2003 support. diff --git a/Zend/Makefile.am b/Zend/Makefile.am index 5ec4590fefe19..6417f3eb141ed 100644 --- a/Zend/Makefile.am +++ b/Zend/Makefile.am @@ -17,7 +17,8 @@ libZend_la_SOURCES=\ zend_objects_API.c zend_ts_hash.c zend_stream.c \ zend_default_classes.c \ zend_iterators.c zend_interfaces.c zend_exceptions.c \ - zend_strtod.c zend_closures.c zend_float.c zend_string.c zend_signal.c + zend_strtod.c zend_closures.c zend_float.c zend_string.c zend_signal.c \ + zend_generators.c libZend_la_LDFLAGS = libZend_la_LIBADD = @ZEND_EXTRA_LIBS@ @@ -31,7 +32,7 @@ zend_ini_scanner.lo: zend_ini_parser.h # Language parser/scanner rules zend_language_scanner.c: $(srcdir)/zend_language_scanner.l - $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt $(srcdir)/zend_language_scanner_defs.h -o$@ $(srcdir)/zend_language_scanner.l + $(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt $(srcdir)/zend_language_scanner_defs.h -o$@ $(srcdir)/zend_language_scanner.l zend_language_parser.h: zend_language_parser.c zend_language_parser.c: $(srcdir)/zend_language_parser.y @@ -43,7 +44,7 @@ zend_ini_parser.c: $(srcdir)/zend_ini_parser.y $(YACC) -p ini_ -v -d $(srcdir)/zend_ini_parser.y -o zend_ini_parser.c zend_ini_scanner.c: $(srcdir)/zend_ini_scanner.l - $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt $(srcdir)/zend_ini_scanner_defs.h -o$@ $(srcdir)/zend_ini_scanner.l + $(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt $(srcdir)/zend_ini_scanner_defs.h -o$@ $(srcdir)/zend_ini_scanner.l zend_ini_parser.h: zend_ini_parser.c diff --git a/Zend/Zend.dsp b/Zend/Zend.dsp index ebe01978c4e1e..23ebd4532b5e7 100644 --- a/Zend/Zend.dsp +++ b/Zend/Zend.dsp @@ -159,6 +159,10 @@ SOURCE=.\zend_float.c # End Source File # Begin Source File +SOURCE=.\zend_generators.c +# End Source File +# Begin Source File + SOURCE=.\zend_hash.c # End Source File # Begin Source File diff --git a/Zend/ZendTS.dsp b/Zend/ZendTS.dsp index 3494cd4e17ff8..3be2c58bed6fa 100644 --- a/Zend/ZendTS.dsp +++ b/Zend/ZendTS.dsp @@ -185,6 +185,10 @@ SOURCE=.\zend_extensions.c # End Source File # Begin Source File +SOURCE=.\zend_generators.c +# End Source File +# Begin Source File + SOURCE=.\zend_hash.c # End Source File # Begin Source File diff --git a/Zend/tests/bug18556.phpt b/Zend/tests/bug18556.phpt new file mode 100644 index 0000000000000..036abb2ada873 --- /dev/null +++ b/Zend/tests/bug18556.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #18556 (Setting locale to 'tr_TR' lowercases class names) +--FILE-- +foo = "Foo"; + } +} + +echo "Instantiating an infoBlob with a lowercase i\n"; +$foobar = new infoBlob(); +echo $foobar->foo; +echo "\nInstantiating an InfoBlob with an uppercase I\n"; +$foobar = new InfoBlob(); +echo $foobar->foo; +echo "\n"; +setlocale(LC_ALL, "tr_TR.utf8"); +foreach(get_declared_classes() as $class) +{ + if(!class_exists($class)) + echo "$class No Longer Exists!\n"; + +} +echo "Done.\n"; +?> +--EXPECT-- +Instantiating an infoBlob with a lowercase i +Foo +Instantiating an InfoBlob with an uppercase I +Foo +Done. diff --git a/Zend/tests/bug60738.phpt b/Zend/tests/bug60738.phpt new file mode 100644 index 0000000000000..e4080715ec72a --- /dev/null +++ b/Zend/tests/bug60738.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #60738 Allow 'set_error_handler' to handle NULL +--FILE-- + +--EXPECTF-- +NULL +Intercepted error! +object(Closure)#1 (0) { +} + +Notice: Error! in %s on line %d diff --git a/Zend/tests/bug60738_variation.phpt b/Zend/tests/bug60738_variation.phpt new file mode 100644 index 0000000000000..d7cf00ecdbc48 --- /dev/null +++ b/Zend/tests/bug60738_variation.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #60738 Allow 'set_error_handler' to handle NULL +--FILE-- + +--EXPECTF-- +NULL +object(Closure)#1 (0) { +} + +Fatal error: Uncaught exception 'Exception' with message 'Exception!' in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d + diff --git a/Zend/tests/bug60833.phpt b/Zend/tests/bug60833.phpt new file mode 100644 index 0000000000000..deb6c0f691603 --- /dev/null +++ b/Zend/tests/bug60833.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #60833 (self, parent, static behave inconsistently case-sensitive) +--FILE-- +v1 = new sELF; + $this->v2 = new SELF; + } +} + +class B extends A { + static $x = "B"; + function testit() { + PARENT::testit(); + $this->v3 = new sELF; + $this->v4 = new PARENT; + $this->v4 = STATIC::$x; + } +} +$t = new B(); +$t->testit(); +var_dump($t); +?> +--EXPECTF-- +object(B)#%d (4) { + ["v1"]=> + object(A)#%d (0) { + } + ["v2"]=> + object(A)#%d (0) { + } + ["v3"]=> + object(B)#%d (0) { + } + ["v4"]=> + string(1) "B" +} + diff --git a/Zend/tests/bug61681.phpt b/Zend/tests/bug61681.phpt new file mode 100644 index 0000000000000..acc027539815a --- /dev/null +++ b/Zend/tests/bug61681.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #61681: Malformed grammar +--FILE-- + +--EXPECT-- +ooxx diff --git a/Zend/tests/bug61767.phpt b/Zend/tests/bug61767.phpt index 5270872e5d8c2..9bd9c907bdc2c 100644 --- a/Zend/tests/bug61767.phpt +++ b/Zend/tests/bug61767.phpt @@ -17,18 +17,16 @@ $undefined->foo(); --EXPECTF-- Error handler called (Undefined variable: undefined) -Warning: Uncaught exception 'ErrorException' with message 'Undefined variable: undefined' in %sbug61767.php:13 +Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: undefined' in %sbug61767.php:%d Stack trace: -#0 %sbug61767.php(13): {closure}(8, 'Undefined varia...', '%s', 13, Array) +#0 %sbug61767.php(%d): {closure}(%s, 'Undefined varia...', '%s', %d, Array) #1 {main} - thrown in %sbug61767.php on line 13 - -Fatal error: Call to a member function foo() on a non-object in %sbug61767.php on line 13 + thrown in %sbug61767.php on line %d Shutting down Array ( [type] => 1 - [message] => Call to a member function foo() on a non-object + [message] => %a [file] => %sbug61767.php - [line] => 13 + [line] => %d ) diff --git a/Zend/tests/bug62991.phpt b/Zend/tests/bug62991.phpt new file mode 100644 index 0000000000000..cb4ff933591b6 --- /dev/null +++ b/Zend/tests/bug62991.phpt @@ -0,0 +1,50 @@ +--TEST-- +Bug #62991 (Segfault with generator and closure) +--FILE-- + +--EXPECT-- +Array +( + [0] => 1 + [1] => 2 + [2] => 3 +) +Array +( + [0] => 1 + [1] => 2 + [2] => 3 +) +okey diff --git a/Zend/tests/bug63741.phpt b/Zend/tests/bug63741.phpt new file mode 100644 index 0000000000000..fc04c9e79c4b4 --- /dev/null +++ b/Zend/tests/bug63741.phpt @@ -0,0 +1,50 @@ +--TEST-- +Bug #63741 (Crash when autoloading from spl) +--FILE-- + +EOT +); + +include dirname(__FILE__)."/bug63741.tmp.php"; +?> +--CLEAN-- + +--EXPECT-- +autoloading... +OK! diff --git a/Zend/tests/bug64135.phpt b/Zend/tests/bug64135.phpt new file mode 100644 index 0000000000000..1c7b1500a2b0c --- /dev/null +++ b/Zend/tests/bug64135.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #64135 (Exceptions from set_error_handler are not always propagated) +--FILE-- +undefined(); +} catch(Exception $e) { + echo "Exception is thrown"; +} +--EXPECT-- +Exception is thrown diff --git a/Zend/tests/catch_finally_001.phpt b/Zend/tests/catch_finally_001.phpt new file mode 100644 index 0000000000000..0c3f597a0a5a2 --- /dev/null +++ b/Zend/tests/catch_finally_001.phpt @@ -0,0 +1,32 @@ +--TEST-- +Try catch finally (basic test) +--FILE-- + +--EXPECTF-- +try +finally +end + +try +catch +finally +end diff --git a/Zend/tests/catch_finally_002.phpt b/Zend/tests/catch_finally_002.phpt new file mode 100644 index 0000000000000..c54477ff8cced --- /dev/null +++ b/Zend/tests/catch_finally_002.phpt @@ -0,0 +1,21 @@ +--TEST-- +Try catch finally (basic test with return) +--FILE-- + +--EXPECTF-- +try +finally +int(1) diff --git a/Zend/tests/catch_finally_003.phpt b/Zend/tests/catch_finally_003.phpt new file mode 100644 index 0000000000000..24e468d335c33 --- /dev/null +++ b/Zend/tests/catch_finally_003.phpt @@ -0,0 +1,40 @@ +--TEST-- +Try catch finally (with multi-returns) +--FILE-- + +--EXPECTF-- +string(3) "try" +string(7) "finally" +string(7) "finally" +try +string(4) "para" diff --git a/Zend/tests/catch_finally_004.phpt b/Zend/tests/catch_finally_004.phpt new file mode 100644 index 0000000000000..a2c22beab1182 --- /dev/null +++ b/Zend/tests/catch_finally_004.phpt @@ -0,0 +1,41 @@ +--TEST-- +Try catch finally (nesting try-catch-finally) +--FILE-- +getMessage()); +} while ($ex = $ex->getPrevious()); +?> +--EXPECT-- +123432int(1) +string(7) "finally" +string(5) "catch" diff --git a/Zend/tests/catch_finally_005.phpt b/Zend/tests/catch_finally_005.phpt new file mode 100644 index 0000000000000..c2fd55df27b1c --- /dev/null +++ b/Zend/tests/catch_finally_005.phpt @@ -0,0 +1,21 @@ +--TEST-- +Try catch finally (with multi-returns and exception) +--FILE-- + +--EXPECTF-- +int(3) diff --git a/Zend/tests/catch_finally_006.phpt b/Zend/tests/catch_finally_006.phpt new file mode 100644 index 0000000000000..216219b6a5b37 --- /dev/null +++ b/Zend/tests/catch_finally_006.phpt @@ -0,0 +1,28 @@ +--TEST-- +Try catch finally (re-throw exception in catch block) +--FILE-- +getMessage()); +} +?> +--EXPECT-- +string(4) "para" +string(7) "finally" +string(6) "return" diff --git a/Zend/tests/class_name_as_scalar.phpt b/Zend/tests/class_name_as_scalar.phpt new file mode 100644 index 0000000000000..38e55b16d551b --- /dev/null +++ b/Zend/tests/class_name_as_scalar.phpt @@ -0,0 +1,77 @@ +--TEST-- +class name as scalar from ::class keyword +--FILE-- + +--EXPECTF-- +In NS +string(11) "Foo\Bar\Moo" +Top +string(11) "Foo\Bar\One" +string(3) "Boo" +string(7) "Bee\Bop" +string(3) "Moo" +object(Foo\Bar\One)#1 (0) { +} +string(11) "Foo\Bar\Two" +string(11) "Foo\Bar\Two" +string(11) "Foo\Bar\One" +string(11) "Foo\Bar\Baz" +Parent +string(11) "Foo\Bar\Two" +string(13) "Foo\Bar\Three" +string(11) "Foo\Bar\One" +string(11) "Foo\Bar\Baz" +Compile Check +string(13) "Foo\Bar\Three" +string(11) "Foo\Bar\Baz" +string(11) "Foo\Bar\One" +string(11) "Foo\Bar\Two" diff --git a/Zend/tests/class_name_as_scalar_error_001.phpt b/Zend/tests/class_name_as_scalar_error_001.phpt new file mode 100644 index 0000000000000..1c7aa7ea848bd --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_001.phpt @@ -0,0 +1,13 @@ +--TEST-- +class name as scalar from ::class keyword error using static in class constant +--FILE-- + +--EXPECTF-- +Fatal error: static::class cannot be used for compile-time class name resolution in %s on line %d diff --git a/Zend/tests/class_name_as_scalar_error_002.phpt b/Zend/tests/class_name_as_scalar_error_002.phpt new file mode 100644 index 0000000000000..59b7a2edc9acc --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_002.phpt @@ -0,0 +1,13 @@ +--TEST-- +class name as scalar from ::class keyword error using parent in class constant +--FILE-- + +--EXPECTF-- +Fatal error: parent::class cannot be used for compile-time class name resolution in %s on line %d diff --git a/Zend/tests/class_name_as_scalar_error_003.phpt b/Zend/tests/class_name_as_scalar_error_003.phpt new file mode 100644 index 0000000000000..92990416930fd --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_003.phpt @@ -0,0 +1,13 @@ +--TEST-- +class name as scalar from ::class keyword error using static in method signature +--FILE-- + +--EXPECTF-- +Fatal error: static::class cannot be used for compile-time class name resolution in %s on line %d diff --git a/Zend/tests/class_name_as_scalar_error_004.phpt b/Zend/tests/class_name_as_scalar_error_004.phpt new file mode 100644 index 0000000000000..c00037fca3e15 --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_004.phpt @@ -0,0 +1,13 @@ +--TEST-- +class name as scalar from ::class keyword error using parent in method signature +--FILE-- + +--EXPECTF-- +Fatal error: parent::class cannot be used for compile-time class name resolution in %s on line %d diff --git a/Zend/tests/class_name_as_scalar_error_005.phpt b/Zend/tests/class_name_as_scalar_error_005.phpt new file mode 100644 index 0000000000000..39de69ffb3f6e --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_005.phpt @@ -0,0 +1,10 @@ +--TEST-- +class name as scalar from ::class keyword error using static non class context +--FILE-- + +--EXPECTF-- +Fatal error: Cannot access static::class when no class scope is active in %s on line %d \ No newline at end of file diff --git a/Zend/tests/class_name_as_scalar_error_006.phpt b/Zend/tests/class_name_as_scalar_error_006.phpt new file mode 100644 index 0000000000000..a4cc9a528b5c2 --- /dev/null +++ b/Zend/tests/class_name_as_scalar_error_006.phpt @@ -0,0 +1,10 @@ +--TEST-- +class name as scalar from ::class keyword error using parent in non class context +--FILE-- + +--EXPECTF-- +Fatal error: Cannot access parent::class when no class scope is active in %s on line %d diff --git a/Zend/tests/const_dereference_001.phpt b/Zend/tests/const_dereference_001.phpt new file mode 100644 index 0000000000000..5fe6e4d4332af --- /dev/null +++ b/Zend/tests/const_dereference_001.phpt @@ -0,0 +1,21 @@ +--TEST-- +Const array deference +--FILE-- + +--EXPECTF-- +int(4) + +Notice: Undefined index: foo in %sconst_dereference_001.php on line %d +NULL +int(6) +123 diff --git a/Zend/tests/const_dereference_002.phpt b/Zend/tests/const_dereference_002.phpt new file mode 100644 index 0000000000000..ff89519755747 --- /dev/null +++ b/Zend/tests/const_dereference_002.phpt @@ -0,0 +1,18 @@ +--TEST-- +Const string dereference +--FILE-- + +--EXPECTF-- +int(4) + +Notice: Undefined index: foo in %sconst_dereference_003.php on line %d +NULL +int(6) +123 diff --git a/Zend/tests/empty_with_expr.phpt b/Zend/tests/empty_with_expr.phpt new file mode 100644 index 0000000000000..582eb3d2d0b68 --- /dev/null +++ b/Zend/tests/empty_with_expr.phpt @@ -0,0 +1,32 @@ +--TEST-- +empty() with arbitrary expressions +--FILE-- +&$v) { -} - -echo "Done\n"; -?> ---EXPECTF-- -Fatal error: Cannot create references to elements of a temporary array expression in %s on line %d diff --git a/Zend/tests/foreach_list_001.phpt b/Zend/tests/foreach_list_001.phpt new file mode 100644 index 0000000000000..a318f1aad955a --- /dev/null +++ b/Zend/tests/foreach_list_001.phpt @@ -0,0 +1,43 @@ +--TEST-- +foreach with list syntax +--FILE-- + list(list($a, $b), list($c, $d))) { + var_dump($key . $a . $b . $c . $d); +} + + +?> +--EXPECT-- +string(2) "12" +string(2) "34" +string(2) "ab" +string(2) "cd" +string(4) "1234" +string(4) "5678" +string(5) "01234" +string(5) "15678" diff --git a/Zend/tests/foreach_list_002.phpt b/Zend/tests/foreach_list_002.phpt new file mode 100644 index 0000000000000..251870ba099ea --- /dev/null +++ b/Zend/tests/foreach_list_002.phpt @@ -0,0 +1,26 @@ +--TEST-- +foreach with freak lists +--FILE-- + +--EXPECTF-- +int(1) +int(3) +string(1) "b" + +Notice: Uninitialized string offset: 1 in %sforeach_list_002.php on line %d +string(0) "" + +Notice: Uninitialized string offset: 1 in %sforeach_list_002.php on line %d +string(0) "" diff --git a/Zend/tests/foreach_list_003.phpt b/Zend/tests/foreach_list_003.phpt new file mode 100644 index 0000000000000..8674ecd754ffb --- /dev/null +++ b/Zend/tests/foreach_list_003.phpt @@ -0,0 +1,13 @@ +--TEST-- +foreach with list key +--FILE-- + list(list(), $a)) { +} + +?> +--EXPECTF-- +Fatal error: Cannot use list as key element in %sforeach_list_003.php on line %d diff --git a/Zend/tests/foreach_list_004.phpt b/Zend/tests/foreach_list_004.phpt new file mode 100644 index 0000000000000..fd48e8a1f34ba --- /dev/null +++ b/Zend/tests/foreach_list_004.phpt @@ -0,0 +1,13 @@ +--TEST-- +foreach with empty list +--FILE-- + list()) { +} + +?> +--EXPECTF-- +Fatal error: Cannot use empty list in %sforeach_list_004.php on line %d diff --git a/Zend/tests/foreach_temp_array_expr_with_refs.phpt b/Zend/tests/foreach_temp_array_expr_with_refs.phpt new file mode 100644 index 0000000000000..8978b7b011419 --- /dev/null +++ b/Zend/tests/foreach_temp_array_expr_with_refs.phpt @@ -0,0 +1,18 @@ +--TEST-- +Temporary array expressions can be iterated by reference +--FILE-- + +--EXPECT-- +string(5) "a-foo" +string(5) "b-foo" diff --git a/Zend/tests/generators/auto_incrementing_keys.phpt b/Zend/tests/generators/auto_incrementing_keys.phpt new file mode 100644 index 0000000000000..acfb2f2ce00bb --- /dev/null +++ b/Zend/tests/generators/auto_incrementing_keys.phpt @@ -0,0 +1,22 @@ +--TEST-- +Generator keys are auto-incrementing by default +--FILE-- + 'rab'; + yield 'oof'; +} + +foreach (gen() as $k => $v) { + echo $k, ' => ', $v, "\n"; +} + +?> +--EXPECT-- +0 => foo +1 => bar +5 => rab +6 => oof diff --git a/Zend/tests/generators/backtrace.phpt b/Zend/tests/generators/backtrace.phpt new file mode 100644 index 0000000000000..5fed1d467e676 --- /dev/null +++ b/Zend/tests/generators/backtrace.phpt @@ -0,0 +1,27 @@ +--TEST-- +Printing the stack trace in a generator +--FILE-- +rewind(); // trigger run +} + +$gen = f2('foo', 'bar'); +f3($gen); + +?> +--EXPECTF-- +#0 f1() called at [%s:%d] +#1 f2(foo, bar) +#2 Generator->rewind() called at [%s:%d] +#3 f3(Generator Object ()) called at [%s:%d] diff --git a/Zend/tests/generators/bug63066.phpt b/Zend/tests/generators/bug63066.phpt new file mode 100644 index 0000000000000..8c4c8b4a84d3a --- /dev/null +++ b/Zend/tests/generators/bug63066.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #63066 (Calling an undefined method in a generator results in a seg fault) +--FILE-- +fatalError(); +} + +foreach(gen(new stdClass()) as $value) + echo $value, "\n"; +--EXPECTF-- +foo + +Fatal error: Call to undefined method stdClass::fatalError() in %sbug63066.php on line 5 diff --git a/Zend/tests/generators/clone.phpt b/Zend/tests/generators/clone.phpt new file mode 100644 index 0000000000000..36811dfe6e744 --- /dev/null +++ b/Zend/tests/generators/clone.phpt @@ -0,0 +1,32 @@ +--TEST-- +Generators can be cloned +--FILE-- +current()); +$g1->next(); + +$g2 = clone $g1; +var_dump($g2->current()); +$g2->next(); + +var_dump($g2->current()); +var_dump($g1->current()); + +$g1->next(); +var_dump($g1->current()); + +?> +--EXPECT-- +int(0) +int(1) +int(2) +int(1) +int(2) diff --git a/Zend/tests/generators/clone_after_object_call.phpt b/Zend/tests/generators/clone_after_object_call.phpt new file mode 100644 index 0000000000000..0a424268cc8d8 --- /dev/null +++ b/Zend/tests/generators/clone_after_object_call.phpt @@ -0,0 +1,20 @@ +--TEST-- +Cloning a generator after an object method was called +--FILE-- +b(); + yield; +} + +$g1 = gen(); +$g1->rewind(); +$g2 = clone $g1; + +echo "Done"; +--EXPECT-- +Done diff --git a/Zend/tests/generators/clone_with_foreach.phpt b/Zend/tests/generators/clone_with_foreach.phpt new file mode 100644 index 0000000000000..b05ed073120dc --- /dev/null +++ b/Zend/tests/generators/clone_with_foreach.phpt @@ -0,0 +1,33 @@ +--TEST-- +Cloning a generator with a foreach loop properly adds a ref for the loop var +--FILE-- +current()); + +$g2 = clone $g1; +var_dump($g2->current()); + +$g1->next(); +$g2->next(); +var_dump($g1->current()); +var_dump($g2->current()); + +unset($g1); +$g2->next(); +var_dump($g2->current()); + +?> +--EXPECT-- +int(1) +int(1) +int(2) +int(2) +int(3) diff --git a/Zend/tests/generators/clone_with_properties.phpt b/Zend/tests/generators/clone_with_properties.phpt new file mode 100644 index 0000000000000..900253c682214 --- /dev/null +++ b/Zend/tests/generators/clone_with_properties.phpt @@ -0,0 +1,18 @@ +--TEST-- +Tests cloning a generator with properties +--FILE-- +prop = 'val'; + +$g2 = clone $g1; +unset($g1); + +var_dump($g2->prop); + +?> +--EXPECT-- +string(3) "val" diff --git a/Zend/tests/generators/clone_with_stack.phpt b/Zend/tests/generators/clone_with_stack.phpt new file mode 100644 index 0000000000000..5a8e6d842ca8e --- /dev/null +++ b/Zend/tests/generators/clone_with_stack.phpt @@ -0,0 +1,18 @@ +--TEST-- +A generator with an active stack can be cloned +--FILE-- +rewind(); +$g2 = clone $g1; +unset($g1); +$g2->send(10); + +?> +--EXPECT-- +string(10) "xxxxxxxxxx" diff --git a/Zend/tests/generators/clone_with_symbol_table.phpt b/Zend/tests/generators/clone_with_symbol_table.phpt new file mode 100644 index 0000000000000..e1fefebd8fa42 --- /dev/null +++ b/Zend/tests/generators/clone_with_symbol_table.phpt @@ -0,0 +1,27 @@ +--TEST-- +A generator using a symbol table can be cloned +--FILE-- + 'bar']); + + // interrupt + yield; + + var_dump($foo); +} + +$g1 = gen(); +$g1->rewind(); +$g2 = clone $g1; +unset($g1); +$g2->next(); + +?> +--EXPECT-- +string(3) "bar" diff --git a/Zend/tests/generators/clone_with_this.phpt b/Zend/tests/generators/clone_with_this.phpt new file mode 100644 index 0000000000000..b242d851ebec5 --- /dev/null +++ b/Zend/tests/generators/clone_with_this.phpt @@ -0,0 +1,24 @@ +--TEST-- +Cloning a generator method (with $this) +--FILE-- +foo = 'bar'; + yield; // interrupt + var_dump($this->foo); + } +} + +$g1 = (new Test)->gen(); +$g1->rewind(); // goto yield +$g2 = clone $g1; +unset($g1); +$g2->next(); + +?> +--EXPECT-- +string(3) "bar" diff --git a/Zend/tests/generators/dynamic_call.phpt b/Zend/tests/generators/dynamic_call.phpt new file mode 100644 index 0000000000000..d56454095294d --- /dev/null +++ b/Zend/tests/generators/dynamic_call.phpt @@ -0,0 +1,19 @@ +--TEST-- +It's possible to invoke a generator dynamically +--FILE-- + +--EXPECT-- +string(3) "bar" +string(3) "foo" diff --git a/Zend/tests/generators/errors/generator_cannot_return_before_yield_error.phpt b/Zend/tests/generators/errors/generator_cannot_return_before_yield_error.phpt new file mode 100644 index 0000000000000..ad618d20ba2d4 --- /dev/null +++ b/Zend/tests/generators/errors/generator_cannot_return_before_yield_error.phpt @@ -0,0 +1,13 @@ +--TEST-- +Generators cannot return values (even before yield) +--FILE-- + +--EXPECTF-- +Fatal error: Generators cannot return values using "return" in %s on line 4 diff --git a/Zend/tests/generators/errors/generator_cannot_return_error.phpt b/Zend/tests/generators/errors/generator_cannot_return_error.phpt new file mode 100644 index 0000000000000..51149062a7ed6 --- /dev/null +++ b/Zend/tests/generators/errors/generator_cannot_return_error.phpt @@ -0,0 +1,13 @@ +--TEST-- +Generators cannot return values +--FILE-- + +--EXPECTF-- +Fatal error: Generators cannot return values using "return" in %s on line 5 diff --git a/Zend/tests/generators/errors/generator_extend_error.phpt b/Zend/tests/generators/errors/generator_extend_error.phpt new file mode 100644 index 0000000000000..550f16ae03b9d --- /dev/null +++ b/Zend/tests/generators/errors/generator_extend_error.phpt @@ -0,0 +1,10 @@ +--TEST-- +The Generator class cannot be extended +--FILE-- + +--EXPECTF-- +Fatal error: Class ExtendedGenerator may not inherit from final class (Generator) in %s on line %d diff --git a/Zend/tests/generators/errors/generator_instantiate_error.phpt b/Zend/tests/generators/errors/generator_instantiate_error.phpt new file mode 100644 index 0000000000000..f8941c087af42 --- /dev/null +++ b/Zend/tests/generators/errors/generator_instantiate_error.phpt @@ -0,0 +1,10 @@ +--TEST-- +It's not possible to directly instantiate the Generator class +--FILE-- + +--EXPECTF-- +Catchable fatal error: The "Generator" class is reserved for internal use and cannot be manually instantiated in %s on line %d diff --git a/Zend/tests/generators/errors/non_ref_generator_iterated_by_ref_error.phpt b/Zend/tests/generators/errors/non_ref_generator_iterated_by_ref_error.phpt new file mode 100644 index 0000000000000..de5b22f6ba63e --- /dev/null +++ b/Zend/tests/generators/errors/non_ref_generator_iterated_by_ref_error.phpt @@ -0,0 +1,18 @@ +--TEST-- +Non-ref generators cannot be iterated by-ref +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught exception 'Exception' with message 'You can only iterate a generator by-reference if it declared that it yields by-reference' in %s:%d +Stack trace: +#0 %s(%d): unknown() +#1 {main} + thrown in %s on line %d + diff --git a/Zend/tests/generators/errors/resume_running_generator_error.phpt b/Zend/tests/generators/errors/resume_running_generator_error.phpt new file mode 100644 index 0000000000000..567d72f3f9483 --- /dev/null +++ b/Zend/tests/generators/errors/resume_running_generator_error.phpt @@ -0,0 +1,17 @@ +--TEST-- +It is not possible to resume an already running generator +--FILE-- +next(); +} + +$gen = gen(); +$gen->send($gen); +$gen->next(); + +?> +--EXPECTF-- +Fatal error: Cannot resume an already running generator in %s on line %d diff --git a/Zend/tests/generators/errors/serialize_unserialize_error.phpt b/Zend/tests/generators/errors/serialize_unserialize_error.phpt new file mode 100644 index 0000000000000..a8470b0a63ab8 --- /dev/null +++ b/Zend/tests/generators/errors/serialize_unserialize_error.phpt @@ -0,0 +1,46 @@ +--TEST-- +Generators can't be serialized or unserialized +--FILE-- + +--EXPECTF-- +exception 'Exception' with message 'Serialization of 'Generator' is not allowed' in %s:%d +Stack trace: +#0 %s(%d): serialize(Object(Generator)) +#1 {main} + +exception 'Exception' with message 'Unserialization of 'Generator' is not allowed' in %s:%d +Stack trace: +#0 [internal function]: Generator->__wakeup() +#1 %s(%d): unserialize('O:9:"Generator"...') +#2 {main} + + +Notice: unserialize(): Error at offset 19 of 20 bytes in %s on line %d +exception 'Exception' with message 'Unserialization of 'Generator' is not allowed' in %s:%d +Stack trace: +#0 %s(%d): unserialize('C:9:"Generator"...') +#1 {main} diff --git a/Zend/tests/generators/errors/yield_const_by_ref_error.phpt b/Zend/tests/generators/errors/yield_const_by_ref_error.phpt new file mode 100644 index 0000000000000..e79f83e24a192 --- /dev/null +++ b/Zend/tests/generators/errors/yield_const_by_ref_error.phpt @@ -0,0 +1,16 @@ +--TEST-- +A notice is thrown when yielding a constant value by reference +--FILE-- +current()); + +?> +--EXPECTF-- +Notice: Only variable references should be yielded by reference in %s on line %d +string(3) "foo" diff --git a/Zend/tests/generators/errors/yield_in_force_closed_finally_error.phpt b/Zend/tests/generators/errors/yield_in_force_closed_finally_error.phpt new file mode 100644 index 0000000000000..aada676a68e8e --- /dev/null +++ b/Zend/tests/generators/errors/yield_in_force_closed_finally_error.phpt @@ -0,0 +1,29 @@ +--TEST-- +yield cannot be used in a finally block when the generator is force-closed +--FILE-- +rewind(); +unset($gen); + +?> +--EXPECTF-- +before yield +before yield in finally + +Fatal error: Cannot yield from finally in a force-closed generator in %s on line %d diff --git a/Zend/tests/generators/errors/yield_non_ref_function_call_by_ref_error.phpt b/Zend/tests/generators/errors/yield_non_ref_function_call_by_ref_error.phpt new file mode 100644 index 0000000000000..4b8563331c673 --- /dev/null +++ b/Zend/tests/generators/errors/yield_non_ref_function_call_by_ref_error.phpt @@ -0,0 +1,20 @@ +--TEST-- +Yielding the result of a non-ref function call throw a notice +--FILE-- +current()); + +?> +--EXPECTF-- +Notice: Only variable references should be yielded by reference in %s on line %d +string(3) "bar" diff --git a/Zend/tests/generators/errors/yield_outside_function_error.phpt b/Zend/tests/generators/errors/yield_outside_function_error.phpt new file mode 100644 index 0000000000000..f999c1c03bf48 --- /dev/null +++ b/Zend/tests/generators/errors/yield_outside_function_error.phpt @@ -0,0 +1,10 @@ +--TEST-- +Yield cannot be used outside of functions +--FILE-- + +--EXPECTF-- +Fatal error: The "yield" expression can only be used inside a function in %s on line %d diff --git a/Zend/tests/generators/fibonacci.phpt b/Zend/tests/generators/fibonacci.phpt new file mode 100644 index 0000000000000..35b31352ff3e7 --- /dev/null +++ b/Zend/tests/generators/fibonacci.phpt @@ -0,0 +1,36 @@ +--TEST-- +Creating an infinite fibonacci list using a generator +--FILE-- + 1000) break; + + var_dump($n); +} + +?> +--EXPECT-- +int(1) +int(2) +int(3) +int(5) +int(8) +int(13) +int(21) +int(34) +int(55) +int(89) +int(144) +int(233) +int(377) +int(610) +int(987) diff --git a/Zend/tests/generators/finally/finally_ran_on_close.phpt b/Zend/tests/generators/finally/finally_ran_on_close.phpt new file mode 100644 index 0000000000000..04a0561c87993 --- /dev/null +++ b/Zend/tests/generators/finally/finally_ran_on_close.phpt @@ -0,0 +1,30 @@ +--TEST-- +finally is run even if a generator is closed mid-execution +--FILE-- +rewind(); +unset($gen); + +?> +--EXPECT-- +before yield +finally run +second finally run diff --git a/Zend/tests/generators/finally/return_return.phpt b/Zend/tests/generators/finally/return_return.phpt new file mode 100644 index 0000000000000..02e2739de7ec5 --- /dev/null +++ b/Zend/tests/generators/finally/return_return.phpt @@ -0,0 +1,33 @@ +--TEST-- +try { return } finally { return } in generator +--FILE-- +rewind(); // force run + +?> +--EXPECTF-- +before return +before return in inner finally +outer finally run diff --git a/Zend/tests/generators/finally/return_yield.phpt b/Zend/tests/generators/finally/return_yield.phpt new file mode 100644 index 0000000000000..c4f348598770e --- /dev/null +++ b/Zend/tests/generators/finally/return_yield.phpt @@ -0,0 +1,18 @@ +--TEST-- +try { return } finally { yield } +--FILE-- +rewind(); + +set_error_handler(function() use($gen) {}); + +?> +--EXPECT-- +array(0) { +} diff --git a/Zend/tests/generators/finally/throw_yield.phpt b/Zend/tests/generators/finally/throw_yield.phpt new file mode 100644 index 0000000000000..2013c3ee14a58 --- /dev/null +++ b/Zend/tests/generators/finally/throw_yield.phpt @@ -0,0 +1,24 @@ +--TEST-- +try { throw } finally { yield } +--FILE-- +rewind(); + +?> +--EXPECT-- +array(2) { + [0]=> + string(3) "foo" + [1]=> + string(3) "bar" +} diff --git a/Zend/tests/generators/generator_closure.phpt b/Zend/tests/generators/generator_closure.phpt new file mode 100644 index 0000000000000..bf80066015f5e --- /dev/null +++ b/Zend/tests/generators/generator_closure.phpt @@ -0,0 +1,20 @@ +--TEST-- +Closures can be generators +--FILE-- + +--EXPECT-- +int(1) +int(2) +int(3) diff --git a/Zend/tests/generators/generator_closure_with_this.phpt b/Zend/tests/generators/generator_closure_with_this.phpt new file mode 100644 index 0000000000000..d5a4861e80461 --- /dev/null +++ b/Zend/tests/generators/generator_closure_with_this.phpt @@ -0,0 +1,20 @@ +--TEST-- +Non-static closures can be generators +--FILE-- +getGenFactory(); +var_dump($genFactory()->current()); + +?> +--EXPECT-- +object(Test)#1 (0) { +} diff --git a/Zend/tests/generators/generator_in_multipleiterator.phpt b/Zend/tests/generators/generator_in_multipleiterator.phpt new file mode 100644 index 0000000000000..611dbc9652743 --- /dev/null +++ b/Zend/tests/generators/generator_in_multipleiterator.phpt @@ -0,0 +1,37 @@ +--TEST-- +Generators work properly in MultipleIterator +--FILE-- +attachIterator(gen1()); +$it->attachIterator(gen2()); + +foreach ($it as $values) { + var_dump($values); +} + +?> +--EXPECT-- +array(2) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" +} +array(2) { + [0]=> + string(2) "aa" + [1]=> + string(2) "bb" +} diff --git a/Zend/tests/generators/generator_method.phpt b/Zend/tests/generators/generator_method.phpt new file mode 100644 index 0000000000000..b8196c171ecdf --- /dev/null +++ b/Zend/tests/generators/generator_method.phpt @@ -0,0 +1,29 @@ +--TEST-- +Methods can be generators +--FILE-- +data = $data; + } + + public function getIterator() { + foreach ($this->data as $value) { + yield $value; + } + } +} + +$test = new Test(['foo', 'bar', 'baz']); +foreach ($test as $value) { + var_dump($value); +} + +?> +--EXPECT-- +string(3) "foo" +string(3) "bar" +string(3) "baz" diff --git a/Zend/tests/generators/generator_method_by_ref.phpt b/Zend/tests/generators/generator_method_by_ref.phpt new file mode 100644 index 0000000000000..cfe52fe67ff82 --- /dev/null +++ b/Zend/tests/generators/generator_method_by_ref.phpt @@ -0,0 +1,44 @@ +--TEST-- +Generator methods can yield by reference +--FILE-- +data = $data; + } + + public function getData() { + return $this->data; + } + + public function &getIterator() { + foreach ($this->data as $key => &$value) { + yield $key => $value; + } + } +} + +$test = new Test([1, 2, 3, 4, 5]); +foreach ($test as &$value) { + $value *= -1; +} + +var_dump($test->getData()); + +?> +--EXPECT-- +array(5) { + [0]=> + int(-1) + [1]=> + int(-2) + [2]=> + int(-3) + [3]=> + int(-4) + [4]=> + &int(-5) +} diff --git a/Zend/tests/generators/generator_returns_generator.phpt b/Zend/tests/generators/generator_returns_generator.phpt new file mode 100644 index 0000000000000..ad332a3be9246 --- /dev/null +++ b/Zend/tests/generators/generator_returns_generator.phpt @@ -0,0 +1,18 @@ +--TEST-- +A generator function returns a Generator object +--FILE-- + +--EXPECT-- +bool(true) diff --git a/Zend/tests/generators/generator_rewind.phpt b/Zend/tests/generators/generator_rewind.phpt new file mode 100644 index 0000000000000..c4b5bbbdf4944 --- /dev/null +++ b/Zend/tests/generators/generator_rewind.phpt @@ -0,0 +1,62 @@ +--TEST-- +A generator can only be rewinded before or at the first yield +--FILE-- +rewind(); +$gen->rewind(); +$gen->next(); + +try { + $gen->rewind(); +} catch (Exception $e) { + echo "\n", $e, "\n\n"; +} + +function &gen2() { + $foo = 'bar'; + yield $foo; + yield $foo; +} + +$gen = gen2(); +foreach ($gen as $v) { } +try { + foreach ($gen as $v) { } +} catch (Exception $e) { + echo $e, "\n\n"; +} + +function gen3() { + echo "in generator\n"; + + if (false) yield; +} + +$gen = gen3(); +$gen->rewind(); + +?> +--EXPECTF-- +before yield +after yield + +exception 'Exception' with message 'Cannot rewind a generator that was already run' in %s:%d +Stack trace: +#0 %s(%d): Generator->rewind() +#1 {main} + +exception 'Exception' with message 'Cannot traverse an already closed generator' in %s:%d +Stack trace: +#0 %s(%d): unknown() +#1 {main} + +in generator diff --git a/Zend/tests/generators/generator_send.phpt b/Zend/tests/generators/generator_send.phpt new file mode 100644 index 0000000000000..074d815389711 --- /dev/null +++ b/Zend/tests/generators/generator_send.phpt @@ -0,0 +1,22 @@ +--TEST-- +Values can be sent back to the generator +--FILE-- +current()); +$gen->send("send bar"); +var_dump($gen->current()); +$gen->send("send foo"); + +?> +--EXPECT-- +string(9) "yield foo" +string(8) "send bar" +string(9) "yield bar" +string(8) "send foo" diff --git a/Zend/tests/generators/generator_static_method.phpt b/Zend/tests/generators/generator_static_method.phpt new file mode 100644 index 0000000000000..cd9b450a76caf --- /dev/null +++ b/Zend/tests/generators/generator_static_method.phpt @@ -0,0 +1,29 @@ +--TEST-- +A static method can be a generator +--FILE-- + +--EXPECT-- +string(4) "Test" +string(12) "ExtendedTest" +int(1) +int(2) +int(3) diff --git a/Zend/tests/generators/generator_throwing_during_function_call.phpt b/Zend/tests/generators/generator_throwing_during_function_call.phpt new file mode 100644 index 0000000000000..bd0d2448b7d83 --- /dev/null +++ b/Zend/tests/generators/generator_throwing_during_function_call.phpt @@ -0,0 +1,32 @@ +--TEST-- +Stack is cleaned up properly when an exception is thrown during a function call +--FILE-- +current()); + +try { + $gen->next(); +} catch (Exception $e) { + echo 'Caught exception with message "', $e->getMessage(), '"', "\n"; +} + +var_dump($gen->current()); + +?> +--EXPECT-- +string(3) "foo" +Caught exception with message "test" +NULL diff --git a/Zend/tests/generators/generator_throwing_exception.phpt b/Zend/tests/generators/generator_throwing_exception.phpt new file mode 100644 index 0000000000000..f537c3fc7726e --- /dev/null +++ b/Zend/tests/generators/generator_throwing_exception.phpt @@ -0,0 +1,28 @@ +--TEST-- +Generators can throw exceptions +--FILE-- +current()); + +try { + $gen->next(); +} catch (Exception $e) { + echo 'Caught exception with message "', $e->getMessage(), '"', "\n"; +} + +var_dump($gen->current()); + +?> +--EXPECT-- +string(3) "foo" +Caught exception with message "test" +NULL diff --git a/Zend/tests/generators/generator_throwing_in_foreach.phpt b/Zend/tests/generators/generator_throwing_in_foreach.phpt new file mode 100644 index 0000000000000..dbf20c2ca1c65 --- /dev/null +++ b/Zend/tests/generators/generator_throwing_in_foreach.phpt @@ -0,0 +1,20 @@ +--TEST-- +Exceptions throwing by generators during foreach iteration are properly handled +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught exception 'Exception' with message 'foo' in %s:%d +Stack trace: +#0 %s(%d): gen() +#1 {main} + thrown in %s on line %d + diff --git a/Zend/tests/generators/generator_with_keys.phpt b/Zend/tests/generators/generator_with_keys.phpt new file mode 100644 index 0000000000000..efb377679ec0d --- /dev/null +++ b/Zend/tests/generators/generator_with_keys.phpt @@ -0,0 +1,26 @@ +--TEST-- +Generators can also yield keys +--FILE-- + current($array); + prev($array); + } +} + +$array = [ + 'foo' => 'bar', + 'bar' => 'foo', +]; + +foreach (reverse($array) as $key => $value) { + echo $key, ' => ', $value, "\n"; +} + +?> +--EXPECT-- +bar => foo +foo => bar diff --git a/Zend/tests/generators/ignored_send_leak.phpt b/Zend/tests/generators/ignored_send_leak.phpt new file mode 100644 index 0000000000000..352ba406ba495 --- /dev/null +++ b/Zend/tests/generators/ignored_send_leak.phpt @@ -0,0 +1,17 @@ +--TEST-- +Ignoring a sent value shouldn't leak memory +--FILE-- +send(NULL); + +echo "DONE"; + +?> +--EXPECT-- +DONE diff --git a/Zend/tests/generators/nested_calls_with_die.phpt b/Zend/tests/generators/nested_calls_with_die.phpt new file mode 100644 index 0000000000000..f43d89ba2193c --- /dev/null +++ b/Zend/tests/generators/nested_calls_with_die.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test nested calls with die() in a generator +--FILE-- +rewind(); +} + +function function_with_4_args() { + function_with_3_args(4, 5, 6); +} + +function outerGen() { + function_with_4_args(0, 1, 2, 3); + yield; // force generator +} + +$outerGen = outerGen(); +$outerGen->rewind(); + +?> +--EXPECT-- +Test diff --git a/Zend/tests/generators/nested_method_calls.phpt b/Zend/tests/generators/nested_method_calls.phpt new file mode 100644 index 0000000000000..98aee2e60b09d --- /dev/null +++ b/Zend/tests/generators/nested_method_calls.phpt @@ -0,0 +1,39 @@ +--TEST-- +Yield can be used in nested method calls +--FILE-- +foo($obj->foo(yield)); +} + +$g1 = gen(new A); +$g1->current(); + +$g2 = gen(new B); +$g2->current(); + +$g1->next(); + +$g3 = clone $g2; +unset($g2); +$g3->next(); + +?> +--EXPECT-- +Called A::foo +Called A::foo +Called B::foo +Called B::foo diff --git a/Zend/tests/generators/no_foreach_var_leaks.phpt b/Zend/tests/generators/no_foreach_var_leaks.phpt new file mode 100644 index 0000000000000..62743895ebcbd --- /dev/null +++ b/Zend/tests/generators/no_foreach_var_leaks.phpt @@ -0,0 +1,19 @@ +--TEST-- +foreach() (and other) variables aren't leaked on premature close +--FILE-- +current()); + +// generator is closed here, without running SWITCH_FREE + +?> +--EXPECT-- +string(3) "Foo" diff --git a/Zend/tests/generators/send_after_close.phpt b/Zend/tests/generators/send_after_close.phpt new file mode 100644 index 0000000000000..806baf8cee4ab --- /dev/null +++ b/Zend/tests/generators/send_after_close.phpt @@ -0,0 +1,14 @@ +--TEST-- +Calls to send() after close should do nothing +--FILE-- +send('foo'); +$gen->send('bar'); + +?> +--EXPECT-- +string(3) "foo" diff --git a/Zend/tests/generators/send_returns_current.phpt b/Zend/tests/generators/send_returns_current.phpt new file mode 100644 index 0000000000000..27ba74bc1bd86 --- /dev/null +++ b/Zend/tests/generators/send_returns_current.phpt @@ -0,0 +1,20 @@ +--TEST-- +$generator->send() returns the yielded value +--FILE-- +send('foo')); +var_dump($gen->send('bar')); + +?> +--EXPECT-- +string(3) "oof" +string(3) "rab" diff --git a/Zend/tests/generators/throw_already_closed.phpt b/Zend/tests/generators/throw_already_closed.phpt new file mode 100644 index 0000000000000..e918e540ab967 --- /dev/null +++ b/Zend/tests/generators/throw_already_closed.phpt @@ -0,0 +1,23 @@ +--TEST-- +Generator::throw() on an already closed generator +--FILE-- +next(); +$gen->next(); +var_dump($gen->valid()); +$gen->throw(new Exception('test')); + +?> +--EXPECTF-- +bool(false) + +Fatal error: Uncaught exception 'Exception' with message 'test' in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d diff --git a/Zend/tests/generators/throw_caught.phpt b/Zend/tests/generators/throw_caught.phpt new file mode 100644 index 0000000000000..0c3f8e9b2daae --- /dev/null +++ b/Zend/tests/generators/throw_caught.phpt @@ -0,0 +1,25 @@ +--TEST-- +Generator::throw() where the exception is caught in the generator +--FILE-- +throw(new RuntimeException('Test'))); + +?> +--EXPECTF-- +exception 'RuntimeException' with message 'Test' in %s:%d +Stack trace: +#0 {main} + +string(6) "result" diff --git a/Zend/tests/generators/throw_not_an_exception.phpt b/Zend/tests/generators/throw_not_an_exception.phpt new file mode 100644 index 0000000000000..d93903e2150d1 --- /dev/null +++ b/Zend/tests/generators/throw_not_an_exception.phpt @@ -0,0 +1,15 @@ +--TEST-- +Generator::throw() with something that's not an exception +--FILE-- +throw(new stdClass); + +?> +--EXPECTF-- +Fatal error: Exceptions must be valid objects derived from the Exception base class in %s on line %d diff --git a/Zend/tests/generators/throw_rethrow.phpt b/Zend/tests/generators/throw_rethrow.phpt new file mode 100644 index 0000000000000..267f5f0db86ec --- /dev/null +++ b/Zend/tests/generators/throw_rethrow.phpt @@ -0,0 +1,32 @@ +--TEST-- +Generator::throw() where the generator throws a different exception +--FILE-- +throw(new RuntimeException('throw'))); + +?> +--EXPECTF-- +Caught: exception 'RuntimeException' with message 'throw' in %s:%d +Stack trace: +#0 {main} + + +Fatal error: Uncaught exception 'LogicException' with message 'new throw' in %s:%d +Stack trace: +#0 [internal function]: gen() +#1 %s(%d): Generator->throw(Object(RuntimeException)) +#2 {main} + thrown in %s on line %d + diff --git a/Zend/tests/generators/throw_uncaught.phpt b/Zend/tests/generators/throw_uncaught.phpt new file mode 100644 index 0000000000000..f06cff1b8ecf2 --- /dev/null +++ b/Zend/tests/generators/throw_uncaught.phpt @@ -0,0 +1,19 @@ +--TEST-- +Generator::throw() where the exception is not caught in the generator +--FILE-- +throw(new RuntimeException('test'))); + +?> +--EXPECTF-- +Fatal error: Uncaught exception 'RuntimeException' with message 'test' in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d diff --git a/Zend/tests/generators/unused_return_value.phpt b/Zend/tests/generators/unused_return_value.phpt new file mode 100644 index 0000000000000..ddce64542c9a0 --- /dev/null +++ b/Zend/tests/generators/unused_return_value.phpt @@ -0,0 +1,13 @@ +--TEST-- +There shouldn't be any leaks when the genertor's return value isn't used +--FILE-- + +===DONE=== +--EXPECT-- +===DONE=== diff --git a/Zend/tests/generators/xrange.phpt b/Zend/tests/generators/xrange.phpt new file mode 100644 index 0000000000000..4d8b60fa909a8 --- /dev/null +++ b/Zend/tests/generators/xrange.phpt @@ -0,0 +1,23 @@ +--TEST-- +Simple generator xrange() test +--FILE-- + +--EXPECT-- +int(10) +int(12) +int(14) +int(16) +int(18) +int(20) diff --git a/Zend/tests/generators/yield_array_key.phpt b/Zend/tests/generators/yield_array_key.phpt new file mode 100644 index 0000000000000..5afba00de830a --- /dev/null +++ b/Zend/tests/generators/yield_array_key.phpt @@ -0,0 +1,18 @@ +--TEST-- +Array keys can be yielded from generators +--FILE-- + 1; +} + +$gen = gen(); +var_dump($gen->key()); +var_dump($gen->current()); + +?> +--EXPECT-- +array(0) { +} +int(1) diff --git a/Zend/tests/generators/yield_array_offset_by_ref.phpt b/Zend/tests/generators/yield_array_offset_by_ref.phpt new file mode 100644 index 0000000000000..544108e64d89b --- /dev/null +++ b/Zend/tests/generators/yield_array_offset_by_ref.phpt @@ -0,0 +1,26 @@ +--TEST-- +Array offsets can be yielded by reference +--FILE-- + +--EXPECT-- +array(3) { + [0]=> + &int(-1) + [1]=> + int(2) + [2]=> + int(3) +} diff --git a/Zend/tests/generators/yield_by_reference.phpt b/Zend/tests/generators/yield_by_reference.phpt new file mode 100644 index 0000000000000..dba0791c0d495 --- /dev/null +++ b/Zend/tests/generators/yield_by_reference.phpt @@ -0,0 +1,42 @@ +--TEST-- +Generators can yield by-reference +--FILE-- + &$value) { + yield $key => $value; + } +} + +$array = [1, 2, 3]; +$iter = iter($array); +foreach ($iter as &$value) { + $value *= -1; +} +var_dump($array); + +$array = [1, 2, 3]; +foreach (iter($array) as &$value) { + $value *= -1; +} +var_dump($array); + +?> +--EXPECT-- +array(3) { + [0]=> + int(-1) + [1]=> + int(-2) + [2]=> + &int(-3) +} +array(3) { + [0]=> + int(-1) + [1]=> + int(-2) + [2]=> + &int(-3) +} diff --git a/Zend/tests/generators/yield_closure.phpt b/Zend/tests/generators/yield_closure.phpt new file mode 100644 index 0000000000000..e380b299461a3 --- /dev/null +++ b/Zend/tests/generators/yield_closure.phpt @@ -0,0 +1,17 @@ +--TEST-- +Generator shouldn't crash if last yielded value is a closure +--FILE-- +next(); + +echo "Done!"; + +?> +--EXPECT-- +Done! diff --git a/Zend/tests/generators/yield_during_function_call.phpt b/Zend/tests/generators/yield_during_function_call.phpt new file mode 100644 index 0000000000000..21071f9fb4af6 --- /dev/null +++ b/Zend/tests/generators/yield_during_function_call.phpt @@ -0,0 +1,15 @@ +--TEST-- +"yield" can occur during a function call +--FILE-- +send(10); + +?> +--EXPECT-- +string(10) "xxxxxxxxxx" diff --git a/Zend/tests/generators/yield_during_method_call.phpt b/Zend/tests/generators/yield_during_method_call.phpt new file mode 100644 index 0000000000000..5fbe84fff559b --- /dev/null +++ b/Zend/tests/generators/yield_during_method_call.phpt @@ -0,0 +1,35 @@ +--TEST-- +Yield can be used during a method call +--FILE-- +b(yield); +} + +$gen = gen(); +$gen->send('foo'); + +// test resource cleanup +$gen = gen(); +$gen->rewind(); +unset($gen); + +// test cloning +$g1 = gen(); +$g1->rewind(); +$g2 = clone $g1; +unset($g1); +$g2->send('bar'); + +?> +--EXPECT-- +foo +bar diff --git a/Zend/tests/generators/yield_in_finally.phpt b/Zend/tests/generators/yield_in_finally.phpt new file mode 100644 index 0000000000000..805484ad1d150 --- /dev/null +++ b/Zend/tests/generators/yield_in_finally.phpt @@ -0,0 +1,29 @@ +--TEST-- +yield can be used in finally (apart from forced closes) +--FILE-- +current()); +$gen->next(); + +?> +--EXPECTF-- +before return +before yield +string(%d) "yielded value" +after yield diff --git a/Zend/tests/generators/yield_in_parenthesis.phpt b/Zend/tests/generators/yield_in_parenthesis.phpt new file mode 100644 index 0000000000000..4a603f4cc1a50 --- /dev/null +++ b/Zend/tests/generators/yield_in_parenthesis.phpt @@ -0,0 +1,23 @@ +--TEST-- +No additional parenthesis are required around yield if they are already present +--FILE-- +func(yield $foo); + new Foo(yield $foo); +} + +echo "Done"; + +?> +--EXPECT-- +Done diff --git a/Zend/tests/generators/yield_ref_function_call_by_reference.phpt b/Zend/tests/generators/yield_ref_function_call_by_reference.phpt new file mode 100644 index 0000000000000..e371affd92c8e --- /dev/null +++ b/Zend/tests/generators/yield_ref_function_call_by_reference.phpt @@ -0,0 +1,24 @@ +--TEST-- +The result of a by-ref function call can be yielded just fine +--FILE-- + +--EXPECT-- +string(3) "bar" diff --git a/Zend/tests/generators/yield_without_value.phpt b/Zend/tests/generators/yield_without_value.phpt new file mode 100644 index 0000000000000..510c755bd3fe9 --- /dev/null +++ b/Zend/tests/generators/yield_without_value.phpt @@ -0,0 +1,27 @@ +--TEST-- +yield can be used without a value +--FILE-- +current()); +$reciever->send(1); +var_dump($reciever->current()); +$reciever->send(2); +var_dump($reciever->current()); +$reciever->send(3); + +?> +--EXPECT-- +NULL +int(1) +NULL +int(2) +NULL +int(3) diff --git a/Zend/tests/isset_expr_error.phpt b/Zend/tests/isset_expr_error.phpt new file mode 100644 index 0000000000000..27fc6cd8d3772 --- /dev/null +++ b/Zend/tests/isset_expr_error.phpt @@ -0,0 +1,8 @@ +--TEST-- +Error message for isset(func()) +--FILE-- + +--EXPECTF-- +Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in %s on line %d diff --git a/Zend/tests/isset_func_error.phpt b/Zend/tests/isset_func_error.phpt new file mode 100644 index 0000000000000..7d1036def8e2a --- /dev/null +++ b/Zend/tests/isset_func_error.phpt @@ -0,0 +1,8 @@ +--TEST-- +Error message for isset(func()) +--FILE-- + +--EXPECTF-- +Fatal error: Cannot use isset() on the result of a function call (you can use "null !== func()" instead) in %s on line %d diff --git a/Zend/tests/offset_assign.phpt b/Zend/tests/offset_assign.phpt index 6a005910953ab..721516f53cb2f 100644 --- a/Zend/tests/offset_assign.phpt +++ b/Zend/tests/offset_assign.phpt @@ -3,11 +3,11 @@ Crash on $x['x']['y'] += 1 when $x is string --FILE-- ---EXPECTF-- +--EXPECTF-- Warning: Illegal string offset 'x' in %soffset_assign.php on line %d Fatal error: Cannot use string offset as an array in %soffset_assign.php on line %d diff --git a/Zend/tests/offset_string.phpt b/Zend/tests/offset_string.phpt index f7cb81bb20d35..c546b371830f4 100644 --- a/Zend/tests/offset_string.phpt +++ b/Zend/tests/offset_string.phpt @@ -27,7 +27,7 @@ var_dump($str[$arr]); echo "Done\n"; ?> ---EXPECTF-- +--EXPECTF-- string(1) "i" Notice: String offset cast occurred in %s on line %d diff --git a/Zend/tests/try_catch_finally_001.phpt b/Zend/tests/try_catch_finally_001.phpt new file mode 100644 index 0000000000000..3d478f461aeca --- /dev/null +++ b/Zend/tests/try_catch_finally_001.phpt @@ -0,0 +1,36 @@ +--TEST-- +Try catch finally +--FILE-- + +--EXPECTF-- +1234int(1) diff --git a/Zend/tests/try_catch_finally_002.phpt b/Zend/tests/try_catch_finally_002.phpt new file mode 100644 index 0000000000000..79efcb3de8cc4 --- /dev/null +++ b/Zend/tests/try_catch_finally_002.phpt @@ -0,0 +1,42 @@ +--TEST-- +Try catch finally catch(multi catch blocks) +--FILE-- + +--EXPECTF-- +123456int(7) diff --git a/Zend/tests/try_catch_finally_003.phpt b/Zend/tests/try_catch_finally_003.phpt new file mode 100644 index 0000000000000..7ec8ec82db4d0 --- /dev/null +++ b/Zend/tests/try_catch_finally_003.phpt @@ -0,0 +1,36 @@ +--TEST-- +Try catch finally (multi catch blocks with return) +--FILE-- + +--EXPECTF-- +1234int(4) diff --git a/Zend/tests/try_catch_finally_004.phpt b/Zend/tests/try_catch_finally_004.phpt new file mode 100644 index 0000000000000..eb8d0966a1ca2 --- /dev/null +++ b/Zend/tests/try_catch_finally_004.phpt @@ -0,0 +1,30 @@ +--TEST-- +Try catch finally (re-throw exception in catch block) +--CREDITS-- +adoy +--FILE-- + +--EXPECTF-- +string(3) "try" +string(7) "finally" +string(8) "finally2" diff --git a/Zend/tests/try_catch_finally_005.phpt b/Zend/tests/try_catch_finally_005.phpt new file mode 100644 index 0000000000000..dafeb6bbe0436 --- /dev/null +++ b/Zend/tests/try_catch_finally_005.phpt @@ -0,0 +1,52 @@ +--TEST-- +Try catch finally (break / cont in try block) +--CREDITS-- +adoy +--FILE-- + +--EXPECTF-- +string(5) "break" +string(9) "continue1" +string(9) "continue1" +string(9) "continue2" +string(7) "finally" +string(9) "continue2" +string(8) "cactched" +string(7) "finally" +string(9) "continue2" +string(7) "finally" diff --git a/Zend/tests/try_catch_finally_006.phpt b/Zend/tests/try_catch_finally_006.phpt new file mode 100644 index 0000000000000..dab6af6a58156 --- /dev/null +++ b/Zend/tests/try_catch_finally_006.phpt @@ -0,0 +1,39 @@ +--TEST-- +Try catch finally (goto in try/catch block) +--CREDITS-- +adoy +--FILE-- + +--EXPECTF-- +string(8) "finally1" +string(8) "finally2" +string(5) "label" +string(7) "return2" +string(8) "finally1" +string(7) "catched" +string(8) "finally2" +string(7) "return1" diff --git a/Zend/tests/try_catch_finally_007.phpt b/Zend/tests/try_catch_finally_007.phpt new file mode 100644 index 0000000000000..ad33c68131706 --- /dev/null +++ b/Zend/tests/try_catch_finally_007.phpt @@ -0,0 +1,46 @@ +--TEST-- +Try catch finally (goto in try/catch block) +--CREDITS-- +adoy +--FILE-- + +--EXPECTF-- +string(8) "finally1" +string(7) "catched" +string(8) "finally2" +string(5) "label" +NULL +string(8) "finally1" +string(7) "catched" +string(8) "finally2" +string(6) "return" diff --git a/Zend/tests/try_finally_001.phpt b/Zend/tests/try_finally_001.phpt new file mode 100644 index 0000000000000..0f740872c2acd --- /dev/null +++ b/Zend/tests/try_finally_001.phpt @@ -0,0 +1,22 @@ +--TEST-- +Try finally (basic test) +--FILE-- + +--EXPECTF-- +string(7) "finally" + +Fatal error: Uncaught exception 'Exception' with message 'ex' %s +Stack trace: +#0 %stry_finally_001.php(%d): foo('finally') +#1 {main} + thrown in %stry_finally_001.php on line %d diff --git a/Zend/tests/try_finally_002.phpt b/Zend/tests/try_finally_002.phpt new file mode 100644 index 0000000000000..99a34f62fbd7a --- /dev/null +++ b/Zend/tests/try_finally_002.phpt @@ -0,0 +1,23 @@ +--TEST-- +Try finally (re-throw exception in finally block) +--FILE-- +getMessage()); + } while ($e = $e->getPrevious()); +} +?> +--EXPECT-- +string(7) "finally" +string(3) "try" diff --git a/Zend/tests/try_finally_003.phpt b/Zend/tests/try_finally_003.phpt new file mode 100644 index 0000000000000..c1294911bd330 --- /dev/null +++ b/Zend/tests/try_finally_003.phpt @@ -0,0 +1,27 @@ +--TEST-- +Try finally (call sequence test) +--FILE-- + +--EXPECTF-- +1234 +Fatal error: Uncaught exception 'Exception' with message 'ex' %s +Stack trace: +#0 %stry_finally_003.php(%d): foo() +#1 {main} + thrown in %stry_finally_003.php on line %d diff --git a/Zend/tests/try_finally_004.phpt b/Zend/tests/try_finally_004.phpt new file mode 100644 index 0000000000000..08930a40c5244 --- /dev/null +++ b/Zend/tests/try_finally_004.phpt @@ -0,0 +1,14 @@ +--TEST-- +Try finally (without catch/finally block) +--FILE-- + +--EXPECTF-- +Fatal error: Cannot use try without catch or finally in %stry_finally_004.php on line %d diff --git a/Zend/tests/try_finally_005.phpt b/Zend/tests/try_finally_005.phpt new file mode 100644 index 0000000000000..8664d6b1bf9a8 --- /dev/null +++ b/Zend/tests/try_finally_005.phpt @@ -0,0 +1,17 @@ +--TEST-- +Try finally (with long goto) +--FILE-- + +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_005.php on line %d diff --git a/Zend/tests/try_finally_006.phpt b/Zend/tests/try_finally_006.phpt new file mode 100644 index 0000000000000..f53e6b5bc1e84 --- /dev/null +++ b/Zend/tests/try_finally_006.phpt @@ -0,0 +1,26 @@ +--TEST-- +Try finally (with near goto) +--FILE-- + +--EXPECTF-- +label +okey diff --git a/Zend/tests/try_finally_007.phpt b/Zend/tests/try_finally_007.phpt new file mode 100644 index 0000000000000..634937495c313 --- /dev/null +++ b/Zend/tests/try_finally_007.phpt @@ -0,0 +1,22 @@ +--TEST-- +Try finally (with goto previous label) +--FILE-- + +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_007.php on line %d diff --git a/Zend/tests/try_finally_008.phpt b/Zend/tests/try_finally_008.phpt new file mode 100644 index 0000000000000..cee37aedabfc2 --- /dev/null +++ b/Zend/tests/try_finally_008.phpt @@ -0,0 +1,21 @@ +--TEST-- +Try finally (with break in do...while) +--FILE-- + +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_008.php on line %d diff --git a/Zend/tests/try_finally_009.phpt b/Zend/tests/try_finally_009.phpt new file mode 100644 index 0000000000000..b29930a75e482 --- /dev/null +++ b/Zend/tests/try_finally_009.phpt @@ -0,0 +1,23 @@ +--TEST-- +Try finally (with for continue) +--FILE-- + +--EXPECTF-- +Fatal error: jump out of a finally block is disallowed in %stry_finally_009.php on line %d diff --git a/Zend/tests/try_finally_010.phpt b/Zend/tests/try_finally_010.phpt new file mode 100644 index 0000000000000..bbac8dd1e5962 --- /dev/null +++ b/Zend/tests/try_finally_010.phpt @@ -0,0 +1,30 @@ +--TEST-- +Try finally (function call in the finaly block after exception) +--FILE-- + 0) print "skip Running on 64-bit target"; ?> +--FILE-- + +--EXPECTF-- +int(-2147450880) +int(2147483646) +float(-2147516415) diff --git a/Zend/tests/zend_signed_multiply-64bit.phpt b/Zend/tests/zend_signed_multiply-64bit.phpt new file mode 100644 index 0000000000000..94a6e035fac3f --- /dev/null +++ b/Zend/tests/zend_signed_multiply-64bit.phpt @@ -0,0 +1,14 @@ +--TEST-- +Zend signed multiply 64-bit +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +int(-9223372034707292160) +int(9223372036854775806) +float(-9.2233720390023E+18) diff --git a/Zend/zend.c b/Zend/zend.c index fc443d95b919b..aad6165e408a3 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -158,9 +158,10 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent, case HASH_KEY_IS_STRING: if (is_object) { const char *prop_name, *class_name; - int mangled = zend_unmangle_property_name(string_key, str_len - 1, &class_name, &prop_name); + int prop_len; + int mangled = zend_unmangle_property_name_ex(string_key, str_len - 1, &class_name, &prop_name, &prop_len); - ZEND_PUTS_EX(prop_name); + ZEND_WRITE_EX(prop_name, prop_len); if (class_name && mangled == SUCCESS) { if (class_name[0]=='*') { ZEND_PUTS_EX(":protected"); @@ -683,11 +684,11 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions TS #if HAVE_DTRACE /* build with dtrace support */ zend_compile_file = dtrace_compile_file; - zend_execute = dtrace_execute; + zend_execute_ex = dtrace_execute_ex; zend_execute_internal = dtrace_execute_internal; #else zend_compile_file = compile_file; - zend_execute = execute; + zend_execute_ex = execute_ex; zend_execute_internal = NULL; #endif /* HAVE_SYS_SDT_H */ zend_compile_string = compile_string; diff --git a/Zend/zend.h b/Zend/zend.h index b6c1a5b8a6f91..40515fbfdd8e2 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -22,7 +22,7 @@ #ifndef ZEND_H #define ZEND_H -#define ZEND_VERSION "2.4.0" +#define ZEND_VERSION "2.6.0-dev" #define ZEND_ENGINE_2 @@ -133,6 +133,11 @@ char *alloca (); # endif #endif +/* Compatibility with non-clang compilers */ +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + /* GCC x.y.z supplies __GNUC__ = x and __GNUC_MINOR__ = y */ #ifdef __GNUC__ # define ZEND_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) @@ -146,6 +151,14 @@ char *alloca (); # define ZEND_ATTRIBUTE_MALLOC #endif +#if ZEND_GCC_VERSION >= 4003 || __has_attribute(alloc_size) +# define ZEND_ATTRIBUTE_ALLOC_SIZE(X) __attribute__ ((alloc_size(X))) +# define ZEND_ATTRIBUTE_ALLOC_SIZE2(X,Y) __attribute__ ((alloc_size(X,Y))) +#else +# define ZEND_ATTRIBUTE_ALLOC_SIZE(X) +# define ZEND_ATTRIBUTE_ALLOC_SIZE2(X,Y) +#endif + #if ZEND_GCC_VERSION >= 2007 # define ZEND_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first))) #else @@ -212,6 +225,7 @@ char *alloca (); #define ZEND_FILE_LINE_EMPTY_CC , ZEND_FILE_LINE_EMPTY_C #define ZEND_FILE_LINE_ORIG_RELAY_C __zend_orig_filename, __zend_orig_lineno #define ZEND_FILE_LINE_ORIG_RELAY_CC , ZEND_FILE_LINE_ORIG_RELAY_C +#define ZEND_ASSERT(c) assert(c) #else #define ZEND_FILE_LINE_D #define ZEND_FILE_LINE_DC @@ -225,6 +239,7 @@ char *alloca (); #define ZEND_FILE_LINE_EMPTY_CC #define ZEND_FILE_LINE_ORIG_RELAY_C #define ZEND_FILE_LINE_ORIG_RELAY_CC +#define ZEND_ASSERT(c) #endif /* ZEND_DEBUG */ #ifdef ZTS @@ -263,10 +278,10 @@ static const char long_min_digits[] = "9223372036854775808"; #define MAX_LENGTH_OF_DOUBLE 32 -#undef SUCCESS -#undef FAILURE -#define SUCCESS 0 -#define FAILURE -1 /* this MUST stay a negative number, or it may affect functions! */ +typedef enum { + SUCCESS = 0, + FAILURE = -1, /* this MUST stay a negative number, or it may affect functions! */ +} ZEND_RESULT_CODE; #include "zend_hash.h" #include "zend_ts_hash.h" @@ -436,8 +451,6 @@ struct _zend_trait_precedence { zend_trait_method_reference *trait_method; zend_class_entry** exclude_from_classes; - - union _zend_function* function; /* FIXME: kept in 5.4 for BC, not used */ }; typedef struct _zend_trait_precedence zend_trait_precedence; @@ -454,8 +467,6 @@ struct _zend_trait_alias { * modifiers to be set on trait method */ zend_uint modifiers; - - union _zend_function* function; /* FIXME: kept in 5.4 for BC, not used */ }; typedef struct _zend_trait_alias zend_trait_alias; diff --git a/Zend/zend_API.c b/Zend/zend_API.c index eec4ab0bb1529..95c90ea753c8d 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -306,16 +306,14 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con { const char *spec_walk = *spec; char c = *spec_walk++; - int return_null = 0; + int check_null = 0; /* scan through modifiers */ while (1) { if (*spec_walk == '/') { SEPARATE_ZVAL_IF_NOT_REF(arg); } else if (*spec_walk == '!') { - if (Z_TYPE_PP(arg) == IS_NULL) { - return_null = 1; - } + check_null = 1; } else { break; } @@ -327,6 +325,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'L': { long *p = va_arg(*va, long *); + + if (check_null) { + zend_bool *p = va_arg(*va, zend_bool *); + *p = (Z_TYPE_PP(arg) == IS_NULL); + } + switch (Z_TYPE_PP(arg)) { case IS_STRING: { @@ -380,6 +384,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'd': { double *p = va_arg(*va, double *); + + if (check_null) { + zend_bool *p = va_arg(*va, zend_bool *); + *p = (Z_TYPE_PP(arg) == IS_NULL); + } + switch (Z_TYPE_PP(arg)) { case IS_STRING: { @@ -418,7 +428,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con int *pl = va_arg(*va, int *); switch (Z_TYPE_PP(arg)) { case IS_NULL: - if (return_null) { + if (check_null) { *p = NULL; *pl = 0; break; @@ -462,6 +472,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'b': { zend_bool *p = va_arg(*va, zend_bool *); + + if (check_null) { + zend_bool *p = va_arg(*va, zend_bool *); + *p = (Z_TYPE_PP(arg) == IS_NULL); + } + switch (Z_TYPE_PP(arg)) { case IS_NULL: case IS_STRING: @@ -484,7 +500,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'r': { zval **p = va_arg(*va, zval **); - if (return_null) { + if (check_null && Z_TYPE_PP(arg) == IS_NULL) { *p = NULL; break; } @@ -499,7 +515,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'a': { zval **p = va_arg(*va, zval **); - if (return_null) { + if (check_null && Z_TYPE_PP(arg) == IS_NULL) { *p = NULL; break; } @@ -514,7 +530,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'h': { HashTable **p = va_arg(*va, HashTable **); - if (return_null) { + if (check_null && Z_TYPE_PP(arg) == IS_NULL) { *p = NULL; break; } @@ -534,7 +550,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'o': { zval **p = va_arg(*va, zval **); - if (return_null) { + if (check_null && Z_TYPE_PP(arg) == IS_NULL) { *p = NULL; break; } @@ -551,7 +567,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con zval **p = va_arg(*va, zval **); zend_class_entry *ce = va_arg(*va, zend_class_entry *); - if (return_null) { + if (check_null && Z_TYPE_PP(arg) == IS_NULL) { *p = NULL; break; } @@ -573,7 +589,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con zend_class_entry **lookup, **pce = va_arg(*va, zend_class_entry **); zend_class_entry *ce_base = *pce; - if (return_null) { + if (check_null && Z_TYPE_PP(arg) == IS_NULL) { *pce = NULL; break; } @@ -607,7 +623,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con zend_fcall_info_cache *fcc = va_arg(*va, zend_fcall_info_cache *); char *is_callable_error = NULL; - if (return_null) { + if (check_null && Z_TYPE_PP(arg) == IS_NULL) { fci->size = 0; fcc->initialized = 0; break; @@ -637,7 +653,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'z': { zval **p = va_arg(*va, zval **); - if (return_null) { + if (check_null && Z_TYPE_PP(arg) == IS_NULL) { *p = NULL; } else { *p = *arg; @@ -648,7 +664,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'Z': { zval ***p = va_arg(*va, zval ***); - if (return_null) { + if (check_null && Z_TYPE_PP(arg) == IS_NULL) { *p = NULL; } else { *p = arg; @@ -697,6 +713,19 @@ static int zend_parse_arg(int arg_num, zval **arg, va_list *va, const char **spe } /* }}} */ +ZEND_API int zend_parse_parameter(int flags, int arg_num TSRMLS_DC, zval **arg, const char *spec, ...) +{ + va_list va; + int ret; + int quiet = flags & ZEND_PARSE_PARAMS_QUIET; + + va_start(va, spec); + ret = zend_parse_arg(arg_num, arg, &va, &spec, quiet TSRMLS_CC); + va_end(va); + + return ret; +} + static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va, int flags TSRMLS_DC) /* {{{ */ { const char *spec_walk; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index e20f8d6240ac3..fb642c1475587 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -258,6 +258,8 @@ ZEND_API char *zend_zval_type_name(const zval *arg); ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...); ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...); +ZEND_API int zend_parse_parameter(int flags, int arg_num TSRMLS_DC, zval **arg, const char *spec, ...); + /* End of parameter parsing API -- andrei */ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type TSRMLS_DC); diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 605e39646367a..fea94dec31186 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -658,9 +658,9 @@ static unsigned int _mem_block_end_magic = 0; #define ZEND_MM_LARGE_BUCKET_INDEX(S) zend_mm_high_bit(S) -static void *_zend_mm_alloc_int(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC; +static void *_zend_mm_alloc_int(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_ALLOC_SIZE(2); static void _zend_mm_free_int(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); -static void *_zend_mm_realloc_int(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +static void *_zend_mm_realloc_int(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_ALLOC_SIZE(3); static inline unsigned int zend_mm_high_bit(size_t _size) { @@ -2494,6 +2494,46 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset) return res; } +#elif defined(__GNUC__) && defined(__arm__) + +static inline size_t safe_address(size_t nmemb, size_t size, size_t offset) +{ + size_t res; + unsigned long overflow; + + __asm__ ("umull %0,%1,%2,%3\n\tadds %0,%4\n\tadc %1,%1" + : "=&r"(res), "=&r"(overflow) + : "r"(nmemb), + "r"(size), + "r"(offset)); + + if (UNEXPECTED(overflow)) { + zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset); + return 0; + } + return res; +} + +#elif defined(__GNUC__) && defined(__aarch64__) + +static inline size_t safe_address(size_t nmemb, size_t size, size_t offset) +{ + size_t res; + unsigned long overflow; + + __asm__ ("mul %0,%2,%3\n\tumulh %1,%2,%3\n\tadds %0,%0,%4\n\tadc %1,%1,%1" + : "=&r"(res), "=&r"(overflow) + : "r"(nmemb), + "r"(size), + "r"(offset)); + + if (UNEXPECTED(overflow)) { + zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset); + return 0; + } + return res; +} + #elif SIZEOF_SIZE_T == 4 && defined(HAVE_ZEND_LONG64) static inline size_t safe_address(size_t nmemb, size_t size, size_t offset) diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h index d456f90d4c7b8..0b4e74d8971a2 100644 --- a/Zend/zend_alloc.h +++ b/Zend/zend_alloc.h @@ -54,12 +54,12 @@ BEGIN_EXTERN_C() ZEND_API char *zend_strndup(const char *s, unsigned int length) ZEND_ATTRIBUTE_MALLOC; -ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC; +ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_ALLOC_SIZE(1); 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 void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_ALLOC_SIZE2(1,2); +ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_ALLOC_SIZE(2); ZEND_API void *_safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API void *_safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset); ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC; diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index fcd1deac67e49..4d950a203b31e 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -987,7 +987,7 @@ ZEND_FUNCTION(get_object_vars) HashPosition pos; char *key; const char *prop_name, *class_name; - uint key_len; + uint key_len, prop_len; ulong num_index; zend_object *zobj; @@ -1014,10 +1014,10 @@ ZEND_FUNCTION(get_object_vars) 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 (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) == SUCCESS) { - zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name); + zend_unmangle_property_name_ex(key, key_len - 1, &class_name, &prop_name, &prop_len); /* Not separating references */ Z_ADDREF_PP(value); - add_assoc_zval_ex(return_value, prop_name, strlen(prop_name)+1, *value); + add_assoc_zval_ex(return_value, prop_name, prop_len + 1, *value); } } zend_hash_move_forward_ex(properties, &pos); @@ -1512,7 +1512,6 @@ ZEND_FUNCTION(trigger_error) ZEND_FUNCTION(set_error_handler) { zval *error_handler; - zend_bool had_orig_error_handler=0; char *error_handler_name = NULL; long error_type = E_ALL; @@ -1520,38 +1519,31 @@ ZEND_FUNCTION(set_error_handler) return; } - if (!zend_is_callable(error_handler, 0, &error_handler_name TSRMLS_CC)) { - 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"); + if (Z_TYPE_P(error_handler) != IS_NULL) { /* NULL == unset */ + if (!zend_is_callable(error_handler, 0, &error_handler_name TSRMLS_CC)) { + 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); + return; + } efree(error_handler_name); - return; } - efree(error_handler_name); if (EG(user_error_handler)) { - had_orig_error_handler = 1; - *return_value = *EG(user_error_handler); - zval_copy_ctor(return_value); - INIT_PZVAL(return_value); + RETVAL_ZVAL(EG(user_error_handler), 1, 0); + 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 */ - FREE_ZVAL(EG(user_error_handler)); + if (Z_TYPE_P(error_handler) == IS_NULL) { /* unset user-defined handler */ EG(user_error_handler) = NULL; - RETURN_TRUE; + return; } + ALLOC_ZVAL(EG(user_error_handler)); + MAKE_COPY_ZVAL(&error_handler, EG(user_error_handler)); EG(user_error_handler_error_reporting) = (int)error_type; - *EG(user_error_handler) = *error_handler; - zval_copy_ctor(EG(user_error_handler)); - INIT_PZVAL(EG(user_error_handler)); - - if (!had_orig_error_handler) { - RETURN_NULL(); - } } /* }}} */ @@ -1585,7 +1577,6 @@ ZEND_FUNCTION(set_exception_handler) { zval *exception_handler; char *exception_handler_name = NULL; - zend_bool had_orig_exception_handler=0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &exception_handler) == FAILURE) { return; @@ -1602,24 +1593,18 @@ ZEND_FUNCTION(set_exception_handler) } if (EG(user_exception_handler)) { - had_orig_exception_handler = 1; - *return_value = *EG(user_exception_handler); - zval_copy_ctor(return_value); + RETVAL_ZVAL(EG(user_exception_handler), 1, 0); + zend_ptr_stack_push(&EG(user_exception_handlers), EG(user_exception_handler)); } - ALLOC_ZVAL(EG(user_exception_handler)); if (Z_TYPE_P(exception_handler) == IS_NULL) { /* unset user-defined handler */ - FREE_ZVAL(EG(user_exception_handler)); EG(user_exception_handler) = NULL; - RETURN_TRUE; + return; } + ALLOC_ZVAL(EG(user_exception_handler)); MAKE_COPY_ZVAL(&exception_handler, EG(user_exception_handler)) - - if (!had_orig_exception_handler) { - RETURN_NULL(); - } } /* }}} */ diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 8f4f9c47b87b0..1a8d10890060b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5,7 +5,7 @@ | Copyright (c) 1998-2013 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 | + | 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 | @@ -107,7 +107,7 @@ ZEND_API zend_executor_globals executor_globals; static void zend_duplicate_property_info(zend_property_info *property_info) /* {{{ */ { - if (!IS_INTERNED(property_info->name)) { + if (!IS_INTERNED(property_info->name)) { property_info->name = estrndup(property_info->name, property_info->name_length); } if (property_info->doc_comment) { @@ -118,7 +118,7 @@ static void zend_duplicate_property_info(zend_property_info *property_info) /* { static void zend_duplicate_property_info_internal(zend_property_info *property_info) /* {{{ */ { - if (!IS_INTERNED(property_info->name)) { + if (!IS_INTERNED(property_info->name)) { property_info->name = zend_strndup(property_info->name, property_info->name_length); } } @@ -179,6 +179,9 @@ void zend_init_compiler_context(TSRMLS_D) /* {{{ */ CG(context).literals_size = 0; CG(context).current_brk_cont = -1; CG(context).backpatch_count = 0; + CG(context).nested_calls = 0; + CG(context).used_stack = 0; + CG(context).in_finally = 0; CG(context).labels = NULL; } /* }}} */ @@ -285,7 +288,7 @@ ZEND_API zend_bool zend_is_compiling(TSRMLS_D) /* {{{ */ static zend_uint get_temporary_variable(zend_op_array *op_array) /* {{{ */ { - return (op_array->T)++ * ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)); + return (zend_uint)EX_TMP_VAR_NUM(0, (op_array->T)++); } /* }}} */ @@ -380,7 +383,7 @@ int zend_add_func_name_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC zval c; int lc_literal; - if (op_array->last_literal > 0 && + if (op_array->last_literal > 0 && &op_array->literals[op_array->last_literal - 1].constant == zv && op_array->literals[op_array->last_literal - 1].cache_slot == -1) { /* we already have function name as last literal (do nothing) */ @@ -388,7 +391,7 @@ int zend_add_func_name_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC } else { ret = zend_add_literal(op_array, zv TSRMLS_CC); } - + lc_name = zend_str_tolower_dup(Z_STRVAL_P(zv), Z_STRLEN_P(zv)); ZVAL_STRINGL(&c, lc_name, Z_STRLEN_P(zv), 0); lc_literal = zend_add_literal(CG(active_op_array), &c TSRMLS_CC); @@ -407,7 +410,7 @@ int zend_add_ns_func_name_literal(zend_op_array *op_array, const zval *zv TSRMLS zval c; int lc_literal; - if (op_array->last_literal > 0 && + if (op_array->last_literal > 0 && &op_array->literals[op_array->last_literal - 1].constant == zv && op_array->literals[op_array->last_literal - 1].cache_slot == -1) { /* we already have function name as last literal (do nothing) */ @@ -440,7 +443,7 @@ int zend_add_class_name_literal(zend_op_array *op_array, const zval *zv TSRMLS_D zval c; int lc_literal; - if (op_array->last_literal > 0 && + if (op_array->last_literal > 0 && &op_array->literals[op_array->last_literal - 1].constant == zv && op_array->literals[op_array->last_literal - 1].cache_slot == -1) { /* we already have function name as last literal (do nothing) */ @@ -474,7 +477,7 @@ int zend_add_const_name_literal(zend_op_array *op_array, const zval *zv, int unq int name_len, ns_len; zval c; - if (op_array->last_literal > 0 && + if (op_array->last_literal > 0 && &op_array->literals[op_array->last_literal - 1].constant == zv && op_array->literals[op_array->last_literal - 1].cache_slot == -1) { /* we already have function name as last literal (do nothing) */ @@ -483,7 +486,7 @@ int zend_add_const_name_literal(zend_op_array *op_array, const zval *zv, int unq ret = zend_add_literal(op_array, zv TSRMLS_CC); } - /* skip leading '\\' */ + /* skip leading '\\' */ if (Z_STRVAL_P(zv)[0] == '\\') { name_len = Z_STRLEN_P(zv) - 1; name = Z_STRVAL_P(zv) + 1; @@ -813,7 +816,7 @@ void fetch_array_dim(znode *result, const znode *parent, const znode *dim TSRMLS opline.result.var = opline.op1.var; zend_llist_add_element(fetch_list_ptr, &opline); } - + init_op(&opline TSRMLS_CC); opline.opcode = ZEND_FETCH_DIM_W; /* the backpatching routine assumes W */ opline.result_type = IS_VAR; @@ -827,12 +830,12 @@ void fetch_array_dim(znode *result, const znode *parent, const znode *dim TSRMLS ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline.op2.constant)), Z_STRLEN(CONSTANT(opline.op2.constant))+1, index, numeric = 1); if (numeric) { zval_dtor(&CONSTANT(opline.op2.constant)); - ZVAL_LONG(&CONSTANT(opline.op2.constant), index); + ZVAL_LONG(&CONSTANT(opline.op2.constant), index); } else { CALCULATE_LITERAL_HASH(opline.op2.constant); } } - + GET_NODE(result, opline.result); zend_llist_add_element(fetch_list_ptr, &opline); @@ -937,7 +940,7 @@ void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC) /* { opline->result.var = get_temporary_variable(CG(active_op_array)); opline->op1_type = IS_CONST; LITERAL_STRINGL(opline->op1, - CG(active_op_array)->vars[value->u.op.var].name, + CG(active_op_array)->vars[value->u.op.var].name, CG(active_op_array)->vars[value->u.op.var].name_len, 1); CALCULATE_LITERAL_HASH(opline->op1.constant); SET_UNUSED(opline->op2); @@ -1566,7 +1569,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n if (is_method) { int result; - + lcname = zend_new_interned_string(zend_str_tolower_dup(name, name_len), name_len + 1, 1 TSRMLS_CC); if (IS_INTERNED(lcname)) { @@ -1621,7 +1624,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n } } else { char *class_lcname; - + class_lcname = do_alloca(CG(active_class_entry)->name_length + 1, use_heap); zend_str_tolower_copy(class_lcname, CG(active_class_entry)->name, CG(active_class_entry)->name_length); /* Improve after RC: cache the lowercase class name */ @@ -1672,7 +1675,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n } else if ((name_len == sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME)-1))) { if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) { zend_error(E_WARNING, "The magic method __toString() must have public visibility and cannot be static"); - } + } CG(active_class_entry)->__tostring = (zend_function *) CG(active_op_array); } else if (!(fn_flags & ZEND_ACC_STATIC)) { CG(active_op_array)->fn_flags |= ZEND_ACC_ALLOW_STATIC; @@ -1723,7 +1726,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n } { - /* Push a seperator to the switch and foreach stacks */ + /* Push a seperator to the switch stack */ zend_switch_entry switch_entry; switch_entry.cond.op_type = IS_UNUSED; @@ -1731,16 +1734,16 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n switch_entry.control_var = 0; zend_stack_push(&CG(switch_cond_stack), (void *) &switch_entry, sizeof(switch_entry)); + } - { - /* Foreach stack separator */ - zend_op dummy_opline; + { + /* Push a separator to the foreach stack */ + zend_op dummy_opline; - dummy_opline.result_type = IS_UNUSED; - dummy_opline.op1_type = IS_UNUSED; + dummy_opline.result_type = IS_UNUSED; + dummy_opline.op1_type = IS_UNUSED; - zend_stack_push(&CG(foreach_copy_stack), (void *) &dummy_opline, sizeof(zend_op)); - } + zend_stack_push(&CG(foreach_copy_stack), (void *) &dummy_opline, sizeof(zend_op)); } if (CG(doc_comment)) { @@ -1803,14 +1806,14 @@ void zend_do_end_function_declaration(const znode *function_token TSRMLS_DC) /* if (CG(active_class_entry)) { zend_check_magic_method_implementation(CG(active_class_entry), (zend_function*)CG(active_op_array), E_COMPILE_ERROR TSRMLS_CC); } else { - /* we don't care if the function name is longer, in fact lowercasing only + /* 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(CG(active_op_array)->function_name); zend_str_tolower_copy(lcname, CG(active_op_array)->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_AUTOLOAD_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_AUTOLOAD_FUNC_NAME, sizeof(ZEND_AUTOLOAD_FUNC_NAME)) && CG(active_op_array)->num_args != 1) { zend_error(E_COMPILE_ERROR, "%s() must take exactly 1 argument", ZEND_AUTOLOAD_FUNC_NAME); - } + } } CG(active_op_array)->line_end = zend_get_compiled_lineno(TSRMLS_C); @@ -1936,7 +1939,7 @@ int zend_do_begin_function_call(znode *function_name, zend_bool check_namespace internal function with short name */ zend_do_begin_dynamic_function_call(function_name, 1 TSRMLS_CC); return 1; - } + } lcname = zend_str_tolower_dup(function_name->u.constant.value.str.val, function_name->u.constant.value.str.len); if ((zend_hash_find(CG(function_table), lcname, function_name->u.constant.value.str.len+1, (void **) &function)==FAILURE) || @@ -1945,11 +1948,14 @@ int zend_do_begin_function_call(znode *function_name, zend_bool check_namespace zend_do_begin_dynamic_function_call(function_name, 0 TSRMLS_CC); efree(lcname); return 1; /* Dynamic */ - } + } efree(function_name->u.constant.value.str.val); function_name->u.constant.value.str.val = lcname; - + zend_stack_push(&CG(function_call_stack), (void *) &function, sizeof(zend_function *)); + if (CG(context).nested_calls + 1 > CG(active_op_array)->nested_calls) { + CG(active_op_array)->nested_calls = CG(context).nested_calls + 1; + } zend_do_extended_fcall_begin(TSRMLS_C); return 0; } @@ -1978,7 +1984,7 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC) /* {{{ */ name = CONSTANT(last_op->op2.constant); if (Z_TYPE(name) != IS_STRING) { zend_error(E_COMPILE_ERROR, "Method name must be a string"); - } + } if (!IS_INTERNED(Z_STRVAL(name))) { Z_STRVAL(name) = estrndup(Z_STRVAL(name), Z_STRLEN(name)); } @@ -1988,11 +1994,13 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC) /* {{{ */ GET_POLYMORPHIC_CACHE_SLOT(last_op->op2.constant); } last_op->opcode = ZEND_INIT_METHOD_CALL; - SET_UNUSED(last_op->result); + last_op->result_type = IS_UNUSED; + last_op->result.num = CG(context).nested_calls; Z_LVAL(left_bracket->u.constant) = ZEND_INIT_FCALL_BY_NAME; } else { zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_INIT_FCALL_BY_NAME; + opline->result.num = CG(context).nested_calls; SET_UNUSED(opline->op1); if (left_bracket->op_type == IS_CONST) { opline->op2_type = IS_CONST; @@ -2004,6 +2012,9 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC) /* {{{ */ } zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); + if (++CG(context).nested_calls > CG(active_op_array)->nested_calls) { + CG(active_op_array)->nested_calls = CG(context).nested_calls; + } zend_do_extended_fcall_begin(TSRMLS_C); } /* }}} */ @@ -2031,12 +2042,14 @@ void zend_do_begin_dynamic_function_call(znode *function_name, int ns_call TSRML /* In run-time PHP will check for function with full name and internal function with short name */ opline->opcode = ZEND_INIT_NS_FCALL_BY_NAME; + opline->result.num = CG(context).nested_calls; SET_UNUSED(opline->op1); opline->op2_type = IS_CONST; opline->op2.constant = zend_add_ns_func_name_literal(CG(active_op_array), &function_name->u.constant TSRMLS_CC); GET_CACHE_SLOT(opline->op2.constant); } else { opline->opcode = ZEND_INIT_FCALL_BY_NAME; + opline->result.num = CG(context).nested_calls; SET_UNUSED(opline->op1); if (function_name->op_type == IS_CONST) { opline->op2_type = IS_CONST; @@ -2048,6 +2061,9 @@ void zend_do_begin_dynamic_function_call(znode *function_name, int ns_call TSRML } zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); + if (++CG(context).nested_calls > CG(active_op_array)->nested_calls) { + CG(active_op_array)->nested_calls = CG(context).nested_calls; + } zend_do_extended_fcall_begin(TSRMLS_C); } /* }}} */ @@ -2103,6 +2119,53 @@ void zend_resolve_non_class_name(znode *element_name, zend_bool check_namespace } /* }}} */ +void zend_do_resolve_class_name(znode *result, znode *class_name, int is_static TSRMLS_DC) /* {{{ */ +{ + char *lcname; + int lctype; + znode constant_name; + + lcname = zend_str_tolower_dup(Z_STRVAL(class_name->u.constant), class_name->u.constant.value.str.len); + lctype = zend_get_class_fetch_type(lcname, strlen(lcname)); + switch (lctype) { + case ZEND_FETCH_CLASS_SELF: + if (!CG(active_class_entry)) { + zend_error(E_COMPILE_ERROR, "Cannot access self::class when no class scope is active"); + } + zval_dtor(&class_name->u.constant); + class_name->op_type = IS_CONST; + ZVAL_STRINGL(&class_name->u.constant, CG(active_class_entry)->name, CG(active_class_entry)->name_length, 1); + *result = *class_name; + break; + case ZEND_FETCH_CLASS_STATIC: + case ZEND_FETCH_CLASS_PARENT: + if (is_static) { + zend_error(E_COMPILE_ERROR, + "%s::class cannot be used for compile-time class name resolution", + lctype == ZEND_FETCH_CLASS_STATIC ? "static" : "parent" + ); + } + if (!CG(active_class_entry)) { + zend_error(E_COMPILE_ERROR, + "Cannot access %s::class when no class scope is active", + lctype == ZEND_FETCH_CLASS_STATIC ? "static" : "parent" + ); + } + constant_name.op_type = IS_CONST; + ZVAL_STRINGL(&constant_name.u.constant, "class", sizeof("class")-1, 1); + zend_do_fetch_constant(result, class_name, &constant_name, ZEND_RT, 1 TSRMLS_CC); + break; + case ZEND_FETCH_CLASS_DEFAULT: + zend_resolve_class_name(class_name, ZEND_FETCH_CLASS_GLOBAL, 1 TSRMLS_CC); + *result = *class_name; + break; + } + + efree(lcname); + +} +/* }}} */ + void zend_resolve_class_name(znode *class_name, ulong fetch_type, int check_ns_name TSRMLS_DC) /* {{{ */ { char *compound; @@ -2125,7 +2188,7 @@ void zend_resolve_class_name(znode *class_name, ulong fetch_type, int check_ns_n if (ZEND_FETCH_CLASS_DEFAULT != zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant))) { zend_error(E_COMPILE_ERROR, "'\\%s' is an invalid class name", Z_STRVAL(class_name->u.constant)); } - } else { + } else { if (CG(current_import)) { len = compound - Z_STRVAL(class_name->u.constant); lcname = zend_str_tolower_dup(Z_STRVAL(class_name->u.constant), len); @@ -2395,6 +2458,7 @@ int zend_do_begin_class_member_function_call(znode *class_name, znode *method_na opline->extended_value = class_node.EA ; } opline->opcode = ZEND_INIT_STATIC_METHOD_CALL; + opline->result.num = CG(context).nested_calls; if (class_node.op_type == IS_CONST) { opline->op1_type = IS_CONST; opline->op1.constant = @@ -2416,6 +2480,9 @@ int zend_do_begin_class_member_function_call(znode *class_name, znode *method_na } zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); + if (++CG(context).nested_calls > CG(active_op_array)->nested_calls) { + CG(active_op_array)->nested_calls = CG(context).nested_calls; + } zend_do_extended_fcall_begin(TSRMLS_C); return 1; /* Dynamic */ } @@ -2436,21 +2503,29 @@ void zend_do_end_function_call(znode *function_name, znode *result, const znode if (!is_method && !is_dynamic_fcall && function_name->op_type==IS_CONST) { opline->opcode = ZEND_DO_FCALL; SET_NODE(opline->op1, function_name); + SET_UNUSED(opline->op2); + opline->op2.num = CG(context).nested_calls; CALCULATE_LITERAL_HASH(opline->op1.constant); GET_CACHE_SLOT(opline->op1.constant); } else { opline->opcode = ZEND_DO_FCALL_BY_NAME; SET_UNUSED(opline->op1); + SET_UNUSED(opline->op2); + opline->op2.num = --CG(context).nested_calls; } } opline->result.var = get_temporary_variable(CG(active_op_array)); opline->result_type = IS_VAR; - GET_NODE(result, opline->result) ; - SET_UNUSED(opline->op2); + GET_NODE(result, opline->result); zend_stack_del_top(&CG(function_call_stack)); opline->extended_value = Z_LVAL(argument_list->u.constant); + + if (CG(context).used_stack + 1 > CG(active_op_array)->used_stack) { + CG(active_op_array)->used_stack = CG(context).used_stack + 1; + } + CG(context).used_stack -= Z_LVAL(argument_list->u.constant); } /* }}} */ @@ -2478,8 +2553,8 @@ void zend_do_pass_param(znode *param, zend_uchar op, int offset TSRMLS_DC) /* {{ zend_error(E_COMPILE_ERROR, "Call-time pass-by-reference has been removed"); } return; - } - + } + if (function_ptr) { if (ARG_MAY_BE_SENT_BY_REF(function_ptr, (zend_uint) offset)) { if (param->op_type & (IS_VAR|IS_CV) && original_op != ZEND_SEND_VAL) { @@ -2558,6 +2633,10 @@ void zend_do_pass_param(znode *param, zend_uchar op, int offset TSRMLS_DC) /* {{ SET_NODE(opline->op1, param); opline->op2.opline_num = offset; SET_UNUSED(opline->op2); + + if (++CG(context).used_stack > CG(active_op_array)->used_stack) { + CG(active_op_array)->used_stack = CG(context).used_stack; + } } /* }}} */ @@ -2612,9 +2691,12 @@ void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC) /* {{{ */ { zend_op *opline; int start_op_number, end_op_number; + zend_bool returns_reference = (CG(active_op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0; + + /* The error for use of return inside a generator is thrown in pass_two. */ if (do_end_vparse) { - if ((CG(active_op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_is_function_or_method_call(expr)) { + if (returns_reference && !zend_is_function_or_method_call(expr)) { zend_do_end_variable_parse(expr, BP_VAR_W, 0 TSRMLS_CC); } else { zend_do_end_variable_parse(expr, BP_VAR_R, 0 TSRMLS_CC); @@ -2637,9 +2719,16 @@ void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC) /* {{{ */ start_op_number++; } + if (CG(context).in_finally) { + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + opline->opcode = ZEND_DISCARD_EXCEPTION; + SET_UNUSED(opline->op1); + SET_UNUSED(opline->op2); + } + opline = get_next_op(CG(active_op_array) TSRMLS_CC); - opline->opcode = (CG(active_op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) ? ZEND_RETURN_BY_REF : ZEND_RETURN; + opline->opcode = returns_reference ? ZEND_RETURN_BY_REF : ZEND_RETURN; if (expr) { SET_NODE(opline->op1, expr); @@ -2656,12 +2745,59 @@ void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC) /* {{{ */ } /* }}} */ +void zend_do_yield(znode *result, znode *value, const znode *key, zend_bool is_variable TSRMLS_DC) /* {{{ */ +{ + zend_op *opline; + + if (!CG(active_op_array)->function_name) { + zend_error(E_COMPILE_ERROR, "The \"yield\" expression can only be used inside a function"); + } + + CG(active_op_array)->fn_flags |= ZEND_ACC_GENERATOR; + + if (is_variable) { + if ((CG(active_op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_is_function_or_method_call(value)) { + zend_do_end_variable_parse(value, BP_VAR_W, 0 TSRMLS_CC); + } else { + zend_do_end_variable_parse(value, BP_VAR_R, 0 TSRMLS_CC); + } + } + + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + + opline->opcode = ZEND_YIELD; + + if (value) { + SET_NODE(opline->op1, value); + + if (is_variable && zend_is_function_or_method_call(value)) { + opline->extended_value = ZEND_RETURNS_FUNCTION; + } + } else { + SET_UNUSED(opline->op1); + } + + if (key) { + SET_NODE(opline->op2, key); + } else { + SET_UNUSED(opline->op2); + } + + opline->result_type = IS_TMP_VAR; + opline->result.var = get_temporary_variable(CG(active_op_array)); + GET_NODE(result, opline->result); +} +/* }}} */ + static int zend_add_try_element(zend_uint try_op TSRMLS_DC) /* {{{ */ { int try_catch_offset = CG(active_op_array)->last_try_catch++; CG(active_op_array)->try_catch_array = erealloc(CG(active_op_array)->try_catch_array, sizeof(zend_try_catch_element)*CG(active_op_array)->last_try_catch); CG(active_op_array)->try_catch_array[try_catch_offset].try_op = try_op; + CG(active_op_array)->try_catch_array[try_catch_offset].catch_op = 0; + CG(active_op_array)->try_catch_array[try_catch_offset].finally_op = 0; + CG(active_op_array)->try_catch_array[try_catch_offset].finally_end = 0; return try_catch_offset; } /* }}} */ @@ -2678,7 +2814,7 @@ void zend_do_first_catch(znode *open_parentheses TSRMLS_DC) /* {{{ */ } /* }}} */ -void zend_initialize_try_catch_element(const znode *try_token TSRMLS_DC) /* {{{ */ +void zend_initialize_try_catch_element(znode *catch_token TSRMLS_DC) /* {{{ */ { int jmp_op_number = get_next_op_number(CG(active_op_array)); zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); @@ -2695,7 +2831,7 @@ void zend_initialize_try_catch_element(const znode *try_token TSRMLS_DC) /* {{{ zend_stack_top(&CG(bp_stack), (void **) &jmp_list_ptr); zend_llist_add_element(jmp_list_ptr, &jmp_op_number); - zend_add_catch_element(try_token->u.op.opline_num, get_next_op_number(CG(active_op_array)) TSRMLS_CC); + catch_token->EA = get_next_op_number(CG(active_op_array)); } /* }}} */ @@ -2721,7 +2857,29 @@ void zend_do_try(znode *try_token TSRMLS_DC) /* {{{ */ } /* }}} */ -void zend_do_begin_catch(znode *try_token, znode *class_name, znode *catch_var, znode *first_catch TSRMLS_DC) /* {{{ */ +void zend_do_finally(znode *finally_token TSRMLS_DC) /* {{{ */ +{ + zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); + + finally_token->u.op.opline_num = get_next_op_number(CG(active_op_array)); + /* call the the "finally" block */ + opline->opcode = ZEND_FAST_CALL; + SET_UNUSED(opline->op1); + opline->op1.opline_num = finally_token->u.op.opline_num + 1; + SET_UNUSED(opline->op2); + /* jump to code after the "finally" block, + * the actual jump address is going to be set in zend_do_end_finally() + */ + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + opline->opcode = ZEND_JMP; + SET_UNUSED(opline->op1); + SET_UNUSED(opline->op2); + + CG(context).in_finally++; +} +/* }}} */ + +void zend_do_begin_catch(znode *catch_token, znode *class_name, znode *catch_var, znode *first_catch TSRMLS_DC) /* {{{ */ { long catch_op_number; zend_op *opline; @@ -2749,11 +2907,11 @@ void zend_do_begin_catch(znode *try_token, znode *class_name, znode *catch_var, Z_STRVAL(catch_var->u.constant) = (char*)CG(active_op_array)->vars[opline->op2.var].name; opline->result.num = 0; /* 1 means it's the last catch in the block */ - try_token->u.op.opline_num = catch_op_number; + catch_token->u.op.opline_num = catch_op_number; } /* }}} */ -void zend_do_end_catch(const znode *try_token TSRMLS_DC) /* {{{ */ +void zend_do_end_catch(znode *catch_token TSRMLS_DC) /* {{{ */ { int jmp_op_number = get_next_op_number(CG(active_op_array)); zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); @@ -2767,7 +2925,38 @@ void zend_do_end_catch(const znode *try_token TSRMLS_DC) /* {{{ */ zend_stack_top(&CG(bp_stack), (void **) &jmp_list_ptr); zend_llist_add_element(jmp_list_ptr, &jmp_op_number); - CG(active_op_array)->opcodes[try_token->u.op.opline_num].extended_value = get_next_op_number(CG(active_op_array)); + CG(active_op_array)->opcodes[catch_token->u.op.opline_num].extended_value = get_next_op_number(CG(active_op_array)); +} +/* }}} */ + +void zend_do_bind_catch(znode *try_token, znode *catch_token TSRMLS_DC) /* {{{ */ { + if (catch_token->op_type != IS_UNUSED) { + zend_add_catch_element(try_token->u.op.opline_num, catch_token->EA TSRMLS_CC); + } +} +/* }}} */ + +void zend_do_end_finally(znode *try_token, znode* catch_token, znode *finally_token TSRMLS_DC) /* {{{ */ +{ + if (catch_token->op_type == IS_UNUSED && finally_token->op_type == IS_UNUSED) { + zend_error(E_COMPILE_ERROR, "Cannot use try without catch or finally"); + } + if (finally_token->op_type != IS_UNUSED) { + zend_op *opline; + + CG(active_op_array)->try_catch_array[try_token->u.op.opline_num].finally_op = finally_token->u.op.opline_num + 1; + CG(active_op_array)->try_catch_array[try_token->u.op.opline_num].finally_end = get_next_op_number(CG(active_op_array)); + CG(active_op_array)->has_finally_block = 1; + + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + opline->opcode = ZEND_FAST_RET; + SET_UNUSED(opline->op1); + SET_UNUSED(opline->op2); + + CG(active_op_array)->opcodes[finally_token->u.op.opline_num].op1.opline_num = get_next_op_number(CG(active_op_array)); + + CG(context).in_finally--; + } } /* }}} */ @@ -2874,7 +3063,7 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */ lc_class_name = zend_str_tolower_dup(ce->name, ce->name_length); if (!zend_hash_exists(&ce->function_table, lc_class_name, ce->name_length+1)) { lc_parent_class_name = zend_str_tolower_dup(ce->parent->name, ce->parent->name_length); - if (!zend_hash_exists(&ce->function_table, lc_parent_class_name, ce->parent->name_length+1) && + if (!zend_hash_exists(&ce->function_table, lc_parent_class_name, ce->parent->name_length+1) && zend_hash_find(&ce->parent->function_table, lc_parent_class_name, ce->parent->name_length+1, (void **)&function)==SUCCESS) { if (function->common.fn_flags & ZEND_ACC_CTOR) { /* inherit parent's constructor */ @@ -3013,8 +3202,8 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c return 0; } } - } - } + } + } if (fe->common.arg_info[i].type_hint != proto->common.arg_info[i].type_hint) { /* Incompatible type hint */ return 0; @@ -3043,7 +3232,7 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c buf = erealloc(buf, length); \ } -static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{{ */ +static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{{ */ { char *offset, *buf; zend_uint length = 1024; @@ -3060,7 +3249,7 @@ static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{ *(offset++) = ':'; *(offset++) = ':'; } - + { size_t name_len = strlen(fptr->common.function_name); REALLOC_BUF_IF_EXCEED(buf, offset, length, name_len); @@ -3101,7 +3290,7 @@ static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{ offset += type_name_len; *(offset++) = ' '; } - + if (arg_info->pass_by_reference) { *(offset++) = '&'; } @@ -3203,7 +3392,7 @@ static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{ *offset = '\0'; return buf; -} +} /* }}} */ static void do_inheritance_check_on_method(zend_function *child, zend_function *parent TSRMLS_DC) /* {{{ */ @@ -3215,7 +3404,7 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function * && parent->common.fn_flags & ZEND_ACC_ABSTRACT && parent->common.scope != (child->common.prototype ? child->common.prototype->common.scope : child->common.scope) && child->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_IMPLEMENTED_ABSTRACT)) { - zend_error(E_COMPILE_ERROR, "Can't inherit abstract function %s::%s() (previously declared abstract in %s)", + zend_error(E_COMPILE_ERROR, "Can't inherit abstract function %s::%s() (previously declared abstract in %s)", parent->common.scope->name, child->common.function_name, child->common.prototype ? child->common.prototype->common.scope->name : child->common.scope->name); @@ -3255,7 +3444,7 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function * } if (parent_flags & ZEND_ACC_PRIVATE) { - child->common.prototype = NULL; + child->common.prototype = NULL; } else if (parent_flags & ZEND_ACC_ABSTRACT) { child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT; child->common.prototype = parent; @@ -3266,12 +3455,12 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function * if (child->common.prototype && (child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT)) { if (!zend_do_perform_implementation_check(child, child->common.prototype TSRMLS_CC)) { - zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, zend_get_function_declaration(child->common.prototype? child->common.prototype : parent TSRMLS_CC)); + zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, zend_get_function_declaration(child->common.prototype? child->common.prototype : parent TSRMLS_CC)); } } else if (EG(error_reporting) & E_STRICT || EG(user_error_handler)) { /* Check E_STRICT (or custom error handler) before the check so that we save some time */ if (!zend_do_perform_implementation_check(child, parent TSRMLS_CC)) { char *method_prototype = zend_get_function_declaration(child->common.prototype? child->common.prototype : parent TSRMLS_CC); - zend_error(E_STRICT, "Declaration of %s::%s() should be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, method_prototype); + zend_error(E_STRICT, "Declaration of %s::%s() should be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, method_prototype); efree(method_prototype); } } @@ -3290,9 +3479,9 @@ static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_f } return 1; /* method doesn't exist in child, copy from parent */ } - + do_inheritance_check_on_method(child, parent TSRMLS_CC); - + return 0; } /* }}} */ @@ -3323,7 +3512,7 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro zend_error(E_COMPILE_ERROR, "Cannot redeclare %s%s::$%s as %s%s::$%s", (parent_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", parent_ce->name, hash_key->arKey, (child_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ce->name, hash_key->arKey); - + } if(parent_info->flags & ZEND_ACC_CHANGED) { @@ -3589,10 +3778,10 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry } } ce->interfaces[ce->num_interfaces++] = iface; - + zend_hash_merge_ex(&ce->constants_table, &iface->constants_table, (copy_ctor_func_t) zval_add_ref, sizeof(zval *), (merge_checker_func_t) do_inherit_constant_check, iface); zend_hash_merge_ex(&ce->function_table, &iface->function_table, (copy_ctor_func_t) do_inherit_method, sizeof(zend_function), (merge_checker_func_t) do_inherit_method_check, ce); - + do_implement_interface(ce, iface TSRMLS_CC); zend_do_inherit_interfaces(ce, iface TSRMLS_CC); } @@ -3632,10 +3821,10 @@ static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_ { zend_uint fn_flags = fn->common.scope->ce_flags; zend_uint other_flags = other_fn->common.scope->ce_flags; - + return zend_do_perform_implementation_check(fn, other_fn TSRMLS_CC) && zend_do_perform_implementation_check(other_fn, fn TSRMLS_CC) - && ((fn_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC)) == + && ((fn_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC)) == (other_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC))); /* equal final and static qualifier */ } /* }}} */ @@ -3648,7 +3837,7 @@ static void zend_add_magic_methods(zend_class_entry* ce, const char* mname, uint if (ce->constructor) { zend_error(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ce->name); } - ce->constructor = fe; fe->common.fn_flags |= ZEND_ACC_CTOR; + ce->constructor = fe; fe->common.fn_flags |= ZEND_ACC_CTOR; } else if (!strncmp(mname, ZEND_DESTRUCTOR_FUNC_NAME, mname_len)) { ce->destructor = fe; fe->common.fn_flags |= ZEND_ACC_DTOR; } else if (!strncmp(mname, ZEND_GET_FUNC_NAME, mname_len)) { @@ -3785,7 +3974,7 @@ static int zend_traits_copy_functions(zend_function *fn TSRMLS_DC, int num_args, ce = va_arg(args, zend_class_entry*); overriden = va_arg(args, HashTable**); exclude_table = va_arg(args, HashTable*); - + fnname_len = strlen(fn->common.function_name); /* apply aliases which are qualified with a class name, there should not be any ambiguity */ @@ -3799,9 +3988,9 @@ static int zend_traits_copy_functions(zend_function *fn TSRMLS_DC, int num_args, && alias->trait_method->mname_len == fnname_len && (zend_binary_strcasecmp(alias->trait_method->method_name, alias->trait_method->mname_len, fn->common.function_name, fnname_len) == 0)) { fn_copy = *fn; - + /* if it is 0, no modifieres has been changed */ - if (alias->modifiers) { + if (alias->modifiers) { fn_copy.common.fn_flags = alias->modifiers | (fn->common.fn_flags ^ (fn->common.fn_flags & ZEND_ACC_PPP_MASK)); } @@ -3904,7 +4093,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /* cur_method_ref->ce->name, cur_method_ref->method_name); } - + /** With the other traits, we are more permissive. We do not give errors for those. This allows to be more defensive in such definitions. @@ -3918,20 +4107,20 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /* if (!(cur_precedence->exclude_from_classes[j] = zend_fetch_class(class_name, name_length, ZEND_FETCH_CLASS_TRAIT |ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC))) { zend_error(E_COMPILE_ERROR, "Could not find trait %s", class_name); - } + } zend_check_trait_usage(ce, cur_precedence->exclude_from_classes[j] TSRMLS_CC); /* make sure that the trait method is not from a class mentioned in exclude_from_classes, for consistency */ if (cur_precedence->trait_method->ce == cur_precedence->exclude_from_classes[i]) { zend_error(E_COMPILE_ERROR, - "Inconsistent insteadof definition. " + "Inconsistent insteadof definition. " "The method %s is to be used from %s, but %s is also on the exclude list", cur_method_ref->method_name, cur_precedence->trait_method->ce->name, cur_precedence->trait_method->ce->name); } - + efree(class_name); j++; } @@ -3971,7 +4160,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /* static void zend_traits_compile_exclude_table(HashTable* exclude_table, zend_trait_precedence **precedences, zend_class_entry *trait) /* {{{ */ { size_t i = 0, j; - + if (!precedences) { return; } @@ -3982,7 +4171,7 @@ static void zend_traits_compile_exclude_table(HashTable* exclude_table, zend_tra if (precedences[i]->exclude_from_classes[j] == trait) { zend_uint lcname_len = precedences[i]->trait_method->mname_len; char *lcname = zend_str_tolower_dup(precedences[i]->trait_method->method_name, lcname_len); - + if (zend_hash_add(exclude_table, lcname, lcname_len, NULL, 0, NULL) == FAILURE) { efree(lcname); zend_error(E_COMPILE_ERROR, "Failed to evaluate a trait precedence (%s). Method of trait %s was defined to be excluded multiple times", precedences[i]->trait_method->method_name, trait->name); @@ -4019,7 +4208,7 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ zend_hash_apply_with_arguments(&ce->traits[i]->function_table TSRMLS_CC, (apply_func_args_t)zend_traits_copy_functions, 3, ce, &overriden, NULL); } } - + zend_hash_apply_with_argument(&ce->function_table, (apply_func_arg_t)zend_fixup_trait_method, ce TSRMLS_CC); if (overriden) { @@ -4057,7 +4246,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* { const char* class_name_unused; zend_bool not_compatible; zval* prop_value; - char* doc_comment; + char* doc_comment; zend_uint flags; /* In the following steps the properties are inserted into the property table @@ -4079,18 +4268,17 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* { prop_name_length = property_info->name_length; } else { /* for private and protected we need to unmangle the names */ - zend_unmangle_property_name(property_info->name, property_info->name_length, - &class_name_unused, &prop_name); - prop_name_length = strlen(prop_name); + zend_unmangle_property_name_ex(property_info->name, property_info->name_length, + &class_name_unused, &prop_name, &prop_name_length); prop_hash = zend_get_hash_value(prop_name, prop_name_length + 1); } /* next: check for conflicts with current class */ if (zend_hash_quick_find(&ce->properties_info, prop_name, prop_name_length+1, prop_hash, (void **) &coliding_prop) == SUCCESS) { - if (coliding_prop->flags & ZEND_ACC_SHADOW) { + if (coliding_prop->flags & ZEND_ACC_SHADOW) { zend_hash_quick_del(&ce->properties_info, prop_name, prop_name_length+1, prop_hash); flags |= ZEND_ACC_CHANGED; - } else { + } else { if ((coliding_prop->flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC)) == (flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))) { /* flags are identical, now the value needs to be checked */ @@ -4111,14 +4299,14 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* { } if (not_compatible) { - zend_error(E_COMPILE_ERROR, + zend_error(E_COMPILE_ERROR, "%s and %s define the same property ($%s) in the composition of %s. However, the definition differs and is considered incompatible. Class was composed", find_first_definition(ce, i, prop_name, prop_name_length, prop_hash, coliding_prop->ce)->name, property_info->ce->name, prop_name, ce->name); } else { - zend_error(E_STRICT, + zend_error(E_STRICT, "%s and %s define the same property ($%s) in the composition of %s. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed", find_first_definition(ce, i, prop_name, prop_name_length, prop_hash, coliding_prop->ce)->name, property_info->ce->name, @@ -4138,8 +4326,8 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* { Z_ADDREF_P(prop_value); doc_comment = property_info->doc_comment ? estrndup(property_info->doc_comment, property_info->doc_comment_len) : NULL; - zend_declare_property_ex(ce, prop_name, prop_name_length, - prop_value, flags, + zend_declare_property_ex(ce, prop_name, prop_name_length, + prop_value, flags, doc_comment, property_info->doc_comment_len TSRMLS_CC); } } @@ -4151,7 +4339,7 @@ static void zend_do_check_for_inconsistent_traits_aliasing(zend_class_entry *ce int i = 0; zend_trait_alias* cur_alias; char* lc_method_name; - + if (ce->trait_aliases) { while (ce->trait_aliases[i]) { cur_alias = ce->trait_aliases[i]; @@ -4172,7 +4360,7 @@ static void zend_do_check_for_inconsistent_traits_aliasing(zend_class_entry *ce we check against it and abort. 2) it is just a plain old inconsitency/typo/bug as in the case where alias is set. */ - + lc_method_name = zend_str_tolower_dup(cur_alias->trait_method->method_name, cur_alias->trait_method->mname_len); if (zend_hash_exists(&ce->function_table, @@ -4209,7 +4397,7 @@ ZEND_API void zend_do_bind_traits(zend_class_entry *ce TSRMLS_DC) /* {{{ */ /* first care about all methods to be flattened into the class */ zend_do_traits_method_binding(ce TSRMLS_CC); - + /* Aliases which have not been applied indicate typos/bugs. */ zend_do_check_for_inconsistent_traits_aliasing(ce TSRMLS_CC); @@ -4218,7 +4406,7 @@ ZEND_API void zend_do_bind_traits(zend_class_entry *ce TSRMLS_DC) /* {{{ */ /* verify that all abstract methods from traits have been implemented */ zend_verify_abstract_class(ce TSRMLS_CC); - + /* now everything should be fine and an added ZEND_ACC_IMPLICIT_ABSTRACT_CLASS should be removed */ if (ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) { ce->ce_flags -= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; @@ -4268,7 +4456,7 @@ void zend_prepare_reference(znode *result, znode *class_name, znode *method_name zend_trait_method_reference *method_ref = emalloc(sizeof(zend_trait_method_reference)); method_ref->ce = NULL; - /* REM: There should not be a need for copying, + /* REM: There should not be a need for copying, zend_do_begin_class_declaration is also just using that string */ if (class_name) { zend_resolve_class_name(class_name, ZEND_FETCH_CLASS_GLOBAL, 1 TSRMLS_CC); @@ -4312,8 +4500,6 @@ void zend_add_trait_alias(znode *method_reference, znode *modifiers, znode *alia } else { trait_alias->alias = NULL; } - trait_alias->function = NULL; - zend_add_to_list(&ce->trait_aliases, trait_alias TSRMLS_CC); } /* }}} */ @@ -4326,8 +4512,6 @@ void zend_add_trait_precedence(znode *method_reference, znode *trait_list TSRMLS trait_precedence->trait_method = (zend_trait_method_reference*)method_reference->u.op.ptr; trait_precedence->exclude_from_classes = (zend_class_entry**) trait_list->u.op.ptr; - trait_precedence->function = NULL; - zend_add_to_list(&ce->trait_precedences, trait_precedence TSRMLS_CC); } /* }}} */ @@ -4846,7 +5030,7 @@ void zend_do_begin_class_declaration(const znode *class_token, znode *class_name build_runtime_defined_function_key(&key, lcname, new_class_entry->name_length TSRMLS_CC); opline->op1.constant = zend_add_literal(CG(active_op_array), &key TSRMLS_CC); Z_HASH_P(&CONSTANT(opline->op1.constant)) = zend_hash_func(Z_STRVAL(CONSTANT(opline->op1.constant)), Z_STRLEN(CONSTANT(opline->op1.constant))); - + opline->op2_type = IS_CONST; if (doing_inheritance) { @@ -4863,7 +5047,7 @@ void zend_do_begin_class_declaration(const znode *class_token, znode *class_name LITERAL_STRINGL(opline->op2, lcname, new_class_entry->name_length, 0); CALCULATE_LITERAL_HASH(opline->op2.constant); - + zend_hash_quick_update(CG(class_table), Z_STRVAL(key), Z_STRLEN(key), Z_HASH_P(&CONSTANT(opline->op1.constant)), &new_class_entry, sizeof(zend_class_entry *), NULL); CG(active_class_entry) = new_class_entry; @@ -4914,7 +5098,7 @@ void zend_do_end_class_declaration(const znode *class_token, const znode *parent } ce->info.user.line_end = zend_get_compiled_lineno(TSRMLS_C); - + /* Check for traits and proceed like with interfaces. * The only difference will be a combined handling of them in the end. * Thus, we need another opcode here. */ @@ -4939,7 +5123,7 @@ void zend_do_end_class_declaration(const znode *class_token, const znode *parent } } /* Inherit interfaces; reset number to zero, we need it for above check and - * will restore it during actual implementation. + * will restore it during actual implementation. * The ZEND_ACC_IMPLEMENT_INTERFACES flag disables double call to * zend_verify_abstract_class() */ if (ce->num_interfaces > 0) { @@ -5040,7 +5224,7 @@ static int zend_strnlen(const char* s, int maxlen) /* {{{ */ } /* }}} */ -ZEND_API int zend_unmangle_property_name(const char *mangled_property, int len, const char **class_name, const char **prop_name) /* {{{ */ +ZEND_API int zend_unmangle_property_name_ex(const char *mangled_property, int len, const char **class_name, const char **prop_name, int *prop_len) /* {{{ */ { int class_name_len; @@ -5048,22 +5232,34 @@ ZEND_API int zend_unmangle_property_name(const char *mangled_property, int len, if (mangled_property[0]!=0) { *prop_name = mangled_property; + if (prop_len) { + *prop_len = len; + } return SUCCESS; } if (len < 3 || mangled_property[1]==0) { zend_error(E_NOTICE, "Illegal member variable name"); *prop_name = mangled_property; + if (prop_len) { + *prop_len = len; + } return FAILURE; } - class_name_len = zend_strnlen(mangled_property+1, --len - 1) + 1; + class_name_len = zend_strnlen(mangled_property + 1, --len - 1) + 1; if (class_name_len >= len || mangled_property[class_name_len]!=0) { zend_error(E_NOTICE, "Corrupt member variable name"); *prop_name = mangled_property; + if (prop_len) { + *prop_len = len + 1; + } return FAILURE; } - *class_name = mangled_property+1; - *prop_name = (*class_name)+class_name_len; + *class_name = mangled_property + 1; + *prop_name = (*class_name) + class_name_len; + if (prop_len) { + *prop_len = len - class_name_len; + } return SUCCESS; } /* }}} */ @@ -5129,7 +5325,7 @@ void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_D ALLOC_ZVAL(property); *property = value->u.constant; - + cname = zend_new_interned_string(var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, 0 TSRMLS_CC); if (IS_INTERNED(cname)) { @@ -5142,7 +5338,7 @@ void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_D zend_error(E_COMPILE_ERROR, "Cannot redefine class constant %s::%s", CG(active_class_entry)->name, var_name->u.constant.value.str.val); } FREE_PNODE(var_name); - + if (CG(doc_comment)) { efree(CG(doc_comment)); CG(doc_comment) = NULL; @@ -5231,17 +5427,17 @@ void zend_do_halt_compiler_register(TSRMLS_D) /* {{{ */ char *name, *cfilename; char haltoff[] = "__COMPILER_HALT_OFFSET__"; int len, clen; - + if (CG(has_bracketed_namespaces) && CG(in_namespace)) { zend_error(E_COMPILE_ERROR, "__HALT_COMPILER() can only be used from the outermost scope"); } - + cfilename = zend_get_compiled_filename(TSRMLS_C); clen = strlen(cfilename); zend_mangle_property_name(&name, &len, haltoff, sizeof(haltoff) - 1, cfilename, clen, 0); zend_register_long_constant(name, len+1, zend_get_scanned_file_offset(TSRMLS_C), CONST_CS, 0 TSRMLS_CC); pefree(name, 0); - + if (CG(in_namespace)) { zend_do_end_namespace(TSRMLS_C); } @@ -5274,12 +5470,16 @@ void zend_do_begin_new_object(znode *new_token, znode *class_type TSRMLS_DC) /* new_token->u.op.opline_num = get_next_op_number(CG(active_op_array)); opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_NEW; + opline->extended_value = CG(context).nested_calls; opline->result_type = IS_VAR; opline->result.var = get_temporary_variable(CG(active_op_array)); SET_NODE(opline->op1, class_type); SET_UNUSED(opline->op2); zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(unsigned char *)); + if (++CG(context).nested_calls > CG(active_op_array)->nested_calls) { + CG(active_op_array)->nested_calls = CG(context).nested_calls; + } } /* }}} */ @@ -5314,7 +5514,7 @@ static zend_constant* zend_get_ct_const(const zval *const_name, int all_internal } } else if (zend_hash_find(EG(zend_constants), Z_STRVAL_P(const_name), Z_STRLEN_P(const_name)+1, (void **) &c) == FAILURE) { char *lookup_name = zend_str_tolower_dup(Z_STRVAL_P(const_name), Z_STRLEN_P(const_name)); - + if (zend_hash_find(EG(zend_constants), lookup_name, Z_STRLEN_P(const_name)+1, (void **) &c)==SUCCESS) { if ((c->flags & CONST_CT_SUBST) && !(c->flags & CONST_CS)) { efree(lookup_name); @@ -5367,7 +5567,7 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con case ZEND_CT: /* this is a class constant */ type = zend_get_class_fetch_type(Z_STRVAL(constant_container->u.constant), Z_STRLEN(constant_container->u.constant)); - + if (ZEND_FETCH_CLASS_STATIC == type) { zend_error(E_ERROR, "\"static::\" is not allowed in compile-time constants"); } else if (ZEND_FETCH_CLASS_DEFAULT == type) { @@ -5431,7 +5631,7 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con compound = memchr(Z_STRVAL(constant_name->u.constant), '\\', Z_STRLEN(constant_name->u.constant)); zend_resolve_non_class_name(constant_name, check_namespace TSRMLS_CC); - + if(zend_constant_ct_subst(result, &constant_name->u.constant, 1 TSRMLS_CC)) { break; } @@ -5447,7 +5647,7 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con /* the name is unambiguous */ opline->extended_value = 0; opline->op2.constant = zend_add_const_name_literal(CG(active_op_array), &constant_name->u.constant, 0 TSRMLS_CC); - } else { + } else { opline->extended_value = IS_CONSTANT_UNQUALIFIED; if (CG(current_namespace)) { opline->extended_value |= IS_CONSTANT_IN_NAMESPACE; @@ -5492,6 +5692,13 @@ void zend_do_shell_exec(znode *result, const znode *cmd TSRMLS_DC) /* {{{ */ opline->extended_value = 1; SET_UNUSED(opline->op2); GET_NODE(result, opline->result); + + if (CG(context).nested_calls + 1 > CG(active_op_array)->nested_calls) { + CG(active_op_array)->nested_calls = CG(context).nested_calls + 1; + } + if (CG(context).used_stack + 2 > CG(active_op_array)->used_stack) { + CG(active_op_array)->used_stack = CG(context).used_stack + 2; + } } /* }}} */ @@ -5514,7 +5721,7 @@ void zend_do_init_array(znode *result, const znode *expr, const znode *offset, z ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline->op2.constant)), Z_STRLEN(CONSTANT(opline->op2.constant))+1, index, numeric = 1); if (numeric) { zval_dtor(&CONSTANT(opline->op2.constant)); - ZVAL_LONG(&CONSTANT(opline->op2.constant), index); + ZVAL_LONG(&CONSTANT(opline->op2.constant), index); } else { CALCULATE_LITERAL_HASH(opline->op2.constant); } @@ -5546,7 +5753,7 @@ void zend_do_add_array_element(znode *result, const znode *expr, const znode *of ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline->op2.constant)), Z_STRLEN(CONSTANT(opline->op2.constant))+1, index, numeric = 1); if (numeric) { zval_dtor(&CONSTANT(opline->op2.constant)); - ZVAL_LONG(&CONSTANT(opline->op2.constant), index); + ZVAL_LONG(&CONSTANT(opline->op2.constant), index); } else { CALCULATE_LITERAL_HASH(opline->op2.constant); } @@ -5806,7 +6013,7 @@ void zend_do_fetch_lexical_variable(znode *varname, zend_bool is_ref TSRMLS_DC) Z_TYPE(value.u.constant) |= is_ref ? IS_LEXICAL_REF : IS_LEXICAL_VAR; Z_SET_REFCOUNT_P(&value.u.constant, 1); Z_UNSET_ISREF_P(&value.u.constant); - + zend_do_fetch_static_variable(varname, &value, is_ref ? ZEND_FETCH_STATIC : ZEND_FETCH_LEXICAL TSRMLS_CC); } /* }}} */ @@ -5936,7 +6143,16 @@ void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC zend_do_end_variable_parse(variable, BP_VAR_IS, 0 TSRMLS_CC); - zend_check_writable_variable(variable); + if (zend_is_function_or_method_call(variable)) { + if (type == ZEND_ISEMPTY) { + /* empty(func()) can be transformed to !func() */ + zend_do_unary_op(ZEND_BOOL_NOT, result, variable TSRMLS_CC); + } else { + zend_error(E_COMPILE_ERROR, "Cannot use isset() on the result of a function call (you can use \"null !== func()\" instead)"); + } + + return; + } if (variable->op_type == IS_CV) { last_op = get_next_op(CG(active_op_array) TSRMLS_CC); @@ -6083,15 +6299,18 @@ void zend_do_foreach_cont(znode *foreach_token, const znode *open_brackets_token opline->extended_value |= ZEND_FE_FETCH_WITH_KEY; } - if ((key->op_type != IS_UNUSED) && (key->EA & ZEND_PARSED_REFERENCE_VARIABLE)) { - zend_error(E_COMPILE_ERROR, "Key element cannot be a reference"); + if ((key->op_type != IS_UNUSED)) { + if (key->EA & ZEND_PARSED_REFERENCE_VARIABLE) { + zend_error(E_COMPILE_ERROR, "Key element cannot be a reference"); + } + if (key->EA & ZEND_PARSED_LIST_EXPR) { + zend_error(E_COMPILE_ERROR, "Cannot use list as key element"); + } } if (value->EA & ZEND_PARSED_REFERENCE_VARIABLE) { assign_by_ref = 1; - if (!(opline-1)->extended_value) { - zend_error(E_COMPILE_ERROR, "Cannot create references to elements of a temporary array expression"); - } + /* Mark extended_value for assign-by-reference */ opline->extended_value |= ZEND_FE_FETCH_BYREF; CG(active_op_array)->opcodes[foreach_token->u.op.opline_num].extended_value |= ZEND_FE_RESET_REFERENCE; @@ -6120,13 +6339,21 @@ void zend_do_foreach_cont(znode *foreach_token, const znode *open_brackets_token GET_NODE(&value_node, opline->result); - if (assign_by_ref) { - zend_do_end_variable_parse(value, BP_VAR_W, 0 TSRMLS_CC); - /* Mark FE_FETCH as IS_VAR as it holds the data directly as a value */ - zend_do_assign_ref(NULL, value, &value_node TSRMLS_CC); - } else { - zend_do_assign(&dummy, value, &value_node TSRMLS_CC); + if (value->EA & ZEND_PARSED_LIST_EXPR) { + if (!CG(list_llist).head) { + zend_error(E_COMPILE_ERROR, "Cannot use empty list"); + } + zend_do_list_end(&dummy, &value_node TSRMLS_CC); zend_do_free(&dummy TSRMLS_CC); + } else { + if (assign_by_ref) { + zend_do_end_variable_parse(value, BP_VAR_W, 0 TSRMLS_CC); + /* Mark FE_FETCH as IS_VAR as it holds the data directly as a value */ + zend_do_assign_ref(NULL, value, &value_node TSRMLS_CC); + } else { + zend_do_assign(&dummy, value, &value_node TSRMLS_CC); + zend_do_free(&dummy TSRMLS_CC); + } } if (key->op_type != IS_UNUSED) { @@ -6302,7 +6529,7 @@ void zend_do_jmp_set(const znode *value, znode *jmp_token, znode *colon_token TS opline->result.var = get_temporary_variable(CG(active_op_array)); SET_NODE(opline->op1, value); SET_UNUSED(opline->op2); - + GET_NODE(colon_token, opline->result); jmp_token->u.op.opline_num = op_number; @@ -6331,11 +6558,11 @@ void zend_do_jmp_set_else(znode *result, const znode *false_value, const znode * opline->extended_value = 0; SET_NODE(opline->op1, false_value); SET_UNUSED(opline->op2); - + GET_NODE(result, opline->result); CG(active_op_array)->opcodes[jmp_token->u.op.opline_num].op2.opline_num = get_next_op_number(CG(active_op_array)); - + DEC_BPC(CG(active_op_array)); } /* }}} */ @@ -6548,16 +6775,13 @@ int zendlex(znode *zendlval TSRMLS_DC) /* {{{ */ CG(increment_lineno) = 1; } if (CG(has_bracketed_namespaces) && !CG(in_namespace)) { - goto again; + goto again; } retval = ';'; /* implicit ; */ break; case T_OPEN_TAG_WITH_ECHO: retval = T_ECHO; break; - case T_END_HEREDOC: - efree(Z_STRVAL(zendlval->u.constant)); - break; } INIT_PZVAL(&zendlval->u.constant); @@ -6641,13 +6865,13 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify int zend_get_class_fetch_type(const char *class_name, uint class_name_len) /* {{{ */ { if ((class_name_len == sizeof("self")-1) && - !memcmp(class_name, "self", sizeof("self")-1)) { - return ZEND_FETCH_CLASS_SELF; + !strncasecmp(class_name, "self", sizeof("self")-1)) { + return ZEND_FETCH_CLASS_SELF; } else if ((class_name_len == sizeof("parent")-1) && - !memcmp(class_name, "parent", sizeof("parent")-1)) { + !strncasecmp(class_name, "parent", sizeof("parent")-1)) { return ZEND_FETCH_CLASS_PARENT; } else if ((class_name_len == sizeof("static")-1) && - !memcmp(class_name, "static", sizeof("static")-1)) { + !strncasecmp(class_name, "static", sizeof("static")-1)) { return ZEND_FETCH_CLASS_STATIC; } else { return ZEND_FETCH_CLASS_DEFAULT; @@ -6760,7 +6984,7 @@ void zend_do_begin_namespace(const znode *name, zend_bool with_bracket TSRMLS_DC efree(CG(current_import)); CG(current_import) = NULL; } - + if (CG(doc_comment)) { efree(CG(doc_comment)); CG(doc_comment) = NULL; @@ -6932,7 +7156,7 @@ ZEND_API size_t zend_dirname(char *path, size_t len) len_adjust += 2; if (2 == len) { /* Return "c:" on Win32 for dirname("c:"). - * It would be more consistent to return "c:." + * It would be more consistent to return "c:." * but that would require making the string *longer*. */ return len; @@ -6940,7 +7164,7 @@ ZEND_API size_t zend_dirname(char *path, size_t len) } #elif defined(NETWARE) /* - * Find the first occurence of : from the left + * Find the first occurence of : from the left * move the path pointer to the position just after : * increment the len_adjust to the length of path till colon character(inclusive) * If there is no character beyond : simple return len diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 50ee3a4d7fd33..8042dd54eee81 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -59,6 +59,9 @@ typedef struct _zend_compiler_context { int literals_size; int current_brk_cont; int backpatch_count; + int nested_calls; + int used_stack; + int in_finally; HashTable *labels; } zend_compiler_context; @@ -80,7 +83,7 @@ typedef union _znode_op { zend_op *jmp_addr; zval *zv; zend_literal *literal; - void *ptr; /* Used for passing pointers from the compile to execution phase, currently used for traits */ + void *ptr; /* Used for passing pointers from the compile to execution phase, currently used for traits */ } znode_op; typedef struct _znode { /* used only during compilation */ @@ -132,6 +135,8 @@ typedef struct _zend_label { typedef struct _zend_try_catch_element { zend_uint try_op; zend_uint catch_op; /* ketchup! */ + zend_uint finally_op; + zend_uint finally_end; } zend_try_catch_element; #if SIZEOF_LONG == 8 @@ -194,6 +199,7 @@ typedef struct _zend_try_catch_element { #define ZEND_ACC_CLOSURE 0x100000 +#define ZEND_ACC_GENERATOR 0x800000 /* function flag for internal user call handlers __call, __callstatic */ #define ZEND_ACC_CALL_VIA_HANDLER 0x200000 @@ -274,11 +280,15 @@ struct _zend_op_array { zend_uint T; + zend_uint nested_calls; + zend_uint used_stack; + zend_brk_cont_element *brk_cont_array; int last_brk_cont; zend_try_catch_element *try_catch_array; int last_try_catch; + zend_bool has_finally_block; /* static variables support */ HashTable *static_variables; @@ -363,15 +373,19 @@ typedef struct _list_llist_element { union _temp_variable; +typedef struct _call_slot { + zend_function *fbc; + zval *object; + zend_class_entry *called_scope; + zend_bool is_ctor_call; + zend_bool is_ctor_result_used; +} call_slot; + struct _zend_execute_data { struct _zend_op *opline; zend_function_state function_state; - zend_function *fbc; /* Function Being Called */ - zend_class_entry *called_scope; zend_op_array *op_array; zval *object; - union _temp_variable *Ts; - zval ***CVs; HashTable *symbol_table; struct _zend_execute_data *prev_execute_data; zval *old_error_reporting; @@ -380,11 +394,18 @@ struct _zend_execute_data { zend_class_entry *current_scope; zend_class_entry *current_called_scope; zval *current_this; - zval *current_object; + struct _zend_op *fast_ret; /* used by FAST_CALL/FAST_RET (finally keyword) */ + call_slot *call_slots; + call_slot *call; }; #define EX(element) execute_data.element +#define EX_TMP_VAR(ex, n) ((temp_variable*)(((char*)(ex)) + ((int)(n)))) +#define EX_TMP_VAR_NUM(ex, n) (EX_TMP_VAR(ex, 0) - (1 + (n))) + +#define EX_CV_NUM(ex, n) (((zval***)(((char*)(ex))+ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data))))+(n)) + #define IS_CONST (1<<0) #define IS_TMP_VAR (1<<1) @@ -489,6 +510,7 @@ void zend_do_build_full_name(znode *result, znode *prefix, znode *name, int is_c int zend_do_begin_class_member_function_call(znode *class_name, znode *method_name TSRMLS_DC); void zend_do_end_function_call(znode *function_name, znode *result, const 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_yield(znode *result, znode *value, const znode *key, zend_bool is_variable TSRMLS_DC); void zend_do_handle_exception(TSRMLS_D); void zend_do_begin_lambda_function_declaration(znode *result, znode *function_token, int return_reference, int is_static TSRMLS_DC); @@ -496,7 +518,10 @@ void zend_do_fetch_lexical_variable(znode *varname, zend_bool is_ref TSRMLS_DC); void zend_do_try(znode *try_token TSRMLS_DC); void zend_do_begin_catch(znode *try_token, znode *catch_class, znode *catch_var, znode *first_catch TSRMLS_DC); -void zend_do_end_catch(const znode *try_token TSRMLS_DC); +void zend_do_bind_catch(znode *try_token, znode *catch_token TSRMLS_DC); +void zend_do_end_catch(znode *catch_token TSRMLS_DC); +void zend_do_finally(znode *finally_token TSRMLS_DC); +void zend_do_end_finally(znode *try_token, znode* catch_token, znode *finally_token TSRMLS_DC); void zend_do_throw(const znode *expr TSRMLS_DC); ZEND_API int do_bind_function(const zend_op_array *op_array, zend_op *opline, HashTable *function_table, zend_bool compile_time); @@ -613,6 +638,8 @@ void zend_verify_namespace(TSRMLS_D); void zend_do_use(znode *name, znode *new_name, int is_global TSRMLS_DC); void zend_do_end_compilation(TSRMLS_D); +void zend_do_resolve_class_name(znode *result, znode *class_name, int is_static TSRMLS_DC); + void zend_do_label(znode *label TSRMLS_DC); void zend_do_goto(const znode *label TSRMLS_DC); void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2 TSRMLS_DC); @@ -646,7 +673,9 @@ 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, const char *src1, int src1_length, const char *src2, int src2_length, int internal); -ZEND_API int zend_unmangle_property_name(const char *mangled_property, int mangled_property_len, const char **class_name, const char **prop_name); +#define zend_unmangle_property_name(mangled_property, mangled_property_len, class_name, prop_name) \ + zend_unmangle_property_name_ex(mangled_property, mangled_property_len, class_name, prop_name, NULL) +ZEND_API int zend_unmangle_property_name_ex(const char *mangled_property, int mangled_property_len, const char **class_name, const char **prop_name, int *prop_len); #define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor #define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class @@ -659,7 +688,7 @@ void print_op_array(zend_op_array *op_array, int optimizations); ZEND_API 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(const znode *try_token TSRMLS_DC); +void zend_initialize_try_catch_element(znode *catch_token TSRMLS_DC); void zend_do_mark_last_catch(const znode *first_catch, const znode *last_additional_catch TSRMLS_DC); ZEND_API zend_bool zend_is_compiling(TSRMLS_D); ZEND_API char *zend_make_compiled_string_description(const char *name TSRMLS_DC); @@ -715,6 +744,7 @@ int zend_add_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC); #define ZEND_PARSED_VARIABLE (1<<4) #define ZEND_PARSED_REFERENCE_VARIABLE (1<<5) #define ZEND_PARSED_NEW (1<<6) +#define ZEND_PARSED_LIST_EXPR (1<<7) /* unset types */ @@ -810,6 +840,9 @@ int zend_add_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC); #define ZEND_RETURNS_FUNCTION 1<<0 #define ZEND_RETURNS_NEW 1<<1 +#define ZEND_FAST_RET_TO_CATCH 1 +#define ZEND_FAST_RET_TO_FINALLY 2 + END_EXTERN_C() #define ZEND_CLONE_FUNC_NAME "__clone" diff --git a/Zend/zend_default_classes.c b/Zend/zend_default_classes.c index 43d8e631dbc06..46b00eac4e43a 100644 --- a/Zend/zend_default_classes.c +++ b/Zend/zend_default_classes.c @@ -25,6 +25,7 @@ #include "zend_interfaces.h" #include "zend_exceptions.h" #include "zend_closures.h" +#include "zend_generators.h" ZEND_API void zend_register_default_classes(TSRMLS_D) @@ -33,6 +34,7 @@ ZEND_API void zend_register_default_classes(TSRMLS_D) zend_register_default_exception(TSRMLS_C); zend_register_iterator_wrapper(TSRMLS_C); zend_register_closure_ce(TSRMLS_C); + zend_register_generator_ce(TSRMLS_C); } /* diff --git a/Zend/zend_dtrace.c b/Zend/zend_dtrace.c index 5b2d0d2dfed21..165172ad1eb4f 100644 --- a/Zend/zend_dtrace.c +++ b/Zend/zend_dtrace.c @@ -44,7 +44,7 @@ ZEND_API zend_op_array *dtrace_compile_file(zend_file_handle *file_handle, int t } /* We wrap the execute function to have fire the execute-entry/return and function-entry/return probes */ -ZEND_API void dtrace_execute(zend_op_array *op_array TSRMLS_DC) +ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data TSRMLS_DC) { int lineno; char *scope, *filename, *funcname, *classname; @@ -72,7 +72,7 @@ ZEND_API void dtrace_execute(zend_op_array *op_array TSRMLS_DC) DTRACE_FUNCTION_ENTRY(funcname, filename, lineno, classname, scope); } - execute(op_array TSRMLS_CC); + execute_ex(execute_data TSRMLS_CC); if (DTRACE_FUNCTION_RETURN_ENABLED() && funcname != NULL) { DTRACE_FUNCTION_RETURN(funcname, filename, lineno, classname, scope); @@ -83,7 +83,7 @@ ZEND_API void dtrace_execute(zend_op_array *op_array TSRMLS_DC) } } -ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC) +ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC) { int lineno; char *filename; @@ -96,7 +96,7 @@ ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data_ptr, int r DTRACE_EXECUTE_ENTRY(filename, lineno); } - execute_internal(execute_data_ptr, return_value_used TSRMLS_CC); + execute_internal(execute_data_ptr, fci, return_value_used TSRMLS_CC); if (DTRACE_EXECUTE_RETURN_ENABLED()) { DTRACE_EXECUTE_RETURN(filename, lineno); diff --git a/Zend/zend_dtrace.h b/Zend/zend_dtrace.h index 65d19ef346a85..26008afb6b36a 100644 --- a/Zend/zend_dtrace.h +++ b/Zend/zend_dtrace.h @@ -32,11 +32,11 @@ extern "C" { #ifdef HAVE_DTRACE ZEND_API zend_op_array *(*zend_dtrace_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); ZEND_API void (*zend_dtrace_execute)(zend_op_array *op_array TSRMLS_DC); -ZEND_API void (*zend_dtrace_execute_internal)(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC); +ZEND_API void (*zend_dtrace_execute_internal)(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC); ZEND_API zend_op_array *dtrace_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC); -ZEND_API void dtrace_execute(zend_op_array *op_array TSRMLS_DC); -ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC); +ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data TSRMLS_DC); +ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC); #include #endif /* HAVE_DTRACE */ diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 276ad382fb192..49a241d9a14e2 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -35,6 +35,7 @@ #include "zend_exceptions.h" #include "zend_interfaces.h" #include "zend_closures.h" +#include "zend_generators.h" #include "zend_vm.h" #include "zend_dtrace.h" @@ -49,10 +50,10 @@ typedef int (*incdec_t)(zval *); -#define get_zval_ptr(op_type, node, Ts, should_free, type) _get_zval_ptr(op_type, node, Ts, should_free, type TSRMLS_CC) -#define get_zval_ptr_ptr(op_type, node, Ts, should_free, type) _get_zval_ptr_ptr(op_type, node, Ts, should_free, type TSRMLS_CC) -#define get_obj_zval_ptr(op_type, node, Ts, should_free, type) _get_obj_zval_ptr(op_type, node, Ts, should_free, type TSRMLS_CC) -#define get_obj_zval_ptr_ptr(op_type, node, Ts, should_free, type) _get_obj_zval_ptr_ptr(op_type, node, Ts, should_free, type TSRMLS_CC) +#define get_zval_ptr(op_type, node, ex, should_free, type) _get_zval_ptr(op_type, node, ex, should_free, type TSRMLS_CC) +#define get_zval_ptr_ptr(op_type, node, ex, should_free, type) _get_zval_ptr_ptr(op_type, node, ex, should_free, type TSRMLS_CC) +#define get_obj_zval_ptr(op_type, node, ex, should_free, type) _get_obj_zval_ptr(op_type, node, ex, should_free, type TSRMLS_CC) +#define get_obj_zval_ptr_ptr(op_type, node, ex, should_free, type) _get_obj_zval_ptr_ptr(op_type, node, ex, should_free, type TSRMLS_CC) /* Prototypes */ static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array TSRMLS_DC); @@ -61,8 +62,8 @@ static void zend_extension_fcall_end_handler(const zend_extension *extension, ze #define RETURN_VALUE_USED(opline) (!((opline)->result_type & EXT_TYPE_UNUSED)) -#define T(offset) (*(temp_variable *)((char *) Ts + offset)) -#define CV(var) CVs[var] +#define EX_T(offset) (*EX_TMP_VAR(execute_data, offset)) +#define EX_CV(var) (*EX_CV_NUM(execute_data, var)) #define TEMP_VAR_STACK_LIMIT 2000 @@ -85,11 +86,10 @@ static zend_always_inline void zend_pzval_unlock_func(zval *z, zend_free_op *sho static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC) { if (!Z_DELREF_P(z)) { - if (z != &EG(uninitialized_zval)) { - GC_REMOVE_ZVAL_FROM_BUFFER(z); - zval_dtor(z); - efree(z); - } + ZEND_ASSERT(z != &EG(uninitialized_zval)); + GC_REMOVE_ZVAL_FROM_BUFFER(z); + zval_dtor(z); + efree(z); } } @@ -153,7 +153,6 @@ static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC) /* End of zend_execute_locks.h */ -#define CV_OF(i) (EG(current_execute_data)->CVs[i]) #define CV_DEF_OF(i) (EG(active_op_array)->vars[i]) #define CTOR_CALL_BIT 0x1 @@ -167,19 +166,22 @@ static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC) #define DECODE_CTOR(ce) \ ((zend_class_entry*)(((zend_uintptr_t)(ce)) & ~(CTOR_CALL_BIT|CTOR_USED_BIT))) -ZEND_API zval** zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, zend_uint var) +#undef EX +#define EX(element) execute_data->element + +ZEND_API zval** zend_get_compiled_variable_value(const zend_execute_data *execute_data, zend_uint var) { - return execute_data_ptr->CVs[var]; + return EX_CV(var); } -static zend_always_inline zval *_get_zval_ptr_tmp(zend_uint var, const temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +static zend_always_inline zval *_get_zval_ptr_tmp(zend_uint var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC) { - return should_free->var = &T(var).tmp_var; + return should_free->var = &EX_T(var).tmp_var; } -static zend_always_inline zval *_get_zval_ptr_var(zend_uint var, const temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +static zend_always_inline zval *_get_zval_ptr_var(zend_uint var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC) { - zval *ptr = T(var).var.ptr; + zval *ptr = EX_T(var).var.ptr; PZVAL_UNLOCK(ptr, should_free); return ptr; @@ -205,7 +207,7 @@ static zend_never_inline zval **_get_zval_cv_lookup(zval ***ptr, zend_uint var, case BP_VAR_W: Z_ADDREF(EG(uninitialized_zval)); if (!EG(active_symbol_table)) { - *ptr = (zval**)EG(current_execute_data)->CVs + (EG(active_op_array)->last_var + var); + *ptr = (zval**)EX_CV_NUM(EG(current_execute_data), EG(active_op_array)->last_var + var); **ptr = &EG(uninitialized_zval); } else { zend_hash_quick_update(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, &EG(uninitialized_zval_ptr), sizeof(zval *), (void **)ptr); @@ -257,7 +259,7 @@ static zend_never_inline zval **_get_zval_cv_lookup_BP_VAR_RW(zval ***ptr, zend_ if (!EG(active_symbol_table)) { Z_ADDREF(EG(uninitialized_zval)); - *ptr = (zval**)EG(current_execute_data)->CVs + (EG(active_op_array)->last_var + var); + *ptr = (zval**)EX_CV_NUM(EG(current_execute_data), EG(active_op_array)->last_var + var); **ptr = &EG(uninitialized_zval); zend_error(E_NOTICE, "Undefined variable: %s", cv->name); } else if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) { @@ -274,7 +276,7 @@ static zend_never_inline zval **_get_zval_cv_lookup_BP_VAR_W(zval ***ptr, zend_u if (!EG(active_symbol_table)) { Z_ADDREF(EG(uninitialized_zval)); - *ptr = (zval**)EG(current_execute_data)->CVs + (EG(active_op_array)->last_var + var); + *ptr = (zval**)EX_CV_NUM(EG(current_execute_data), EG(active_op_array)->last_var + var); **ptr = &EG(uninitialized_zval); } else if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) { Z_ADDREF(EG(uninitialized_zval)); @@ -285,7 +287,7 @@ static zend_never_inline zval **_get_zval_cv_lookup_BP_VAR_W(zval ***ptr, zend_u static zend_always_inline zval *_get_zval_ptr_cv(zend_uint var, int type TSRMLS_DC) { - zval ***ptr = &CV_OF(var); + zval ***ptr = EX_CV_NUM(EG(current_execute_data), var); if (UNEXPECTED(*ptr == NULL)) { return *_get_zval_cv_lookup(ptr, var, type TSRMLS_CC); @@ -293,9 +295,9 @@ static zend_always_inline zval *_get_zval_ptr_cv(zend_uint var, int type TSRMLS_ return **ptr; } -static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(zval ***CVs, zend_uint var TSRMLS_DC) +static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC) { - zval ***ptr = &CV(var); + zval ***ptr = EX_CV_NUM(execute_data, var); if (UNEXPECTED(*ptr == NULL)) { return *_get_zval_cv_lookup_BP_VAR_R(ptr, var TSRMLS_CC); @@ -303,9 +305,9 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(zval ***CVs, zend_uint return **ptr; } -static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(zval ***CVs, zend_uint var TSRMLS_DC) +static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC) { - zval ***ptr = &CV(var); + zval ***ptr = EX_CV_NUM(execute_data, var); if (UNEXPECTED(*ptr == NULL)) { return *_get_zval_cv_lookup_BP_VAR_UNSET(ptr, var TSRMLS_CC); @@ -313,9 +315,9 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(zval ***CVs, zend_ return **ptr; } -static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(zval ***CVs, zend_uint var TSRMLS_DC) +static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC) { - zval ***ptr = &CV(var); + zval ***ptr = EX_CV_NUM(execute_data, var); if (UNEXPECTED(*ptr == NULL)) { return *_get_zval_cv_lookup_BP_VAR_IS(ptr, var TSRMLS_CC); @@ -323,9 +325,9 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(zval ***CVs, zend_uin return **ptr; } -static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(zval ***CVs, zend_uint var TSRMLS_DC) +static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC) { - zval ***ptr = &CV(var); + zval ***ptr = EX_CV_NUM(execute_data, var); if (UNEXPECTED(*ptr == NULL)) { return *_get_zval_cv_lookup_BP_VAR_RW(ptr, var TSRMLS_CC); @@ -333,9 +335,9 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(zval ***CVs, zend_uin return **ptr; } -static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(zval ***CVs, zend_uint var TSRMLS_DC) +static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC) { - zval ***ptr = &CV(var); + zval ***ptr = EX_CV_NUM(execute_data, var); if (UNEXPECTED(*ptr == NULL)) { return *_get_zval_cv_lookup_BP_VAR_W(ptr, var TSRMLS_CC); @@ -343,7 +345,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(zval ***CVs, zend_uint return **ptr; } -static inline zval *_get_zval_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC) +static inline zval *_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) { /* should_free->is_var = 0; */ switch (op_type) { @@ -352,11 +354,11 @@ static inline zval *_get_zval_ptr(int op_type, const znode_op *node, const temp_ return node->zv; break; case IS_TMP_VAR: - should_free->var = TMP_FREE(&T(node->var).tmp_var); - return &T(node->var).tmp_var; + should_free->var = TMP_FREE(&EX_T(node->var).tmp_var); + return &EX_T(node->var).tmp_var; break; case IS_VAR: - return _get_zval_ptr_var(node->var, Ts, should_free TSRMLS_CC); + return _get_zval_ptr_var(node->var, execute_data, should_free TSRMLS_CC); break; case IS_UNUSED: should_free->var = 0; @@ -371,22 +373,22 @@ static inline zval *_get_zval_ptr(int op_type, const znode_op *node, const temp_ return NULL; } -static zend_always_inline zval **_get_zval_ptr_ptr_var(zend_uint var, const temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +static zend_always_inline zval **_get_zval_ptr_ptr_var(zend_uint var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC) { - zval** ptr_ptr = T(var).var.ptr_ptr; + zval** ptr_ptr = EX_T(var).var.ptr_ptr; if (EXPECTED(ptr_ptr != NULL)) { PZVAL_UNLOCK(*ptr_ptr, should_free); } else { /* string offset */ - PZVAL_UNLOCK(T(var).str_offset.str, should_free); + PZVAL_UNLOCK(EX_T(var).str_offset.str, should_free); } return ptr_ptr; } static zend_always_inline zval **_get_zval_ptr_ptr_cv(zend_uint var, int type TSRMLS_DC) { - zval ***ptr = &CV_OF(var); + zval ***ptr = EX_CV_NUM(EG(current_execute_data), var); if (UNEXPECTED(*ptr == NULL)) { return _get_zval_cv_lookup(ptr, var, type TSRMLS_CC); @@ -394,9 +396,9 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv(zend_uint var, int type TS return *ptr; } -static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_R(zval ***CVs, zend_uint var TSRMLS_DC) +static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_R(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC) { - zval ***ptr = &CV(var); + zval ***ptr = EX_CV_NUM(execute_data, var); if (UNEXPECTED(*ptr == NULL)) { return _get_zval_cv_lookup_BP_VAR_R(ptr, var TSRMLS_CC); @@ -404,9 +406,9 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_R(zval ***CVs, zend return *ptr; } -static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_UNSET(zval ***CVs, zend_uint var TSRMLS_DC) +static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_UNSET(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC) { - zval ***ptr = &CV(var); + zval ***ptr = EX_CV_NUM(execute_data, var); if (UNEXPECTED(*ptr == NULL)) { return _get_zval_cv_lookup_BP_VAR_UNSET(ptr, var TSRMLS_CC); @@ -414,9 +416,9 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_UNSET(zval ***CVs, return *ptr; } -static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_IS(zval ***CVs, zend_uint var TSRMLS_DC) +static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_IS(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC) { - zval ***ptr = &CV(var); + zval ***ptr = EX_CV_NUM(execute_data, var); if (UNEXPECTED(*ptr == NULL)) { return _get_zval_cv_lookup_BP_VAR_IS(ptr, var TSRMLS_CC); @@ -424,9 +426,9 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_IS(zval ***CVs, zen return *ptr; } -static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_RW(zval ***CVs, zend_uint var TSRMLS_DC) +static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_RW(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC) { - zval ***ptr = &CV(var); + zval ***ptr = EX_CV_NUM(execute_data, var); if (UNEXPECTED(*ptr == NULL)) { return _get_zval_cv_lookup_BP_VAR_RW(ptr, var TSRMLS_CC); @@ -434,9 +436,9 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_RW(zval ***CVs, zen return *ptr; } -static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_W(zval ***CVs, zend_uint var TSRMLS_DC) +static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_W(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC) { - zval ***ptr = &CV(var); + zval ***ptr = EX_CV_NUM(execute_data, var); if (UNEXPECTED(*ptr == NULL)) { return _get_zval_cv_lookup_BP_VAR_W(ptr, var TSRMLS_CC); @@ -444,13 +446,13 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_W(zval ***CVs, zend return *ptr; } -static inline zval **_get_zval_ptr_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC) +static inline zval **_get_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) { if (op_type == IS_CV) { should_free->var = 0; return _get_zval_ptr_ptr_cv(node->var, type TSRMLS_CC); } else if (op_type == IS_VAR) { - return _get_zval_ptr_ptr_var(node->var, Ts, should_free TSRMLS_CC); + return _get_zval_ptr_ptr_var(node->var, execute_data, should_free TSRMLS_CC); } else { should_free->var = 0; return NULL; @@ -467,7 +469,7 @@ static zend_always_inline zval *_get_obj_zval_ptr_unused(TSRMLS_D) } } -static inline zval **_get_obj_zval_ptr_ptr(int op_type, const znode_op *op, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC) +static inline zval **_get_obj_zval_ptr_ptr(int op_type, const znode_op *op, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) { if (op_type == IS_UNUSED) { if (EXPECTED(EG(This) != NULL)) { @@ -479,7 +481,7 @@ static inline zval **_get_obj_zval_ptr_ptr(int op_type, const znode_op *op, cons zend_error_noreturn(E_ERROR, "Using $this when not in object context"); } } - return get_zval_ptr_ptr(op_type, op, Ts, should_free, type); + return get_zval_ptr_ptr(op_type, op, execute_data, should_free, type); } static zend_always_inline zval **_get_obj_zval_ptr_ptr_unused(TSRMLS_D) @@ -492,7 +494,7 @@ static zend_always_inline zval **_get_obj_zval_ptr_ptr_unused(TSRMLS_D) } } -static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC) +static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) { if (op_type == IS_UNUSED) { if (EXPECTED(EG(This) != NULL)) { @@ -502,7 +504,7 @@ static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, const temp_vari zend_error_noreturn(E_ERROR, "Using $this when not in object context"); } } - return get_zval_ptr(op_type, op, Ts, should_free, type); + return get_zval_ptr(op_type, op, execute_data, should_free, type); } static void zend_assign_to_variable_reference(zval **variable_ptr_ptr, zval **value_ptr_ptr TSRMLS_DC) @@ -653,11 +655,11 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva return 1; } -static inline void zend_assign_to_object(zval **retval, zval **object_ptr, zval *property_name, int value_type, znode_op *value_op, const temp_variable *Ts, int opcode, const zend_literal *key TSRMLS_DC) +static inline void zend_assign_to_object(zval **retval, zval **object_ptr, zval *property_name, int value_type, znode_op *value_op, const zend_execute_data *execute_data, int opcode, const zend_literal *key TSRMLS_DC) { zval *object = *object_ptr; zend_free_op free_value; - zval *value = get_zval_ptr(value_type, value_op, Ts, &free_value, BP_VAR_R); + zval *value = get_zval_ptr(value_type, value_op, execute_data, &free_value, BP_VAR_R); if (Z_TYPE_P(object) != IS_OBJECT) { if (object == &EG(error_zval)) { @@ -1409,7 +1411,7 @@ static void zend_fetch_property_address(temp_variable *result, zval **container_ } } -static inline zend_brk_cont_element* zend_brk_cont(int nest_levels, int array_offset, const zend_op_array *op_array, const temp_variable *Ts TSRMLS_DC) +static inline zend_brk_cont_element* zend_brk_cont(int nest_levels, int array_offset, const zend_op_array *op_array, const zend_execute_data *execute_data TSRMLS_DC) { int original_nest_levels = nest_levels; zend_brk_cont_element *jmp_to; @@ -1425,12 +1427,12 @@ static inline zend_brk_cont_element* zend_brk_cont(int nest_levels, int array_of switch (brk_opline->opcode) { case ZEND_SWITCH_FREE: if (!(brk_opline->extended_value & EXT_TYPE_FREE_ON_RETURN)) { - zval_ptr_dtor(&T(brk_opline->op1.var).var.ptr); + zval_ptr_dtor(&EX_T(brk_opline->op1.var).var.ptr); } break; case ZEND_FREE: if (!(brk_opline->extended_value & EXT_TYPE_FREE_ON_RETURN)) { - zendi_zval_dtor(T(brk_opline->op1.var).tmp_var); + zendi_zval_dtor(EX_T(brk_opline->op1.var).tmp_var); } break; } @@ -1474,11 +1476,212 @@ static int zend_check_symbol(zval **pz TSRMLS_DC) ZEND_API opcode_handler_t *zend_opcode_handlers; -ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC) +ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC) +{ + if(fci != NULL) { + ((zend_internal_function *) execute_data_ptr->function_state.function)->handler(fci->param_count, + *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC); + + } else { + zval **return_value_ptr = &EX_TMP_VAR(execute_data_ptr, execute_data_ptr->opline->result.var)->var.ptr; + ((zend_internal_function *) execute_data_ptr->function_state.function)->handler(execute_data_ptr->opline->extended_value, *return_value_ptr, + (execute_data_ptr->function_state.function->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)?return_value_ptr:NULL, + execute_data_ptr->object, return_value_used TSRMLS_CC); + } +} + +void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC) /* {{{ */ +{ + if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) { + zend_hash_destroy(symbol_table); + FREE_HASHTABLE(symbol_table); + } else { + /* clean before putting into the cache, since clean + could call dtors, which could use cached hash */ + zend_hash_clean(symbol_table); + *(++EG(symtable_cache_ptr)) = symbol_table; + } +} +/* }}} */ + +static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */ +{ + zval ***cv = EX_CV_NUM(execute_data, 0); + zval ***end = cv + EX(op_array)->last_var; + while (cv != end) { + if (*cv) { + zval_ptr_dtor(*cv); + } + cv++; + } +} +/* }}} */ + +void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */ +{ + i_free_compiled_variables(execute_data); +} +/* }}} */ + +/* + * Stack Frame Layout (the whole stack frame is allocated at once) + * ================== + * + * +========================================+ + * | zend_execute_data |<---+ + * | EX(function_state).arguments |--+ | + * | ... | | | + * | ARGUMENT [1] | | | + * | ... | | | + * | ARGUMENT [ARGS_NUMBER] | | | + * | ARGS_NUMBER |<-+ | + * +========================================+ | + * | + * +========================================+ | + * | TMP_VAR[op_arrat->T-1] | | + * | ... | | + * EX_TMP_VAR_NUM(0) ----> | TMP_VAR[0] | | + * +----------------------------------------+ | + * EG(current_execute_data) -> | zend_execute_data | | + * | EX(prev_execute_data) |----+ + * +----------------------------------------+ + * EX_CV_NUM(0) ---------> | CV[0] |--+ + * | ... | | + * | CV[op_array->last_var-1] | | + * +----------------------------------------+ | + * | Optional slot for CV[0] zval* |<-+ + * | ... | + * | ...for CV [op_array->last_var-1] zval* | + * +----------------------------------------+ + * EX(call_slots) -> | CALL_SLOT[0] | + * | ... | + * | CALL_SLOT[op_array->nested_calls-1] | + * +----------------------------------------+ + * zend_vm_stack_frame_base -> | ARGUMENTS STACK [0] | + * | ... | + * zend_vm_stack_top --------> | ... | + * | ... | + * | ARGUMENTS STACK [op_array->used_stack] | + * +----------------------------------------+ + */ + +static zend_always_inline zend_execute_data *i_create_execute_data_from_op_array(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */ +{ + zend_execute_data *execute_data; + + /* + * When allocating the execute_data, memory for compiled variables and + * temporary variables is also allocated before and after the actual + * zend_execute_data struct. In addition we also allocate space to store + * information about syntactically nested called functions and actual + * parameters. op_array->last_var specifies the number of compiled + * variables and op_array->T is the number of temporary variables. If there + * is no symbol table, then twice as much memory is allocated for compiled + * variables. In that case the first half contains zval**s and the second + * half the actual zval*s (which would otherwise be in the symbol table). + */ + size_t execute_data_size = ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)); + size_t CVs_size = ZEND_MM_ALIGNED_SIZE(sizeof(zval **) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2)); + size_t Ts_size = ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T; + size_t call_slots_size = ZEND_MM_ALIGNED_SIZE(sizeof(call_slot)) * op_array->nested_calls; + size_t stack_size = ZEND_MM_ALIGNED_SIZE(sizeof(zval*)) * op_array->used_stack; + size_t total_size = execute_data_size + Ts_size + CVs_size + call_slots_size + stack_size; + + /* + * Normally the execute_data is allocated on the VM stack (because it does + * not actually do any allocation and thus is faster). For generators + * though this behavior would be suboptimal, because the (rather large) + * structure would have to be copied back and forth every time execution is + * suspended or resumed. That's why for generators the execution context + * is allocated using a separate VM stack, thus allowing to save and + * restore it simply by replacing a pointer. The same segment also keeps + * a copy of previous execute_data and passed parameters. + */ + if (UNEXPECTED((op_array->fn_flags & ZEND_ACC_GENERATOR) != 0)) { + /* Prepend the regular stack frame with a copy of prev_execute_data + * and the passed arguments + */ + int args_count = zend_vm_stack_get_args_count_ex(EG(current_execute_data)); + size_t args_size = ZEND_MM_ALIGNED_SIZE(sizeof(zval*)) * (args_count + 1); + + total_size += args_size + execute_data_size; + + EG(argument_stack) = zend_vm_stack_new_page((total_size + (sizeof(void*) - 1)) / sizeof(void*)); + EG(argument_stack)->prev = NULL; + execute_data = (zend_execute_data*)((char*)ZEND_VM_STACK_ELEMETS(EG(argument_stack)) + args_size + execute_data_size + Ts_size); + + /* copy prev_execute_data */ + EX(prev_execute_data) = (zend_execute_data*)((char*)ZEND_VM_STACK_ELEMETS(EG(argument_stack)) + args_size); + memset(EX(prev_execute_data), 0, sizeof(zend_execute_data)); + EX(prev_execute_data)->function_state.function = (zend_function*)op_array; + EX(prev_execute_data)->function_state.arguments = (void**)((char*)ZEND_VM_STACK_ELEMETS(EG(argument_stack)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval*)) * args_count); + + /* copy arguments */ + *EX(prev_execute_data)->function_state.arguments = (void*)(zend_uintptr_t)args_count; + if (args_count > 0) { + zval **arg_src = (zval**)zend_vm_stack_get_arg_ex(EG(current_execute_data), 1); + zval **arg_dst = (zval**)zend_vm_stack_get_arg_ex(EX(prev_execute_data), 1); + int i; + + for (i = 0; i < args_count; i++) { + arg_dst[i] = arg_src[i]; + Z_ADDREF_P(arg_dst[i]); + } + } + } else { + execute_data = zend_vm_stack_alloc(total_size TSRMLS_CC); + execute_data = (zend_execute_data*)((char*)execute_data + Ts_size); + EX(prev_execute_data) = EG(current_execute_data); + } + + memset(EX_CV_NUM(execute_data, 0), 0, sizeof(zval **) * op_array->last_var); + + EX(call_slots) = (call_slot*)((char *)execute_data + execute_data_size + CVs_size); + + + EX(op_array) = op_array; + + EG(argument_stack)->top = zend_vm_stack_frame_base(execute_data); + + EX(object) = NULL; + EX(current_this) = NULL; + EX(old_error_reporting) = NULL; + EX(symbol_table) = EG(active_symbol_table); + EX(call) = NULL; + EG(current_execute_data) = execute_data; + EX(nested) = nested; + + if (!op_array->run_time_cache && op_array->last_cache_slot) { + op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*)); + } + + if (op_array->this_var != -1 && EG(This)) { + Z_ADDREF_P(EG(This)); /* For $this pointer */ + if (!EG(active_symbol_table)) { + EX_CV(op_array->this_var) = (zval **) EX_CV_NUM(execute_data, op_array->last_var + op_array->this_var); + *EX_CV(op_array->this_var) = EG(This); + } else { + if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), (void **) EX_CV_NUM(execute_data, op_array->this_var))==FAILURE) { + Z_DELREF_P(EG(This)); + } + } + } + + EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes; + EG(opline_ptr) = &EX(opline); + + EX(function_state).function = (zend_function *) op_array; + EX(function_state).arguments = NULL; + + return execute_data; +} +/* }}} */ + +zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */ { - zval **return_value_ptr = &(*(temp_variable *)((char *) execute_data_ptr->Ts + execute_data_ptr->opline->result.var)).var.ptr; - ((zend_internal_function *) execute_data_ptr->function_state.function)->handler(execute_data_ptr->opline->extended_value, *return_value_ptr, (execute_data_ptr->function_state.function->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)?return_value_ptr:NULL, execute_data_ptr->object, return_value_used TSRMLS_CC); + return i_create_execute_data_from_op_array(op_array, nested TSRMLS_CC); } +/* }}} */ #define ZEND_VM_NEXT_OPCODE() \ CHECK_SYMBOL_TABLES() \ @@ -1512,7 +1715,7 @@ ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler { if (opcode != ZEND_USER_OPCODE) { if (handler == NULL) { - /* restore the original handler */ + /* restore the original handler */ zend_user_opcodes[opcode] = opcode; } else { zend_user_opcodes[opcode] = ZEND_USER_OPCODE; @@ -1528,12 +1731,12 @@ ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode) return zend_user_opcode_handlers[opcode]; } -ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC) { - return get_zval_ptr(op_type, node, Ts, should_free, type); +ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) { + return get_zval_ptr(op_type, node, execute_data, should_free, type); } -ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC) { - return get_zval_ptr_ptr(op_type, node, Ts, should_free, type); +ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) { + return get_zval_ptr_ptr(op_type, node, execute_data, should_free, type); } /* diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 19eaeeb402d21..a17f10b312e53 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -5,7 +5,7 @@ | Copyright (c) 1998-2013 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 | + | 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 | @@ -49,24 +49,18 @@ typedef union _temp_variable { BEGIN_EXTERN_C() -ZEND_API extern void (*zend_execute)(zend_op_array *op_array TSRMLS_DC); -ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC); +struct _zend_fcall_info; +ZEND_API extern void (*zend_execute_ex)(zend_execute_data *execute_data TSRMLS_DC); +ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC); 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_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_array, zend_bool nested TSRMLS_DC); +ZEND_API void zend_execute(zend_op_array *op_array TSRMLS_DC); +ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC); +ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, 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 zend_always_inline void safe_free_zval_ptr_rel(zval *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) -{ - TSRMLS_FETCH(); - - if (p!=EG(uninitialized_zval_ptr)) { - FREE_ZVAL_REL(p); - } -} ZEND_API int zend_lookup_class(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC); ZEND_API int zend_lookup_class_ex(const char *name, int name_length, const zend_literal *key, int use_autoload, zend_class_entry ***ce TSRMLS_DC); ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC); @@ -82,11 +76,10 @@ static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC) if (!Z_DELREF_P(zval_ptr)) { TSRMLS_FETCH(); - if (zval_ptr != &EG(uninitialized_zval)) { - GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr); - zval_dtor(zval_ptr); - efree_rel(zval_ptr); - } + ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval)); + GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr); + zval_dtor(zval_ptr); + efree_rel(zval_ptr); } else { TSRMLS_FETCH(); @@ -218,12 +211,6 @@ static zend_always_inline void **zend_vm_stack_top(TSRMLS_D) } static zend_always_inline void zend_vm_stack_push(void *ptr TSRMLS_DC) -{ - ZEND_VM_STACK_GROW_IF_NEEDED(1); - *(EG(argument_stack)->top++) = ptr; -} - -static zend_always_inline void zend_vm_stack_push_nocheck(void *ptr TSRMLS_DC) { *(EG(argument_stack)->top++) = ptr; } @@ -232,11 +219,6 @@ static zend_always_inline void *zend_vm_stack_pop(TSRMLS_D) { void *el = *(--EG(argument_stack)->top); - if (UNEXPECTED(EG(argument_stack)->top == ZEND_VM_STACK_ELEMETS(EG(argument_stack)))) { - zend_vm_stack p = EG(argument_stack); - EG(argument_stack) = p->prev; - efree(p); - } return el; } @@ -269,8 +251,14 @@ static zend_always_inline void *zend_vm_stack_alloc(size_t size TSRMLS_DC) return ret; } +static zend_always_inline void** zend_vm_stack_frame_base(zend_execute_data *ex) +{ + return (void**)((char*)ex->call_slots + + ZEND_MM_ALIGNED_SIZE(sizeof(call_slot)) * ex->op_array->nested_calls); +} + static zend_always_inline void zend_vm_stack_free_int(void *ptr TSRMLS_DC) -{ +{ if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (void**)ptr)) { zend_vm_stack p = EG(argument_stack); @@ -282,7 +270,7 @@ static zend_always_inline void zend_vm_stack_free_int(void *ptr TSRMLS_DC) } static zend_always_inline void zend_vm_stack_free(void *ptr TSRMLS_DC) -{ +{ if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (void**)ptr)) { zend_vm_stack p = EG(argument_stack); @@ -299,51 +287,36 @@ static zend_always_inline void zend_vm_stack_free(void *ptr TSRMLS_DC) } } -static zend_always_inline void** zend_vm_stack_push_args(int count TSRMLS_DC) -{ - - if (UNEXPECTED(EG(argument_stack)->top - ZEND_VM_STACK_ELEMETS(EG(argument_stack)) < count) || - UNEXPECTED(EG(argument_stack)->top == EG(argument_stack)->end)) { - zend_vm_stack p = EG(argument_stack); - - zend_vm_stack_extend(count + 1 TSRMLS_CC); - - EG(argument_stack)->top += count; - *(EG(argument_stack)->top) = (void*)(zend_uintptr_t)count; - while (count-- > 0) { - void *data = *(--p->top); - - if (UNEXPECTED(p->top == ZEND_VM_STACK_ELEMETS(p))) { - zend_vm_stack r = p; - - EG(argument_stack)->prev = p->prev; - p = p->prev; - efree(r); - } - *(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) + count) = data; - } - return EG(argument_stack)->top++; - } - *(EG(argument_stack)->top) = (void*)(zend_uintptr_t)count; - return EG(argument_stack)->top++; -} - -static zend_always_inline void zend_vm_stack_clear_multiple(TSRMLS_D) +static zend_always_inline void zend_vm_stack_clear_multiple(int nested TSRMLS_DC) { void **p = EG(argument_stack)->top - 1; - int delete_count = (int)(zend_uintptr_t) *p; + void **end = p - (int)(zend_uintptr_t)*p; - while (--delete_count>=0) { + while (p != end) { zval *q = *(zval **)(--p); *p = NULL; i_zval_ptr_dtor(q ZEND_FILE_LINE_CC); } - zend_vm_stack_free_int(p TSRMLS_CC); + if (nested) { + EG(argument_stack)->top = p; + } else { + zend_vm_stack_free_int(p TSRMLS_CC); + } } -static zend_always_inline zval** zend_vm_stack_get_arg(int requested_arg TSRMLS_DC) +static zend_always_inline int zend_vm_stack_get_args_count_ex(zend_execute_data *ex) { - void **p = EG(current_execute_data)->prev_execute_data->function_state.arguments; + if (ex) { + void **p = ex->function_state.arguments; + return (int)(zend_uintptr_t) *p; + } else { + return 0; + } +} + +static zend_always_inline zval** zend_vm_stack_get_arg_ex(zend_execute_data *ex, int requested_arg) +{ + void **p = ex->function_state.arguments; int arg_count = (int)(zend_uintptr_t) *p; if (UNEXPECTED(requested_arg > arg_count)) { @@ -352,25 +325,14 @@ static zend_always_inline zval** zend_vm_stack_get_arg(int requested_arg TSRMLS_ return (zval**)p - arg_count + requested_arg - 1; } -static zend_always_inline void zend_arg_types_stack_2_pop(zend_ptr_stack *stack, zval **object, zend_function **fbc) +static zend_always_inline int zend_vm_stack_get_args_count(TSRMLS_D) { - void *a, *b; - - zend_ptr_stack_2_pop(stack, &a, &b); - - *object = (zval *) a; - *fbc = (zend_function *) b; + return zend_vm_stack_get_args_count_ex(EG(current_execute_data)->prev_execute_data); } -static zend_always_inline void zend_arg_types_stack_3_pop(zend_ptr_stack *stack, zend_class_entry **called_scope, zval **object, zend_function **fbc) +static zend_always_inline zval** zend_vm_stack_get_arg(int requested_arg TSRMLS_DC) { - void *a, *b, *c; - - zend_ptr_stack_3_pop(stack, &a, &b, &c); - - *called_scope = (zend_class_entry *) a; - *object = (zval *) b; - *fbc = (zend_function *) c; + return zend_vm_stack_get_arg_ex(EG(current_execute_data)->prev_execute_data, requested_arg); } void execute_new_code(TSRMLS_D); @@ -426,11 +388,14 @@ typedef struct _zend_free_op { /* int is_var; */ } zend_free_op; -ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC); -ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC); +ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC); +ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC); ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS); +void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC); +void zend_free_compiled_variables(zend_execute_data *execute_data); + #define CACHED_PTR(num) \ EG(active_op_array)->run_time_cache[(num)] diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index a38504fbb4c20..f099784a42a89 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -31,14 +31,15 @@ #include "zend_extensions.h" #include "zend_exceptions.h" #include "zend_closures.h" +#include "zend_generators.h" #include "zend_vm.h" #include "zend_float.h" #ifdef HAVE_SYS_TIME_H #include #endif -ZEND_API void (*zend_execute)(zend_op_array *op_array TSRMLS_DC); -ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC); +ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data TSRMLS_DC); +ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC); /* true globals */ ZEND_API const zend_fcall_info empty_fcall_info = { 0, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0 }; @@ -136,7 +137,6 @@ void init_executor(TSRMLS_D) /* {{{ */ INIT_ZVAL(EG(error_zval)); EG(uninitialized_zval_ptr)=&EG(uninitialized_zval); EG(error_zval_ptr)=&EG(error_zval); - zend_ptr_stack_init(&EG(arg_types_stack)); /* destroys stack frame, therefore makes core dumps worthless */ #if 0&&ZEND_DEBUG original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv); @@ -292,10 +292,10 @@ void shutdown_executor(TSRMLS_D) /* {{{ */ } zend_end_try(); zend_try { - zend_vm_stack_destroy(TSRMLS_C); - zend_objects_store_free_object_storage(&EG(objects_store) TSRMLS_CC); + zend_vm_stack_destroy(TSRMLS_C); + /* Destroy all op arrays */ if (EG(full_tables_cleanup)) { zend_hash_reverse_apply(EG(function_table), (apply_func_t) clean_non_persistent_function_full TSRMLS_CC); @@ -323,7 +323,6 @@ 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)); @@ -406,7 +405,7 @@ ZEND_API const char *zend_get_executed_filename(TSRMLS_D) /* {{{ */ ZEND_API uint zend_get_executed_lineno(TSRMLS_D) /* {{{ */ { - if(EG(exception) && EG(opline_ptr) && active_opline->opcode == ZEND_HANDLE_EXCEPTION && + if(EG(exception) && EG(opline_ptr) && active_opline->opcode == ZEND_HANDLE_EXCEPTION && active_opline->lineno == 0 && EG(opline_before_exception)) { return EG(opline_before_exception)->lineno; } @@ -426,27 +425,7 @@ ZEND_API zend_bool zend_is_executing(TSRMLS_D) /* {{{ */ ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) /* {{{ */ { -#if DEBUG_ZEND>=2 - printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, Z_REFCOUNT_PP(zval_ptr), Z_REFCOUNT_PP(zval_ptr) - 1); -#endif - Z_DELREF_PP(zval_ptr); - if (Z_REFCOUNT_PP(zval_ptr) == 0) { - TSRMLS_FETCH(); - - if (*zval_ptr != &EG(uninitialized_zval)) { - GC_REMOVE_ZVAL_FROM_BUFFER(*zval_ptr); - zval_dtor(*zval_ptr); - efree_rel(*zval_ptr); - } - } else { - TSRMLS_FETCH(); - - if (Z_REFCOUNT_PP(zval_ptr) == 1) { - Z_UNSET_ISREF_PP(zval_ptr); - } - - GC_ZVAL_CHECK_POSSIBLE_ROOT(*zval_ptr); - } + i_zval_ptr_dtor(*zval_ptr ZEND_FILE_LINE_RELAY_CC); } /* }}} */ @@ -600,7 +579,7 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco zend_hash_init(tmp_ht, zend_hash_num_elements(Z_ARRVAL_P(p)), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(tmp_ht, Z_ARRVAL_P(p), (copy_ctor_func_t) zval_deep_copy, (void *) &tmp, sizeof(zval *)); Z_ARRVAL_P(p) = tmp_ht; - } + } /* First go over the array and see if there are any constant indices */ zend_hash_internal_pointer_reset(Z_ARRVAL_P(p)); @@ -861,8 +840,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS !ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) { if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (EG(argument_stack)->top))) { /* hack to clean up the stack */ - zend_vm_stack_push_nocheck((void *) (zend_uintptr_t)i TSRMLS_CC); - zend_vm_stack_clear_multiple(TSRMLS_C); + zend_vm_stack_push((void *) (zend_uintptr_t)i TSRMLS_CC); + zend_vm_stack_clear_multiple(0 TSRMLS_CC); } zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given", @@ -898,11 +877,11 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS *param = **(fci->params[i]); INIT_PZVAL(param); } - zend_vm_stack_push_nocheck(param TSRMLS_CC); + zend_vm_stack_push(param TSRMLS_CC); } EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); - zend_vm_stack_push_nocheck((void*)(zend_uintptr_t)fci->param_count TSRMLS_CC); + zend_vm_stack_push((void*)(zend_uintptr_t)fci->param_count TSRMLS_CC); current_scope = EG(scope); EG(scope) = calling_scope; @@ -955,17 +934,15 @@ 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); - zend_execute(EG(active_op_array) TSRMLS_CC); + + if (EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) { + *fci->retval_ptr_ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC); + } else { + zend_execute(EG(active_op_array) TSRMLS_CC); + } + if (!fci->symbol_table && EG(active_symbol_table)) { - if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { - zend_hash_destroy(EG(active_symbol_table)); - FREE_HASHTABLE(EG(active_symbol_table)); - } else { - /* clean before putting into the cache, since clean - could call dtors, which could use cached hash */ - zend_hash_clean(EG(active_symbol_table)); - *(++EG(symtable_cache_ptr)) = EG(active_symbol_table); - } + zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } EG(active_symbol_table) = calling_symbol_table; EG(active_op_array) = original_op_array; @@ -977,7 +954,12 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS if (EX(function_state).function->common.scope) { EG(scope) = EX(function_state).function->common.scope; } - ((zend_internal_function *) EX(function_state).function)->handler(fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC); + if(EXPECTED(zend_execute_internal == NULL)) { + /* saves one function call if zend_execute_internal is not used */ + ((zend_internal_function *) EX(function_state).function)->handler(fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC); + } else { + zend_execute_internal(&execute_data, fci, 1 TSRMLS_CC); + } /* We shouldn't fix bad extensions here, because it can break proper ones (Bug #34045) if (!EX(function_state).function->common.return_reference) @@ -1013,7 +995,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS *fci->retval_ptr_ptr = NULL; } } - zend_vm_stack_clear_multiple(TSRMLS_C); + zend_vm_stack_clear_multiple(0 TSRMLS_CC); if (EG(This)) { zval_ptr_dtor(&EG(This)); @@ -1312,9 +1294,9 @@ void execute_new_code(TSRMLS_D) /* {{{ */ ZEND_VM_SET_OPCODE_HANDLER(opline); opline++; } - + zend_release_labels(TSRMLS_C); - + EG(return_value_ptr_ptr) = NULL; EG(active_op_array) = CG(active_op_array); orig_interactive = CG(interactive); @@ -1337,11 +1319,11 @@ ZEND_API void zend_timeout(int dummy) /* {{{ */ if (zend_on_timeout) { #ifdef ZEND_SIGNALS - /* + /* We got here because we got a timeout signal, so we are in a signal handler at this point. However, we want to be able to timeout any user-supplied shutdown functions, so pretend we are not in a signal handler while we are - calling these + calling these */ SIGG(running) = 0; #endif @@ -1590,7 +1572,7 @@ zend_class_entry *zend_fetch_class(const char *class_name, uint class_name_len, zend_error(E_ERROR, "Trait '%s' not found", class_name); } else { zend_error(E_ERROR, "Class '%s' not found", class_name); - } + } } } return NULL; @@ -1613,7 +1595,7 @@ zend_class_entry *zend_fetch_class_by_name(const char *class_name, uint class_na zend_error(E_ERROR, "Trait '%s' not found", class_name); } else { zend_error(E_ERROR, "Class '%s' not found", class_name); - } + } } } return NULL; @@ -1687,7 +1669,7 @@ ZEND_API void zend_reset_all_cv(HashTable *symbol_table TSRMLS_DC) /* {{{ */ for (ex = EG(current_execute_data); ex; ex = ex->prev_execute_data) { if (ex->op_array && ex->symbol_table == symbol_table) { for (i = 0; i < ex->op_array->last_var; i++) { - ex->CVs[i] = NULL; + *EX_CV_NUM(ex, i) = NULL; } } } @@ -1706,7 +1688,7 @@ ZEND_API void zend_delete_variable(zend_execute_data *ex, HashTable *ht, const c 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; + *EX_CV_NUM(ex, i) = NULL; break; } } @@ -1730,7 +1712,7 @@ ZEND_API int zend_delete_global_variable_ex(const char *name, int name_len, ulon ex->op_array->vars[i].name_len == name_len && !memcmp(ex->op_array->vars[i].name, name, name_len) ) { - ex->CVs[i] = NULL; + *EX_CV_NUM(ex, i) = NULL; break; } } @@ -1754,7 +1736,7 @@ ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */ zend_execute_data *ex; if (!EG(active_symbol_table)) { - + /* Search for last called user function */ ex = EG(current_execute_data); while (ex && !ex->op_array) { @@ -1777,20 +1759,20 @@ ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */ ex->symbol_table = EG(active_symbol_table); if (ex->op_array->this_var != -1 && - !ex->CVs[ex->op_array->this_var] && + !*EX_CV_NUM(ex, ex->op_array->this_var) && EG(This)) { - ex->CVs[ex->op_array->this_var] = (zval**)ex->CVs + ex->op_array->last_var + ex->op_array->this_var; - *ex->CVs[ex->op_array->this_var] = EG(This); + *EX_CV_NUM(ex, ex->op_array->this_var) = (zval**)EX_CV_NUM(ex, ex->op_array->last_var + ex->op_array->this_var); + **EX_CV_NUM(ex, ex->op_array->this_var) = EG(This); } for (i = 0; i < ex->op_array->last_var; i++) { - if (ex->CVs[i]) { + if (*EX_CV_NUM(ex, i)) { zend_hash_quick_update(EG(active_symbol_table), ex->op_array->vars[i].name, ex->op_array->vars[i].name_len + 1, ex->op_array->vars[i].hash_value, - (void**)ex->CVs[i], + (void**)*EX_CV_NUM(ex, i), sizeof(zval*), - (void**)&ex->CVs[i]); + (void**)EX_CV_NUM(ex, i)); } } } diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h index efab29d67e601..83cad7f38d648 100644 --- a/Zend/zend_extensions.h +++ b/Zend/zend_extensions.h @@ -28,7 +28,7 @@ /* The first number is the engine version and the rest is the date. * This way engine 2/3 API no. is always greater than engine 1 API no.. */ -#define ZEND_EXTENSION_API_NO 220100525 +#define ZEND_EXTENSION_API_NO 220121212 typedef struct _zend_extension_version_info { int zend_extension_api_no; diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c new file mode 100644 index 0000000000000..c1dbee124f386 --- /dev/null +++ b/Zend/zend_generators.c @@ -0,0 +1,894 @@ +/* + +----------------------------------------------------------------------+ + | Zend Engine | + +----------------------------------------------------------------------+ + | Copyright (c) 1998-2013 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: Nikita Popov | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#include "zend.h" +#include "zend_API.h" +#include "zend_interfaces.h" +#include "zend_exceptions.h" +#include "zend_generators.h" + +ZEND_API zend_class_entry *zend_ce_generator; +static zend_object_handlers zend_generator_handlers; + +static zend_object_value zend_generator_create(zend_class_entry *class_type TSRMLS_DC); + +ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution TSRMLS_DC) /* {{{ */ +{ + if (generator->value) { + zval_ptr_dtor(&generator->value); + generator->value = NULL; + } + + if (generator->key) { + zval_ptr_dtor(&generator->key); + generator->key = NULL; + } + + if (generator->execute_data) { + zend_execute_data *execute_data = generator->execute_data; + zend_op_array *op_array = execute_data->op_array; + + if (!execute_data->symbol_table) { + zend_free_compiled_variables(execute_data); + } else { + zend_clean_and_cache_symbol_table(execute_data->symbol_table TSRMLS_CC); + } + + if (execute_data->current_this) { + zval_ptr_dtor(&execute_data->current_this); + } + + /* If the generator is closed before it can finish execution (reach + * a return statement) we have to free loop variables manually, as + * we don't know whether the SWITCH_FREE / FREE opcodes have run */ + if (!finished_execution) { + /* -1 required because we want the last run opcode, not the + * next to-be-run one. */ + zend_uint op_num = execute_data->opline - op_array->opcodes - 1; + + int i; + for (i = 0; i < op_array->last_brk_cont; ++i) { + zend_brk_cont_element *brk_cont = op_array->brk_cont_array + i; + + if (brk_cont->start < 0) { + continue; + } else if (brk_cont->start > op_num) { + break; + } else if (brk_cont->brk > op_num) { + zend_op *brk_opline = op_array->opcodes + brk_cont->brk; + + switch (brk_opline->opcode) { + case ZEND_SWITCH_FREE: + { + temp_variable *var = EX_TMP_VAR(execute_data, brk_opline->op1.var); + zval_ptr_dtor(&var->var.ptr); + } + break; + case ZEND_FREE: + { + temp_variable *var = EX_TMP_VAR(execute_data, brk_opline->op1.var); + zval_dtor(&var->tmp_var); + } + break; + } + } + } + } + + /* Clear any backed up stack arguments */ + if (generator->stack != EG(argument_stack)) { + void **ptr = generator->stack->top - 1; + void **end = zend_vm_stack_frame_base(execute_data); + + /* If the top stack element is the argument count, skip it */ + if (execute_data->function_state.arguments) { + ptr--; + } + + for (; ptr >= end; --ptr) { + zval_ptr_dtor((zval**) ptr); + } + } + + while (execute_data->call >= execute_data->call_slots) { + if (execute_data->call->object) { + zval_ptr_dtor(&execute_data->call->object); + } + execute_data->call--; + } + + /* We have added an additional stack frame in prev_execute_data, so we + * have to free it. It also contains the arguments passed to the + * generator (for func_get_args) so those have to be freed too. */ + { + zend_execute_data *prev_execute_data = execute_data->prev_execute_data; + void **arguments = prev_execute_data->function_state.arguments; + + if (arguments) { + int arguments_count = (int) (zend_uintptr_t) *arguments; + zval **arguments_start = (zval **) (arguments - arguments_count); + int i; + + for (i = 0; i < arguments_count; ++i) { + zval_ptr_dtor(arguments_start + i); + } + } + } + + /* Free a clone of closure */ + if (op_array->fn_flags & ZEND_ACC_CLOSURE) { + destroy_op_array(op_array TSRMLS_CC); + efree(op_array); + } + + efree(generator->stack); + if (generator->stack == EG(argument_stack)) { + /* abnormal exit for running generator */ + EG(argument_stack) = NULL; + } + generator->execute_data = NULL; + } +} +/* }}} */ + +static void zend_generator_dtor_storage(zend_generator *generator, zend_object_handle handle TSRMLS_DC) /* {{{ */ +{ + zend_execute_data *ex = generator->execute_data; + zend_uint op_num, finally_op_num; + int i; + + if (!ex || !ex->op_array->has_finally_block) { + return; + } + + /* -1 required because we want the last run opcode, not the + * next to-be-run one. */ + op_num = ex->opline - ex->op_array->opcodes - 1; + + /* Find next finally block */ + finally_op_num = 0; + for (i = 0; i < ex->op_array->last_try_catch; i++) { + zend_try_catch_element *try_catch = &ex->op_array->try_catch_array[i]; + + if (op_num < try_catch->try_op) { + break; + } + + if (op_num < try_catch->finally_op) { + finally_op_num = try_catch->finally_op; + } + } + + /* If a finally block was found we jump directly to it and + * resume the generator. */ + if (finally_op_num) { + ex->opline = &ex->op_array->opcodes[finally_op_num]; + ex->fast_ret = NULL; + generator->flags |= ZEND_GENERATOR_FORCED_CLOSE; + zend_generator_resume(generator TSRMLS_CC); + } +} +/* }}} */ + +static void zend_generator_free_storage(zend_generator *generator TSRMLS_DC) /* {{{ */ +{ + zend_generator_close(generator, 0 TSRMLS_CC); + + zend_object_std_dtor(&generator->std TSRMLS_CC); + efree(generator); +} +/* }}} */ + +static zend_object_value zend_generator_clone(zval *object TSRMLS_DC) /* {{{ */ +{ + zend_generator *orig = zend_object_store_get_object(object TSRMLS_CC); + zend_object_value clone_val = zend_generator_create(Z_OBJCE_P(object) TSRMLS_CC); + zend_generator *clone = zend_object_store_get_object_by_handle(clone_val.handle TSRMLS_CC); + + zend_objects_clone_members( + &clone->std, clone_val, &orig->std, Z_OBJ_HANDLE_P(object) TSRMLS_CC + ); + + clone->execute_data = orig->execute_data; + clone->largest_used_integer_key = orig->largest_used_integer_key; + clone->flags = orig->flags; + + if (orig->execute_data) { + /* Create a few shorter aliases to the old execution data */ + zend_execute_data *execute_data = orig->execute_data; + zend_op_array *op_array = execute_data->op_array; + HashTable *symbol_table = execute_data->symbol_table; + zend_execute_data *current_execute_data; + zend_op **opline_ptr; + HashTable *current_symbol_table; + zend_vm_stack current_stack; + zval *current_this; + void **stack_frame, **orig_stack_frame; + + /* Create new execution context. We have to back up and restore + * EG(current_execute_data), EG(opline_ptr), EG(active_symbol_table) + * and EG(This) here because the function modifies or uses them */ + current_execute_data = EG(current_execute_data); + EG(current_execute_data) = execute_data->prev_execute_data; + opline_ptr = EG(opline_ptr); + current_symbol_table = EG(active_symbol_table); + EG(active_symbol_table) = execute_data->symbol_table; + current_this = EG(This); + EG(This) = NULL; + current_stack = EG(argument_stack); + clone->execute_data = zend_create_execute_data_from_op_array(op_array, 0 TSRMLS_CC); + clone->stack = EG(argument_stack); + EG(argument_stack) = current_stack; + EG(This) = current_this; + EG(active_symbol_table) = current_symbol_table; + EG(current_execute_data) = current_execute_data; + EG(opline_ptr) = opline_ptr; + + /* copy */ + clone->execute_data->opline = execute_data->opline; + clone->execute_data->function_state = execute_data->function_state; + clone->execute_data->object = execute_data->object; + clone->execute_data->current_scope = execute_data->current_scope; + clone->execute_data->current_called_scope = execute_data->current_called_scope; + clone->execute_data->fast_ret = execute_data->fast_ret; + + if (!symbol_table) { + int i; + + /* Copy compiled variables */ + for (i = 0; i < op_array->last_var; i++) { + if (*EX_CV_NUM(execute_data, i)) { + *EX_CV_NUM(clone->execute_data, i) = (zval **) EX_CV_NUM(clone->execute_data, op_array->last_var + i); + **EX_CV_NUM(clone->execute_data, i) = *(zval **) EX_CV_NUM(execute_data, op_array->last_var + i); + Z_ADDREF_PP(*EX_CV_NUM(clone->execute_data, i)); + } + } + } else { + /* Copy symbol table */ + ALLOC_HASHTABLE(clone->execute_data->symbol_table); + zend_hash_init(clone->execute_data->symbol_table, zend_hash_num_elements(symbol_table), NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(clone->execute_data->symbol_table, symbol_table, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); + + /* Update zval** pointers for compiled variables */ + { + int i; + for (i = 0; i < op_array->last_var; i++) { + if (zend_hash_quick_find(clone->execute_data->symbol_table, op_array->vars[i].name, op_array->vars[i].name_len + 1, op_array->vars[i].hash_value, (void **) EX_CV_NUM(clone->execute_data, i)) == FAILURE) { + *EX_CV_NUM(clone->execute_data, i) = NULL; + } + } + } + } + + /* Copy nested-calls stack */ + if (execute_data->call) { + clone->execute_data->call = clone->execute_data->call_slots + + (execute_data->call - execute_data->call_slots); + } else { + clone->execute_data->call = NULL; + } + memcpy(clone->execute_data->call_slots, execute_data->call_slots, ZEND_MM_ALIGNED_SIZE(sizeof(call_slot)) * op_array->nested_calls); + if (clone->execute_data->call >= clone->execute_data->call_slots) { + call_slot *call = clone->execute_data->call; + + while (call >= clone->execute_data->call_slots) { + if (call->object) { + Z_ADDREF_P(call->object); + } + call--; + } + } + + /* Copy the temporary variables */ + memcpy(EX_TMP_VAR_NUM(clone->execute_data, op_array->T-1), EX_TMP_VAR_NUM(execute_data, op_array->T-1), ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T); + + /* Copy arguments passed on stack */ + stack_frame = zend_vm_stack_frame_base(clone->execute_data); + orig_stack_frame = zend_vm_stack_frame_base(execute_data); + clone->stack->top = stack_frame + (orig->stack->top - orig_stack_frame); + if (clone->stack->top != stack_frame) { + memcpy(stack_frame, orig_stack_frame, ZEND_MM_ALIGNED_SIZE(sizeof(zval*)) * (orig->stack->top - orig_stack_frame)); + while (clone->stack->top != stack_frame) { + Z_ADDREF_PP((zval**)stack_frame); + stack_frame++; + } + } + + /* Add references to loop variables */ + { + zend_uint op_num = execute_data->opline - op_array->opcodes; + + int i; + for (i = 0; i < op_array->last_brk_cont; ++i) { + zend_brk_cont_element *brk_cont = op_array->brk_cont_array + i; + + if (brk_cont->start < 0) { + continue; + } else if (brk_cont->start > op_num) { + break; + } else if (brk_cont->brk > op_num) { + zend_op *brk_opline = op_array->opcodes + brk_cont->brk; + + if (brk_opline->opcode == ZEND_SWITCH_FREE) { + temp_variable *var = EX_TMP_VAR(execute_data, brk_opline->op1.var); + + Z_ADDREF_P(var->var.ptr); + } + } + } + } + + /* Update the send_target to use the temporary variable with the same + * offset as the original generator, but in our temporary variable + * memory segment. */ + if (orig->send_target) { + size_t offset = (char *) orig->send_target - (char *)execute_data; + clone->send_target = EX_TMP_VAR(clone->execute_data, offset); + zval_copy_ctor(&clone->send_target->tmp_var); + } + + if (execute_data->current_this) { + clone->execute_data->current_this = execute_data->current_this; + Z_ADDREF_P(execute_data->current_this); + } + } + + /* The value and key are known not to be references, so simply add refs */ + if (orig->value) { + clone->value = orig->value; + Z_ADDREF_P(orig->value); + } + + if (orig->key) { + clone->key = orig->key; + Z_ADDREF_P(orig->key); + } + + return clone_val; +} +/* }}} */ + +static zend_object_value zend_generator_create(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ +{ + zend_generator *generator; + zend_object_value object; + + generator = emalloc(sizeof(zend_generator)); + memset(generator, 0, sizeof(zend_generator)); + + /* The key will be incremented on first use, so it'll start at 0 */ + generator->largest_used_integer_key = -1; + + zend_object_std_init(&generator->std, class_type TSRMLS_CC); + + object.handle = zend_objects_store_put(generator, + (zend_objects_store_dtor_t) zend_generator_dtor_storage, + (zend_objects_free_object_storage_t) zend_generator_free_storage, + NULL TSRMLS_CC + ); + object.handlers = &zend_generator_handlers; + + return object; +} +/* }}} */ + +/* Requires globals EG(scope), EG(current_scope), EG(This), + * EG(active_symbol_table) and EG(current_execute_data). */ +ZEND_API zval *zend_generator_create_zval(zend_op_array *op_array TSRMLS_DC) /* {{{ */ +{ + zval *return_value; + zend_generator *generator; + zend_execute_data *current_execute_data; + zend_op **opline_ptr; + HashTable *current_symbol_table; + zend_execute_data *execute_data; + zend_vm_stack current_stack = EG(argument_stack); + + /* Create a clone of closure, because it may be destroyed */ + if (op_array->fn_flags & ZEND_ACC_CLOSURE) { + zend_op_array *op_array_copy = (zend_op_array*)emalloc(sizeof(zend_op_array)); + *op_array_copy = *op_array; + function_add_ref((zend_function *) op_array_copy); + op_array = op_array_copy; + } + + /* Create new execution context. We have to back up and restore + * EG(current_execute_data), EG(opline_ptr) and EG(active_symbol_table) + * here because the function modifies or uses them */ + current_execute_data = EG(current_execute_data); + opline_ptr = EG(opline_ptr); + current_symbol_table = EG(active_symbol_table); + EG(active_symbol_table) = NULL; + execute_data = zend_create_execute_data_from_op_array(op_array, 0 TSRMLS_CC); + EG(active_symbol_table) = current_symbol_table; + EG(current_execute_data) = current_execute_data; + EG(opline_ptr) = opline_ptr; + + ALLOC_INIT_ZVAL(return_value); + object_init_ex(return_value, zend_ce_generator); + + if (EG(This)) { + Z_ADDREF_P(EG(This)); + } + + /* Back up executor globals. */ + execute_data->current_scope = EG(scope); + execute_data->current_called_scope = EG(called_scope); + execute_data->symbol_table = EG(active_symbol_table); + execute_data->current_this = EG(This); + + /* Save execution context in generator object. */ + generator = (zend_generator *) zend_object_store_get_object(return_value TSRMLS_CC); + generator->execute_data = execute_data; + generator->stack = EG(argument_stack); + EG(argument_stack) = current_stack; + + return return_value; +} +/* }}} */ + +static zend_function *zend_generator_get_constructor(zval *object TSRMLS_DC) /* {{{ */ +{ + zend_error(E_RECOVERABLE_ERROR, "The \"Generator\" class is reserved for internal use and cannot be manually instantiated"); + + return NULL; +} +/* }}} */ + +ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ */ +{ + /* The generator is already closed, thus can't resume */ + if (!generator->execute_data) { + return; + } + + if (generator->flags & ZEND_GENERATOR_CURRENTLY_RUNNING) { + zend_error(E_ERROR, "Cannot resume an already running generator"); + } + + /* Drop the AT_FIRST_YIELD flag */ + generator->flags &= ~ZEND_GENERATOR_AT_FIRST_YIELD; + + { + /* Backup executor globals */ + zval **original_return_value_ptr_ptr = EG(return_value_ptr_ptr); + zend_execute_data *original_execute_data = EG(current_execute_data); + zend_op **original_opline_ptr = EG(opline_ptr); + zend_op_array *original_active_op_array = EG(active_op_array); + HashTable *original_active_symbol_table = EG(active_symbol_table); + zval *original_This = EG(This); + zend_class_entry *original_scope = EG(scope); + zend_class_entry *original_called_scope = EG(called_scope); + zend_vm_stack original_stack = EG(argument_stack); + + /* We (mis)use the return_value_ptr_ptr to provide the generator object + * to the executor, so YIELD will be able to set the yielded value */ + EG(return_value_ptr_ptr) = (zval **) generator; + + /* Set executor globals */ + EG(current_execute_data) = generator->execute_data; + EG(opline_ptr) = &generator->execute_data->opline; + EG(active_op_array) = generator->execute_data->op_array; + EG(active_symbol_table) = generator->execute_data->symbol_table; + EG(This) = generator->execute_data->current_this; + EG(scope) = generator->execute_data->current_scope; + EG(called_scope) = generator->execute_data->current_called_scope; + EG(argument_stack) = generator->stack; + + /* We want the backtrace to look as if the generator function was + * called from whatever method we are current running (e.g. next()). + * The first prev_execute_data contains an additional stack frame, + * which makes the generator function show up in the backtrace and + * makes the arguments available to func_get_args(). So we have to + * set the prev_execute_data of that prev_execute_data :) */ + generator->execute_data->prev_execute_data->prev_execute_data = original_execute_data; + + /* Resume execution */ + generator->flags |= ZEND_GENERATOR_CURRENTLY_RUNNING; + zend_execute_ex(generator->execute_data TSRMLS_CC); + generator->flags &= ~ZEND_GENERATOR_CURRENTLY_RUNNING; + + /* Restore executor globals */ + EG(return_value_ptr_ptr) = original_return_value_ptr_ptr; + EG(current_execute_data) = original_execute_data; + EG(opline_ptr) = original_opline_ptr; + EG(active_op_array) = original_active_op_array; + EG(active_symbol_table) = original_active_symbol_table; + EG(This) = original_This; + EG(scope) = original_scope; + EG(called_scope) = original_called_scope; + EG(argument_stack) = original_stack; + + /* If an exception was thrown in the generator we have to internally + * rethrow it in the parent scope. */ + if (UNEXPECTED(EG(exception) != NULL)) { + zend_throw_exception_internal(NULL TSRMLS_CC); + } + } +} +/* }}} */ + +static void zend_generator_ensure_initialized(zend_generator *generator TSRMLS_DC) /* {{{ */ +{ + if (generator->execute_data && !generator->value) { + zend_generator_resume(generator TSRMLS_CC); + generator->flags |= ZEND_GENERATOR_AT_FIRST_YIELD; + } +} +/* }}} */ + +static void zend_generator_rewind(zend_generator *generator TSRMLS_DC) /* {{{ */ +{ + zend_generator_ensure_initialized(generator TSRMLS_CC); + + if (!(generator->flags & ZEND_GENERATOR_AT_FIRST_YIELD)) { + zend_throw_exception(NULL, "Cannot rewind a generator that was already run", 0 TSRMLS_CC); + } +} +/* }}} */ + +/* {{{ proto void Generator::rewind() + * Rewind the generator */ +ZEND_METHOD(Generator, rewind) +{ + zend_generator *generator; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); + + zend_generator_rewind(generator TSRMLS_CC); +} +/* }}} */ + +/* {{{ proto bool Generator::valid() + * Check whether the generator is valid */ +ZEND_METHOD(Generator, valid) +{ + zend_generator *generator; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); + + zend_generator_ensure_initialized(generator TSRMLS_CC); + + RETURN_BOOL(generator->value != NULL); +} +/* }}} */ + +/* {{{ proto mixed Generator::current() + * Get the current value */ +ZEND_METHOD(Generator, current) +{ + zend_generator *generator; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); + + zend_generator_ensure_initialized(generator TSRMLS_CC); + + if (generator->value) { + RETURN_ZVAL(generator->value, 1, 0); + } +} +/* }}} */ + +/* {{{ proto mixed Generator::key() + * Get the current key */ +ZEND_METHOD(Generator, key) +{ + zend_generator *generator; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); + + zend_generator_ensure_initialized(generator TSRMLS_CC); + + if (generator->key) { + RETURN_ZVAL(generator->key, 1, 0); + } +} +/* }}} */ + +/* {{{ proto void Generator::next() + * Advances the generator */ +ZEND_METHOD(Generator, next) +{ + zend_generator *generator; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); + + zend_generator_ensure_initialized(generator TSRMLS_CC); + + zend_generator_resume(generator TSRMLS_CC); +} +/* }}} */ + +/* {{{ proto mixed Generator::send(mixed $value) + * Sends a value to the generator */ +ZEND_METHOD(Generator, send) +{ + zval *value; + zend_generator *generator; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) { + return; + } + + generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); + + zend_generator_ensure_initialized(generator TSRMLS_CC); + + /* The generator is already closed, thus can't send anything */ + if (!generator->execute_data) { + return; + } + + /* Put sent value into the TMP_VAR slot */ + MAKE_COPY_ZVAL(&value, &generator->send_target->tmp_var); + + zend_generator_resume(generator TSRMLS_CC); + + if (generator->value) { + RETURN_ZVAL(generator->value, 1, 0); + } +} +/* }}} */ + +/* {{{ proto mixed Generator::throw(Exception $exception) + * Throws an exception into the generator */ +ZEND_METHOD(Generator, throw) +{ + zval *exception, *exception_copy; + zend_generator *generator; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &exception) == FAILURE) { + return; + } + + ALLOC_ZVAL(exception_copy); + MAKE_COPY_ZVAL(&exception, exception_copy); + + generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); + + if (generator->execute_data) { + /* Throw the exception in the context of the generator */ + zend_execute_data *current_execute_data = EG(current_execute_data); + EG(current_execute_data) = generator->execute_data; + + zend_throw_exception_object(exception_copy TSRMLS_CC); + + EG(current_execute_data) = current_execute_data; + + zend_generator_resume(generator TSRMLS_CC); + + if (generator->value) { + RETURN_ZVAL(generator->value, 1, 0); + } + } else { + /* If the generator is already closed throw the exception in the + * current context */ + zend_throw_exception_object(exception_copy TSRMLS_CC); + } +} +/* }}} */ + +/* {{{ proto void Generator::__wakeup() + * Throws an Exception as generators can't be serialized */ +ZEND_METHOD(Generator, __wakeup) +{ + /* Just specifying the zend_class_unserialize_deny handler is not enough, + * because it is only invoked for C unserialization. For O the error has + * to be thrown in __wakeup. */ + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + zend_throw_exception(NULL, "Unserialization of 'Generator' is not allowed", 0 TSRMLS_CC); +} +/* }}} */ + +/* get_iterator implementation */ + +static void zend_generator_iterator_dtor(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ +{ + zval *object = ((zend_generator_iterator *) iterator)->object; + + zval_ptr_dtor(&object); +} +/* }}} */ + +static int zend_generator_iterator_valid(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ +{ + zend_generator *generator = (zend_generator *) iterator->data; + + zend_generator_ensure_initialized(generator TSRMLS_CC); + + return generator->value != NULL ? SUCCESS : FAILURE; +} +/* }}} */ + +static void zend_generator_iterator_get_data(zend_object_iterator *iterator, zval ***data TSRMLS_DC) /* {{{ */ +{ + zend_generator *generator = (zend_generator *) iterator->data; + + zend_generator_ensure_initialized(generator TSRMLS_CC); + + if (generator->value) { + *data = &generator->value; + } else { + *data = NULL; + } +} +/* }}} */ + +static int zend_generator_iterator_get_key(zend_object_iterator *iterator, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC) /* {{{ */ +{ + zend_generator *generator = (zend_generator *) iterator->data; + + zend_generator_ensure_initialized(generator TSRMLS_CC); + + if (!generator->key) { + return HASH_KEY_NON_EXISTANT; + } + + if (Z_TYPE_P(generator->key) == IS_LONG) { + *int_key = Z_LVAL_P(generator->key); + return HASH_KEY_IS_LONG; + } + + if (Z_TYPE_P(generator->key) == IS_STRING) { + *str_key = estrndup(Z_STRVAL_P(generator->key), Z_STRLEN_P(generator->key)); + *str_key_len = Z_STRLEN_P(generator->key) + 1; + return HASH_KEY_IS_STRING; + } + + /* Waiting for Etienne's patch to allow arbitrary zval keys. Until then + * error out on non-int and non-string keys. */ + zend_error_noreturn(E_ERROR, "Currently only int and string keys can be yielded"); + return HASH_KEY_NON_EXISTANT; /* Nerver reached */ +} +/* }}} */ + +static void zend_generator_iterator_move_forward(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ +{ + zend_generator *generator = (zend_generator *) iterator->data; + + zend_generator_ensure_initialized(generator TSRMLS_CC); + + zend_generator_resume(generator TSRMLS_CC); +} +/* }}} */ + +static void zend_generator_iterator_rewind(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ +{ + zend_generator *generator = (zend_generator *) iterator->data; + + zend_generator_rewind(generator TSRMLS_CC); +} +/* }}} */ + +static zend_object_iterator_funcs zend_generator_iterator_functions = { + zend_generator_iterator_dtor, + zend_generator_iterator_valid, + zend_generator_iterator_get_data, + zend_generator_iterator_get_key, + zend_generator_iterator_move_forward, + zend_generator_iterator_rewind +}; + +zend_object_iterator *zend_generator_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) /* {{{ */ +{ + zend_generator_iterator *iterator; + zend_generator *generator; + + generator = (zend_generator *) zend_object_store_get_object(object TSRMLS_CC); + + if (!generator->execute_data) { + zend_throw_exception(NULL, "Cannot traverse an already closed generator", 0 TSRMLS_CC); + return NULL; + } + + if (by_ref && !(generator->execute_data->op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE)) { + zend_throw_exception(NULL, "You can only iterate a generator by-reference if it declared that it yields by-reference", 0 TSRMLS_CC); + return NULL; + } + + iterator = &generator->iterator; + iterator->intern.funcs = &zend_generator_iterator_functions; + iterator->intern.data = (void *) generator; + + /* We have to keep a reference to the generator object zval around, + * otherwise the generator may be destroyed during iteration. */ + Z_ADDREF_P(object); + iterator->object = object; + + return (zend_object_iterator *) iterator; +} +/* }}} */ + +ZEND_BEGIN_ARG_INFO(arginfo_generator_void, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_generator_send, 0, 0, 1) + ZEND_ARG_INFO(0, value) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_generator_throw, 0, 0, 1) + ZEND_ARG_INFO(0, exception) +ZEND_END_ARG_INFO() + +static const zend_function_entry generator_functions[] = { + ZEND_ME(Generator, rewind, arginfo_generator_void, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, valid, arginfo_generator_void, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, current, arginfo_generator_void, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, key, arginfo_generator_void, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, next, arginfo_generator_void, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, send, arginfo_generator_send, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, throw, arginfo_generator_throw, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, __wakeup, arginfo_generator_void, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +void zend_register_generator_ce(TSRMLS_D) /* {{{ */ +{ + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, "Generator", generator_functions); + zend_ce_generator = zend_register_internal_class(&ce TSRMLS_CC); + zend_ce_generator->ce_flags |= ZEND_ACC_FINAL_CLASS; + zend_ce_generator->create_object = zend_generator_create; + zend_ce_generator->serialize = zend_class_serialize_deny; + zend_ce_generator->unserialize = zend_class_unserialize_deny; + + /* get_iterator has to be assigned *after* implementing the inferface */ + zend_class_implements(zend_ce_generator TSRMLS_CC, 1, zend_ce_iterator); + zend_ce_generator->get_iterator = zend_generator_get_iterator; + zend_ce_generator->iterator_funcs.funcs = &zend_generator_iterator_functions; + + memcpy(&zend_generator_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + zend_generator_handlers.get_constructor = zend_generator_get_constructor; + zend_generator_handlers.clone_obj = zend_generator_clone; +} +/* }}} */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode: t + * End: + */ diff --git a/Zend/zend_generators.h b/Zend/zend_generators.h new file mode 100644 index 0000000000000..9f37b93c45a15 --- /dev/null +++ b/Zend/zend_generators.h @@ -0,0 +1,77 @@ +/* + +----------------------------------------------------------------------+ + | Zend Engine | + +----------------------------------------------------------------------+ + | Copyright (c) 1998-2013 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: Nikita Popov | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef ZEND_GENERATORS_H +#define ZEND_GENERATORS_H + +BEGIN_EXTERN_C() +extern ZEND_API zend_class_entry *zend_ce_generator; +END_EXTERN_C() + +typedef struct _zend_generator_iterator { + zend_object_iterator intern; + + /* The generator object zval has to be stored, because the iterator is + * holding a ref to it, which has to be dtored. */ + zval *object; +} zend_generator_iterator; + +typedef struct _zend_generator { + zend_object std; + + zend_generator_iterator iterator; + + /* The suspended execution context. */ + zend_execute_data *execute_data; + + /* The separate stack used by generator */ + zend_vm_stack stack; + + /* Current value */ + zval *value; + /* Current key */ + zval *key; + /* Variable to put sent value into */ + temp_variable *send_target; + /* Largest used integer key for auto-incrementing keys */ + long largest_used_integer_key; + + /* ZEND_GENERATOR_* flags */ + zend_uchar flags; +} zend_generator; + +static const zend_uchar ZEND_GENERATOR_CURRENTLY_RUNNING = 0x1; +static const zend_uchar ZEND_GENERATOR_FORCED_CLOSE = 0x2; +static const zend_uchar ZEND_GENERATOR_AT_FIRST_YIELD = 0x4; + +void zend_register_generator_ce(TSRMLS_D); +ZEND_API zval *zend_generator_create_zval(zend_op_array *op_array TSRMLS_DC); +ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution TSRMLS_DC); +ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC); + +#endif + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode: t + * End: + */ diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 58392c199bd58..800bdc7f66bcf 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -89,9 +89,6 @@ struct _zend_compiler_globals { int zend_lineno; - char *heredoc; - int heredoc_len; - zend_op_array *active_op_array; HashTable *function_table; /* function symbol table */ @@ -170,8 +167,6 @@ struct _zend_executor_globals { zval error_zval; zval *error_zval_ptr; - zend_ptr_stack arg_types_stack; - /* symbol table cache */ HashTable *symtable_cache[SYMTABLE_CACHE_SIZE]; HashTable **symtable_cache_limit; @@ -297,6 +292,7 @@ struct _zend_php_scanner_globals { unsigned char *yy_limit; int yy_state; zend_stack state_stack; + zend_ptr_stack heredoc_label_stack; /* original (unfiltered) script */ unsigned char *script_org; diff --git a/Zend/zend_highlight.c b/Zend/zend_highlight.c index ad299e35902c2..c789cb719a01b 100644 --- a/Zend/zend_highlight.c +++ b/Zend/zend_highlight.c @@ -153,8 +153,6 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini efree(token.value.str.val); break; } - } else if (token_type == T_END_HEREDOC) { - efree(token.value.str.val); } token.type = 0; } @@ -188,7 +186,6 @@ ZEND_API void zend_strip(TSRMLS_D) case T_END_HEREDOC: zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); - efree(token.value.str.val); /* read the following character, either newline or ; */ if (lex_scan(&token TSRMLS_CC) != T_WHITESPACE) { zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); diff --git a/Zend/zend_ini_scanner.c b/Zend/zend_ini_scanner.c index 5f483de522472..35d9763bd9678 100644 --- a/Zend/zend_ini_scanner.c +++ b/Zend/zend_ini_scanner.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Fri Nov 16 18:24:06 2012 */ +/* Generated by re2c 0.13.5 */ #line 1 "Zend/zend_ini_scanner.l" /* +----------------------------------------------------------------------+ diff --git a/Zend/zend_ini_scanner_defs.h b/Zend/zend_ini_scanner_defs.h index 1fe4c0cd446f4..287d7bc1fbb9f 100644 --- a/Zend/zend_ini_scanner_defs.h +++ b/Zend/zend_ini_scanner_defs.h @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Fri Nov 16 18:24:06 2012 */ +/* Generated by re2c 0.13.5 */ #line 3 "Zend/zend_ini_scanner_defs.h" enum YYCONDTYPE { diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 1f5d73296fbb2..ccbc9b174c9d4 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -68,6 +68,8 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %token T_LOGICAL_AND "and (T_LOGICAL_AND)" %right T_PRINT %token T_PRINT "print (T_PRINT)" +%right T_YIELD +%token T_YIELD "yield (T_YIELD)" %left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL %token T_PLUS_EQUAL "+= (T_PLUS_EQUAL)" %token T_MINUS_EQUAL "-= (T_MINUS_EQUAL)" @@ -160,6 +162,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %token T_RETURN "return (T_RETURN)" %token T_TRY "try (T_TRY)" %token T_CATCH "catch (T_CATCH)" +%token T_FINALLY "finally (T_FINALLY)" %token T_THROW "throw (T_THROW)" %token T_USE "use (T_USE)" %token T_INSTEADOF "insteadof (T_INSTEADOF)" @@ -276,10 +279,10 @@ statement: unticked_statement: '{' inner_statement_list '}' - | T_IF '(' expr ')' { zend_do_if_cond(&$3, &$4 TSRMLS_CC); } statement { zend_do_if_after_statement(&$4, 1 TSRMLS_CC); } elseif_list else_single { zend_do_if_end(TSRMLS_C); } - | T_IF '(' expr ')' ':' { zend_do_if_cond(&$3, &$4 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$4, 1 TSRMLS_CC); } new_elseif_list new_else_single T_ENDIF ';' { zend_do_if_end(TSRMLS_C); } - | T_WHILE '(' { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' { zend_do_while_cond(&$4, &$5 TSRMLS_CC); } while_statement { zend_do_while_end(&$1, &$5 TSRMLS_CC); } - | T_DO { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); zend_do_do_while_begin(TSRMLS_C); } statement T_WHILE '(' { $5.u.op.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' ';' { zend_do_do_while_end(&$1, &$5, &$7 TSRMLS_CC); } + | T_IF parenthesis_expr { zend_do_if_cond(&$2, &$1 TSRMLS_CC); } statement { zend_do_if_after_statement(&$1, 1 TSRMLS_CC); } elseif_list else_single { zend_do_if_end(TSRMLS_C); } + | T_IF parenthesis_expr ':' { zend_do_if_cond(&$2, &$1 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$1, 1 TSRMLS_CC); } new_elseif_list new_else_single T_ENDIF ';' { zend_do_if_end(TSRMLS_C); } + | T_WHILE { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); } parenthesis_expr { zend_do_while_cond(&$3, &$$ TSRMLS_CC); } while_statement { zend_do_while_end(&$1, &$4 TSRMLS_CC); } + | T_DO { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); zend_do_do_while_begin(TSRMLS_C); } statement T_WHILE { $4.u.op.opline_num = get_next_op_number(CG(active_op_array)); } parenthesis_expr ';' { zend_do_do_while_end(&$1, &$4, &$6 TSRMLS_CC); } | T_FOR '(' for_expr @@ -289,7 +292,7 @@ unticked_statement: for_expr ')' { zend_do_free(&$9 TSRMLS_CC); zend_do_for_before_statement(&$4, &$7 TSRMLS_CC); } for_statement { zend_do_for_end(&$7 TSRMLS_CC); } - | T_SWITCH '(' expr ')' { zend_do_switch_cond(&$3 TSRMLS_CC); } switch_case_list { zend_do_switch_end(&$6 TSRMLS_CC); } + | T_SWITCH parenthesis_expr { zend_do_switch_cond(&$2 TSRMLS_CC); } switch_case_list { zend_do_switch_end(&$4 TSRMLS_CC); } | T_BREAK ';' { zend_do_brk_cont(ZEND_BRK, NULL TSRMLS_CC); } | T_BREAK expr ';' { zend_do_brk_cont(ZEND_BRK, &$2 TSRMLS_CC); } | T_CONTINUE ';' { zend_do_brk_cont(ZEND_CONT, NULL TSRMLS_CC); } @@ -297,6 +300,7 @@ unticked_statement: | T_RETURN ';' { zend_do_return(NULL, 0 TSRMLS_CC); } | T_RETURN expr_without_variable ';' { zend_do_return(&$2, 0 TSRMLS_CC); } | T_RETURN variable ';' { zend_do_return(&$2, 1 TSRMLS_CC); } + | yield_expr ';' { zend_do_free(&$1 TSRMLS_CC); } | T_GLOBAL global_var_list ';' | T_STATIC static_var_list ';' | T_ECHO echo_expr_list ';' @@ -309,20 +313,29 @@ unticked_statement: foreach_statement { zend_do_foreach_end(&$1, &$4 TSRMLS_CC); } | T_FOREACH '(' expr_without_variable T_AS { zend_do_foreach_begin(&$1, &$2, &$3, &$4, 0 TSRMLS_CC); } - variable foreach_optional_arg ')' { zend_check_writable_variable(&$6); zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); } + foreach_variable foreach_optional_arg ')' { zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); } foreach_statement { zend_do_foreach_end(&$1, &$4 TSRMLS_CC); } | T_DECLARE { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); zend_do_declare_begin(TSRMLS_C); } '(' declare_list ')' declare_statement { zend_do_declare_end(&$1 TSRMLS_CC); } | ';' /* empty statement */ | T_TRY { zend_do_try(&$1 TSRMLS_CC); } '{' inner_statement_list '}' - T_CATCH '(' { zend_initialize_try_catch_element(&$1 TSRMLS_CC); } - fully_qualified_class_name { zend_do_first_catch(&$7 TSRMLS_CC); } - T_VARIABLE ')' { zend_do_begin_catch(&$1, &$9, &$11, &$7 TSRMLS_CC); } - '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); } - additional_catches { zend_do_mark_last_catch(&$7, &$18 TSRMLS_CC); } + catch_statement { zend_do_bind_catch(&$1, &$6 TSRMLS_CC); } + finally_statement { zend_do_end_finally(&$1, &$6, &$8 TSRMLS_CC); } | T_THROW expr ';' { zend_do_throw(&$2 TSRMLS_CC); } | T_GOTO T_STRING ';' { zend_do_goto(&$2 TSRMLS_CC); } ; +catch_statement: + /* empty */ { $$.op_type = IS_UNUSED; } + | T_CATCH '(' { zend_initialize_try_catch_element(&$1 TSRMLS_CC); } + fully_qualified_class_name { zend_do_first_catch(&$2 TSRMLS_CC); } + T_VARIABLE ')' { zend_do_begin_catch(&$1, &$4, &$6, &$2 TSRMLS_CC); } + '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); } + additional_catches { zend_do_mark_last_catch(&$2, &$13 TSRMLS_CC); $$ = $1;} + +finally_statement: + /* empty */ { $$.op_type = IS_UNUSED; } + | T_FINALLY { zend_do_finally(&$1 TSRMLS_CC); } '{' inner_statement_list '}' { $$ = $1; } +; additional_catches: non_empty_additional_catches { $$ = $1; } @@ -334,12 +347,10 @@ non_empty_additional_catches: | non_empty_additional_catches additional_catch { $$ = $2; } ; - additional_catch: T_CATCH '(' fully_qualified_class_name { $$.u.op.opline_num = get_next_op_number(CG(active_op_array)); } T_VARIABLE ')' { zend_do_begin_catch(&$1, &$3, &$5, NULL TSRMLS_CC); } '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); } ; - unset_variables: unset_variable | unset_variables ',' unset_variable @@ -357,7 +368,6 @@ class_declaration_statement: unticked_class_declaration_statement { DO_TICKS(); } ; - is_reference: /* empty */ { $$.op_type = ZEND_RETURN_VAL; } | '&' { $$.op_type = ZEND_RETURN_REF; } @@ -366,7 +376,8 @@ is_reference: unticked_function_declaration_statement: function is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$3, 0, $2.op_type, NULL TSRMLS_CC); } - '(' parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); } + '(' parameter_list ')' + '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); } ; unticked_class_declaration_statement: @@ -421,10 +432,10 @@ foreach_optional_arg: | T_DOUBLE_ARROW foreach_variable { $$ = $2; } ; - foreach_variable: variable { zend_check_writable_variable(&$1); $$ = $1; } | '&' variable { zend_check_writable_variable(&$2); $$ = $2; $$.EA |= ZEND_PARSED_REFERENCE_VARIABLE; } + | T_LIST '(' { zend_do_list_init(TSRMLS_C); } assignment_list ')' { $$ = $1; $$.EA = ZEND_PARSED_LIST_EXPR; } ; for_statement: @@ -481,13 +492,13 @@ while_statement: elseif_list: /* empty */ - | elseif_list T_ELSEIF '(' expr ')' { zend_do_if_cond(&$4, &$5 TSRMLS_CC); } statement { zend_do_if_after_statement(&$5, 0 TSRMLS_CC); } + | elseif_list T_ELSEIF parenthesis_expr { zend_do_if_cond(&$3, &$2 TSRMLS_CC); } statement { zend_do_if_after_statement(&$2, 0 TSRMLS_CC); } ; new_elseif_list: /* empty */ - | new_elseif_list T_ELSEIF '(' expr ')' ':' { zend_do_if_cond(&$4, &$5 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$5, 0 TSRMLS_CC); } + | new_elseif_list T_ELSEIF parenthesis_expr ':' { zend_do_if_cond(&$3, &$2 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$2, 0 TSRMLS_CC); } ; @@ -530,8 +541,9 @@ optional_class_type: function_call_parameter_list: - non_empty_function_call_parameter_list { $$ = $1; } - | /* empty */ { Z_LVAL($$.u.constant) = 0; } + '(' ')' { Z_LVAL($$.u.constant) = 0; } + | '(' non_empty_function_call_parameter_list ')' { $$ = $2; } + | '(' yield_expr ')' { Z_LVAL($$.u.constant) = 1; zend_do_pass_param(&$2, ZEND_SEND_VAL, Z_LVAL($$.u.constant) TSRMLS_CC); } ; @@ -576,8 +588,9 @@ class_statement: variable_modifiers { CG(access_type) = Z_LVAL($1.u.constant); } class_variable_declaration ';' | class_constant_declaration ';' | trait_use_statement - | method_modifiers function is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$4, 1, $3.op_type, &$1 TSRMLS_CC); } '(' - parameter_list ')' method_body { zend_do_abstract_method(&$4, &$1, &$9 TSRMLS_CC); zend_do_end_function_declaration(&$2 TSRMLS_CC); } + | method_modifiers function is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$4, 1, $3.op_type, &$1 TSRMLS_CC); } + '(' parameter_list ')' + method_body { zend_do_abstract_method(&$4, &$1, &$9 TSRMLS_CC); zend_do_end_function_declaration(&$2 TSRMLS_CC); } ; trait_use_statement: @@ -770,7 +783,7 @@ expr_without_variable: | expr '>' expr { zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$3, &$1 TSRMLS_CC); } | expr T_IS_GREATER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$3, &$1 TSRMLS_CC); } | expr T_INSTANCEOF class_name_reference { zend_do_instanceof(&$$, &$1, &$3, 0 TSRMLS_CC); } - | '(' expr ')' { $$ = $2; } + | parenthesis_expr { $$ = $1; } | new_expr { $$ = $1; } | '(' new_expr ')' { $$ = $2; } instance_call { $$ = $5; } | expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); } @@ -789,16 +802,35 @@ expr_without_variable: | T_EXIT exit_expr { zend_do_exit(&$$, &$2 TSRMLS_CC); } | '@' { zend_do_begin_silence(&$1 TSRMLS_CC); } expr { zend_do_end_silence(&$1 TSRMLS_CC); $$ = $3; } | scalar { $$ = $1; } - | T_ARRAY '(' array_pair_list ')' { $$ = $3; } - | '[' array_pair_list ']' { $$ = $2; } + | combined_scalar_offset { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); } + | combined_scalar { $$ = $1; } | '`' backticks_expr '`' { zend_do_shell_exec(&$$, &$2 TSRMLS_CC); } | T_PRINT expr { zend_do_print(&$$, &$2 TSRMLS_CC); } - | function is_reference '(' { zend_do_begin_lambda_function_declaration(&$$, &$1, $2.op_type, 0 TSRMLS_CC); } - parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); $$ = $4; } - | T_STATIC function is_reference '(' { zend_do_begin_lambda_function_declaration(&$$, &$2, $3.op_type, 1 TSRMLS_CC); } - parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$2 TSRMLS_CC); $$ = $5; } + | T_YIELD { zend_do_yield(&$$, NULL, NULL, 0 TSRMLS_CC); } + | function is_reference { zend_do_begin_lambda_function_declaration(&$$, &$1, $2.op_type, 0 TSRMLS_CC); } + '(' parameter_list ')' lexical_vars + '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); $$ = $3; } + | T_STATIC function is_reference { zend_do_begin_lambda_function_declaration(&$$, &$2, $3.op_type, 1 TSRMLS_CC); } + '(' parameter_list ')' lexical_vars + '{' inner_statement_list '}' { zend_do_end_function_declaration(&$2 TSRMLS_CC); $$ = $4; } +; + +yield_expr: + T_YIELD expr_without_variable { zend_do_yield(&$$, &$2, NULL, 0 TSRMLS_CC); } + | T_YIELD variable { zend_do_yield(&$$, &$2, NULL, 1 TSRMLS_CC); } + | T_YIELD expr T_DOUBLE_ARROW expr_without_variable { zend_do_yield(&$$, &$4, &$2, 0 TSRMLS_CC); } + | T_YIELD expr T_DOUBLE_ARROW variable { zend_do_yield(&$$, &$4, &$2, 1 TSRMLS_CC); } ; +combined_scalar_offset: + combined_scalar '[' dim_offset ']' { zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); } + | combined_scalar_offset '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); } + | T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']' { $1.EA = 0; zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); } + +combined_scalar: + T_ARRAY '(' array_pair_list ')' { $$ = $3; } + | '[' array_pair_list ']' { $$ = $2; } + function: T_FUNCTION { $$.u.op.opline_num = CG(zend_lineno); } ; @@ -816,30 +848,22 @@ lexical_var_list: ; function_call: - namespace_name '(' { $2.u.op.opline_num = zend_do_begin_function_call(&$1, 1 TSRMLS_CC); } - function_call_parameter_list - ')' { zend_do_end_function_call(&$1, &$$, &$4, 0, $2.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); } - | T_NAMESPACE T_NS_SEPARATOR namespace_name '(' { $1.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$1.u.constant); zend_do_build_namespace_name(&$1, &$1, &$3 TSRMLS_CC); $4.u.op.opline_num = zend_do_begin_function_call(&$1, 0 TSRMLS_CC); } - function_call_parameter_list - ')' { zend_do_end_function_call(&$1, &$$, &$6, 0, $4.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); } - | T_NS_SEPARATOR namespace_name '(' { $3.u.op.opline_num = zend_do_begin_function_call(&$2, 0 TSRMLS_CC); } - function_call_parameter_list - ')' { zend_do_end_function_call(&$2, &$$, &$5, 0, $3.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); } - | class_name T_PAAMAYIM_NEKUDOTAYIM variable_name '(' { $4.u.op.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } - function_call_parameter_list - ')' { zend_do_end_function_call($4.u.op.opline_num?NULL:&$3, &$$, &$6, $4.u.op.opline_num, $4.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} - | class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(&$3, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } - function_call_parameter_list - ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} - | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name '(' { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } - function_call_parameter_list - ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} - | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(&$3, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } - function_call_parameter_list - ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} - | variable_without_objects '(' { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_dynamic_function_call(&$1, 0 TSRMLS_CC); } - function_call_parameter_list ')' - { zend_do_end_function_call(&$1, &$$, &$4, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} + namespace_name { $$.u.op.opline_num = zend_do_begin_function_call(&$1, 1 TSRMLS_CC); } + function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$3, 0, $2.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); } + | T_NAMESPACE T_NS_SEPARATOR namespace_name { $1.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$1.u.constant); zend_do_build_namespace_name(&$1, &$1, &$3 TSRMLS_CC); $$.u.op.opline_num = zend_do_begin_function_call(&$1, 0 TSRMLS_CC); } + function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$5, 0, $4.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); } + | T_NS_SEPARATOR namespace_name { $$.u.op.opline_num = zend_do_begin_function_call(&$2, 0 TSRMLS_CC); } + function_call_parameter_list { zend_do_end_function_call(&$2, &$$, &$4, 0, $3.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); } + | class_name T_PAAMAYIM_NEKUDOTAYIM variable_name { $$.u.op.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } + function_call_parameter_list { zend_do_end_function_call($4.u.op.opline_num?NULL:&$3, &$$, &$5, $4.u.op.opline_num, $4.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} + | class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { zend_do_end_variable_parse(&$3, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } + function_call_parameter_list { zend_do_end_function_call(NULL, &$$, &$5, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } + function_call_parameter_list { zend_do_end_function_call(NULL, &$$, &$5, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { zend_do_end_variable_parse(&$3, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } + function_call_parameter_list { zend_do_end_function_call(NULL, &$$, &$5, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} + | variable_without_objects { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_dynamic_function_call(&$1, 0 TSRMLS_CC); } + function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$3, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} ; class_name: @@ -884,7 +908,7 @@ dynamic_class_name_variable_property: exit_expr: /* empty */ { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; } | '(' ')' { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; } - | '(' expr ')' { $$ = $2; } + | parenthesis_expr { $$ = $1; } ; backticks_expr: @@ -895,8 +919,8 @@ backticks_expr: ctor_arguments: - /* empty */ { Z_LVAL($$.u.constant)=0; } - | '(' function_call_parameter_list ')' { $$ = $2; } + /* empty */ { Z_LVAL($$.u.constant) = 0; } + | function_call_parameter_list { $$ = $1; } ; @@ -911,13 +935,14 @@ common_scalar: | T_METHOD_C { $$ = $1; } | T_FUNC_C { $$ = $1; } | T_NS_C { $$ = $1; } - | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC { $$ = $2; CG(heredoc) = Z_STRVAL($1.u.constant); CG(heredoc_len) = Z_STRLEN($1.u.constant); } - | T_START_HEREDOC T_END_HEREDOC { ZVAL_EMPTY_STRING(&$$.u.constant); INIT_PZVAL(&$$.u.constant); $$.op_type = IS_CONST; CG(heredoc) = Z_STRVAL($1.u.constant); CG(heredoc_len) = Z_STRLEN($1.u.constant); } + | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC { $$ = $2; } + | T_START_HEREDOC T_END_HEREDOC { ZVAL_EMPTY_STRING(&$$.u.constant); INIT_PZVAL(&$$.u.constant); $$.op_type = IS_CONST; } ; static_scalar: /* compile-time evaluated scalars */ common_scalar { $$ = $1; } + | static_class_name_scalar { $$ = $1; } | namespace_name { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_CT, 1 TSRMLS_CC); } | T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); $3 = $$; zend_do_fetch_constant(&$$, NULL, &$3, ZEND_CT, 0 TSRMLS_CC); } | T_NS_SEPARATOR namespace_name { char *tmp = estrndup(Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); memcpy(&(tmp[1]), Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); tmp[0] = '\\'; efree(Z_STRVAL($2.u.constant)); Z_STRVAL($2.u.constant) = tmp; ++Z_STRLEN($2.u.constant); zend_do_fetch_constant(&$$, NULL, &$2, ZEND_CT, 0 TSRMLS_CC); } @@ -935,13 +960,14 @@ static_class_constant: scalar: T_STRING_VARNAME { $$ = $1; } + | class_name_scalar { $$ = $1; } | class_constant { $$ = $1; } | namespace_name { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC); } | T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); $3 = $$; zend_do_fetch_constant(&$$, NULL, &$3, ZEND_RT, 0 TSRMLS_CC); } | T_NS_SEPARATOR namespace_name { char *tmp = estrndup(Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); memcpy(&(tmp[1]), Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); tmp[0] = '\\'; efree(Z_STRVAL($2.u.constant)); Z_STRVAL($2.u.constant) = tmp; ++Z_STRLEN($2.u.constant); zend_do_fetch_constant(&$$, NULL, &$2, ZEND_RT, 0 TSRMLS_CC); } | common_scalar { $$ = $1; } | '"' encaps_list '"' { $$ = $2; } - | T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; CG(heredoc) = Z_STRVAL($1.u.constant); CG(heredoc_len) = Z_STRLEN($1.u.constant); } + | T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; } | T_CLASS_C { if (Z_TYPE($1.u.constant) == IS_CONSTANT) {zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC);} else {$$ = $1;} } ; @@ -968,6 +994,11 @@ expr: | expr_without_variable { $$ = $1; } ; +parenthesis_expr: + '(' expr ')' { $$ = $2; } + | '(' yield_expr ')' { $$ = $2; } +; + r_variable: variable { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); $$ = $1; } @@ -1007,9 +1038,8 @@ array_method_dereference: ; method: - '(' { zend_do_pop_object(&$1 TSRMLS_CC); zend_do_begin_method_call(&$1 TSRMLS_CC); } - function_call_parameter_list ')' - { zend_do_end_function_call(&$1, &$$, &$3, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); } + { zend_do_pop_object(&$$ TSRMLS_CC); zend_do_begin_method_call(&$$ TSRMLS_CC); } + function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$2, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); } ; method_or_not: @@ -1149,6 +1179,7 @@ encaps_var_offset: internal_functions_in_yacc: T_ISSET '(' isset_variables ')' { $$ = $3; } | T_EMPTY '(' variable ')' { zend_do_isset_or_isempty(ZEND_ISEMPTY, &$$, &$3 TSRMLS_CC); } + | T_EMPTY '(' expr_without_variable ')' { zend_do_unary_op(ZEND_BOOL_NOT, &$$, &$3 TSRMLS_CC); } | T_INCLUDE expr { zend_do_include_or_eval(ZEND_INCLUDE, &$$, &$2 TSRMLS_CC); } | T_INCLUDE_ONCE expr { zend_do_include_or_eval(ZEND_INCLUDE_ONCE, &$$, &$2 TSRMLS_CC); } | T_EVAL '(' expr ')' { zend_do_include_or_eval(ZEND_EVAL, &$$, &$3 TSRMLS_CC); } @@ -1157,8 +1188,13 @@ internal_functions_in_yacc: ; isset_variables: - variable { zend_do_isset_or_isempty(ZEND_ISSET, &$$, &$1 TSRMLS_CC); } - | isset_variables ',' { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } variable { znode tmp; zend_do_isset_or_isempty(ZEND_ISSET, &tmp, &$4 TSRMLS_CC); zend_do_boolean_and_end(&$$, &$1, &tmp, &$2 TSRMLS_CC); } + isset_variable { $$ = $1; } + | isset_variables ',' { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } isset_variable { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 TSRMLS_CC); } +; + +isset_variable: + variable { zend_do_isset_or_isempty(ZEND_ISSET, &$$, &$1 TSRMLS_CC); } + | expr_without_variable { zend_error(E_COMPILE_ERROR, "Cannot use isset() on the result of an expression (you can use \"null !== expression\" instead)"); } ; class_constant: @@ -1166,6 +1202,14 @@ class_constant: | variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_RT, 0 TSRMLS_CC); } ; +static_class_name_scalar: + class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS { zend_do_resolve_class_name(&$$, &$1, 1 TSRMLS_CC); } +; + +class_name_scalar: + class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS { zend_do_resolve_class_name(&$$, &$1, 0 TSRMLS_CC); } +; + %% /* Copy to YYRES the contents of YYSTR after stripping away unnecessary diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c index 40fb5745597d0..f2ba6bf9d4d51 100644 --- a/Zend/zend_language_scanner.c +++ b/Zend/zend_language_scanner.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Wed Nov 14 17:46:56 2012 */ +/* Generated by re2c 0.13.5 */ #line 1 "Zend/zend_language_scanner.l" /* +----------------------------------------------------------------------+ @@ -180,22 +180,23 @@ static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC) void startup_scanner(TSRMLS_D) { CG(parse_error) = 0; - CG(heredoc) = NULL; - CG(heredoc_len) = 0; CG(doc_comment) = NULL; CG(doc_comment_len) = 0; zend_stack_init(&SCNG(state_stack)); + zend_ptr_stack_init(&SCNG(heredoc_label_stack)); +} + +static void heredoc_label_dtor(zend_heredoc_label *heredoc_label) { + efree(heredoc_label->label); } void shutdown_scanner(TSRMLS_D) { - if (CG(heredoc)) { - efree(CG(heredoc)); - CG(heredoc_len)=0; - } CG(parse_error) = 0; - zend_stack_destroy(&SCNG(state_stack)); RESET_DOC_COMMENT(); + zend_stack_destroy(&SCNG(state_stack)); + zend_ptr_stack_clean(&SCNG(heredoc_label_stack), (void (*)(void *)) &heredoc_label_dtor, 1); + zend_ptr_stack_destroy(&SCNG(heredoc_label_stack)); } ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC) @@ -210,6 +211,9 @@ ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC) lex_state->state_stack = SCNG(state_stack); zend_stack_init(&SCNG(state_stack)); + lex_state->heredoc_label_stack = SCNG(heredoc_label_stack); + zend_ptr_stack_init(&SCNG(heredoc_label_stack)); + lex_state->in = SCNG(yy_in); lex_state->yy_state = YYSTATE; lex_state->filename = zend_get_compiled_filename(TSRMLS_C); @@ -236,6 +240,10 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC) zend_stack_destroy(&SCNG(state_stack)); SCNG(state_stack) = lex_state->state_stack; + zend_ptr_stack_clean(&SCNG(heredoc_label_stack), (void (*)(void *)) &heredoc_label_dtor, 1); + zend_ptr_stack_destroy(&SCNG(heredoc_label_stack)); + SCNG(heredoc_label_stack) = lex_state->heredoc_label_stack; + SCNG(yy_in) = lex_state->in; YYSETCONDITION(lex_state->yy_state); CG(zend_lineno) = lex_state->lineno; @@ -252,12 +260,6 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC) SCNG(input_filter) = lex_state->input_filter; SCNG(output_filter) = lex_state->output_filter; SCNG(script_encoding) = lex_state->script_encoding; - - if (CG(heredoc)) { - efree(CG(heredoc)); - CG(heredoc) = NULL; - CG(heredoc_len) = 0; - } } ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC) @@ -1000,7 +1002,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) yymore_restart: -#line 1004 "Zend/zend_language_scanner.c" +#line 1006 "Zend/zend_language_scanner.c" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -1099,7 +1101,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) yy3: YYDEBUG(3, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1792 "Zend/zend_language_scanner.l" +#line 1803 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -1159,7 +1161,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) HANDLE_NEWLINES(yytext, yyleng); return T_INLINE_HTML; } -#line 1163 "Zend/zend_language_scanner.c" +#line 1165 "Zend/zend_language_scanner.c" yy4: YYDEBUG(4, *YYCURSOR); yych = *++YYCURSOR; @@ -1177,7 +1179,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) yy6: YYDEBUG(6, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1780 "Zend/zend_language_scanner.l" +#line 1791 "Zend/zend_language_scanner.l" { if (CG(short_tags)) { zendlval->value.str.val = yytext; /* no copying - intentional */ @@ -1189,14 +1191,14 @@ int lex_scan(zval *zendlval TSRMLS_DC) goto inline_char_handler; } } -#line 1193 "Zend/zend_language_scanner.c" +#line 1195 "Zend/zend_language_scanner.c" yy7: YYDEBUG(7, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) == '=') goto yy43; YYDEBUG(8, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1757 "Zend/zend_language_scanner.l" +#line 1768 "Zend/zend_language_scanner.l" { if (CG(asp_tags)) { zendlval->value.str.val = yytext; /* no copying - intentional */ @@ -1208,7 +1210,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) goto inline_char_handler; } } -#line 1212 "Zend/zend_language_scanner.c" +#line 1214 "Zend/zend_language_scanner.c" yy9: YYDEBUG(9, *YYCURSOR); yych = *++YYCURSOR; @@ -1394,7 +1396,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(38, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1717 "Zend/zend_language_scanner.l" +#line 1728 "Zend/zend_language_scanner.l" { YYCTYPE *bracket = (YYCTYPE*)zend_memrchr(yytext, '<', yyleng - (sizeof("script language=php>") - 1)); @@ -1411,7 +1413,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) BEGIN(ST_IN_SCRIPTING); return T_OPEN_TAG; } -#line 1415 "Zend/zend_language_scanner.c" +#line 1417 "Zend/zend_language_scanner.c" yy39: YYDEBUG(39, *YYCURSOR); yych = *++YYCURSOR; @@ -1438,7 +1440,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(44, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1735 "Zend/zend_language_scanner.l" +#line 1746 "Zend/zend_language_scanner.l" { if (CG(asp_tags)) { zendlval->value.str.val = yytext; /* no copying - intentional */ @@ -1450,13 +1452,13 @@ int lex_scan(zval *zendlval TSRMLS_DC) goto inline_char_handler; } } -#line 1454 "Zend/zend_language_scanner.c" +#line 1456 "Zend/zend_language_scanner.c" yy45: YYDEBUG(45, *YYCURSOR); ++YYCURSOR; YYDEBUG(46, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1748 "Zend/zend_language_scanner.l" +#line 1759 "Zend/zend_language_scanner.l" { zendlval->value.str.val = yytext; /* no copying - intentional */ zendlval->value.str.len = yyleng; @@ -1464,7 +1466,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) BEGIN(ST_IN_SCRIPTING); return T_OPEN_TAG_WITH_ECHO; } -#line 1468 "Zend/zend_language_scanner.c" +#line 1470 "Zend/zend_language_scanner.c" yy47: YYDEBUG(47, *YYCURSOR); yych = *++YYCURSOR; @@ -1491,7 +1493,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) yy51: YYDEBUG(51, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1770 "Zend/zend_language_scanner.l" +#line 1781 "Zend/zend_language_scanner.l" { zendlval->value.str.val = yytext; /* no copying - intentional */ zendlval->value.str.len = yyleng; @@ -1500,7 +1502,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) BEGIN(ST_IN_SCRIPTING); return T_OPEN_TAG; } -#line 1504 "Zend/zend_language_scanner.c" +#line 1506 "Zend/zend_language_scanner.c" yy52: YYDEBUG(52, *YYCURSOR); ++YYCURSOR; @@ -1571,7 +1573,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) yy56: YYDEBUG(56, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2243 "Zend/zend_language_scanner.l" +#line 2254 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -1612,7 +1614,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) zend_scan_escape_string(zendlval, yytext, yyleng, '`' TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } -#line 1616 "Zend/zend_language_scanner.c" +#line 1618 "Zend/zend_language_scanner.c" yy57: YYDEBUG(57, *YYCURSOR); yych = *++YYCURSOR; @@ -1623,12 +1625,12 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(59, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2187 "Zend/zend_language_scanner.l" +#line 2198 "Zend/zend_language_scanner.l" { BEGIN(ST_IN_SCRIPTING); return '`'; } -#line 1632 "Zend/zend_language_scanner.c" +#line 1634 "Zend/zend_language_scanner.c" yy60: YYDEBUG(60, *YYCURSOR); yych = *++YYCURSOR; @@ -1638,14 +1640,14 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(62, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2174 "Zend/zend_language_scanner.l" +#line 2185 "Zend/zend_language_scanner.l" { zendlval->value.lval = (long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; } -#line 1649 "Zend/zend_language_scanner.c" +#line 1651 "Zend/zend_language_scanner.c" yy63: YYDEBUG(63, *YYCURSOR); yyaccept = 0; @@ -1661,24 +1663,24 @@ int lex_scan(zval *zendlval TSRMLS_DC) yy65: YYDEBUG(65, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1874 "Zend/zend_language_scanner.l" +#line 1885 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1671 "Zend/zend_language_scanner.c" +#line 1673 "Zend/zend_language_scanner.c" yy66: YYDEBUG(66, *YYCURSOR); ++YYCURSOR; YYDEBUG(67, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1451 "Zend/zend_language_scanner.l" +#line 1461 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); return T_DOLLAR_OPEN_CURLY_BRACES; } -#line 1682 "Zend/zend_language_scanner.c" +#line 1684 "Zend/zend_language_scanner.c" yy68: YYDEBUG(68, *YYCURSOR); yych = *++YYCURSOR; @@ -1692,7 +1694,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(71, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1866 "Zend/zend_language_scanner.l" +#line 1877 "Zend/zend_language_scanner.l" { yyless(yyleng - 1); yy_push_state(ST_VAR_OFFSET TSRMLS_CC); @@ -1700,7 +1702,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1704 "Zend/zend_language_scanner.c" +#line 1706 "Zend/zend_language_scanner.c" yy72: YYDEBUG(72, *YYCURSOR); yych = *++YYCURSOR; @@ -1718,7 +1720,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(74, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1856 "Zend/zend_language_scanner.l" +#line 1867 "Zend/zend_language_scanner.l" { yyless(yyleng - 3); yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); @@ -1726,7 +1728,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1730 "Zend/zend_language_scanner.c" +#line 1732 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_DOUBLE_QUOTES: @@ -1794,7 +1796,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) yy78: YYDEBUG(78, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2193 "Zend/zend_language_scanner.l" +#line 2204 "Zend/zend_language_scanner.l" { if (GET_DOUBLE_QUOTES_SCANNED_LENGTH()) { YYCURSOR += GET_DOUBLE_QUOTES_SCANNED_LENGTH() - 1; @@ -1843,7 +1845,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) zend_scan_escape_string(zendlval, yytext, yyleng, '"' TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } -#line 1847 "Zend/zend_language_scanner.c" +#line 1849 "Zend/zend_language_scanner.c" yy79: YYDEBUG(79, *YYCURSOR); yych = *++YYCURSOR; @@ -1854,12 +1856,12 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(81, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2182 "Zend/zend_language_scanner.l" +#line 2193 "Zend/zend_language_scanner.l" { BEGIN(ST_IN_SCRIPTING); return '"'; } -#line 1863 "Zend/zend_language_scanner.c" +#line 1865 "Zend/zend_language_scanner.c" yy82: YYDEBUG(82, *YYCURSOR); yych = *++YYCURSOR; @@ -1869,14 +1871,14 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(84, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2174 "Zend/zend_language_scanner.l" +#line 2185 "Zend/zend_language_scanner.l" { zendlval->value.lval = (long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; } -#line 1880 "Zend/zend_language_scanner.c" +#line 1882 "Zend/zend_language_scanner.c" yy85: YYDEBUG(85, *YYCURSOR); yyaccept = 0; @@ -1892,24 +1894,24 @@ int lex_scan(zval *zendlval TSRMLS_DC) yy87: YYDEBUG(87, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1874 "Zend/zend_language_scanner.l" +#line 1885 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1902 "Zend/zend_language_scanner.c" +#line 1904 "Zend/zend_language_scanner.c" yy88: YYDEBUG(88, *YYCURSOR); ++YYCURSOR; YYDEBUG(89, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1451 "Zend/zend_language_scanner.l" +#line 1461 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); return T_DOLLAR_OPEN_CURLY_BRACES; } -#line 1913 "Zend/zend_language_scanner.c" +#line 1915 "Zend/zend_language_scanner.c" yy90: YYDEBUG(90, *YYCURSOR); yych = *++YYCURSOR; @@ -1923,7 +1925,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(93, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1866 "Zend/zend_language_scanner.l" +#line 1877 "Zend/zend_language_scanner.l" { yyless(yyleng - 1); yy_push_state(ST_VAR_OFFSET TSRMLS_CC); @@ -1931,7 +1933,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1935 "Zend/zend_language_scanner.c" +#line 1937 "Zend/zend_language_scanner.c" yy94: YYDEBUG(94, *YYCURSOR); yych = *++YYCURSOR; @@ -1949,7 +1951,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(96, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1856 "Zend/zend_language_scanner.l" +#line 1867 "Zend/zend_language_scanner.l" { yyless(yyleng - 3); yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); @@ -1957,7 +1959,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1961 "Zend/zend_language_scanner.c" +#line 1963 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_END_HEREDOC: @@ -1968,19 +1970,20 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(100, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2161 "Zend/zend_language_scanner.l" +#line 2171 "Zend/zend_language_scanner.l" { - YYCURSOR += CG(heredoc_len) - 1; - yyleng = CG(heredoc_len); + zend_heredoc_label *heredoc_label = zend_ptr_stack_pop(&SCNG(heredoc_label_stack)); + + YYCURSOR += heredoc_label->length - 1; + yyleng = heredoc_label->length; + + heredoc_label_dtor(heredoc_label); + efree(heredoc_label); - Z_STRVAL_P(zendlval) = CG(heredoc); - Z_STRLEN_P(zendlval) = CG(heredoc_len); - CG(heredoc) = NULL; - CG(heredoc_len) = 0; BEGIN(ST_IN_SCRIPTING); return T_END_HEREDOC; } -#line 1984 "Zend/zend_language_scanner.c" +#line 1987 "Zend/zend_language_scanner.c" /* *********************************** */ yyc_ST_HEREDOC: { @@ -2042,10 +2045,12 @@ int lex_scan(zval *zendlval TSRMLS_DC) yy104: YYDEBUG(104, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2285 "Zend/zend_language_scanner.l" +#line 2296 "Zend/zend_language_scanner.l" { int newline = 0; + zend_heredoc_label *heredoc_label = zend_ptr_stack_top(&SCNG(heredoc_label_stack)); + if (YYCURSOR > YYLIMIT) { return 0; } @@ -2061,8 +2066,8 @@ int lex_scan(zval *zendlval TSRMLS_DC) /* fall through */ case '\n': /* Check for ending label on the next line */ - if (IS_LABEL_START(*YYCURSOR) && CG(heredoc_len) < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, CG(heredoc), CG(heredoc_len))) { - YYCTYPE *end = YYCURSOR + CG(heredoc_len); + if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) { + YYCTYPE *end = YYCURSOR + heredoc_label->length; if (*end == ';') { end++; @@ -2113,7 +2118,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0 TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } -#line 2117 "Zend/zend_language_scanner.c" +#line 2122 "Zend/zend_language_scanner.c" yy105: YYDEBUG(105, *YYCURSOR); yych = *++YYCURSOR; @@ -2128,14 +2133,14 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(108, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2174 "Zend/zend_language_scanner.l" +#line 2185 "Zend/zend_language_scanner.l" { zendlval->value.lval = (long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; } -#line 2139 "Zend/zend_language_scanner.c" +#line 2144 "Zend/zend_language_scanner.c" yy109: YYDEBUG(109, *YYCURSOR); yyaccept = 0; @@ -2151,24 +2156,24 @@ int lex_scan(zval *zendlval TSRMLS_DC) yy111: YYDEBUG(111, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1874 "Zend/zend_language_scanner.l" +#line 1885 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zendlval->type = IS_STRING; return T_VARIABLE; } -#line 2161 "Zend/zend_language_scanner.c" +#line 2166 "Zend/zend_language_scanner.c" yy112: YYDEBUG(112, *YYCURSOR); ++YYCURSOR; YYDEBUG(113, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1451 "Zend/zend_language_scanner.l" +#line 1461 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); return T_DOLLAR_OPEN_CURLY_BRACES; } -#line 2172 "Zend/zend_language_scanner.c" +#line 2177 "Zend/zend_language_scanner.c" yy114: YYDEBUG(114, *YYCURSOR); yych = *++YYCURSOR; @@ -2182,7 +2187,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(117, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1866 "Zend/zend_language_scanner.l" +#line 1877 "Zend/zend_language_scanner.l" { yyless(yyleng - 1); yy_push_state(ST_VAR_OFFSET TSRMLS_CC); @@ -2190,7 +2195,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) zendlval->type = IS_STRING; return T_VARIABLE; } -#line 2194 "Zend/zend_language_scanner.c" +#line 2199 "Zend/zend_language_scanner.c" yy118: YYDEBUG(118, *YYCURSOR); yych = *++YYCURSOR; @@ -2208,7 +2213,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) ++YYCURSOR; YYDEBUG(120, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1856 "Zend/zend_language_scanner.l" +#line 1867 "Zend/zend_language_scanner.l" { yyless(yyleng - 3); yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); @@ -2216,7 +2221,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) zendlval->type = IS_STRING; return T_VARIABLE; } -#line 2220 "Zend/zend_language_scanner.c" +#line 2225 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_IN_SCRIPTING: @@ -2288,32 +2293,32 @@ int lex_scan(zval *zendlval TSRMLS_DC) case 0x1C: case 0x1D: case 0x1E: - case 0x1F: goto yy183; + case 0x1F: goto yy184; case '\t': case '\n': case '\r': - case ' ': goto yy139; - case '!': goto yy152; - case '"': goto yy179; - case '#': goto yy175; - case '$': goto yy164; - case '%': goto yy158; - case '&': goto yy159; - case '\'': goto yy177; - case '(': goto yy146; + case ' ': goto yy140; + case '!': goto yy153; + case '"': goto yy180; + case '#': goto yy176; + case '$': goto yy165; + case '%': goto yy159; + case '&': goto yy160; + case '\'': goto yy178; + case '(': goto yy147; case ')': case ',': case ';': case '@': case '[': case ']': - case '~': goto yy165; - case '*': goto yy155; - case '+': goto yy151; - case '-': goto yy137; - case '.': goto yy157; - case '/': goto yy156; - case '0': goto yy171; + case '~': goto yy166; + case '*': goto yy156; + case '+': goto yy152; + case '-': goto yy138; + case '.': goto yy158; + case '/': goto yy157; + case '0': goto yy172; case '1': case '2': case '3': @@ -2322,16 +2327,16 @@ int lex_scan(zval *zendlval TSRMLS_DC) case '6': case '7': case '8': - case '9': goto yy173; - case ':': goto yy141; - case '<': goto yy153; - case '=': goto yy149; - case '>': goto yy154; - case '?': goto yy166; + case '9': goto yy174; + case ':': goto yy142; + case '<': goto yy154; + case '=': goto yy150; + case '>': goto yy155; + case '?': goto yy167; case 'A': - case 'a': goto yy132; + case 'a': goto yy133; case 'B': - case 'b': goto yy134; + case 'b': goto yy135; case 'C': case 'c': goto yy127; case 'D': @@ -2341,39 +2346,41 @@ int lex_scan(zval *zendlval TSRMLS_DC) case 'F': case 'f': goto yy126; case 'G': - case 'g': goto yy135; + case 'g': goto yy136; case 'I': - case 'i': goto yy130; + case 'i': goto yy131; case 'L': - case 'l': goto yy150; + case 'l': goto yy151; case 'N': - case 'n': goto yy144; + case 'n': goto yy145; case 'O': - case 'o': goto yy162; + case 'o': goto yy163; case 'P': - case 'p': goto yy136; + case 'p': goto yy137; case 'R': case 'r': goto yy128; case 'S': - case 's': goto yy133; + case 's': goto yy134; case 'T': - case 't': goto yy129; + case 't': goto yy130; case 'U': - case 'u': goto yy147; + case 'u': goto yy148; case 'V': - case 'v': goto yy145; + case 'v': goto yy146; case 'W': - case 'w': goto yy131; + case 'w': goto yy132; case 'X': - case 'x': goto yy163; - case '\\': goto yy142; - case '^': goto yy161; - case '_': goto yy148; - case '`': goto yy181; - case '{': goto yy167; - case '|': goto yy160; - case '}': goto yy169; - default: goto yy174; + case 'x': goto yy164; + case 'Y': + case 'y': goto yy129; + case '\\': goto yy143; + case '^': goto yy162; + case '_': goto yy149; + case '`': goto yy182; + case '{': goto yy168; + case '|': goto yy161; + case '}': goto yy170; + default: goto yy175; } yy123: YYDEBUG(123, *YYCURSOR); @@ -2381,49 +2388,49 @@ int lex_scan(zval *zendlval TSRMLS_DC) YYDEBUG(-1, yych); switch ((yych = *YYCURSOR)) { case 'C': - case 'c': goto yy726; + case 'c': goto yy735; case 'L': - case 'l': goto yy727; + case 'l': goto yy736; case 'M': - case 'm': goto yy728; + case 'm': goto yy737; case 'N': - case 'n': goto yy729; + case 'n': goto yy738; case 'V': - case 'v': goto yy730; + case 'v': goto yy739; case 'X': - case 'x': goto yy731; - default: goto yy186; + case 'x': goto yy740; + default: goto yy187; } yy124: YYDEBUG(124, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1897 "Zend/zend_language_scanner.l" +#line 1908 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, yytext, yyleng); zendlval->type = IS_STRING; return T_STRING; } -#line 2407 "Zend/zend_language_scanner.c" +#line 2414 "Zend/zend_language_scanner.c" yy125: YYDEBUG(125, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'O') { if (yych <= 'H') { - if (yych == 'E') goto yy708; - goto yy186; + if (yych == 'E') goto yy717; + goto yy187; } else { - if (yych <= 'I') goto yy709; - if (yych <= 'N') goto yy186; - goto yy710; + if (yych <= 'I') goto yy718; + if (yych <= 'N') goto yy187; + goto yy719; } } else { if (yych <= 'h') { - if (yych == 'e') goto yy708; - goto yy186; + if (yych == 'e') goto yy717; + goto yy187; } else { - if (yych <= 'i') goto yy709; - if (yych == 'o') goto yy710; - goto yy186; + if (yych <= 'i') goto yy718; + if (yych == 'o') goto yy719; + goto yy187; } } yy126: @@ -2431,21 +2438,21 @@ int lex_scan(zval *zendlval TSRMLS_DC) yych = *++YYCURSOR; if (yych <= 'U') { if (yych <= 'N') { - if (yych == 'I') goto yy687; - goto yy186; + if (yych == 'I') goto yy693; + goto yy187; } else { - if (yych <= 'O') goto yy688; - if (yych <= 'T') goto yy186; - goto yy689; + if (yych <= 'O') goto yy694; + if (yych <= 'T') goto yy187; + goto yy695; } } else { if (yych <= 'n') { - if (yych == 'i') goto yy687; - goto yy186; + if (yych == 'i') goto yy693; + goto yy187; } else { - if (yych <= 'o') goto yy688; - if (yych == 'u') goto yy689; - goto yy186; + if (yych <= 'o') goto yy694; + if (yych == 'u') goto yy695; + goto yy187; } } yy127: @@ -2453,196 +2460,202 @@ int lex_scan(zval *zendlval TSRMLS_DC) yych = *++YYCURSOR; if (yych <= 'O') { if (yych <= 'K') { - if (yych == 'A') goto yy652; - goto yy186; + if (yych == 'A') goto yy658; + goto yy187; } else { - if (yych <= 'L') goto yy653; - if (yych <= 'N') goto yy186; - goto yy654; + if (yych <= 'L') goto yy659; + if (yych <= 'N') goto yy187; + goto yy660; } } else { if (yych <= 'k') { - if (yych == 'a') goto yy652; - goto yy186; + if (yych == 'a') goto yy658; + goto yy187; } else { - if (yych <= 'l') goto yy653; - if (yych == 'o') goto yy654; - goto yy186; + if (yych <= 'l') goto yy659; + if (yych == 'o') goto yy660; + goto yy187; } } yy128: YYDEBUG(128, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy634; - if (yych == 'e') goto yy634; - goto yy186; + if (yych == 'E') goto yy640; + if (yych == 'e') goto yy640; + goto yy187; yy129: YYDEBUG(129, *YYCURSOR); yych = *++YYCURSOR; + if (yych == 'I') goto yy635; + if (yych == 'i') goto yy635; + goto yy187; +yy130: + YYDEBUG(130, *YYCURSOR); + yych = *++YYCURSOR; if (yych <= 'R') { - if (yych == 'H') goto yy622; - if (yych <= 'Q') goto yy186; - goto yy623; + if (yych == 'H') goto yy623; + if (yych <= 'Q') goto yy187; + goto yy624; } else { if (yych <= 'h') { - if (yych <= 'g') goto yy186; - goto yy622; + if (yych <= 'g') goto yy187; + goto yy623; } else { - if (yych == 'r') goto yy623; - goto yy186; + if (yych == 'r') goto yy624; + goto yy187; } } -yy130: - YYDEBUG(130, *YYCURSOR); +yy131: + YYDEBUG(131, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'S') { if (yych <= 'L') { - if (yych == 'F') goto yy569; - goto yy186; + if (yych == 'F') goto yy570; + goto yy187; } else { - if (yych <= 'M') goto yy571; - if (yych <= 'N') goto yy572; - if (yych <= 'R') goto yy186; - goto yy573; + if (yych <= 'M') goto yy572; + if (yych <= 'N') goto yy573; + if (yych <= 'R') goto yy187; + goto yy574; } } else { if (yych <= 'm') { - if (yych == 'f') goto yy569; - if (yych <= 'l') goto yy186; - goto yy571; + if (yych == 'f') goto yy570; + if (yych <= 'l') goto yy187; + goto yy572; } else { - if (yych <= 'n') goto yy572; - if (yych == 's') goto yy573; - goto yy186; + if (yych <= 'n') goto yy573; + if (yych == 's') goto yy574; + goto yy187; } } -yy131: - YYDEBUG(131, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'H') goto yy564; - if (yych == 'h') goto yy564; - goto yy186; yy132: YYDEBUG(132, *YYCURSOR); yych = *++YYCURSOR; + if (yych == 'H') goto yy565; + if (yych == 'h') goto yy565; + goto yy187; +yy133: + YYDEBUG(133, *YYCURSOR); + yych = *++YYCURSOR; if (yych <= 'S') { if (yych <= 'M') { - if (yych == 'B') goto yy546; - goto yy186; + if (yych == 'B') goto yy547; + goto yy187; } else { - if (yych <= 'N') goto yy547; - if (yych <= 'Q') goto yy186; - if (yych <= 'R') goto yy548; - goto yy549; + if (yych <= 'N') goto yy548; + if (yych <= 'Q') goto yy187; + if (yych <= 'R') goto yy549; + goto yy550; } } else { if (yych <= 'n') { - if (yych == 'b') goto yy546; - if (yych <= 'm') goto yy186; - goto yy547; + if (yych == 'b') goto yy547; + if (yych <= 'm') goto yy187; + goto yy548; } else { - if (yych <= 'q') goto yy186; - if (yych <= 'r') goto yy548; - if (yych <= 's') goto yy549; - goto yy186; + if (yych <= 'q') goto yy187; + if (yych <= 'r') goto yy549; + if (yych <= 's') goto yy550; + goto yy187; } } -yy133: - YYDEBUG(133, *YYCURSOR); +yy134: + YYDEBUG(134, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'W') { - if (yych == 'T') goto yy534; - if (yych <= 'V') goto yy186; - goto yy535; + if (yych == 'T') goto yy535; + if (yych <= 'V') goto yy187; + goto yy536; } else { if (yych <= 't') { - if (yych <= 's') goto yy186; - goto yy534; + if (yych <= 's') goto yy187; + goto yy535; } else { - if (yych == 'w') goto yy535; - goto yy186; + if (yych == 'w') goto yy536; + goto yy187; } } -yy134: - YYDEBUG(134, *YYCURSOR); +yy135: + YYDEBUG(135, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= ';') { if (yych <= '"') { - if (yych <= '!') goto yy186; - goto yy526; + if (yych <= '!') goto yy187; + goto yy527; } else { - if (yych == '\'') goto yy527; - goto yy186; + if (yych == '\'') goto yy528; + goto yy187; } } else { if (yych <= 'R') { - if (yych <= '<') goto yy525; - if (yych <= 'Q') goto yy186; - goto yy528; + if (yych <= '<') goto yy526; + if (yych <= 'Q') goto yy187; + goto yy529; } else { - if (yych == 'r') goto yy528; - goto yy186; + if (yych == 'r') goto yy529; + goto yy187; } } -yy135: - YYDEBUG(135, *YYCURSOR); +yy136: + YYDEBUG(136, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'O') { - if (yych == 'L') goto yy515; - if (yych <= 'N') goto yy186; - goto yy516; + if (yych == 'L') goto yy516; + if (yych <= 'N') goto yy187; + goto yy517; } else { if (yych <= 'l') { - if (yych <= 'k') goto yy186; - goto yy515; + if (yych <= 'k') goto yy187; + goto yy516; } else { - if (yych == 'o') goto yy516; - goto yy186; + if (yych == 'o') goto yy517; + goto yy187; } } -yy136: - YYDEBUG(136, *YYCURSOR); +yy137: + YYDEBUG(137, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'U') { - if (yych == 'R') goto yy491; - if (yych <= 'T') goto yy186; - goto yy492; + if (yych == 'R') goto yy492; + if (yych <= 'T') goto yy187; + goto yy493; } else { if (yych <= 'r') { - if (yych <= 'q') goto yy186; - goto yy491; + if (yych <= 'q') goto yy187; + goto yy492; } else { - if (yych == 'u') goto yy492; - goto yy186; + if (yych == 'u') goto yy493; + goto yy187; } } -yy137: - YYDEBUG(137, *YYCURSOR); +yy138: + YYDEBUG(138, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) <= '<') { - if (yych == '-') goto yy487; + if (yych == '-') goto yy488; } else { - if (yych <= '=') goto yy485; - if (yych <= '>') goto yy489; + if (yych <= '=') goto yy486; + if (yych <= '>') goto yy490; } -yy138: - YYDEBUG(138, *YYCURSOR); +yy139: + YYDEBUG(139, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1440 "Zend/zend_language_scanner.l" +#line 1450 "Zend/zend_language_scanner.l" { return yytext[0]; } -#line 2637 "Zend/zend_language_scanner.c" -yy139: - YYDEBUG(139, *YYCURSOR); - ++YYCURSOR; - yych = *YYCURSOR; - goto yy484; +#line 2650 "Zend/zend_language_scanner.c" yy140: YYDEBUG(140, *YYCURSOR); + ++YYCURSOR; + yych = *YYCURSOR; + goto yy485; +yy141: + YYDEBUG(141, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1171 "Zend/zend_language_scanner.l" +#line 1181 "Zend/zend_language_scanner.l" { zendlval->value.str.val = yytext; /* no copying - intentional */ zendlval->value.str.len = yyleng; @@ -2650,261 +2663,261 @@ int lex_scan(zval *zendlval TSRMLS_DC) HANDLE_NEWLINES(yytext, yyleng); return T_WHITESPACE; } -#line 2654 "Zend/zend_language_scanner.c" -yy141: - YYDEBUG(141, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == ':') goto yy481; - goto yy138; +#line 2667 "Zend/zend_language_scanner.c" yy142: YYDEBUG(142, *YYCURSOR); - ++YYCURSOR; + yych = *++YYCURSOR; + if (yych == ':') goto yy482; + goto yy139; +yy143: YYDEBUG(143, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(144, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1200 "Zend/zend_language_scanner.l" +#line 1210 "Zend/zend_language_scanner.l" { return T_NS_SEPARATOR; } -#line 2669 "Zend/zend_language_scanner.c" -yy144: - YYDEBUG(144, *YYCURSOR); +#line 2682 "Zend/zend_language_scanner.c" +yy145: + YYDEBUG(145, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'E') { - if (yych == 'A') goto yy469; - if (yych <= 'D') goto yy186; - goto yy470; + if (yych == 'A') goto yy470; + if (yych <= 'D') goto yy187; + goto yy471; } else { if (yych <= 'a') { - if (yych <= '`') goto yy186; - goto yy469; + if (yych <= '`') goto yy187; + goto yy470; } else { - if (yych == 'e') goto yy470; - goto yy186; + if (yych == 'e') goto yy471; + goto yy187; } } -yy145: - YYDEBUG(145, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'A') goto yy466; - if (yych == 'a') goto yy466; - goto yy186; yy146: YYDEBUG(146, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'A') goto yy467; + if (yych == 'a') goto yy467; + goto yy187; +yy147: + YYDEBUG(147, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if (yych <= 'S') { if (yych <= 'D') { if (yych <= ' ') { - if (yych == '\t') goto yy391; - if (yych <= 0x1F) goto yy138; - goto yy391; + if (yych == '\t') goto yy392; + if (yych <= 0x1F) goto yy139; + goto yy392; } else { - if (yych <= '@') goto yy138; - if (yych == 'C') goto yy138; - goto yy391; + if (yych <= '@') goto yy139; + if (yych == 'C') goto yy139; + goto yy392; } } else { if (yych <= 'I') { - if (yych == 'F') goto yy391; - if (yych <= 'H') goto yy138; - goto yy391; + if (yych == 'F') goto yy392; + if (yych <= 'H') goto yy139; + goto yy392; } else { - if (yych == 'O') goto yy391; - if (yych <= 'Q') goto yy138; - goto yy391; + if (yych == 'O') goto yy392; + if (yych <= 'Q') goto yy139; + goto yy392; } } } else { if (yych <= 'f') { if (yych <= 'b') { - if (yych == 'U') goto yy391; - if (yych <= '`') goto yy138; - goto yy391; + if (yych == 'U') goto yy392; + if (yych <= '`') goto yy139; + goto yy392; } else { - if (yych == 'd') goto yy391; - if (yych <= 'e') goto yy138; - goto yy391; + if (yych == 'd') goto yy392; + if (yych <= 'e') goto yy139; + goto yy392; } } else { if (yych <= 'o') { - if (yych == 'i') goto yy391; - if (yych <= 'n') goto yy138; - goto yy391; + if (yych == 'i') goto yy392; + if (yych <= 'n') goto yy139; + goto yy392; } else { if (yych <= 's') { - if (yych <= 'q') goto yy138; - goto yy391; + if (yych <= 'q') goto yy139; + goto yy392; } else { - if (yych == 'u') goto yy391; - goto yy138; + if (yych == 'u') goto yy392; + goto yy139; } } } } -yy147: - YYDEBUG(147, *YYCURSOR); +yy148: + YYDEBUG(148, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'S') { - if (yych == 'N') goto yy382; - if (yych <= 'R') goto yy186; - goto yy383; + if (yych == 'N') goto yy383; + if (yych <= 'R') goto yy187; + goto yy384; } else { if (yych <= 'n') { - if (yych <= 'm') goto yy186; - goto yy382; + if (yych <= 'm') goto yy187; + goto yy383; } else { - if (yych == 's') goto yy383; - goto yy186; + if (yych == 's') goto yy384; + goto yy187; } } -yy148: - YYDEBUG(148, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '_') goto yy300; - goto yy186; yy149: YYDEBUG(149, *YYCURSOR); yych = *++YYCURSOR; - if (yych <= '<') goto yy138; - if (yych <= '=') goto yy294; - if (yych <= '>') goto yy296; - goto yy138; + if (yych == '_') goto yy301; + goto yy187; yy150: YYDEBUG(150, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy290; - if (yych == 'i') goto yy290; - goto yy186; + if (yych <= '<') goto yy139; + if (yych <= '=') goto yy295; + if (yych <= '>') goto yy297; + goto yy139; yy151: YYDEBUG(151, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '+') goto yy288; - if (yych == '=') goto yy286; - goto yy138; + if (yych == 'I') goto yy291; + if (yych == 'i') goto yy291; + goto yy187; yy152: YYDEBUG(152, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '=') goto yy283; - goto yy138; + if (yych == '+') goto yy289; + if (yych == '=') goto yy287; + goto yy139; yy153: YYDEBUG(153, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == '=') goto yy284; + goto yy139; +yy154: + YYDEBUG(154, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if (yych <= ';') { - if (yych == '/') goto yy255; - goto yy138; + if (yych == '/') goto yy256; + goto yy139; } else { - if (yych <= '<') goto yy253; - if (yych <= '=') goto yy256; - if (yych <= '>') goto yy258; - goto yy138; + if (yych <= '<') goto yy254; + if (yych <= '=') goto yy257; + if (yych <= '>') goto yy259; + goto yy139; } -yy154: - YYDEBUG(154, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= '<') goto yy138; - if (yych <= '=') goto yy249; - if (yych <= '>') goto yy247; - goto yy138; yy155: YYDEBUG(155, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '=') goto yy245; - goto yy138; + if (yych <= '<') goto yy139; + if (yych <= '=') goto yy250; + if (yych <= '>') goto yy248; + goto yy139; yy156: YYDEBUG(156, *YYCURSOR); yych = *++YYCURSOR; - if (yych <= '.') { - if (yych == '*') goto yy237; - goto yy138; - } else { - if (yych <= '/') goto yy239; - if (yych == '=') goto yy240; - goto yy138; - } + if (yych == '=') goto yy246; + goto yy139; yy157: YYDEBUG(157, *YYCURSOR); yych = *++YYCURSOR; - if (yych <= '/') goto yy138; - if (yych <= '9') goto yy233; - if (yych == '=') goto yy235; - goto yy138; + if (yych <= '.') { + if (yych == '*') goto yy238; + goto yy139; + } else { + if (yych <= '/') goto yy240; + if (yych == '=') goto yy241; + goto yy139; + } yy158: YYDEBUG(158, *YYCURSOR); yych = *++YYCURSOR; - if (yych <= '<') goto yy138; - if (yych <= '=') goto yy229; - if (yych <= '>') goto yy227; - goto yy138; + if (yych <= '/') goto yy139; + if (yych <= '9') goto yy234; + if (yych == '=') goto yy236; + goto yy139; yy159: YYDEBUG(159, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '&') goto yy223; - if (yych == '=') goto yy225; - goto yy138; + if (yych <= '<') goto yy139; + if (yych <= '=') goto yy230; + if (yych <= '>') goto yy228; + goto yy139; yy160: YYDEBUG(160, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '=') goto yy221; - if (yych == '|') goto yy219; - goto yy138; + if (yych == '&') goto yy224; + if (yych == '=') goto yy226; + goto yy139; yy161: YYDEBUG(161, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '=') goto yy217; - goto yy138; + if (yych == '=') goto yy222; + if (yych == '|') goto yy220; + goto yy139; yy162: YYDEBUG(162, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy215; - if (yych == 'r') goto yy215; - goto yy186; + if (yych == '=') goto yy218; + goto yy139; yy163: YYDEBUG(163, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy212; - if (yych == 'o') goto yy212; - goto yy186; + if (yych == 'R') goto yy216; + if (yych == 'r') goto yy216; + goto yy187; yy164: YYDEBUG(164, *YYCURSOR); yych = *++YYCURSOR; - if (yych <= '_') { - if (yych <= '@') goto yy138; - if (yych <= 'Z') goto yy209; - if (yych <= '^') goto yy138; - goto yy209; - } else { - if (yych <= '`') goto yy138; - if (yych <= 'z') goto yy209; - if (yych <= '~') goto yy138; - goto yy209; - } + if (yych == 'O') goto yy213; + if (yych == 'o') goto yy213; + goto yy187; yy165: YYDEBUG(165, *YYCURSOR); yych = *++YYCURSOR; - goto yy138; + if (yych <= '_') { + if (yych <= '@') goto yy139; + if (yych <= 'Z') goto yy210; + if (yych <= '^') goto yy139; + goto yy210; + } else { + if (yych <= '`') goto yy139; + if (yych <= 'z') goto yy210; + if (yych <= '~') goto yy139; + goto yy210; + } yy166: YYDEBUG(166, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '>') goto yy205; - goto yy138; + goto yy139; yy167: YYDEBUG(167, *YYCURSOR); - ++YYCURSOR; + yych = *++YYCURSOR; + if (yych == '>') goto yy206; + goto yy139; +yy168: YYDEBUG(168, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(169, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1445 "Zend/zend_language_scanner.l" +#line 1455 "Zend/zend_language_scanner.l" { yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); return '{'; } -#line 2902 "Zend/zend_language_scanner.c" -yy169: - YYDEBUG(169, *YYCURSOR); - ++YYCURSOR; +#line 2915 "Zend/zend_language_scanner.c" +yy170: YYDEBUG(170, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(171, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1457 "Zend/zend_language_scanner.l" +#line 1467 "Zend/zend_language_scanner.l" { RESET_DOC_COMMENT(); if (!zend_stack_is_empty(&SCNG(state_stack))) { @@ -2912,35 +2925,35 @@ int lex_scan(zval *zendlval TSRMLS_DC) } return '}'; } -#line 2916 "Zend/zend_language_scanner.c" -yy171: - YYDEBUG(171, *YYCURSOR); +#line 2929 "Zend/zend_language_scanner.c" +yy172: + YYDEBUG(172, *YYCURSOR); yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); if (yych <= 'E') { if (yych <= '9') { - if (yych == '.') goto yy187; - if (yych >= '0') goto yy190; + if (yych == '.') goto yy188; + if (yych >= '0') goto yy191; } else { - if (yych == 'B') goto yy198; - if (yych >= 'E') goto yy192; + if (yych == 'B') goto yy199; + if (yych >= 'E') goto yy193; } } else { if (yych <= 'b') { - if (yych == 'X') goto yy197; - if (yych >= 'b') goto yy198; + if (yych == 'X') goto yy198; + if (yych >= 'b') goto yy199; } else { if (yych <= 'e') { - if (yych >= 'e') goto yy192; + if (yych >= 'e') goto yy193; } else { - if (yych == 'x') goto yy197; + if (yych == 'x') goto yy198; } } } -yy172: - YYDEBUG(172, *YYCURSOR); +yy173: + YYDEBUG(173, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1507 "Zend/zend_language_scanner.l" +#line 1518 "Zend/zend_language_scanner.l" { if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */ zendlval->value.lval = strtol(yytext, NULL, 0); @@ -2961,35 +2974,35 @@ int lex_scan(zval *zendlval TSRMLS_DC) zendlval->type = IS_LONG; return T_LNUMBER; } -#line 2965 "Zend/zend_language_scanner.c" -yy173: - YYDEBUG(173, *YYCURSOR); +#line 2978 "Zend/zend_language_scanner.c" +yy174: + YYDEBUG(174, *YYCURSOR); yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '9') { - if (yych == '.') goto yy187; - if (yych <= '/') goto yy172; - goto yy190; + if (yych == '.') goto yy188; + if (yych <= '/') goto yy173; + goto yy191; } else { if (yych <= 'E') { - if (yych <= 'D') goto yy172; - goto yy192; + if (yych <= 'D') goto yy173; + goto yy193; } else { - if (yych == 'e') goto yy192; - goto yy172; + if (yych == 'e') goto yy193; + goto yy173; } } -yy174: - YYDEBUG(174, *YYCURSOR); - yych = *++YYCURSOR; - goto yy186; yy175: YYDEBUG(175, *YYCURSOR); - ++YYCURSOR; + yych = *++YYCURSOR; + goto yy187; yy176: YYDEBUG(176, *YYCURSOR); + ++YYCURSOR; +yy177: + YYDEBUG(177, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1904 "Zend/zend_language_scanner.l" +#line 1915 "Zend/zend_language_scanner.l" { while (YYCURSOR < YYLIMIT) { switch (*YYCURSOR++) { @@ -3023,14 +3036,14 @@ int lex_scan(zval *zendlval TSRMLS_DC) return T_COMMENT; } -#line 3027 "Zend/zend_language_scanner.c" -yy177: - YYDEBUG(177, *YYCURSOR); - ++YYCURSOR; +#line 3040 "Zend/zend_language_scanner.c" yy178: YYDEBUG(178, *YYCURSOR); + ++YYCURSOR; +yy179: + YYDEBUG(179, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1995 "Zend/zend_language_scanner.l" +#line 2006 "Zend/zend_language_scanner.l" { register char *s, *t; char *end; @@ -3098,14 +3111,14 @@ int lex_scan(zval *zendlval TSRMLS_DC) } return T_CONSTANT_ENCAPSED_STRING; } -#line 3102 "Zend/zend_language_scanner.c" -yy179: - YYDEBUG(179, *YYCURSOR); - ++YYCURSOR; +#line 3115 "Zend/zend_language_scanner.c" yy180: YYDEBUG(180, *YYCURSOR); + ++YYCURSOR; +yy181: + YYDEBUG(181, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2064 "Zend/zend_language_scanner.l" +#line 2075 "Zend/zend_language_scanner.l" { int bprefix = (yytext[0] != '"') ? 1 : 0; @@ -3146,24 +3159,24 @@ int lex_scan(zval *zendlval TSRMLS_DC) BEGIN(ST_DOUBLE_QUOTES); return '"'; } -#line 3150 "Zend/zend_language_scanner.c" -yy181: - YYDEBUG(181, *YYCURSOR); - ++YYCURSOR; +#line 3163 "Zend/zend_language_scanner.c" +yy182: YYDEBUG(182, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(183, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2155 "Zend/zend_language_scanner.l" +#line 2165 "Zend/zend_language_scanner.l" { BEGIN(ST_BACKQUOTE); return '`'; } -#line 3161 "Zend/zend_language_scanner.c" -yy183: - YYDEBUG(183, *YYCURSOR); - ++YYCURSOR; +#line 3174 "Zend/zend_language_scanner.c" +yy184: YYDEBUG(184, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(185, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2413 "Zend/zend_language_scanner.l" +#line 2428 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -3172,132 +3185,132 @@ int lex_scan(zval *zendlval TSRMLS_DC) zend_error(E_COMPILE_WARNING,"Unexpected character in input: '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE); goto restart; } -#line 3176 "Zend/zend_language_scanner.c" -yy185: - YYDEBUG(185, *YYCURSOR); +#line 3189 "Zend/zend_language_scanner.c" +yy186: + YYDEBUG(186, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy186: - YYDEBUG(186, *YYCURSOR); +yy187: + YYDEBUG(187, *YYCURSOR); if (yybm[0+yych] & 4) { - goto yy185; + goto yy186; } goto yy124; -yy187: - YYDEBUG(187, *YYCURSOR); +yy188: + YYDEBUG(188, *YYCURSOR); yyaccept = 3; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(188, *YYCURSOR); + YYDEBUG(189, *YYCURSOR); if (yybm[0+yych] & 8) { - goto yy187; + goto yy188; } - if (yych == 'E') goto yy192; - if (yych == 'e') goto yy192; -yy189: - YYDEBUG(189, *YYCURSOR); + if (yych == 'E') goto yy193; + if (yych == 'e') goto yy193; +yy190: + YYDEBUG(190, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1572 "Zend/zend_language_scanner.l" +#line 1583 "Zend/zend_language_scanner.l" { zendlval->value.dval = zend_strtod(yytext, NULL); zendlval->type = IS_DOUBLE; return T_DNUMBER; } -#line 3209 "Zend/zend_language_scanner.c" -yy190: - YYDEBUG(190, *YYCURSOR); +#line 3222 "Zend/zend_language_scanner.c" +yy191: + YYDEBUG(191, *YYCURSOR); yyaccept = 2; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(191, *YYCURSOR); + YYDEBUG(192, *YYCURSOR); if (yych <= '9') { - if (yych == '.') goto yy187; - if (yych <= '/') goto yy172; - goto yy190; + if (yych == '.') goto yy188; + if (yych <= '/') goto yy173; + goto yy191; } else { if (yych <= 'E') { - if (yych <= 'D') goto yy172; + if (yych <= 'D') goto yy173; } else { - if (yych != 'e') goto yy172; + if (yych != 'e') goto yy173; } } -yy192: - YYDEBUG(192, *YYCURSOR); +yy193: + YYDEBUG(193, *YYCURSOR); yych = *++YYCURSOR; if (yych <= ',') { - if (yych == '+') goto yy194; + if (yych == '+') goto yy195; } else { - if (yych <= '-') goto yy194; - if (yych <= '/') goto yy193; - if (yych <= '9') goto yy195; + if (yych <= '-') goto yy195; + if (yych <= '/') goto yy194; + if (yych <= '9') goto yy196; } -yy193: - YYDEBUG(193, *YYCURSOR); +yy194: + YYDEBUG(194, *YYCURSOR); YYCURSOR = YYMARKER; if (yyaccept <= 2) { if (yyaccept <= 1) { if (yyaccept <= 0) { goto yy124; } else { - goto yy138; + goto yy139; } } else { - goto yy172; + goto yy173; } } else { if (yyaccept <= 4) { if (yyaccept <= 3) { - goto yy189; + goto yy190; } else { - goto yy238; + goto yy239; } } else { - goto yy254; + goto yy255; } } -yy194: - YYDEBUG(194, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= '/') goto yy193; - if (yych >= ':') goto yy193; yy195: YYDEBUG(195, *YYCURSOR); + yych = *++YYCURSOR; + if (yych <= '/') goto yy194; + if (yych >= ':') goto yy194; +yy196: + YYDEBUG(196, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(196, *YYCURSOR); - if (yych <= '/') goto yy189; - if (yych <= '9') goto yy195; - goto yy189; -yy197: YYDEBUG(197, *YYCURSOR); - yych = *++YYCURSOR; - if (yybm[0+yych] & 32) { - goto yy202; - } - goto yy193; + if (yych <= '/') goto yy190; + if (yych <= '9') goto yy196; + goto yy190; yy198: YYDEBUG(198, *YYCURSOR); yych = *++YYCURSOR; - if (yybm[0+yych] & 16) { - goto yy199; + if (yybm[0+yych] & 32) { + goto yy203; } - goto yy193; + goto yy194; yy199: YYDEBUG(199, *YYCURSOR); + yych = *++YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy200; + } + goto yy194; +yy200: + YYDEBUG(200, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(200, *YYCURSOR); + YYDEBUG(201, *YYCURSOR); if (yybm[0+yych] & 16) { - goto yy199; + goto yy200; } - YYDEBUG(201, *YYCURSOR); + YYDEBUG(202, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1482 "Zend/zend_language_scanner.l" +#line 1493 "Zend/zend_language_scanner.l" { char *bin = yytext + 2; /* Skip "0b" */ int len = yyleng - 2; @@ -3322,19 +3335,19 @@ int lex_scan(zval *zendlval TSRMLS_DC) return T_DNUMBER; } } -#line 3326 "Zend/zend_language_scanner.c" -yy202: - YYDEBUG(202, *YYCURSOR); +#line 3339 "Zend/zend_language_scanner.c" +yy203: + YYDEBUG(203, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(203, *YYCURSOR); + YYDEBUG(204, *YYCURSOR); if (yybm[0+yych] & 32) { - goto yy202; + goto yy203; } - YYDEBUG(204, *YYCURSOR); + YYDEBUG(205, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1528 "Zend/zend_language_scanner.l" +#line 1539 "Zend/zend_language_scanner.l" { char *hex = yytext + 2; /* Skip "0x" */ int len = yyleng - 2; @@ -3359,16 +3372,16 @@ int lex_scan(zval *zendlval TSRMLS_DC) return T_DNUMBER; } } -#line 3363 "Zend/zend_language_scanner.c" -yy205: - YYDEBUG(205, *YYCURSOR); - ++YYCURSOR; - if ((yych = *YYCURSOR) == '\n') goto yy207; - if (yych == '\r') goto yy208; +#line 3376 "Zend/zend_language_scanner.c" yy206: YYDEBUG(206, *YYCURSOR); + ++YYCURSOR; + if ((yych = *YYCURSOR) == '\n') goto yy208; + if (yych == '\r') goto yy209; +yy207: + YYDEBUG(207, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1972 "Zend/zend_language_scanner.l" +#line 1983 "Zend/zend_language_scanner.l" { zendlval->value.str.val = yytext; /* no copying - intentional */ zendlval->value.str.len = yyleng; @@ -3376,137 +3389,137 @@ int lex_scan(zval *zendlval TSRMLS_DC) BEGIN(INITIAL); return T_CLOSE_TAG; /* implicit ';' at php-end tag */ } -#line 3380 "Zend/zend_language_scanner.c" -yy207: - YYDEBUG(207, *YYCURSOR); - yych = *++YYCURSOR; - goto yy206; +#line 3393 "Zend/zend_language_scanner.c" yy208: YYDEBUG(208, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '\n') goto yy207; - goto yy206; + goto yy207; yy209: YYDEBUG(209, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == '\n') goto yy208; + goto yy207; +yy210: + YYDEBUG(210, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(210, *YYCURSOR); + YYDEBUG(211, *YYCURSOR); if (yych <= '^') { if (yych <= '9') { - if (yych >= '0') goto yy209; + if (yych >= '0') goto yy210; } else { - if (yych <= '@') goto yy211; - if (yych <= 'Z') goto yy209; + if (yych <= '@') goto yy212; + if (yych <= 'Z') goto yy210; } } else { if (yych <= '`') { - if (yych <= '_') goto yy209; + if (yych <= '_') goto yy210; } else { - if (yych <= 'z') goto yy209; - if (yych >= 0x7F) goto yy209; + if (yych <= 'z') goto yy210; + if (yych >= 0x7F) goto yy210; } } -yy211: - YYDEBUG(211, *YYCURSOR); +yy212: + YYDEBUG(212, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1874 "Zend/zend_language_scanner.l" +#line 1885 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zendlval->type = IS_STRING; return T_VARIABLE; } -#line 3420 "Zend/zend_language_scanner.c" -yy212: - YYDEBUG(212, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'R') goto yy213; - if (yych != 'r') goto yy186; +#line 3433 "Zend/zend_language_scanner.c" yy213: YYDEBUG(213, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'R') goto yy214; + if (yych != 'r') goto yy187; +yy214: + YYDEBUG(214, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(214, *YYCURSOR); + YYDEBUG(215, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1428 "Zend/zend_language_scanner.l" +#line 1438 "Zend/zend_language_scanner.l" { return T_LOGICAL_XOR; } -#line 3438 "Zend/zend_language_scanner.c" -yy215: - YYDEBUG(215, *YYCURSOR); +#line 3451 "Zend/zend_language_scanner.c" +yy216: + YYDEBUG(216, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(216, *YYCURSOR); + YYDEBUG(217, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1420 "Zend/zend_language_scanner.l" +#line 1430 "Zend/zend_language_scanner.l" { return T_LOGICAL_OR; } -#line 3451 "Zend/zend_language_scanner.c" -yy217: - YYDEBUG(217, *YYCURSOR); - ++YYCURSOR; +#line 3464 "Zend/zend_language_scanner.c" +yy218: YYDEBUG(218, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(219, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1408 "Zend/zend_language_scanner.l" +#line 1418 "Zend/zend_language_scanner.l" { return T_XOR_EQUAL; } -#line 3461 "Zend/zend_language_scanner.c" -yy219: - YYDEBUG(219, *YYCURSOR); - ++YYCURSOR; +#line 3474 "Zend/zend_language_scanner.c" +yy220: YYDEBUG(220, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(221, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1412 "Zend/zend_language_scanner.l" +#line 1422 "Zend/zend_language_scanner.l" { return T_BOOLEAN_OR; } -#line 3471 "Zend/zend_language_scanner.c" -yy221: - YYDEBUG(221, *YYCURSOR); - ++YYCURSOR; +#line 3484 "Zend/zend_language_scanner.c" +yy222: YYDEBUG(222, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(223, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1404 "Zend/zend_language_scanner.l" +#line 1414 "Zend/zend_language_scanner.l" { return T_OR_EQUAL; } -#line 3481 "Zend/zend_language_scanner.c" -yy223: - YYDEBUG(223, *YYCURSOR); - ++YYCURSOR; +#line 3494 "Zend/zend_language_scanner.c" +yy224: YYDEBUG(224, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(225, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1416 "Zend/zend_language_scanner.l" +#line 1426 "Zend/zend_language_scanner.l" { return T_BOOLEAN_AND; } -#line 3491 "Zend/zend_language_scanner.c" -yy225: - YYDEBUG(225, *YYCURSOR); - ++YYCURSOR; +#line 3504 "Zend/zend_language_scanner.c" +yy226: YYDEBUG(226, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(227, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1400 "Zend/zend_language_scanner.l" +#line 1410 "Zend/zend_language_scanner.l" { return T_AND_EQUAL; } -#line 3501 "Zend/zend_language_scanner.c" -yy227: - YYDEBUG(227, *YYCURSOR); - ++YYCURSOR; - if ((yych = *YYCURSOR) == '\n') goto yy231; - if (yych == '\r') goto yy232; +#line 3514 "Zend/zend_language_scanner.c" yy228: YYDEBUG(228, *YYCURSOR); + ++YYCURSOR; + if ((yych = *YYCURSOR) == '\n') goto yy232; + if (yych == '\r') goto yy233; +yy229: + YYDEBUG(229, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1981 "Zend/zend_language_scanner.l" +#line 1992 "Zend/zend_language_scanner.l" { if (CG(asp_tags)) { BEGIN(INITIAL); @@ -3519,61 +3532,61 @@ int lex_scan(zval *zendlval TSRMLS_DC) return yytext[0]; } } -#line 3523 "Zend/zend_language_scanner.c" -yy229: - YYDEBUG(229, *YYCURSOR); - ++YYCURSOR; +#line 3536 "Zend/zend_language_scanner.c" +yy230: YYDEBUG(230, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(231, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1388 "Zend/zend_language_scanner.l" +#line 1398 "Zend/zend_language_scanner.l" { return T_MOD_EQUAL; } -#line 3533 "Zend/zend_language_scanner.c" -yy231: - YYDEBUG(231, *YYCURSOR); - yych = *++YYCURSOR; - goto yy228; +#line 3546 "Zend/zend_language_scanner.c" yy232: YYDEBUG(232, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '\n') goto yy231; - goto yy228; + goto yy229; yy233: YYDEBUG(233, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == '\n') goto yy232; + goto yy229; +yy234: + YYDEBUG(234, *YYCURSOR); yyaccept = 3; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(234, *YYCURSOR); + YYDEBUG(235, *YYCURSOR); if (yych <= 'D') { - if (yych <= '/') goto yy189; - if (yych <= '9') goto yy233; - goto yy189; + if (yych <= '/') goto yy190; + if (yych <= '9') goto yy234; + goto yy190; } else { - if (yych <= 'E') goto yy192; - if (yych == 'e') goto yy192; - goto yy189; + if (yych <= 'E') goto yy193; + if (yych == 'e') goto yy193; + goto yy190; } -yy235: - YYDEBUG(235, *YYCURSOR); - ++YYCURSOR; +yy236: YYDEBUG(236, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(237, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1384 "Zend/zend_language_scanner.l" +#line 1394 "Zend/zend_language_scanner.l" { return T_CONCAT_EQUAL; } -#line 3568 "Zend/zend_language_scanner.c" -yy237: - YYDEBUG(237, *YYCURSOR); - yyaccept = 4; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == '*') goto yy242; +#line 3581 "Zend/zend_language_scanner.c" yy238: YYDEBUG(238, *YYCURSOR); + yyaccept = 4; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '*') goto yy243; +yy239: + YYDEBUG(239, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1938 "Zend/zend_language_scanner.l" +#line 1949 "Zend/zend_language_scanner.l" { int doc_com; @@ -3607,316 +3620,313 @@ int lex_scan(zval *zendlval TSRMLS_DC) return T_COMMENT; } -#line 3611 "Zend/zend_language_scanner.c" -yy239: - YYDEBUG(239, *YYCURSOR); - yych = *++YYCURSOR; - goto yy176; +#line 3624 "Zend/zend_language_scanner.c" yy240: YYDEBUG(240, *YYCURSOR); - ++YYCURSOR; + yych = *++YYCURSOR; + goto yy177; +yy241: YYDEBUG(241, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(242, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1380 "Zend/zend_language_scanner.l" +#line 1390 "Zend/zend_language_scanner.l" { return T_DIV_EQUAL; } -#line 3625 "Zend/zend_language_scanner.c" -yy242: - YYDEBUG(242, *YYCURSOR); +#line 3638 "Zend/zend_language_scanner.c" +yy243: + YYDEBUG(243, *YYCURSOR); yych = *++YYCURSOR; if (yybm[0+yych] & 64) { - goto yy243; + goto yy244; } - goto yy193; -yy243: - YYDEBUG(243, *YYCURSOR); + goto yy194; +yy244: + YYDEBUG(244, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(244, *YYCURSOR); + YYDEBUG(245, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy243; + goto yy244; } - goto yy238; -yy245: - YYDEBUG(245, *YYCURSOR); - ++YYCURSOR; + goto yy239; +yy246: YYDEBUG(246, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(247, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1376 "Zend/zend_language_scanner.l" +#line 1386 "Zend/zend_language_scanner.l" { return T_MUL_EQUAL; } -#line 3652 "Zend/zend_language_scanner.c" -yy247: - YYDEBUG(247, *YYCURSOR); - ++YYCURSOR; - if ((yych = *YYCURSOR) == '=') goto yy251; +#line 3665 "Zend/zend_language_scanner.c" +yy248: YYDEBUG(248, *YYCURSOR); + ++YYCURSOR; + if ((yych = *YYCURSOR) == '=') goto yy252; + YYDEBUG(249, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1436 "Zend/zend_language_scanner.l" +#line 1446 "Zend/zend_language_scanner.l" { return T_SR; } -#line 3663 "Zend/zend_language_scanner.c" -yy249: - YYDEBUG(249, *YYCURSOR); - ++YYCURSOR; +#line 3676 "Zend/zend_language_scanner.c" +yy250: YYDEBUG(250, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(251, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1364 "Zend/zend_language_scanner.l" +#line 1374 "Zend/zend_language_scanner.l" { return T_IS_GREATER_OR_EQUAL; } -#line 3673 "Zend/zend_language_scanner.c" -yy251: - YYDEBUG(251, *YYCURSOR); - ++YYCURSOR; +#line 3686 "Zend/zend_language_scanner.c" +yy252: YYDEBUG(252, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(253, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1396 "Zend/zend_language_scanner.l" +#line 1406 "Zend/zend_language_scanner.l" { return T_SR_EQUAL; } -#line 3683 "Zend/zend_language_scanner.c" -yy253: - YYDEBUG(253, *YYCURSOR); - yyaccept = 5; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= ';') goto yy254; - if (yych <= '<') goto yy269; - if (yych <= '=') goto yy267; +#line 3696 "Zend/zend_language_scanner.c" yy254: YYDEBUG(254, *YYCURSOR); + yyaccept = 5; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= ';') goto yy255; + if (yych <= '<') goto yy270; + if (yych <= '=') goto yy268; +yy255: + YYDEBUG(255, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1432 "Zend/zend_language_scanner.l" +#line 1442 "Zend/zend_language_scanner.l" { return T_SL; } -#line 3698 "Zend/zend_language_scanner.c" -yy255: - YYDEBUG(255, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'S') goto yy260; - if (yych == 's') goto yy260; - goto yy193; +#line 3711 "Zend/zend_language_scanner.c" yy256: YYDEBUG(256, *YYCURSOR); - ++YYCURSOR; + yych = *++YYCURSOR; + if (yych == 'S') goto yy261; + if (yych == 's') goto yy261; + goto yy194; +yy257: YYDEBUG(257, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(258, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1360 "Zend/zend_language_scanner.l" +#line 1370 "Zend/zend_language_scanner.l" { return T_IS_SMALLER_OR_EQUAL; } -#line 3714 "Zend/zend_language_scanner.c" -yy258: - YYDEBUG(258, *YYCURSOR); - ++YYCURSOR; +#line 3727 "Zend/zend_language_scanner.c" yy259: YYDEBUG(259, *YYCURSOR); + ++YYCURSOR; +yy260: + YYDEBUG(260, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1356 "Zend/zend_language_scanner.l" +#line 1366 "Zend/zend_language_scanner.l" { return T_IS_NOT_EQUAL; } -#line 3725 "Zend/zend_language_scanner.c" -yy260: - YYDEBUG(260, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'C') goto yy261; - if (yych != 'c') goto yy193; +#line 3738 "Zend/zend_language_scanner.c" yy261: YYDEBUG(261, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy262; - if (yych != 'r') goto yy193; + if (yych == 'C') goto yy262; + if (yych != 'c') goto yy194; yy262: YYDEBUG(262, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy263; - if (yych != 'i') goto yy193; + if (yych == 'R') goto yy263; + if (yych != 'r') goto yy194; yy263: YYDEBUG(263, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'P') goto yy264; - if (yych != 'p') goto yy193; + if (yych == 'I') goto yy264; + if (yych != 'i') goto yy194; yy264: YYDEBUG(264, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy265; - if (yych != 't') goto yy193; + if (yych == 'P') goto yy265; + if (yych != 'p') goto yy194; yy265: YYDEBUG(265, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'T') goto yy266; + if (yych != 't') goto yy194; +yy266: + YYDEBUG(266, *YYCURSOR); ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(266, *YYCURSOR); + YYDEBUG(267, *YYCURSOR); if (yych <= '\r') { - if (yych <= 0x08) goto yy193; - if (yych <= '\n') goto yy265; - if (yych <= '\f') goto yy193; - goto yy265; + if (yych <= 0x08) goto yy194; + if (yych <= '\n') goto yy266; + if (yych <= '\f') goto yy194; + goto yy266; } else { if (yych <= ' ') { - if (yych <= 0x1F) goto yy193; - goto yy265; + if (yych <= 0x1F) goto yy194; + goto yy266; } else { - if (yych == '>') goto yy205; - goto yy193; + if (yych == '>') goto yy206; + goto yy194; } } -yy267: - YYDEBUG(267, *YYCURSOR); - ++YYCURSOR; +yy268: YYDEBUG(268, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(269, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1392 "Zend/zend_language_scanner.l" +#line 1402 "Zend/zend_language_scanner.l" { return T_SL_EQUAL; } -#line 3780 "Zend/zend_language_scanner.c" -yy269: - YYDEBUG(269, *YYCURSOR); +#line 3793 "Zend/zend_language_scanner.c" +yy270: + YYDEBUG(270, *YYCURSOR); ++YYCURSOR; YYFILL(2); yych = *YYCURSOR; - YYDEBUG(270, *YYCURSOR); + YYDEBUG(271, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy269; + goto yy270; } if (yych <= 'Z') { if (yych <= '&') { - if (yych == '"') goto yy274; - goto yy193; + if (yych == '"') goto yy275; + goto yy194; } else { - if (yych <= '\'') goto yy273; - if (yych <= '@') goto yy193; + if (yych <= '\'') goto yy274; + if (yych <= '@') goto yy194; } } else { if (yych <= '`') { - if (yych != '_') goto yy193; + if (yych != '_') goto yy194; } else { - if (yych <= 'z') goto yy271; - if (yych <= '~') goto yy193; + if (yych <= 'z') goto yy272; + if (yych <= '~') goto yy194; } } -yy271: - YYDEBUG(271, *YYCURSOR); +yy272: + YYDEBUG(272, *YYCURSOR); ++YYCURSOR; YYFILL(2); yych = *YYCURSOR; - YYDEBUG(272, *YYCURSOR); + YYDEBUG(273, *YYCURSOR); if (yych <= '@') { if (yych <= '\f') { - if (yych == '\n') goto yy278; - goto yy193; + if (yych == '\n') goto yy279; + goto yy194; } else { - if (yych <= '\r') goto yy280; - if (yych <= '/') goto yy193; - if (yych <= '9') goto yy271; - goto yy193; + if (yych <= '\r') goto yy281; + if (yych <= '/') goto yy194; + if (yych <= '9') goto yy272; + goto yy194; } } else { if (yych <= '_') { - if (yych <= 'Z') goto yy271; - if (yych <= '^') goto yy193; - goto yy271; + if (yych <= 'Z') goto yy272; + if (yych <= '^') goto yy194; + goto yy272; } else { - if (yych <= '`') goto yy193; - if (yych <= 'z') goto yy271; - if (yych <= '~') goto yy193; - goto yy271; + if (yych <= '`') goto yy194; + if (yych <= 'z') goto yy272; + if (yych <= '~') goto yy194; + goto yy272; } } -yy273: - YYDEBUG(273, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '\'') goto yy193; - if (yych <= '/') goto yy282; - if (yych <= '9') goto yy193; - goto yy282; yy274: YYDEBUG(274, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '"') goto yy193; - if (yych <= '/') goto yy276; - if (yych <= '9') goto yy193; - goto yy276; + if (yych == '\'') goto yy194; + if (yych <= '/') goto yy283; + if (yych <= '9') goto yy194; + goto yy283; yy275: YYDEBUG(275, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == '"') goto yy194; + if (yych <= '/') goto yy277; + if (yych <= '9') goto yy194; + goto yy277; +yy276: + YYDEBUG(276, *YYCURSOR); ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; -yy276: - YYDEBUG(276, *YYCURSOR); +yy277: + YYDEBUG(277, *YYCURSOR); if (yych <= 'Z') { if (yych <= '/') { - if (yych != '"') goto yy193; + if (yych != '"') goto yy194; } else { - if (yych <= '9') goto yy275; - if (yych <= '@') goto yy193; - goto yy275; + if (yych <= '9') goto yy276; + if (yych <= '@') goto yy194; + goto yy276; } } else { if (yych <= '`') { - if (yych == '_') goto yy275; - goto yy193; + if (yych == '_') goto yy276; + goto yy194; } else { - if (yych <= 'z') goto yy275; - if (yych <= '~') goto yy193; - goto yy275; + if (yych <= 'z') goto yy276; + if (yych <= '~') goto yy194; + goto yy276; } } -yy277: - YYDEBUG(277, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '\n') goto yy278; - if (yych == '\r') goto yy280; - goto yy193; yy278: YYDEBUG(278, *YYCURSOR); - ++YYCURSOR; + yych = *++YYCURSOR; + if (yych == '\n') goto yy279; + if (yych == '\r') goto yy281; + goto yy194; yy279: YYDEBUG(279, *YYCURSOR); + ++YYCURSOR; +yy280: + YYDEBUG(280, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2106 "Zend/zend_language_scanner.l" +#line 2117 "Zend/zend_language_scanner.l" { char *s; int bprefix = (yytext[0] != '<') ? 1 : 0; - - /* save old heredoc label */ - Z_STRVAL_P(zendlval) = CG(heredoc); - Z_STRLEN_P(zendlval) = CG(heredoc_len); + zend_heredoc_label *heredoc_label = emalloc(sizeof(zend_heredoc_label)); CG(zend_lineno)++; - CG(heredoc_len) = yyleng-bprefix-3-1-(yytext[yyleng-2]=='\r'?1:0); + heredoc_label->length = yyleng-bprefix-3-1-(yytext[yyleng-2]=='\r'?1:0); s = yytext+bprefix+3; while ((*s == ' ') || (*s == '\t')) { s++; - CG(heredoc_len)--; + heredoc_label->length--; } if (*s == '\'') { s++; - CG(heredoc_len) -= 2; + heredoc_label->length -= 2; BEGIN(ST_NOWDOC); } else { if (*s == '"') { s++; - CG(heredoc_len) -= 2; + heredoc_label->length -= 2; } BEGIN(ST_HEREDOC); } - CG(heredoc) = estrndup(s, CG(heredoc_len)); + heredoc_label->label = estrndup(s, heredoc_label->length); /* Check for ending label on the next line */ - if (CG(heredoc_len) < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, s, CG(heredoc_len))) { - YYCTYPE *end = YYCURSOR + CG(heredoc_len); + if (heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, s, heredoc_label->length)) { + YYCTYPE *end = YYCURSOR + heredoc_label->length; if (*end == ';') { end++; @@ -3927,257 +3937,259 @@ int lex_scan(zval *zendlval TSRMLS_DC) } } + zend_ptr_stack_push(&SCNG(heredoc_label_stack), (void *) heredoc_label); + return T_START_HEREDOC; } -#line 3933 "Zend/zend_language_scanner.c" -yy280: - YYDEBUG(280, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '\n') goto yy278; - goto yy279; +#line 3945 "Zend/zend_language_scanner.c" yy281: YYDEBUG(281, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == '\n') goto yy279; + goto yy280; +yy282: + YYDEBUG(282, *YYCURSOR); ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; -yy282: - YYDEBUG(282, *YYCURSOR); +yy283: + YYDEBUG(283, *YYCURSOR); if (yych <= 'Z') { if (yych <= '/') { - if (yych == '\'') goto yy277; - goto yy193; + if (yych == '\'') goto yy278; + goto yy194; } else { - if (yych <= '9') goto yy281; - if (yych <= '@') goto yy193; - goto yy281; + if (yych <= '9') goto yy282; + if (yych <= '@') goto yy194; + goto yy282; } } else { if (yych <= '`') { - if (yych == '_') goto yy281; - goto yy193; + if (yych == '_') goto yy282; + goto yy194; } else { - if (yych <= 'z') goto yy281; - if (yych <= '~') goto yy193; - goto yy281; + if (yych <= 'z') goto yy282; + if (yych <= '~') goto yy194; + goto yy282; } } -yy283: - YYDEBUG(283, *YYCURSOR); - yych = *++YYCURSOR; - if (yych != '=') goto yy259; +yy284: YYDEBUG(284, *YYCURSOR); - ++YYCURSOR; + yych = *++YYCURSOR; + if (yych != '=') goto yy260; YYDEBUG(285, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(286, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1348 "Zend/zend_language_scanner.l" +#line 1358 "Zend/zend_language_scanner.l" { return T_IS_NOT_IDENTICAL; } -#line 3977 "Zend/zend_language_scanner.c" -yy286: - YYDEBUG(286, *YYCURSOR); - ++YYCURSOR; +#line 3989 "Zend/zend_language_scanner.c" +yy287: YYDEBUG(287, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(288, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1368 "Zend/zend_language_scanner.l" +#line 1378 "Zend/zend_language_scanner.l" { return T_PLUS_EQUAL; } -#line 3987 "Zend/zend_language_scanner.c" -yy288: - YYDEBUG(288, *YYCURSOR); - ++YYCURSOR; +#line 3999 "Zend/zend_language_scanner.c" +yy289: YYDEBUG(289, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(290, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1336 "Zend/zend_language_scanner.l" +#line 1346 "Zend/zend_language_scanner.l" { return T_INC; } -#line 3997 "Zend/zend_language_scanner.c" -yy290: - YYDEBUG(290, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'S') goto yy291; - if (yych != 's') goto yy186; +#line 4009 "Zend/zend_language_scanner.c" yy291: YYDEBUG(291, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy292; - if (yych != 't') goto yy186; + if (yych == 'S') goto yy292; + if (yych != 's') goto yy187; yy292: YYDEBUG(292, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'T') goto yy293; + if (yych != 't') goto yy187; +yy293: + YYDEBUG(293, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(293, *YYCURSOR); + YYDEBUG(294, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1324 "Zend/zend_language_scanner.l" +#line 1334 "Zend/zend_language_scanner.l" { return T_LIST; } -#line 4020 "Zend/zend_language_scanner.c" -yy294: - YYDEBUG(294, *YYCURSOR); - ++YYCURSOR; - if ((yych = *YYCURSOR) == '=') goto yy298; +#line 4032 "Zend/zend_language_scanner.c" +yy295: YYDEBUG(295, *YYCURSOR); + ++YYCURSOR; + if ((yych = *YYCURSOR) == '=') goto yy299; + YYDEBUG(296, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1352 "Zend/zend_language_scanner.l" +#line 1362 "Zend/zend_language_scanner.l" { return T_IS_EQUAL; } -#line 4031 "Zend/zend_language_scanner.c" -yy296: - YYDEBUG(296, *YYCURSOR); - ++YYCURSOR; +#line 4043 "Zend/zend_language_scanner.c" +yy297: YYDEBUG(297, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(298, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1320 "Zend/zend_language_scanner.l" +#line 1330 "Zend/zend_language_scanner.l" { return T_DOUBLE_ARROW; } -#line 4041 "Zend/zend_language_scanner.c" -yy298: - YYDEBUG(298, *YYCURSOR); - ++YYCURSOR; +#line 4053 "Zend/zend_language_scanner.c" +yy299: YYDEBUG(299, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(300, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1344 "Zend/zend_language_scanner.l" +#line 1354 "Zend/zend_language_scanner.l" { return T_IS_IDENTICAL; } -#line 4051 "Zend/zend_language_scanner.c" -yy300: - YYDEBUG(300, *YYCURSOR); +#line 4063 "Zend/zend_language_scanner.c" +yy301: + YYDEBUG(301, *YYCURSOR); yych = *++YYCURSOR; YYDEBUG(-1, yych); switch (yych) { case 'C': - case 'c': goto yy302; + case 'c': goto yy303; case 'D': - case 'd': goto yy307; + case 'd': goto yy308; case 'F': - case 'f': goto yy304; + case 'f': goto yy305; case 'H': - case 'h': goto yy301; + case 'h': goto yy302; case 'L': - case 'l': goto yy306; + case 'l': goto yy307; case 'M': - case 'm': goto yy305; + case 'm': goto yy306; case 'N': - case 'n': goto yy308; + case 'n': goto yy309; case 'T': - case 't': goto yy303; - default: goto yy186; + case 't': goto yy304; + default: goto yy187; } -yy301: - YYDEBUG(301, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'A') goto yy369; - if (yych == 'a') goto yy369; - goto yy186; yy302: YYDEBUG(302, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy362; - if (yych == 'l') goto yy362; - goto yy186; + if (yych == 'A') goto yy370; + if (yych == 'a') goto yy370; + goto yy187; yy303: YYDEBUG(303, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy355; - if (yych == 'r') goto yy355; - goto yy186; + if (yych == 'L') goto yy363; + if (yych == 'l') goto yy363; + goto yy187; yy304: YYDEBUG(304, *YYCURSOR); yych = *++YYCURSOR; + if (yych == 'R') goto yy356; + if (yych == 'r') goto yy356; + goto yy187; +yy305: + YYDEBUG(305, *YYCURSOR); + yych = *++YYCURSOR; if (yych <= 'U') { - if (yych == 'I') goto yy339; - if (yych <= 'T') goto yy186; - goto yy340; + if (yych == 'I') goto yy340; + if (yych <= 'T') goto yy187; + goto yy341; } else { if (yych <= 'i') { - if (yych <= 'h') goto yy186; - goto yy339; + if (yych <= 'h') goto yy187; + goto yy340; } else { - if (yych == 'u') goto yy340; - goto yy186; + if (yych == 'u') goto yy341; + goto yy187; } } -yy305: - YYDEBUG(305, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'E') goto yy331; - if (yych == 'e') goto yy331; - goto yy186; yy306: YYDEBUG(306, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy325; - if (yych == 'i') goto yy325; - goto yy186; + if (yych == 'E') goto yy332; + if (yych == 'e') goto yy332; + goto yy187; yy307: YYDEBUG(307, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy320; - if (yych == 'i') goto yy320; - goto yy186; + if (yych == 'I') goto yy326; + if (yych == 'i') goto yy326; + goto yy187; yy308: YYDEBUG(308, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy309; - if (yych != 'a') goto yy186; + if (yych == 'I') goto yy321; + if (yych == 'i') goto yy321; + goto yy187; yy309: YYDEBUG(309, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'M') goto yy310; - if (yych != 'm') goto yy186; + if (yych == 'A') goto yy310; + if (yych != 'a') goto yy187; yy310: YYDEBUG(310, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy311; - if (yych != 'e') goto yy186; + if (yych == 'M') goto yy311; + if (yych != 'm') goto yy187; yy311: YYDEBUG(311, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'S') goto yy312; - if (yych != 's') goto yy186; + if (yych == 'E') goto yy312; + if (yych != 'e') goto yy187; yy312: YYDEBUG(312, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'P') goto yy313; - if (yych != 'p') goto yy186; + if (yych == 'S') goto yy313; + if (yych != 's') goto yy187; yy313: YYDEBUG(313, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy314; - if (yych != 'a') goto yy186; + if (yych == 'P') goto yy314; + if (yych != 'p') goto yy187; yy314: YYDEBUG(314, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy315; - if (yych != 'c') goto yy186; + if (yych == 'A') goto yy315; + if (yych != 'a') goto yy187; yy315: YYDEBUG(315, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy316; - if (yych != 'e') goto yy186; + if (yych == 'C') goto yy316; + if (yych != 'c') goto yy187; yy316: YYDEBUG(316, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych == 'E') goto yy317; + if (yych != 'e') goto yy187; +yy317: YYDEBUG(317, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych != '_') goto yy187; YYDEBUG(318, *YYCURSOR); + yych = *++YYCURSOR; + if (yych != '_') goto yy187; + YYDEBUG(319, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(319, *YYCURSOR); + YYDEBUG(320, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1707 "Zend/zend_language_scanner.l" +#line 1718 "Zend/zend_language_scanner.l" { if (CG(current_namespace)) { *zendlval = *CG(current_namespace); @@ -4187,27 +4199,27 @@ int lex_scan(zval *zendlval TSRMLS_DC) } return T_NS_C; } -#line 4191 "Zend/zend_language_scanner.c" -yy320: - YYDEBUG(320, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'R') goto yy321; - if (yych != 'r') goto yy186; +#line 4203 "Zend/zend_language_scanner.c" yy321: YYDEBUG(321, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych == 'R') goto yy322; + if (yych != 'r') goto yy187; +yy322: YYDEBUG(322, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych != '_') goto yy187; YYDEBUG(323, *YYCURSOR); + yych = *++YYCURSOR; + if (yych != '_') goto yy187; + YYDEBUG(324, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(324, *YYCURSOR); + YYDEBUG(325, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1680 "Zend/zend_language_scanner.l" +#line 1691 "Zend/zend_language_scanner.l" { char *filename = zend_get_compiled_filename(TSRMLS_C); const size_t filename_len = strlen(filename); @@ -4234,73 +4246,73 @@ int lex_scan(zval *zendlval TSRMLS_DC) zendlval->type = IS_STRING; return T_DIR; } -#line 4238 "Zend/zend_language_scanner.c" -yy325: - YYDEBUG(325, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'N') goto yy326; - if (yych != 'n') goto yy186; +#line 4250 "Zend/zend_language_scanner.c" yy326: YYDEBUG(326, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy327; - if (yych != 'e') goto yy186; + if (yych == 'N') goto yy327; + if (yych != 'n') goto yy187; yy327: YYDEBUG(327, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych == 'E') goto yy328; + if (yych != 'e') goto yy187; +yy328: YYDEBUG(328, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych != '_') goto yy187; YYDEBUG(329, *YYCURSOR); + yych = *++YYCURSOR; + if (yych != '_') goto yy187; + YYDEBUG(330, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(330, *YYCURSOR); + YYDEBUG(331, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1662 "Zend/zend_language_scanner.l" +#line 1673 "Zend/zend_language_scanner.l" { zendlval->value.lval = CG(zend_lineno); zendlval->type = IS_LONG; return T_LINE; } -#line 4269 "Zend/zend_language_scanner.c" -yy331: - YYDEBUG(331, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'T') goto yy332; - if (yych != 't') goto yy186; +#line 4281 "Zend/zend_language_scanner.c" yy332: YYDEBUG(332, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'H') goto yy333; - if (yych != 'h') goto yy186; + if (yych == 'T') goto yy333; + if (yych != 't') goto yy187; yy333: YYDEBUG(333, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy334; - if (yych != 'o') goto yy186; + if (yych == 'H') goto yy334; + if (yych != 'h') goto yy187; yy334: YYDEBUG(334, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'D') goto yy335; - if (yych != 'd') goto yy186; + if (yych == 'O') goto yy335; + if (yych != 'o') goto yy187; yy335: YYDEBUG(335, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych == 'D') goto yy336; + if (yych != 'd') goto yy187; +yy336: YYDEBUG(336, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych != '_') goto yy187; YYDEBUG(337, *YYCURSOR); + yych = *++YYCURSOR; + if (yych != '_') goto yy187; + YYDEBUG(338, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(338, *YYCURSOR); + YYDEBUG(339, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1641 "Zend/zend_language_scanner.l" +#line 1652 "Zend/zend_language_scanner.l" { const char *class_name = CG(active_class_entry) ? CG(active_class_entry)->name : NULL; const char *func_name = CG(active_op_array)? CG(active_op_array)->function_name : NULL; @@ -4321,58 +4333,58 @@ int lex_scan(zval *zendlval TSRMLS_DC) zendlval->type = IS_STRING; return T_METHOD_C; } -#line 4325 "Zend/zend_language_scanner.c" -yy339: - YYDEBUG(339, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'L') goto yy350; - if (yych == 'l') goto yy350; - goto yy186; +#line 4337 "Zend/zend_language_scanner.c" yy340: YYDEBUG(340, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy341; - if (yych != 'n') goto yy186; + if (yych == 'L') goto yy351; + if (yych == 'l') goto yy351; + goto yy187; yy341: YYDEBUG(341, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy342; - if (yych != 'c') goto yy186; + if (yych == 'N') goto yy342; + if (yych != 'n') goto yy187; yy342: YYDEBUG(342, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy343; - if (yych != 't') goto yy186; + if (yych == 'C') goto yy343; + if (yych != 'c') goto yy187; yy343: YYDEBUG(343, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy344; - if (yych != 'i') goto yy186; + if (yych == 'T') goto yy344; + if (yych != 't') goto yy187; yy344: YYDEBUG(344, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy345; - if (yych != 'o') goto yy186; + if (yych == 'I') goto yy345; + if (yych != 'i') goto yy187; yy345: YYDEBUG(345, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy346; - if (yych != 'n') goto yy186; + if (yych == 'O') goto yy346; + if (yych != 'o') goto yy187; yy346: YYDEBUG(346, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych == 'N') goto yy347; + if (yych != 'n') goto yy187; +yy347: YYDEBUG(347, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych != '_') goto yy187; YYDEBUG(348, *YYCURSOR); + yych = *++YYCURSOR; + if (yych != '_') goto yy187; + YYDEBUG(349, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(349, *YYCURSOR); + YYDEBUG(350, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1625 "Zend/zend_language_scanner.l" +#line 1636 "Zend/zend_language_scanner.l" { const char *func_name = NULL; @@ -4388,27 +4400,27 @@ int lex_scan(zval *zendlval TSRMLS_DC) zendlval->type = IS_STRING; return T_FUNC_C; } -#line 4392 "Zend/zend_language_scanner.c" -yy350: - YYDEBUG(350, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'E') goto yy351; - if (yych != 'e') goto yy186; +#line 4404 "Zend/zend_language_scanner.c" yy351: YYDEBUG(351, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych == 'E') goto yy352; + if (yych != 'e') goto yy187; +yy352: YYDEBUG(352, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych != '_') goto yy187; YYDEBUG(353, *YYCURSOR); + yych = *++YYCURSOR; + if (yych != '_') goto yy187; + YYDEBUG(354, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(354, *YYCURSOR); + YYDEBUG(355, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1668 "Zend/zend_language_scanner.l" +#line 1679 "Zend/zend_language_scanner.l" { char *filename = zend_get_compiled_filename(TSRMLS_C); @@ -4420,37 +4432,37 @@ int lex_scan(zval *zendlval TSRMLS_DC) zendlval->type = IS_STRING; return T_FILE; } -#line 4424 "Zend/zend_language_scanner.c" -yy355: - YYDEBUG(355, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'A') goto yy356; - if (yych != 'a') goto yy186; +#line 4436 "Zend/zend_language_scanner.c" yy356: YYDEBUG(356, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy357; - if (yych != 'i') goto yy186; + if (yych == 'A') goto yy357; + if (yych != 'a') goto yy187; yy357: YYDEBUG(357, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy358; - if (yych != 't') goto yy186; + if (yych == 'I') goto yy358; + if (yych != 'i') goto yy187; yy358: YYDEBUG(358, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych == 'T') goto yy359; + if (yych != 't') goto yy187; +yy359: YYDEBUG(359, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych != '_') goto yy187; YYDEBUG(360, *YYCURSOR); + yych = *++YYCURSOR; + if (yych != '_') goto yy187; + YYDEBUG(361, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(361, *YYCURSOR); + YYDEBUG(362, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1605 "Zend/zend_language_scanner.l" +#line 1616 "Zend/zend_language_scanner.l" { const char *trait_name = NULL; @@ -4470,37 +4482,37 @@ int lex_scan(zval *zendlval TSRMLS_DC) return T_TRAIT_C; } -#line 4474 "Zend/zend_language_scanner.c" -yy362: - YYDEBUG(362, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'A') goto yy363; - if (yych != 'a') goto yy186; +#line 4486 "Zend/zend_language_scanner.c" yy363: YYDEBUG(363, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'S') goto yy364; - if (yych != 's') goto yy186; + if (yych == 'A') goto yy364; + if (yych != 'a') goto yy187; yy364: YYDEBUG(364, *YYCURSOR); yych = *++YYCURSOR; if (yych == 'S') goto yy365; - if (yych != 's') goto yy186; + if (yych != 's') goto yy187; yy365: YYDEBUG(365, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych == 'S') goto yy366; + if (yych != 's') goto yy187; +yy366: YYDEBUG(366, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych != '_') goto yy187; YYDEBUG(367, *YYCURSOR); + yych = *++YYCURSOR; + if (yych != '_') goto yy187; + YYDEBUG(368, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(368, *YYCURSOR); + YYDEBUG(369, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1578 "Zend/zend_language_scanner.l" +#line 1589 "Zend/zend_language_scanner.l" { const char *class_name = NULL; @@ -4527,2648 +4539,2709 @@ int lex_scan(zval *zendlval TSRMLS_DC) } return T_CLASS_C; } -#line 4531 "Zend/zend_language_scanner.c" -yy369: - YYDEBUG(369, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'L') goto yy370; - if (yych != 'l') goto yy186; +#line 4543 "Zend/zend_language_scanner.c" yy370: YYDEBUG(370, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy371; - if (yych != 't') goto yy186; + if (yych == 'L') goto yy371; + if (yych != 'l') goto yy187; yy371: YYDEBUG(371, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '_') goto yy186; + if (yych == 'T') goto yy372; + if (yych != 't') goto yy187; +yy372: YYDEBUG(372, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy373; - if (yych != 'c') goto yy186; -yy373: + if (yych != '_') goto yy187; YYDEBUG(373, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy374; - if (yych != 'o') goto yy186; + if (yych == 'C') goto yy374; + if (yych != 'c') goto yy187; yy374: YYDEBUG(374, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'M') goto yy375; - if (yych != 'm') goto yy186; + if (yych == 'O') goto yy375; + if (yych != 'o') goto yy187; yy375: YYDEBUG(375, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'P') goto yy376; - if (yych != 'p') goto yy186; + if (yych == 'M') goto yy376; + if (yych != 'm') goto yy187; yy376: YYDEBUG(376, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy377; - if (yych != 'i') goto yy186; + if (yych == 'P') goto yy377; + if (yych != 'p') goto yy187; yy377: YYDEBUG(377, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy378; - if (yych != 'l') goto yy186; + if (yych == 'I') goto yy378; + if (yych != 'i') goto yy187; yy378: YYDEBUG(378, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy379; - if (yych != 'e') goto yy186; + if (yych == 'L') goto yy379; + if (yych != 'l') goto yy187; yy379: YYDEBUG(379, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy380; - if (yych != 'r') goto yy186; + if (yych == 'E') goto yy380; + if (yych != 'e') goto yy187; yy380: YYDEBUG(380, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'R') goto yy381; + if (yych != 'r') goto yy187; +yy381: + YYDEBUG(381, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(381, *YYCURSOR); + YYDEBUG(382, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1288 "Zend/zend_language_scanner.l" +#line 1298 "Zend/zend_language_scanner.l" { return T_HALT_COMPILER; } -#line 4597 "Zend/zend_language_scanner.c" -yy382: - YYDEBUG(382, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'S') goto yy386; - if (yych == 's') goto yy386; - goto yy186; +#line 4609 "Zend/zend_language_scanner.c" yy383: YYDEBUG(383, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy384; - if (yych != 'e') goto yy186; + if (yych == 'S') goto yy387; + if (yych == 's') goto yy387; + goto yy187; yy384: YYDEBUG(384, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'E') goto yy385; + if (yych != 'e') goto yy187; +yy385: + YYDEBUG(385, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(385, *YYCURSOR); + YYDEBUG(386, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1268 "Zend/zend_language_scanner.l" +#line 1278 "Zend/zend_language_scanner.l" { return T_USE; } -#line 4621 "Zend/zend_language_scanner.c" -yy386: - YYDEBUG(386, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'E') goto yy387; - if (yych != 'e') goto yy186; +#line 4633 "Zend/zend_language_scanner.c" yy387: YYDEBUG(387, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy388; - if (yych != 't') goto yy186; + if (yych == 'E') goto yy388; + if (yych != 'e') goto yy187; yy388: YYDEBUG(388, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'T') goto yy389; + if (yych != 't') goto yy187; +yy389: + YYDEBUG(389, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(389, *YYCURSOR); + YYDEBUG(390, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1316 "Zend/zend_language_scanner.l" +#line 1326 "Zend/zend_language_scanner.l" { return T_UNSET; } -#line 4644 "Zend/zend_language_scanner.c" -yy390: - YYDEBUG(390, *YYCURSOR); +#line 4656 "Zend/zend_language_scanner.c" +yy391: + YYDEBUG(391, *YYCURSOR); ++YYCURSOR; YYFILL(7); yych = *YYCURSOR; -yy391: - YYDEBUG(391, *YYCURSOR); +yy392: + YYDEBUG(392, *YYCURSOR); if (yych <= 'S') { if (yych <= 'D') { if (yych <= ' ') { - if (yych == '\t') goto yy390; - if (yych <= 0x1F) goto yy193; - goto yy390; + if (yych == '\t') goto yy391; + if (yych <= 0x1F) goto yy194; + goto yy391; } else { if (yych <= 'A') { - if (yych <= '@') goto yy193; - goto yy395; + if (yych <= '@') goto yy194; + goto yy396; } else { - if (yych <= 'B') goto yy393; - if (yych <= 'C') goto yy193; - goto yy398; + if (yych <= 'B') goto yy394; + if (yych <= 'C') goto yy194; + goto yy399; } } } else { if (yych <= 'I') { - if (yych == 'F') goto yy399; - if (yych <= 'H') goto yy193; - goto yy400; + if (yych == 'F') goto yy400; + if (yych <= 'H') goto yy194; + goto yy401; } else { if (yych <= 'O') { - if (yych <= 'N') goto yy193; - goto yy394; + if (yych <= 'N') goto yy194; + goto yy395; } else { - if (yych <= 'Q') goto yy193; - if (yych <= 'R') goto yy397; - goto yy396; + if (yych <= 'Q') goto yy194; + if (yych <= 'R') goto yy398; + goto yy397; } } } } else { if (yych <= 'f') { if (yych <= 'a') { - if (yych == 'U') goto yy392; - if (yych <= '`') goto yy193; - goto yy395; + if (yych == 'U') goto yy393; + if (yych <= '`') goto yy194; + goto yy396; } else { if (yych <= 'c') { - if (yych <= 'b') goto yy393; - goto yy193; + if (yych <= 'b') goto yy394; + goto yy194; } else { - if (yych <= 'd') goto yy398; - if (yych <= 'e') goto yy193; - goto yy399; + if (yych <= 'd') goto yy399; + if (yych <= 'e') goto yy194; + goto yy400; } } } else { if (yych <= 'q') { if (yych <= 'i') { - if (yych <= 'h') goto yy193; - goto yy400; + if (yych <= 'h') goto yy194; + goto yy401; } else { - if (yych == 'o') goto yy394; - goto yy193; + if (yych == 'o') goto yy395; + goto yy194; } } else { if (yych <= 's') { - if (yych <= 'r') goto yy397; - goto yy396; + if (yych <= 'r') goto yy398; + goto yy397; } else { - if (yych != 'u') goto yy193; + if (yych != 'u') goto yy194; } } } } -yy392: - YYDEBUG(392, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'N') goto yy459; - if (yych == 'n') goto yy459; - goto yy193; yy393: YYDEBUG(393, *YYCURSOR); yych = *++YYCURSOR; + if (yych == 'N') goto yy460; + if (yych == 'n') goto yy460; + goto yy194; +yy394: + YYDEBUG(394, *YYCURSOR); + yych = *++YYCURSOR; if (yych <= 'O') { - if (yych == 'I') goto yy446; - if (yych <= 'N') goto yy193; - goto yy447; + if (yych == 'I') goto yy447; + if (yych <= 'N') goto yy194; + goto yy448; } else { if (yych <= 'i') { - if (yych <= 'h') goto yy193; - goto yy446; + if (yych <= 'h') goto yy194; + goto yy447; } else { - if (yych == 'o') goto yy447; - goto yy193; + if (yych == 'o') goto yy448; + goto yy194; } } -yy394: - YYDEBUG(394, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'B') goto yy438; - if (yych == 'b') goto yy438; - goto yy193; yy395: YYDEBUG(395, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy431; - if (yych == 'r') goto yy431; - goto yy193; + if (yych == 'B') goto yy439; + if (yych == 'b') goto yy439; + goto yy194; yy396: YYDEBUG(396, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy423; - if (yych == 't') goto yy423; - goto yy193; + if (yych == 'R') goto yy432; + if (yych == 'r') goto yy432; + goto yy194; yy397: YYDEBUG(397, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy421; - if (yych == 'e') goto yy421; - goto yy193; + if (yych == 'T') goto yy424; + if (yych == 't') goto yy424; + goto yy194; yy398: YYDEBUG(398, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy417; - if (yych == 'o') goto yy417; - goto yy193; + if (yych == 'E') goto yy422; + if (yych == 'e') goto yy422; + goto yy194; yy399: YYDEBUG(399, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy410; - if (yych == 'l') goto yy410; - goto yy193; + if (yych == 'O') goto yy418; + if (yych == 'o') goto yy418; + goto yy194; yy400: YYDEBUG(400, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy401; - if (yych != 'n') goto yy193; + if (yych == 'L') goto yy411; + if (yych == 'l') goto yy411; + goto yy194; yy401: YYDEBUG(401, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy402; - if (yych != 't') goto yy193; + if (yych == 'N') goto yy402; + if (yych != 'n') goto yy194; yy402: YYDEBUG(402, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy403; - if (yych != 'e') goto yy405; + if (yych == 'T') goto yy403; + if (yych != 't') goto yy194; yy403: YYDEBUG(403, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'G') goto yy408; - if (yych == 'g') goto yy408; - goto yy193; + if (yych == 'E') goto yy404; + if (yych != 'e') goto yy406; yy404: YYDEBUG(404, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'G') goto yy409; + if (yych == 'g') goto yy409; + goto yy194; +yy405: + YYDEBUG(405, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy405: - YYDEBUG(405, *YYCURSOR); +yy406: + YYDEBUG(406, *YYCURSOR); if (yych <= 0x1F) { - if (yych == '\t') goto yy404; - goto yy193; + if (yych == '\t') goto yy405; + goto yy194; } else { - if (yych <= ' ') goto yy404; - if (yych != ')') goto yy193; + if (yych <= ' ') goto yy405; + if (yych != ')') goto yy194; } - YYDEBUG(406, *YYCURSOR); - ++YYCURSOR; YYDEBUG(407, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(408, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1216 "Zend/zend_language_scanner.l" +#line 1226 "Zend/zend_language_scanner.l" { return T_INT_CAST; } -#line 4820 "Zend/zend_language_scanner.c" -yy408: - YYDEBUG(408, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'E') goto yy409; - if (yych != 'e') goto yy193; +#line 4832 "Zend/zend_language_scanner.c" yy409: YYDEBUG(409, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy404; - if (yych == 'r') goto yy404; - goto yy193; + if (yych == 'E') goto yy410; + if (yych != 'e') goto yy194; yy410: YYDEBUG(410, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy411; - if (yych != 'o') goto yy193; + if (yych == 'R') goto yy405; + if (yych == 'r') goto yy405; + goto yy194; yy411: YYDEBUG(411, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy412; - if (yych != 'a') goto yy193; + if (yych == 'O') goto yy412; + if (yych != 'o') goto yy194; yy412: YYDEBUG(412, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy413; - if (yych != 't') goto yy193; + if (yych == 'A') goto yy413; + if (yych != 'a') goto yy194; yy413: YYDEBUG(413, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'T') goto yy414; + if (yych != 't') goto yy194; +yy414: + YYDEBUG(414, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(414, *YYCURSOR); + YYDEBUG(415, *YYCURSOR); if (yych <= 0x1F) { - if (yych == '\t') goto yy413; - goto yy193; + if (yych == '\t') goto yy414; + goto yy194; } else { - if (yych <= ' ') goto yy413; - if (yych != ')') goto yy193; + if (yych <= ' ') goto yy414; + if (yych != ')') goto yy194; } - YYDEBUG(415, *YYCURSOR); - ++YYCURSOR; YYDEBUG(416, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(417, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1220 "Zend/zend_language_scanner.l" +#line 1230 "Zend/zend_language_scanner.l" { return T_DOUBLE_CAST; } -#line 4868 "Zend/zend_language_scanner.c" -yy417: - YYDEBUG(417, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'U') goto yy418; - if (yych != 'u') goto yy193; +#line 4880 "Zend/zend_language_scanner.c" yy418: YYDEBUG(418, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'B') goto yy419; - if (yych != 'b') goto yy193; + if (yych == 'U') goto yy419; + if (yych != 'u') goto yy194; yy419: YYDEBUG(419, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy420; - if (yych != 'l') goto yy193; + if (yych == 'B') goto yy420; + if (yych != 'b') goto yy194; yy420: YYDEBUG(420, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy413; - if (yych == 'e') goto yy413; - goto yy193; + if (yych == 'L') goto yy421; + if (yych != 'l') goto yy194; yy421: YYDEBUG(421, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy422; - if (yych != 'a') goto yy193; + if (yych == 'E') goto yy414; + if (yych == 'e') goto yy414; + goto yy194; yy422: YYDEBUG(422, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy413; - if (yych == 'l') goto yy413; - goto yy193; + if (yych == 'A') goto yy423; + if (yych != 'a') goto yy194; yy423: YYDEBUG(423, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy424; - if (yych != 'r') goto yy193; + if (yych == 'L') goto yy414; + if (yych == 'l') goto yy414; + goto yy194; yy424: YYDEBUG(424, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy425; - if (yych != 'i') goto yy193; + if (yych == 'R') goto yy425; + if (yych != 'r') goto yy194; yy425: YYDEBUG(425, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy426; - if (yych != 'n') goto yy193; + if (yych == 'I') goto yy426; + if (yych != 'i') goto yy194; yy426: YYDEBUG(426, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'G') goto yy427; - if (yych != 'g') goto yy193; + if (yych == 'N') goto yy427; + if (yych != 'n') goto yy194; yy427: YYDEBUG(427, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'G') goto yy428; + if (yych != 'g') goto yy194; +yy428: + YYDEBUG(428, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(428, *YYCURSOR); + YYDEBUG(429, *YYCURSOR); if (yych <= 0x1F) { - if (yych == '\t') goto yy427; - goto yy193; + if (yych == '\t') goto yy428; + goto yy194; } else { - if (yych <= ' ') goto yy427; - if (yych != ')') goto yy193; + if (yych <= ' ') goto yy428; + if (yych != ')') goto yy194; } - YYDEBUG(429, *YYCURSOR); - ++YYCURSOR; YYDEBUG(430, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(431, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1224 "Zend/zend_language_scanner.l" +#line 1234 "Zend/zend_language_scanner.l" { return T_STRING_CAST; } -#line 4942 "Zend/zend_language_scanner.c" -yy431: - YYDEBUG(431, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'R') goto yy432; - if (yych != 'r') goto yy193; +#line 4954 "Zend/zend_language_scanner.c" yy432: YYDEBUG(432, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy433; - if (yych != 'a') goto yy193; + if (yych == 'R') goto yy433; + if (yych != 'r') goto yy194; yy433: YYDEBUG(433, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'Y') goto yy434; - if (yych != 'y') goto yy193; + if (yych == 'A') goto yy434; + if (yych != 'a') goto yy194; yy434: YYDEBUG(434, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'Y') goto yy435; + if (yych != 'y') goto yy194; +yy435: + YYDEBUG(435, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(435, *YYCURSOR); + YYDEBUG(436, *YYCURSOR); if (yych <= 0x1F) { - if (yych == '\t') goto yy434; - goto yy193; + if (yych == '\t') goto yy435; + goto yy194; } else { - if (yych <= ' ') goto yy434; - if (yych != ')') goto yy193; + if (yych <= ' ') goto yy435; + if (yych != ')') goto yy194; } - YYDEBUG(436, *YYCURSOR); - ++YYCURSOR; YYDEBUG(437, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(438, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1228 "Zend/zend_language_scanner.l" +#line 1238 "Zend/zend_language_scanner.l" { return T_ARRAY_CAST; } -#line 4979 "Zend/zend_language_scanner.c" -yy438: - YYDEBUG(438, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'J') goto yy439; - if (yych != 'j') goto yy193; +#line 4991 "Zend/zend_language_scanner.c" yy439: YYDEBUG(439, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy440; - if (yych != 'e') goto yy193; + if (yych == 'J') goto yy440; + if (yych != 'j') goto yy194; yy440: YYDEBUG(440, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy441; - if (yych != 'c') goto yy193; + if (yych == 'E') goto yy441; + if (yych != 'e') goto yy194; yy441: YYDEBUG(441, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy442; - if (yych != 't') goto yy193; + if (yych == 'C') goto yy442; + if (yych != 'c') goto yy194; yy442: YYDEBUG(442, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'T') goto yy443; + if (yych != 't') goto yy194; +yy443: + YYDEBUG(443, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(443, *YYCURSOR); + YYDEBUG(444, *YYCURSOR); if (yych <= 0x1F) { - if (yych == '\t') goto yy442; - goto yy193; + if (yych == '\t') goto yy443; + goto yy194; } else { - if (yych <= ' ') goto yy442; - if (yych != ')') goto yy193; + if (yych <= ' ') goto yy443; + if (yych != ')') goto yy194; } - YYDEBUG(444, *YYCURSOR); - ++YYCURSOR; YYDEBUG(445, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(446, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1232 "Zend/zend_language_scanner.l" +#line 1242 "Zend/zend_language_scanner.l" { return T_OBJECT_CAST; } -#line 5021 "Zend/zend_language_scanner.c" -yy446: - YYDEBUG(446, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'N') goto yy456; - if (yych == 'n') goto yy456; - goto yy193; +#line 5033 "Zend/zend_language_scanner.c" yy447: YYDEBUG(447, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy448; - if (yych != 'o') goto yy193; + if (yych == 'N') goto yy457; + if (yych == 'n') goto yy457; + goto yy194; yy448: YYDEBUG(448, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy449; - if (yych != 'l') goto yy193; + if (yych == 'O') goto yy449; + if (yych != 'o') goto yy194; yy449: YYDEBUG(449, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy454; - if (yych == 'e') goto yy454; - goto yy451; + if (yych == 'L') goto yy450; + if (yych != 'l') goto yy194; yy450: YYDEBUG(450, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'E') goto yy455; + if (yych == 'e') goto yy455; + goto yy452; +yy451: + YYDEBUG(451, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy451: - YYDEBUG(451, *YYCURSOR); +yy452: + YYDEBUG(452, *YYCURSOR); if (yych <= 0x1F) { - if (yych == '\t') goto yy450; - goto yy193; + if (yych == '\t') goto yy451; + goto yy194; } else { - if (yych <= ' ') goto yy450; - if (yych != ')') goto yy193; + if (yych <= ' ') goto yy451; + if (yych != ')') goto yy194; } - YYDEBUG(452, *YYCURSOR); - ++YYCURSOR; YYDEBUG(453, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(454, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1236 "Zend/zend_language_scanner.l" +#line 1246 "Zend/zend_language_scanner.l" { return T_BOOL_CAST; } -#line 5066 "Zend/zend_language_scanner.c" -yy454: - YYDEBUG(454, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'A') goto yy455; - if (yych != 'a') goto yy193; +#line 5078 "Zend/zend_language_scanner.c" yy455: YYDEBUG(455, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy450; - if (yych == 'n') goto yy450; - goto yy193; + if (yych == 'A') goto yy456; + if (yych != 'a') goto yy194; yy456: YYDEBUG(456, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy457; - if (yych != 'a') goto yy193; + if (yych == 'N') goto yy451; + if (yych == 'n') goto yy451; + goto yy194; yy457: YYDEBUG(457, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy458; - if (yych != 'r') goto yy193; + if (yych == 'A') goto yy458; + if (yych != 'a') goto yy194; yy458: YYDEBUG(458, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'Y') goto yy427; - if (yych == 'y') goto yy427; - goto yy193; + if (yych == 'R') goto yy459; + if (yych != 'r') goto yy194; yy459: YYDEBUG(459, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'S') goto yy460; - if (yych != 's') goto yy193; + if (yych == 'Y') goto yy428; + if (yych == 'y') goto yy428; + goto yy194; yy460: YYDEBUG(460, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy461; - if (yych != 'e') goto yy193; + if (yych == 'S') goto yy461; + if (yych != 's') goto yy194; yy461: YYDEBUG(461, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy462; - if (yych != 't') goto yy193; + if (yych == 'E') goto yy462; + if (yych != 'e') goto yy194; yy462: YYDEBUG(462, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'T') goto yy463; + if (yych != 't') goto yy194; +yy463: + YYDEBUG(463, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(463, *YYCURSOR); + YYDEBUG(464, *YYCURSOR); if (yych <= 0x1F) { - if (yych == '\t') goto yy462; - goto yy193; + if (yych == '\t') goto yy463; + goto yy194; } else { - if (yych <= ' ') goto yy462; - if (yych != ')') goto yy193; + if (yych <= ' ') goto yy463; + if (yych != ')') goto yy194; } - YYDEBUG(464, *YYCURSOR); - ++YYCURSOR; YYDEBUG(465, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(466, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1240 "Zend/zend_language_scanner.l" +#line 1250 "Zend/zend_language_scanner.l" { return T_UNSET_CAST; } -#line 5130 "Zend/zend_language_scanner.c" -yy466: - YYDEBUG(466, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'R') goto yy467; - if (yych != 'r') goto yy186; +#line 5142 "Zend/zend_language_scanner.c" yy467: YYDEBUG(467, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'R') goto yy468; + if (yych != 'r') goto yy187; +yy468: + YYDEBUG(468, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(468, *YYCURSOR); + YYDEBUG(469, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1212 "Zend/zend_language_scanner.l" +#line 1222 "Zend/zend_language_scanner.l" { return T_VAR; } -#line 5148 "Zend/zend_language_scanner.c" -yy469: - YYDEBUG(469, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'M') goto yy473; - if (yych == 'm') goto yy473; - goto yy186; +#line 5160 "Zend/zend_language_scanner.c" yy470: YYDEBUG(470, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'W') goto yy471; - if (yych != 'w') goto yy186; + if (yych == 'M') goto yy474; + if (yych == 'm') goto yy474; + goto yy187; yy471: YYDEBUG(471, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'W') goto yy472; + if (yych != 'w') goto yy187; +yy472: + YYDEBUG(472, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(472, *YYCURSOR); + YYDEBUG(473, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1204 "Zend/zend_language_scanner.l" +#line 1214 "Zend/zend_language_scanner.l" { return T_NEW; } -#line 5172 "Zend/zend_language_scanner.c" -yy473: - YYDEBUG(473, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'E') goto yy474; - if (yych != 'e') goto yy186; +#line 5184 "Zend/zend_language_scanner.c" yy474: YYDEBUG(474, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'S') goto yy475; - if (yych != 's') goto yy186; + if (yych == 'E') goto yy475; + if (yych != 'e') goto yy187; yy475: YYDEBUG(475, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'P') goto yy476; - if (yych != 'p') goto yy186; + if (yych == 'S') goto yy476; + if (yych != 's') goto yy187; yy476: YYDEBUG(476, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy477; - if (yych != 'a') goto yy186; + if (yych == 'P') goto yy477; + if (yych != 'p') goto yy187; yy477: YYDEBUG(477, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy478; - if (yych != 'c') goto yy186; + if (yych == 'A') goto yy478; + if (yych != 'a') goto yy187; yy478: YYDEBUG(478, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy479; - if (yych != 'e') goto yy186; + if (yych == 'C') goto yy479; + if (yych != 'c') goto yy187; yy479: YYDEBUG(479, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'E') goto yy480; + if (yych != 'e') goto yy187; +yy480: + YYDEBUG(480, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(480, *YYCURSOR); + YYDEBUG(481, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1264 "Zend/zend_language_scanner.l" +#line 1274 "Zend/zend_language_scanner.l" { return T_NAMESPACE; } -#line 5215 "Zend/zend_language_scanner.c" -yy481: - YYDEBUG(481, *YYCURSOR); - ++YYCURSOR; +#line 5227 "Zend/zend_language_scanner.c" +yy482: YYDEBUG(482, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(483, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1196 "Zend/zend_language_scanner.l" +#line 1206 "Zend/zend_language_scanner.l" { return T_PAAMAYIM_NEKUDOTAYIM; } -#line 5225 "Zend/zend_language_scanner.c" -yy483: - YYDEBUG(483, *YYCURSOR); +#line 5237 "Zend/zend_language_scanner.c" +yy484: + YYDEBUG(484, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy484: - YYDEBUG(484, *YYCURSOR); +yy485: + YYDEBUG(485, *YYCURSOR); if (yych <= '\f') { - if (yych <= 0x08) goto yy140; - if (yych <= '\n') goto yy483; - goto yy140; + if (yych <= 0x08) goto yy141; + if (yych <= '\n') goto yy484; + goto yy141; } else { - if (yych <= '\r') goto yy483; - if (yych == ' ') goto yy483; - goto yy140; + if (yych <= '\r') goto yy484; + if (yych == ' ') goto yy484; + goto yy141; } -yy485: - YYDEBUG(485, *YYCURSOR); - ++YYCURSOR; +yy486: YYDEBUG(486, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(487, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1372 "Zend/zend_language_scanner.l" +#line 1382 "Zend/zend_language_scanner.l" { return T_MINUS_EQUAL; } -#line 5251 "Zend/zend_language_scanner.c" -yy487: - YYDEBUG(487, *YYCURSOR); - ++YYCURSOR; +#line 5263 "Zend/zend_language_scanner.c" +yy488: YYDEBUG(488, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(489, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1340 "Zend/zend_language_scanner.l" +#line 1350 "Zend/zend_language_scanner.l" { return T_DEC; } -#line 5261 "Zend/zend_language_scanner.c" -yy489: - YYDEBUG(489, *YYCURSOR); - ++YYCURSOR; +#line 5273 "Zend/zend_language_scanner.c" +yy490: YYDEBUG(490, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(491, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1166 "Zend/zend_language_scanner.l" +#line 1176 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); return T_OBJECT_OPERATOR; } -#line 5272 "Zend/zend_language_scanner.c" -yy491: - YYDEBUG(491, *YYCURSOR); +#line 5284 "Zend/zend_language_scanner.c" +yy492: + YYDEBUG(492, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'O') { - if (yych == 'I') goto yy498; - if (yych <= 'N') goto yy186; - goto yy499; + if (yych == 'I') goto yy499; + if (yych <= 'N') goto yy187; + goto yy500; } else { if (yych <= 'i') { - if (yych <= 'h') goto yy186; - goto yy498; + if (yych <= 'h') goto yy187; + goto yy499; } else { - if (yych == 'o') goto yy499; - goto yy186; + if (yych == 'o') goto yy500; + goto yy187; } } -yy492: - YYDEBUG(492, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'B') goto yy493; - if (yych != 'b') goto yy186; yy493: YYDEBUG(493, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy494; - if (yych != 'l') goto yy186; + if (yych == 'B') goto yy494; + if (yych != 'b') goto yy187; yy494: YYDEBUG(494, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy495; - if (yych != 'i') goto yy186; + if (yych == 'L') goto yy495; + if (yych != 'l') goto yy187; yy495: YYDEBUG(495, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy496; - if (yych != 'c') goto yy186; + if (yych == 'I') goto yy496; + if (yych != 'i') goto yy187; yy496: YYDEBUG(496, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'C') goto yy497; + if (yych != 'c') goto yy187; +yy497: + YYDEBUG(497, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(497, *YYCURSOR); + YYDEBUG(498, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1312 "Zend/zend_language_scanner.l" +#line 1322 "Zend/zend_language_scanner.l" { return T_PUBLIC; } -#line 5321 "Zend/zend_language_scanner.c" -yy498: - YYDEBUG(498, *YYCURSOR); +#line 5333 "Zend/zend_language_scanner.c" +yy499: + YYDEBUG(499, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'V') { - if (yych == 'N') goto yy507; - if (yych <= 'U') goto yy186; - goto yy508; + if (yych == 'N') goto yy508; + if (yych <= 'U') goto yy187; + goto yy509; } else { if (yych <= 'n') { - if (yych <= 'm') goto yy186; - goto yy507; + if (yych <= 'm') goto yy187; + goto yy508; } else { - if (yych == 'v') goto yy508; - goto yy186; + if (yych == 'v') goto yy509; + goto yy187; } } -yy499: - YYDEBUG(499, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'T') goto yy500; - if (yych != 't') goto yy186; yy500: YYDEBUG(500, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy501; - if (yych != 'e') goto yy186; + if (yych == 'T') goto yy501; + if (yych != 't') goto yy187; yy501: YYDEBUG(501, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy502; - if (yych != 'c') goto yy186; + if (yych == 'E') goto yy502; + if (yych != 'e') goto yy187; yy502: YYDEBUG(502, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy503; - if (yych != 't') goto yy186; + if (yych == 'C') goto yy503; + if (yych != 'c') goto yy187; yy503: YYDEBUG(503, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy504; - if (yych != 'e') goto yy186; + if (yych == 'T') goto yy504; + if (yych != 't') goto yy187; yy504: YYDEBUG(504, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'D') goto yy505; - if (yych != 'd') goto yy186; + if (yych == 'E') goto yy505; + if (yych != 'e') goto yy187; yy505: YYDEBUG(505, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'D') goto yy506; + if (yych != 'd') goto yy187; +yy506: + YYDEBUG(506, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(506, *YYCURSOR); + YYDEBUG(507, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1308 "Zend/zend_language_scanner.l" +#line 1318 "Zend/zend_language_scanner.l" { return T_PROTECTED; } -#line 5380 "Zend/zend_language_scanner.c" -yy507: - YYDEBUG(507, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'T') goto yy513; - if (yych == 't') goto yy513; - goto yy186; +#line 5392 "Zend/zend_language_scanner.c" yy508: YYDEBUG(508, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy509; - if (yych != 'a') goto yy186; + if (yych == 'T') goto yy514; + if (yych == 't') goto yy514; + goto yy187; yy509: YYDEBUG(509, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy510; - if (yych != 't') goto yy186; + if (yych == 'A') goto yy510; + if (yych != 'a') goto yy187; yy510: YYDEBUG(510, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy511; - if (yych != 'e') goto yy186; + if (yych == 'T') goto yy511; + if (yych != 't') goto yy187; yy511: YYDEBUG(511, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'E') goto yy512; + if (yych != 'e') goto yy187; +yy512: + YYDEBUG(512, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(512, *YYCURSOR); + YYDEBUG(513, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1304 "Zend/zend_language_scanner.l" +#line 1314 "Zend/zend_language_scanner.l" { return T_PRIVATE; } -#line 5414 "Zend/zend_language_scanner.c" -yy513: - YYDEBUG(513, *YYCURSOR); +#line 5426 "Zend/zend_language_scanner.c" +yy514: + YYDEBUG(514, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(514, *YYCURSOR); + YYDEBUG(515, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1142 "Zend/zend_language_scanner.l" +#line 1152 "Zend/zend_language_scanner.l" { return T_PRINT; } -#line 5427 "Zend/zend_language_scanner.c" -yy515: - YYDEBUG(515, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'O') goto yy520; - if (yych == 'o') goto yy520; - goto yy186; +#line 5439 "Zend/zend_language_scanner.c" yy516: YYDEBUG(516, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy517; - if (yych != 't') goto yy186; + if (yych == 'O') goto yy521; + if (yych == 'o') goto yy521; + goto yy187; yy517: YYDEBUG(517, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy518; - if (yych != 'o') goto yy186; + if (yych == 'T') goto yy518; + if (yych != 't') goto yy187; yy518: YYDEBUG(518, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'O') goto yy519; + if (yych != 'o') goto yy187; +yy519: + YYDEBUG(519, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(519, *YYCURSOR); + YYDEBUG(520, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1134 "Zend/zend_language_scanner.l" +#line 1144 "Zend/zend_language_scanner.l" { return T_GOTO; } -#line 5456 "Zend/zend_language_scanner.c" -yy520: - YYDEBUG(520, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'B') goto yy521; - if (yych != 'b') goto yy186; +#line 5468 "Zend/zend_language_scanner.c" yy521: YYDEBUG(521, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy522; - if (yych != 'a') goto yy186; + if (yych == 'B') goto yy522; + if (yych != 'b') goto yy187; yy522: YYDEBUG(522, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy523; - if (yych != 'l') goto yy186; + if (yych == 'A') goto yy523; + if (yych != 'a') goto yy187; yy523: YYDEBUG(523, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'L') goto yy524; + if (yych != 'l') goto yy187; +yy524: + YYDEBUG(524, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(524, *YYCURSOR); + YYDEBUG(525, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1276 "Zend/zend_language_scanner.l" +#line 1286 "Zend/zend_language_scanner.l" { return T_GLOBAL; } -#line 5484 "Zend/zend_language_scanner.c" -yy525: - YYDEBUG(525, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '<') goto yy533; - goto yy193; +#line 5496 "Zend/zend_language_scanner.c" yy526: YYDEBUG(526, *YYCURSOR); yych = *++YYCURSOR; - goto yy180; + if (yych == '<') goto yy534; + goto yy194; yy527: YYDEBUG(527, *YYCURSOR); yych = *++YYCURSOR; - goto yy178; + goto yy181; yy528: YYDEBUG(528, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy529; - if (yych != 'e') goto yy186; + goto yy179; yy529: YYDEBUG(529, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy530; - if (yych != 'a') goto yy186; + if (yych == 'E') goto yy530; + if (yych != 'e') goto yy187; yy530: YYDEBUG(530, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'K') goto yy531; - if (yych != 'k') goto yy186; + if (yych == 'A') goto yy531; + if (yych != 'a') goto yy187; yy531: YYDEBUG(531, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'K') goto yy532; + if (yych != 'k') goto yy187; +yy532: + YYDEBUG(532, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(532, *YYCURSOR); + YYDEBUG(533, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1126 "Zend/zend_language_scanner.l" +#line 1136 "Zend/zend_language_scanner.l" { return T_BREAK; } -#line 5525 "Zend/zend_language_scanner.c" -yy533: - YYDEBUG(533, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '<') goto yy269; - goto yy193; +#line 5537 "Zend/zend_language_scanner.c" yy534: YYDEBUG(534, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy541; - if (yych == 'a') goto yy541; - goto yy186; + if (yych == '<') goto yy270; + goto yy194; yy535: YYDEBUG(535, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy536; - if (yych != 'i') goto yy186; + if (yych == 'A') goto yy542; + if (yych == 'a') goto yy542; + goto yy187; yy536: YYDEBUG(536, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy537; - if (yych != 't') goto yy186; + if (yych == 'I') goto yy537; + if (yych != 'i') goto yy187; yy537: YYDEBUG(537, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy538; - if (yych != 'c') goto yy186; + if (yych == 'T') goto yy538; + if (yych != 't') goto yy187; yy538: YYDEBUG(538, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'H') goto yy539; - if (yych != 'h') goto yy186; + if (yych == 'C') goto yy539; + if (yych != 'c') goto yy187; yy539: YYDEBUG(539, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'H') goto yy540; + if (yych != 'h') goto yy187; +yy540: + YYDEBUG(540, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(540, *YYCURSOR); + YYDEBUG(541, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1110 "Zend/zend_language_scanner.l" +#line 1120 "Zend/zend_language_scanner.l" { return T_SWITCH; } -#line 5569 "Zend/zend_language_scanner.c" -yy541: - YYDEBUG(541, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'T') goto yy542; - if (yych != 't') goto yy186; +#line 5581 "Zend/zend_language_scanner.c" yy542: YYDEBUG(542, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy543; - if (yych != 'i') goto yy186; + if (yych == 'T') goto yy543; + if (yych != 't') goto yy187; yy543: YYDEBUG(543, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy544; - if (yych != 'c') goto yy186; + if (yych == 'I') goto yy544; + if (yych != 'i') goto yy187; yy544: YYDEBUG(544, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'C') goto yy545; + if (yych != 'c') goto yy187; +yy545: + YYDEBUG(545, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(545, *YYCURSOR); + YYDEBUG(546, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1292 "Zend/zend_language_scanner.l" +#line 1302 "Zend/zend_language_scanner.l" { return T_STATIC; } -#line 5597 "Zend/zend_language_scanner.c" -yy546: - YYDEBUG(546, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'S') goto yy557; - if (yych == 's') goto yy557; - goto yy186; +#line 5609 "Zend/zend_language_scanner.c" yy547: YYDEBUG(547, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'D') goto yy555; - if (yych == 'd') goto yy555; - goto yy186; + if (yych == 'S') goto yy558; + if (yych == 's') goto yy558; + goto yy187; yy548: YYDEBUG(548, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy551; - if (yych == 'r') goto yy551; - goto yy186; + if (yych == 'D') goto yy556; + if (yych == 'd') goto yy556; + goto yy187; yy549: YYDEBUG(549, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'R') goto yy552; + if (yych == 'r') goto yy552; + goto yy187; +yy550: + YYDEBUG(550, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(550, *YYCURSOR); + YYDEBUG(551, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1106 "Zend/zend_language_scanner.l" +#line 1116 "Zend/zend_language_scanner.l" { return T_AS; } -#line 5628 "Zend/zend_language_scanner.c" -yy551: - YYDEBUG(551, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'A') goto yy552; - if (yych != 'a') goto yy186; +#line 5640 "Zend/zend_language_scanner.c" yy552: YYDEBUG(552, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'Y') goto yy553; - if (yych != 'y') goto yy186; + if (yych == 'A') goto yy553; + if (yych != 'a') goto yy187; yy553: YYDEBUG(553, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'Y') goto yy554; + if (yych != 'y') goto yy187; +yy554: + YYDEBUG(554, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(554, *YYCURSOR); + YYDEBUG(555, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1328 "Zend/zend_language_scanner.l" +#line 1338 "Zend/zend_language_scanner.l" { return T_ARRAY; } -#line 5651 "Zend/zend_language_scanner.c" -yy555: - YYDEBUG(555, *YYCURSOR); +#line 5663 "Zend/zend_language_scanner.c" +yy556: + YYDEBUG(556, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(556, *YYCURSOR); + YYDEBUG(557, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1424 "Zend/zend_language_scanner.l" +#line 1434 "Zend/zend_language_scanner.l" { return T_LOGICAL_AND; } -#line 5664 "Zend/zend_language_scanner.c" -yy557: - YYDEBUG(557, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'T') goto yy558; - if (yych != 't') goto yy186; +#line 5676 "Zend/zend_language_scanner.c" yy558: YYDEBUG(558, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy559; - if (yych != 'r') goto yy186; + if (yych == 'T') goto yy559; + if (yych != 't') goto yy187; yy559: YYDEBUG(559, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy560; - if (yych != 'a') goto yy186; + if (yych == 'R') goto yy560; + if (yych != 'r') goto yy187; yy560: YYDEBUG(560, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy561; - if (yych != 'c') goto yy186; + if (yych == 'A') goto yy561; + if (yych != 'a') goto yy187; yy561: YYDEBUG(561, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy562; - if (yych != 't') goto yy186; + if (yych == 'C') goto yy562; + if (yych != 'c') goto yy187; yy562: YYDEBUG(562, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'T') goto yy563; + if (yych != 't') goto yy187; +yy563: + YYDEBUG(563, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(563, *YYCURSOR); + YYDEBUG(564, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1296 "Zend/zend_language_scanner.l" +#line 1306 "Zend/zend_language_scanner.l" { return T_ABSTRACT; } -#line 5702 "Zend/zend_language_scanner.c" -yy564: - YYDEBUG(564, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'I') goto yy565; - if (yych != 'i') goto yy186; +#line 5714 "Zend/zend_language_scanner.c" yy565: YYDEBUG(565, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy566; - if (yych != 'l') goto yy186; + if (yych == 'I') goto yy566; + if (yych != 'i') goto yy187; yy566: YYDEBUG(566, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy567; - if (yych != 'e') goto yy186; + if (yych == 'L') goto yy567; + if (yych != 'l') goto yy187; yy567: YYDEBUG(567, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'E') goto yy568; + if (yych != 'e') goto yy187; +yy568: + YYDEBUG(568, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(568, *YYCURSOR); + YYDEBUG(569, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1066 "Zend/zend_language_scanner.l" +#line 1076 "Zend/zend_language_scanner.l" { return T_WHILE; } -#line 5730 "Zend/zend_language_scanner.c" -yy569: - YYDEBUG(569, *YYCURSOR); +#line 5742 "Zend/zend_language_scanner.c" +yy570: + YYDEBUG(570, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(570, *YYCURSOR); + YYDEBUG(571, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1050 "Zend/zend_language_scanner.l" +#line 1060 "Zend/zend_language_scanner.l" { return T_IF; } -#line 5743 "Zend/zend_language_scanner.c" -yy571: - YYDEBUG(571, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'P') goto yy613; - if (yych == 'p') goto yy613; - goto yy186; +#line 5755 "Zend/zend_language_scanner.c" yy572: YYDEBUG(572, *YYCURSOR); yych = *++YYCURSOR; + if (yych == 'P') goto yy614; + if (yych == 'p') goto yy614; + goto yy187; +yy573: + YYDEBUG(573, *YYCURSOR); + yych = *++YYCURSOR; if (yych <= 'T') { if (yych <= 'C') { - if (yych <= 'B') goto yy186; - goto yy580; + if (yych <= 'B') goto yy187; + goto yy581; } else { - if (yych <= 'R') goto yy186; - if (yych <= 'S') goto yy578; - goto yy579; + if (yych <= 'R') goto yy187; + if (yych <= 'S') goto yy579; + goto yy580; } } else { if (yych <= 'r') { - if (yych == 'c') goto yy580; - goto yy186; + if (yych == 'c') goto yy581; + goto yy187; } else { - if (yych <= 's') goto yy578; - if (yych <= 't') goto yy579; - goto yy186; + if (yych <= 's') goto yy579; + if (yych <= 't') goto yy580; + goto yy187; } } -yy573: - YYDEBUG(573, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'S') goto yy574; - if (yych != 's') goto yy186; yy574: YYDEBUG(574, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy575; - if (yych != 'e') goto yy186; + if (yych == 'S') goto yy575; + if (yych != 's') goto yy187; yy575: YYDEBUG(575, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy576; - if (yych != 't') goto yy186; + if (yych == 'E') goto yy576; + if (yych != 'e') goto yy187; yy576: YYDEBUG(576, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'T') goto yy577; + if (yych != 't') goto yy187; +yy577: + YYDEBUG(577, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(577, *YYCURSOR); + YYDEBUG(578, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1280 "Zend/zend_language_scanner.l" +#line 1290 "Zend/zend_language_scanner.l" { return T_ISSET; } -#line 5799 "Zend/zend_language_scanner.c" -yy578: - YYDEBUG(578, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'T') goto yy599; - if (yych == 't') goto yy599; - goto yy186; +#line 5811 "Zend/zend_language_scanner.c" yy579: YYDEBUG(579, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy592; - if (yych == 'e') goto yy592; - goto yy186; + if (yych == 'T') goto yy600; + if (yych == 't') goto yy600; + goto yy187; yy580: YYDEBUG(580, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy581; - if (yych != 'l') goto yy186; + if (yych == 'E') goto yy593; + if (yych == 'e') goto yy593; + goto yy187; yy581: YYDEBUG(581, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'U') goto yy582; - if (yych != 'u') goto yy186; + if (yych == 'L') goto yy582; + if (yych != 'l') goto yy187; yy582: YYDEBUG(582, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'D') goto yy583; - if (yych != 'd') goto yy186; + if (yych == 'U') goto yy583; + if (yych != 'u') goto yy187; yy583: YYDEBUG(583, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy584; - if (yych != 'e') goto yy186; + if (yych == 'D') goto yy584; + if (yych != 'd') goto yy187; yy584: YYDEBUG(584, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'E') goto yy585; + if (yych != 'e') goto yy187; +yy585: + YYDEBUG(585, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) <= '^') { if (yych <= '9') { - if (yych >= '0') goto yy185; + if (yych >= '0') goto yy186; } else { - if (yych <= '@') goto yy585; - if (yych <= 'Z') goto yy185; + if (yych <= '@') goto yy586; + if (yych <= 'Z') goto yy186; } } else { if (yych <= '`') { - if (yych <= '_') goto yy586; + if (yych <= '_') goto yy587; } else { - if (yych <= 'z') goto yy185; - if (yych >= 0x7F) goto yy185; + if (yych <= 'z') goto yy186; + if (yych >= 0x7F) goto yy186; } } -yy585: - YYDEBUG(585, *YYCURSOR); +yy586: + YYDEBUG(586, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1248 "Zend/zend_language_scanner.l" +#line 1258 "Zend/zend_language_scanner.l" { return T_INCLUDE; } -#line 5857 "Zend/zend_language_scanner.c" -yy586: - YYDEBUG(586, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'O') goto yy587; - if (yych != 'o') goto yy186; +#line 5869 "Zend/zend_language_scanner.c" yy587: YYDEBUG(587, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy588; - if (yych != 'n') goto yy186; + if (yych == 'O') goto yy588; + if (yych != 'o') goto yy187; yy588: YYDEBUG(588, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy589; - if (yych != 'c') goto yy186; + if (yych == 'N') goto yy589; + if (yych != 'n') goto yy187; yy589: YYDEBUG(589, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy590; - if (yych != 'e') goto yy186; + if (yych == 'C') goto yy590; + if (yych != 'c') goto yy187; yy590: YYDEBUG(590, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'E') goto yy591; + if (yych != 'e') goto yy187; +yy591: + YYDEBUG(591, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(591, *YYCURSOR); + YYDEBUG(592, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1252 "Zend/zend_language_scanner.l" +#line 1262 "Zend/zend_language_scanner.l" { return T_INCLUDE_ONCE; } -#line 5890 "Zend/zend_language_scanner.c" -yy592: - YYDEBUG(592, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'R') goto yy593; - if (yych != 'r') goto yy186; +#line 5902 "Zend/zend_language_scanner.c" yy593: YYDEBUG(593, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'F') goto yy594; - if (yych != 'f') goto yy186; + if (yych == 'R') goto yy594; + if (yych != 'r') goto yy187; yy594: YYDEBUG(594, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy595; - if (yych != 'a') goto yy186; + if (yych == 'F') goto yy595; + if (yych != 'f') goto yy187; yy595: YYDEBUG(595, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy596; - if (yych != 'c') goto yy186; + if (yych == 'A') goto yy596; + if (yych != 'a') goto yy187; yy596: YYDEBUG(596, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy597; - if (yych != 'e') goto yy186; + if (yych == 'C') goto yy597; + if (yych != 'c') goto yy187; yy597: YYDEBUG(597, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'E') goto yy598; + if (yych != 'e') goto yy187; +yy598: + YYDEBUG(598, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(598, *YYCURSOR); + YYDEBUG(599, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1150 "Zend/zend_language_scanner.l" +#line 1160 "Zend/zend_language_scanner.l" { return T_INTERFACE; } -#line 5928 "Zend/zend_language_scanner.c" -yy599: - YYDEBUG(599, *YYCURSOR); +#line 5940 "Zend/zend_language_scanner.c" +yy600: + YYDEBUG(600, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'E') { - if (yych == 'A') goto yy600; - if (yych <= 'D') goto yy186; - goto yy601; + if (yych == 'A') goto yy601; + if (yych <= 'D') goto yy187; + goto yy602; } else { if (yych <= 'a') { - if (yych <= '`') goto yy186; + if (yych <= '`') goto yy187; } else { - if (yych == 'e') goto yy601; - goto yy186; + if (yych == 'e') goto yy602; + goto yy187; } } -yy600: - YYDEBUG(600, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'N') goto yy607; - if (yych == 'n') goto yy607; - goto yy186; yy601: YYDEBUG(601, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy602; - if (yych != 'a') goto yy186; + if (yych == 'N') goto yy608; + if (yych == 'n') goto yy608; + goto yy187; yy602: YYDEBUG(602, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'D') goto yy603; - if (yych != 'd') goto yy186; + if (yych == 'A') goto yy603; + if (yych != 'a') goto yy187; yy603: YYDEBUG(603, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy604; - if (yych != 'o') goto yy186; + if (yych == 'D') goto yy604; + if (yych != 'd') goto yy187; yy604: YYDEBUG(604, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'F') goto yy605; - if (yych != 'f') goto yy186; + if (yych == 'O') goto yy605; + if (yych != 'o') goto yy187; yy605: YYDEBUG(605, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'F') goto yy606; + if (yych != 'f') goto yy187; +yy606: + YYDEBUG(606, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(606, *YYCURSOR); + YYDEBUG(607, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1272 "Zend/zend_language_scanner.l" +#line 1282 "Zend/zend_language_scanner.l" { return T_INSTEADOF; } -#line 5982 "Zend/zend_language_scanner.c" -yy607: - YYDEBUG(607, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'C') goto yy608; - if (yych != 'c') goto yy186; +#line 5994 "Zend/zend_language_scanner.c" yy608: YYDEBUG(608, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy609; - if (yych != 'e') goto yy186; + if (yych == 'C') goto yy609; + if (yych != 'c') goto yy187; yy609: YYDEBUG(609, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy610; - if (yych != 'o') goto yy186; + if (yych == 'E') goto yy610; + if (yych != 'e') goto yy187; yy610: YYDEBUG(610, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'F') goto yy611; - if (yych != 'f') goto yy186; + if (yych == 'O') goto yy611; + if (yych != 'o') goto yy187; yy611: YYDEBUG(611, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'F') goto yy612; + if (yych != 'f') goto yy187; +yy612: + YYDEBUG(612, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(612, *YYCURSOR); + YYDEBUG(613, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1102 "Zend/zend_language_scanner.l" +#line 1112 "Zend/zend_language_scanner.l" { return T_INSTANCEOF; } -#line 6015 "Zend/zend_language_scanner.c" -yy613: - YYDEBUG(613, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'L') goto yy614; - if (yych != 'l') goto yy186; +#line 6027 "Zend/zend_language_scanner.c" yy614: YYDEBUG(614, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy615; - if (yych != 'e') goto yy186; + if (yych == 'L') goto yy615; + if (yych != 'l') goto yy187; yy615: YYDEBUG(615, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'M') goto yy616; - if (yych != 'm') goto yy186; + if (yych == 'E') goto yy616; + if (yych != 'e') goto yy187; yy616: YYDEBUG(616, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy617; - if (yych != 'e') goto yy186; + if (yych == 'M') goto yy617; + if (yych != 'm') goto yy187; yy617: YYDEBUG(617, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy618; - if (yych != 'n') goto yy186; + if (yych == 'E') goto yy618; + if (yych != 'e') goto yy187; yy618: YYDEBUG(618, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy619; - if (yych != 't') goto yy186; + if (yych == 'N') goto yy619; + if (yych != 'n') goto yy187; yy619: YYDEBUG(619, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'S') goto yy620; - if (yych != 's') goto yy186; + if (yych == 'T') goto yy620; + if (yych != 't') goto yy187; yy620: YYDEBUG(620, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'S') goto yy621; + if (yych != 's') goto yy187; +yy621: + YYDEBUG(621, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(621, *YYCURSOR); + YYDEBUG(622, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1162 "Zend/zend_language_scanner.l" +#line 1172 "Zend/zend_language_scanner.l" { return T_IMPLEMENTS; } -#line 6063 "Zend/zend_language_scanner.c" -yy622: - YYDEBUG(622, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'R') goto yy630; - if (yych == 'r') goto yy630; - goto yy186; +#line 6075 "Zend/zend_language_scanner.c" yy623: YYDEBUG(623, *YYCURSOR); yych = *++YYCURSOR; + if (yych == 'R') goto yy631; + if (yych == 'r') goto yy631; + goto yy187; +yy624: + YYDEBUG(624, *YYCURSOR); + yych = *++YYCURSOR; if (yych <= 'Y') { - if (yych == 'A') goto yy626; - if (yych <= 'X') goto yy186; + if (yych == 'A') goto yy627; + if (yych <= 'X') goto yy187; } else { if (yych <= 'a') { - if (yych <= '`') goto yy186; - goto yy626; + if (yych <= '`') goto yy187; + goto yy627; } else { - if (yych != 'y') goto yy186; + if (yych != 'y') goto yy187; } } - YYDEBUG(624, *YYCURSOR); + YYDEBUG(625, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(625, *YYCURSOR); + YYDEBUG(626, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1038 "Zend/zend_language_scanner.l" +#line 1044 "Zend/zend_language_scanner.l" { return T_TRY; } -#line 6095 "Zend/zend_language_scanner.c" -yy626: - YYDEBUG(626, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'I') goto yy627; - if (yych != 'i') goto yy186; +#line 6107 "Zend/zend_language_scanner.c" yy627: YYDEBUG(627, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy628; - if (yych != 't') goto yy186; + if (yych == 'I') goto yy628; + if (yych != 'i') goto yy187; yy628: YYDEBUG(628, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'T') goto yy629; + if (yych != 't') goto yy187; +yy629: + YYDEBUG(629, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(629, *YYCURSOR); + YYDEBUG(630, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1154 "Zend/zend_language_scanner.l" +#line 1164 "Zend/zend_language_scanner.l" { return T_TRAIT; } -#line 6118 "Zend/zend_language_scanner.c" -yy630: - YYDEBUG(630, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'O') goto yy631; - if (yych != 'o') goto yy186; +#line 6130 "Zend/zend_language_scanner.c" yy631: YYDEBUG(631, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'W') goto yy632; - if (yych != 'w') goto yy186; + if (yych == 'O') goto yy632; + if (yych != 'o') goto yy187; yy632: YYDEBUG(632, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'W') goto yy633; + if (yych != 'w') goto yy187; +yy633: + YYDEBUG(633, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(633, *YYCURSOR); + YYDEBUG(634, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1046 "Zend/zend_language_scanner.l" +#line 1056 "Zend/zend_language_scanner.l" { return T_THROW; } -#line 6141 "Zend/zend_language_scanner.c" -yy634: - YYDEBUG(634, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= 'T') { - if (yych == 'Q') goto yy636; - if (yych <= 'S') goto yy186; - } else { - if (yych <= 'q') { - if (yych <= 'p') goto yy186; - goto yy636; - } else { - if (yych != 't') goto yy186; - } - } +#line 6153 "Zend/zend_language_scanner.c" +yy635: YYDEBUG(635, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'U') goto yy648; - if (yych == 'u') goto yy648; - goto yy186; + if (yych == 'E') goto yy636; + if (yych != 'e') goto yy187; yy636: YYDEBUG(636, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'U') goto yy637; - if (yych != 'u') goto yy186; + if (yych == 'L') goto yy637; + if (yych != 'l') goto yy187; yy637: YYDEBUG(637, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy638; - if (yych != 'i') goto yy186; + if (yych == 'D') goto yy638; + if (yych != 'd') goto yy187; yy638: YYDEBUG(638, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'R') goto yy639; - if (yych != 'r') goto yy186; -yy639: + ++YYCURSOR; + if (yybm[0+(yych = *YYCURSOR)] & 4) { + goto yy186; + } YYDEBUG(639, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'E') goto yy640; - if (yych != 'e') goto yy186; + yyleng = YYCURSOR - SCNG(yy_text); +#line 1040 "Zend/zend_language_scanner.l" + { + return T_YIELD; +} +#line 6181 "Zend/zend_language_scanner.c" yy640: YYDEBUG(640, *YYCURSOR); - ++YYCURSOR; - if ((yych = *YYCURSOR) <= '^') { - if (yych <= '9') { - if (yych >= '0') goto yy185; - } else { - if (yych <= '@') goto yy641; - if (yych <= 'Z') goto yy185; - } + yych = *++YYCURSOR; + if (yych <= 'T') { + if (yych == 'Q') goto yy642; + if (yych <= 'S') goto yy187; } else { - if (yych <= '`') { - if (yych <= '_') goto yy642; + if (yych <= 'q') { + if (yych <= 'p') goto yy187; + goto yy642; } else { - if (yych <= 'z') goto yy185; - if (yych >= 0x7F) goto yy185; + if (yych != 't') goto yy187; } } -yy641: YYDEBUG(641, *YYCURSOR); - yyleng = YYCURSOR - SCNG(yy_text); -#line 1256 "Zend/zend_language_scanner.l" - { - return T_REQUIRE; -} -#line 6206 "Zend/zend_language_scanner.c" + yych = *++YYCURSOR; + if (yych == 'U') goto yy654; + if (yych == 'u') goto yy654; + goto yy187; yy642: YYDEBUG(642, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy643; - if (yych != 'o') goto yy186; + if (yych == 'U') goto yy643; + if (yych != 'u') goto yy187; yy643: YYDEBUG(643, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy644; - if (yych != 'n') goto yy186; + if (yych == 'I') goto yy644; + if (yych != 'i') goto yy187; yy644: YYDEBUG(644, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy645; - if (yych != 'c') goto yy186; + if (yych == 'R') goto yy645; + if (yych != 'r') goto yy187; yy645: YYDEBUG(645, *YYCURSOR); yych = *++YYCURSOR; if (yych == 'E') goto yy646; - if (yych != 'e') goto yy186; + if (yych != 'e') goto yy187; yy646: YYDEBUG(646, *YYCURSOR); ++YYCURSOR; - if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + if ((yych = *YYCURSOR) <= '^') { + if (yych <= '9') { + if (yych >= '0') goto yy186; + } else { + if (yych <= '@') goto yy647; + if (yych <= 'Z') goto yy186; + } + } else { + if (yych <= '`') { + if (yych <= '_') goto yy648; + } else { + if (yych <= 'z') goto yy186; + if (yych >= 0x7F) goto yy186; + } } +yy647: YYDEBUG(647, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1260 "Zend/zend_language_scanner.l" +#line 1266 "Zend/zend_language_scanner.l" { - return T_REQUIRE_ONCE; + return T_REQUIRE; } -#line 6239 "Zend/zend_language_scanner.c" +#line 6246 "Zend/zend_language_scanner.c" yy648: YYDEBUG(648, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy649; - if (yych != 'r') goto yy186; + if (yych == 'O') goto yy649; + if (yych != 'o') goto yy187; yy649: YYDEBUG(649, *YYCURSOR); yych = *++YYCURSOR; if (yych == 'N') goto yy650; - if (yych != 'n') goto yy186; + if (yych != 'n') goto yy187; yy650: YYDEBUG(650, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'C') goto yy651; + if (yych != 'c') goto yy187; +yy651: + YYDEBUG(651, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'E') goto yy652; + if (yych != 'e') goto yy187; +yy652: + YYDEBUG(652, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(651, *YYCURSOR); + YYDEBUG(653, *YYCURSOR); + yyleng = YYCURSOR - SCNG(yy_text); +#line 1270 "Zend/zend_language_scanner.l" + { + return T_REQUIRE_ONCE; +} +#line 6279 "Zend/zend_language_scanner.c" +yy654: + YYDEBUG(654, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'R') goto yy655; + if (yych != 'r') goto yy187; +yy655: + YYDEBUG(655, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'N') goto yy656; + if (yych != 'n') goto yy187; +yy656: + YYDEBUG(656, *YYCURSOR); + ++YYCURSOR; + if (yybm[0+(yych = *YYCURSOR)] & 4) { + goto yy186; + } + YYDEBUG(657, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1034 "Zend/zend_language_scanner.l" +#line 1036 "Zend/zend_language_scanner.l" { return T_RETURN; } -#line 6262 "Zend/zend_language_scanner.c" -yy652: - YYDEBUG(652, *YYCURSOR); +#line 6302 "Zend/zend_language_scanner.c" +yy658: + YYDEBUG(658, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'T') { if (yych <= 'L') { - if (yych <= 'K') goto yy186; - goto yy675; + if (yych <= 'K') goto yy187; + goto yy681; } else { - if (yych <= 'R') goto yy186; - if (yych <= 'S') goto yy674; - goto yy673; + if (yych <= 'R') goto yy187; + if (yych <= 'S') goto yy680; + goto yy679; } } else { if (yych <= 'r') { - if (yych == 'l') goto yy675; - goto yy186; + if (yych == 'l') goto yy681; + goto yy187; } else { - if (yych <= 's') goto yy674; - if (yych <= 't') goto yy673; - goto yy186; + if (yych <= 's') goto yy680; + if (yych <= 't') goto yy679; + goto yy187; } } -yy653: - YYDEBUG(653, *YYCURSOR); +yy659: + YYDEBUG(659, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'O') { - if (yych == 'A') goto yy665; - if (yych <= 'N') goto yy186; - goto yy666; + if (yych == 'A') goto yy671; + if (yych <= 'N') goto yy187; + goto yy672; } else { if (yych <= 'a') { - if (yych <= '`') goto yy186; - goto yy665; + if (yych <= '`') goto yy187; + goto yy671; } else { - if (yych == 'o') goto yy666; - goto yy186; + if (yych == 'o') goto yy672; + goto yy187; } } -yy654: - YYDEBUG(654, *YYCURSOR); +yy660: + YYDEBUG(660, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy655; - if (yych != 'n') goto yy186; -yy655: - YYDEBUG(655, *YYCURSOR); + if (yych == 'N') goto yy661; + if (yych != 'n') goto yy187; +yy661: + YYDEBUG(661, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'T') { - if (yych <= 'R') goto yy186; - if (yych >= 'T') goto yy657; + if (yych <= 'R') goto yy187; + if (yych >= 'T') goto yy663; } else { - if (yych <= 'r') goto yy186; - if (yych <= 's') goto yy656; - if (yych <= 't') goto yy657; - goto yy186; + if (yych <= 'r') goto yy187; + if (yych <= 's') goto yy662; + if (yych <= 't') goto yy663; + goto yy187; } -yy656: - YYDEBUG(656, *YYCURSOR); +yy662: + YYDEBUG(662, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy663; - if (yych == 't') goto yy663; - goto yy186; -yy657: - YYDEBUG(657, *YYCURSOR); + if (yych == 'T') goto yy669; + if (yych == 't') goto yy669; + goto yy187; +yy663: + YYDEBUG(663, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy658; - if (yych != 'i') goto yy186; -yy658: - YYDEBUG(658, *YYCURSOR); + if (yych == 'I') goto yy664; + if (yych != 'i') goto yy187; +yy664: + YYDEBUG(664, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy659; - if (yych != 'n') goto yy186; -yy659: - YYDEBUG(659, *YYCURSOR); + if (yych == 'N') goto yy665; + if (yych != 'n') goto yy187; +yy665: + YYDEBUG(665, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'U') goto yy660; - if (yych != 'u') goto yy186; -yy660: - YYDEBUG(660, *YYCURSOR); + if (yych == 'U') goto yy666; + if (yych != 'u') goto yy187; +yy666: + YYDEBUG(666, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy661; - if (yych != 'e') goto yy186; -yy661: - YYDEBUG(661, *YYCURSOR); + if (yych == 'E') goto yy667; + if (yych != 'e') goto yy187; +yy667: + YYDEBUG(667, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(662, *YYCURSOR); + YYDEBUG(668, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1130 "Zend/zend_language_scanner.l" +#line 1140 "Zend/zend_language_scanner.l" { return T_CONTINUE; } -#line 6356 "Zend/zend_language_scanner.c" -yy663: - YYDEBUG(663, *YYCURSOR); +#line 6396 "Zend/zend_language_scanner.c" +yy669: + YYDEBUG(669, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(664, *YYCURSOR); + YYDEBUG(670, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1030 "Zend/zend_language_scanner.l" +#line 1032 "Zend/zend_language_scanner.l" { return T_CONST; } -#line 6369 "Zend/zend_language_scanner.c" -yy665: - YYDEBUG(665, *YYCURSOR); +#line 6409 "Zend/zend_language_scanner.c" +yy671: + YYDEBUG(671, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'S') goto yy670; - if (yych == 's') goto yy670; - goto yy186; -yy666: - YYDEBUG(666, *YYCURSOR); + if (yych == 'S') goto yy676; + if (yych == 's') goto yy676; + goto yy187; +yy672: + YYDEBUG(672, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy667; - if (yych != 'n') goto yy186; -yy667: - YYDEBUG(667, *YYCURSOR); + if (yych == 'N') goto yy673; + if (yych != 'n') goto yy187; +yy673: + YYDEBUG(673, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy668; - if (yych != 'e') goto yy186; -yy668: - YYDEBUG(668, *YYCURSOR); + if (yych == 'E') goto yy674; + if (yych != 'e') goto yy187; +yy674: + YYDEBUG(674, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(669, *YYCURSOR); + YYDEBUG(675, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1208 "Zend/zend_language_scanner.l" +#line 1218 "Zend/zend_language_scanner.l" { return T_CLONE; } -#line 6398 "Zend/zend_language_scanner.c" -yy670: - YYDEBUG(670, *YYCURSOR); +#line 6438 "Zend/zend_language_scanner.c" +yy676: + YYDEBUG(676, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'S') goto yy671; - if (yych != 's') goto yy186; -yy671: - YYDEBUG(671, *YYCURSOR); + if (yych == 'S') goto yy677; + if (yych != 's') goto yy187; +yy677: + YYDEBUG(677, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(672, *YYCURSOR); + YYDEBUG(678, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1146 "Zend/zend_language_scanner.l" +#line 1156 "Zend/zend_language_scanner.l" { return T_CLASS; } -#line 6416 "Zend/zend_language_scanner.c" -yy673: - YYDEBUG(673, *YYCURSOR); +#line 6456 "Zend/zend_language_scanner.c" +yy679: + YYDEBUG(679, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy684; - if (yych == 'c') goto yy684; - goto yy186; -yy674: - YYDEBUG(674, *YYCURSOR); + if (yych == 'C') goto yy690; + if (yych == 'c') goto yy690; + goto yy187; +yy680: + YYDEBUG(680, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy682; - if (yych == 'e') goto yy682; - goto yy186; -yy675: - YYDEBUG(675, *YYCURSOR); + if (yych == 'E') goto yy688; + if (yych == 'e') goto yy688; + goto yy187; +yy681: + YYDEBUG(681, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy676; - if (yych != 'l') goto yy186; -yy676: - YYDEBUG(676, *YYCURSOR); + if (yych == 'L') goto yy682; + if (yych != 'l') goto yy187; +yy682: + YYDEBUG(682, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy677; - if (yych != 'a') goto yy186; -yy677: - YYDEBUG(677, *YYCURSOR); + if (yych == 'A') goto yy683; + if (yych != 'a') goto yy187; +yy683: + YYDEBUG(683, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'B') goto yy678; - if (yych != 'b') goto yy186; -yy678: - YYDEBUG(678, *YYCURSOR); + if (yych == 'B') goto yy684; + if (yych != 'b') goto yy187; +yy684: + YYDEBUG(684, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy679; - if (yych != 'l') goto yy186; -yy679: - YYDEBUG(679, *YYCURSOR); + if (yych == 'L') goto yy685; + if (yych != 'l') goto yy187; +yy685: + YYDEBUG(685, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy680; - if (yych != 'e') goto yy186; -yy680: - YYDEBUG(680, *YYCURSOR); + if (yych == 'E') goto yy686; + if (yych != 'e') goto yy187; +yy686: + YYDEBUG(686, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(681, *YYCURSOR); + YYDEBUG(687, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1332 "Zend/zend_language_scanner.l" +#line 1342 "Zend/zend_language_scanner.l" { return T_CALLABLE; } -#line 6466 "Zend/zend_language_scanner.c" -yy682: - YYDEBUG(682, *YYCURSOR); +#line 6506 "Zend/zend_language_scanner.c" +yy688: + YYDEBUG(688, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(683, *YYCURSOR); + YYDEBUG(689, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1118 "Zend/zend_language_scanner.l" +#line 1128 "Zend/zend_language_scanner.l" { return T_CASE; } -#line 6479 "Zend/zend_language_scanner.c" -yy684: - YYDEBUG(684, *YYCURSOR); +#line 6519 "Zend/zend_language_scanner.c" +yy690: + YYDEBUG(690, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'H') goto yy685; - if (yych != 'h') goto yy186; -yy685: - YYDEBUG(685, *YYCURSOR); + if (yych == 'H') goto yy691; + if (yych != 'h') goto yy187; +yy691: + YYDEBUG(691, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(686, *YYCURSOR); + YYDEBUG(692, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1042 "Zend/zend_language_scanner.l" +#line 1048 "Zend/zend_language_scanner.l" { return T_CATCH; } -#line 6497 "Zend/zend_language_scanner.c" -yy687: - YYDEBUG(687, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'N') goto yy704; - if (yych == 'n') goto yy704; - goto yy186; -yy688: - YYDEBUG(688, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'R') goto yy697; - if (yych == 'r') goto yy697; - goto yy186; -yy689: - YYDEBUG(689, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'N') goto yy690; - if (yych != 'n') goto yy186; -yy690: - YYDEBUG(690, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'C') goto yy691; - if (yych != 'c') goto yy186; -yy691: - YYDEBUG(691, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'T') goto yy692; - if (yych != 't') goto yy186; -yy692: - YYDEBUG(692, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'I') goto yy693; - if (yych != 'i') goto yy186; +#line 6537 "Zend/zend_language_scanner.c" yy693: YYDEBUG(693, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy694; - if (yych != 'o') goto yy186; + if (yych == 'N') goto yy710; + if (yych == 'n') goto yy710; + goto yy187; yy694: YYDEBUG(694, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'N') goto yy695; - if (yych != 'n') goto yy186; + if (yych == 'R') goto yy703; + if (yych == 'r') goto yy703; + goto yy187; yy695: YYDEBUG(695, *YYCURSOR); - ++YYCURSOR; - if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; - } + yych = *++YYCURSOR; + if (yych == 'N') goto yy696; + if (yych != 'n') goto yy187; +yy696: YYDEBUG(696, *YYCURSOR); - yyleng = YYCURSOR - SCNG(yy_text); -#line 1026 "Zend/zend_language_scanner.l" - { - return T_FUNCTION; -} -#line 6552 "Zend/zend_language_scanner.c" + yych = *++YYCURSOR; + if (yych == 'C') goto yy697; + if (yych != 'c') goto yy187; yy697: YYDEBUG(697, *YYCURSOR); - ++YYCURSOR; - if ((yych = *YYCURSOR) <= '^') { - if (yych <= '@') { - if (yych <= '/') goto yy698; - if (yych <= '9') goto yy185; - } else { - if (yych == 'E') goto yy699; - if (yych <= 'Z') goto yy185; - } - } else { - if (yych <= 'd') { - if (yych != '`') goto yy185; - } else { - if (yych <= 'e') goto yy699; - if (yych <= 'z') goto yy185; - if (yych >= 0x7F) goto yy185; - } - } + yych = *++YYCURSOR; + if (yych == 'T') goto yy698; + if (yych != 't') goto yy187; yy698: YYDEBUG(698, *YYCURSOR); - yyleng = YYCURSOR - SCNG(yy_text); -#line 1078 "Zend/zend_language_scanner.l" - { - return T_FOR; -} -#line 6580 "Zend/zend_language_scanner.c" + yych = *++YYCURSOR; + if (yych == 'I') goto yy699; + if (yych != 'i') goto yy187; yy699: YYDEBUG(699, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy700; - if (yych != 'a') goto yy186; + if (yych == 'O') goto yy700; + if (yych != 'o') goto yy187; yy700: YYDEBUG(700, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy701; - if (yych != 'c') goto yy186; + if (yych == 'N') goto yy701; + if (yych != 'n') goto yy187; yy701: YYDEBUG(701, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'H') goto yy702; - if (yych != 'h') goto yy186; -yy702: - YYDEBUG(702, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(703, *YYCURSOR); + YYDEBUG(702, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1086 "Zend/zend_language_scanner.l" +#line 1028 "Zend/zend_language_scanner.l" { - return T_FOREACH; + return T_FUNCTION; } -#line 6608 "Zend/zend_language_scanner.c" +#line 6592 "Zend/zend_language_scanner.c" +yy703: + YYDEBUG(703, *YYCURSOR); + ++YYCURSOR; + if ((yych = *YYCURSOR) <= '^') { + if (yych <= '@') { + if (yych <= '/') goto yy704; + if (yych <= '9') goto yy186; + } else { + if (yych == 'E') goto yy705; + if (yych <= 'Z') goto yy186; + } + } else { + if (yych <= 'd') { + if (yych != '`') goto yy186; + } else { + if (yych <= 'e') goto yy705; + if (yych <= 'z') goto yy186; + if (yych >= 0x7F) goto yy186; + } + } yy704: YYDEBUG(704, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'A') goto yy705; - if (yych != 'a') goto yy186; + yyleng = YYCURSOR - SCNG(yy_text); +#line 1088 "Zend/zend_language_scanner.l" + { + return T_FOR; +} +#line 6620 "Zend/zend_language_scanner.c" yy705: YYDEBUG(705, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy706; - if (yych != 'l') goto yy186; + if (yych == 'A') goto yy706; + if (yych != 'a') goto yy187; yy706: YYDEBUG(706, *YYCURSOR); - ++YYCURSOR; - if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; - } + yych = *++YYCURSOR; + if (yych == 'C') goto yy707; + if (yych != 'c') goto yy187; +yy707: YYDEBUG(707, *YYCURSOR); - yyleng = YYCURSOR - SCNG(yy_text); -#line 1300 "Zend/zend_language_scanner.l" - { - return T_FINAL; -} -#line 6631 "Zend/zend_language_scanner.c" + yych = *++YYCURSOR; + if (yych == 'H') goto yy708; + if (yych != 'h') goto yy187; yy708: YYDEBUG(708, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= 'F') { - if (yych == 'C') goto yy714; - if (yych <= 'E') goto yy186; - goto yy715; - } else { - if (yych <= 'c') { - if (yych <= 'b') goto yy186; - goto yy714; - } else { - if (yych == 'f') goto yy715; - goto yy186; - } - } -yy709: - YYDEBUG(709, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'E') goto yy712; - if (yych == 'e') goto yy712; - goto yy186; -yy710: - YYDEBUG(710, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(711, *YYCURSOR); + YYDEBUG(709, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1074 "Zend/zend_language_scanner.l" +#line 1096 "Zend/zend_language_scanner.l" { - return T_DO; + return T_FOREACH; } -#line 6666 "Zend/zend_language_scanner.c" +#line 6648 "Zend/zend_language_scanner.c" +yy710: + YYDEBUG(710, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'A') goto yy711; + if (yych != 'a') goto yy187; +yy711: + YYDEBUG(711, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'L') goto yy712; + if (yych != 'l') goto yy187; yy712: YYDEBUG(712, *YYCURSOR); ++YYCURSOR; - if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + if ((yych = *YYCURSOR) <= '^') { + if (yych <= '@') { + if (yych <= '/') goto yy713; + if (yych <= '9') goto yy186; + } else { + if (yych == 'L') goto yy714; + if (yych <= 'Z') goto yy186; + } + } else { + if (yych <= 'k') { + if (yych != '`') goto yy186; + } else { + if (yych <= 'l') goto yy714; + if (yych <= 'z') goto yy186; + if (yych >= 0x7F) goto yy186; + } } +yy713: YYDEBUG(713, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1022 "Zend/zend_language_scanner.l" +#line 1310 "Zend/zend_language_scanner.l" { - return T_EXIT; + return T_FINAL; } -#line 6679 "Zend/zend_language_scanner.c" +#line 6686 "Zend/zend_language_scanner.c" yy714: YYDEBUG(714, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy721; - if (yych == 'l') goto yy721; - goto yy186; + if (yych == 'Y') goto yy715; + if (yych != 'y') goto yy187; yy715: YYDEBUG(715, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'A') goto yy716; - if (yych != 'a') goto yy186; -yy716: + ++YYCURSOR; + if (yybm[0+(yych = *YYCURSOR)] & 4) { + goto yy186; + } YYDEBUG(716, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'U') goto yy717; - if (yych != 'u') goto yy186; + yyleng = YYCURSOR - SCNG(yy_text); +#line 1052 "Zend/zend_language_scanner.l" + { + return T_FINALLY; +} +#line 6704 "Zend/zend_language_scanner.c" yy717: YYDEBUG(717, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy718; - if (yych != 'l') goto yy186; + if (yych <= 'F') { + if (yych == 'C') goto yy723; + if (yych <= 'E') goto yy187; + goto yy724; + } else { + if (yych <= 'c') { + if (yych <= 'b') goto yy187; + goto yy723; + } else { + if (yych == 'f') goto yy724; + goto yy187; + } + } yy718: YYDEBUG(718, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy719; - if (yych != 't') goto yy186; + if (yych == 'E') goto yy721; + if (yych == 'e') goto yy721; + goto yy187; yy719: YYDEBUG(719, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } YYDEBUG(720, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1122 "Zend/zend_language_scanner.l" +#line 1084 "Zend/zend_language_scanner.l" { - return T_DEFAULT; + return T_DO; } -#line 6718 "Zend/zend_language_scanner.c" +#line 6739 "Zend/zend_language_scanner.c" yy721: YYDEBUG(721, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'A') goto yy722; - if (yych != 'a') goto yy186; -yy722: + ++YYCURSOR; + if (yybm[0+(yych = *YYCURSOR)] & 4) { + goto yy186; + } YYDEBUG(722, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'R') goto yy723; - if (yych != 'r') goto yy186; + yyleng = YYCURSOR - SCNG(yy_text); +#line 1024 "Zend/zend_language_scanner.l" + { + return T_EXIT; +} +#line 6752 "Zend/zend_language_scanner.c" yy723: YYDEBUG(723, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy724; - if (yych != 'e') goto yy186; + if (yych == 'L') goto yy730; + if (yych == 'l') goto yy730; + goto yy187; yy724: YYDEBUG(724, *YYCURSOR); - ++YYCURSOR; - if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; - } + yych = *++YYCURSOR; + if (yych == 'A') goto yy725; + if (yych != 'a') goto yy187; +yy725: YYDEBUG(725, *YYCURSOR); - yyleng = YYCURSOR - SCNG(yy_text); -#line 1094 "Zend/zend_language_scanner.l" - { - return T_DECLARE; -} -#line 6746 "Zend/zend_language_scanner.c" + yych = *++YYCURSOR; + if (yych == 'U') goto yy726; + if (yych != 'u') goto yy187; yy726: YYDEBUG(726, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'H') goto yy788; - if (yych == 'h') goto yy788; - goto yy186; + if (yych == 'L') goto yy727; + if (yych != 'l') goto yy187; yy727: YYDEBUG(727, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'S') goto yy782; - if (yych == 's') goto yy782; - goto yy186; + if (yych == 'T') goto yy728; + if (yych != 't') goto yy187; yy728: YYDEBUG(728, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'P') goto yy778; - if (yych == 'p') goto yy778; - goto yy186; -yy729: + ++YYCURSOR; + if (yybm[0+(yych = *YYCURSOR)] & 4) { + goto yy186; + } YYDEBUG(729, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'D') goto yy744; - if (yych == 'd') goto yy744; - goto yy186; + yyleng = YYCURSOR - SCNG(yy_text); +#line 1132 "Zend/zend_language_scanner.l" + { + return T_DEFAULT; +} +#line 6791 "Zend/zend_language_scanner.c" yy730: YYDEBUG(730, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy741; - if (yych == 'a') goto yy741; - goto yy186; + if (yych == 'A') goto yy731; + if (yych != 'a') goto yy187; yy731: YYDEBUG(731, *YYCURSOR); yych = *++YYCURSOR; - if (yych <= 'T') { - if (yych == 'I') goto yy732; - if (yych <= 'S') goto yy186; - goto yy733; - } else { - if (yych <= 'i') { - if (yych <= 'h') goto yy186; - } else { - if (yych == 't') goto yy733; - goto yy186; - } - } + if (yych == 'R') goto yy732; + if (yych != 'r') goto yy187; yy732: YYDEBUG(732, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy739; - if (yych == 't') goto yy739; - goto yy186; + if (yych == 'E') goto yy733; + if (yych != 'e') goto yy187; yy733: YYDEBUG(733, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'E') goto yy734; - if (yych != 'e') goto yy186; -yy734: + ++YYCURSOR; + if (yybm[0+(yych = *YYCURSOR)] & 4) { + goto yy186; + } YYDEBUG(734, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'N') goto yy735; - if (yych != 'n') goto yy186; + yyleng = YYCURSOR - SCNG(yy_text); +#line 1104 "Zend/zend_language_scanner.l" + { + return T_DECLARE; +} +#line 6819 "Zend/zend_language_scanner.c" yy735: YYDEBUG(735, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'D') goto yy736; - if (yych != 'd') goto yy186; + if (yych == 'H') goto yy797; + if (yych == 'h') goto yy797; + goto yy187; yy736: YYDEBUG(736, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'S') goto yy737; - if (yych != 's') goto yy186; + if (yych == 'S') goto yy791; + if (yych == 's') goto yy791; + goto yy187; yy737: YYDEBUG(737, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'P') goto yy787; + if (yych == 'p') goto yy787; + goto yy187; +yy738: + YYDEBUG(738, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'D') goto yy753; + if (yych == 'd') goto yy753; + goto yy187; +yy739: + YYDEBUG(739, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'A') goto yy750; + if (yych == 'a') goto yy750; + goto yy187; +yy740: + YYDEBUG(740, *YYCURSOR); + yych = *++YYCURSOR; + if (yych <= 'T') { + if (yych == 'I') goto yy741; + if (yych <= 'S') goto yy187; + goto yy742; + } else { + if (yych <= 'i') { + if (yych <= 'h') goto yy187; + } else { + if (yych == 't') goto yy742; + goto yy187; + } + } +yy741: + YYDEBUG(741, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'T') goto yy748; + if (yych == 't') goto yy748; + goto yy187; +yy742: + YYDEBUG(742, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'E') goto yy743; + if (yych != 'e') goto yy187; +yy743: + YYDEBUG(743, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'N') goto yy744; + if (yych != 'n') goto yy187; +yy744: + YYDEBUG(744, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'D') goto yy745; + if (yych != 'd') goto yy187; +yy745: + YYDEBUG(745, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'S') goto yy746; + if (yych != 's') goto yy187; +yy746: + YYDEBUG(746, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(738, *YYCURSOR); + YYDEBUG(747, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1158 "Zend/zend_language_scanner.l" +#line 1168 "Zend/zend_language_scanner.l" { return T_EXTENDS; } -#line 6830 "Zend/zend_language_scanner.c" -yy739: - YYDEBUG(739, *YYCURSOR); +#line 6903 "Zend/zend_language_scanner.c" +yy748: + YYDEBUG(748, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(740, *YYCURSOR); + YYDEBUG(749, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1018 "Zend/zend_language_scanner.l" +#line 1020 "Zend/zend_language_scanner.l" { return T_EXIT; } -#line 6843 "Zend/zend_language_scanner.c" -yy741: - YYDEBUG(741, *YYCURSOR); +#line 6916 "Zend/zend_language_scanner.c" +yy750: + YYDEBUG(750, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy742; - if (yych != 'l') goto yy186; -yy742: - YYDEBUG(742, *YYCURSOR); + if (yych == 'L') goto yy751; + if (yych != 'l') goto yy187; +yy751: + YYDEBUG(751, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(743, *YYCURSOR); + YYDEBUG(752, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1244 "Zend/zend_language_scanner.l" +#line 1254 "Zend/zend_language_scanner.l" { return T_EVAL; } -#line 6861 "Zend/zend_language_scanner.c" -yy744: - YYDEBUG(744, *YYCURSOR); +#line 6934 "Zend/zend_language_scanner.c" +yy753: + YYDEBUG(753, *YYCURSOR); yych = *++YYCURSOR; YYDEBUG(-1, yych); switch (yych) { case 'D': - case 'd': goto yy745; + case 'd': goto yy754; case 'F': - case 'f': goto yy746; + case 'f': goto yy755; case 'I': - case 'i': goto yy747; + case 'i': goto yy756; case 'S': - case 's': goto yy748; + case 's': goto yy757; case 'W': - case 'w': goto yy749; - default: goto yy186; + case 'w': goto yy758; + default: goto yy187; } -yy745: - YYDEBUG(745, *YYCURSOR); +yy754: + YYDEBUG(754, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy771; - if (yych == 'e') goto yy771; - goto yy186; -yy746: - YYDEBUG(746, *YYCURSOR); + if (yych == 'E') goto yy780; + if (yych == 'e') goto yy780; + goto yy187; +yy755: + YYDEBUG(755, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy763; - if (yych == 'o') goto yy763; - goto yy186; -yy747: - YYDEBUG(747, *YYCURSOR); + if (yych == 'O') goto yy772; + if (yych == 'o') goto yy772; + goto yy187; +yy756: + YYDEBUG(756, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'F') goto yy761; - if (yych == 'f') goto yy761; - goto yy186; -yy748: - YYDEBUG(748, *YYCURSOR); + if (yych == 'F') goto yy770; + if (yych == 'f') goto yy770; + goto yy187; +yy757: + YYDEBUG(757, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'W') goto yy755; - if (yych == 'w') goto yy755; - goto yy186; -yy749: - YYDEBUG(749, *YYCURSOR); + if (yych == 'W') goto yy764; + if (yych == 'w') goto yy764; + goto yy187; +yy758: + YYDEBUG(758, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'H') goto yy750; - if (yych != 'h') goto yy186; -yy750: - YYDEBUG(750, *YYCURSOR); + if (yych == 'H') goto yy759; + if (yych != 'h') goto yy187; +yy759: + YYDEBUG(759, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy751; - if (yych != 'i') goto yy186; -yy751: - YYDEBUG(751, *YYCURSOR); + if (yych == 'I') goto yy760; + if (yych != 'i') goto yy187; +yy760: + YYDEBUG(760, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy752; - if (yych != 'l') goto yy186; -yy752: - YYDEBUG(752, *YYCURSOR); + if (yych == 'L') goto yy761; + if (yych != 'l') goto yy187; +yy761: + YYDEBUG(761, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy753; - if (yych != 'e') goto yy186; -yy753: - YYDEBUG(753, *YYCURSOR); + if (yych == 'E') goto yy762; + if (yych != 'e') goto yy187; +yy762: + YYDEBUG(762, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(754, *YYCURSOR); + YYDEBUG(763, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1070 "Zend/zend_language_scanner.l" +#line 1080 "Zend/zend_language_scanner.l" { return T_ENDWHILE; } -#line 6935 "Zend/zend_language_scanner.c" -yy755: - YYDEBUG(755, *YYCURSOR); +#line 7008 "Zend/zend_language_scanner.c" +yy764: + YYDEBUG(764, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'I') goto yy756; - if (yych != 'i') goto yy186; -yy756: - YYDEBUG(756, *YYCURSOR); + if (yych == 'I') goto yy765; + if (yych != 'i') goto yy187; +yy765: + YYDEBUG(765, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy757; - if (yych != 't') goto yy186; -yy757: - YYDEBUG(757, *YYCURSOR); + if (yych == 'T') goto yy766; + if (yych != 't') goto yy187; +yy766: + YYDEBUG(766, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy758; - if (yych != 'c') goto yy186; -yy758: - YYDEBUG(758, *YYCURSOR); + if (yych == 'C') goto yy767; + if (yych != 'c') goto yy187; +yy767: + YYDEBUG(767, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'H') goto yy759; - if (yych != 'h') goto yy186; -yy759: - YYDEBUG(759, *YYCURSOR); + if (yych == 'H') goto yy768; + if (yych != 'h') goto yy187; +yy768: + YYDEBUG(768, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(760, *YYCURSOR); + YYDEBUG(769, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1114 "Zend/zend_language_scanner.l" +#line 1124 "Zend/zend_language_scanner.l" { return T_ENDSWITCH; } -#line 6968 "Zend/zend_language_scanner.c" -yy761: - YYDEBUG(761, *YYCURSOR); +#line 7041 "Zend/zend_language_scanner.c" +yy770: + YYDEBUG(770, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(762, *YYCURSOR); + YYDEBUG(771, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1058 "Zend/zend_language_scanner.l" +#line 1068 "Zend/zend_language_scanner.l" { return T_ENDIF; } -#line 6981 "Zend/zend_language_scanner.c" -yy763: - YYDEBUG(763, *YYCURSOR); +#line 7054 "Zend/zend_language_scanner.c" +yy772: + YYDEBUG(772, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy764; - if (yych != 'r') goto yy186; -yy764: - YYDEBUG(764, *YYCURSOR); + if (yych == 'R') goto yy773; + if (yych != 'r') goto yy187; +yy773: + YYDEBUG(773, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) <= '^') { if (yych <= '@') { - if (yych <= '/') goto yy765; - if (yych <= '9') goto yy185; + if (yych <= '/') goto yy774; + if (yych <= '9') goto yy186; } else { - if (yych == 'E') goto yy766; - if (yych <= 'Z') goto yy185; + if (yych == 'E') goto yy775; + if (yych <= 'Z') goto yy186; } } else { if (yych <= 'd') { - if (yych != '`') goto yy185; + if (yych != '`') goto yy186; } else { - if (yych <= 'e') goto yy766; - if (yych <= 'z') goto yy185; - if (yych >= 0x7F) goto yy185; + if (yych <= 'e') goto yy775; + if (yych <= 'z') goto yy186; + if (yych >= 0x7F) goto yy186; } } -yy765: - YYDEBUG(765, *YYCURSOR); +yy774: + YYDEBUG(774, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1082 "Zend/zend_language_scanner.l" +#line 1092 "Zend/zend_language_scanner.l" { return T_ENDFOR; } -#line 7014 "Zend/zend_language_scanner.c" -yy766: - YYDEBUG(766, *YYCURSOR); +#line 7087 "Zend/zend_language_scanner.c" +yy775: + YYDEBUG(775, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy767; - if (yych != 'a') goto yy186; -yy767: - YYDEBUG(767, *YYCURSOR); + if (yych == 'A') goto yy776; + if (yych != 'a') goto yy187; +yy776: + YYDEBUG(776, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy768; - if (yych != 'c') goto yy186; -yy768: - YYDEBUG(768, *YYCURSOR); + if (yych == 'C') goto yy777; + if (yych != 'c') goto yy187; +yy777: + YYDEBUG(777, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'H') goto yy769; - if (yych != 'h') goto yy186; -yy769: - YYDEBUG(769, *YYCURSOR); + if (yych == 'H') goto yy778; + if (yych != 'h') goto yy187; +yy778: + YYDEBUG(778, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(770, *YYCURSOR); + YYDEBUG(779, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1090 "Zend/zend_language_scanner.l" +#line 1100 "Zend/zend_language_scanner.l" { return T_ENDFOREACH; } -#line 7042 "Zend/zend_language_scanner.c" -yy771: - YYDEBUG(771, *YYCURSOR); +#line 7115 "Zend/zend_language_scanner.c" +yy780: + YYDEBUG(780, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'C') goto yy772; - if (yych != 'c') goto yy186; -yy772: - YYDEBUG(772, *YYCURSOR); + if (yych == 'C') goto yy781; + if (yych != 'c') goto yy187; +yy781: + YYDEBUG(781, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'L') goto yy773; - if (yych != 'l') goto yy186; -yy773: - YYDEBUG(773, *YYCURSOR); + if (yych == 'L') goto yy782; + if (yych != 'l') goto yy187; +yy782: + YYDEBUG(782, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'A') goto yy774; - if (yych != 'a') goto yy186; -yy774: - YYDEBUG(774, *YYCURSOR); + if (yych == 'A') goto yy783; + if (yych != 'a') goto yy187; +yy783: + YYDEBUG(783, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'R') goto yy775; - if (yych != 'r') goto yy186; -yy775: - YYDEBUG(775, *YYCURSOR); + if (yych == 'R') goto yy784; + if (yych != 'r') goto yy187; +yy784: + YYDEBUG(784, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy776; - if (yych != 'e') goto yy186; -yy776: - YYDEBUG(776, *YYCURSOR); + if (yych == 'E') goto yy785; + if (yych != 'e') goto yy187; +yy785: + YYDEBUG(785, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(777, *YYCURSOR); + YYDEBUG(786, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1098 "Zend/zend_language_scanner.l" +#line 1108 "Zend/zend_language_scanner.l" { return T_ENDDECLARE; } -#line 7080 "Zend/zend_language_scanner.c" -yy778: - YYDEBUG(778, *YYCURSOR); +#line 7153 "Zend/zend_language_scanner.c" +yy787: + YYDEBUG(787, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'T') goto yy779; - if (yych != 't') goto yy186; -yy779: - YYDEBUG(779, *YYCURSOR); + if (yych == 'T') goto yy788; + if (yych != 't') goto yy187; +yy788: + YYDEBUG(788, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'Y') goto yy780; - if (yych != 'y') goto yy186; -yy780: - YYDEBUG(780, *YYCURSOR); + if (yych == 'Y') goto yy789; + if (yych != 'y') goto yy187; +yy789: + YYDEBUG(789, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(781, *YYCURSOR); + YYDEBUG(790, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1284 "Zend/zend_language_scanner.l" +#line 1294 "Zend/zend_language_scanner.l" { return T_EMPTY; } -#line 7103 "Zend/zend_language_scanner.c" -yy782: - YYDEBUG(782, *YYCURSOR); +#line 7176 "Zend/zend_language_scanner.c" +yy791: + YYDEBUG(791, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'E') goto yy783; - if (yych != 'e') goto yy186; -yy783: - YYDEBUG(783, *YYCURSOR); + if (yych == 'E') goto yy792; + if (yych != 'e') goto yy187; +yy792: + YYDEBUG(792, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) <= '^') { if (yych <= '@') { - if (yych <= '/') goto yy784; - if (yych <= '9') goto yy185; + if (yych <= '/') goto yy793; + if (yych <= '9') goto yy186; } else { - if (yych == 'I') goto yy785; - if (yych <= 'Z') goto yy185; + if (yych == 'I') goto yy794; + if (yych <= 'Z') goto yy186; } } else { if (yych <= 'h') { - if (yych != '`') goto yy185; + if (yych != '`') goto yy186; } else { - if (yych <= 'i') goto yy785; - if (yych <= 'z') goto yy185; - if (yych >= 0x7F) goto yy185; + if (yych <= 'i') goto yy794; + if (yych <= 'z') goto yy186; + if (yych >= 0x7F) goto yy186; } } -yy784: - YYDEBUG(784, *YYCURSOR); +yy793: + YYDEBUG(793, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1062 "Zend/zend_language_scanner.l" +#line 1072 "Zend/zend_language_scanner.l" { return T_ELSE; } -#line 7136 "Zend/zend_language_scanner.c" -yy785: - YYDEBUG(785, *YYCURSOR); +#line 7209 "Zend/zend_language_scanner.c" +yy794: + YYDEBUG(794, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'F') goto yy786; - if (yych != 'f') goto yy186; -yy786: - YYDEBUG(786, *YYCURSOR); + if (yych == 'F') goto yy795; + if (yych != 'f') goto yy187; +yy795: + YYDEBUG(795, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(787, *YYCURSOR); + YYDEBUG(796, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1054 "Zend/zend_language_scanner.l" +#line 1064 "Zend/zend_language_scanner.l" { return T_ELSEIF; } -#line 7154 "Zend/zend_language_scanner.c" -yy788: - YYDEBUG(788, *YYCURSOR); +#line 7227 "Zend/zend_language_scanner.c" +yy797: + YYDEBUG(797, *YYCURSOR); yych = *++YYCURSOR; - if (yych == 'O') goto yy789; - if (yych != 'o') goto yy186; -yy789: - YYDEBUG(789, *YYCURSOR); + if (yych == 'O') goto yy798; + if (yych != 'o') goto yy187; +yy798: + YYDEBUG(798, *YYCURSOR); ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 4) { - goto yy185; + goto yy186; } - YYDEBUG(790, *YYCURSOR); + YYDEBUG(799, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1138 "Zend/zend_language_scanner.l" +#line 1148 "Zend/zend_language_scanner.l" { return T_ECHO; } -#line 7172 "Zend/zend_language_scanner.c" +#line 7245 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_LOOKING_FOR_PROPERTY: @@ -7207,41 +7280,41 @@ int lex_scan(zval *zendlval TSRMLS_DC) 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, }; - YYDEBUG(791, *YYCURSOR); + YYDEBUG(800, *YYCURSOR); YYFILL(2); yych = *YYCURSOR; if (yych <= '-') { if (yych <= '\r') { - if (yych <= 0x08) goto yy799; - if (yych <= '\n') goto yy793; - if (yych <= '\f') goto yy799; + if (yych <= 0x08) goto yy808; + if (yych <= '\n') goto yy802; + if (yych <= '\f') goto yy808; } else { - if (yych == ' ') goto yy793; - if (yych <= ',') goto yy799; - goto yy795; + if (yych == ' ') goto yy802; + if (yych <= ',') goto yy808; + goto yy804; } } else { if (yych <= '_') { - if (yych <= '@') goto yy799; - if (yych <= 'Z') goto yy797; - if (yych <= '^') goto yy799; - goto yy797; + if (yych <= '@') goto yy808; + if (yych <= 'Z') goto yy806; + if (yych <= '^') goto yy808; + goto yy806; } else { - if (yych <= '`') goto yy799; - if (yych <= 'z') goto yy797; - if (yych <= '~') goto yy799; - goto yy797; + if (yych <= '`') goto yy808; + if (yych <= 'z') goto yy806; + if (yych <= '~') goto yy808; + goto yy806; } } -yy793: - YYDEBUG(793, *YYCURSOR); +yy802: + YYDEBUG(802, *YYCURSOR); ++YYCURSOR; yych = *YYCURSOR; - goto yy805; -yy794: - YYDEBUG(794, *YYCURSOR); + goto yy814; +yy803: + YYDEBUG(803, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1171 "Zend/zend_language_scanner.l" +#line 1181 "Zend/zend_language_scanner.l" { zendlval->value.str.val = yytext; /* no copying - intentional */ zendlval->value.str.len = yyleng; @@ -7249,73 +7322,73 @@ int lex_scan(zval *zendlval TSRMLS_DC) HANDLE_NEWLINES(yytext, yyleng); return T_WHITESPACE; } -#line 7253 "Zend/zend_language_scanner.c" -yy795: - YYDEBUG(795, *YYCURSOR); +#line 7326 "Zend/zend_language_scanner.c" +yy804: + YYDEBUG(804, *YYCURSOR); ++YYCURSOR; - if ((yych = *YYCURSOR) == '>') goto yy802; -yy796: - YYDEBUG(796, *YYCURSOR); + if ((yych = *YYCURSOR) == '>') goto yy811; +yy805: + YYDEBUG(805, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1190 "Zend/zend_language_scanner.l" +#line 1200 "Zend/zend_language_scanner.l" { yyless(0); yy_pop_state(TSRMLS_C); goto restart; } -#line 7267 "Zend/zend_language_scanner.c" -yy797: - YYDEBUG(797, *YYCURSOR); +#line 7340 "Zend/zend_language_scanner.c" +yy806: + YYDEBUG(806, *YYCURSOR); ++YYCURSOR; yych = *YYCURSOR; - goto yy801; -yy798: - YYDEBUG(798, *YYCURSOR); + goto yy810; +yy807: + YYDEBUG(807, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1183 "Zend/zend_language_scanner.l" +#line 1193 "Zend/zend_language_scanner.l" { yy_pop_state(TSRMLS_C); zend_copy_value(zendlval, yytext, yyleng); zendlval->type = IS_STRING; return T_STRING; } -#line 7283 "Zend/zend_language_scanner.c" -yy799: - YYDEBUG(799, *YYCURSOR); +#line 7356 "Zend/zend_language_scanner.c" +yy808: + YYDEBUG(808, *YYCURSOR); yych = *++YYCURSOR; - goto yy796; -yy800: - YYDEBUG(800, *YYCURSOR); + goto yy805; +yy809: + YYDEBUG(809, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy801: - YYDEBUG(801, *YYCURSOR); +yy810: + YYDEBUG(810, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy800; + goto yy809; } - goto yy798; -yy802: - YYDEBUG(802, *YYCURSOR); + goto yy807; +yy811: + YYDEBUG(811, *YYCURSOR); ++YYCURSOR; - YYDEBUG(803, *YYCURSOR); + YYDEBUG(812, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1179 "Zend/zend_language_scanner.l" +#line 1189 "Zend/zend_language_scanner.l" { return T_OBJECT_OPERATOR; } -#line 7308 "Zend/zend_language_scanner.c" -yy804: - YYDEBUG(804, *YYCURSOR); +#line 7381 "Zend/zend_language_scanner.c" +yy813: + YYDEBUG(813, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy805: - YYDEBUG(805, *YYCURSOR); +yy814: + YYDEBUG(814, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy804; + goto yy813; } - goto yy794; + goto yy803; } /* *********************************** */ yyc_ST_LOOKING_FOR_VARNAME: @@ -7354,73 +7427,99 @@ int lex_scan(zval *zendlval TSRMLS_DC) 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; - YYDEBUG(806, *YYCURSOR); + YYDEBUG(815, *YYCURSOR); YYFILL(2); yych = *YYCURSOR; if (yych <= '_') { - if (yych <= '@') goto yy810; - if (yych <= 'Z') goto yy808; - if (yych <= '^') goto yy810; + if (yych <= '@') goto yy819; + if (yych <= 'Z') goto yy817; + if (yych <= '^') goto yy819; } else { - if (yych <= '`') goto yy810; - if (yych <= 'z') goto yy808; - if (yych <= '~') goto yy810; + if (yych <= '`') goto yy819; + if (yych <= 'z') goto yy817; + if (yych <= '~') goto yy819; } -yy808: - YYDEBUG(808, *YYCURSOR); - ++YYCURSOR; - yych = *YYCURSOR; - goto yy813; -yy809: - YYDEBUG(809, *YYCURSOR); - yyleng = YYCURSOR - SCNG(yy_text); -#line 1466 "Zend/zend_language_scanner.l" - { - zend_copy_value(zendlval, yytext, yyleng); - zendlval->type = IS_STRING; - yy_pop_state(TSRMLS_C); - yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); - return T_STRING_VARNAME; -} -#line 7386 "Zend/zend_language_scanner.c" -yy810: - YYDEBUG(810, *YYCURSOR); - ++YYCURSOR; - YYDEBUG(811, *YYCURSOR); +yy817: + YYDEBUG(817, *YYCURSOR); + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '_') { + if (yych <= '@') { + if (yych <= '/') goto yy818; + if (yych <= '9') goto yy821; + } else { + if (yych <= '[') goto yy821; + if (yych >= '_') goto yy821; + } + } else { + if (yych <= '|') { + if (yych <= '`') goto yy818; + if (yych <= 'z') goto yy821; + } else { + if (yych != '~') goto yy821; + } + } +yy818: + YYDEBUG(818, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1475 "Zend/zend_language_scanner.l" +#line 1486 "Zend/zend_language_scanner.l" { yyless(0); yy_pop_state(TSRMLS_C); yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); goto restart; } -#line 7399 "Zend/zend_language_scanner.c" -yy812: - YYDEBUG(812, *YYCURSOR); +#line 7473 "Zend/zend_language_scanner.c" +yy819: + YYDEBUG(819, *YYCURSOR); + yych = *++YYCURSOR; + goto yy818; +yy820: + YYDEBUG(820, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy813: - YYDEBUG(813, *YYCURSOR); +yy821: + YYDEBUG(821, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy812; + goto yy820; } - goto yy809; + if (yych == '[') goto yy823; + if (yych == '}') goto yy823; + YYDEBUG(822, *YYCURSOR); + YYCURSOR = YYMARKER; + goto yy818; +yy823: + YYDEBUG(823, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(824, *YYCURSOR); + yyleng = YYCURSOR - SCNG(yy_text); +#line 1476 "Zend/zend_language_scanner.l" + { + yyless(yyleng - 1); + zend_copy_value(zendlval, yytext, yyleng); + zendlval->type = IS_STRING; + yy_pop_state(TSRMLS_C); + yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); + return T_STRING_VARNAME; +} +#line 7507 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_NOWDOC: - YYDEBUG(814, *YYCURSOR); + YYDEBUG(825, *YYCURSOR); YYFILL(1); yych = *YYCURSOR; - YYDEBUG(816, *YYCURSOR); + YYDEBUG(827, *YYCURSOR); ++YYCURSOR; - YYDEBUG(817, *YYCURSOR); + YYDEBUG(828, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2357 "Zend/zend_language_scanner.l" +#line 2370 "Zend/zend_language_scanner.l" { int newline = 0; + zend_heredoc_label *heredoc_label = zend_ptr_stack_top(&SCNG(heredoc_label_stack)); + if (YYCURSOR > YYLIMIT) { return 0; } @@ -7436,8 +7535,8 @@ int lex_scan(zval *zendlval TSRMLS_DC) /* fall through */ case '\n': /* Check for ending label on the next line */ - if (IS_LABEL_START(*YYCURSOR) && CG(heredoc_len) < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, CG(heredoc), CG(heredoc_len))) { - YYCTYPE *end = YYCURSOR + CG(heredoc_len); + if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) { + YYCTYPE *end = YYCURSOR + heredoc_label->length; if (*end == ';') { end++; @@ -7472,7 +7571,7 @@ int lex_scan(zval *zendlval TSRMLS_DC) HANDLE_NEWLINES(yytext, yyleng - newline); return T_ENCAPSED_AND_WHITESPACE; } -#line 7476 "Zend/zend_language_scanner.c" +#line 7575 "Zend/zend_language_scanner.c" /* *********************************** */ yyc_ST_VAR_OFFSET: { @@ -7510,76 +7609,76 @@ int lex_scan(zval *zendlval TSRMLS_DC) 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, }; - YYDEBUG(818, *YYCURSOR); + YYDEBUG(829, *YYCURSOR); YYFILL(3); yych = *YYCURSOR; if (yych <= '/') { if (yych <= ' ') { if (yych <= '\f') { - if (yych <= 0x08) goto yy832; - if (yych <= '\n') goto yy828; - goto yy832; + if (yych <= 0x08) goto yy843; + if (yych <= '\n') goto yy839; + goto yy843; } else { - if (yych <= '\r') goto yy828; - if (yych <= 0x1F) goto yy832; - goto yy828; + if (yych <= '\r') goto yy839; + if (yych <= 0x1F) goto yy843; + goto yy839; } } else { if (yych <= '$') { - if (yych <= '"') goto yy827; - if (yych <= '#') goto yy828; - goto yy823; + if (yych <= '"') goto yy838; + if (yych <= '#') goto yy839; + goto yy834; } else { - if (yych == '\'') goto yy828; - goto yy827; + if (yych == '\'') goto yy839; + goto yy838; } } } else { if (yych <= '\\') { if (yych <= '@') { - if (yych <= '0') goto yy820; - if (yych <= '9') goto yy822; - goto yy827; + if (yych <= '0') goto yy831; + if (yych <= '9') goto yy833; + goto yy838; } else { - if (yych <= 'Z') goto yy830; - if (yych <= '[') goto yy827; - goto yy828; + if (yych <= 'Z') goto yy841; + if (yych <= '[') goto yy838; + goto yy839; } } else { if (yych <= '_') { - if (yych <= ']') goto yy825; - if (yych <= '^') goto yy827; - goto yy830; + if (yych <= ']') goto yy836; + if (yych <= '^') goto yy838; + goto yy841; } else { - if (yych <= '`') goto yy827; - if (yych <= 'z') goto yy830; - if (yych <= '~') goto yy827; - goto yy830; + if (yych <= '`') goto yy838; + if (yych <= 'z') goto yy841; + if (yych <= '~') goto yy838; + goto yy841; } } } -yy820: - YYDEBUG(820, *YYCURSOR); +yy831: + YYDEBUG(831, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= 'W') { if (yych <= '9') { - if (yych >= '0') goto yy844; + if (yych >= '0') goto yy855; } else { - if (yych == 'B') goto yy841; + if (yych == 'B') goto yy852; } } else { if (yych <= 'b') { - if (yych <= 'X') goto yy843; - if (yych >= 'b') goto yy841; + if (yych <= 'X') goto yy854; + if (yych >= 'b') goto yy852; } else { - if (yych == 'x') goto yy843; + if (yych == 'x') goto yy854; } } -yy821: - YYDEBUG(821, *YYCURSOR); +yy832: + YYDEBUG(832, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1553 "Zend/zend_language_scanner.l" +#line 1564 "Zend/zend_language_scanner.l" { /* Offset could be treated as a long */ if (yyleng < MAX_LENGTH_OF_LONG - 1 || (yyleng == MAX_LENGTH_OF_LONG - 1 && strcmp(yytext, long_min_digits) < 0)) { zendlval->value.lval = strtol(yytext, NULL, 10); @@ -7591,81 +7690,81 @@ int lex_scan(zval *zendlval TSRMLS_DC) } return T_NUM_STRING; } -#line 7595 "Zend/zend_language_scanner.c" -yy822: - YYDEBUG(822, *YYCURSOR); +#line 7694 "Zend/zend_language_scanner.c" +yy833: + YYDEBUG(833, *YYCURSOR); yych = *++YYCURSOR; - goto yy840; -yy823: - YYDEBUG(823, *YYCURSOR); + goto yy851; +yy834: + YYDEBUG(834, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) <= '_') { - if (yych <= '@') goto yy824; - if (yych <= 'Z') goto yy836; - if (yych >= '_') goto yy836; + if (yych <= '@') goto yy835; + if (yych <= 'Z') goto yy847; + if (yych >= '_') goto yy847; } else { - if (yych <= '`') goto yy824; - if (yych <= 'z') goto yy836; - if (yych >= 0x7F) goto yy836; + if (yych <= '`') goto yy835; + if (yych <= 'z') goto yy847; + if (yych >= 0x7F) goto yy847; } -yy824: - YYDEBUG(824, *YYCURSOR); +yy835: + YYDEBUG(835, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1885 "Zend/zend_language_scanner.l" +#line 1896 "Zend/zend_language_scanner.l" { /* Only '[' can be valid, but returning other tokens will allow a more explicit parse error */ return yytext[0]; } -#line 7620 "Zend/zend_language_scanner.c" -yy825: - YYDEBUG(825, *YYCURSOR); +#line 7719 "Zend/zend_language_scanner.c" +yy836: + YYDEBUG(836, *YYCURSOR); ++YYCURSOR; - YYDEBUG(826, *YYCURSOR); + YYDEBUG(837, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1880 "Zend/zend_language_scanner.l" +#line 1891 "Zend/zend_language_scanner.l" { yy_pop_state(TSRMLS_C); return ']'; } -#line 7631 "Zend/zend_language_scanner.c" -yy827: - YYDEBUG(827, *YYCURSOR); +#line 7730 "Zend/zend_language_scanner.c" +yy838: + YYDEBUG(838, *YYCURSOR); yych = *++YYCURSOR; - goto yy824; -yy828: - YYDEBUG(828, *YYCURSOR); + goto yy835; +yy839: + YYDEBUG(839, *YYCURSOR); ++YYCURSOR; - YYDEBUG(829, *YYCURSOR); + YYDEBUG(840, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1890 "Zend/zend_language_scanner.l" +#line 1901 "Zend/zend_language_scanner.l" { /* Invalid rule to return a more explicit parse error with proper line number */ yyless(0); yy_pop_state(TSRMLS_C); return T_ENCAPSED_AND_WHITESPACE; } -#line 7648 "Zend/zend_language_scanner.c" -yy830: - YYDEBUG(830, *YYCURSOR); +#line 7747 "Zend/zend_language_scanner.c" +yy841: + YYDEBUG(841, *YYCURSOR); ++YYCURSOR; yych = *YYCURSOR; - goto yy835; -yy831: - YYDEBUG(831, *YYCURSOR); + goto yy846; +yy842: + YYDEBUG(842, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1897 "Zend/zend_language_scanner.l" +#line 1908 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, yytext, yyleng); zendlval->type = IS_STRING; return T_STRING; } -#line 7663 "Zend/zend_language_scanner.c" -yy832: - YYDEBUG(832, *YYCURSOR); +#line 7762 "Zend/zend_language_scanner.c" +yy843: + YYDEBUG(843, *YYCURSOR); ++YYCURSOR; - YYDEBUG(833, *YYCURSOR); + YYDEBUG(844, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2413 "Zend/zend_language_scanner.l" +#line 2428 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -7674,118 +7773,118 @@ int lex_scan(zval *zendlval TSRMLS_DC) zend_error(E_COMPILE_WARNING,"Unexpected character in input: '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE); goto restart; } -#line 7678 "Zend/zend_language_scanner.c" -yy834: - YYDEBUG(834, *YYCURSOR); +#line 7777 "Zend/zend_language_scanner.c" +yy845: + YYDEBUG(845, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy835: - YYDEBUG(835, *YYCURSOR); +yy846: + YYDEBUG(846, *YYCURSOR); if (yybm[0+yych] & 16) { - goto yy834; + goto yy845; } - goto yy831; -yy836: - YYDEBUG(836, *YYCURSOR); + goto yy842; +yy847: + YYDEBUG(847, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(837, *YYCURSOR); + YYDEBUG(848, *YYCURSOR); if (yych <= '^') { if (yych <= '9') { - if (yych >= '0') goto yy836; + if (yych >= '0') goto yy847; } else { - if (yych <= '@') goto yy838; - if (yych <= 'Z') goto yy836; + if (yych <= '@') goto yy849; + if (yych <= 'Z') goto yy847; } } else { if (yych <= '`') { - if (yych <= '_') goto yy836; + if (yych <= '_') goto yy847; } else { - if (yych <= 'z') goto yy836; - if (yych >= 0x7F) goto yy836; + if (yych <= 'z') goto yy847; + if (yych >= 0x7F) goto yy847; } } -yy838: - YYDEBUG(838, *YYCURSOR); +yy849: + YYDEBUG(849, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1874 "Zend/zend_language_scanner.l" +#line 1885 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zendlval->type = IS_STRING; return T_VARIABLE; } -#line 7720 "Zend/zend_language_scanner.c" -yy839: - YYDEBUG(839, *YYCURSOR); +#line 7819 "Zend/zend_language_scanner.c" +yy850: + YYDEBUG(850, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy840: - YYDEBUG(840, *YYCURSOR); +yy851: + YYDEBUG(851, *YYCURSOR); if (yybm[0+yych] & 32) { - goto yy839; + goto yy850; } - goto yy821; -yy841: - YYDEBUG(841, *YYCURSOR); + goto yy832; +yy852: + YYDEBUG(852, *YYCURSOR); yych = *++YYCURSOR; if (yybm[0+yych] & 128) { - goto yy849; + goto yy860; } -yy842: - YYDEBUG(842, *YYCURSOR); +yy853: + YYDEBUG(853, *YYCURSOR); YYCURSOR = YYMARKER; - goto yy821; -yy843: - YYDEBUG(843, *YYCURSOR); + goto yy832; +yy854: + YYDEBUG(854, *YYCURSOR); yych = *++YYCURSOR; if (yybm[0+yych] & 64) { - goto yy847; + goto yy858; } - goto yy842; -yy844: - YYDEBUG(844, *YYCURSOR); + goto yy853; +yy855: + YYDEBUG(855, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(845, *YYCURSOR); - if (yych <= '/') goto yy846; - if (yych <= '9') goto yy844; -yy846: - YYDEBUG(846, *YYCURSOR); + YYDEBUG(856, *YYCURSOR); + if (yych <= '/') goto yy857; + if (yych <= '9') goto yy855; +yy857: + YYDEBUG(857, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1565 "Zend/zend_language_scanner.l" +#line 1576 "Zend/zend_language_scanner.l" { /* Offset must be treated as a string */ zendlval->value.str.val = (char *)estrndup(yytext, yyleng); zendlval->value.str.len = yyleng; zendlval->type = IS_STRING; return T_NUM_STRING; } -#line 7767 "Zend/zend_language_scanner.c" -yy847: - YYDEBUG(847, *YYCURSOR); +#line 7866 "Zend/zend_language_scanner.c" +yy858: + YYDEBUG(858, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(848, *YYCURSOR); + YYDEBUG(859, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy847; + goto yy858; } - goto yy846; -yy849: - YYDEBUG(849, *YYCURSOR); + goto yy857; +yy860: + YYDEBUG(860, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(850, *YYCURSOR); + YYDEBUG(861, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy849; + goto yy860; } - goto yy846; + goto yy857; } } -#line 2422 "Zend/zend_language_scanner.l" +#line 2437 "Zend/zend_language_scanner.l" } diff --git a/Zend/zend_language_scanner.h b/Zend/zend_language_scanner.h index 826ad7aba65d9..03ca911262c95 100644 --- a/Zend/zend_language_scanner.h +++ b/Zend/zend_language_scanner.h @@ -31,6 +31,7 @@ typedef struct _zend_lex_state { unsigned char *yy_limit; int yy_state; zend_stack state_stack; + zend_ptr_stack heredoc_label_stack; zend_file_handle *in; uint lineno; @@ -50,6 +51,10 @@ typedef struct _zend_lex_state { const zend_encoding *script_encoding; } zend_lex_state; +typedef struct _zend_heredoc_label { + char *label; + int length; +} zend_heredoc_label; BEGIN_EXTERN_C() int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2); diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index cc54557b3bb5c..d44ba20e1bb74 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -178,22 +178,23 @@ static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC) void startup_scanner(TSRMLS_D) { CG(parse_error) = 0; - CG(heredoc) = NULL; - CG(heredoc_len) = 0; CG(doc_comment) = NULL; CG(doc_comment_len) = 0; zend_stack_init(&SCNG(state_stack)); + zend_ptr_stack_init(&SCNG(heredoc_label_stack)); +} + +static void heredoc_label_dtor(zend_heredoc_label *heredoc_label) { + efree(heredoc_label->label); } void shutdown_scanner(TSRMLS_D) { - if (CG(heredoc)) { - efree(CG(heredoc)); - CG(heredoc_len)=0; - } CG(parse_error) = 0; - zend_stack_destroy(&SCNG(state_stack)); RESET_DOC_COMMENT(); + zend_stack_destroy(&SCNG(state_stack)); + zend_ptr_stack_clean(&SCNG(heredoc_label_stack), (void (*)(void *)) &heredoc_label_dtor, 1); + zend_ptr_stack_destroy(&SCNG(heredoc_label_stack)); } ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC) @@ -208,6 +209,9 @@ ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC) lex_state->state_stack = SCNG(state_stack); zend_stack_init(&SCNG(state_stack)); + lex_state->heredoc_label_stack = SCNG(heredoc_label_stack); + zend_ptr_stack_init(&SCNG(heredoc_label_stack)); + lex_state->in = SCNG(yy_in); lex_state->yy_state = YYSTATE; lex_state->filename = zend_get_compiled_filename(TSRMLS_C); @@ -234,6 +238,10 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC) zend_stack_destroy(&SCNG(state_stack)); SCNG(state_stack) = lex_state->state_stack; + zend_ptr_stack_clean(&SCNG(heredoc_label_stack), (void (*)(void *)) &heredoc_label_dtor, 1); + zend_ptr_stack_destroy(&SCNG(heredoc_label_stack)); + SCNG(heredoc_label_stack) = lex_state->heredoc_label_stack; + SCNG(yy_in) = lex_state->in; YYSETCONDITION(lex_state->yy_state); CG(zend_lineno) = lex_state->lineno; @@ -250,12 +258,6 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC) SCNG(input_filter) = lex_state->input_filter; SCNG(output_filter) = lex_state->output_filter; SCNG(script_encoding) = lex_state->script_encoding; - - if (CG(heredoc)) { - efree(CG(heredoc)); - CG(heredoc) = NULL; - CG(heredoc_len) = 0; - } } ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC) @@ -1035,6 +1037,10 @@ NEWLINE ("\r"|"\n"|"\r\n") return T_RETURN; } +"yield" { + return T_YIELD; +} + "try" { return T_TRY; } @@ -1043,6 +1049,10 @@ NEWLINE ("\r"|"\n"|"\r\n") return T_CATCH; } +"finally" { + return T_FINALLY; +} + "throw" { return T_THROW; } @@ -1463,7 +1473,8 @@ NEWLINE ("\r"|"\n"|"\r\n") } -{LABEL} { +{LABEL}[[}] { + yyless(yyleng - 1); zend_copy_value(zendlval, yytext, yyleng); zendlval->type = IS_STRING; yy_pop_state(TSRMLS_C); @@ -2106,38 +2117,35 @@ inline_html: b?"<<<"{TABS_AND_SPACES}({LABEL}|([']{LABEL}['])|(["]{LABEL}["])){NEWLINE} { char *s; int bprefix = (yytext[0] != '<') ? 1 : 0; - - /* save old heredoc label */ - Z_STRVAL_P(zendlval) = CG(heredoc); - Z_STRLEN_P(zendlval) = CG(heredoc_len); + zend_heredoc_label *heredoc_label = emalloc(sizeof(zend_heredoc_label)); CG(zend_lineno)++; - CG(heredoc_len) = yyleng-bprefix-3-1-(yytext[yyleng-2]=='\r'?1:0); + heredoc_label->length = yyleng-bprefix-3-1-(yytext[yyleng-2]=='\r'?1:0); s = yytext+bprefix+3; while ((*s == ' ') || (*s == '\t')) { s++; - CG(heredoc_len)--; + heredoc_label->length--; } if (*s == '\'') { s++; - CG(heredoc_len) -= 2; + heredoc_label->length -= 2; BEGIN(ST_NOWDOC); } else { if (*s == '"') { s++; - CG(heredoc_len) -= 2; + heredoc_label->length -= 2; } BEGIN(ST_HEREDOC); } - CG(heredoc) = estrndup(s, CG(heredoc_len)); + heredoc_label->label = estrndup(s, heredoc_label->length); /* Check for ending label on the next line */ - if (CG(heredoc_len) < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, s, CG(heredoc_len))) { - YYCTYPE *end = YYCURSOR + CG(heredoc_len); + if (heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, s, heredoc_label->length)) { + YYCTYPE *end = YYCURSOR + heredoc_label->length; if (*end == ';') { end++; @@ -2148,6 +2156,8 @@ inline_html: } } + zend_ptr_stack_push(&SCNG(heredoc_label_stack), (void *) heredoc_label); + return T_START_HEREDOC; } @@ -2159,13 +2169,14 @@ inline_html: {ANY_CHAR} { - YYCURSOR += CG(heredoc_len) - 1; - yyleng = CG(heredoc_len); + zend_heredoc_label *heredoc_label = zend_ptr_stack_pop(&SCNG(heredoc_label_stack)); + + YYCURSOR += heredoc_label->length - 1; + yyleng = heredoc_label->length; + + heredoc_label_dtor(heredoc_label); + efree(heredoc_label); - Z_STRVAL_P(zendlval) = CG(heredoc); - Z_STRLEN_P(zendlval) = CG(heredoc_len); - CG(heredoc) = NULL; - CG(heredoc_len) = 0; BEGIN(ST_IN_SCRIPTING); return T_END_HEREDOC; } @@ -2285,6 +2296,8 @@ double_quotes_scan_done: {ANY_CHAR} { int newline = 0; + zend_heredoc_label *heredoc_label = zend_ptr_stack_top(&SCNG(heredoc_label_stack)); + if (YYCURSOR > YYLIMIT) { return 0; } @@ -2300,8 +2313,8 @@ double_quotes_scan_done: /* fall through */ case '\n': /* Check for ending label on the next line */ - if (IS_LABEL_START(*YYCURSOR) && CG(heredoc_len) < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, CG(heredoc), CG(heredoc_len))) { - YYCTYPE *end = YYCURSOR + CG(heredoc_len); + if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) { + YYCTYPE *end = YYCURSOR + heredoc_label->length; if (*end == ';') { end++; @@ -2357,6 +2370,8 @@ heredoc_scan_done: {ANY_CHAR} { int newline = 0; + zend_heredoc_label *heredoc_label = zend_ptr_stack_top(&SCNG(heredoc_label_stack)); + if (YYCURSOR > YYLIMIT) { return 0; } @@ -2372,8 +2387,8 @@ heredoc_scan_done: /* fall through */ case '\n': /* Check for ending label on the next line */ - if (IS_LABEL_START(*YYCURSOR) && CG(heredoc_len) < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, CG(heredoc), CG(heredoc_len))) { - YYCTYPE *end = YYCURSOR + CG(heredoc_len); + if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) { + YYCTYPE *end = YYCURSOR + heredoc_label->length; if (*end == ';') { end++; diff --git a/Zend/zend_language_scanner_defs.h b/Zend/zend_language_scanner_defs.h index 9bde2a0e14d90..5926e3c61d971 100644 --- a/Zend/zend_language_scanner_defs.h +++ b/Zend/zend_language_scanner_defs.h @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Wed Nov 14 17:46:56 2012 */ +/* Generated by re2c 0.13.5 */ #line 3 "Zend/zend_language_scanner_defs.h" enum YYCONDTYPE { diff --git a/Zend/zend_llist.c b/Zend/zend_llist.c index 8aa369b502a8e..20f847c7812c7 100644 --- a/Zend/zend_llist.c +++ b/Zend/zend_llist.c @@ -91,15 +91,13 @@ ZEND_API void zend_llist_prepend_element(zend_llist *l, void *element) ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, void *element2)) { zend_llist_element *current=l->head; - zend_llist_element *next; while (current) { - next = current->next; if (compare(current->data, element)) { DEL_LLIST_ELEMENT(current, l); break; } - current = next; + current = current->next; } } diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h index 1e420347f55b5..d4adcf5aac982 100644 --- a/Zend/zend_modules.h +++ b/Zend/zend_modules.h @@ -33,7 +33,7 @@ #define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *zend_module TSRMLS_DC #define ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU zend_module TSRMLS_CC -#define ZEND_MODULE_API_NO 20100525 +#define ZEND_MODULE_API_NO 20121212 #ifdef ZTS #define USING_ZTS 1 #else diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index c3c9657f3b25e..e52956f417627 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -13,7 +13,7 @@ | license@zend.com so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Sascha Schumann | - | Ard Biesheuvel | + | Ard Biesheuvel | +----------------------------------------------------------------------+ */ @@ -43,6 +43,31 @@ else (lval) = __tmpvar; \ } while (0) +#elif defined(__arm__) && defined(__GNUC__) + +#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ + long __tmpvar; \ + __asm__("smull %0, %1, %2, %3\n" \ + "sub %1, %1, %0, asr #31" \ + : "=r"(__tmpvar), "=r"(usedval) \ + : "r"(a), "r"(b)); \ + if (usedval) (dval) = (double) (a) * (double) (b); \ + else (lval) = __tmpvar; \ +} while (0) + +#elif defined(__aarch64__) && defined(__GNUC__) + +#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ + long __tmpvar; \ + __asm__("mul %0, %2, %3\n" \ + "smulh %1, %2, %3\n" \ + "sub %1, %1, %0, asr #63\n" \ + : "=X"(__tmpvar), "=X"(usedval) \ + : "X"(a), "X"(b)); \ + if (usedval) (dval) = (double) (a) * (double) (b); \ + else (lval) = __tmpvar; \ +} while (0) + #elif SIZEOF_LONG == 4 && defined(HAVE_ZEND_LONG64) #define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ @@ -58,15 +83,15 @@ #else -#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ - long __lres = (a) * (b); \ - long double __dres = (long double)(a) * (long double)(b); \ - long double __delta = (long double) __lres - __dres; \ - if ( ((usedval) = (( __dres + __delta ) != __dres))) { \ - (dval) = __dres; \ - } else { \ - (lval) = __lres; \ - } \ +#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ + long __lres = (a) * (b); \ + long double __dres = (long double)(a) * (long double)(b); \ + long double __delta = (long double) __lres - __dres; \ + if ( ((usedval) = (( __dres + __delta ) != __dres))) { \ + (dval) = __dres; \ + } else { \ + (lval) = __lres; \ + } \ } while (0) #endif diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index cc45d35ecd27e..176d451e053c3 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -363,9 +363,10 @@ ZEND_API int zend_check_property_access(zend_object *zobj, const char *prop_info zend_property_info *property_info; const char *class_name, *prop_name; zval member; + int prop_name_len; - zend_unmangle_property_name(prop_info_name, prop_info_name_len, &class_name, &prop_name); - ZVAL_STRING(&member, prop_name, 0); + zend_unmangle_property_name_ex(prop_info_name, prop_info_name_len, &class_name, &prop_name, &prop_name_len); + ZVAL_STRINGL(&member, prop_name, prop_name_len, 0); property_info = zend_get_property_info_quick(zobj->ce, &member, 1, NULL TSRMLS_CC); if (!property_info) { return FAILURE; diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index e673f0197c791..db0a40035b6d3 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -70,6 +70,9 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz op_array->T = 0; + op_array->nested_calls = 0; + op_array->used_stack = 0; + op_array->function_name = NULL; op_array->filename = zend_get_compiled_filename(TSRMLS_C); op_array->doc_comment = NULL; @@ -87,6 +90,7 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz op_array->static_variables = NULL; op_array->last_try_catch = 0; + op_array->has_finally_block = 0; op_array->this_var = -1; @@ -479,6 +483,170 @@ static void zend_extension_op_array_handler(zend_extension *extension, zend_op_a } } +static void zend_check_finally_breakout(zend_op_array *op_array, zend_uint op_num, zend_uint dst_num TSRMLS_DC) +{ + zend_uint i; + + for (i = 0; i < op_array->last_try_catch; i++) { + if (op_array->try_catch_array[i].try_op > op_num) { + break; + } + if ((op_num >= op_array->try_catch_array[i].finally_op + && op_num <= op_array->try_catch_array[i].finally_end) + && (dst_num > op_array->try_catch_array[i].finally_end + || dst_num < op_array->try_catch_array[i].finally_op)) { + CG(in_compilation) = 1; + CG(active_op_array) = op_array; + CG(zend_lineno) = op_array->opcodes[op_num].lineno; + zend_error(E_COMPILE_ERROR, "jump out of a finally block is disallowed"); + } + } +} + +static void zend_resolve_finally_call(zend_op_array *op_array, zend_uint op_num, zend_uint dst_num TSRMLS_DC) +{ + zend_uint start_op; + zend_op *opline; + zend_uint i = op_array->last_try_catch; + + if (dst_num != (zend_uint)-1) { + zend_check_finally_breakout(op_array, op_num, dst_num TSRMLS_CC); + } + + /* the backward order is mater */ + while (i > 0) { + i--; + if (op_array->try_catch_array[i].finally_op && + op_num >= op_array->try_catch_array[i].try_op && + op_num < op_array->try_catch_array[i].finally_op - 1 && + (dst_num < op_array->try_catch_array[i].try_op || + dst_num > op_array->try_catch_array[i].finally_end)) { + /* we have a jump out of try block that needs executing finally */ + + /* generate a FAST_CALL to finally block */ + start_op = get_next_op_number(op_array); + + opline = get_next_op(op_array TSRMLS_CC); + opline->opcode = ZEND_FAST_CALL; + SET_UNUSED(opline->op1); + SET_UNUSED(opline->op2); + opline->op1.opline_num = op_array->try_catch_array[i].finally_op; + if (op_array->try_catch_array[i].catch_op) { + opline->extended_value = 1; + opline->op2.opline_num = op_array->try_catch_array[i].catch_op; + } + + /* generate a sequence of FAST_CALL to upward finally block */ + while (i > 0) { + i--; + if (op_array->try_catch_array[i].finally_op && + op_num >= op_array->try_catch_array[i].try_op && + op_num < op_array->try_catch_array[i].finally_op - 1 && + (dst_num < op_array->try_catch_array[i].try_op || + dst_num > op_array->try_catch_array[i].finally_end)) { + + opline = get_next_op(op_array TSRMLS_CC); + opline->opcode = ZEND_FAST_CALL; + SET_UNUSED(opline->op1); + SET_UNUSED(opline->op2); + opline->op1.opline_num = op_array->try_catch_array[i].finally_op; + } + } + + /* Finish the sequence with original opcode */ + opline = get_next_op(op_array TSRMLS_CC); + *opline = op_array->opcodes[op_num]; + + /* Replace original opcode with jump to this sequence */ + opline = op_array->opcodes + op_num; + opline->opcode = ZEND_JMP; + SET_UNUSED(opline->op1); + SET_UNUSED(opline->op2); + opline->op1.opline_num = start_op; + + break; + } + } +} + +static void zend_resolve_finally_ret(zend_op_array *op_array, zend_uint op_num TSRMLS_DC) +{ + int i; + zend_uint catch_op_num = 0, finally_op_num = 0; + + for (i = 0; i < op_array->last_try_catch; i++) { + if (op_array->try_catch_array[i].try_op > op_num) { + break; + } + if (op_num < op_array->try_catch_array[i].finally_op) { + finally_op_num = op_array->try_catch_array[i].finally_op; + } + if (op_num < op_array->try_catch_array[i].catch_op) { + catch_op_num = op_array->try_catch_array[i].catch_op; + } + } + + if (finally_op_num && (!catch_op_num || catch_op_num >= finally_op_num)) { + /* in case of unhandled exception return to upward finally block */ + op_array->opcodes[op_num].extended_value = ZEND_FAST_RET_TO_FINALLY; + op_array->opcodes[op_num].op2.opline_num = finally_op_num; + } else if (catch_op_num) { + /* in case of unhandled exception return to upward catch block */ + op_array->opcodes[op_num].extended_value = ZEND_FAST_RET_TO_CATCH; + op_array->opcodes[op_num].op2.opline_num = catch_op_num; + } +} + +static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC) +{ + zend_uint i; + zend_op *opline; + + for (i = 0; i < op_array->last; i++) { + opline = op_array->opcodes + i; + switch (opline->opcode) { + case ZEND_RETURN: + case ZEND_RETURN_BY_REF: + case ZEND_GENERATOR_RETURN: + zend_resolve_finally_call(op_array, i, (zend_uint)-1 TSRMLS_CC); + break; + case ZEND_BRK: + case ZEND_CONT: + { + int nest_levels, array_offset; + zend_brk_cont_element *jmp_to; + + nest_levels = Z_LVAL(op_array->literals[opline->op2.constant].constant); + array_offset = opline->op1.opline_num; + do { + jmp_to = &op_array->brk_cont_array[array_offset]; + if (nest_levels > 1) { + array_offset = jmp_to->parent; + } + } while (--nest_levels > 0); + zend_resolve_finally_call(op_array, i, opline->opcode == ZEND_BRK ? jmp_to->brk : jmp_to->cont TSRMLS_CC); + break; + } + case ZEND_GOTO: + if (Z_TYPE(op_array->literals[opline->op2.constant].constant) != IS_LONG) { + zend_uint num = opline->op2.constant; + opline->op2.zv = &op_array->literals[opline->op2.constant].constant; + zend_resolve_goto_label(op_array, opline, 1 TSRMLS_CC); + opline->op2.constant = num; + } + /* break omitted intentionally */ + case ZEND_JMP: + zend_resolve_finally_call(op_array, i, opline->op1.opline_num TSRMLS_CC); + break; + case ZEND_FAST_RET: + zend_resolve_finally_ret(op_array, i TSRMLS_CC); + break; + default: + break; + } + } +} + ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC) { zend_op *opline, *end; @@ -486,6 +654,9 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC) if (op_array->type!=ZEND_USER_FUNCTION && op_array->type!=ZEND_EVAL_CODE) { return 0; } + if (op_array->has_finally_block) { + zend_resolve_finally_calls(op_array TSRMLS_CC); + } if (CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO) { zend_update_extended_info(op_array TSRMLS_CC); } @@ -522,6 +693,7 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC) } /* break omitted intentionally */ case ZEND_JMP: + case ZEND_FAST_CALL: opline->op1.jmp_addr = &op_array->opcodes[opline->op1.opline_num]; break; case ZEND_JMPZ: @@ -532,6 +704,17 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC) case ZEND_JMP_SET_VAR: opline->op2.jmp_addr = &op_array->opcodes[opline->op2.opline_num]; break; + case ZEND_RETURN: + case ZEND_RETURN_BY_REF: + if (op_array->fn_flags & ZEND_ACC_GENERATOR) { + if (opline->op1_type != IS_CONST || Z_TYPE_P(opline->op1.zv) != IS_NULL) { + CG(zend_lineno) = opline->lineno; + zend_error(E_COMPILE_ERROR, "Generators cannot return values using \"return\""); + } + + opline->opcode = ZEND_GENERATOR_RETURN; + } + break; } ZEND_VM_SET_OPCODE_HANDLER(opline); opline++; diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 594f1f1057510..c8b868d16a809 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -42,6 +42,43 @@ static _locale_t current_locale = NULL; #define TYPE_PAIR(t1,t2) (((t1) << 4) | (t2)) +static const unsigned char tolower_map[256] = { +0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, +0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, +0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, +0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, +0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f, +0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x5b,0x5c,0x5d,0x5e,0x5f, +0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f, +0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f, +0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, +0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, +0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf, +0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf, +0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf, +0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf, +0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef, +0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff +}; + +#define zend_tolower_ascii(c) (tolower_map[(unsigned char)(c)]) + +/** + * Functions using locale lowercase: + zend_binary_strncasecmp_l + zend_binary_strcasecmp_l + zend_binary_zval_strcasecmp + zend_binary_zval_strncasecmp + string_compare_function_ex + string_case_compare_function + * Functions using ascii lowercase: + zend_str_tolower_copy + zend_str_tolower_dup + zend_str_tolower + zend_binary_strcasecmp + zend_binary_strncasecmp + */ + ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */ { int retval; @@ -535,6 +572,24 @@ ZEND_API void convert_to_boolean(zval *op) /* {{{ */ } /* }}} */ +ZEND_API void _convert_to_cstring(zval *op ZEND_FILE_LINE_DC) /* {{{ */ +{ + double dval; + switch (Z_TYPE_P(op)) { + case IS_DOUBLE: { + TSRMLS_FETCH(); + dval = Z_DVAL_P(op); + Z_STRLEN_P(op) = zend_spprintf(&Z_STRVAL_P(op), 0, "%.*H", (int) EG(precision), dval); + /* %H already handles removing trailing zeros from the fractional part, yay */ + break; + } + default: + _convert_to_string(op ZEND_FILE_LINE_CC); + } + Z_TYPE_P(op) = IS_STRING; +} +/* }}} */ + ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */ { long lval; @@ -1911,7 +1966,7 @@ ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned in register unsigned char *end = str + length; while (str < end) { - *result++ = zend_tolower((int)*str++); + *result++ = zend_tolower_ascii(*str++); } *result = '\0'; @@ -1931,7 +1986,7 @@ ZEND_API void zend_str_tolower(char *str, unsigned int length) /* {{{ */ register unsigned char *end = p + length; while (p < end) { - *p = zend_tolower((int)*p); + *p = zend_tolower_ascii(*p); p++; } } @@ -1978,6 +2033,49 @@ ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, u return 0; } + len = MIN(len1, len2); + while (len--) { + c1 = zend_tolower_ascii(*(unsigned char *)s1++); + c2 = zend_tolower_ascii(*(unsigned char *)s2++); + if (c1 != c2) { + return c1 - c2; + } + } + + return len1 - len2; +} +/* }}} */ + +ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */ +{ + int len; + int c1, c2; + + if (s1 == s2) { + return 0; + } + len = MIN(length, MIN(len1, len2)); + while (len--) { + c1 = zend_tolower_ascii(*(unsigned char *)s1++); + c2 = zend_tolower_ascii(*(unsigned char *)s2++); + if (c1 != c2) { + return c1 - c2; + } + } + + return MIN(length, len1) - MIN(length, len2); +} +/* }}} */ + +ZEND_API int zend_binary_strcasecmp_l(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */ +{ + int len; + int c1, c2; + + if (s1 == s2) { + return 0; + } + len = MIN(len1, len2); while (len--) { c1 = zend_tolower((int)*(unsigned char *)s1++); @@ -1991,7 +2089,7 @@ ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, u } /* }}} */ -ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */ +ZEND_API int zend_binary_strncasecmp_l(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */ { int len; int c1, c2; @@ -2026,13 +2124,13 @@ ZEND_API int zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3) /* {{{ */ ZEND_API int zend_binary_zval_strcasecmp(zval *s1, zval *s2) /* {{{ */ { - return zend_binary_strcasecmp(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2)); + return zend_binary_strcasecmp_l(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2)); } /* }}} */ ZEND_API int zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval *s3) /* {{{ */ { - return zend_binary_strncasecmp(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2), Z_LVAL_P(s3)); + return zend_binary_strncasecmp_l(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2), Z_LVAL_P(s3)); } /* }}} */ @@ -2067,7 +2165,7 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) /* {{{ */ } else if (ret2!=IS_DOUBLE) { if (oflow1) { ZVAL_LONG(result, oflow1); - return; + return; } dval2 = (double) lval2; } else if (dval1 == dval2 && !zend_finite(dval1)) { diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 02a96dd26e264..20a5277d5b639 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -301,6 +301,7 @@ ZEND_API int increment_function(zval *op1); ZEND_API int decrement_function(zval *op2); ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC); +ZEND_API void _convert_to_cstring(zval *op ZEND_FILE_LINE_DC); ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC); ZEND_API void convert_to_long(zval *op); ZEND_API void convert_to_double(zval *op); @@ -314,6 +315,7 @@ ZEND_API void multi_convert_to_double_ex(int argc, ...); ZEND_API void multi_convert_to_string_ex(int argc, ...); ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2); ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2); +#define convert_to_cstring(op) if ((op)->type != IS_STRING) { _convert_to_cstring((op) ZEND_FILE_LINE_CC); } #define convert_to_string(op) if ((op)->type != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); } ZEND_API double zend_string_to_double(const char *number, zend_uint length); @@ -340,6 +342,7 @@ ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint len2, uint length); ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, uint len2); ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length); +ZEND_API int zend_binary_strncasecmp_l(const char *s1, uint len1, const char *s2, uint len2, uint length); ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2); ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC); diff --git a/Zend/zend_ptr_stack.c b/Zend/zend_ptr_stack.c index 7d2fa2d29739c..9dbdb3ddd77a8 100644 --- a/Zend/zend_ptr_stack.c +++ b/Zend/zend_ptr_stack.c @@ -110,7 +110,6 @@ ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack) { return stack->top; } - /* * Local variables: * tab-width: 4 diff --git a/Zend/zend_ptr_stack.h b/Zend/zend_ptr_stack.h index e2e7705764155..1099240796fb5 100644 --- a/Zend/zend_ptr_stack.h +++ b/Zend/zend_ptr_stack.h @@ -111,6 +111,11 @@ static zend_always_inline void *zend_ptr_stack_pop(zend_ptr_stack *stack) return *(--stack->top_element); } +static inline void *zend_ptr_stack_top(zend_ptr_stack *stack) +{ + return stack->elements[stack->top - 1]; +} + #endif /* ZEND_PTR_STACK_H */ /* diff --git a/Zend/zend_qsort.c b/Zend/zend_qsort.c index bf179904efe58..128c48dfc8318 100644 --- a/Zend/zend_qsort.c +++ b/Zend/zend_qsort.c @@ -19,6 +19,7 @@ /* $Id$ */ #include "zend.h" +#include "zend_qsort.h" #include @@ -53,7 +54,7 @@ static void _zend_qsort_swap(void *a, void *b, size_t siz) } } -ZEND_API void zend_qsort(void *base, size_t nmemb, size_t siz, compare_func_t compare TSRMLS_DC) +ZEND_API void zend_qsort_r(void *base, size_t nmemb, size_t siz, compare_r_func_t compare, void *arg TSRMLS_DC) { void *begin_stack[QSORT_STACK_SIZE]; void *end_stack[QSORT_STACK_SIZE]; @@ -80,10 +81,10 @@ ZEND_API void zend_qsort(void *base, size_t nmemb, size_t siz, compare_func_t co seg2 = end; while (1) { - for (; seg1 < seg2 && compare(begin, seg1 TSRMLS_CC) > 0; + for (; seg1 < seg2 && compare(begin, seg1 TSRMLS_CC, arg) > 0; seg1 += siz); - for (; seg2 >= seg1 && compare(seg2, begin TSRMLS_CC) > 0; + for (; seg2 >= seg1 && compare(seg2, begin TSRMLS_CC, arg) > 0; seg2 -= siz); if (seg1 >= seg2) @@ -117,6 +118,11 @@ ZEND_API void zend_qsort(void *base, size_t nmemb, size_t siz, compare_func_t co } } +ZEND_API void zend_qsort(void *base, size_t nmemb, size_t siz, compare_func_t compare TSRMLS_DC) +{ + zend_qsort_r(base, nmemb, siz, (compare_r_func_t)compare, NULL TSRMLS_CC); +} + /* * Local Variables: * c-basic-offset: 4 diff --git a/Zend/zend_qsort.h b/Zend/zend_qsort.h index 58c99f26c2f58..0ce32a77c13d2 100644 --- a/Zend/zend_qsort.h +++ b/Zend/zend_qsort.h @@ -22,7 +22,9 @@ #define ZEND_QSORT_H BEGIN_EXTERN_C() +typedef int (*compare_r_func_t)(const void *, const void * TSRMLS_DC, void *); ZEND_API void zend_qsort(void *base, size_t nmemb, size_t siz, compare_func_t compare TSRMLS_DC); +ZEND_API void zend_qsort_r(void *base, size_t nmemb, size_t siz, compare_r_func_t compare, void *arg TSRMLS_DC); END_EXTERN_C() #endif /* ZEND_QSORT_H */ diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c index f61ae0b176cd0..6105fb11193b4 100644 --- a/Zend/zend_signal.c +++ b/Zend/zend_signal.c @@ -215,7 +215,7 @@ ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigac sa.sa_mask = global_sigmask; if (sigaction(signo, &sa, NULL) < 0) { - zend_error(E_WARNING, "Error installing signal handler for %d", signo); + zend_error(E_ERROR, "Error installing signal handler for %d", signo); } /* unsure this signal is not blocked */ @@ -267,7 +267,7 @@ static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void sa.sa_mask = global_sigmask; if (sigaction(signo, &sa, NULL) < 0) { - zend_error(E_WARNING, "Error installing signal handler for %d", signo); + zend_error(E_ERROR, "Error installing signal handler for %d", signo); } return SUCCESS; diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index e5cdd1d1fbd28..d65136cf6cdf2 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -334,7 +334,7 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMP|VAR zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW); zval *object; zval *property = GET_OP2_ZVAL_PTR(BP_VAR_R); - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (OP1_TYPE == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -465,8 +465,8 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_helper, VAR|UNUSED|CV, CONST|TMP|VAR|UNU zval *dim = GET_OP2_ZVAL_PTR(BP_VAR_R); zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, OP2_TYPE, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; @@ -1149,7 +1149,7 @@ ZEND_VM_HANDLER(92, ZEND_FETCH_FUNC_ARG, CONST|TMP|VAR|CV, UNUSED|CONST|VAR) USE_OPLINE ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, - ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R); + ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R); } ZEND_VM_HANDLER(95, ZEND_FETCH_UNSET, CONST|TMP|VAR|CV, UNUSED|CONST|VAR) @@ -1162,7 +1162,7 @@ ZEND_VM_HANDLER(89, ZEND_FETCH_IS, CONST|TMP|VAR|CV, UNUSED|CONST|VAR) ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, BP_VAR_IS); } -ZEND_VM_HANDLER(81, ZEND_FETCH_DIM_R, VAR|CV, CONST|TMP|VAR|CV) +ZEND_VM_HANDLER(81, ZEND_FETCH_DIM_R, CONST|TMP|VAR|CV, CONST|TMP|VAR|CV) { USE_OPLINE zend_free_op free_op1, free_op2; @@ -1175,10 +1175,19 @@ ZEND_VM_HANDLER(81, ZEND_FETCH_DIM_R, VAR|CV, CONST|TMP|VAR|CV) EX_T(opline->op1.var).var.ptr_ptr) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); } - container = GET_OP1_ZVAL_PTR_PTR(BP_VAR_R); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_R TSRMLS_CC); - FREE_OP2(); - FREE_OP1_VAR_PTR(); + + if (OP1_TYPE == IS_TMP_VAR || OP1_TYPE == IS_CONST) { + zval *container = GET_OP1_ZVAL_PTR(BP_VAR_R); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_R TSRMLS_CC); + FREE_OP2(); + FREE_OP1(); + } else { + container = GET_OP1_ZVAL_PTR_PTR(BP_VAR_R); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_R TSRMLS_CC); + FREE_OP2(); + FREE_OP1_VAR_PTR(); + } + CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -1262,7 +1271,7 @@ ZEND_VM_HANDLER(93, ZEND_FETCH_DIM_FUNC_ARG, VAR|CV, CONST|TMP|VAR|UNUSED|CV) SAVE_OPLINE(); - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { container = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W); if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -1309,6 +1318,7 @@ ZEND_VM_HANDLER(96, ZEND_FETCH_DIM_UNSET, VAR|CV, CONST|TMP|VAR|CV) FREE_OP1_VAR_PTR(); if (UNEXPECTED(EX_T(opline->result.var).var.ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); + ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_res; zval **retval_ptr = EX_T(opline->result.var).var.ptr_ptr; @@ -1498,7 +1508,7 @@ ZEND_VM_HANDLER(94, ZEND_FETCH_OBJ_FUNC_ARG, VAR|UNUSED|CV, CONST|TMP|VAR|CV) { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1, free_op2; zval *property; @@ -1615,7 +1625,7 @@ ZEND_VM_HANDLER(136, ZEND_ASSIGN_OBJ, VAR|UNUSED|CV, CONST|TMP|VAR|CV) if (OP1_TYPE == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (IS_OP2_TMP_FREE()) { zval_ptr_dtor(&property_name); } else { @@ -1647,7 +1657,7 @@ ZEND_VM_HANDLER(147, ZEND_ASSIGN_DIM, VAR|CV, CONST|TMP|VAR|UNUSED|CV) if (IS_OP2_TMP_FREE()) { MAKE_REAL_ZVAL_PTR(property_name); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (IS_OP2_TMP_FREE()) { zval_ptr_dtor(&property_name); } else { @@ -1662,8 +1672,8 @@ ZEND_VM_HANDLER(147, ZEND_ASSIGN_DIM, VAR|CV, CONST|TMP|VAR|UNUSED|CV) zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, OP2_TYPE, BP_VAR_W TSRMLS_CC); FREE_OP2(); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); if (UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) { if (RETURN_VALUE_USED(opline)) { @@ -1819,6 +1829,270 @@ ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VAR|CV, VAR|CV) ZEND_VM_NEXT_OPCODE(); } +ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) +{ + zend_bool nested = EX(nested); + zend_op_array *op_array = EX(op_array); + + EG(current_execute_data) = EX(prev_execute_data); + EG(opline_ptr) = NULL; + if (!EG(active_symbol_table)) { + i_free_compiled_variables(execute_data); + } + + zend_vm_stack_free((char*)execute_data - (ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T) TSRMLS_CC); + + if ((op_array->fn_flags & ZEND_ACC_CLOSURE) && op_array->prototype) { + zval_ptr_dtor((zval**)&op_array->prototype); + } + + if (nested) { + execute_data = EG(current_execute_data); + } + if (nested) { + USE_OPLINE + + LOAD_REGS(); + LOAD_OPLINE(); + if (UNEXPECTED(opline->opcode == ZEND_INCLUDE_OR_EVAL)) { + + EX(function_state).function = (zend_function *) EX(op_array); + EX(function_state).arguments = NULL; + + EG(opline_ptr) = &EX(opline); + EG(active_op_array) = EX(op_array); + EG(return_value_ptr_ptr) = EX(original_return_value); + destroy_op_array(op_array TSRMLS_CC); + efree(op_array); + if (UNEXPECTED(EG(exception) != NULL)) { + zend_throw_exception_internal(NULL TSRMLS_CC); + HANDLE_EXCEPTION_LEAVE(); + } + + ZEND_VM_INC_OPCODE(); + ZEND_VM_LEAVE(); + } else { + EG(opline_ptr) = &EX(opline); + EG(active_op_array) = EX(op_array); + EG(return_value_ptr_ptr) = EX(original_return_value); + if (EG(active_symbol_table)) { + zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); + } + EG(active_symbol_table) = EX(symbol_table); + + EX(function_state).function = (zend_function *) EX(op_array); + EX(function_state).arguments = NULL; + + if (EG(This)) { + if (UNEXPECTED(EG(exception) != NULL) && EX(call)->is_ctor_call) { + if (EX(call)->is_ctor_result_used) { + Z_DELREF_P(EG(This)); + } + if (Z_REFCOUNT_P(EG(This)) == 1) { + zend_object_store_ctor_failed(EG(This) TSRMLS_CC); + } + } + zval_ptr_dtor(&EG(This)); + } + EG(This) = EX(current_this); + EG(scope) = EX(current_scope); + EG(called_scope) = EX(current_called_scope); + + EX(call)--; + + zend_vm_stack_clear_multiple(1 TSRMLS_CC); + + if (UNEXPECTED(EG(exception) != NULL)) { + zend_throw_exception_internal(NULL TSRMLS_CC); + if (RETURN_VALUE_USED(opline) && EX_T(opline->result.var).var.ptr) { + zval_ptr_dtor(&EX_T(opline->result.var).var.ptr); + } + HANDLE_EXCEPTION_LEAVE(); + } + + ZEND_VM_INC_OPCODE(); + ZEND_VM_LEAVE(); + } + } + ZEND_VM_RETURN(); +} + +ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) +{ + USE_OPLINE + zend_bool should_change_scope = 0; + zend_function *fbc = EX(function_state).function; + + SAVE_OPLINE(); + EX(object) = EX(call)->object; + if (UNEXPECTED((fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) != 0)) { + if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_ABSTRACT) != 0)) { + zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", fbc->common.scope->name, fbc->common.function_name); + } + if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_DEPRECATED) != 0)) { + zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated", + fbc->common.scope ? fbc->common.scope->name : "", + fbc->common.scope ? "::" : "", + fbc->common.function_name); + if (UNEXPECTED(EG(exception) != NULL)) { + HANDLE_EXCEPTION(); + } + } + } + if (fbc->common.scope && + !(fbc->common.fn_flags & ZEND_ACC_STATIC) && + !EX(object)) { + + if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + /* FIXME: output identifiers properly */ + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically", fbc->common.scope->name, fbc->common.function_name); + if (UNEXPECTED(EG(exception) != NULL)) { + HANDLE_EXCEPTION(); + } + } else { + /* FIXME: output identifiers properly */ + /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically", fbc->common.scope->name, fbc->common.function_name); + } + } + + if (fbc->type == ZEND_USER_FUNCTION || fbc->common.scope) { + should_change_scope = 1; + EX(current_this) = EG(This); + EX(current_scope) = EG(scope); + EX(current_called_scope) = EG(called_scope); + EG(This) = EX(object); + EG(scope) = (fbc->type == ZEND_USER_FUNCTION || !EX(object)) ? fbc->common.scope : NULL; + EG(called_scope) = EX(call)->called_scope; + } + + EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); + zend_vm_stack_push((void*)(zend_uintptr_t)opline->extended_value TSRMLS_CC); + LOAD_OPLINE(); + + if (fbc->type == ZEND_INTERNAL_FUNCTION) { + temp_variable *ret = &EX_T(opline->result.var); + + MAKE_STD_ZVAL(ret->var.ptr); + ZVAL_NULL(ret->var.ptr); + ret->var.ptr_ptr = &ret->var.ptr; + ret->var.fcall_returned_reference = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0; + + if (fbc->common.arg_info) { + zend_uint i=0; + zval **p = (zval**)EX(function_state).arguments; + ulong arg_count = opline->extended_value; + + while (arg_count>0) { + zend_verify_arg_type(fbc, ++i, *(p-arg_count), 0 TSRMLS_CC); + arg_count--; + } + } + + if (!zend_execute_internal) { + /* saves one function call if zend_execute_internal is not used */ + fbc->internal_function.handler(opline->extended_value, ret->var.ptr, (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) ? &ret->var.ptr : NULL, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); + } else { + zend_execute_internal(execute_data, NULL, RETURN_VALUE_USED(opline) TSRMLS_CC); + } + + if (!RETURN_VALUE_USED(opline)) { + zval_ptr_dtor(&ret->var.ptr); + } + } else if (fbc->type == ZEND_USER_FUNCTION) { + EX(original_return_value) = EG(return_value_ptr_ptr); + EG(active_symbol_table) = NULL; + EG(active_op_array) = &fbc->op_array; + EG(return_value_ptr_ptr) = NULL; + if (RETURN_VALUE_USED(opline)) { + temp_variable *ret = &EX_T(opline->result.var); + + ret->var.ptr = NULL; + EG(return_value_ptr_ptr) = &ret->var.ptr; + ret->var.ptr_ptr = &ret->var.ptr; + ret->var.fcall_returned_reference = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0; + } + + if (UNEXPECTED((EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) { + if (RETURN_VALUE_USED(opline)) { + EX_T(opline->result.var).var.ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC); + } + } else if (EXPECTED(zend_execute_ex == execute_ex)) { + if (EXPECTED(EG(exception) == NULL)) { + ZEND_VM_ENTER(); + } + } else { + zend_execute(EG(active_op_array) TSRMLS_CC); + } + + EG(opline_ptr) = &EX(opline); + EG(active_op_array) = EX(op_array); + EG(return_value_ptr_ptr) = EX(original_return_value); + if (EG(active_symbol_table)) { + zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); + } + EG(active_symbol_table) = EX(symbol_table); + } else { /* ZEND_OVERLOADED_FUNCTION */ + MAKE_STD_ZVAL(EX_T(opline->result.var).var.ptr); + ZVAL_NULL(EX_T(opline->result.var).var.ptr); + + /* Not sure what should be done here if it's a static method */ + if (EXPECTED(EX(object) != NULL)) { + Z_OBJ_HT_P(EX(object))->call_method(fbc->common.function_name, opline->extended_value, EX_T(opline->result.var).var.ptr, &EX_T(opline->result.var).var.ptr, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); + } else { + zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); + } + + if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { + efree((char*)fbc->common.function_name); + } + efree(fbc); + + if (!RETURN_VALUE_USED(opline)) { + zval_ptr_dtor(&EX_T(opline->result.var).var.ptr); + } else { + Z_UNSET_ISREF_P(EX_T(opline->result.var).var.ptr); + Z_SET_REFCOUNT_P(EX_T(opline->result.var).var.ptr, 1); + EX_T(opline->result.var).var.fcall_returned_reference = 0; + EX_T(opline->result.var).var.ptr_ptr = &EX_T(opline->result.var).var.ptr; + } + } + + EX(function_state).function = (zend_function *) EX(op_array); + EX(function_state).arguments = NULL; + + if (should_change_scope) { + if (EG(This)) { + if (UNEXPECTED(EG(exception) != NULL) && EX(call)->is_ctor_call) { + if (EX(call)->is_ctor_result_used) { + Z_DELREF_P(EG(This)); + } + if (Z_REFCOUNT_P(EG(This)) == 1) { + zend_object_store_ctor_failed(EG(This) TSRMLS_CC); + } + } + zval_ptr_dtor(&EG(This)); + } + EG(This) = EX(current_this); + EG(scope) = EX(current_scope); + EG(called_scope) = EX(current_called_scope); + } + + EX(call)--; + + zend_vm_stack_clear_multiple(1 TSRMLS_CC); + + if (UNEXPECTED(EG(exception) != NULL)) { + zend_throw_exception_internal(NULL TSRMLS_CC); + if (RETURN_VALUE_USED(opline) && EX_T(opline->result.var).var.ptr) { + zval_ptr_dtor(&EX_T(opline->result.var).var.ptr); + } + HANDLE_EXCEPTION(); + } + + ZEND_VM_NEXT_OPCODE(); +} + ZEND_VM_HANDLER(42, ZEND_JMP, ANY, ANY) { USE_OPLINE @@ -1827,7 +2101,7 @@ ZEND_VM_HANDLER(42, ZEND_JMP, ANY, ANY) printf("Jumping to %d\n", opline->op1.opline_num); #endif ZEND_VM_SET_OPCODE(opline->op1.jmp_addr); - ZEND_VM_CONTINUE(); /* CHECK_ME */ + ZEND_VM_CONTINUE(); } ZEND_VM_HANDLER(43, ZEND_JMPZ, CONST|TMP|VAR|CV, ANY) @@ -2112,7 +2386,9 @@ ZEND_VM_HANDLER(109, ZEND_FETCH_CLASS, ANY, CONST|TMP|VAR|UNUSED|CV) USE_OPLINE SAVE_OPLINE(); - EG(exception) = NULL; + if (EG(exception)) { + zend_exception_save(TSRMLS_C); + } if (OP2_TYPE == IS_UNUSED) { EX_T(opline->result.var).class_entry = zend_fetch_class(NULL, 0, opline->extended_value TSRMLS_CC); CHECK_EXCEPTION(); @@ -2149,9 +2425,9 @@ ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV) char *function_name_strval; int function_name_strlen; zend_free_op free_op1, free_op2; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); function_name = GET_OP2_ZVAL_PTR(BP_VAR_R); @@ -2163,49 +2439,55 @@ ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV) function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_R); + call->object = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_R); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (OP2_TYPE != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((OP2_TYPE == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((OP2_TYPE == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (OP2_TYPE == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + FREE_OP2(); + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; FREE_OP2(); FREE_OP1_IF_VAR(); @@ -2219,9 +2501,9 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS USE_OPLINE zval *function_name; zend_class_entry *ce; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (OP1_TYPE == IS_CONST) { /* no function found. try a static method in class */ @@ -2235,24 +2517,24 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS } CACHE_PTR(opline->op1.literal->cache_slot, ce); } - EX(called_scope) = ce; + call->called_scope = ce; } else { ce = EX_T(opline->op1.var).class_entry; if (opline->extended_value == ZEND_FETCH_CLASS_PARENT || opline->extended_value == ZEND_FETCH_CLASS_SELF) { - EX(called_scope) = EG(called_scope); + call->called_scope = EG(called_scope); } else { - EX(called_scope) = ce; + call->called_scope = ce; } } if (OP1_TYPE == IS_CONST && OP2_TYPE == IS_CONST && CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); } else if (OP1_TYPE != IS_CONST && OP2_TYPE == IS_CONST && - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { /* do nothing */ } else if (OP2_TYPE != IS_UNUSED) { char *function_name_strval = NULL; @@ -2275,20 +2557,20 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS if (function_name_strval) { if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + call->fbc = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((OP2_TYPE == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((OP2_TYPE == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, function_name_strval); } if (OP2_TYPE == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { if (OP1_TYPE == IS_CONST) { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } else { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, EX(fbc)); + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, call->fbc); } } } @@ -2302,29 +2584,31 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS if (EG(This) && Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name); } - EX(fbc) = ce->constructor; + call->fbc = ce->constructor; } - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; + if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { + call->object = NULL; } else { if (EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + if (call->fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } } - if ((EX(object) = EG(This))) { - Z_ADDREF_P(EX(object)); - EX(called_scope) = Z_OBJCE_P(EX(object)); + if ((call->object = EG(This))) { + Z_ADDREF_P(call->object); + call->called_scope = Z_OBJCE_P(call->object); } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -2334,19 +2618,22 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV) { USE_OPLINE zval *function_name; - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + call_slot *call = EX(call_slots) + opline->result.num; if (OP2_TYPE == IS_CONST) { function_name = (zval*)(opline->op2.literal+1); if (CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); - } else if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)+1, Z_HASH_P(function_name), (void **) &EX(fbc)) == FAILURE)) { + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); + } else if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)+1, Z_HASH_P(function_name), (void **) &call->fbc) == FAILURE)) { SAVE_OPLINE(); zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv)); } else { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - EX(object) = NULL; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; /*CHECK_EXCEPTION();*/ ZEND_VM_NEXT_OPCODE(); } else { @@ -2366,425 +2653,142 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV) } else { lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } - if (UNEXPECTED(zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)) == FAILURE)) { + if (UNEXPECTED(zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &call->fbc) == FAILURE)) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } efree(lcname); FREE_OP2(); - EX(object) = NULL; - CHECK_EXCEPTION(); - ZEND_VM_NEXT_OPCODE(); - } else if (OP2_TYPE != IS_CONST && OP2_TYPE != IS_TMP_VAR && - EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) && - Z_OBJ_HANDLER_P(function_name, get_closure) && - Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &EX(called_scope), &EX(fbc), &EX(object) TSRMLS_CC) == SUCCESS) { - if (EX(object)) { - Z_ADDREF_P(EX(object)); - } - if (OP2_TYPE == IS_VAR && OP2_FREE && - EX(fbc)->common.fn_flags & ZEND_ACC_CLOSURE) { - /* Delay closure destruction until its invocation */ - EX(fbc)->common.prototype = (zend_function*)function_name; - } else { - FREE_OP2(); - } + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); - } else if (OP2_TYPE != IS_CONST && - EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) && - zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) { - zend_class_entry *ce; - zval **method = NULL; - zval **obj = NULL; - - zend_hash_index_find(Z_ARRVAL_P(function_name), 0, (void **) &obj); - zend_hash_index_find(Z_ARRVAL_P(function_name), 1, (void **) &method); - - if (!obj || !method) { - zend_error_noreturn(E_ERROR, "Array callback has to contain indices 0 and 1"); - } - - if (Z_TYPE_PP(obj) != IS_STRING && Z_TYPE_PP(obj) != IS_OBJECT) { - zend_error_noreturn(E_ERROR, "First array member is not a valid class name or object"); - } - - if (Z_TYPE_PP(method) != IS_STRING) { - zend_error_noreturn(E_ERROR, "Second array member is not a valid method"); - } - - if (Z_TYPE_PP(obj) == IS_STRING) { - ce = zend_fetch_class_by_name(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), NULL, 0 TSRMLS_CC); - if (UNEXPECTED(ce == NULL)) { - CHECK_EXCEPTION(); - ZEND_VM_NEXT_OPCODE(); - } - EX(called_scope) = ce; - EX(object) = NULL; - - if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method) TSRMLS_CC); - } else { - EX(fbc) = zend_std_get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); - } - } else { - EX(object) = *obj; - ce = EX(called_scope) = Z_OBJCE_PP(obj); - - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), Z_STRVAL_PP(method)); - } - - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; - } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ - } else { - zval *this_ptr; - ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); - zval_copy_ctor(this_ptr); - EX(object) = this_ptr; - } - } - } - - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, Z_STRVAL_PP(method)); - } - FREE_OP2(); - CHECK_EXCEPTION(); - ZEND_VM_NEXT_OPCODE(); - } else { - zend_error_noreturn(E_ERROR, "Function name must be a string"); - } - } -} - - -ZEND_VM_HANDLER(69, ZEND_INIT_NS_FCALL_BY_NAME, ANY, CONST) -{ - USE_OPLINE - zend_literal *func_name; - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - - func_name = opline->op2.literal + 1; - if (CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); - } else if (zend_hash_quick_find(EG(function_table), Z_STRVAL(func_name->constant), Z_STRLEN(func_name->constant)+1, func_name->hash_value, (void **) &EX(fbc))==FAILURE) { - func_name++; - if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL(func_name->constant), Z_STRLEN(func_name->constant)+1, func_name->hash_value, (void **) &EX(fbc))==FAILURE)) { - SAVE_OPLINE(); - zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv)); - } else { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); - } - } else { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); - } - - EX(object) = NULL; - ZEND_VM_NEXT_OPCODE(); -} - -ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) -{ - zend_bool nested; - zend_op_array *op_array = EX(op_array); - - EG(current_execute_data) = EX(prev_execute_data); - EG(opline_ptr) = NULL; - if (!EG(active_symbol_table)) { - zval ***cv = EX_CVs(); - zval ***end = cv + op_array->last_var; - while (cv != end) { - if (*cv) { - zval_ptr_dtor(*cv); - } - cv++; - } - } - - if ((op_array->fn_flags & ZEND_ACC_CLOSURE) && op_array->prototype) { - zval_ptr_dtor((zval**)&op_array->prototype); - } - - nested = EX(nested); - - zend_vm_stack_free(execute_data TSRMLS_CC); - - if (nested) { - execute_data = EG(current_execute_data); - } - if (nested) { - USE_OPLINE - - LOAD_REGS(); - LOAD_OPLINE(); - if (UNEXPECTED(opline->opcode == ZEND_INCLUDE_OR_EVAL)) { - - EX(function_state).function = (zend_function *) EX(op_array); - EX(function_state).arguments = NULL; - EX(object) = EX(current_object); - - EG(opline_ptr) = &EX(opline); - EG(active_op_array) = EX(op_array); - EG(return_value_ptr_ptr) = EX(original_return_value); - destroy_op_array(op_array TSRMLS_CC); - efree(op_array); - if (UNEXPECTED(EG(exception) != NULL)) { - zend_throw_exception_internal(NULL TSRMLS_CC); - HANDLE_EXCEPTION_LEAVE(); - } else if (RETURN_VALUE_USED(opline)) { - if (!EX_T(opline->result.var).var.ptr) { /* there was no return statement */ - zval *retval; - - ALLOC_ZVAL(retval); - ZVAL_BOOL(retval, 1); - INIT_PZVAL(retval); - EX_T(opline->result.var).var.ptr = retval; - } - } - - ZEND_VM_INC_OPCODE(); - ZEND_VM_LEAVE(); - } else { - - EG(opline_ptr) = &EX(opline); - EG(active_op_array) = EX(op_array); - EG(return_value_ptr_ptr) = EX(original_return_value); - if (EG(active_symbol_table)) { - if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { - zend_hash_destroy(EG(active_symbol_table)); - FREE_HASHTABLE(EG(active_symbol_table)); - } else { - /* clean before putting into the cache, since clean - could call dtors, which could use cached hash */ - zend_hash_clean(EG(active_symbol_table)); - *(++EG(symtable_cache_ptr)) = EG(active_symbol_table); - } - } - EG(active_symbol_table) = EX(symbol_table); - - EX(function_state).function = (zend_function *) EX(op_array); - EX(function_state).arguments = NULL; - - if (EG(This)) { - if (UNEXPECTED(EG(exception) != NULL) && IS_CTOR_CALL(EX(called_scope))) { - if (IS_CTOR_USED(EX(called_scope))) { - Z_DELREF_P(EG(This)); - } - if (Z_REFCOUNT_P(EG(This)) == 1) { - zend_object_store_ctor_failed(EG(This) TSRMLS_CC); - } - } - zval_ptr_dtor(&EG(This)); - } - EG(This) = EX(current_this); - EG(scope) = EX(current_scope); - EG(called_scope) = EX(current_called_scope); - - EX(object) = EX(current_object); - EX(called_scope) = DECODE_CTOR(EX(called_scope)); - - zend_vm_stack_clear_multiple(TSRMLS_C); - - if (UNEXPECTED(EG(exception) != NULL)) { - zend_throw_exception_internal(NULL TSRMLS_CC); - if (RETURN_VALUE_USED(opline) && EX_T(opline->result.var).var.ptr) { - zval_ptr_dtor(&EX_T(opline->result.var).var.ptr); - } - HANDLE_EXCEPTION_LEAVE(); - } - - ZEND_VM_INC_OPCODE(); - ZEND_VM_LEAVE(); - } - } - ZEND_VM_RETURN(); -} - -ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) -{ - USE_OPLINE - zend_bool should_change_scope = 0; - zend_function *fbc = EX(function_state).function; - - SAVE_OPLINE(); - if (UNEXPECTED((fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) != 0)) { - if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_ABSTRACT) != 0)) { - zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", fbc->common.scope->name, fbc->common.function_name); - CHECK_EXCEPTION(); - ZEND_VM_NEXT_OPCODE(); /* Never reached */ - } - if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_DEPRECATED) != 0)) { - zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated", - fbc->common.scope ? fbc->common.scope->name : "", - fbc->common.scope ? "::" : "", - fbc->common.function_name); - } - } - if (fbc->common.scope && - !(fbc->common.fn_flags & ZEND_ACC_STATIC) && - !EX(object)) { - - if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - /* FIXME: output identifiers properly */ - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically", fbc->common.scope->name, fbc->common.function_name); - } else { - /* FIXME: output identifiers properly */ - /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically", fbc->common.scope->name, fbc->common.function_name); - } - } - - if (fbc->type == ZEND_USER_FUNCTION || fbc->common.scope) { - should_change_scope = 1; - EX(current_this) = EG(This); - EX(current_scope) = EG(scope); - EX(current_called_scope) = EG(called_scope); - EG(This) = EX(object); - EG(scope) = (fbc->type == ZEND_USER_FUNCTION || !EX(object)) ? fbc->common.scope : NULL; - EG(called_scope) = EX(called_scope); - } - - zend_arg_types_stack_3_pop(&EG(arg_types_stack), &EX(called_scope), &EX(current_object), &EX(fbc)); - EX(function_state).arguments = zend_vm_stack_push_args(opline->extended_value TSRMLS_CC); - LOAD_OPLINE(); - - if (fbc->type == ZEND_INTERNAL_FUNCTION) { - temp_variable *ret = &EX_T(opline->result.var); - - MAKE_STD_ZVAL(ret->var.ptr); - ZVAL_NULL(ret->var.ptr); - ret->var.ptr_ptr = &ret->var.ptr; - ret->var.fcall_returned_reference = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0; - - if (fbc->common.arg_info) { - zend_uint i=0; - zval **p = (zval**)EX(function_state).arguments; - ulong arg_count = opline->extended_value; - - while (arg_count>0) { - zend_verify_arg_type(fbc, ++i, *(p-arg_count), 0 TSRMLS_CC); - arg_count--; - } - } - - if (!zend_execute_internal) { - /* saves one function call if zend_execute_internal is not used */ - fbc->internal_function.handler(opline->extended_value, ret->var.ptr, (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) ? &ret->var.ptr : NULL, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); - } else { - zend_execute_internal(EXECUTE_DATA, RETURN_VALUE_USED(opline) TSRMLS_CC); - } - - if (!RETURN_VALUE_USED(opline)) { - zval_ptr_dtor(&ret->var.ptr); - } - } else if (fbc->type == ZEND_USER_FUNCTION) { - EX(original_return_value) = EG(return_value_ptr_ptr); - EG(active_symbol_table) = NULL; - EG(active_op_array) = &fbc->op_array; - EG(return_value_ptr_ptr) = NULL; - if (RETURN_VALUE_USED(opline)) { - temp_variable *ret = &EX_T(opline->result.var); + } else if (OP2_TYPE != IS_CONST && OP2_TYPE != IS_TMP_VAR && + EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) && + Z_OBJ_HANDLER_P(function_name, get_closure) && + Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &call->called_scope, &call->fbc, &call->object TSRMLS_CC) == SUCCESS) { + if (call->object) { + Z_ADDREF_P(call->object); + } + if (OP2_TYPE == IS_VAR && OP2_FREE && + call->fbc->common.fn_flags & ZEND_ACC_CLOSURE) { + /* Delay closure destruction until its invocation */ + call->fbc->common.prototype = (zend_function*)function_name; + } else { + FREE_OP2(); + } + call->is_ctor_call = 0; + EX(call) = call; + CHECK_EXCEPTION(); + ZEND_VM_NEXT_OPCODE(); + } else if (OP2_TYPE != IS_CONST && + EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) && + zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) { + zend_class_entry *ce; + zval **method = NULL; + zval **obj = NULL; - ret->var.ptr = NULL; - EG(return_value_ptr_ptr) = &ret->var.ptr; - ret->var.ptr_ptr = &ret->var.ptr; - ret->var.fcall_returned_reference = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0; - } + zend_hash_index_find(Z_ARRVAL_P(function_name), 0, (void **) &obj); + zend_hash_index_find(Z_ARRVAL_P(function_name), 1, (void **) &method); - if (EXPECTED(zend_execute == execute)) { - if (EXPECTED(EG(exception) == NULL)) { - ZEND_VM_ENTER(); + if (!obj || !method) { + zend_error_noreturn(E_ERROR, "Array callback has to contain indices 0 and 1"); } - } else { - zend_execute(EG(active_op_array) TSRMLS_CC); - } - EG(opline_ptr) = &EX(opline); - EG(active_op_array) = EX(op_array); - EG(return_value_ptr_ptr) = EX(original_return_value); - if (EG(active_symbol_table)) { - if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { - zend_hash_destroy(EG(active_symbol_table)); - FREE_HASHTABLE(EG(active_symbol_table)); - } else { - /* clean before putting into the cache, since clean - could call dtors, which could use cached hash */ - zend_hash_clean(EG(active_symbol_table)); - *(++EG(symtable_cache_ptr)) = EG(active_symbol_table); + if (Z_TYPE_PP(obj) != IS_STRING && Z_TYPE_PP(obj) != IS_OBJECT) { + zend_error_noreturn(E_ERROR, "First array member is not a valid class name or object"); } - } - EG(active_symbol_table) = EX(symbol_table); - } else { /* ZEND_OVERLOADED_FUNCTION */ - MAKE_STD_ZVAL(EX_T(opline->result.var).var.ptr); - ZVAL_NULL(EX_T(opline->result.var).var.ptr); - - /* Not sure what should be done here if it's a static method */ - if (EXPECTED(EX(object) != NULL)) { - Z_OBJ_HT_P(EX(object))->call_method(fbc->common.function_name, opline->extended_value, EX_T(opline->result.var).var.ptr, &EX_T(opline->result.var).var.ptr, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); - } else { - zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); - } - if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { - efree((char*)fbc->common.function_name); - } - efree(fbc); + if (Z_TYPE_PP(method) != IS_STRING) { + zend_error_noreturn(E_ERROR, "Second array member is not a valid method"); + } - if (!RETURN_VALUE_USED(opline)) { - zval_ptr_dtor(&EX_T(opline->result.var).var.ptr); - } else { - Z_UNSET_ISREF_P(EX_T(opline->result.var).var.ptr); - Z_SET_REFCOUNT_P(EX_T(opline->result.var).var.ptr, 1); - EX_T(opline->result.var).var.fcall_returned_reference = 0; - EX_T(opline->result.var).var.ptr_ptr = &EX_T(opline->result.var).var.ptr; - } - } + if (Z_TYPE_PP(obj) == IS_STRING) { + ce = zend_fetch_class_by_name(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), NULL, 0 TSRMLS_CC); + if (UNEXPECTED(ce == NULL)) { + CHECK_EXCEPTION(); + ZEND_VM_NEXT_OPCODE(); + } + call->called_scope = ce; + call->object = NULL; - EX(function_state).function = (zend_function *) EX(op_array); - EX(function_state).arguments = NULL; + if (ce->get_static_method) { + call->fbc = ce->get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method) TSRMLS_CC); + } else { + call->fbc = zend_std_get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); + } + } else { + call->object = *obj; + ce = call->called_scope = Z_OBJCE_PP(obj); - if (should_change_scope) { - if (EG(This)) { - if (UNEXPECTED(EG(exception) != NULL) && IS_CTOR_CALL(EX(called_scope))) { - if (IS_CTOR_USED(EX(called_scope))) { - Z_DELREF_P(EG(This)); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_PP(method)); } - if (Z_REFCOUNT_P(EG(This)) == 1) { - zend_object_store_ctor_failed(EG(This) TSRMLS_CC); + + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; + } else { + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ + } else { + zval *this_ptr; + ALLOC_ZVAL(this_ptr); + INIT_PZVAL_COPY(this_ptr, call->object); + zval_copy_ctor(this_ptr); + call->object = this_ptr; + } } } - zval_ptr_dtor(&EG(This)); + + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, Z_STRVAL_PP(method)); + } + call->is_ctor_call = 0; + EX(call) = call; + FREE_OP2(); + CHECK_EXCEPTION(); + ZEND_VM_NEXT_OPCODE(); + } else { + zend_error_noreturn(E_ERROR, "Function name must be a string"); + ZEND_VM_NEXT_OPCODE(); /* Never reached */ } - EG(This) = EX(current_this); - EG(scope) = EX(current_scope); - EG(called_scope) = EX(current_called_scope); } +} - EX(object) = EX(current_object); - EX(called_scope) = DECODE_CTOR(EX(called_scope)); - zend_vm_stack_clear_multiple(TSRMLS_C); +ZEND_VM_HANDLER(69, ZEND_INIT_NS_FCALL_BY_NAME, ANY, CONST) +{ + USE_OPLINE + zend_literal *func_name; + call_slot *call = EX(call_slots) + opline->result.num; - if (UNEXPECTED(EG(exception) != NULL)) { - zend_throw_exception_internal(NULL TSRMLS_CC); - if (RETURN_VALUE_USED(opline) && EX_T(opline->result.var).var.ptr) { - zval_ptr_dtor(&EX_T(opline->result.var).var.ptr); + func_name = opline->op2.literal + 1; + if (CACHED_PTR(opline->op2.literal->cache_slot)) { + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); + } else if (zend_hash_quick_find(EG(function_table), Z_STRVAL(func_name->constant), Z_STRLEN(func_name->constant)+1, func_name->hash_value, (void **) &call->fbc)==FAILURE) { + func_name++; + if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL(func_name->constant), Z_STRLEN(func_name->constant)+1, func_name->hash_value, (void **) &call->fbc)==FAILURE)) { + SAVE_OPLINE(); + zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv)); + } else { + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - HANDLE_EXCEPTION(); + } else { + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; ZEND_VM_NEXT_OPCODE(); } ZEND_VM_HANDLER(61, ZEND_DO_FCALL_BY_NAME, ANY, ANY) { - EX(function_state).function = EX(fbc); + EX(function_state).function = EX(call)->fbc; ZEND_VM_DISPATCH_TO_HELPER(zend_do_fcall_common_helper); } @@ -2793,8 +2797,7 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, CONST, ANY) USE_OPLINE zend_free_op free_op1; zval *fname = GET_OP1_ZVAL_PTR(BP_VAR_R); - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + call_slot *call = EX(call_slots) + opline->op2.num; if (CACHED_PTR(opline->op1.literal->cache_slot)) { EX(function_state).function = CACHED_PTR(opline->op1.literal->cache_slot); @@ -2804,7 +2807,11 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, CONST, ANY) } else { CACHE_PTR(opline->op1.literal->cache_slot, EX(function_state).function); } - EX(object) = NULL; + call->fbc = EX(function_state).function; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; FREE_OP1(); @@ -2825,6 +2832,9 @@ ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY) FREE_OP1(); } } else if (!IS_OP1_TMP_FREE()) { /* Not a temp var */ + if (*EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } if (OP1_TYPE == IS_CONST || (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) { zval *ret; @@ -2846,6 +2856,10 @@ ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY) } else { zval *ret; + if (*EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } + ALLOC_ZVAL(ret); INIT_PZVAL_COPY(ret, retval_ptr); *EG(return_value_ptr_ptr) = ret; @@ -2864,6 +2878,10 @@ ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY) SAVE_OPLINE(); do { + if (EG(return_value_ptr_ptr) && *EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } + if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR) { /* Not supposed to happen, but we'll allow it */ zend_error(E_NOTICE, "Only variable references should be returned by reference"); @@ -2922,6 +2940,18 @@ ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY) ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); } +ZEND_VM_HANDLER(161, ZEND_GENERATOR_RETURN, ANY, ANY) +{ + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + /* Close the generator to free up resources */ + zend_generator_close(generator, 1 TSRMLS_CC); + + /* Pass execution back to handling code */ + ZEND_VM_RETURN(); +} + ZEND_VM_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY) { USE_OPLINE @@ -2993,7 +3023,7 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV) if (EX_CV(opline->op2.var)) { zval_ptr_dtor(EX_CV(opline->op2.var)); } - EX_CV(opline->op2.var) = (zval**)EX_CVs() + (EX(op_array)->last_var + opline->op2.var); + EX_CV(opline->op2.var) = (zval**)EX_CV_NUM(execute_data, EX(op_array)->last_var + opline->op2.var); *EX_CV(opline->op2.var) = EG(exception); } else { zend_compiled_variable *cv = &CV_DEF_OF(opline->op2.var); @@ -3015,7 +3045,7 @@ ZEND_VM_HANDLER(65, ZEND_SEND_VAL, CONST|TMP, ANY) SAVE_OPLINE(); if (opline->extended_value==ZEND_DO_FCALL_BY_NAME - && ARG_MUST_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + && ARG_MUST_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.opline_num); } { @@ -3076,7 +3106,7 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY) if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); } - } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); } @@ -3102,7 +3132,7 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY) if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ? !(opline->extended_value & ZEND_ARG_SEND_SILENT) : - !ARG_MAY_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + !ARG_MAY_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { zend_error(E_STRICT, "Only variables should be passed by reference"); } ALLOC_ZVAL(valptr); @@ -3138,7 +3168,7 @@ ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, ANY) ZEND_VM_NEXT_OPCODE(); } - if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION && !ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION && !ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); } @@ -3157,7 +3187,7 @@ ZEND_VM_HANDLER(66, ZEND_SEND_VAR, VAR|CV, ANY) USE_OPLINE if ((opline->extended_value == ZEND_DO_FCALL_BY_NAME) - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + && ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_REF); } SAVE_OPLINE(); @@ -3195,7 +3225,7 @@ ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY) zval **var_ptr; zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, *param, opline->extended_value TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->result.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC); Z_DELREF_PP(var_ptr); *var_ptr = *param; Z_ADDREF_PP(var_ptr); @@ -3231,7 +3261,7 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST) } zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value, opline->extended_value TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->result.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC); Z_DELREF_PP(var_ptr); *var_ptr = assignment_value; @@ -3261,7 +3291,7 @@ ZEND_VM_HANDLER(50, ZEND_BRK, ANY, CONST) SAVE_OPLINE(); el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num, - EX(op_array), EX_Ts() TSRMLS_CC); + EX(op_array), execute_data TSRMLS_CC); FREE_OP2(); ZEND_VM_JMP(EX(op_array)->opcodes + el->brk); } @@ -3273,7 +3303,7 @@ ZEND_VM_HANDLER(51, ZEND_CONT, ANY, CONST) SAVE_OPLINE(); el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num, - EX(op_array), EX_Ts() TSRMLS_CC); + EX(op_array), execute_data TSRMLS_CC); FREE_OP2(); ZEND_VM_JMP(EX(op_array)->opcodes + el->cont); } @@ -3286,7 +3316,7 @@ ZEND_VM_HANDLER(100, ZEND_GOTO, ANY, CONST) SAVE_OPLINE(); el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->extended_value, - EX(op_array), EX_Ts() TSRMLS_CC); + EX(op_array), execute_data TSRMLS_CC); brk_opline = EX(op_array)->opcodes + el->brk; @@ -3363,17 +3393,20 @@ ZEND_VM_HANDLER(68, ZEND_NEW, ANY, ANY) } ZEND_VM_JMP(EX(op_array)->opcodes + opline->op2.opline_num); } else { + call_slot *call = EX(call_slots) + opline->extended_value; + if (RETURN_VALUE_USED(opline)) { PZVAL_LOCK(object_zval); AI_SET_PTR(&EX_T(opline->result.var), object_zval); } - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), ENCODE_CTOR(EX(called_scope), RETURN_VALUE_USED(opline))); - /* We are not handling overloaded classes right now */ - EX(object) = object_zval; - EX(fbc) = constructor; - EX(called_scope) = EX_T(opline->op1.var).class_entry; + call->fbc = constructor; + call->object = object_zval; + call->called_scope = EX_T(opline->op1.var).class_entry; + call->is_ctor_call = 1; + call->is_ctor_result_used = RETURN_VALUE_USED(opline); + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -3526,6 +3559,9 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST) } ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, *value); zval_copy_ctor(&EX_T(opline->result.var).tmp_var); + } else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && strcmp(Z_STRVAL_P(opline->op2.zv), "class") == 0) { + /* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */ + ZVAL_STRINGL(&EX_T(opline->result.var).tmp_var, ce->name, ce->name_length, 1); } else { zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv)); } @@ -3700,7 +3736,7 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY) zend_op_array *new_op_array=NULL; zend_free_op free_op1; zval *inc_filename; - zval *tmp_inc_filename = NULL; + zval *tmp_inc_filename = NULL; zend_bool failure_retval=0; SAVE_OPLINE(); @@ -3792,8 +3828,6 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY) EG(return_value_ptr_ptr) = NULL; } - EX(current_object) = EX(object); - EX(function_state).function = (zend_function *) new_op_array; EX(object) = NULL; @@ -3801,14 +3835,13 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY) zend_rebuild_symbol_table(TSRMLS_C); } - if (EXPECTED(zend_execute == execute)) { + if (EXPECTED(zend_execute_ex == execute_ex)) { ZEND_VM_ENTER(); } else { zend_execute(new_op_array TSRMLS_CC); } EX(function_state).function = (zend_function *) EX(op_array); - EX(object) = EX(current_object); EG(opline_ptr) = &EX(opline); EG(active_op_array) = EX(op_array); @@ -3818,15 +3851,6 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY) if (UNEXPECTED(EG(exception) != NULL)) { zend_throw_exception_internal(NULL TSRMLS_CC); HANDLE_EXCEPTION(); - } else if (RETURN_VALUE_USED(opline)) { - if (!EX_T(opline->result.var).var.ptr) { /* there was no return statement */ - zval *retval; - - ALLOC_ZVAL(retval); - ZVAL_BOOL(retval, 1); - INIT_PZVAL(retval); - EX_T(opline->result.var).var.ptr = retval; - } } } else if (RETURN_VALUE_USED(opline)) { @@ -3903,7 +3927,7 @@ ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR) ulong hash_value = zend_inline_hash_func(varname->value.str.val, varname->value.str.len+1); target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - zend_delete_variable(EXECUTE_DATA, target_symbol_table, varname->value.str.val, varname->value.str.len+1, hash_value TSRMLS_CC); + zend_delete_variable(execute_data, target_symbol_table, varname->value.str.val, varname->value.str.len+1, hash_value TSRMLS_CC); } if (OP1_TYPE != IS_CONST && varname == &tmp) { @@ -4241,8 +4265,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) zend_check_property_access(zobj, str_key, str_key_len-1 TSRMLS_CC) != SUCCESS)); zend_hash_get_pointer(fe_ht, &EX_T(opline->op1.var).fe.fe_pos); if (use_key && key_type != HASH_KEY_IS_LONG) { - zend_unmangle_property_name(str_key, str_key_len-1, &class_name, &prop_name); - str_key_len = strlen(prop_name); + zend_unmangle_property_name_ex(str_key, str_key_len-1, &class_name, &prop_name, &str_key_len); str_key = estrndup(prop_name, str_key_len); str_key_len++; } @@ -4980,13 +5003,15 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) { zend_uint op_num = EG(opline_before_exception)-EG(active_op_array)->opcodes; int i; - zend_uint catch_op_num = 0; - int catched = 0; - zval restored_error_reporting; + zend_uint catch_op_num = 0, finally_op_num = 0; + void **stack_frame; - void **stack_frame = (void**)(((char*)EX_Ts()) + - (ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * EX(op_array)->T)); + /* Figure out where the next stack frame (which maybe contains pushed + * arguments that have to be dtor'ed) starts */ + stack_frame = zend_vm_stack_frame_base(execute_data); + /* If the exception was thrown during a function call there might be + * arguments pushed to the stack that have to be dtor'ed. */ while (zend_vm_stack_top(TSRMLS_C) != stack_frame) { zval *stack_zval_p = zend_vm_stack_pop(TSRMLS_C); zval_ptr_dtor(&stack_zval_p); @@ -4996,27 +5021,32 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) if (EG(active_op_array)->try_catch_array[i].try_op > op_num) { /* further blocks will not be relevant... */ break; - } else if (op_num < EG(active_op_array)->try_catch_array[i].catch_op) { + } + if (op_num < EG(active_op_array)->try_catch_array[i].catch_op) { catch_op_num = EX(op_array)->try_catch_array[i].catch_op; - catched = 1; + } + if (op_num < EG(active_op_array)->try_catch_array[i].finally_op) { + finally_op_num = EX(op_array)->try_catch_array[i].finally_op; } } - while (EX(fbc)) { - EX(called_scope) = (zend_class_entry*)zend_ptr_stack_pop(&EG(arg_types_stack)); - if (EX(object)) { - if (IS_CTOR_CALL(EX(called_scope))) { - if (IS_CTOR_USED(EX(called_scope))) { - Z_DELREF_P(EX(object)); - } - if (Z_REFCOUNT_P(EX(object)) == 1) { - zend_object_store_ctor_failed(EX(object) TSRMLS_CC); + if (EX(call) >= EX(call_slots)) { + call_slot *call = EX(call); + do { + if (call->object) { + if (call->is_ctor_call) { + if (call->is_ctor_result_used) { + Z_DELREF_P(call->object); + } + if (Z_REFCOUNT_P(call->object) == 1) { + zend_object_store_ctor_failed(call->object TSRMLS_CC); + } } + zval_ptr_dtor(&call->object); } - zval_ptr_dtor(&EX(object)); - } - EX(called_scope) = DECODE_CTOR(EX(called_scope)); - zend_arg_types_stack_2_pop(&EG(arg_types_stack), &EX(object), &EX(fbc)); + call--; + } while (call >= EX(call_slots)); + EX(call) = NULL; } for (i=0; ilast_brk_cont; i++) { @@ -5026,7 +5056,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) /* further blocks will not be relevant... */ break; } else if (op_num < EX(op_array)->brk_cont_array[i].brk) { - if (!catched || + if (!catch_op_num || catch_op_num >= EX(op_array)->brk_cont_array[i].brk) { zend_op *brk_opline = &EX(op_array)->opcodes[EX(op_array)->brk_cont_array[i].brk]; @@ -5048,6 +5078,8 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) /* restore previous error_reporting value */ if (!EG(error_reporting) && EX(old_error_reporting) != NULL && Z_LVAL_P(EX(old_error_reporting)) != 0) { + zval restored_error_reporting; + Z_TYPE(restored_error_reporting) = IS_LONG; Z_LVAL(restored_error_reporting) = Z_LVAL_P(EX(old_error_reporting)); convert_to_string(&restored_error_reporting); @@ -5056,12 +5088,21 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) } EX(old_error_reporting) = NULL; - if (!catched) { - ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); - } else { + if (finally_op_num && (!catch_op_num || catch_op_num >= finally_op_num)) { + zend_exception_save(TSRMLS_C); + EX(fast_ret) = NULL; + ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[finally_op_num]); + ZEND_VM_CONTINUE(); + } else if (catch_op_num) { ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[catch_op_num]); - ZEND_VM_CONTINUE(); - } + ZEND_VM_CONTINUE(); + } else { + if (UNEXPECTED((EX(op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) { + ZEND_VM_DISPATCH_TO_HANDLER(ZEND_GENERATOR_RETURN); + } else { + ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); + } + } } ZEND_VM_HANDLER(146, ZEND_VERIFY_ABSTRACT_CLASS, ANY, ANY) @@ -5087,7 +5128,11 @@ ZEND_VM_HANDLER(150, ZEND_USER_OPCODE, ANY, ANY) case ZEND_USER_OPCODE_CONTINUE: ZEND_VM_CONTINUE(); case ZEND_USER_OPCODE_RETURN: - ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); + if (UNEXPECTED((EX(op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) { + ZEND_VM_DISPATCH_TO_HANDLER(ZEND_GENERATOR_RETURN); + } else { + ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); + } case ZEND_USER_OPCODE_ENTER: ZEND_VM_ENTER(); case ZEND_USER_OPCODE_LEAVE: @@ -5152,7 +5197,7 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA_FUNCTION, CONST, UNUSED) zend_error_noreturn(E_ERROR, "Base lambda function for closure not found"); } - zend_create_closure(&EX_T(opline->result.var).tmp_var, op_array, EG(scope), EG(This) TSRMLS_CC); + zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(scope), EG(This) TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -5166,8 +5211,8 @@ ZEND_VM_HANDLER(156, ZEND_SEPARATE, VAR, UNUSED) SAVE_OPLINE(); var_ptr = EX_T(opline->op1.var).var.ptr; if (Z_TYPE_P(var_ptr) != IS_OBJECT && - !PZVAL_IS_REF(var_ptr) && - Z_REFCOUNT_P(var_ptr) > 1) { + !PZVAL_IS_REF(var_ptr) && + Z_REFCOUNT_P(var_ptr) > 1) { Z_DELREF_P(var_ptr); ALLOC_ZVAL(new_zv); @@ -5179,4 +5224,212 @@ ZEND_VM_HANDLER(156, ZEND_SEPARATE, VAR, UNUSED) ZEND_VM_NEXT_OPCODE(); } +ZEND_VM_HANDLER(160, ZEND_YIELD, CONST|TMP|VAR|CV|UNUSED, CONST|TMP|VAR|CV|UNUSED) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (OP1_TYPE != IS_UNUSED) { + zend_free_op free_op1; + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = GET_OP1_ZVAL_PTR(BP_VAR_R); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!IS_OP1_TMP_FREE()) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W); + + if (OP1_TYPE == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (OP1_TYPE == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + FREE_OP1_IF_VAR(); + } + } else { + zval *value = GET_OP1_ZVAL_PTR(BP_VAR_R); + + /* Consts, temporary variables and references need copying */ + if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!IS_OP1_TMP_FREE()) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + FREE_OP1_IF_VAR(); + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (OP2_TYPE != IS_UNUSED) { + zend_free_op free_op2; + zval *key = GET_OP2_ZVAL_PTR(BP_VAR_R); + + /* Consts, temporary variables and references need copying */ + if (OP2_TYPE == IS_CONST || OP2_TYPE == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!IS_OP2_TMP_FREE()) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + FREE_OP2_IF_VAR(); + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + +ZEND_VM_HANDLER(159, ZEND_DISCARD_EXCEPTION, ANY, ANY) +{ + if (EG(prev_exception) != NULL) { + /* discard the previously thrown exception */ + zval_ptr_dtor(&EG(prev_exception)); + EG(prev_exception) = NULL; + } + + ZEND_VM_NEXT_OPCODE(); +} + +ZEND_VM_HANDLER(162, ZEND_FAST_CALL, ANY, ANY) +{ + USE_OPLINE + + if (opline->extended_value && + UNEXPECTED(EG(prev_exception) != NULL)) { + /* in case of unhandled exception jump to catch block instead of finally */ + ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]); + ZEND_VM_CONTINUE(); + } + EX(fast_ret) = opline + 1; + ZEND_VM_SET_OPCODE(opline->op1.jmp_addr); + ZEND_VM_CONTINUE(); +} + +ZEND_VM_HANDLER(163, ZEND_FAST_RET, ANY, ANY) +{ + if (EX(fast_ret)) { + ZEND_VM_SET_OPCODE(EX(fast_ret)); + ZEND_VM_CONTINUE(); + } else { + /* special case for unhandled exceptions */ + USE_OPLINE + + if (opline->extended_value == ZEND_FAST_RET_TO_FINALLY) { + ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]); + ZEND_VM_CONTINUE(); + } else if (opline->extended_value == ZEND_FAST_RET_TO_CATCH) { + zend_exception_restore(TSRMLS_C); + ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]); + ZEND_VM_CONTINUE(); + } else if (UNEXPECTED((EX(op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) { + zend_exception_restore(TSRMLS_C); + ZEND_VM_DISPATCH_TO_HANDLER(ZEND_GENERATOR_RETURN); + } else { + zend_exception_restore(TSRMLS_C); + ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); + } + } +} + ZEND_VM_EXPORT_HELPER(zend_do_fcall, zend_do_fcall_common_helper) diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 97e5a8e93fd05..f3336a8f85a99 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -326,79 +326,25 @@ static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* o #define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); #define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC -#undef EX -#define EX(element) execute_data->element -#undef EX_CV -#define EX_CV(var) EX(CVs)[var] -#undef EX_CVs -#define EX_CVs() EX(CVs) -#undef EX_T -#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset)) -#undef EX_Ts -#define EX_Ts() EX(Ts) - - -ZEND_API void execute(zend_op_array *op_array TSRMLS_DC) +ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC) { DCL_OPLINE - zend_execute_data *execute_data; - zend_bool nested = 0; - zend_bool original_in_execution = EG(in_execution); + zend_bool original_in_execution; - if (EG(exception)) { - return; - } + original_in_execution = EG(in_execution); EG(in_execution) = 1; + if (0) { zend_vm_enter: - /* Initialize execute_data */ - execute_data = (zend_execute_data *)zend_vm_stack_alloc( - ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)) + - ZEND_MM_ALIGNED_SIZE(sizeof(zval**) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2)) + - ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T TSRMLS_CC); - - EX(CVs) = (zval***)((char*)execute_data + ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data))); - memset(EX(CVs), 0, sizeof(zval**) * op_array->last_var); - EX(Ts) = (temp_variable *)(((char*)EX(CVs)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval**) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2))); - EX(fbc) = NULL; - EX(called_scope) = NULL; - EX(object) = NULL; - EX(old_error_reporting) = NULL; - EX(op_array) = op_array; - EX(symbol_table) = EG(active_symbol_table); - EX(prev_execute_data) = EG(current_execute_data); - EG(current_execute_data) = execute_data; - EX(nested) = nested; - nested = 1; - - LOAD_REGS(); - - if (!op_array->run_time_cache && op_array->last_cache_slot) { - op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*)); + execute_data = i_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC); } - if (op_array->this_var != -1 && EG(This)) { - Z_ADDREF_P(EG(This)); /* For $this pointer */ - if (!EG(active_symbol_table)) { - EX_CV(op_array->this_var) = (zval**)EX_CVs() + (op_array->last_var + op_array->this_var); - *EX_CV(op_array->this_var) = EG(This); - } else { - if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), (void**)&EX_CV(op_array->this_var))==FAILURE) { - Z_DELREF_P(EG(This)); - } - } - } - - EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes; - EG(opline_ptr) = &EX(opline); + LOAD_REGS(); LOAD_OPLINE(); - EX(function_state).function = (zend_function *) op_array; - EX(function_state).arguments = NULL; - while (1) { int ret; #ifdef ZEND_WIN32 @@ -413,10 +359,11 @@ ZEND_API void execute(zend_op_array *op_array TSRMLS_DC) EG(in_execution) = original_in_execution; return; case 2: - op_array = EG(active_op_array); goto zend_vm_enter; + break; case 3: execute_data = EG(current_execute_data); + break; default: break; } @@ -426,59 +373,31 @@ ZEND_API void execute(zend_op_array *op_array TSRMLS_DC) zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen"); } -static int ZEND_FASTCALL ZEND_JMP_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +ZEND_API void zend_execute(zend_op_array *op_array TSRMLS_DC) { - USE_OPLINE - -#if DEBUG_ZEND>=2 - printf("Jumping to %d\n", opline->op1.opline_num); -#endif - ZEND_VM_SET_OPCODE(opline->op1.jmp_addr); - ZEND_VM_CONTINUE(); /* CHECK_ME */ -} - -static int ZEND_FASTCALL ZEND_INIT_STRING_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - USE_OPLINE - zval *tmp = &EX_T(opline->result.var).tmp_var; - - SAVE_OPLINE(); - tmp->value.str.val = emalloc(1); - tmp->value.str.val[0] = 0; - tmp->value.str.len = 0; - Z_SET_REFCOUNT_P(tmp, 1); - tmp->type = IS_STRING; - Z_UNSET_ISREF_P(tmp); - /*CHECK_EXCEPTION();*/ - ZEND_VM_NEXT_OPCODE(); + if (EG(exception)) { + return; + } + zend_execute_ex(i_create_execute_data_from_op_array(op_array, 0 TSRMLS_CC) TSRMLS_CC); } static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) { - zend_bool nested; + zend_bool nested = EX(nested); zend_op_array *op_array = EX(op_array); EG(current_execute_data) = EX(prev_execute_data); EG(opline_ptr) = NULL; if (!EG(active_symbol_table)) { - zval ***cv = EX_CVs(); - zval ***end = cv + op_array->last_var; - while (cv != end) { - if (*cv) { - zval_ptr_dtor(*cv); - } - cv++; - } + i_free_compiled_variables(execute_data); } + zend_vm_stack_free((char*)execute_data - (ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T) TSRMLS_CC); + if ((op_array->fn_flags & ZEND_ACC_CLOSURE) && op_array->prototype) { zval_ptr_dtor((zval**)&op_array->prototype); } - nested = EX(nested); - - zend_vm_stack_free(execute_data TSRMLS_CC); - if (nested) { execute_data = EG(current_execute_data); } @@ -491,7 +410,6 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) EX(function_state).function = (zend_function *) EX(op_array); EX(function_state).arguments = NULL; - EX(object) = EX(current_object); EG(opline_ptr) = &EX(opline); EG(active_op_array) = EX(op_array); @@ -501,34 +419,16 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) if (UNEXPECTED(EG(exception) != NULL)) { zend_throw_exception_internal(NULL TSRMLS_CC); HANDLE_EXCEPTION_LEAVE(); - } else if (RETURN_VALUE_USED(opline)) { - if (!EX_T(opline->result.var).var.ptr) { /* there was no return statement */ - zval *retval; - - ALLOC_ZVAL(retval); - ZVAL_BOOL(retval, 1); - INIT_PZVAL(retval); - EX_T(opline->result.var).var.ptr = retval; - } } ZEND_VM_INC_OPCODE(); ZEND_VM_LEAVE(); } else { - EG(opline_ptr) = &EX(opline); EG(active_op_array) = EX(op_array); EG(return_value_ptr_ptr) = EX(original_return_value); if (EG(active_symbol_table)) { - if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { - zend_hash_destroy(EG(active_symbol_table)); - FREE_HASHTABLE(EG(active_symbol_table)); - } else { - /* clean before putting into the cache, since clean - could call dtors, which could use cached hash */ - zend_hash_clean(EG(active_symbol_table)); - *(++EG(symtable_cache_ptr)) = EG(active_symbol_table); - } + zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } EG(active_symbol_table) = EX(symbol_table); @@ -536,8 +436,8 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) EX(function_state).arguments = NULL; if (EG(This)) { - if (UNEXPECTED(EG(exception) != NULL) && IS_CTOR_CALL(EX(called_scope))) { - if (IS_CTOR_USED(EX(called_scope))) { + if (UNEXPECTED(EG(exception) != NULL) && EX(call)->is_ctor_call) { + if (EX(call)->is_ctor_result_used) { Z_DELREF_P(EG(This)); } if (Z_REFCOUNT_P(EG(This)) == 1) { @@ -550,10 +450,9 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) EG(scope) = EX(current_scope); EG(called_scope) = EX(current_called_scope); - EX(object) = EX(current_object); - EX(called_scope) = DECODE_CTOR(EX(called_scope)); + EX(call)--; - zend_vm_stack_clear_multiple(TSRMLS_C); + zend_vm_stack_clear_multiple(1 TSRMLS_CC); if (UNEXPECTED(EG(exception) != NULL)) { zend_throw_exception_internal(NULL TSRMLS_CC); @@ -577,17 +476,19 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR zend_function *fbc = EX(function_state).function; SAVE_OPLINE(); + EX(object) = EX(call)->object; if (UNEXPECTED((fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) != 0)) { if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_ABSTRACT) != 0)) { zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", fbc->common.scope->name, fbc->common.function_name); - CHECK_EXCEPTION(); - ZEND_VM_NEXT_OPCODE(); /* Never reached */ } if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_DEPRECATED) != 0)) { zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated", fbc->common.scope ? fbc->common.scope->name : "", fbc->common.scope ? "::" : "", fbc->common.function_name); + if (UNEXPECTED(EG(exception) != NULL)) { + HANDLE_EXCEPTION(); + } } } if (fbc->common.scope && @@ -597,6 +498,9 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* FIXME: output identifiers properly */ zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically", fbc->common.scope->name, fbc->common.function_name); + if (UNEXPECTED(EG(exception) != NULL)) { + HANDLE_EXCEPTION(); + } } else { /* FIXME: output identifiers properly */ /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ @@ -611,11 +515,11 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR EX(current_called_scope) = EG(called_scope); EG(This) = EX(object); EG(scope) = (fbc->type == ZEND_USER_FUNCTION || !EX(object)) ? fbc->common.scope : NULL; - EG(called_scope) = EX(called_scope); + EG(called_scope) = EX(call)->called_scope; } - zend_arg_types_stack_3_pop(&EG(arg_types_stack), &EX(called_scope), &EX(current_object), &EX(fbc)); - EX(function_state).arguments = zend_vm_stack_push_args(opline->extended_value TSRMLS_CC); + EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); + zend_vm_stack_push((void*)(zend_uintptr_t)opline->extended_value TSRMLS_CC); LOAD_OPLINE(); if (fbc->type == ZEND_INTERNAL_FUNCTION) { @@ -641,7 +545,7 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR /* saves one function call if zend_execute_internal is not used */ fbc->internal_function.handler(opline->extended_value, ret->var.ptr, (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) ? &ret->var.ptr : NULL, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); } else { - zend_execute_internal(execute_data, RETURN_VALUE_USED(opline) TSRMLS_CC); + zend_execute_internal(execute_data, NULL, RETURN_VALUE_USED(opline) TSRMLS_CC); } if (!RETURN_VALUE_USED(opline)) { @@ -661,7 +565,11 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR ret->var.fcall_returned_reference = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0; } - if (EXPECTED(zend_execute == execute)) { + if (UNEXPECTED((EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) { + if (RETURN_VALUE_USED(opline)) { + EX_T(opline->result.var).var.ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC); + } + } else if (EXPECTED(zend_execute_ex == execute_ex)) { if (EXPECTED(EG(exception) == NULL)) { ZEND_VM_ENTER(); } @@ -673,22 +581,14 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR EG(active_op_array) = EX(op_array); EG(return_value_ptr_ptr) = EX(original_return_value); if (EG(active_symbol_table)) { - if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { - zend_hash_destroy(EG(active_symbol_table)); - FREE_HASHTABLE(EG(active_symbol_table)); - } else { - /* clean before putting into the cache, since clean - could call dtors, which could use cached hash */ - zend_hash_clean(EG(active_symbol_table)); - *(++EG(symtable_cache_ptr)) = EG(active_symbol_table); - } + zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } EG(active_symbol_table) = EX(symbol_table); } else { /* ZEND_OVERLOADED_FUNCTION */ MAKE_STD_ZVAL(EX_T(opline->result.var).var.ptr); ZVAL_NULL(EX_T(opline->result.var).var.ptr); - /* Not sure what should be done here if it's a static method */ + /* Not sure what should be done here if it's a static method */ if (EXPECTED(EX(object) != NULL)) { Z_OBJ_HT_P(EX(object))->call_method(fbc->common.function_name, opline->extended_value, EX_T(opline->result.var).var.ptr, &EX_T(opline->result.var).var.ptr, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); } else { @@ -715,8 +615,8 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR if (should_change_scope) { if (EG(This)) { - if (UNEXPECTED(EG(exception) != NULL) && IS_CTOR_CALL(EX(called_scope))) { - if (IS_CTOR_USED(EX(called_scope))) { + if (UNEXPECTED(EG(exception) != NULL) && EX(call)->is_ctor_call) { + if (EX(call)->is_ctor_result_used) { Z_DELREF_P(EG(This)); } if (Z_REFCOUNT_P(EG(This)) == 1) { @@ -730,10 +630,9 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR EG(called_scope) = EX(current_called_scope); } - EX(object) = EX(current_object); - EX(called_scope) = DECODE_CTOR(EX(called_scope)); + EX(call)--; - zend_vm_stack_clear_multiple(TSRMLS_C); + zend_vm_stack_clear_multiple(1 TSRMLS_CC); if (UNEXPECTED(EG(exception) != NULL)) { zend_throw_exception_internal(NULL TSRMLS_CC); @@ -746,12 +645,51 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_JMP_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + +#if DEBUG_ZEND>=2 + printf("Jumping to %d\n", opline->op1.opline_num); +#endif + ZEND_VM_SET_OPCODE(opline->op1.jmp_addr); + ZEND_VM_CONTINUE(); +} + +static int ZEND_FASTCALL ZEND_INIT_STRING_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + zval *tmp = &EX_T(opline->result.var).tmp_var; + + SAVE_OPLINE(); + tmp->value.str.val = emalloc(1); + tmp->value.str.val[0] = 0; + tmp->value.str.len = 0; + Z_SET_REFCOUNT_P(tmp, 1); + tmp->type = IS_STRING; + Z_UNSET_ISREF_P(tmp); + /*CHECK_EXCEPTION();*/ + ZEND_VM_NEXT_OPCODE(); +} + static int ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { - EX(function_state).function = EX(fbc); + EX(function_state).function = EX(call)->fbc; return zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_GENERATOR_RETURN_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + /* Close the generator to free up resources */ + zend_generator_close(generator, 1 TSRMLS_CC); + + /* Pass execution back to handling code */ + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_RECV_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -783,7 +721,7 @@ static int ZEND_FASTCALL ZEND_RECV_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval **var_ptr; zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, *param, opline->extended_value TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->result.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC); Z_DELREF_PP(var_ptr); *var_ptr = *param; Z_ADDREF_PP(var_ptr); @@ -823,17 +761,20 @@ static int ZEND_FASTCALL ZEND_NEW_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } ZEND_VM_JMP(EX(op_array)->opcodes + opline->op2.opline_num); } else { + call_slot *call = EX(call_slots) + opline->extended_value; + if (RETURN_VALUE_USED(opline)) { PZVAL_LOCK(object_zval); AI_SET_PTR(&EX_T(opline->result.var), object_zval); } - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), ENCODE_CTOR(EX(called_scope), RETURN_VALUE_USED(opline))); - /* We are not handling overloaded classes right now */ - EX(object) = object_zval; - EX(fbc) = constructor; - EX(called_scope) = EX_T(opline->op1.var).class_entry; + call->fbc = constructor; + call->object = object_zval; + call->called_scope = EX_T(opline->op1.var).class_entry; + call->is_ctor_call = 1; + call->is_ctor_result_used = RETURN_VALUE_USED(opline); + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -1033,13 +974,15 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER { zend_uint op_num = EG(opline_before_exception)-EG(active_op_array)->opcodes; int i; - zend_uint catch_op_num = 0; - int catched = 0; - zval restored_error_reporting; + zend_uint catch_op_num = 0, finally_op_num = 0; + void **stack_frame; - void **stack_frame = (void**)(((char*)EX_Ts()) + - (ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * EX(op_array)->T)); + /* Figure out where the next stack frame (which maybe contains pushed + * arguments that have to be dtor'ed) starts */ + stack_frame = zend_vm_stack_frame_base(execute_data); + /* If the exception was thrown during a function call there might be + * arguments pushed to the stack that have to be dtor'ed. */ while (zend_vm_stack_top(TSRMLS_C) != stack_frame) { zval *stack_zval_p = zend_vm_stack_pop(TSRMLS_C); zval_ptr_dtor(&stack_zval_p); @@ -1049,27 +992,32 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER if (EG(active_op_array)->try_catch_array[i].try_op > op_num) { /* further blocks will not be relevant... */ break; - } else if (op_num < EG(active_op_array)->try_catch_array[i].catch_op) { + } + if (op_num < EG(active_op_array)->try_catch_array[i].catch_op) { catch_op_num = EX(op_array)->try_catch_array[i].catch_op; - catched = 1; + } + if (op_num < EG(active_op_array)->try_catch_array[i].finally_op) { + finally_op_num = EX(op_array)->try_catch_array[i].finally_op; } } - while (EX(fbc)) { - EX(called_scope) = (zend_class_entry*)zend_ptr_stack_pop(&EG(arg_types_stack)); - if (EX(object)) { - if (IS_CTOR_CALL(EX(called_scope))) { - if (IS_CTOR_USED(EX(called_scope))) { - Z_DELREF_P(EX(object)); - } - if (Z_REFCOUNT_P(EX(object)) == 1) { - zend_object_store_ctor_failed(EX(object) TSRMLS_CC); + if (EX(call) >= EX(call_slots)) { + call_slot *call = EX(call); + do { + if (call->object) { + if (call->is_ctor_call) { + if (call->is_ctor_result_used) { + Z_DELREF_P(call->object); + } + if (Z_REFCOUNT_P(call->object) == 1) { + zend_object_store_ctor_failed(call->object TSRMLS_CC); + } } + zval_ptr_dtor(&call->object); } - zval_ptr_dtor(&EX(object)); - } - EX(called_scope) = DECODE_CTOR(EX(called_scope)); - zend_arg_types_stack_2_pop(&EG(arg_types_stack), &EX(object), &EX(fbc)); + call--; + } while (call >= EX(call_slots)); + EX(call) = NULL; } for (i=0; ilast_brk_cont; i++) { @@ -1079,7 +1027,7 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER /* further blocks will not be relevant... */ break; } else if (op_num < EX(op_array)->brk_cont_array[i].brk) { - if (!catched || + if (!catch_op_num || catch_op_num >= EX(op_array)->brk_cont_array[i].brk) { zend_op *brk_opline = &EX(op_array)->opcodes[EX(op_array)->brk_cont_array[i].brk]; @@ -1101,6 +1049,8 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER /* restore previous error_reporting value */ if (!EG(error_reporting) && EX(old_error_reporting) != NULL && Z_LVAL_P(EX(old_error_reporting)) != 0) { + zval restored_error_reporting; + Z_TYPE(restored_error_reporting) = IS_LONG; Z_LVAL(restored_error_reporting) = Z_LVAL_P(EX(old_error_reporting)); convert_to_string(&restored_error_reporting); @@ -1109,12 +1059,21 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER } EX(old_error_reporting) = NULL; - if (!catched) { - return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - } else { + if (finally_op_num && (!catch_op_num || catch_op_num >= finally_op_num)) { + zend_exception_save(TSRMLS_C); + EX(fast_ret) = NULL; + ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[finally_op_num]); + ZEND_VM_CONTINUE(); + } else if (catch_op_num) { ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[catch_op_num]); - ZEND_VM_CONTINUE(); - } + ZEND_VM_CONTINUE(); + } else { + if (UNEXPECTED((EX(op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) { + return ZEND_GENERATOR_RETURN_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + } else { + return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + } + } } static int ZEND_FASTCALL ZEND_VERIFY_ABSTRACT_CLASS_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -1140,7 +1099,11 @@ static int ZEND_FASTCALL ZEND_USER_OPCODE_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS case ZEND_USER_OPCODE_CONTINUE: ZEND_VM_CONTINUE(); case ZEND_USER_OPCODE_RETURN: - return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + if (UNEXPECTED((EX(op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) { + return ZEND_GENERATOR_RETURN_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + } else { + return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + } case ZEND_USER_OPCODE_ENTER: ZEND_VM_ENTER(); case ZEND_USER_OPCODE_LEAVE: @@ -1152,12 +1115,66 @@ static int ZEND_FASTCALL ZEND_USER_OPCODE_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS } } +static int ZEND_FASTCALL ZEND_DISCARD_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + if (EG(prev_exception) != NULL) { + /* discard the previously thrown exception */ + zval_ptr_dtor(&EG(prev_exception)); + EG(prev_exception) = NULL; + } + + ZEND_VM_NEXT_OPCODE(); +} + +static int ZEND_FASTCALL ZEND_FAST_CALL_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + if (opline->extended_value && + UNEXPECTED(EG(prev_exception) != NULL)) { + /* in case of unhandled exception jump to catch block instead of finally */ + ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]); + ZEND_VM_CONTINUE(); + } + EX(fast_ret) = opline + 1; + ZEND_VM_SET_OPCODE(opline->op1.jmp_addr); + ZEND_VM_CONTINUE(); +} + +static int ZEND_FASTCALL ZEND_FAST_RET_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + if (EX(fast_ret)) { + ZEND_VM_SET_OPCODE(EX(fast_ret)); + ZEND_VM_CONTINUE(); + } else { + /* special case for unhandled exceptions */ + USE_OPLINE + + if (opline->extended_value == ZEND_FAST_RET_TO_FINALLY) { + ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]); + ZEND_VM_CONTINUE(); + } else if (opline->extended_value == ZEND_FAST_RET_TO_CATCH) { + zend_exception_restore(TSRMLS_C); + ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]); + ZEND_VM_CONTINUE(); + } else if (UNEXPECTED((EX(op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) { + zend_exception_restore(TSRMLS_C); + return ZEND_GENERATOR_RETURN_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + } else { + zend_exception_restore(TSRMLS_C); + return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + } + } +} + static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE SAVE_OPLINE(); - EG(exception) = NULL; + if (EG(exception)) { + zend_exception_save(TSRMLS_C); + } if (IS_CONST == IS_UNUSED) { EX_T(opline->result.var).class_entry = zend_fetch_class(NULL, 0, opline->extended_value TSRMLS_CC); CHECK_EXCEPTION(); @@ -1190,19 +1207,22 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE { USE_OPLINE zval *function_name; - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + call_slot *call = EX(call_slots) + opline->result.num; if (IS_CONST == IS_CONST) { function_name = (zval*)(opline->op2.literal+1); if (CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); - } else if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)+1, Z_HASH_P(function_name), (void **) &EX(fbc)) == FAILURE)) { + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); + } else if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)+1, Z_HASH_P(function_name), (void **) &call->fbc) == FAILURE)) { SAVE_OPLINE(); zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv)); } else { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - EX(object) = NULL; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; /*CHECK_EXCEPTION();*/ ZEND_VM_NEXT_OPCODE(); } else { @@ -1222,28 +1242,33 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE } else { lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } - if (UNEXPECTED(zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)) == FAILURE)) { + if (UNEXPECTED(zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &call->fbc) == FAILURE)) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } efree(lcname); - EX(object) = NULL; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else if (IS_CONST != IS_CONST && IS_CONST != IS_TMP_VAR && EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) && Z_OBJ_HANDLER_P(function_name, get_closure) && - Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &EX(called_scope), &EX(fbc), &EX(object) TSRMLS_CC) == SUCCESS) { - if (EX(object)) { - Z_ADDREF_P(EX(object)); + Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &call->called_scope, &call->fbc, &call->object TSRMLS_CC) == SUCCESS) { + if (call->object) { + Z_ADDREF_P(call->object); } if (IS_CONST == IS_VAR && 0 && - EX(fbc)->common.fn_flags & ZEND_ACC_CLOSURE) { + call->fbc->common.fn_flags & ZEND_ACC_CLOSURE) { /* Delay closure destruction until its invocation */ - EX(fbc)->common.prototype = (zend_function*)function_name; + call->fbc->common.prototype = (zend_function*)function_name; } else { } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else if (IS_CONST != IS_CONST && @@ -1274,46 +1299,49 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } - EX(called_scope) = ce; - EX(object) = NULL; + call->called_scope = ce; + call->object = NULL; if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method) TSRMLS_CC); + call->fbc = ce->get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method) TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); } } else { - EX(object) = *obj; - ce = EX(called_scope) = Z_OBJCE_PP(obj); + call->object = *obj; + ce = call->called_scope = Z_OBJCE_PP(obj); - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), Z_STRVAL_PP(method)); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_PP(method)); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, Z_STRVAL_PP(method)); } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { zend_error_noreturn(E_ERROR, "Function name must be a string"); + ZEND_VM_NEXT_OPCODE(); /* Never reached */ } } } @@ -1323,25 +1351,27 @@ static int ZEND_FASTCALL ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPC { USE_OPLINE zend_literal *func_name; - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + call_slot *call = EX(call_slots) + opline->result.num; func_name = opline->op2.literal + 1; if (CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); - } else if (zend_hash_quick_find(EG(function_table), Z_STRVAL(func_name->constant), Z_STRLEN(func_name->constant)+1, func_name->hash_value, (void **) &EX(fbc))==FAILURE) { + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); + } else if (zend_hash_quick_find(EG(function_table), Z_STRVAL(func_name->constant), Z_STRLEN(func_name->constant)+1, func_name->hash_value, (void **) &call->fbc)==FAILURE) { func_name++; - if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL(func_name->constant), Z_STRLEN(func_name->constant)+1, func_name->hash_value, (void **) &EX(fbc))==FAILURE)) { + if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL(func_name->constant), Z_STRLEN(func_name->constant)+1, func_name->hash_value, (void **) &call->fbc)==FAILURE)) { SAVE_OPLINE(); zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv)); } else { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } } else { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - EX(object) = NULL; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; ZEND_VM_NEXT_OPCODE(); } @@ -1371,7 +1401,7 @@ static int ZEND_FASTCALL ZEND_RECV_INIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ } zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value, opline->extended_value TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->result.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC); Z_DELREF_PP(var_ptr); *var_ptr = assignment_value; @@ -1386,7 +1416,7 @@ static int ZEND_FASTCALL ZEND_BRK_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num, - EX(op_array), EX_Ts() TSRMLS_CC); + EX(op_array), execute_data TSRMLS_CC); ZEND_VM_JMP(EX(op_array)->opcodes + el->brk); } @@ -1398,7 +1428,7 @@ static int ZEND_FASTCALL ZEND_CONT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num, - EX(op_array), EX_Ts() TSRMLS_CC); + EX(op_array), execute_data TSRMLS_CC); ZEND_VM_JMP(EX(op_array)->opcodes + el->cont); } @@ -1411,7 +1441,7 @@ static int ZEND_FASTCALL ZEND_GOTO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->extended_value, - EX(op_array), EX_Ts() TSRMLS_CC); + EX(op_array), execute_data TSRMLS_CC); brk_opline = EX(op_array)->opcodes + el->brk; @@ -1462,14 +1492,16 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ USE_OPLINE SAVE_OPLINE(); - EG(exception) = NULL; + if (EG(exception)) { + zend_exception_save(TSRMLS_C); + } if (IS_TMP_VAR == IS_UNUSED) { EX_T(opline->result.var).class_entry = zend_fetch_class(NULL, 0, opline->extended_value TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_op2; - zval *class_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *class_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_TMP_VAR == IS_CONST) { if (CACHED_PTR(opline->op2.literal->cache_slot)) { @@ -1496,19 +1528,22 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H { USE_OPLINE zval *function_name; - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + call_slot *call = EX(call_slots) + opline->result.num; if (IS_TMP_VAR == IS_CONST) { function_name = (zval*)(opline->op2.literal+1); if (CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); - } else if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)+1, Z_HASH_P(function_name), (void **) &EX(fbc)) == FAILURE)) { + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); + } else if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)+1, Z_HASH_P(function_name), (void **) &call->fbc) == FAILURE)) { SAVE_OPLINE(); zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv)); } else { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - EX(object) = NULL; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; /*CHECK_EXCEPTION();*/ ZEND_VM_NEXT_OPCODE(); } else { @@ -1517,7 +1552,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H zend_free_op free_op2; SAVE_OPLINE(); - function_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { function_name_strval = Z_STRVAL_P(function_name); @@ -1528,28 +1563,33 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H } else { lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } - if (UNEXPECTED(zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)) == FAILURE)) { + if (UNEXPECTED(zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &call->fbc) == FAILURE)) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } efree(lcname); zval_dtor(free_op2.var); - EX(object) = NULL; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else if (IS_TMP_VAR != IS_CONST && IS_TMP_VAR != IS_TMP_VAR && EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) && Z_OBJ_HANDLER_P(function_name, get_closure) && - Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &EX(called_scope), &EX(fbc), &EX(object) TSRMLS_CC) == SUCCESS) { - if (EX(object)) { - Z_ADDREF_P(EX(object)); + Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &call->called_scope, &call->fbc, &call->object TSRMLS_CC) == SUCCESS) { + if (call->object) { + Z_ADDREF_P(call->object); } if (IS_TMP_VAR == IS_VAR && 1 && - EX(fbc)->common.fn_flags & ZEND_ACC_CLOSURE) { + call->fbc->common.fn_flags & ZEND_ACC_CLOSURE) { /* Delay closure destruction until its invocation */ - EX(fbc)->common.prototype = (zend_function*)function_name; + call->fbc->common.prototype = (zend_function*)function_name; } else { zval_dtor(free_op2.var); } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else if (IS_TMP_VAR != IS_CONST && @@ -1580,46 +1620,49 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } - EX(called_scope) = ce; - EX(object) = NULL; + call->called_scope = ce; + call->object = NULL; if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method) TSRMLS_CC); + call->fbc = ce->get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method) TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); } } else { - EX(object) = *obj; - ce = EX(called_scope) = Z_OBJCE_PP(obj); + call->object = *obj; + ce = call->called_scope = Z_OBJCE_PP(obj); - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), Z_STRVAL_PP(method)); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_PP(method)); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, Z_STRVAL_PP(method)); } + call->is_ctor_call = 0; + EX(call) = call; zval_dtor(free_op2.var); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { zend_error_noreturn(E_ERROR, "Function name must be a string"); + ZEND_VM_NEXT_OPCODE(); /* Never reached */ } } } @@ -1630,14 +1673,16 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ USE_OPLINE SAVE_OPLINE(); - EG(exception) = NULL; + if (EG(exception)) { + zend_exception_save(TSRMLS_C); + } if (IS_VAR == IS_UNUSED) { EX_T(opline->result.var).class_entry = zend_fetch_class(NULL, 0, opline->extended_value TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_op2; - zval *class_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *class_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR == IS_CONST) { if (CACHED_PTR(opline->op2.literal->cache_slot)) { @@ -1664,19 +1709,22 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H { USE_OPLINE zval *function_name; - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + call_slot *call = EX(call_slots) + opline->result.num; if (IS_VAR == IS_CONST) { function_name = (zval*)(opline->op2.literal+1); if (CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); - } else if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)+1, Z_HASH_P(function_name), (void **) &EX(fbc)) == FAILURE)) { + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); + } else if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)+1, Z_HASH_P(function_name), (void **) &call->fbc) == FAILURE)) { SAVE_OPLINE(); zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv)); } else { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - EX(object) = NULL; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; /*CHECK_EXCEPTION();*/ ZEND_VM_NEXT_OPCODE(); } else { @@ -1685,7 +1733,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H zend_free_op free_op2; SAVE_OPLINE(); - function_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { function_name_strval = Z_STRVAL_P(function_name); @@ -1696,28 +1744,33 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H } else { lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } - if (UNEXPECTED(zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)) == FAILURE)) { + if (UNEXPECTED(zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &call->fbc) == FAILURE)) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } efree(lcname); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; - EX(object) = NULL; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else if (IS_VAR != IS_CONST && IS_VAR != IS_TMP_VAR && EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) && Z_OBJ_HANDLER_P(function_name, get_closure) && - Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &EX(called_scope), &EX(fbc), &EX(object) TSRMLS_CC) == SUCCESS) { - if (EX(object)) { - Z_ADDREF_P(EX(object)); + Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &call->called_scope, &call->fbc, &call->object TSRMLS_CC) == SUCCESS) { + if (call->object) { + Z_ADDREF_P(call->object); } if (IS_VAR == IS_VAR && (free_op2.var != NULL) && - EX(fbc)->common.fn_flags & ZEND_ACC_CLOSURE) { + call->fbc->common.fn_flags & ZEND_ACC_CLOSURE) { /* Delay closure destruction until its invocation */ - EX(fbc)->common.prototype = (zend_function*)function_name; + call->fbc->common.prototype = (zend_function*)function_name; } else { if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else if (IS_VAR != IS_CONST && @@ -1748,46 +1801,49 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } - EX(called_scope) = ce; - EX(object) = NULL; + call->called_scope = ce; + call->object = NULL; if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method) TSRMLS_CC); + call->fbc = ce->get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method) TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); } } else { - EX(object) = *obj; - ce = EX(called_scope) = Z_OBJCE_PP(obj); + call->object = *obj; + ce = call->called_scope = Z_OBJCE_PP(obj); - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), Z_STRVAL_PP(method)); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_PP(method)); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, Z_STRVAL_PP(method)); } + call->is_ctor_call = 0; + EX(call) = call; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { zend_error_noreturn(E_ERROR, "Function name must be a string"); + ZEND_VM_NEXT_OPCODE(); /* Never reached */ } } } @@ -1798,7 +1854,9 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDL USE_OPLINE SAVE_OPLINE(); - EG(exception) = NULL; + if (EG(exception)) { + zend_exception_save(TSRMLS_C); + } if (IS_UNUSED == IS_UNUSED) { EX_T(opline->result.var).class_entry = zend_fetch_class(NULL, 0, opline->extended_value TSRMLS_CC); CHECK_EXCEPTION(); @@ -1832,14 +1890,16 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_A USE_OPLINE SAVE_OPLINE(); - EG(exception) = NULL; + if (EG(exception)) { + zend_exception_save(TSRMLS_C); + } if (IS_CV == IS_UNUSED) { EX_T(opline->result.var).class_entry = zend_fetch_class(NULL, 0, opline->extended_value TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { - zval *class_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *class_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_CV == IS_CONST) { if (CACHED_PTR(opline->op2.literal->cache_slot)) { @@ -1865,19 +1925,22 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA { USE_OPLINE zval *function_name; - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + call_slot *call = EX(call_slots) + opline->result.num; if (IS_CV == IS_CONST) { function_name = (zval*)(opline->op2.literal+1); if (CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); - } else if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)+1, Z_HASH_P(function_name), (void **) &EX(fbc)) == FAILURE)) { + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); + } else if (UNEXPECTED(zend_hash_quick_find(EG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)+1, Z_HASH_P(function_name), (void **) &call->fbc) == FAILURE)) { SAVE_OPLINE(); zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv)); } else { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - EX(object) = NULL; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; /*CHECK_EXCEPTION();*/ ZEND_VM_NEXT_OPCODE(); } else { @@ -1886,7 +1949,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); - function_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + function_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { function_name_strval = Z_STRVAL_P(function_name); @@ -1897,28 +1960,33 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA } else { lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); } - if (UNEXPECTED(zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &EX(fbc)) == FAILURE)) { + if (UNEXPECTED(zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &call->fbc) == FAILURE)) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } efree(lcname); - EX(object) = NULL; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else if (IS_CV != IS_CONST && IS_CV != IS_TMP_VAR && EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) && Z_OBJ_HANDLER_P(function_name, get_closure) && - Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &EX(called_scope), &EX(fbc), &EX(object) TSRMLS_CC) == SUCCESS) { - if (EX(object)) { - Z_ADDREF_P(EX(object)); + Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &call->called_scope, &call->fbc, &call->object TSRMLS_CC) == SUCCESS) { + if (call->object) { + Z_ADDREF_P(call->object); } if (IS_CV == IS_VAR && 0 && - EX(fbc)->common.fn_flags & ZEND_ACC_CLOSURE) { + call->fbc->common.fn_flags & ZEND_ACC_CLOSURE) { /* Delay closure destruction until its invocation */ - EX(fbc)->common.prototype = (zend_function*)function_name; + call->fbc->common.prototype = (zend_function*)function_name; } else { } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else if (IS_CV != IS_CONST && @@ -1949,46 +2017,49 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } - EX(called_scope) = ce; - EX(object) = NULL; + call->called_scope = ce; + call->object = NULL; if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method) TSRMLS_CC); + call->fbc = ce->get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method) TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); } } else { - EX(object) = *obj; - ce = EX(called_scope) = Z_OBJCE_PP(obj); + call->object = *obj; + ce = call->called_scope = Z_OBJCE_PP(obj); - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), Z_STRVAL_PP(method)); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, Z_STRVAL_PP(method), Z_STRLEN_PP(method), NULL TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_PP(method)); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, Z_STRVAL_PP(method)); } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { zend_error_noreturn(E_ERROR, "Function name must be a string"); + ZEND_VM_NEXT_OPCODE(); /* Never reached */ } } } @@ -2207,8 +2278,7 @@ static int ZEND_FASTCALL ZEND_DO_FCALL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A USE_OPLINE zval *fname = opline->op1.zv; - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); + call_slot *call = EX(call_slots) + opline->op2.num; if (CACHED_PTR(opline->op1.literal->cache_slot)) { EX(function_state).function = CACHED_PTR(opline->op1.literal->cache_slot); @@ -2218,7 +2288,11 @@ static int ZEND_FASTCALL ZEND_DO_FCALL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A } else { CACHE_PTR(opline->op1.literal->cache_slot, EX(function_state).function); } - EX(object) = NULL; + call->fbc = EX(function_state).function; + call->object = NULL; + call->called_scope = NULL; + call->is_ctor_call = 0; + EX(call) = call; return zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -2237,6 +2311,9 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG } } else if (!0) { /* Not a temp var */ + if (*EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } if (IS_CONST == IS_CONST || (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) { zval *ret; @@ -2258,6 +2335,10 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG } else { zval *ret; + if (*EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } + ALLOC_ZVAL(ret); INIT_PZVAL_COPY(ret, retval_ptr); *EG(return_value_ptr_ptr) = ret; @@ -2276,6 +2357,10 @@ static int ZEND_FASTCALL ZEND_RETURN_BY_REF_SPEC_CONST_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); do { + if (EG(return_value_ptr_ptr) && *EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) { /* Not supposed to happen, but we'll allow it */ zend_error(E_NOTICE, "Only variable references should be returned by reference"); @@ -2366,7 +2451,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); if (opline->extended_value==ZEND_DO_FCALL_BY_NAME - && ARG_MUST_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + && ARG_MUST_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.opline_num); } { @@ -2530,7 +2615,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA zend_op_array *new_op_array=NULL; zval *inc_filename; - zval *tmp_inc_filename = NULL; + zval *tmp_inc_filename = NULL; zend_bool failure_retval=0; SAVE_OPLINE(); @@ -2622,8 +2707,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA EG(return_value_ptr_ptr) = NULL; } - EX(current_object) = EX(object); - EX(function_state).function = (zend_function *) new_op_array; EX(object) = NULL; @@ -2631,14 +2714,13 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA zend_rebuild_symbol_table(TSRMLS_C); } - if (EXPECTED(zend_execute == execute)) { + if (EXPECTED(zend_execute_ex == execute_ex)) { ZEND_VM_ENTER(); } else { zend_execute(new_op_array TSRMLS_CC); } EX(function_state).function = (zend_function *) EX(op_array); - EX(object) = EX(current_object); EG(opline_ptr) = &EX(opline); EG(active_op_array) = EX(op_array); @@ -2648,15 +2730,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA if (UNEXPECTED(EG(exception) != NULL)) { zend_throw_exception_internal(NULL TSRMLS_CC); HANDLE_EXCEPTION(); - } else if (RETURN_VALUE_USED(opline)) { - if (!EX_T(opline->result.var).var.ptr) { /* there was no return statement */ - zval *retval; - - ALLOC_ZVAL(retval); - ZVAL_BOOL(retval, 1); - INIT_PZVAL(retval); - EX_T(opline->result.var).var.ptr = retval; - } } } else if (RETURN_VALUE_USED(opline)) { @@ -3365,7 +3438,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_CONST_CONST_HANDLER(ZEND_OPCO { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_CONST_CONST(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_CONST_CONST(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -3378,6 +3451,36 @@ static int ZEND_FASTCALL ZEND_FETCH_IS_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HAN return zend_fetch_var_address_helper_SPEC_CONST_CONST(BP_VAR_IS, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + zval **container; + + SAVE_OPLINE(); + + if ((opline->extended_value & ZEND_FETCH_ADD_LOCK) && + IS_CONST != IS_CV && + EX_T(opline->op1.var).var.ptr_ptr) { + PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); + } + + if (IS_CONST == IS_TMP_VAR || IS_CONST == IS_CONST) { + zval *container = opline->op1.zv; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); + + + } else { + container = NULL; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); + + + } + + CHECK_EXCEPTION(); + ZEND_VM_NEXT_OPCODE(); +} + static int ZEND_FASTCALL ZEND_FETCH_DIM_TMP_VAR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -3407,9 +3510,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER( USE_OPLINE zval *function_name; zend_class_entry *ce; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_CONST == IS_CONST) { /* no function found. try a static method in class */ @@ -3423,24 +3526,24 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER( } CACHE_PTR(opline->op1.literal->cache_slot, ce); } - EX(called_scope) = ce; + call->called_scope = ce; } else { ce = EX_T(opline->op1.var).class_entry; if (opline->extended_value == ZEND_FETCH_CLASS_PARENT || opline->extended_value == ZEND_FETCH_CLASS_SELF) { - EX(called_scope) = EG(called_scope); + call->called_scope = EG(called_scope); } else { - EX(called_scope) = ce; + call->called_scope = ce; } } if (IS_CONST == IS_CONST && IS_CONST == IS_CONST && CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); } else if (IS_CONST != IS_CONST && IS_CONST == IS_CONST && - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { /* do nothing */ } else if (IS_CONST != IS_UNUSED) { char *function_name_strval = NULL; @@ -3463,20 +3566,20 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER( if (function_name_strval) { if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + call->fbc = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, function_name_strval); } if (IS_CONST == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { if (IS_CONST == IS_CONST) { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } else { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, EX(fbc)); + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, call->fbc); } } } @@ -3490,29 +3593,31 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER( if (EG(This) && Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name); } - EX(fbc) = ce->constructor; + call->fbc = ce->constructor; } - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; + if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { + call->object = NULL; } else { if (EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + if (call->fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } } - if ((EX(object) = EG(This))) { - Z_ADDREF_P(EX(object)); - EX(called_scope) = Z_OBJCE_P(EX(object)); + if ((call->object = EG(This))) { + Z_ADDREF_P(call->object); + call->called_scope = Z_OBJCE_P(call->object); } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -3618,6 +3723,9 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO } ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, *value); zval_copy_ctor(&EX_T(opline->result.var).tmp_var); + } else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && strcmp(Z_STRVAL_P(opline->op2.zv), "class") == 0) { + /* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */ + ZVAL_STRINGL(&EX_T(opline->result.var).tmp_var, ce->name, ce->name_length, 1); } else { zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv)); } @@ -3928,6 +4036,159 @@ static int ZEND_FASTCALL ZEND_DECLARE_CONST_SPEC_CONST_CONST_HANDLER(ZEND_OPCOD ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_CONST != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = opline->op1.zv; + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_CONST == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_CONST == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = opline->op1.zv; + + /* Consts, temporary variables and references need copying */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_CONST != IS_UNUSED) { + + zval *key = opline->op2.zv; + + /* Consts, temporary variables and references need copying */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -3936,7 +4197,7 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -3951,7 +4212,7 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -3966,7 +4227,7 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -3981,7 +4242,7 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -3996,7 +4257,7 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4011,7 +4272,7 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4026,7 +4287,7 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4041,7 +4302,7 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4056,7 +4317,7 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4072,7 +4333,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCO SAVE_OPLINE(); is_identical_function(result, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); zval_dtor(free_op2.var); @@ -4089,7 +4350,7 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4105,7 +4366,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4121,7 +4382,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4137,7 +4398,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CONST_TMP_HANDLER(ZEND_O SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4152,7 +4413,7 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4167,7 +4428,7 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4182,7 +4443,7 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4197,21 +4458,51 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + zend_free_op free_op2; + zval **container; + + SAVE_OPLINE(); + + if ((opline->extended_value & ZEND_FETCH_ADD_LOCK) && + IS_CONST != IS_CV && + EX_T(opline->op1.var).var.ptr_ptr) { + PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); + } + + if (IS_CONST == IS_TMP_VAR || IS_CONST == IS_CONST) { + zval *container = opline->op1.zv; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); + zval_dtor(free_op2.var); + + } else { + container = NULL; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); + zval_dtor(free_op2.var); + + } + + CHECK_EXCEPTION(); + ZEND_VM_NEXT_OPCODE(); +} + static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE zval *function_name; zend_class_entry *ce; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_CONST == IS_CONST) { /* no function found. try a static method in class */ @@ -4225,24 +4516,24 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE } CACHE_PTR(opline->op1.literal->cache_slot, ce); } - EX(called_scope) = ce; + call->called_scope = ce; } else { ce = EX_T(opline->op1.var).class_entry; if (opline->extended_value == ZEND_FETCH_CLASS_PARENT || opline->extended_value == ZEND_FETCH_CLASS_SELF) { - EX(called_scope) = EG(called_scope); + call->called_scope = EG(called_scope); } else { - EX(called_scope) = ce; + call->called_scope = ce; } } if (IS_CONST == IS_CONST && IS_TMP_VAR == IS_CONST && CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); } else if (IS_CONST != IS_CONST && IS_TMP_VAR == IS_CONST && - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { /* do nothing */ } else if (IS_TMP_VAR != IS_UNUSED) { char *function_name_strval = NULL; @@ -4253,7 +4544,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE function_name_strval = Z_STRVAL_P(opline->op2.zv); function_name_strlen = Z_STRLEN_P(opline->op2.zv); } else { - function_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { zend_error_noreturn(E_ERROR, "Function name must be a string"); @@ -4265,20 +4556,20 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE if (function_name_strval) { if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + call->fbc = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, function_name_strval); } if (IS_TMP_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { if (IS_CONST == IS_CONST) { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } else { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, EX(fbc)); + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, call->fbc); } } } @@ -4292,29 +4583,31 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE if (EG(This) && Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name); } - EX(fbc) = ce->constructor; + call->fbc = ce->constructor; } - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; + if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { + call->object = NULL; } else { if (EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + if (call->fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } } - if ((EX(object) = EG(This))) { - Z_ADDREF_P(EX(object)); - EX(called_scope) = Z_OBJCE_P(EX(object)); + if ((call->object = EG(This))) { + Z_ADDREF_P(call->object); + call->called_scope = Z_OBJCE_P(call->object); } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -4331,7 +4624,7 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_A } is_equal_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -4376,7 +4669,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_TMP_HANDLER(ZEND_OPC if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -4438,6 +4731,159 @@ static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HAN } } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_CONST != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = opline->op1.zv; + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_CONST == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_CONST == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = opline->op1.zv; + + /* Consts, temporary variables and references need copying */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_TMP_VAR != IS_UNUSED) { + zend_free_op free_op2; + zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -4446,7 +4892,7 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4461,7 +4907,7 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4476,7 +4922,7 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4491,7 +4937,7 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4506,7 +4952,7 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4521,7 +4967,7 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4536,7 +4982,7 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4551,7 +4997,7 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4566,7 +5012,7 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4582,7 +5028,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CONST_VAR_HANDLER(ZEND_OPCO SAVE_OPLINE(); is_identical_function(result, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; @@ -4599,7 +5045,7 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4615,7 +5061,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4631,7 +5077,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4647,7 +5093,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CONST_VAR_HANDLER(ZEND_O SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4662,7 +5108,7 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4677,7 +5123,7 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4692,7 +5138,7 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4707,7 +5153,7 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -4865,7 +5311,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_CONST_VAR(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_CONST_VAR(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -4878,14 +5324,44 @@ static int ZEND_FASTCALL ZEND_FETCH_IS_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDL return zend_fetch_var_address_helper_SPEC_CONST_VAR(BP_VAR_IS, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + zend_free_op free_op2; + zval **container; + + SAVE_OPLINE(); + + if ((opline->extended_value & ZEND_FETCH_ADD_LOCK) && + IS_CONST != IS_CV && + EX_T(opline->op1.var).var.ptr_ptr) { + PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); + } + + if (IS_CONST == IS_TMP_VAR || IS_CONST == IS_CONST) { + zval *container = opline->op1.zv; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + + } else { + container = NULL; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + + } + + CHECK_EXCEPTION(); + ZEND_VM_NEXT_OPCODE(); +} + static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE zval *function_name; zend_class_entry *ce; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_CONST == IS_CONST) { /* no function found. try a static method in class */ @@ -4899,24 +5375,24 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZE } CACHE_PTR(opline->op1.literal->cache_slot, ce); } - EX(called_scope) = ce; + call->called_scope = ce; } else { ce = EX_T(opline->op1.var).class_entry; if (opline->extended_value == ZEND_FETCH_CLASS_PARENT || opline->extended_value == ZEND_FETCH_CLASS_SELF) { - EX(called_scope) = EG(called_scope); + call->called_scope = EG(called_scope); } else { - EX(called_scope) = ce; + call->called_scope = ce; } } if (IS_CONST == IS_CONST && IS_VAR == IS_CONST && CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); } else if (IS_CONST != IS_CONST && IS_VAR == IS_CONST && - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { /* do nothing */ } else if (IS_VAR != IS_UNUSED) { char *function_name_strval = NULL; @@ -4927,7 +5403,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZE function_name_strval = Z_STRVAL_P(opline->op2.zv); function_name_strlen = Z_STRLEN_P(opline->op2.zv); } else { - function_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { zend_error_noreturn(E_ERROR, "Function name must be a string"); @@ -4939,20 +5415,20 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZE if (function_name_strval) { if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + call->fbc = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, function_name_strval); } if (IS_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { if (IS_CONST == IS_CONST) { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } else { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, EX(fbc)); + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, call->fbc); } } } @@ -4966,29 +5442,31 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZE if (EG(This) && Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name); } - EX(fbc) = ce->constructor; + call->fbc = ce->constructor; } - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; + if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { + call->object = NULL; } else { if (EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + if (call->fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } } - if ((EX(object) = EG(This))) { - Z_ADDREF_P(EX(object)); - EX(called_scope) = Z_OBJCE_P(EX(object)); + if ((call->object = EG(This))) { + Z_ADDREF_P(call->object); + call->called_scope = Z_OBJCE_P(call->object); } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -5005,7 +5483,7 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_A } is_equal_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -5050,7 +5528,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_VAR_HANDLER(ZEND_OPC if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -5273,6 +5751,160 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_CONST_VAR_HANDLER(ZEND_OPC ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_CONST != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = opline->op1.zv; + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_CONST == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_CONST == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = opline->op1.zv; + + /* Consts, temporary variables and references need copying */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_VAR != IS_UNUSED) { + zend_free_op free_op2; + zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_UNUSED(int type, ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -5424,7 +6056,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_CONST_UNUSED_HANDLER(ZEND_OPC { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_CONST_UNUSED(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_CONST_UNUSED(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -5442,9 +6074,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER USE_OPLINE zval *function_name; zend_class_entry *ce; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_CONST == IS_CONST) { /* no function found. try a static method in class */ @@ -5458,24 +6090,24 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER } CACHE_PTR(opline->op1.literal->cache_slot, ce); } - EX(called_scope) = ce; + call->called_scope = ce; } else { ce = EX_T(opline->op1.var).class_entry; if (opline->extended_value == ZEND_FETCH_CLASS_PARENT || opline->extended_value == ZEND_FETCH_CLASS_SELF) { - EX(called_scope) = EG(called_scope); + call->called_scope = EG(called_scope); } else { - EX(called_scope) = ce; + call->called_scope = ce; } } if (IS_CONST == IS_CONST && IS_UNUSED == IS_CONST && CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); } else if (IS_CONST != IS_CONST && IS_UNUSED == IS_CONST && - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { /* do nothing */ } else if (IS_UNUSED != IS_UNUSED) { char *function_name_strval = NULL; @@ -5498,20 +6130,20 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER if (function_name_strval) { if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + call->fbc = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_UNUSED == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_UNUSED == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, function_name_strval); } if (IS_UNUSED == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { if (IS_CONST == IS_CONST) { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } else { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, EX(fbc)); + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, call->fbc); } } } @@ -5525,29 +6157,31 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER if (EG(This) && Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name); } - EX(fbc) = ce->constructor; + call->fbc = ce->constructor; } - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; + if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { + call->object = NULL; } else { if (EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + if (call->fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } } - if ((EX(object) = EG(This))) { - Z_ADDREF_P(EX(object)); - EX(called_scope) = Z_OBJCE_P(EX(object)); + if ((call->object = EG(This))) { + Z_ADDREF_P(call->object); + call->called_scope = Z_OBJCE_P(call->object); } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -5826,12 +6460,165 @@ static int ZEND_FASTCALL ZEND_DECLARE_LAMBDA_FUNCTION_SPEC_CONST_UNUSED_HANDLER zend_error_noreturn(E_ERROR, "Base lambda function for closure not found"); } - zend_create_closure(&EX_T(opline->result.var).tmp_var, op_array, EG(scope), EG(This) TSRMLS_CC); + zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(scope), EG(This) TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_CONST != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = opline->op1.zv; + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_CONST == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_CONST == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = opline->op1.zv; + + /* Consts, temporary variables and references need copying */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_UNUSED != IS_UNUSED) { + + zval *key = NULL; + + /* Consts, temporary variables and references need copying */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -5840,7 +6627,7 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -5855,7 +6642,7 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -5870,7 +6657,7 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -5885,7 +6672,7 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -5900,7 +6687,7 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -5915,7 +6702,7 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -5930,7 +6717,7 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -5945,7 +6732,7 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -5960,7 +6747,7 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -5976,7 +6763,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CONST_CV_HANDLER(ZEND_OPCOD SAVE_OPLINE(); is_identical_function(result, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); @@ -5993,7 +6780,7 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); CHECK_EXCEPTION(); @@ -6009,7 +6796,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); CHECK_EXCEPTION(); @@ -6025,7 +6812,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); CHECK_EXCEPTION(); @@ -6041,7 +6828,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CONST_CV_HANDLER(ZEND_OP SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); CHECK_EXCEPTION(); @@ -6056,7 +6843,7 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -6071,7 +6858,7 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -6086,7 +6873,7 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -6101,8 +6888,38 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); + + + CHECK_EXCEPTION(); + ZEND_VM_NEXT_OPCODE(); +} + +static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + zval **container; + + SAVE_OPLINE(); + + if ((opline->extended_value & ZEND_FETCH_ADD_LOCK) && + IS_CONST != IS_CV && + EX_T(opline->op1.var).var.ptr_ptr) { + PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); + } + + if (IS_CONST == IS_TMP_VAR || IS_CONST == IS_CONST) { + zval *container = opline->op1.zv; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); + + + } else { + container = NULL; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); + + + } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -6113,9 +6930,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEN USE_OPLINE zval *function_name; zend_class_entry *ce; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_CONST == IS_CONST) { /* no function found. try a static method in class */ @@ -6129,24 +6946,24 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEN } CACHE_PTR(opline->op1.literal->cache_slot, ce); } - EX(called_scope) = ce; + call->called_scope = ce; } else { ce = EX_T(opline->op1.var).class_entry; if (opline->extended_value == ZEND_FETCH_CLASS_PARENT || opline->extended_value == ZEND_FETCH_CLASS_SELF) { - EX(called_scope) = EG(called_scope); + call->called_scope = EG(called_scope); } else { - EX(called_scope) = ce; + call->called_scope = ce; } } if (IS_CONST == IS_CONST && IS_CV == IS_CONST && CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); } else if (IS_CONST != IS_CONST && IS_CV == IS_CONST && - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { /* do nothing */ } else if (IS_CV != IS_UNUSED) { char *function_name_strval = NULL; @@ -6157,7 +6974,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEN function_name_strval = Z_STRVAL_P(opline->op2.zv); function_name_strlen = Z_STRLEN_P(opline->op2.zv); } else { - function_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + function_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { zend_error_noreturn(E_ERROR, "Function name must be a string"); @@ -6169,20 +6986,20 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEN if (function_name_strval) { if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + call->fbc = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, function_name_strval); } if (IS_CV == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { if (IS_CONST == IS_CONST) { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } else { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, EX(fbc)); + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, call->fbc); } } } @@ -6196,29 +7013,31 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEN if (EG(This) && Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name); } - EX(fbc) = ce->constructor; + call->fbc = ce->constructor; } - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; + if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { + call->object = NULL; } else { if (EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + if (call->fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } } - if ((EX(object) = EG(This))) { - Z_ADDREF_P(EX(object)); - EX(called_scope) = Z_OBJCE_P(EX(object)); + if ((call->object = EG(This))) { + Z_ADDREF_P(call->object); + call->called_scope = Z_OBJCE_P(call->object); } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -6268,7 +7087,7 @@ static int ZEND_FASTCALL ZEND_CATCH_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_A if (EX_CV(opline->op2.var)) { zval_ptr_dtor(EX_CV(opline->op2.var)); } - EX_CV(opline->op2.var) = (zval**)EX_CVs() + (EX(op_array)->last_var + opline->op2.var); + EX_CV(opline->op2.var) = (zval**)EX_CV_NUM(execute_data, EX(op_array)->last_var + opline->op2.var); *EX_CV(opline->op2.var) = EG(exception); } else { zend_compiled_variable *cv = &CV_DEF_OF(opline->op2.var); @@ -6295,7 +7114,7 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_AR } is_equal_function(&EX_T(opline->result.var).tmp_var, opline->op1.zv, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -6339,7 +7158,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CV_HANDLER(ZEND_OPCO if (IS_CV != IS_UNUSED) { - zval *offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -6401,6 +7220,159 @@ static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HAND } } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_CONST != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = opline->op1.zv; + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_CONST == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_CONST == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = opline->op1.zv; + + /* Consts, temporary variables and references need copying */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_CV != IS_UNUSED) { + + zval *key = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_BW_NOT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -6408,7 +7380,7 @@ static int ZEND_FASTCALL ZEND_BW_NOT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); bitwise_not_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -6421,7 +7393,7 @@ static int ZEND_FASTCALL ZEND_BOOL_NOT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); boolean_not_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -6434,7 +7406,7 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *z; SAVE_OPLINE(); - z = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + z = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR == IS_TMP_VAR && Z_TYPE_P(z) == IS_OBJECT) { INIT_PZVAL(z); @@ -6462,7 +7434,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) int ret; SAVE_OPLINE(); - val = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { ret = Z_LVAL_P(val); @@ -6492,7 +7464,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) int ret; SAVE_OPLINE(); - val = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { ret = Z_LVAL_P(val); @@ -6522,7 +7494,7 @@ static int ZEND_FASTCALL ZEND_JMPZNZ_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) int retval; SAVE_OPLINE(); - val = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { retval = Z_LVAL_P(val); @@ -6556,7 +7528,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS int retval; SAVE_OPLINE(); - val = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { retval = Z_LVAL_P(val); @@ -6587,7 +7559,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG int retval; SAVE_OPLINE(); - val = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + val = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { retval = Z_LVAL_P(val); @@ -6631,13 +7603,16 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; SAVE_OPLINE(); - retval_ptr = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + retval_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (!EG(return_value_ptr_ptr)) { if (IS_TMP_VAR == IS_TMP_VAR) { zval_dtor(free_op1.var); } } else if (!1) { /* Not a temp var */ + if (*EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } if (IS_TMP_VAR == IS_CONST || (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) { zval *ret; @@ -6659,6 +7634,10 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { zval *ret; + if (*EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } + ALLOC_ZVAL(ret); INIT_PZVAL_COPY(ret, retval_ptr); *EG(return_value_ptr_ptr) = ret; @@ -6677,11 +7656,15 @@ static int ZEND_FASTCALL ZEND_RETURN_BY_REF_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); do { + if (EG(return_value_ptr_ptr) && *EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR) { /* Not supposed to happen, but we'll allow it */ zend_error(E_NOTICE, "Only variable references should be returned by reference"); - retval_ptr = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + retval_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (!EG(return_value_ptr_ptr)) { if (IS_TMP_VAR == IS_TMP_VAR) { zval_dtor(free_op1.var); @@ -6742,7 +7725,7 @@ static int ZEND_FASTCALL ZEND_THROW_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) { zend_error_noreturn(E_ERROR, "Can only throw objects"); @@ -6767,7 +7750,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); if (opline->extended_value==ZEND_DO_FCALL_BY_NAME - && ARG_MUST_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + && ARG_MUST_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.opline_num); } { @@ -6775,7 +7758,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG zval *value; zend_free_op free_op1; - value = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); ALLOC_ZVAL(valptr); INIT_PZVAL_COPY(valptr, value); @@ -6797,7 +7780,7 @@ static int ZEND_FASTCALL ZEND_BOOL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */ - ZVAL_BOOL(retval, i_zend_is_true(_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC))); + ZVAL_BOOL(retval, i_zend_is_true(_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC))); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -6814,7 +7797,7 @@ static int ZEND_FASTCALL ZEND_CLONE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_object_clone_obj_t clone_call; SAVE_OPLINE(); - obj = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + obj = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR == IS_CONST || UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT)) { @@ -6875,7 +7858,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *result = &EX_T(opline->result.var).tmp_var; SAVE_OPLINE(); - expr = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (opline->extended_value != IS_STRING) { ZVAL_COPY_VALUE(result, expr); @@ -6932,11 +7915,11 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND zend_op_array *new_op_array=NULL; zend_free_op free_op1; zval *inc_filename; - zval *tmp_inc_filename = NULL; + zval *tmp_inc_filename = NULL; zend_bool failure_retval=0; SAVE_OPLINE(); - inc_filename = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + inc_filename = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (inc_filename->type!=IS_STRING) { MAKE_STD_ZVAL(tmp_inc_filename); @@ -7024,8 +8007,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND EG(return_value_ptr_ptr) = NULL; } - EX(current_object) = EX(object); - EX(function_state).function = (zend_function *) new_op_array; EX(object) = NULL; @@ -7033,14 +8014,13 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND zend_rebuild_symbol_table(TSRMLS_C); } - if (EXPECTED(zend_execute == execute)) { + if (EXPECTED(zend_execute_ex == execute_ex)) { ZEND_VM_ENTER(); } else { zend_execute(new_op_array TSRMLS_CC); } EX(function_state).function = (zend_function *) EX(op_array); - EX(object) = EX(current_object); EG(opline_ptr) = &EX(opline); EG(active_op_array) = EX(op_array); @@ -7050,15 +8030,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND if (UNEXPECTED(EG(exception) != NULL)) { zend_throw_exception_internal(NULL TSRMLS_CC); HANDLE_EXCEPTION(); - } else if (RETURN_VALUE_USED(opline)) { - if (!EX_T(opline->result.var).var.ptr) { /* there was no return statement */ - zval *retval; - - ALLOC_ZVAL(retval); - ZVAL_BOOL(retval, 1); - INIT_PZVAL(retval); - EX_T(opline->result.var).var.ptr = retval; - } } } else if (RETURN_VALUE_USED(opline)) { @@ -7113,7 +8084,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG Z_ADDREF_P(array_ptr); } } else { - array_ptr = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + array_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (1) { /* IS_TMP_VAR */ zval *tmp; @@ -7222,7 +8193,7 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op1; - zval *ptr = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval *ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (Z_TYPE_P(ptr) == IS_LONG) { EG(exit_status) = Z_LVAL_P(ptr); @@ -7272,7 +8243,7 @@ static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (i_zend_is_true(value)) { ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, value); @@ -7298,7 +8269,7 @@ static int ZEND_FASTCALL ZEND_JMP_SET_VAR_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ zval *value, *ret; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (i_zend_is_true(value)) { if (IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) { @@ -7333,7 +8304,7 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, value); if (!1) { @@ -7351,7 +8322,7 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_VAR_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLE zval *value, *ret; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) { Z_ADDREF_P(value); @@ -7379,7 +8350,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_A zend_bool result; SAVE_OPLINE(); - expr = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->get_class_entry) { result = instanceof_function(Z_OBJCE_P(expr), EX_T(opline->op2.var).class_entry TSRMLS_CC); @@ -7399,7 +8370,7 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7414,7 +8385,7 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7429,7 +8400,7 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7444,7 +8415,7 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7459,7 +8430,7 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7474,7 +8445,7 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7489,7 +8460,7 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7504,7 +8475,7 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7519,7 +8490,7 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7535,7 +8506,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_TMP_CONST_HANDLER(ZEND_OPCO SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); zval_dtor(free_op1.var); @@ -7552,7 +8523,7 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC)); zval_dtor(free_op1.var); @@ -7568,7 +8539,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC)); zval_dtor(free_op1.var); @@ -7584,7 +8555,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC)); zval_dtor(free_op1.var); @@ -7600,7 +8571,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_TMP_CONST_HANDLER(ZEND_O SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC)); zval_dtor(free_op1.var); @@ -7615,7 +8586,7 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7630,7 +8601,7 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7645,7 +8616,7 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7660,7 +8631,7 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); zval_dtor(free_op1.var); @@ -7679,7 +8650,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type, ulong hash_value; SAVE_OPLINE(); - varname = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { ZVAL_COPY_VALUE(&tmp_varname, varname); @@ -7819,7 +8790,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_TMP_CONST(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_TMP_CONST(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -7832,6 +8803,36 @@ static int ZEND_FASTCALL ZEND_FETCH_IS_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDL return zend_fetch_var_address_helper_SPEC_TMP_CONST(BP_VAR_IS, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + zend_free_op free_op1; + zval **container; + + SAVE_OPLINE(); + + if ((opline->extended_value & ZEND_FETCH_ADD_LOCK) && + IS_TMP_VAR != IS_CV && + EX_T(opline->op1.var).var.ptr_ptr) { + PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); + } + + if (IS_TMP_VAR == IS_TMP_VAR || IS_TMP_VAR == IS_CONST) { + zval *container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); + + zval_dtor(free_op1.var); + } else { + container = NULL; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); + + + } + + CHECK_EXCEPTION(); + ZEND_VM_NEXT_OPCODE(); +} + static int ZEND_FASTCALL ZEND_FETCH_DIM_TMP_VAR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -7839,7 +8840,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_TMP_VAR_SPEC_TMP_CONST_HANDLER(ZEND_OPC zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) { PZVAL_LOCK(&EG(uninitialized_zval)); @@ -7909,9 +8910,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CONST_HANDLER(ZEND_OPCO char *function_name_strval; int function_name_strlen; zend_free_op free_op1; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); function_name = opline->op2.zv; @@ -7923,49 +8924,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CONST_HANDLER(ZEND_OPCO function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + call->object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_CONST != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_CONST == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); @@ -7982,7 +8989,7 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_A PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); CHECK_EXCEPTION(); @@ -8006,7 +9013,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CONST_HANDLER(ZEND_OPC expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr_ptr=_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (1) { /* temporary variable */ zval *new_expr; @@ -8113,7 +9120,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HAND ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -8189,7 +9196,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_CONST_HANDLER(ZEND_OPC } else { HashTable *target_symbol_table; zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -8250,6 +9257,159 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_CONST_HANDLER(ZEND_OPC ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_TMP_VAR != IS_UNUSED) { + zend_free_op free_op1; + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_TMP_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_TMP_VAR == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_CONST != IS_UNUSED) { + + zval *key = opline->op2.zv; + + /* Consts, temporary variables and references need copying */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -8257,8 +9417,8 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8272,8 +9432,8 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8287,8 +9447,8 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8302,8 +9462,8 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8317,8 +9477,8 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8332,8 +9492,8 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8347,8 +9507,8 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8362,8 +9522,8 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8377,8 +9537,8 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8393,8 +9553,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); zval_dtor(free_op1.var); zval_dtor(free_op2.var); @@ -8410,8 +9570,8 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8426,8 +9586,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8442,8 +9602,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8458,8 +9618,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_TMP_TMP_HANDLER(ZEND_OPC SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8473,8 +9633,8 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8488,8 +9648,8 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8503,8 +9663,8 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8518,14 +9678,44 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + zend_free_op free_op1, free_op2; + zval **container; + + SAVE_OPLINE(); + + if ((opline->extended_value & ZEND_FETCH_ADD_LOCK) && + IS_TMP_VAR != IS_CV && + EX_T(opline->op1.var).var.ptr_ptr) { + PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); + } + + if (IS_TMP_VAR == IS_TMP_VAR || IS_TMP_VAR == IS_CONST) { + zval *container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); + zval_dtor(free_op2.var); + zval_dtor(free_op1.var); + } else { + container = NULL; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); + zval_dtor(free_op2.var); + + } + + CHECK_EXCEPTION(); + ZEND_VM_NEXT_OPCODE(); +} + static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -8536,7 +9726,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ int use_copy = 0; SAVE_OPLINE(); - var = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + var = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_TMP_VAR == IS_UNUSED) { /* Initialize for erealloc in add_string_to_string */ @@ -8578,11 +9768,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE char *function_name_strval; int function_name_strlen; zend_free_op free_op1, free_op2; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -8592,49 +9782,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + call->object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_TMP_VAR != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_TMP_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + zval_dtor(free_op2.var); + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; zval_dtor(free_op2.var); @@ -8652,8 +9848,8 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -8677,7 +9873,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP_HANDLER(ZEND_OPCOD expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr_ptr=_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (1) { /* temporary variable */ zval *new_expr; @@ -8698,7 +9894,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP_HANDLER(ZEND_OPCOD if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -8760,6 +9956,159 @@ static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDL } } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_TMP_VAR != IS_UNUSED) { + zend_free_op free_op1; + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_TMP_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_TMP_VAR == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_TMP_VAR != IS_UNUSED) { + zend_free_op free_op2; + zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -8767,8 +10116,8 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8782,8 +10131,8 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8797,8 +10146,8 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8812,8 +10161,8 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8827,8 +10176,8 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8842,8 +10191,8 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8857,8 +10206,8 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8872,8 +10221,8 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8887,8 +10236,8 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8903,8 +10252,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; @@ -8920,8 +10269,8 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8936,8 +10285,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8952,8 +10301,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8968,8 +10317,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_TMP_VAR_HANDLER(ZEND_OPC SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8983,8 +10332,8 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -8998,8 +10347,8 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -9013,8 +10362,8 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -9028,8 +10377,8 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -9047,7 +10396,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE ulong hash_value; SAVE_OPLINE(); - varname = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { ZVAL_COPY_VALUE(&tmp_varname, varname); @@ -9187,7 +10536,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_H { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_TMP_VAR(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_TMP_VAR(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -9200,6 +10549,36 @@ static int ZEND_FASTCALL ZEND_FETCH_IS_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER return zend_fetch_var_address_helper_SPEC_TMP_VAR(BP_VAR_IS, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + zend_free_op free_op1, free_op2; + zval **container; + + SAVE_OPLINE(); + + if ((opline->extended_value & ZEND_FETCH_ADD_LOCK) && + IS_TMP_VAR != IS_CV && + EX_T(opline->op1.var).var.ptr_ptr) { + PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); + } + + if (IS_TMP_VAR == IS_TMP_VAR || IS_TMP_VAR == IS_CONST) { + zval *container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + zval_dtor(free_op1.var); + } else { + container = NULL; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + + } + + CHECK_EXCEPTION(); + ZEND_VM_NEXT_OPCODE(); +} + static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -9210,7 +10589,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ int use_copy = 0; SAVE_OPLINE(); - var = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + var = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_TMP_VAR == IS_UNUSED) { /* Initialize for erealloc in add_string_to_string */ @@ -9252,11 +10631,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE char *function_name_strval; int function_name_strlen; zend_free_op free_op1, free_op2; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -9266,49 +10645,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + call->object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_VAR != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; @@ -9326,8 +10711,8 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -9351,7 +10736,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_VAR_HANDLER(ZEND_OPCOD expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr_ptr=_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (1) { /* temporary variable */ zval *new_expr; @@ -9372,7 +10757,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_VAR_HANDLER(ZEND_OPCOD if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -9458,7 +10843,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLE ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -9534,7 +10919,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCOD } else { HashTable *target_symbol_table; zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -9595,6 +10980,160 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_VAR_HANDLER(ZEND_OPCOD ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_TMP_VAR != IS_UNUSED) { + zend_free_op free_op1; + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_TMP_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_TMP_VAR == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_VAR != IS_UNUSED) { + zend_free_op free_op2; + zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type, ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -9606,7 +11145,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type, ulong hash_value; SAVE_OPLINE(); - varname = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { ZVAL_COPY_VALUE(&tmp_varname, varname); @@ -9746,7 +11285,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCOD { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_TMP_UNUSED(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_TMP_UNUSED(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -9776,7 +11315,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNUSED_HANDLER(ZEND_OP expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr_ptr=_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (1) { /* temporary variable */ zval *new_expr; @@ -9883,7 +11422,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HAN ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -9959,7 +11498,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_UNUSED_HANDLER(ZEND_OP } else { HashTable *target_symbol_table; zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -10020,6 +11559,159 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_UNUSED_HANDLER(ZEND_OP ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_TMP_VAR != IS_UNUSED) { + zend_free_op free_op1; + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_TMP_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_TMP_VAR == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_UNUSED != IS_UNUSED) { + + zval *key = NULL; + + /* Consts, temporary variables and references need copying */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -10027,8 +11719,8 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10042,8 +11734,8 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10057,8 +11749,8 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10072,8 +11764,8 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10087,8 +11779,8 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10102,8 +11794,8 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10117,8 +11809,8 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10132,8 +11824,8 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10147,8 +11839,8 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10163,8 +11855,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); zval_dtor(free_op1.var); @@ -10180,8 +11872,8 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10196,8 +11888,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10212,8 +11904,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10228,8 +11920,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_TMP_CV_HANDLER(ZEND_OPCO SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10243,8 +11935,8 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10258,8 +11950,8 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10273,8 +11965,8 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10288,14 +11980,44 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + zend_free_op free_op1; + zval **container; + + SAVE_OPLINE(); + + if ((opline->extended_value & ZEND_FETCH_ADD_LOCK) && + IS_TMP_VAR != IS_CV && + EX_T(opline->op1.var).var.ptr_ptr) { + PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); + } + + if (IS_TMP_VAR == IS_TMP_VAR || IS_TMP_VAR == IS_CONST) { + zval *container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); + + zval_dtor(free_op1.var); + } else { + container = NULL; + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); + + + } + + CHECK_EXCEPTION(); + ZEND_VM_NEXT_OPCODE(); +} + static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -10306,7 +12028,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_A int use_copy = 0; SAVE_OPLINE(); - var = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + var = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_TMP_VAR == IS_UNUSED) { /* Initialize for erealloc in add_string_to_string */ @@ -10347,11 +12069,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_ char *function_name_strval; int function_name_strlen; zend_free_op free_op1; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + function_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_CV != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -10361,49 +12083,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_ function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + call->object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_CV != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_CV == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); @@ -10420,8 +12148,8 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10444,7 +12172,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr_ptr=_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (1) { /* temporary variable */ zval *new_expr; @@ -10465,7 +12193,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE if (IS_CV != IS_UNUSED) { - zval *offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -10527,6 +12255,159 @@ static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLE } } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_TMP_VAR != IS_UNUSED) { + zend_free_op free_op1; + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_TMP_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_TMP_VAR == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_CV != IS_UNUSED) { + + zval *key = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_BW_NOT_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -10534,7 +12415,7 @@ static int ZEND_FASTCALL ZEND_BW_NOT_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); bitwise_not_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10547,7 +12428,7 @@ static int ZEND_FASTCALL ZEND_BOOL_NOT_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); boolean_not_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -10560,7 +12441,7 @@ static int ZEND_FASTCALL ZEND_PRE_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval **var_ptr; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -10607,7 +12488,7 @@ static int ZEND_FASTCALL ZEND_PRE_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval **var_ptr; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -10654,7 +12535,7 @@ static int ZEND_FASTCALL ZEND_POST_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zval **var_ptr, *retval; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -10697,7 +12578,7 @@ static int ZEND_FASTCALL ZEND_POST_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zval **var_ptr, *retval; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -10740,7 +12621,7 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *z; SAVE_OPLINE(); - z = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + z = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_TMP_VAR && Z_TYPE_P(z) == IS_OBJECT) { INIT_PZVAL(z); @@ -10768,7 +12649,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) int ret; SAVE_OPLINE(); - val = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + val = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { ret = Z_LVAL_P(val); @@ -10798,7 +12679,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) int ret; SAVE_OPLINE(); - val = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + val = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { ret = Z_LVAL_P(val); @@ -10828,7 +12709,7 @@ static int ZEND_FASTCALL ZEND_JMPZNZ_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) int retval; SAVE_OPLINE(); - val = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + val = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { retval = Z_LVAL_P(val); @@ -10862,7 +12743,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS int retval; SAVE_OPLINE(); - val = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + val = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { retval = Z_LVAL_P(val); @@ -10893,7 +12774,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG int retval; SAVE_OPLINE(); - val = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + val = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { retval = Z_LVAL_P(val); @@ -10937,13 +12818,16 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; SAVE_OPLINE(); - retval_ptr = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + retval_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (!EG(return_value_ptr_ptr)) { if (IS_VAR == IS_TMP_VAR) { if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; } } else if (!0) { /* Not a temp var */ + if (*EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } if (IS_VAR == IS_CONST || (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) { zval *ret; @@ -10965,6 +12849,10 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { zval *ret; + if (*EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } + ALLOC_ZVAL(ret); INIT_PZVAL_COPY(ret, retval_ptr); *EG(return_value_ptr_ptr) = ret; @@ -10983,11 +12871,15 @@ static int ZEND_FASTCALL ZEND_RETURN_BY_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); do { + if (EG(return_value_ptr_ptr) && *EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { /* Not supposed to happen, but we'll allow it */ zend_error(E_NOTICE, "Only variable references should be returned by reference"); - retval_ptr = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + retval_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (!EG(return_value_ptr_ptr)) { if (IS_VAR == IS_TMP_VAR) { if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -11009,7 +12901,7 @@ static int ZEND_FASTCALL ZEND_RETURN_BY_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLE break; } - retval_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + retval_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(retval_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference"); @@ -11049,7 +12941,7 @@ static int ZEND_FASTCALL ZEND_THROW_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; SAVE_OPLINE(); - value = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) { zend_error_noreturn(E_ERROR, "Can only throw objects"); @@ -11073,7 +12965,7 @@ static int ZEND_FASTCALL zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_AR USE_OPLINE zval *varptr; zend_free_op free_op1; - varptr = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (varptr == &EG(uninitialized_zval)) { ALLOC_ZVAL(varptr); @@ -11107,7 +12999,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { return zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } - } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { return zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -11118,7 +13010,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND varptr = EX_T(opline->op1.var).var.ptr; PZVAL_UNLOCK_EX(varptr, &free_op1, 0); } else { - varptr = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); } if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) || EX_T(opline->op1.var).var.fcall_returned_reference) && @@ -11133,7 +13025,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ? !(opline->extended_value & ZEND_ARG_SEND_SILENT) : - !ARG_MAY_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + !ARG_MAY_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { zend_error(E_STRICT, "Only variables should be passed by reference"); } ALLOC_ZVAL(valptr); @@ -11156,7 +13048,7 @@ static int ZEND_FASTCALL ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zval *varptr; SAVE_OPLINE(); - varptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(varptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); @@ -11169,7 +13061,7 @@ static int ZEND_FASTCALL ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG ZEND_VM_NEXT_OPCODE(); } - if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION && !ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION && !ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { return zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -11188,7 +13080,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG USE_OPLINE if ((opline->extended_value == ZEND_DO_FCALL_BY_NAME) - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + && ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { return ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } SAVE_OPLINE(); @@ -11203,7 +13095,7 @@ static int ZEND_FASTCALL ZEND_BOOL_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */ - ZVAL_BOOL(retval, i_zend_is_true(_get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC))); + ZVAL_BOOL(retval, i_zend_is_true(_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC))); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -11230,7 +13122,7 @@ static int ZEND_FASTCALL ZEND_CLONE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_object_clone_obj_t clone_call; SAVE_OPLINE(); - obj = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + obj = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_CONST || UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT)) { @@ -11291,7 +13183,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *result = &EX_T(opline->result.var).tmp_var; SAVE_OPLINE(); - expr = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (opline->extended_value != IS_STRING) { ZVAL_COPY_VALUE(result, expr); @@ -11348,11 +13240,11 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND zend_op_array *new_op_array=NULL; zend_free_op free_op1; zval *inc_filename; - zval *tmp_inc_filename = NULL; + zval *tmp_inc_filename = NULL; zend_bool failure_retval=0; SAVE_OPLINE(); - inc_filename = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + inc_filename = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (inc_filename->type!=IS_STRING) { MAKE_STD_ZVAL(tmp_inc_filename); @@ -11440,8 +13332,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND EG(return_value_ptr_ptr) = NULL; } - EX(current_object) = EX(object); - EX(function_state).function = (zend_function *) new_op_array; EX(object) = NULL; @@ -11449,14 +13339,13 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND zend_rebuild_symbol_table(TSRMLS_C); } - if (EXPECTED(zend_execute == execute)) { + if (EXPECTED(zend_execute_ex == execute_ex)) { ZEND_VM_ENTER(); } else { zend_execute(new_op_array TSRMLS_CC); } EX(function_state).function = (zend_function *) EX(op_array); - EX(object) = EX(current_object); EG(opline_ptr) = &EX(opline); EG(active_op_array) = EX(op_array); @@ -11466,15 +13355,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND if (UNEXPECTED(EG(exception) != NULL)) { zend_throw_exception_internal(NULL TSRMLS_CC); HANDLE_EXCEPTION(); - } else if (RETURN_VALUE_USED(opline)) { - if (!EX_T(opline->result.var).var.ptr) { /* there was no return statement */ - zval *retval; - - ALLOC_ZVAL(retval); - ZVAL_BOOL(retval, 1); - INIT_PZVAL(retval); - EX_T(opline->result.var).var.ptr = retval; - } } } else if (RETURN_VALUE_USED(opline)) { @@ -11502,7 +13382,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) && (opline->extended_value & ZEND_FE_RESET_VARIABLE)) { - array_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + array_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (array_ptr_ptr == NULL || array_ptr_ptr == &EG(uninitialized_zval_ptr)) { MAKE_STD_ZVAL(array_ptr); ZVAL_NULL(array_ptr); @@ -11529,7 +13409,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG Z_ADDREF_P(array_ptr); } } else { - array_ptr = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + array_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { /* IS_TMP_VAR */ zval *tmp; @@ -11672,8 +13552,7 @@ static int ZEND_FASTCALL ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zend_check_property_access(zobj, str_key, str_key_len-1 TSRMLS_CC) != SUCCESS)); zend_hash_get_pointer(fe_ht, &EX_T(opline->op1.var).fe.fe_pos); if (use_key && key_type != HASH_KEY_IS_LONG) { - zend_unmangle_property_name(str_key, str_key_len-1, &class_name, &prop_name); - str_key_len = strlen(prop_name); + zend_unmangle_property_name_ex(str_key, str_key_len-1, &class_name, &prop_name, &str_key_len); str_key = estrndup(prop_name, str_key_len); str_key_len++; } @@ -11781,7 +13660,7 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); if (IS_VAR != IS_UNUSED) { zend_free_op free_op1; - zval *ptr = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval *ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (Z_TYPE_P(ptr) == IS_LONG) { EG(exit_status) = Z_LVAL_P(ptr); @@ -11802,7 +13681,7 @@ static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (i_zend_is_true(value)) { ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, value); @@ -11828,7 +13707,7 @@ static int ZEND_FASTCALL ZEND_JMP_SET_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ zval *value, *ret; SAVE_OPLINE(); - value = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (i_zend_is_true(value)) { if (IS_VAR == IS_VAR || IS_VAR == IS_CV) { @@ -11863,7 +13742,7 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, value); if (!0) { @@ -11881,7 +13760,7 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLE zval *value, *ret; SAVE_OPLINE(); - value = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR || IS_VAR == IS_CV) { Z_ADDREF_P(value); @@ -11910,7 +13789,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_A zend_bool result; SAVE_OPLINE(); - expr = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->get_class_entry) { result = instanceof_function(Z_OBJCE_P(expr), EX_T(opline->op2.var).class_entry TSRMLS_CC); @@ -11930,7 +13809,7 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -11945,7 +13824,7 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -11960,7 +13839,7 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -11975,7 +13854,7 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -11990,7 +13869,7 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12005,7 +13884,7 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12020,7 +13899,7 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12035,7 +13914,7 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12050,7 +13929,7 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12066,7 +13945,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_VAR_CONST_HANDLER(ZEND_OPCO SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12083,7 +13962,7 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12099,7 +13978,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12115,7 +13994,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12131,7 +14010,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_VAR_CONST_HANDLER(ZEND_O SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12146,7 +14025,7 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12161,7 +14040,7 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12176,7 +14055,7 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12191,7 +14070,7 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12203,10 +14082,10 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_CONST(int (*b { USE_OPLINE zend_free_op free_op1, free_op_data1; - zval **object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); zval *object; zval *property = opline->op2.zv; - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -12324,7 +14203,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_CONST(int (*binar return zend_binary_assign_op_obj_helper_SPEC_VAR_CONST(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); break; case ZEND_ASSIGN_DIM: { - zval **container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -12337,14 +14216,14 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_CONST(int (*binar zval *dim = opline->op2.zv; zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_CONST, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: value = opline->op2.zv; - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); /* do nothing */ break; } @@ -12466,7 +14345,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_CONST(incdec_t int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); property = opline->op2.zv; retval = &EX_T(opline->result.var).var.ptr; @@ -12570,7 +14449,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_CONST(incdec_ int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); property = opline->op2.zv; retval = &EX_T(opline->result.var).tmp_var; @@ -12672,7 +14551,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type, ulong hash_value; SAVE_OPLINE(); - varname = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { ZVAL_COPY_VALUE(&tmp_varname, varname); @@ -12812,7 +14691,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_VAR_CONST(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_VAR_CONST(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -12838,10 +14717,19 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA EX_T(opline->op1.var).var.ptr_ptr) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); - if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + if (IS_VAR == IS_TMP_VAR || IS_VAR == IS_CONST) { + zval *container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } else { + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -12853,7 +14741,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -12887,7 +14775,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -12909,7 +14797,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, opline->op2.zv, IS_CONST, BP_VAR_IS TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -12925,8 +14813,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_CONST_HANDLER(ZEND_OP SAVE_OPLINE(); - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -12938,7 +14826,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_CONST_HANDLER(ZEND_OP if (IS_CONST == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); } @@ -12954,7 +14842,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_CONST_HANDLER(ZEND_OPCOD zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -12972,6 +14860,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_CONST_HANDLER(ZEND_OPCOD if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (UNEXPECTED(EX_T(opline->result.var).var.ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); + ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_res; zval **retval_ptr = EX_T(opline->result.var).var.ptr_ptr; @@ -12996,7 +14885,7 @@ static int ZEND_FASTCALL zend_fetch_property_address_read_helper_SPEC_VAR_CONST( zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); offset = opline->op2.zv; if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || @@ -13053,7 +14942,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA if (0) { MAKE_REAL_ZVAL_PTR(property); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } @@ -13093,7 +14982,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); property = opline->op2.zv; - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -13124,7 +15013,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); offset = opline->op2.zv; if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || @@ -13161,7 +15050,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_CONST_HANDLER(ZEND_OP { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1; zval *property; @@ -13169,7 +15058,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_CONST_HANDLER(ZEND_OP SAVE_OPLINE(); property = opline->op2.zv; - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -13202,7 +15091,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_CONST_HANDLER(ZEND_OPCOD zval *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); property = opline->op2.zv; if (IS_VAR == IS_CV) { @@ -13245,7 +15134,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN zval *property_name; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); property_name = opline->op2.zv; if (0) { @@ -13254,7 +15143,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_CONST == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_CONST == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -13274,7 +15163,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN zval **object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -13286,7 +15175,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN if (0) { MAKE_REAL_ZVAL_PTR(property_name); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((IS_CONST == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_CONST == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -13300,8 +15189,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAN zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, IS_CONST, BP_VAR_W TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); if (UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) { if (RETURN_VALUE_USED(opline)) { @@ -13356,7 +15245,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); value = opline->op2.zv; - variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T(opline->op1.var), value, IS_CONST TSRMLS_CC)) { @@ -13409,9 +15298,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCO char *function_name_strval; int function_name_strlen; zend_free_op free_op1; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); function_name = opline->op2.zv; @@ -13423,49 +15312,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCO function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + call->object = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_CONST != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_CONST == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -13478,9 +15373,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZE USE_OPLINE zval *function_name; zend_class_entry *ce; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_VAR == IS_CONST) { /* no function found. try a static method in class */ @@ -13494,24 +15389,24 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZE } CACHE_PTR(opline->op1.literal->cache_slot, ce); } - EX(called_scope) = ce; + call->called_scope = ce; } else { ce = EX_T(opline->op1.var).class_entry; if (opline->extended_value == ZEND_FETCH_CLASS_PARENT || opline->extended_value == ZEND_FETCH_CLASS_SELF) { - EX(called_scope) = EG(called_scope); + call->called_scope = EG(called_scope); } else { - EX(called_scope) = ce; + call->called_scope = ce; } } if (IS_VAR == IS_CONST && IS_CONST == IS_CONST && CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); } else if (IS_VAR != IS_CONST && IS_CONST == IS_CONST && - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { /* do nothing */ } else if (IS_CONST != IS_UNUSED) { char *function_name_strval = NULL; @@ -13534,20 +15429,20 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZE if (function_name_strval) { if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + call->fbc = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, function_name_strval); } if (IS_CONST == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { if (IS_VAR == IS_CONST) { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } else { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, EX(fbc)); + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, call->fbc); } } } @@ -13561,29 +15456,31 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZE if (EG(This) && Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name); } - EX(fbc) = ce->constructor; + call->fbc = ce->constructor; } - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; + if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { + call->object = NULL; } else { if (EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + if (call->fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } } - if ((EX(object) = EG(This))) { - Z_ADDREF_P(EX(object)); - EX(called_scope) = Z_OBJCE_P(EX(object)); + if ((call->object = EG(This))) { + Z_ADDREF_P(call->object); + call->called_scope = Z_OBJCE_P(call->object); } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -13599,7 +15496,7 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_A PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), opline->op2.zv TSRMLS_CC); CHECK_EXCEPTION(); @@ -13689,6 +15586,9 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE } ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, *value); zval_copy_ctor(&EX_T(opline->result.var).tmp_var); + } else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && strcmp(Z_STRVAL_P(opline->op2.zv), "class") == 0) { + /* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */ + ZVAL_STRINGL(&EX_T(opline->result.var).tmp_var, ce->name, ce->name_length, 1); } else { zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv)); } @@ -13706,7 +15606,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CONST_HANDLER(ZEND_OPC SAVE_OPLINE(); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) { - zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); @@ -13715,7 +15615,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CONST_HANDLER(ZEND_OPC expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr_ptr=_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { /* temporary variable */ zval *new_expr; @@ -13822,7 +15722,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -13883,7 +15783,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_CV && container != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(container); } @@ -13982,7 +15882,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); offset = opline->op2.zv; if (IS_VAR != IS_VAR || container) { @@ -14039,7 +15939,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_VAR_CONST_HANDLER(ZEND_OPC } else { HashTable *target_symbol_table; zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -14111,7 +16011,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_CONST( zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); offset = opline->op2.zv; @@ -14254,6 +16154,161 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_CONST_HANDLER(ZEN return zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_CONST(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_VAR != IS_UNUSED) { + zend_free_op free_op1; + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_VAR == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + } else { + zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_CONST != IS_UNUSED) { + + zval *key = opline->op2.zv; + + /* Consts, temporary variables and references need copying */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -14261,8 +16316,8 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14276,8 +16331,8 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14291,8 +16346,8 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14306,8 +16361,8 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14321,8 +16376,8 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14336,8 +16391,8 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14351,8 +16406,8 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14366,8 +16421,8 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14381,8 +16436,8 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14397,8 +16452,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); @@ -14414,8 +16469,8 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14430,8 +16485,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14446,8 +16501,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14462,8 +16517,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_VAR_TMP_HANDLER(ZEND_OPC SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14477,8 +16532,8 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14492,8 +16547,8 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14507,8 +16562,8 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14522,8 +16577,8 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -14534,10 +16589,10 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_TMP(int (*bin { USE_OPLINE zend_free_op free_op1, free_op2, free_op_data1; - zval **object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); zval *object; - zval *property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -14655,7 +16710,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_TMP(int (*binary_ return zend_binary_assign_op_obj_helper_SPEC_VAR_TMP(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); break; case ZEND_ASSIGN_DIM: { - zval **container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -14665,17 +16720,17 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_TMP(int (*binary_ } return zend_binary_assign_op_obj_helper_SPEC_VAR_TMP(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_TMP_VAR, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: - value = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); /* do nothing */ break; } @@ -14798,8 +16853,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_TMP(incdec_t i int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).var.ptr; if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -14902,8 +16957,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_TMP(incdec_t int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).tmp_var; if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -15006,10 +17061,19 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND EX_T(opline->op1.var).var.ptr_ptr) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); - zval_dtor(free_op2.var); - if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + + if (IS_VAR == IS_TMP_VAR || IS_VAR == IS_CONST) { + zval *container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); + zval_dtor(free_op2.var); + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } else { + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); + zval_dtor(free_op2.var); + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -15021,12 +17085,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_W TSRMLS_CC); zval_dtor(free_op2.var); if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -15055,12 +17119,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_RW TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_RW TSRMLS_CC); zval_dtor(free_op2.var); if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -15077,8 +17141,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_IS TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_IS TSRMLS_CC); zval_dtor(free_op2.var); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -15093,12 +17157,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_TMP_HANDLER(ZEND_OPCO SAVE_OPLINE(); - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); } @@ -15106,8 +17170,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_TMP_HANDLER(ZEND_OPCO if (IS_TMP_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); } zval_dtor(free_op2.var); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -15122,7 +17186,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_ zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -15132,7 +17196,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_ if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_UNSET TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_UNSET TSRMLS_CC); zval_dtor(free_op2.var); if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -15140,6 +17204,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_ if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (UNEXPECTED(EX_T(opline->result.var).var.ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); + ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_res; zval **retval_ptr = EX_T(opline->result.var).var.ptr_ptr; @@ -15164,8 +17229,8 @@ static int ZEND_FASTCALL zend_fetch_property_address_read_helper_SPEC_VAR_TMP(ZE zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -15211,7 +17276,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR == IS_VAR && (opline->extended_value & ZEND_FETCH_ADD_LOCK)) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); @@ -15221,7 +17286,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND if (1) { MAKE_REAL_ZVAL_PTR(property); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } @@ -15260,8 +17325,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (1) { MAKE_REAL_ZVAL_PTR(property); @@ -15292,8 +17357,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -15329,15 +17394,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_TMP_HANDLER(ZEND_OPCO { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1, free_op2; zval *property; zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (1) { MAKE_REAL_ZVAL_PTR(property); @@ -15370,8 +17435,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_ zval *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -15413,8 +17478,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDL zval *property_name; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (1) { MAKE_REAL_ZVAL_PTR(property_name); @@ -15422,7 +17487,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDL if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_TMP_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_TMP_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (1) { zval_ptr_dtor(&property_name); } else { @@ -15442,19 +17507,19 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDL zval **object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } if (Z_TYPE_PP(object_ptr) == IS_OBJECT) { zend_free_op free_op2; - zval *property_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (1) { MAKE_REAL_ZVAL_PTR(property_name); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((IS_TMP_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_TMP_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (1) { zval_ptr_dtor(&property_name); } else { @@ -15463,14 +17528,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDL } else { zend_free_op free_op2, free_op_data1, free_op_data2; zval *value; - zval *dim = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zval **variable_ptr_ptr; zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, IS_TMP_VAR, BP_VAR_W TSRMLS_CC); zval_dtor(free_op2.var); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); if (UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) { if (RETURN_VALUE_USED(opline)) { @@ -15524,8 +17589,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_A zval **variable_ptr_ptr; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T(opline->op1.var), value, IS_TMP_VAR TSRMLS_CC)) { @@ -15578,11 +17643,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE char *function_name_strval; int function_name_strlen; zend_free_op free_op1, free_op2; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -15592,49 +17657,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + call->object = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_TMP_VAR != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_TMP_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + zval_dtor(free_op2.var); + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; zval_dtor(free_op2.var); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -15648,9 +17719,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND USE_OPLINE zval *function_name; zend_class_entry *ce; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_VAR == IS_CONST) { /* no function found. try a static method in class */ @@ -15664,24 +17735,24 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND } CACHE_PTR(opline->op1.literal->cache_slot, ce); } - EX(called_scope) = ce; + call->called_scope = ce; } else { ce = EX_T(opline->op1.var).class_entry; if (opline->extended_value == ZEND_FETCH_CLASS_PARENT || opline->extended_value == ZEND_FETCH_CLASS_SELF) { - EX(called_scope) = EG(called_scope); + call->called_scope = EG(called_scope); } else { - EX(called_scope) = ce; + call->called_scope = ce; } } if (IS_VAR == IS_CONST && IS_TMP_VAR == IS_CONST && CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); } else if (IS_VAR != IS_CONST && IS_TMP_VAR == IS_CONST && - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { /* do nothing */ } else if (IS_TMP_VAR != IS_UNUSED) { char *function_name_strval = NULL; @@ -15692,7 +17763,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND function_name_strval = Z_STRVAL_P(opline->op2.zv); function_name_strlen = Z_STRLEN_P(opline->op2.zv); } else { - function_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { zend_error_noreturn(E_ERROR, "Function name must be a string"); @@ -15704,20 +17775,20 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND if (function_name_strval) { if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + call->fbc = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, function_name_strval); } if (IS_TMP_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { if (IS_VAR == IS_CONST) { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } else { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, EX(fbc)); + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, call->fbc); } } } @@ -15731,29 +17802,31 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND if (EG(This) && Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name); } - EX(fbc) = ce->constructor; + call->fbc = ce->constructor; } - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; + if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { + call->object = NULL; } else { if (EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + if (call->fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } } - if ((EX(object) = EG(This))) { - Z_ADDREF_P(EX(object)); - EX(called_scope) = Z_OBJCE_P(EX(object)); + if ((call->object = EG(This))) { + Z_ADDREF_P(call->object); + call->called_scope = Z_OBJCE_P(call->object); } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -15769,8 +17842,8 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -15785,7 +17858,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCOD SAVE_OPLINE(); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) { - zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); @@ -15794,7 +17867,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCOD expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr_ptr=_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { /* temporary variable */ zval *new_expr; @@ -15815,7 +17888,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCOD if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -15886,11 +17959,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_CV && container != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(container); } - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR != IS_VAR || container) { switch (Z_TYPE_PP(container)) { @@ -15985,8 +18058,8 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR != IS_VAR || container) { if (IS_VAR == IS_CV && container != &EG(uninitialized_zval_ptr)) { @@ -16029,9 +18102,9 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_TMP(in zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; @@ -16172,6 +18245,161 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_ return zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_TMP(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_VAR != IS_UNUSED) { + zend_free_op free_op1; + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_VAR == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + } else { + zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_TMP_VAR != IS_UNUSED) { + zend_free_op free_op2; + zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -16179,8 +18407,8 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16194,8 +18422,8 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16209,8 +18437,8 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16224,8 +18452,8 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16239,8 +18467,8 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16254,8 +18482,8 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16269,8 +18497,8 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16284,8 +18512,8 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16299,8 +18527,8 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16315,8 +18543,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; @@ -16332,8 +18560,8 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16348,8 +18576,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16364,8 +18592,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16380,8 +18608,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_VAR_VAR_HANDLER(ZEND_OPC SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16395,8 +18623,8 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16410,8 +18638,8 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16425,8 +18653,8 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16440,8 +18668,8 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -16452,10 +18680,10 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_VAR(int (*bin { USE_OPLINE zend_free_op free_op1, free_op2, free_op_data1; - zval **object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); zval *object; - zval *property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -16573,7 +18801,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_VAR(int (*binary_ return zend_binary_assign_op_obj_helper_SPEC_VAR_VAR(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); break; case ZEND_ASSIGN_DIM: { - zval **container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -16583,17 +18811,17 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_VAR(int (*binary_ } return zend_binary_assign_op_obj_helper_SPEC_VAR_VAR(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_VAR, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: - value = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); /* do nothing */ break; } @@ -16716,8 +18944,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_VAR(incdec_t i int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).var.ptr; if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -16820,8 +19048,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_VAR(incdec_t int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).tmp_var; if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -16922,7 +19150,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE ulong hash_value; SAVE_OPLINE(); - varname = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { ZVAL_COPY_VALUE(&tmp_varname, varname); @@ -17062,7 +19290,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_H { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_VAR_VAR(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_VAR_VAR(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -17088,10 +19316,19 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND EX_T(opline->op1.var).var.ptr_ptr) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); - if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; - if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + + if (IS_VAR == IS_TMP_VAR || IS_VAR == IS_CONST) { + zval *container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } else { + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -17103,12 +19340,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_W TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -17137,12 +19374,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_RW TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_RW TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -17159,8 +19396,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_IS TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_IS TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -17175,12 +19412,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_VAR_HANDLER(ZEND_OPCO SAVE_OPLINE(); - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); } @@ -17188,8 +19425,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_VAR_HANDLER(ZEND_OPCO if (IS_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); } if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -17204,7 +19441,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_ zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -17214,7 +19451,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_ if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_UNSET TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_UNSET TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -17222,6 +19459,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_ if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (UNEXPECTED(EX_T(opline->result.var).var.ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); + ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_res; zval **retval_ptr = EX_T(opline->result.var).var.ptr_ptr; @@ -17246,8 +19484,8 @@ static int ZEND_FASTCALL zend_fetch_property_address_read_helper_SPEC_VAR_VAR(ZE zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -17293,7 +19531,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR == IS_VAR && (opline->extended_value & ZEND_FETCH_ADD_LOCK)) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); @@ -17303,7 +19541,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND if (0) { MAKE_REAL_ZVAL_PTR(property); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } @@ -17342,8 +19580,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -17374,8 +19612,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -17411,15 +19649,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_VAR_HANDLER(ZEND_OPCO { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1, free_op2; zval *property; zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -17452,8 +19690,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_ zval *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -17495,8 +19733,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL zval *property_name; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property_name); @@ -17504,7 +19742,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -17524,19 +19762,19 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL zval **object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } if (Z_TYPE_PP(object_ptr) == IS_OBJECT) { zend_free_op free_op2; - zval *property_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property_name); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((IS_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -17545,14 +19783,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL } else { zend_free_op free_op2, free_op_data1, free_op_data2; zval *value; - zval *dim = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zval **variable_ptr_ptr; zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, IS_VAR, BP_VAR_W TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); if (UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) { if (RETURN_VALUE_USED(opline)) { @@ -17606,8 +19844,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_A zval **variable_ptr_ptr; SAVE_OPLINE(); - value = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T(opline->op1.var), value, IS_VAR TSRMLS_CC)) { @@ -17662,7 +19900,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL zval **value_ptr_ptr; SAVE_OPLINE(); - value_ptr_ptr = _get_zval_ptr_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + value_ptr_ptr = _get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR == IS_VAR && value_ptr_ptr && @@ -17685,7 +19923,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL zend_error_noreturn(E_ERROR, "Cannot assign by reference to overloaded object"); } - variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if ((IS_VAR == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) || (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); @@ -17715,11 +19953,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE char *function_name_strval; int function_name_strlen; zend_free_op free_op1, free_op2; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -17729,49 +19967,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + call->object = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_VAR != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -17785,9 +20029,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND USE_OPLINE zval *function_name; zend_class_entry *ce; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_VAR == IS_CONST) { /* no function found. try a static method in class */ @@ -17801,24 +20045,24 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND } CACHE_PTR(opline->op1.literal->cache_slot, ce); } - EX(called_scope) = ce; + call->called_scope = ce; } else { ce = EX_T(opline->op1.var).class_entry; if (opline->extended_value == ZEND_FETCH_CLASS_PARENT || opline->extended_value == ZEND_FETCH_CLASS_SELF) { - EX(called_scope) = EG(called_scope); + call->called_scope = EG(called_scope); } else { - EX(called_scope) = ce; + call->called_scope = ce; } } if (IS_VAR == IS_CONST && IS_VAR == IS_CONST && CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); } else if (IS_VAR != IS_CONST && IS_VAR == IS_CONST && - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { /* do nothing */ } else if (IS_VAR != IS_UNUSED) { char *function_name_strval = NULL; @@ -17829,7 +20073,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND function_name_strval = Z_STRVAL_P(opline->op2.zv); function_name_strlen = Z_STRLEN_P(opline->op2.zv); } else { - function_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { zend_error_noreturn(E_ERROR, "Function name must be a string"); @@ -17841,20 +20085,20 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND if (function_name_strval) { if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + call->fbc = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, function_name_strval); } if (IS_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { if (IS_VAR == IS_CONST) { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } else { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, EX(fbc)); + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, call->fbc); } } } @@ -17868,29 +20112,31 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND if (EG(This) && Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name); } - EX(fbc) = ce->constructor; + call->fbc = ce->constructor; } - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; + if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { + call->object = NULL; } else { if (EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + if (call->fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } } - if ((EX(object) = EG(This))) { - Z_ADDREF_P(EX(object)); - EX(called_scope) = Z_OBJCE_P(EX(object)); + if ((call->object = EG(This))) { + Z_ADDREF_P(call->object); + call->called_scope = Z_OBJCE_P(call->object); } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -17906,8 +20152,8 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -17922,7 +20168,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCOD SAVE_OPLINE(); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) { - zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); @@ -17931,7 +20177,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCOD expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr_ptr=_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { /* temporary variable */ zval *new_expr; @@ -17952,7 +20198,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCOD if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -18038,7 +20284,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -18099,11 +20345,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_CV && container != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(container); } - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR != IS_VAR || container) { switch (Z_TYPE_PP(container)) { @@ -18198,8 +20444,8 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR != IS_VAR || container) { if (IS_VAR == IS_CV && container != &EG(uninitialized_zval_ptr)) { @@ -18255,7 +20501,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_VAR_VAR_HANDLER(ZEND_OPCOD } else { HashTable *target_symbol_table; zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -18327,9 +20573,9 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_VAR(in zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; @@ -18470,14 +20716,170 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_ return zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_VAR(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_VAR != IS_UNUSED) { + zend_free_op free_op1; + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_VAR == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + } else { + zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_VAR != IS_UNUSED) { + zend_free_op free_op2; + zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_UNUSED(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE zend_free_op free_op1, free_op_data1; - zval **object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); zval *object; zval *property = NULL; - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -18595,7 +20997,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_UNUSED(int (*bina return zend_binary_assign_op_obj_helper_SPEC_VAR_UNUSED(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); break; case ZEND_ASSIGN_DIM: { - zval **container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -18608,14 +21010,14 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_UNUSED(int (*bina zval *dim = NULL; zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_UNUSED, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: value = NULL; - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); /* do nothing */ break; } @@ -18737,7 +21139,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type, ulong hash_value; SAVE_OPLINE(); - varname = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { ZVAL_COPY_VALUE(&tmp_varname, varname); @@ -18877,7 +21279,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCOD { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_VAR_UNUSED(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_VAR_UNUSED(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -18897,7 +21299,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_H zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -18931,7 +21333,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_ zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -18954,8 +21356,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_UNUSED_HANDLER(ZEND_O SAVE_OPLINE(); - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -18967,7 +21369,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_UNUSED_HANDLER(ZEND_O if (IS_UNUSED == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, NULL, IS_UNUSED, BP_VAR_R TSRMLS_CC); } @@ -18983,7 +21385,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HA zval **object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -18995,7 +21397,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HA if (0) { MAKE_REAL_ZVAL_PTR(property_name); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((IS_UNUSED == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_UNUSED == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -19009,8 +21411,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HA zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, IS_UNUSED, BP_VAR_W TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); if (UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) { if (RETURN_VALUE_USED(opline)) { @@ -19061,9 +21463,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(Z USE_OPLINE zval *function_name; zend_class_entry *ce; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_VAR == IS_CONST) { /* no function found. try a static method in class */ @@ -19077,24 +21479,24 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(Z } CACHE_PTR(opline->op1.literal->cache_slot, ce); } - EX(called_scope) = ce; + call->called_scope = ce; } else { ce = EX_T(opline->op1.var).class_entry; if (opline->extended_value == ZEND_FETCH_CLASS_PARENT || opline->extended_value == ZEND_FETCH_CLASS_SELF) { - EX(called_scope) = EG(called_scope); + call->called_scope = EG(called_scope); } else { - EX(called_scope) = ce; + call->called_scope = ce; } } if (IS_VAR == IS_CONST && IS_UNUSED == IS_CONST && CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); } else if (IS_VAR != IS_CONST && IS_UNUSED == IS_CONST && - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { /* do nothing */ } else if (IS_UNUSED != IS_UNUSED) { char *function_name_strval = NULL; @@ -19117,20 +21519,20 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(Z if (function_name_strval) { if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + call->fbc = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_UNUSED == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_UNUSED == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, function_name_strval); } if (IS_UNUSED == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { if (IS_VAR == IS_CONST) { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } else { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, EX(fbc)); + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, call->fbc); } } } @@ -19144,29 +21546,31 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(Z if (EG(This) && Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name); } - EX(fbc) = ce->constructor; + call->fbc = ce->constructor; } - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; + if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { + call->object = NULL; } else { if (EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + if (call->fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } } - if ((EX(object) = EG(This))) { - Z_ADDREF_P(EX(object)); - EX(called_scope) = Z_OBJCE_P(EX(object)); + if ((call->object = EG(This))) { + Z_ADDREF_P(call->object); + call->called_scope = Z_OBJCE_P(call->object); } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -19180,7 +21584,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_HANDLER(ZEND_OP SAVE_OPLINE(); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) { - zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); @@ -19189,7 +21593,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_HANDLER(ZEND_OP expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr_ptr=_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { /* temporary variable */ zval *new_expr; @@ -19296,7 +21700,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HAN ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -19372,7 +21776,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_VAR_UNUSED_HANDLER(ZEND_OP } else { HashTable *target_symbol_table; zend_free_op free_op1; - zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -19441,8 +21845,8 @@ static int ZEND_FASTCALL ZEND_SEPARATE_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); var_ptr = EX_T(opline->op1.var).var.ptr; if (Z_TYPE_P(var_ptr) != IS_OBJECT && - !PZVAL_IS_REF(var_ptr) && - Z_REFCOUNT_P(var_ptr) > 1) { + !PZVAL_IS_REF(var_ptr) && + Z_REFCOUNT_P(var_ptr) > 1) { Z_DELREF_P(var_ptr); ALLOC_ZVAL(new_zv); @@ -19454,6 +21858,161 @@ static int ZEND_FASTCALL ZEND_SEPARATE_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HAND ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_VAR != IS_UNUSED) { + zend_free_op free_op1; + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_VAR == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + } else { + zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_UNUSED != IS_UNUSED) { + + zval *key = NULL; + + /* Consts, temporary variables and references need copying */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -19461,8 +22020,8 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19476,8 +22035,8 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19491,8 +22050,8 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19506,8 +22065,8 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19521,8 +22080,8 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19536,8 +22095,8 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19551,8 +22110,8 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19566,8 +22125,8 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19581,8 +22140,8 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19597,8 +22156,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -19614,8 +22173,8 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19630,8 +22189,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19646,8 +22205,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19662,8 +22221,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_VAR_CV_HANDLER(ZEND_OPCO SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19677,8 +22236,8 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19692,8 +22251,8 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19707,8 +22266,8 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19722,8 +22281,8 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -19734,10 +22293,10 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_VAR_CV(int (*bina { USE_OPLINE zend_free_op free_op1, free_op_data1; - zval **object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); zval *object; - zval *property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -19855,7 +22414,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_CV(int (*binary_o return zend_binary_assign_op_obj_helper_SPEC_VAR_CV(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); break; case ZEND_ASSIGN_DIM: { - zval **container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -19865,17 +22424,17 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_VAR_CV(int (*binary_o } return zend_binary_assign_op_obj_helper_SPEC_VAR_CV(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_CV, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: - value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); /* do nothing */ break; } @@ -19997,8 +22556,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_VAR_CV(incdec_t in int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); retval = &EX_T(opline->result.var).var.ptr; if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -20101,8 +22660,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_VAR_CV(incdec_t i int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); retval = &EX_T(opline->result.var).tmp_var; if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -20205,10 +22764,19 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL EX_T(opline->op1.var).var.ptr_ptr) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); - if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + if (IS_VAR == IS_TMP_VAR || IS_VAR == IS_CONST) { + zval *container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } else { + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@ -20220,12 +22788,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -20254,12 +22822,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_RW TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_RW TSRMLS_CC); if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -20276,8 +22844,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_IS TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_IS TSRMLS_CC); if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; CHECK_EXCEPTION(); @@ -20292,12 +22860,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_CV_HANDLER(ZEND_OPCOD SAVE_OPLINE(); - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); } @@ -20305,8 +22873,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_CV_HANDLER(ZEND_OPCOD if (IS_CV == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); } if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -20321,7 +22889,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_H zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -20331,7 +22899,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_H if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_UNSET TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_UNSET TSRMLS_CC); if (IS_VAR == IS_VAR && (free_op1.var != NULL) && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -20339,6 +22907,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_H if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; if (UNEXPECTED(EX_T(opline->result.var).var.ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); + ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_res; zval **retval_ptr = EX_T(opline->result.var).var.ptr_ptr; @@ -20363,8 +22932,8 @@ static int ZEND_FASTCALL zend_fetch_property_address_read_helper_SPEC_VAR_CV(ZEN zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -20410,7 +22979,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_VAR == IS_VAR && (opline->extended_value & ZEND_FETCH_ADD_LOCK)) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); @@ -20420,7 +22989,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL if (0) { MAKE_REAL_ZVAL_PTR(property); } - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } @@ -20459,8 +23028,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -20491,8 +23060,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -20528,15 +23097,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_CV_HANDLER(ZEND_OPCOD { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1; zval *property; zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -20569,8 +23138,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_H zval *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_VAR == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -20612,8 +23181,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE zval *property_name; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - property_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + property_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property_name); @@ -20621,7 +23190,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -20641,19 +23210,19 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE zval **object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } if (Z_TYPE_PP(object_ptr) == IS_OBJECT) { - zval *property_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *property_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property_name); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -20662,13 +23231,13 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE } else { zend_free_op free_op_data1, free_op_data2; zval *value; - zval *dim = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); zval **variable_ptr_ptr; zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, IS_CV, BP_VAR_W TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); if (UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) { if (RETURN_VALUE_USED(opline)) { @@ -20722,8 +23291,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_AR zval **variable_ptr_ptr; SAVE_OPLINE(); - value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); - variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T(opline->op1.var), value, IS_CV TSRMLS_CC)) { @@ -20777,7 +23346,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE zval **value_ptr_ptr; SAVE_OPLINE(); - value_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op2.var TSRMLS_CC); + value_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op2.var TSRMLS_CC); if (IS_CV == IS_VAR && value_ptr_ptr && @@ -20800,7 +23369,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE zend_error_noreturn(E_ERROR, "Cannot assign by reference to overloaded object"); } - variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if ((IS_CV == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) || (IS_VAR == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); @@ -20829,11 +23398,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_ char *function_name_strval; int function_name_strlen; zend_free_op free_op1; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + function_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_CV != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -20843,49 +23412,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_ function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + call->object = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_CV != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_CV == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -20898,9 +23473,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_ USE_OPLINE zval *function_name; zend_class_entry *ce; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); if (IS_VAR == IS_CONST) { /* no function found. try a static method in class */ @@ -20914,24 +23489,24 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_ } CACHE_PTR(opline->op1.literal->cache_slot, ce); } - EX(called_scope) = ce; + call->called_scope = ce; } else { ce = EX_T(opline->op1.var).class_entry; if (opline->extended_value == ZEND_FETCH_CLASS_PARENT || opline->extended_value == ZEND_FETCH_CLASS_SELF) { - EX(called_scope) = EG(called_scope); + call->called_scope = EG(called_scope); } else { - EX(called_scope) = ce; + call->called_scope = ce; } } if (IS_VAR == IS_CONST && IS_CV == IS_CONST && CACHED_PTR(opline->op2.literal->cache_slot)) { - EX(fbc) = CACHED_PTR(opline->op2.literal->cache_slot); + call->fbc = CACHED_PTR(opline->op2.literal->cache_slot); } else if (IS_VAR != IS_CONST && IS_CV == IS_CONST && - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce))) { /* do nothing */ } else if (IS_CV != IS_UNUSED) { char *function_name_strval = NULL; @@ -20942,7 +23517,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_ function_name_strval = Z_STRVAL_P(opline->op2.zv); function_name_strlen = Z_STRLEN_P(opline->op2.zv); } else { - function_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + function_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { zend_error_noreturn(E_ERROR, "Function name must be a string"); @@ -20954,20 +23529,20 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_ if (function_name_strval) { if (ce->get_static_method) { - EX(fbc) = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); + call->fbc = ce->get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); } else { - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = zend_std_get_static_method(ce, function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); } - if (UNEXPECTED(EX(fbc) == NULL)) { + if (UNEXPECTED(call->fbc == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name, function_name_strval); } if (IS_CV == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) { if (IS_VAR == IS_CONST) { - CACHE_PTR(opline->op2.literal->cache_slot, EX(fbc)); + CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } else { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, EX(fbc)); + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, ce, call->fbc); } } } @@ -20981,29 +23556,31 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_ if (EG(This) && Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name); } - EX(fbc) = ce->constructor; + call->fbc = ce->constructor; } - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; + if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { + call->object = NULL; } else { if (EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + if (call->fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ - zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name, call->fbc->common.function_name); } } - if ((EX(object) = EG(This))) { - Z_ADDREF_P(EX(object)); - EX(called_scope) = Z_OBJCE_P(EX(object)); + if ((call->object = EG(This))) { + Z_ADDREF_P(call->object); + call->called_scope = Z_OBJCE_P(call->object); } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -21019,8 +23596,8 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -21034,7 +23611,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE SAVE_OPLINE(); if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) { - zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + zval **expr_ptr_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); @@ -21043,7 +23620,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + expr_ptr=_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (0) { /* temporary variable */ zval *new_expr; @@ -21064,7 +23641,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE if (IS_CV != IS_UNUSED) { - zval *offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -21135,11 +23712,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (IS_VAR == IS_CV && container != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(container); } - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_VAR != IS_VAR || container) { switch (Z_TYPE_PP(container)) { @@ -21234,8 +23811,8 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_VAR != IS_VAR || container) { if (IS_VAR == IS_CV && container != &EG(uninitialized_zval_ptr)) { @@ -21278,9 +23855,9 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_CV(int zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC); + container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; @@ -21421,6 +23998,161 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_VAR_CV_HANDLER(ZEND_O return zend_isset_isempty_dim_prop_obj_handler_SPEC_VAR_CV(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_VAR != IS_UNUSED) { + zend_free_op free_op1; + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + if (IS_VAR == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_VAR == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + } else { + zval *value = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_CV != IS_UNUSED) { + + zval *key = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -21513,7 +24245,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_CONST(int zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); zval *object; zval *property = opline->op2.zv; - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -21643,8 +24375,8 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_CONST(int (*bi zval *dim = opline->op2.zv; zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_CONST, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; @@ -22138,7 +24870,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_CONST_HANDLER(ZEND { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1; zval *property; @@ -22230,7 +24962,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_ if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_CONST == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_CONST == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -22296,9 +25028,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CONST_HANDLER(ZEND_O char *function_name_strval; int function_name_strlen; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); function_name = opline->op2.zv; @@ -22310,49 +25042,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CONST_HANDLER(ZEND_O function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_obj_zval_ptr_unused(TSRMLS_C); + call->object = _get_obj_zval_ptr_unused(TSRMLS_C); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_CONST != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_CONST == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); @@ -22442,6 +25180,9 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC } ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, *value); zval_copy_ctor(&EX_T(opline->result.var).tmp_var); + } else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && strcmp(Z_STRVAL_P(opline->op2.zv), "class") == 0) { + /* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */ + ZVAL_STRINGL(&EX_T(opline->result.var).tmp_var, ce->name, ce->name_length, 1); } else { zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv)); } @@ -22756,14 +25497,167 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UNUSED_CONST_HANDLER( return zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_CONST(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_UNUSED != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = NULL; + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_UNUSED == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_UNUSED == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = NULL; + + /* Consts, temporary variables and references need copying */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_CONST != IS_UNUSED) { + + zval *key = opline->op2.zv; + + /* Consts, temporary variables and references need copying */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_TMP(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE zend_free_op free_op2, free_op_data1; zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); zval *object; - zval *property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -22890,16 +25784,16 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_TMP(int (*bina } return zend_binary_assign_op_obj_helper_SPEC_UNUSED_TMP(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_TMP_VAR, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: - value = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); var_ptr = NULL; /* do nothing */ break; @@ -23024,7 +25918,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_UNUSED_TMP(incdec_ SAVE_OPLINE(); object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).var.ptr; if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -23128,7 +26022,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_UNUSED_TMP(incdec SAVE_OPLINE(); object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).tmp_var; if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -23228,7 +26122,7 @@ static int ZEND_FASTCALL zend_fetch_property_address_read_helper_SPEC_UNUSED_TMP SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -23273,7 +26167,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_H zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_UNUSED == IS_VAR && (opline->extended_value & ZEND_FETCH_ADD_LOCK)) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); @@ -23321,7 +26215,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); if (1) { @@ -23354,7 +26248,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -23389,14 +26283,14 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_TMP_HANDLER(ZEND_O { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1, free_op2; zval *property; zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); if (1) { @@ -23431,7 +26325,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCO SAVE_OPLINE(); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_UNUSED == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -23473,7 +26367,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (1) { MAKE_REAL_ZVAL_PTR(property_name); @@ -23481,7 +26375,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HA if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_TMP_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_TMP_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (1) { zval_ptr_dtor(&property_name); } else { @@ -23504,7 +26398,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDL int use_copy = 0; SAVE_OPLINE(); - var = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + var = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_UNUSED == IS_UNUSED) { /* Initialize for erealloc in add_string_to_string */ @@ -23546,11 +26440,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_TMP_HANDLER(ZEND_OPC char *function_name_strval; int function_name_strlen; zend_free_op free_op2; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -23560,49 +26454,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_TMP_HANDLER(ZEND_OPC function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_obj_zval_ptr_unused(TSRMLS_C); + call->object = _get_obj_zval_ptr_unused(TSRMLS_C); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_TMP_VAR != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_TMP_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + zval_dtor(free_op2.var); + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; zval_dtor(free_op2.var); @@ -23637,7 +26537,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN if (IS_UNUSED == IS_CV && container != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(container); } - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_UNUSED != IS_VAR || container) { switch (Z_TYPE_PP(container)) { @@ -23732,7 +26632,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_UNUSED != IS_VAR || container) { if (IS_UNUSED == IS_CV && container != &EG(uninitialized_zval_ptr)) { @@ -23776,7 +26676,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_TMP SAVE_OPLINE(); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; @@ -23915,14 +26815,167 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UNUSED_TMP_HANDLER(ZE return zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_TMP(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_UNUSED != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = NULL; + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_UNUSED == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_UNUSED == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = NULL; + + /* Consts, temporary variables and references need copying */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_TMP_VAR != IS_UNUSED) { + zend_free_op free_op2; + zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_VAR(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE zend_free_op free_op2, free_op_data1; zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); zval *object; - zval *property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -24049,16 +27102,16 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_VAR(int (*bina } return zend_binary_assign_op_obj_helper_SPEC_UNUSED_VAR(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_VAR, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: - value = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + value = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); var_ptr = NULL; /* do nothing */ break; @@ -24183,7 +27236,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_UNUSED_VAR(incdec_ SAVE_OPLINE(); object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).var.ptr; if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -24287,7 +27340,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_UNUSED_VAR(incdec SAVE_OPLINE(); object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).tmp_var; if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -24387,7 +27440,7 @@ static int ZEND_FASTCALL zend_fetch_property_address_read_helper_SPEC_UNUSED_VAR SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -24432,7 +27485,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_H zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_UNUSED == IS_VAR && (opline->extended_value & ZEND_FETCH_ADD_LOCK)) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); @@ -24480,7 +27533,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); if (0) { @@ -24513,7 +27566,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -24548,14 +27601,14 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_VAR_HANDLER(ZEND_O { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1, free_op2; zval *property; zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); if (0) { @@ -24590,7 +27643,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCO SAVE_OPLINE(); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_UNUSED == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -24632,7 +27685,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property_name); @@ -24640,7 +27693,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HA if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -24663,7 +27716,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDL int use_copy = 0; SAVE_OPLINE(); - var = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + var = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_UNUSED == IS_UNUSED) { /* Initialize for erealloc in add_string_to_string */ @@ -24705,11 +27758,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_VAR_HANDLER(ZEND_OPC char *function_name_strval; int function_name_strlen; zend_free_op free_op2; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -24719,49 +27772,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_VAR_HANDLER(ZEND_OPC function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_obj_zval_ptr_unused(TSRMLS_C); + call->object = _get_obj_zval_ptr_unused(TSRMLS_C); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_VAR != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; @@ -24796,7 +27855,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN if (IS_UNUSED == IS_CV && container != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(container); } - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_UNUSED != IS_VAR || container) { switch (Z_TYPE_PP(container)) { @@ -24891,7 +27950,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_UNUSED != IS_VAR || container) { if (IS_UNUSED == IS_CV && container != &EG(uninitialized_zval_ptr)) { @@ -24935,7 +27994,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_VAR SAVE_OPLINE(); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; @@ -25074,283 +28133,168 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UNUSED_VAR_HANDLER(ZE return zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_VAR(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } -static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_UNUSED(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) +static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE - zend_free_op free_op_data1; - zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - zval *object; - zval *property = NULL; - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - int have_get_ptr = 0; - if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { - zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); } - make_real_object(object_ptr TSRMLS_CC); - object = *object_ptr; + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } - if (UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { - zend_error(E_WARNING, "Attempt to assign property of non-object"); + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } - FREE_OP(free_op_data1); + /* Set the new yielded value */ + if (IS_UNUSED != IS_UNUSED) { - if (RETURN_VALUE_USED(opline)) { - PZVAL_LOCK(&EG(uninitialized_zval)); - EX_T(opline->result.var).var.ptr = &EG(uninitialized_zval); - EX_T(opline->result.var).var.ptr_ptr = NULL; - } - } else { - /* here we are sure we are dealing with an object */ - if (0) { - MAKE_REAL_ZVAL_PTR(property); - } - /* here property is a string */ - if (opline->extended_value == ZEND_ASSIGN_OBJ - && Z_OBJ_HT_P(object)->get_property_ptr_ptr) { - zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, ((IS_UNUSED == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); - if (zptr != NULL) { /* NULL means no success in getting PTR */ - SEPARATE_ZVAL_IF_NOT_REF(zptr); + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR) { + zval *value, *copy; - have_get_ptr = 1; - binary_op(*zptr, *zptr, value TSRMLS_CC); - if (RETURN_VALUE_USED(opline)) { - PZVAL_LOCK(*zptr); - EX_T(opline->result.var).var.ptr = *zptr; - EX_T(opline->result.var).var.ptr_ptr = NULL; - } - } - } + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - if (!have_get_ptr) { - zval *z = NULL; + value = NULL; + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); - if (opline->extended_value == ZEND_ASSIGN_OBJ) { - if (Z_OBJ_HT_P(object)->read_property) { - z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_R, ((IS_UNUSED == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); - } - } else /* if (opline->extended_value == ZEND_ASSIGN_DIM) */ { - if (Z_OBJ_HT_P(object)->read_dimension) { - z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_R TSRMLS_CC); + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); } - } - if (z) { - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { - zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - if (Z_REFCOUNT_P(z) == 0) { - GC_REMOVE_ZVAL_FROM_BUFFER(z); - zval_dtor(z); - FREE_ZVAL(z); - } - z = value; - } - Z_ADDREF_P(z); - SEPARATE_ZVAL_IF_NOT_REF(&z); - binary_op(z, z, value TSRMLS_CC); - if (opline->extended_value == ZEND_ASSIGN_OBJ) { - Z_OBJ_HT_P(object)->write_property(object, property, z, ((IS_UNUSED == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); - } else /* if (opline->extended_value == ZEND_ASSIGN_DIM) */ { - Z_OBJ_HT_P(object)->write_dimension(object, property, z TSRMLS_CC); - } - if (RETURN_VALUE_USED(opline)) { - PZVAL_LOCK(z); - EX_T(opline->result.var).var.ptr = z; - EX_T(opline->result.var).var.ptr_ptr = NULL; - } - zval_ptr_dtor(&z); + generator->value = copy; } else { - zend_error(E_WARNING, "Attempt to assign property of non-object"); - if (RETURN_VALUE_USED(opline)) { - PZVAL_LOCK(&EG(uninitialized_zval)); - EX_T(opline->result.var).var.ptr = &EG(uninitialized_zval); - EX_T(opline->result.var).var.ptr_ptr = NULL; - } - } - } - - if (0) { - zval_ptr_dtor(&property); - } else { - - } - FREE_OP(free_op_data1); - } - - /* assign_obj has two opcodes! */ - CHECK_EXCEPTION(); - ZEND_VM_INC_OPCODE(); - ZEND_VM_NEXT_OPCODE(); -} + zval **value_ptr = NULL; -static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) -{ - USE_OPLINE - zend_free_op free_op_data2, free_op_data1; - zval **var_ptr; - zval *value; + if (IS_UNUSED == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } - SAVE_OPLINE(); - switch (opline->extended_value) { - case ZEND_ASSIGN_OBJ: - return zend_binary_assign_op_obj_helper_SPEC_UNUSED_UNUSED(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - break; - case ZEND_ASSIGN_DIM: { - zval **container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_UNUSED == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); - if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { - zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); - } else if (UNEXPECTED(Z_TYPE_PP(container) == IS_OBJECT)) { - if (IS_UNUSED == IS_VAR && !0) { - Z_ADDREF_PP(container); /* undo the effect of get_obj_zval_ptr_ptr() */ - } - return zend_binary_assign_op_obj_helper_SPEC_UNUSED_UNUSED(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; } else { - zval *dim = NULL; - - zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_UNUSED, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; } - } - break; - default: - value = NULL; - var_ptr = NULL; - /* do nothing */ - break; - } - if (UNEXPECTED(var_ptr == NULL)) { - zend_error_noreturn(E_ERROR, "Cannot use assign-op operators with overloaded objects nor string offsets"); - } - - if (UNEXPECTED(*var_ptr == &EG(error_zval))) { - if (RETURN_VALUE_USED(opline)) { - PZVAL_LOCK(&EG(uninitialized_zval)); - AI_SET_PTR(&EX_T(opline->result.var), &EG(uninitialized_zval)); - } - - - CHECK_EXCEPTION(); - if (opline->extended_value == ZEND_ASSIGN_DIM) { - ZEND_VM_INC_OPCODE(); - } - ZEND_VM_NEXT_OPCODE(); - } + } + } else { + zval *value = NULL; - SEPARATE_ZVAL_IF_NOT_REF(var_ptr); + /* Consts, temporary variables and references need copying */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; - if (UNEXPECTED(Z_TYPE_PP(var_ptr) == IS_OBJECT) - && Z_OBJ_HANDLER_PP(var_ptr, get) - && Z_OBJ_HANDLER_PP(var_ptr, set)) { - /* proxy object */ - zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - Z_ADDREF_P(objval); - binary_op(objval, objval, value TSRMLS_CC); - Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); - zval_ptr_dtor(&objval); - } else { - binary_op(*var_ptr, *var_ptr, value TSRMLS_CC); - } + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); - if (RETURN_VALUE_USED(opline)) { - PZVAL_LOCK(*var_ptr); - AI_SET_PTR(&EX_T(opline->result.var), *var_ptr); - } + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } - if (opline->extended_value == ZEND_ASSIGN_DIM) { - FREE_OP(free_op_data1); - FREE_OP_VAR_PTR(free_op_data2); + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } - CHECK_EXCEPTION(); - ZEND_VM_INC_OPCODE(); + } } else { - - CHECK_EXCEPTION(); + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); } - ZEND_VM_NEXT_OPCODE(); -} -static int ZEND_FASTCALL ZEND_ASSIGN_ADD_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(add_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} + /* Set the new yielded key */ + if (IS_VAR != IS_UNUSED) { + zend_free_op free_op2; + zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); -static int ZEND_FASTCALL ZEND_ASSIGN_SUB_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(sub_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} + /* Consts, temporary variables and references need copying */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; -static int ZEND_FASTCALL ZEND_ASSIGN_MUL_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(mul_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); -static int ZEND_FASTCALL ZEND_ASSIGN_DIV_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(div_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } -static int ZEND_FASTCALL ZEND_ASSIGN_MOD_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(mod_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } -static int ZEND_FASTCALL ZEND_ASSIGN_SL_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(shift_left_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } -static int ZEND_FASTCALL ZEND_ASSIGN_SR_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(shift_right_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; -static int ZEND_FASTCALL ZEND_ASSIGN_CONCAT_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(concat_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } -static int ZEND_FASTCALL ZEND_ASSIGN_BW_OR_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(bitwise_or_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); -static int ZEND_FASTCALL ZEND_ASSIGN_BW_AND_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(bitwise_and_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); -static int ZEND_FASTCALL ZEND_ASSIGN_BW_XOR_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(bitwise_xor_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); -static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - USE_OPLINE + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); - array_init(&EX_T(opline->result.var).tmp_var); - if (IS_UNUSED == IS_UNUSED) { - ZEND_VM_NEXT_OPCODE(); -#if 0 || IS_UNUSED != IS_UNUSED - } else { - return ZEND_ADD_ARRAY_ELEMENT_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -#endif - } + ZEND_VM_RETURN(); } -static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) +static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_UNUSED(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE zend_free_op free_op_data1; zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); zval *object; - zval *property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *property = NULL; + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -25379,7 +28323,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(int (*b /* here property is a string */ if (opline->extended_value == ZEND_ASSIGN_OBJ && Z_OBJ_HT_P(object)->get_property_ptr_ptr) { - zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, ((IS_UNUSED == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (zptr != NULL) { /* NULL means no success in getting PTR */ SEPARATE_ZVAL_IF_NOT_REF(zptr); @@ -25398,7 +28342,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(int (*b if (opline->extended_value == ZEND_ASSIGN_OBJ) { if (Z_OBJ_HT_P(object)->read_property) { - z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_R, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_R, ((IS_UNUSED == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); } } else /* if (opline->extended_value == ZEND_ASSIGN_DIM) */ { if (Z_OBJ_HT_P(object)->read_dimension) { @@ -25420,7 +28364,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(int (*b SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); if (opline->extended_value == ZEND_ASSIGN_OBJ) { - Z_OBJ_HT_P(object)->write_property(object, property, z, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + Z_OBJ_HT_P(object)->write_property(object, property, z, ((IS_UNUSED == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); } else /* if (opline->extended_value == ZEND_ASSIGN_DIM) */ { Z_OBJ_HT_P(object)->write_dimension(object, property, z TSRMLS_CC); } @@ -25454,7 +28398,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(int (*b ZEND_VM_NEXT_OPCODE(); } -static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_CV(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) +static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE zend_free_op free_op_data2, free_op_data1; @@ -25464,7 +28408,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_CV(int (*binar SAVE_OPLINE(); switch (opline->extended_value) { case ZEND_ASSIGN_OBJ: - return zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_binary_assign_op_obj_helper_SPEC_UNUSED_UNUSED(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); break; case ZEND_ASSIGN_DIM: { zval **container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); @@ -25475,18 +28419,440 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_CV(int (*binar if (IS_UNUSED == IS_VAR && !0) { Z_ADDREF_PP(container); /* undo the effect of get_obj_zval_ptr_ptr() */ } - return zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_binary_assign_op_obj_helper_SPEC_UNUSED_UNUSED(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *dim = NULL; - zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_CV, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_UNUSED, BP_VAR_RW TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: - value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + value = NULL; + var_ptr = NULL; + /* do nothing */ + break; + } + + if (UNEXPECTED(var_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot use assign-op operators with overloaded objects nor string offsets"); + } + + if (UNEXPECTED(*var_ptr == &EG(error_zval))) { + if (RETURN_VALUE_USED(opline)) { + PZVAL_LOCK(&EG(uninitialized_zval)); + AI_SET_PTR(&EX_T(opline->result.var), &EG(uninitialized_zval)); + } + + + CHECK_EXCEPTION(); + if (opline->extended_value == ZEND_ASSIGN_DIM) { + ZEND_VM_INC_OPCODE(); + } + ZEND_VM_NEXT_OPCODE(); + } + + SEPARATE_ZVAL_IF_NOT_REF(var_ptr); + + if (UNEXPECTED(Z_TYPE_PP(var_ptr) == IS_OBJECT) + && Z_OBJ_HANDLER_PP(var_ptr, get) + && Z_OBJ_HANDLER_PP(var_ptr, set)) { + /* proxy object */ + zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); + Z_ADDREF_P(objval); + binary_op(objval, objval, value TSRMLS_CC); + Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); + zval_ptr_dtor(&objval); + } else { + binary_op(*var_ptr, *var_ptr, value TSRMLS_CC); + } + + if (RETURN_VALUE_USED(opline)) { + PZVAL_LOCK(*var_ptr); + AI_SET_PTR(&EX_T(opline->result.var), *var_ptr); + } + + if (opline->extended_value == ZEND_ASSIGN_DIM) { + FREE_OP(free_op_data1); + FREE_OP_VAR_PTR(free_op_data2); + + CHECK_EXCEPTION(); + ZEND_VM_INC_OPCODE(); + } else { + + CHECK_EXCEPTION(); + } + ZEND_VM_NEXT_OPCODE(); +} + +static int ZEND_FASTCALL ZEND_ASSIGN_ADD_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(add_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int ZEND_FASTCALL ZEND_ASSIGN_SUB_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(sub_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int ZEND_FASTCALL ZEND_ASSIGN_MUL_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(mul_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int ZEND_FASTCALL ZEND_ASSIGN_DIV_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(div_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int ZEND_FASTCALL ZEND_ASSIGN_MOD_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(mod_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int ZEND_FASTCALL ZEND_ASSIGN_SL_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(shift_left_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int ZEND_FASTCALL ZEND_ASSIGN_SR_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(shift_right_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int ZEND_FASTCALL ZEND_ASSIGN_CONCAT_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(concat_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int ZEND_FASTCALL ZEND_ASSIGN_BW_OR_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(bitwise_or_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int ZEND_FASTCALL ZEND_ASSIGN_BW_AND_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(bitwise_and_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int ZEND_FASTCALL ZEND_ASSIGN_BW_XOR_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + return zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(bitwise_xor_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + +static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + array_init(&EX_T(opline->result.var).tmp_var); + if (IS_UNUSED == IS_UNUSED) { + ZEND_VM_NEXT_OPCODE(); +#if 0 || IS_UNUSED != IS_UNUSED + } else { + return ZEND_ADD_ARRAY_ELEMENT_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +#endif + } +} + +static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_UNUSED != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = NULL; + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_UNUSED == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_UNUSED == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = NULL; + + /* Consts, temporary variables and references need copying */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_UNUSED != IS_UNUSED) { + + zval *key = NULL; + + /* Consts, temporary variables and references need copying */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + +static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + zend_free_op free_op_data1; + zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); + zval *object; + zval *property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + int have_get_ptr = 0; + + if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); + } + + make_real_object(object_ptr TSRMLS_CC); + object = *object_ptr; + + if (UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + zend_error(E_WARNING, "Attempt to assign property of non-object"); + + FREE_OP(free_op_data1); + + if (RETURN_VALUE_USED(opline)) { + PZVAL_LOCK(&EG(uninitialized_zval)); + EX_T(opline->result.var).var.ptr = &EG(uninitialized_zval); + EX_T(opline->result.var).var.ptr_ptr = NULL; + } + } else { + /* here we are sure we are dealing with an object */ + if (0) { + MAKE_REAL_ZVAL_PTR(property); + } + + /* here property is a string */ + if (opline->extended_value == ZEND_ASSIGN_OBJ + && Z_OBJ_HT_P(object)->get_property_ptr_ptr) { + zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + if (zptr != NULL) { /* NULL means no success in getting PTR */ + SEPARATE_ZVAL_IF_NOT_REF(zptr); + + have_get_ptr = 1; + binary_op(*zptr, *zptr, value TSRMLS_CC); + if (RETURN_VALUE_USED(opline)) { + PZVAL_LOCK(*zptr); + EX_T(opline->result.var).var.ptr = *zptr; + EX_T(opline->result.var).var.ptr_ptr = NULL; + } + } + } + + if (!have_get_ptr) { + zval *z = NULL; + + if (opline->extended_value == ZEND_ASSIGN_OBJ) { + if (Z_OBJ_HT_P(object)->read_property) { + z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_R, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + } + } else /* if (opline->extended_value == ZEND_ASSIGN_DIM) */ { + if (Z_OBJ_HT_P(object)->read_dimension) { + z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_R TSRMLS_CC); + } + } + if (z) { + if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { + zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); + + if (Z_REFCOUNT_P(z) == 0) { + GC_REMOVE_ZVAL_FROM_BUFFER(z); + zval_dtor(z); + FREE_ZVAL(z); + } + z = value; + } + Z_ADDREF_P(z); + SEPARATE_ZVAL_IF_NOT_REF(&z); + binary_op(z, z, value TSRMLS_CC); + if (opline->extended_value == ZEND_ASSIGN_OBJ) { + Z_OBJ_HT_P(object)->write_property(object, property, z, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + } else /* if (opline->extended_value == ZEND_ASSIGN_DIM) */ { + Z_OBJ_HT_P(object)->write_dimension(object, property, z TSRMLS_CC); + } + if (RETURN_VALUE_USED(opline)) { + PZVAL_LOCK(z); + EX_T(opline->result.var).var.ptr = z; + EX_T(opline->result.var).var.ptr_ptr = NULL; + } + zval_ptr_dtor(&z); + } else { + zend_error(E_WARNING, "Attempt to assign property of non-object"); + if (RETURN_VALUE_USED(opline)) { + PZVAL_LOCK(&EG(uninitialized_zval)); + EX_T(opline->result.var).var.ptr = &EG(uninitialized_zval); + EX_T(opline->result.var).var.ptr_ptr = NULL; + } + } + } + + if (0) { + zval_ptr_dtor(&property); + } else { + + } + FREE_OP(free_op_data1); + } + + /* assign_obj has two opcodes! */ + CHECK_EXCEPTION(); + ZEND_VM_INC_OPCODE(); + ZEND_VM_NEXT_OPCODE(); +} + +static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_UNUSED_CV(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + zend_free_op free_op_data2, free_op_data1; + zval **var_ptr; + zval *value; + + SAVE_OPLINE(); + switch (opline->extended_value) { + case ZEND_ASSIGN_OBJ: + return zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + break; + case ZEND_ASSIGN_DIM: { + zval **container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); + + if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); + } else if (UNEXPECTED(Z_TYPE_PP(container) == IS_OBJECT)) { + if (IS_UNUSED == IS_VAR && !0) { + Z_ADDREF_PP(container); /* undo the effect of get_obj_zval_ptr_ptr() */ + } + return zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + } else { + zval *dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + + zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_CV, BP_VAR_RW TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); + } + } + break; + default: + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); var_ptr = NULL; /* do nothing */ break; @@ -25610,7 +28976,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_UNUSED_CV(incdec_t SAVE_OPLINE(); object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); retval = &EX_T(opline->result.var).var.ptr; if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -25714,7 +29080,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_UNUSED_CV(incdec_ SAVE_OPLINE(); object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); retval = &EX_T(opline->result.var).tmp_var; if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -25814,7 +29180,7 @@ static int ZEND_FASTCALL zend_fetch_property_address_read_helper_SPEC_UNUSED_CV( SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -25859,7 +29225,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HA zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_UNUSED == IS_VAR && (opline->extended_value & ZEND_FETCH_ADD_LOCK)) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); @@ -25907,7 +29273,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); if (0) { @@ -25940,7 +29306,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -25975,14 +29341,14 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_CV_HANDLER(ZEND_OP { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1; zval *property; zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); if (0) { @@ -26017,7 +29383,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_CV_HANDLER(ZEND_OPCOD SAVE_OPLINE(); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_UNUSED == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -26059,7 +29425,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAN SAVE_OPLINE(); object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - property_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + property_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property_name); @@ -26067,7 +29433,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAN if (IS_UNUSED == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -26090,7 +29456,7 @@ static int ZEND_FASTCALL ZEND_ADD_VAR_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HANDLE int use_copy = 0; SAVE_OPLINE(); - var = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + var = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_UNUSED == IS_UNUSED) { /* Initialize for erealloc in add_string_to_string */ @@ -26131,11 +29497,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CV_HANDLER(ZEND_OPCO char *function_name_strval; int function_name_strlen; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + function_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_CV != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -26145,49 +29511,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CV_HANDLER(ZEND_OPCO function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_obj_zval_ptr_unused(TSRMLS_C); + call->object = _get_obj_zval_ptr_unused(TSRMLS_C); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_CV != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_CV == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); @@ -26221,7 +29593,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAND if (IS_UNUSED == IS_CV && container != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(container); } - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_UNUSED != IS_VAR || container) { switch (Z_TYPE_PP(container)) { @@ -26316,7 +29688,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_UNUSED != IS_VAR || container) { if (IS_UNUSED == IS_CV && container != &EG(uninitialized_zval_ptr)) { @@ -26360,7 +29732,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_CV( SAVE_OPLINE(); container = _get_obj_zval_ptr_ptr_unused(TSRMLS_C); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; @@ -26499,6 +29871,159 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UNUSED_CV_HANDLER(ZEN return zend_isset_isempty_dim_prop_obj_handler_SPEC_UNUSED_CV(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_UNUSED != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = NULL; + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = NULL; + + if (IS_UNUSED == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_UNUSED == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = NULL; + + /* Consts, temporary variables and references need copying */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_CV != IS_UNUSED) { + + zval *key = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_BW_NOT_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -26506,7 +30031,7 @@ static int ZEND_FASTCALL ZEND_BW_NOT_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); bitwise_not_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -26519,7 +30044,7 @@ static int ZEND_FASTCALL ZEND_BOOL_NOT_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); boolean_not_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -26532,7 +30057,7 @@ static int ZEND_FASTCALL ZEND_PRE_INC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval **var_ptr; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -26578,7 +30103,7 @@ static int ZEND_FASTCALL ZEND_PRE_DEC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval **var_ptr; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -26624,7 +30149,7 @@ static int ZEND_FASTCALL ZEND_POST_INC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval **var_ptr, *retval; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -26666,7 +30191,7 @@ static int ZEND_FASTCALL ZEND_POST_DEC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval **var_ptr, *retval; SAVE_OPLINE(); - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(var_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); @@ -26708,7 +30233,7 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *z; SAVE_OPLINE(); - z = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + z = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_TMP_VAR && Z_TYPE_P(z) == IS_OBJECT) { INIT_PZVAL(z); @@ -26735,7 +30260,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) int ret; SAVE_OPLINE(); - val = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + val = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { ret = Z_LVAL_P(val); @@ -26765,7 +30290,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) int ret; SAVE_OPLINE(); - val = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + val = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { ret = Z_LVAL_P(val); @@ -26795,7 +30320,7 @@ static int ZEND_FASTCALL ZEND_JMPZNZ_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) int retval; SAVE_OPLINE(); - val = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + val = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { retval = Z_LVAL_P(val); @@ -26829,7 +30354,7 @@ static int ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) int retval; SAVE_OPLINE(); - val = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + val = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { retval = Z_LVAL_P(val); @@ -26860,7 +30385,7 @@ static int ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS int retval; SAVE_OPLINE(); - val = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + val = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_TMP_VAR && EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { retval = Z_LVAL_P(val); @@ -26890,13 +30415,16 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); - retval_ptr = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + retval_ptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (!EG(return_value_ptr_ptr)) { if (IS_CV == IS_TMP_VAR) { } } else if (!0) { /* Not a temp var */ + if (*EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } if (IS_CV == IS_CONST || (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) { zval *ret; @@ -26918,6 +30446,10 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { zval *ret; + if (*EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } + ALLOC_ZVAL(ret); INIT_PZVAL_COPY(ret, retval_ptr); *EG(return_value_ptr_ptr) = ret; @@ -26936,11 +30468,15 @@ static int ZEND_FASTCALL ZEND_RETURN_BY_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); do { + if (EG(return_value_ptr_ptr) && *EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR) { /* Not supposed to happen, but we'll allow it */ zend_error(E_NOTICE, "Only variable references should be returned by reference"); - retval_ptr = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + retval_ptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (!EG(return_value_ptr_ptr)) { if (IS_CV == IS_TMP_VAR) { @@ -26962,7 +30498,7 @@ static int ZEND_FASTCALL ZEND_RETURN_BY_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER break; } - retval_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + retval_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(retval_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference"); @@ -27001,7 +30537,7 @@ static int ZEND_FASTCALL ZEND_THROW_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); - value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) { zend_error_noreturn(E_ERROR, "Can only throw objects"); @@ -27025,7 +30561,7 @@ static int ZEND_FASTCALL zend_send_by_var_helper_SPEC_CV(ZEND_OPCODE_HANDLER_ARG USE_OPLINE zval *varptr; - varptr = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + varptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (varptr == &EG(uninitialized_zval)) { ALLOC_ZVAL(varptr); @@ -27059,7 +30595,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { return zend_send_by_var_helper_SPEC_CV(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } - } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { return zend_send_by_var_helper_SPEC_CV(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -27070,7 +30606,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL varptr = EX_T(opline->op1.var).var.ptr; PZVAL_UNLOCK_EX(varptr, &free_op1, 0); } else { - varptr = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + varptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); } if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) || EX_T(opline->op1.var).var.fcall_returned_reference) && @@ -27085,7 +30621,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ? !(opline->extended_value & ZEND_ARG_SEND_SILENT) : - !ARG_MAY_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + !ARG_MAY_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { zend_error(E_STRICT, "Only variables should be passed by reference"); } ALLOC_ZVAL(valptr); @@ -27108,7 +30644,7 @@ static int ZEND_FASTCALL ZEND_SEND_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval *varptr; SAVE_OPLINE(); - varptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + varptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(varptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); @@ -27121,7 +30657,7 @@ static int ZEND_FASTCALL ZEND_SEND_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS ZEND_VM_NEXT_OPCODE(); } - if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION && !ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION && !ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { return zend_send_by_var_helper_SPEC_CV(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -27139,7 +30675,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS USE_OPLINE if ((opline->extended_value == ZEND_DO_FCALL_BY_NAME) - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.opline_num)) { + && ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.opline_num)) { return ZEND_SEND_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } SAVE_OPLINE(); @@ -27154,7 +30690,7 @@ static int ZEND_FASTCALL ZEND_BOOL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */ - ZVAL_BOOL(retval, i_zend_is_true(_get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC))); + ZVAL_BOOL(retval, i_zend_is_true(_get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -27170,7 +30706,7 @@ static int ZEND_FASTCALL ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_object_clone_obj_t clone_call; SAVE_OPLINE(); - obj = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + obj = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CONST || UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT)) { @@ -27231,7 +30767,7 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *result = &EX_T(opline->result.var).tmp_var; SAVE_OPLINE(); - expr = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + expr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (opline->extended_value != IS_STRING) { ZVAL_COPY_VALUE(result, expr); @@ -27288,11 +30824,11 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL zend_op_array *new_op_array=NULL; zval *inc_filename; - zval *tmp_inc_filename = NULL; + zval *tmp_inc_filename = NULL; zend_bool failure_retval=0; SAVE_OPLINE(); - inc_filename = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + inc_filename = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (inc_filename->type!=IS_STRING) { MAKE_STD_ZVAL(tmp_inc_filename); @@ -27380,8 +30916,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL EG(return_value_ptr_ptr) = NULL; } - EX(current_object) = EX(object); - EX(function_state).function = (zend_function *) new_op_array; EX(object) = NULL; @@ -27389,14 +30923,13 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL zend_rebuild_symbol_table(TSRMLS_C); } - if (EXPECTED(zend_execute == execute)) { + if (EXPECTED(zend_execute_ex == execute_ex)) { ZEND_VM_ENTER(); } else { zend_execute(new_op_array TSRMLS_CC); } EX(function_state).function = (zend_function *) EX(op_array); - EX(object) = EX(current_object); EG(opline_ptr) = &EX(opline); EG(active_op_array) = EX(op_array); @@ -27406,15 +30939,6 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL if (UNEXPECTED(EG(exception) != NULL)) { zend_throw_exception_internal(NULL TSRMLS_CC); HANDLE_EXCEPTION(); - } else if (RETURN_VALUE_USED(opline)) { - if (!EX_T(opline->result.var).var.ptr) { /* there was no return statement */ - zval *retval; - - ALLOC_ZVAL(retval); - ZVAL_BOOL(retval, 1); - INIT_PZVAL(retval); - EX_T(opline->result.var).var.ptr = retval; - } } } else if (RETURN_VALUE_USED(opline)) { @@ -27442,7 +30966,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS if ((IS_CV == IS_CV || IS_CV == IS_VAR) && (opline->extended_value & ZEND_FE_RESET_VARIABLE)) { - array_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + array_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (array_ptr_ptr == NULL || array_ptr_ptr == &EG(uninitialized_zval_ptr)) { MAKE_STD_ZVAL(array_ptr); ZVAL_NULL(array_ptr); @@ -27469,7 +30993,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS Z_ADDREF_P(array_ptr); } } else { - array_ptr = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + array_ptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (0) { /* IS_TMP_VAR */ zval *tmp; @@ -27578,7 +31102,7 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); if (IS_CV != IS_UNUSED) { - zval *ptr = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + zval *ptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (Z_TYPE_P(ptr) == IS_LONG) { EG(exit_status) = Z_LVAL_P(ptr); @@ -27599,7 +31123,7 @@ static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (i_zend_is_true(value)) { ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, value); @@ -27624,7 +31148,7 @@ static int ZEND_FASTCALL ZEND_JMP_SET_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_A zval *value, *ret; SAVE_OPLINE(); - value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (i_zend_is_true(value)) { if (IS_CV == IS_VAR || IS_CV == IS_CV) { @@ -27658,7 +31182,7 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG zval *value; SAVE_OPLINE(); - value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, value); if (!0) { @@ -27676,7 +31200,7 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER zval *value, *ret; SAVE_OPLINE(); - value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR || IS_CV == IS_CV) { Z_ADDREF_P(value); @@ -27704,7 +31228,7 @@ static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_AR zend_bool result; SAVE_OPLINE(); - expr = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + expr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->get_class_entry) { result = instanceof_function(Z_OBJCE_P(expr), EX_T(opline->op2.var).class_entry TSRMLS_CC); @@ -27724,7 +31248,7 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27739,7 +31263,7 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27754,7 +31278,7 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27769,7 +31293,7 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27784,7 +31308,7 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27799,7 +31323,7 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27814,7 +31338,7 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27829,7 +31353,7 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27844,7 +31368,7 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27860,7 +31384,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CV_CONST_HANDLER(ZEND_OPCOD SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); @@ -27877,7 +31401,7 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC)); @@ -27893,7 +31417,7 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC)); @@ -27909,7 +31433,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC)); @@ -27925,7 +31449,7 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CV_CONST_HANDLER(ZEND_OP SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC)); @@ -27940,7 +31464,7 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27955,7 +31479,7 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27970,7 +31494,7 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27985,7 +31509,7 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); @@ -27997,10 +31521,10 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_CV_CONST(int (*bi { USE_OPLINE zend_free_op free_op_data1; - zval **object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); zval *object; zval *property = opline->op2.zv; - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -28117,7 +31641,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_CONST(int (*binary return zend_binary_assign_op_obj_helper_SPEC_CV_CONST(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); break; case ZEND_ASSIGN_DIM: { - zval **container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -28130,14 +31654,14 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_CONST(int (*binary zval *dim = opline->op2.zv; zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_CONST, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: value = opline->op2.zv; - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); /* do nothing */ break; } @@ -28259,7 +31783,7 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_CV_CONST(incdec_t int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); property = opline->op2.zv; retval = &EX_T(opline->result.var).var.ptr; @@ -28363,7 +31887,7 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_CV_CONST(incdec_t int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); property = opline->op2.zv; retval = &EX_T(opline->result.var).tmp_var; @@ -28465,7 +31989,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_CONST(int type, Z ulong hash_value; SAVE_OPLINE(); - varname = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + varname = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { ZVAL_COPY_VALUE(&tmp_varname, varname); @@ -28605,7 +32129,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_ { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_CV_CONST(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_CV_CONST(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -28631,9 +32155,18 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN EX_T(opline->op1.var).var.ptr_ptr) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); } - container = _get_zval_ptr_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); + if (IS_CV == IS_TMP_VAR || IS_CV == IS_CONST) { + zval *container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); + + + } else { + container = _get_zval_ptr_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); + + + } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -28646,7 +32179,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -28679,7 +32212,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -28701,7 +32234,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, opline->op2.zv, IS_CONST, BP_VAR_IS TSRMLS_CC); @@ -28717,8 +32250,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_CONST_HANDLER(ZEND_OPC SAVE_OPLINE(); - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -28730,7 +32263,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_CONST_HANDLER(ZEND_OPC if (IS_CONST == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC); } @@ -28746,7 +32279,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_CONST_HANDLER(ZEND_OPCODE zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -28764,6 +32297,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_CONST_HANDLER(ZEND_OPCODE if (UNEXPECTED(EX_T(opline->result.var).var.ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); + ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_res; zval **retval_ptr = EX_T(opline->result.var).var.ptr_ptr; @@ -28788,7 +32322,7 @@ static int ZEND_FASTCALL zend_fetch_property_address_read_helper_SPEC_CV_CONST(Z zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); offset = opline->op2.zv; if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || @@ -28844,7 +32378,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN if (0) { MAKE_REAL_ZVAL_PTR(property); } - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } @@ -28883,7 +32417,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA SAVE_OPLINE(); property = opline->op2.zv; - container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -28914,7 +32448,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); offset = opline->op2.zv; if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || @@ -28950,7 +32484,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_CONST_HANDLER(ZEND_OPC { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1; zval *property; @@ -28958,7 +32492,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_CONST_HANDLER(ZEND_OPC SAVE_OPLINE(); property = opline->op2.zv; - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -28991,7 +32525,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_CONST_HANDLER(ZEND_OPCODE zval *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); property = opline->op2.zv; if (IS_CV == IS_CV) { @@ -29033,7 +32567,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAND zval *property_name; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); property_name = opline->op2.zv; if (0) { @@ -29042,7 +32576,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAND if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_CONST == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_CONST == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -29062,7 +32596,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAND zval **object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -29074,7 +32608,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAND if (0) { MAKE_REAL_ZVAL_PTR(property_name); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((IS_CONST == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_CONST == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -29088,8 +32622,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAND zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, IS_CONST, BP_VAR_W TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); if (UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) { if (RETURN_VALUE_USED(opline)) { @@ -29144,7 +32678,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); value = opline->op2.zv; - variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T(opline->op1.var), value, IS_CONST TSRMLS_CC)) { @@ -29195,9 +32729,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CONST_HANDLER(ZEND_OPCOD char *function_name_strval; int function_name_strlen; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); function_name = opline->op2.zv; @@ -29209,49 +32743,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CONST_HANDLER(ZEND_OPCOD function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + call->object = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_CONST != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_CONST == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); @@ -29268,7 +32808,7 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), opline->op2.zv TSRMLS_CC); CHECK_EXCEPTION(); @@ -29283,7 +32823,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONST_HANDLER(ZEND_OPCO SAVE_OPLINE(); if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) { - zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); @@ -29292,7 +32832,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONST_HANDLER(ZEND_OPCO expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + expr_ptr=_get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (0) { /* temporary variable */ zval *new_expr; @@ -29399,7 +32939,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDL ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + varname = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -29460,7 +33000,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDL ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CV && container != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(container); } @@ -29558,7 +33098,7 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDL zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); offset = opline->op2.zv; if (IS_CV != IS_VAR || container) { @@ -29614,7 +33154,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_CV_CONST_HANDLER(ZEND_OPCO } else { HashTable *target_symbol_table; - zval tmp, *varname = _get_zval_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -29686,7 +33226,7 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_CONST(i zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); offset = opline->op2.zv; @@ -29827,6 +33367,159 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV_CONST_HANDLER(ZEND return zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_CONST(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_CV != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); + + if (IS_CV == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_CV == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_CONST != IS_UNUSED) { + + zval *key = opline->op2.zv; + + /* Consts, temporary variables and references need copying */ + if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -29834,8 +33527,8 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -29849,8 +33542,8 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -29864,8 +33557,8 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -29879,8 +33572,8 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -29894,8 +33587,8 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -29909,8 +33602,8 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -29924,8 +33617,8 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -29939,8 +33632,8 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -29954,8 +33647,8 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -29970,8 +33663,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); zval_dtor(free_op2.var); @@ -29987,8 +33680,8 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -30003,8 +33696,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -30019,8 +33712,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -30035,8 +33728,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CV_TMP_HANDLER(ZEND_OPCO SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -30050,8 +33743,8 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -30065,8 +33758,8 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -30080,8 +33773,8 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -30095,8 +33788,8 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -30107,10 +33800,10 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_CV_TMP(int (*bina { USE_OPLINE zend_free_op free_op2, free_op_data1; - zval **object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); zval *object; - zval *property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -30227,7 +33920,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_TMP(int (*binary_o return zend_binary_assign_op_obj_helper_SPEC_CV_TMP(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); break; case ZEND_ASSIGN_DIM: { - zval **container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -30237,17 +33930,17 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_TMP(int (*binary_o } return zend_binary_assign_op_obj_helper_SPEC_CV_TMP(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_TMP_VAR, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: - value = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); /* do nothing */ break; } @@ -30370,8 +34063,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_CV_TMP(incdec_t in int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).var.ptr; if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -30474,8 +34167,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_CV_TMP(incdec_t i int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).tmp_var; if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -30578,9 +34271,18 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL EX_T(opline->op1.var).var.ptr_ptr) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); } - container = _get_zval_ptr_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); - zval_dtor(free_op2.var); + + if (IS_CV == IS_TMP_VAR || IS_CV == IS_CONST) { + zval *container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); + zval_dtor(free_op2.var); + + } else { + container = _get_zval_ptr_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); + zval_dtor(free_op2.var); + + } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -30593,12 +34295,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_W TSRMLS_CC); zval_dtor(free_op2.var); if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -30626,12 +34328,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_RW TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_RW TSRMLS_CC); zval_dtor(free_op2.var); if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -30648,8 +34350,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_IS TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_IS TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -30664,12 +34366,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_TMP_HANDLER(ZEND_OPCOD SAVE_OPLINE(); - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); } @@ -30677,8 +34379,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_TMP_HANDLER(ZEND_OPCOD if (IS_TMP_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_R TSRMLS_CC); } zval_dtor(free_op2.var); @@ -30693,7 +34395,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_H zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -30703,7 +34405,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_H if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_UNSET TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_TMP_VAR, BP_VAR_UNSET TSRMLS_CC); zval_dtor(free_op2.var); if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -30711,6 +34413,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_H if (UNEXPECTED(EX_T(opline->result.var).var.ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); + ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_res; zval **retval_ptr = EX_T(opline->result.var).var.ptr_ptr; @@ -30735,8 +34438,8 @@ static int ZEND_FASTCALL zend_fetch_property_address_read_helper_SPEC_CV_TMP(ZEN zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -30781,7 +34484,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_CV == IS_VAR && (opline->extended_value & ZEND_FETCH_ADD_LOCK)) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); @@ -30791,7 +34494,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL if (1) { MAKE_REAL_ZVAL_PTR(property); } - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } @@ -30829,8 +34532,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (1) { MAKE_REAL_ZVAL_PTR(property); @@ -30861,8 +34564,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -30897,15 +34600,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_TMP_HANDLER(ZEND_OPCOD { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1, free_op2; zval *property; zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (1) { MAKE_REAL_ZVAL_PTR(property); @@ -30938,8 +34641,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_H zval *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_CV == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -30980,8 +34683,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLE zval *property_name; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); - property_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); + property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (1) { MAKE_REAL_ZVAL_PTR(property_name); @@ -30989,7 +34692,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLE if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_TMP_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_TMP_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (1) { zval_ptr_dtor(&property_name); } else { @@ -31009,19 +34712,19 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLE zval **object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } if (Z_TYPE_PP(object_ptr) == IS_OBJECT) { zend_free_op free_op2; - zval *property_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *property_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (1) { MAKE_REAL_ZVAL_PTR(property_name); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((IS_TMP_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_TMP_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (1) { zval_ptr_dtor(&property_name); } else { @@ -31030,14 +34733,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLE } else { zend_free_op free_op2, free_op_data1, free_op_data2; zval *value; - zval *dim = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zval **variable_ptr_ptr; zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, IS_TMP_VAR, BP_VAR_W TSRMLS_CC); zval_dtor(free_op2.var); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); if (UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) { if (RETURN_VALUE_USED(opline)) { @@ -31091,8 +34794,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR zval **variable_ptr_ptr; SAVE_OPLINE(); - value = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + value = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T(opline->op1.var), value, IS_TMP_VAR TSRMLS_CC)) { @@ -31143,11 +34846,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_ char *function_name_strval; int function_name_strlen; zend_free_op free_op2; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -31157,49 +34860,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_ function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + call->object = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_TMP_VAR != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_TMP_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + zval_dtor(free_op2.var); + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; zval_dtor(free_op2.var); @@ -31217,8 +34926,8 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op2.var); CHECK_EXCEPTION(); @@ -31233,7 +34942,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE SAVE_OPLINE(); if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) { - zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); @@ -31242,7 +34951,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + expr_ptr=_get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (0) { /* temporary variable */ zval *new_expr; @@ -31263,7 +34972,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE if (IS_TMP_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -31334,11 +35043,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CV && container != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(container); } - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_CV != IS_VAR || container) { switch (Z_TYPE_PP(container)) { @@ -31432,8 +35141,8 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_CV != IS_VAR || container) { if (IS_CV == IS_CV && container != &EG(uninitialized_zval_ptr)) { @@ -31475,9 +35184,9 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_TMP(int zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; @@ -31616,6 +35325,159 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV_TMP_HANDLER(ZEND_O return zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_TMP(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_CV != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); + + if (IS_CV == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_CV == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_TMP_VAR != IS_UNUSED) { + zend_free_op free_op2; + zval *key = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_TMP_VAR == IS_CONST || IS_TMP_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!1) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -31623,8 +35485,8 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31638,8 +35500,8 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31653,8 +35515,8 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31668,8 +35530,8 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31683,8 +35545,8 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31698,8 +35560,8 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31713,8 +35575,8 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31728,8 +35590,8 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31743,8 +35605,8 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31759,8 +35621,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; @@ -31776,8 +35638,8 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31792,8 +35654,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31808,8 +35670,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31824,8 +35686,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CV_VAR_HANDLER(ZEND_OPCO SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC)); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31839,8 +35701,8 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31854,8 +35716,8 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31869,8 +35731,8 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31884,8 +35746,8 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -31896,10 +35758,10 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_CV_VAR(int (*bina { USE_OPLINE zend_free_op free_op2, free_op_data1; - zval **object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); zval *object; - zval *property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -32016,7 +35878,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_VAR(int (*binary_o return zend_binary_assign_op_obj_helper_SPEC_CV_VAR(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); break; case ZEND_ASSIGN_DIM: { - zval **container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -32026,17 +35888,17 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_VAR(int (*binary_o } return zend_binary_assign_op_obj_helper_SPEC_CV_VAR(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_VAR, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: - value = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + value = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); /* do nothing */ break; } @@ -32159,8 +36021,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_CV_VAR(incdec_t in int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).var.ptr; if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -32263,8 +36125,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_CV_VAR(incdec_t i int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); retval = &EX_T(opline->result.var).tmp_var; if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -32365,7 +36227,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_VAR(int type, ZEN ulong hash_value; SAVE_OPLINE(); - varname = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + varname = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { ZVAL_COPY_VALUE(&tmp_varname, varname); @@ -32505,7 +36367,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HA { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_CV_VAR(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_CV_VAR(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -32531,9 +36393,18 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL EX_T(opline->op1.var).var.ptr_ptr) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); } - container = _get_zval_ptr_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); - if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + + if (IS_CV == IS_TMP_VAR || IS_CV == IS_CONST) { + zval *container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + + } else { + container = _get_zval_ptr_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + + } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -32546,12 +36417,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_W TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -32579,12 +36450,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_RW TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_RW TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -32601,8 +36472,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_IS TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_IS TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -32617,12 +36488,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_VAR_HANDLER(ZEND_OPCOD SAVE_OPLINE(); - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); } @@ -32630,8 +36501,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_VAR_HANDLER(ZEND_OPCOD if (IS_VAR == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_R TSRMLS_CC); } if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; @@ -32646,7 +36517,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_H zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -32656,7 +36527,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_H if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_UNSET TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC), IS_VAR, BP_VAR_UNSET TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -32664,6 +36535,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_H if (UNEXPECTED(EX_T(opline->result.var).var.ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); + ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_res; zval **retval_ptr = EX_T(opline->result.var).var.ptr_ptr; @@ -32688,8 +36560,8 @@ static int ZEND_FASTCALL zend_fetch_property_address_read_helper_SPEC_CV_VAR(ZEN zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -32734,7 +36606,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_CV == IS_VAR && (opline->extended_value & ZEND_FETCH_ADD_LOCK)) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); @@ -32744,7 +36616,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL if (0) { MAKE_REAL_ZVAL_PTR(property); } - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } @@ -32782,8 +36654,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -32814,8 +36686,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -32850,15 +36722,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_VAR_HANDLER(ZEND_OPCOD { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1, free_op2; zval *property; zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -32891,8 +36763,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_H zval *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_CV == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -32933,8 +36805,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE zval *property_name; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); - property_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); + property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property_name); @@ -32942,7 +36814,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -32962,19 +36834,19 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE zval **object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } if (Z_TYPE_PP(object_ptr) == IS_OBJECT) { zend_free_op free_op2; - zval *property_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *property_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property_name); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((IS_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_VAR == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -32983,14 +36855,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE } else { zend_free_op free_op2, free_op_data1, free_op_data2; zval *value; - zval *dim = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zval **variable_ptr_ptr; zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, IS_VAR, BP_VAR_W TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); if (UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) { if (RETURN_VALUE_USED(opline)) { @@ -33044,8 +36916,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR zval **variable_ptr_ptr; SAVE_OPLINE(); - value = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); - variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + value = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T(opline->op1.var), value, IS_VAR TSRMLS_CC)) { @@ -33098,7 +36970,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE zval **value_ptr_ptr; SAVE_OPLINE(); - value_ptr_ptr = _get_zval_ptr_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + value_ptr_ptr = _get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR == IS_VAR && value_ptr_ptr && @@ -33121,7 +36993,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE zend_error_noreturn(E_ERROR, "Cannot assign by reference to overloaded object"); } - variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if ((IS_VAR == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) || (IS_CV == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); @@ -33150,11 +37022,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_ char *function_name_strval; int function_name_strlen; zend_free_op free_op2; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -33164,49 +37036,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_ function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + call->object = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_VAR != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_VAR == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; @@ -33224,8 +37102,8 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; CHECK_EXCEPTION(); @@ -33240,7 +37118,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE SAVE_OPLINE(); if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) { - zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); @@ -33249,7 +37127,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + expr_ptr=_get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (0) { /* temporary variable */ zval *new_expr; @@ -33270,7 +37148,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE if (IS_VAR != IS_UNUSED) { zend_free_op free_op2; - zval *offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -33356,7 +37234,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + varname = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -33417,11 +37295,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CV && container != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(container); } - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_CV != IS_VAR || container) { switch (Z_TYPE_PP(container)) { @@ -33515,8 +37393,8 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (IS_CV != IS_VAR || container) { if (IS_CV == IS_CV && container != &EG(uninitialized_zval_ptr)) { @@ -33571,7 +37449,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_CV_VAR_HANDLER(ZEND_OPCODE } else { HashTable *target_symbol_table; - zval tmp, *varname = _get_zval_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -33643,9 +37521,9 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_VAR(int zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC); + offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; @@ -33784,14 +37662,168 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV_VAR_HANDLER(ZEND_O return zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_VAR(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_CV != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); + + if (IS_CV == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_CV == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_VAR != IS_UNUSED) { + zend_free_op free_op2; + zval *key = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_VAR == IS_CONST || IS_VAR == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_CV_UNUSED(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE zend_free_op free_op_data1; - zval **object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); zval *object; zval *property = NULL; - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -33908,7 +37940,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_UNUSED(int (*binar return zend_binary_assign_op_obj_helper_SPEC_CV_UNUSED(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); break; case ZEND_ASSIGN_DIM: { - zval **container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -33921,14 +37953,14 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_UNUSED(int (*binar zval *dim = NULL; zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_UNUSED, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: value = NULL; - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); /* do nothing */ break; } @@ -34050,7 +38082,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_UNUSED(int type, ulong hash_value; SAVE_OPLINE(); - varname = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + varname = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { ZVAL_COPY_VALUE(&tmp_varname, varname); @@ -34190,7 +38222,7 @@ static int ZEND_FASTCALL ZEND_FETCH_FUNC_ARG_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE { USE_OPLINE - return zend_fetch_var_address_helper_SPEC_CV_UNUSED(ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + return zend_fetch_var_address_helper_SPEC_CV_UNUSED(ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))?BP_VAR_W:BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } static int ZEND_FASTCALL ZEND_FETCH_UNSET_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) @@ -34210,7 +38242,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HA zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -34243,7 +38275,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_H zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -34266,8 +38298,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_UNUSED_HANDLER(ZEND_OP SAVE_OPLINE(); - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } @@ -34279,7 +38311,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_UNUSED_HANDLER(ZEND_OP if (IS_UNUSED == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, NULL, IS_UNUSED, BP_VAR_R TSRMLS_CC); } @@ -34295,7 +38327,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HAN zval **object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -34307,7 +38339,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HAN if (0) { MAKE_REAL_ZVAL_PTR(property_name); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((IS_UNUSED == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_UNUSED == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -34321,8 +38353,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HAN zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, IS_UNUSED, BP_VAR_W TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); if (UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) { if (RETURN_VALUE_USED(opline)) { @@ -34376,7 +38408,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUSED_HANDLER(ZEND_OPC SAVE_OPLINE(); if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) { - zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); @@ -34385,7 +38417,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUSED_HANDLER(ZEND_OPC expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + expr_ptr=_get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (0) { /* temporary variable */ zval *new_expr; @@ -34492,7 +38524,7 @@ static int ZEND_FASTCALL ZEND_UNSET_VAR_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HAND ZEND_VM_NEXT_OPCODE(); } - varname = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + varname = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -34568,7 +38600,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_CV_UNUSED_HANDLER(ZEND_OPC } else { HashTable *target_symbol_table; - zval tmp, *varname = _get_zval_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); + zval tmp, *varname = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV != IS_CONST && Z_TYPE_P(varname) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, varname); @@ -34629,6 +38661,159 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_CV_UNUSED_HANDLER(ZEND_OPC ZEND_VM_NEXT_OPCODE(); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_CV != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); + + if (IS_CV == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_CV == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_UNUSED != IS_UNUSED) { + + zval *key = NULL; + + /* Consts, temporary variables and references need copying */ + if (IS_UNUSED == IS_CONST || IS_UNUSED == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_ADD_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -34636,8 +38821,8 @@ static int ZEND_FASTCALL ZEND_ADD_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_add_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34651,8 +38836,8 @@ static int ZEND_FASTCALL ZEND_SUB_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_sub_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34666,8 +38851,8 @@ static int ZEND_FASTCALL ZEND_MUL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mul_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34681,8 +38866,8 @@ static int ZEND_FASTCALL ZEND_DIV_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_div_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34696,8 +38881,8 @@ static int ZEND_FASTCALL ZEND_MOD_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); fast_mod_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34711,8 +38896,8 @@ static int ZEND_FASTCALL ZEND_SL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_left_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34726,8 +38911,8 @@ static int ZEND_FASTCALL ZEND_SR_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); shift_right_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34741,8 +38926,8 @@ static int ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); concat_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34756,8 +38941,8 @@ static int ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); is_identical_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34772,8 +38957,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_H SAVE_OPLINE(); is_identical_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); @@ -34789,8 +38974,8 @@ static int ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); ZVAL_BOOL(result, fast_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); CHECK_EXCEPTION(); @@ -34805,8 +38990,8 @@ static int ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL SAVE_OPLINE(); ZVAL_BOOL(result, fast_not_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); CHECK_EXCEPTION(); @@ -34821,8 +39006,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); CHECK_EXCEPTION(); @@ -34837,8 +39022,8 @@ static int ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CV_CV_HANDLER(ZEND_OPCOD SAVE_OPLINE(); ZVAL_BOOL(result, fast_is_smaller_or_equal_function(result, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC)); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC)); CHECK_EXCEPTION(); @@ -34852,8 +39037,8 @@ static int ZEND_FASTCALL ZEND_BW_OR_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); bitwise_or_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34867,8 +39052,8 @@ static int ZEND_FASTCALL ZEND_BW_AND_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); bitwise_and_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34882,8 +39067,8 @@ static int ZEND_FASTCALL ZEND_BW_XOR_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); bitwise_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34897,8 +39082,8 @@ static int ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_A SAVE_OPLINE(); boolean_xor_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); @@ -34909,10 +39094,10 @@ static int ZEND_FASTCALL zend_binary_assign_op_obj_helper_SPEC_CV_CV(int (*binar { USE_OPLINE zend_free_op free_op_data1; - zval **object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); zval *object; - zval *property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); + zval *property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); int have_get_ptr = 0; if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -35029,7 +39214,7 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_CV(int (*binary_op return zend_binary_assign_op_obj_helper_SPEC_CV_CV(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); break; case ZEND_ASSIGN_DIM: { - zval **container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); @@ -35039,17 +39224,17 @@ static int ZEND_FASTCALL zend_binary_assign_op_helper_SPEC_CV_CV(int (*binary_op } return zend_binary_assign_op_obj_helper_SPEC_CV_CV(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } else { - zval *dim = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, IS_CV, BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); } } break; default: - value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); /* do nothing */ break; } @@ -35171,8 +39356,8 @@ static int ZEND_FASTCALL zend_pre_incdec_property_helper_SPEC_CV_CV(incdec_t inc int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); retval = &EX_T(opline->result.var).var.ptr; if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -35275,8 +39460,8 @@ static int ZEND_FASTCALL zend_post_incdec_property_helper_SPEC_CV_CV(incdec_t in int have_get_ptr = 0; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); retval = &EX_T(opline->result.var).tmp_var; if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { @@ -35379,9 +39564,18 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE EX_T(opline->op1.var).var.ptr_ptr) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); } - container = _get_zval_ptr_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); + if (IS_CV == IS_TMP_VAR || IS_CV == IS_CONST) { + zval *container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), &container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); + + + } else { + container = _get_zval_ptr_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); + + + } CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -35394,12 +39588,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_W_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -35427,12 +39621,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_RW_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_RW TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_RW TSRMLS_CC); if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -35449,8 +39643,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_IS TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_IS TSRMLS_CC); CHECK_EXCEPTION(); @@ -35465,12 +39659,12 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_CV_HANDLER(ZEND_OPCODE SAVE_OPLINE(); - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_W TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); } @@ -35478,8 +39672,8 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_CV_HANDLER(ZEND_OPCODE if (IS_CV == IS_UNUSED) { zend_error_noreturn(E_ERROR, "Cannot use [] for reading"); } - container = _get_zval_ptr_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); - zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + zend_fetch_dimension_address_read(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_R TSRMLS_CC); } @@ -35494,7 +39688,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HA zval **container; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -35504,7 +39698,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HA if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_UNSET TSRMLS_CC); + zend_fetch_dimension_address(&EX_T(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC), IS_CV, BP_VAR_UNSET TSRMLS_CC); if (IS_CV == IS_VAR && 0 && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(&EX_T(opline->result.var)); @@ -35512,6 +39706,7 @@ static int ZEND_FASTCALL ZEND_FETCH_DIM_UNSET_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HA if (UNEXPECTED(EX_T(opline->result.var).var.ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); + ZEND_VM_NEXT_OPCODE(); } else { zend_free_op free_res; zval **retval_ptr = EX_T(opline->result.var).var.ptr_ptr; @@ -35536,8 +39731,8 @@ static int ZEND_FASTCALL zend_fetch_property_address_read_helper_SPEC_CV_CV(ZEND zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -35582,7 +39777,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_CV == IS_VAR && (opline->extended_value & ZEND_FETCH_ADD_LOCK)) { PZVAL_LOCK(*EX_T(opline->op1.var).var.ptr_ptr); @@ -35592,7 +39787,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE if (0) { MAKE_REAL_ZVAL_PTR(property); } - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } @@ -35630,8 +39825,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); - container = _get_zval_ptr_ptr_cv_BP_VAR_RW(EX_CVs(), opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -35662,8 +39857,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) || UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) { @@ -35698,15 +39893,15 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_CV_HANDLER(ZEND_OPCODE { USE_OPLINE - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1; zval *property; zval **container; SAVE_OPLINE(); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); - container = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property); @@ -35739,8 +39934,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HA zval *property; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); - property = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); + property = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_CV == IS_CV) { if (container != &EG(uninitialized_zval_ptr)) { @@ -35781,8 +39976,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER zval *property_name; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); - property_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); + property_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property_name); @@ -35790,7 +39985,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -35810,19 +40005,19 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER zval **object_ptr; SAVE_OPLINE(); - object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + object_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(object_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } if (Z_TYPE_PP(object_ptr) == IS_OBJECT) { - zval *property_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *property_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (0) { MAKE_REAL_ZVAL_PTR(property_name); } - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((IS_CV == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC); if (0) { zval_ptr_dtor(&property_name); } else { @@ -35831,13 +40026,13 @@ static int ZEND_FASTCALL ZEND_ASSIGN_DIM_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER } else { zend_free_op free_op_data1, free_op_data2; zval *value; - zval *dim = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); zval **variable_ptr_ptr; zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, IS_CV, BP_VAR_W TSRMLS_CC); - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R); - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC); + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R); + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC); if (UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) { if (RETURN_VALUE_USED(opline)) { @@ -35891,8 +40086,8 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG zval **variable_ptr_ptr; SAVE_OPLINE(); - value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); - variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL)) { if (zend_assign_to_string_offset(&EX_T(opline->op1.var), value, IS_CV TSRMLS_CC)) { @@ -35944,7 +40139,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER zval **value_ptr_ptr; SAVE_OPLINE(); - value_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op2.var TSRMLS_CC); + value_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op2.var TSRMLS_CC); if (IS_CV == IS_VAR && value_ptr_ptr && @@ -35967,7 +40162,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER zend_error_noreturn(E_ERROR, "Cannot assign by reference to overloaded object"); } - variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + variable_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if ((IS_CV == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) || (IS_CV == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); @@ -35995,11 +40190,11 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_H char *function_name_strval; int function_name_strlen; + call_slot *call = EX(call_slots) + opline->result.num; SAVE_OPLINE(); - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(called_scope)); - function_name = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + function_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_CV != IS_CONST && UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) { @@ -36009,49 +40204,55 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_H function_name_strval = Z_STRVAL_P(function_name); function_name_strlen = Z_STRLEN_P(function_name); - EX(object) = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + call->object = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - if (EXPECTED(EX(object) != NULL) && - EXPECTED(Z_TYPE_P(EX(object)) == IS_OBJECT)) { - EX(called_scope) = Z_OBJCE_P(EX(object)); + if (EXPECTED(call->object != NULL) && + EXPECTED(Z_TYPE_P(call->object) == IS_OBJECT)) { + call->called_scope = Z_OBJCE_P(call->object); if (IS_CV != IS_CONST || - (EX(fbc) = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope))) == NULL) { - zval *object = EX(object); + (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { + zval *object = call->object; - if (UNEXPECTED(Z_OBJ_HT_P(EX(object))->get_method == NULL)) { + if (UNEXPECTED(Z_OBJ_HT_P(call->object)->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(&EX(object), function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); - if (UNEXPECTED(EX(fbc) == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); + call->fbc = Z_OBJ_HT_P(call->object)->get_method(&call->object, function_name_strval, function_name_strlen, ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + if (UNEXPECTED(call->fbc == NULL)) { + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), function_name_strval); } if (IS_CV == IS_CONST && - EXPECTED(EX(fbc)->type <= ZEND_USER_FUNCTION) && - EXPECTED((EX(fbc)->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(EX(object) == object)) { - CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, EX(called_scope), EX(fbc)); + EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && + EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && + EXPECTED(call->object == object)) { + CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } } else { + if (UNEXPECTED(EG(exception) != NULL)) { + + HANDLE_EXCEPTION(); + } zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } - if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) { - EX(object) = NULL; + if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { + call->object = NULL; } else { - if (!PZVAL_IS_REF(EX(object))) { - Z_ADDREF_P(EX(object)); /* For $this pointer */ + if (!PZVAL_IS_REF(call->object)) { + Z_ADDREF_P(call->object); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); - INIT_PZVAL_COPY(this_ptr, EX(object)); + INIT_PZVAL_COPY(this_ptr, call->object); zval_copy_ctor(this_ptr); - EX(object) = this_ptr; + call->object = this_ptr; } } + call->is_ctor_call = 0; + EX(call) = call; CHECK_EXCEPTION(); @@ -36068,8 +40269,8 @@ static int ZEND_FASTCALL ZEND_CASE_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) PZVAL_LOCK(EX_T(opline->op1.var).var.ptr); } is_equal_function(&EX_T(opline->result.var).tmp_var, - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC), - _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC) TSRMLS_CC); + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC), + _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC) TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -36083,7 +40284,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_HANDLER(ZEND_OPCODE_ SAVE_OPLINE(); if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) { - zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->op1.var TSRMLS_CC); + zval **expr_ptr_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) { zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets"); @@ -36092,7 +40293,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_HANDLER(ZEND_OPCODE_ expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else { - expr_ptr=_get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC); + expr_ptr=_get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (0) { /* temporary variable */ zval *new_expr; @@ -36113,7 +40314,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_HANDLER(ZEND_OPCODE_ if (IS_CV != IS_UNUSED) { - zval *offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); ulong hval; switch (Z_TYPE_P(offset)) { @@ -36184,11 +40385,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ ulong hval; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); if (IS_CV == IS_CV && container != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(container); } - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_CV != IS_VAR || container) { switch (Z_TYPE_PP(container)) { @@ -36282,8 +40483,8 @@ static int ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(EX_CVs(), opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (IS_CV != IS_VAR || container) { if (IS_CV == IS_CV && container != &EG(uninitialized_zval_ptr)) { @@ -36325,9 +40526,9 @@ static int ZEND_FASTCALL zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_CV(int zval *offset; SAVE_OPLINE(); - container = _get_zval_ptr_ptr_cv_BP_VAR_IS(EX_CVs(), opline->op1.var TSRMLS_CC); + container = _get_zval_ptr_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); - offset = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op2.var TSRMLS_CC); + offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); if (Z_TYPE_PP(container) == IS_ARRAY && !prop_dim) { HashTable *ht; @@ -36466,9 +40667,163 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV_CV_HANDLER(ZEND_OP return zend_isset_isempty_dim_prop_obj_handler_SPEC_CV_CV(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + USE_OPLINE + + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) { + zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator"); + } + + /* Destroy the previously yielded value */ + if (generator->value) { + zval_ptr_dtor(&generator->value); + } + + /* Destroy the previously yielded key */ + if (generator->key) { + zval_ptr_dtor(&generator->key); + } + + /* Set the new yielded value */ + if (IS_CV != IS_UNUSED) { + + + if (EX(op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) { + /* Constants and temporary variables aren't yieldable by reference, + * but we still allow them with a notice. */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR) { + zval *value, *copy; + + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + zval **value_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->op1.var TSRMLS_CC); + + if (IS_CV == IS_VAR && UNEXPECTED(value_ptr == NULL)) { + zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference"); + } + + /* If a function call result is yielded and the function did + * not return by reference we throw a notice. */ + if (IS_CV == IS_VAR && !Z_ISREF_PP(value_ptr) + && !(opline->extended_value == ZEND_RETURNS_FUNCTION + && EX_T(opline->op1.var).var.fcall_returned_reference) + && EX_T(opline->op1.var).var.ptr_ptr == &EX_T(opline->op1.var).var.ptr) { + zend_error(E_NOTICE, "Only variable references should be yielded by reference"); + + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } else { + SEPARATE_ZVAL_TO_MAKE_IS_REF(value_ptr); + Z_ADDREF_PP(value_ptr); + generator->value = *value_ptr; + } + + } + } else { + zval *value = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR + || (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, value); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->value = copy; + } else { + Z_ADDREF_P(value); + generator->value = value; + } + + } + } else { + /* If no value was specified yield null */ + Z_ADDREF(EG(uninitialized_zval)); + generator->value = &EG(uninitialized_zval); + } + + /* Set the new yielded key */ + if (IS_CV != IS_UNUSED) { + + zval *key = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); + + /* Consts, temporary variables and references need copying */ + if (IS_CV == IS_CONST || IS_CV == IS_TMP_VAR + || (PZVAL_IS_REF(key) && Z_REFCOUNT_P(key) > 0) + ) { + zval *copy; + + ALLOC_ZVAL(copy); + INIT_PZVAL_COPY(copy, key); + + /* Temporary variables don't need ctor copying */ + if (!0) { + zval_copy_ctor(copy); + } + + generator->key = copy; + } else { + Z_ADDREF_P(key); + generator->key = key; + } + + if (Z_TYPE_P(generator->key) == IS_LONG + && Z_LVAL_P(generator->key) > generator->largest_used_integer_key + ) { + generator->largest_used_integer_key = Z_LVAL_P(generator->key); + } + + } else { + /* If no key was specified we use auto-increment keys */ + generator->largest_used_integer_key++; + + ALLOC_INIT_ZVAL(generator->key); + ZVAL_LONG(generator->key, generator->largest_used_integer_key); + } + + /* If a value is sent it should go into the result var */ + generator->send_target = &EX_T(opline->result.var); + + /* Initialize the sent value to NULL */ + EX_T(opline->result.var).tmp_var = EG(uninitialized_zval); + + /* We increment to the next op, so we are at the correct position when the + * generator is resumed. */ + ZEND_VM_INC_OPCODE(); + + /* The GOTO VM uses a local opline variable. We need to set the opline + * variable in execute_data so we don't resume at an old position. */ + SAVE_OPLINE(); + + ZEND_VM_RETURN(); +} + static int ZEND_FASTCALL ZEND_NULL_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_error_noreturn(E_ERROR, "Invalid opcode %d/%d/%d.", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type); + ZEND_VM_NEXT_OPCODE(); /* Never reached */ } @@ -38500,16 +42855,16 @@ void zend_init_opcodes_handlers(void) ZEND_FETCH_R_SPEC_CV_VAR_HANDLER, ZEND_FETCH_R_SPEC_CV_UNUSED_HANDLER, ZEND_NULL_HANDLER, + ZEND_FETCH_DIM_R_SPEC_CONST_CONST_HANDLER, + ZEND_FETCH_DIM_R_SPEC_CONST_TMP_HANDLER, + ZEND_FETCH_DIM_R_SPEC_CONST_VAR_HANDLER, ZEND_NULL_HANDLER, + ZEND_FETCH_DIM_R_SPEC_CONST_CV_HANDLER, + ZEND_FETCH_DIM_R_SPEC_TMP_CONST_HANDLER, + ZEND_FETCH_DIM_R_SPEC_TMP_TMP_HANDLER, + ZEND_FETCH_DIM_R_SPEC_TMP_VAR_HANDLER, ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, - ZEND_NULL_HANDLER, + ZEND_FETCH_DIM_R_SPEC_TMP_CV_HANDLER, ZEND_FETCH_DIM_R_SPEC_VAR_CONST_HANDLER, ZEND_FETCH_DIM_R_SPEC_VAR_TMP_HANDLER, ZEND_FETCH_DIM_R_SPEC_VAR_VAR_HANDLER, @@ -40450,6 +44805,131 @@ void zend_init_opcodes_handlers(void) ZEND_JMP_SET_VAR_SPEC_CV_HANDLER, ZEND_JMP_SET_VAR_SPEC_CV_HANDLER, ZEND_JMP_SET_VAR_SPEC_CV_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_DISCARD_EXCEPTION_SPEC_HANDLER, + ZEND_YIELD_SPEC_CONST_CONST_HANDLER, + ZEND_YIELD_SPEC_CONST_TMP_HANDLER, + ZEND_YIELD_SPEC_CONST_VAR_HANDLER, + ZEND_YIELD_SPEC_CONST_UNUSED_HANDLER, + ZEND_YIELD_SPEC_CONST_CV_HANDLER, + ZEND_YIELD_SPEC_TMP_CONST_HANDLER, + ZEND_YIELD_SPEC_TMP_TMP_HANDLER, + ZEND_YIELD_SPEC_TMP_VAR_HANDLER, + ZEND_YIELD_SPEC_TMP_UNUSED_HANDLER, + ZEND_YIELD_SPEC_TMP_CV_HANDLER, + ZEND_YIELD_SPEC_VAR_CONST_HANDLER, + ZEND_YIELD_SPEC_VAR_TMP_HANDLER, + ZEND_YIELD_SPEC_VAR_VAR_HANDLER, + ZEND_YIELD_SPEC_VAR_UNUSED_HANDLER, + ZEND_YIELD_SPEC_VAR_CV_HANDLER, + ZEND_YIELD_SPEC_UNUSED_CONST_HANDLER, + ZEND_YIELD_SPEC_UNUSED_TMP_HANDLER, + ZEND_YIELD_SPEC_UNUSED_VAR_HANDLER, + ZEND_YIELD_SPEC_UNUSED_UNUSED_HANDLER, + ZEND_YIELD_SPEC_UNUSED_CV_HANDLER, + ZEND_YIELD_SPEC_CV_CONST_HANDLER, + ZEND_YIELD_SPEC_CV_TMP_HANDLER, + ZEND_YIELD_SPEC_CV_VAR_HANDLER, + ZEND_YIELD_SPEC_CV_UNUSED_HANDLER, + ZEND_YIELD_SPEC_CV_CV_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_GENERATOR_RETURN_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_CALL_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, + ZEND_FAST_RET_SPEC_HANDLER, ZEND_NULL_HANDLER }; zend_opcode_handlers = (opcode_handler_t*)labels; diff --git a/Zend/zend_vm_execute.skl b/Zend/zend_vm_execute.skl index 6d1b2e70e7d02..13fd88e2d881b 100644 --- a/Zend/zend_vm_execute.skl +++ b/Zend/zend_vm_execute.skl @@ -1,67 +1,25 @@ {%DEFINES%} -ZEND_API void {%EXECUTOR_NAME%}(zend_op_array *op_array TSRMLS_DC) +ZEND_API void {%EXECUTOR_NAME%}_ex(zend_execute_data *execute_data TSRMLS_DC) { DCL_OPLINE - zend_execute_data *execute_data; - zend_bool nested = 0; + zend_bool original_in_execution; + {%HELPER_VARS%} - {%EXECUTION_STATUS%} {%INTERNAL_LABELS%} - if (EG(exception)) { - return; - } - + original_in_execution = EG(in_execution); EG(in_execution) = 1; + if (0) { zend_vm_enter: - /* Initialize execute_data */ - execute_data = (zend_execute_data *)zend_vm_stack_alloc( - ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)) + - ZEND_MM_ALIGNED_SIZE(sizeof(zval**) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2)) + - ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T TSRMLS_CC); - - EX(CVs) = (zval***)((char*)execute_data + ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data))); - memset(EX(CVs), 0, sizeof(zval**) * op_array->last_var); - EX(Ts) = (temp_variable *)(((char*)EX(CVs)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval**) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2))); - EX(fbc) = NULL; - EX(called_scope) = NULL; - EX(object) = NULL; - EX(old_error_reporting) = NULL; - EX(op_array) = op_array; - EX(symbol_table) = EG(active_symbol_table); - EX(prev_execute_data) = EG(current_execute_data); - EG(current_execute_data) = execute_data; - EX(nested) = nested; - nested = 1; - - LOAD_REGS(); - - if (!op_array->run_time_cache && op_array->last_cache_slot) { - op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*)); + execute_data = i_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC); } - if (op_array->this_var != -1 && EG(This)) { - Z_ADDREF_P(EG(This)); /* For $this pointer */ - if (!EG(active_symbol_table)) { - EX_CV(op_array->this_var) = (zval**)EX_CVs() + (op_array->last_var + op_array->this_var); - *EX_CV(op_array->this_var) = EG(This); - } else { - if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), (void**)&EX_CV(op_array->this_var))==FAILURE) { - Z_DELREF_P(EG(This)); - } - } - } - - EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes; - EG(opline_ptr) = &EX(opline); + LOAD_REGS(); LOAD_OPLINE(); - EX(function_state).function = (zend_function *) op_array; - EX(function_state).arguments = NULL; - while (1) { {%ZEND_VM_CONTINUE_LABEL%} #ifdef ZEND_WIN32 @@ -78,6 +36,14 @@ zend_vm_enter: zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen"); } +ZEND_API void zend_{%EXECUTOR_NAME%}(zend_op_array *op_array TSRMLS_DC) +{ + if (EG(exception)) { + return; + } + zend_{%EXECUTOR_NAME%}_ex(i_create_execute_data_from_op_array(op_array, 0 TSRMLS_CC) TSRMLS_CC); +} + {%EXTERNAL_EXECUTOR%} void {%INITIALIZER_NAME%}(void) diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index 97dc0e8bed179..63d0cf73f0d52 100644 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -118,75 +118,75 @@ ); $op1_get_zval_ptr = array( - "ANY" => "get_zval_ptr(opline->op1_type, &opline->op1, EX_Ts(), &free_op1, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)", + "ANY" => "get_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)", + "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", "CONST" => "opline->op1.zv", "UNUSED" => "NULL", - "CV" => "_get_zval_ptr_cv_\\1(EX_CVs(), opline->op1.var TSRMLS_CC)", + "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)", ); $op2_get_zval_ptr = array( - "ANY" => "get_zval_ptr(opline->op2_type, &opline->op2, EX_Ts(), &free_op2, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)", + "ANY" => "get_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)", + "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", "CONST" => "opline->op2.zv", "UNUSED" => "NULL", - "CV" => "_get_zval_ptr_cv_\\1(EX_CVs(), opline->op2.var TSRMLS_CC)", + "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)", ); $op1_get_zval_ptr_ptr = array( - "ANY" => "get_zval_ptr_ptr(opline->op1_type, &opline->op1, EX_Ts(), &free_op1, \\1)", + "ANY" => "get_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)", "TMP" => "NULL", - "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", "CONST" => "NULL", "UNUSED" => "NULL", - "CV" => "_get_zval_ptr_ptr_cv_\\1(EX_CVs(), opline->op1.var TSRMLS_CC)", + "CV" => "_get_zval_ptr_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)", ); $op2_get_zval_ptr_ptr = array( - "ANY" => "get_zval_ptr_ptr(opline->op2_type, &opline->op2, EX_Ts(), &free_op2, \\1)", + "ANY" => "get_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)", "TMP" => "NULL", - "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", "CONST" => "NULL", "UNUSED" => "NULL", - "CV" => "_get_zval_ptr_ptr_cv_\\1(EX_CVs(), opline->op2.var TSRMLS_CC)", + "CV" => "_get_zval_ptr_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)", ); $op1_get_obj_zval_ptr = array( - "ANY" => "get_obj_zval_ptr(opline->op1_type, &opline->op1, EX_Ts(), &free_op1, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)", + "ANY" => "get_obj_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)", + "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", "CONST" => "opline->op1.zv", "UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)", - "CV" => "_get_zval_ptr_cv_\\1(EX_CVs(), opline->op1.var TSRMLS_CC)", + "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)", ); $op2_get_obj_zval_ptr = array( - "ANY" => "get_obj_zval_ptr(opline->op2_type, &opline->op2, EX_Ts(), &free_op2, \\1)", - "TMP" => "_get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)", - "VAR" => "_get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)", + "ANY" => "get_obj_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)", + "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", "CONST" => "opline->op2.zv", "UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)", - "CV" => "_get_zval_ptr_cv_\\1(EX_CVs(), opline->op2.var TSRMLS_CC)", + "CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)", ); $op1_get_obj_zval_ptr_ptr = array( - "ANY" => "get_obj_zval_ptr_ptr(opline->op1_type, &opline->op1, EX_Ts(), &free_op1, \\1)", + "ANY" => "get_obj_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)", "TMP" => "NULL", - "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)", "CONST" => "NULL", "UNUSED" => "_get_obj_zval_ptr_ptr_unused(TSRMLS_C)", - "CV" => "_get_zval_ptr_ptr_cv_\\1(EX_CVs(), opline->op1.var TSRMLS_CC)", + "CV" => "_get_zval_ptr_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)", ); $op2_get_obj_zval_ptr_ptr = array( - "ANY" => "get_obj_zval_ptr_ptr(opline->op2_type, &opline->op2, EX_Ts(), &free_op2, \\1)", + "ANY" => "get_obj_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)", "TMP" => "NULL", - "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)", + "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)", "CONST" => "NULL", "UNUSED" => "_get_obj_zval_ptr_ptr_unused(TSRMLS_C)", - "CV" => "_get_zval_ptr_ptr_cv_\\1(EX_CVs(), opline->op2.var TSRMLS_CC)", + "CV" => "_get_zval_ptr_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)", ); $op1_is_tmp_free = array( @@ -387,52 +387,67 @@ function gen_code($f, $spec, $kind, $export, $code, $op1, $op2, $name) { // Updating code according to selected threading model switch($kind) { case ZEND_VM_KIND_CALL: - $code = preg_replace( + $code = preg_replace_callback( array( "/EXECUTE_DATA/m", "/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m", - "/ZEND_VM_DISPATCH_TO_HELPER\(\s*([A-Za-z_]*)\s*\)/me", - "/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*[A-Za-z_]*\s*,\s*(.*)\s*\);/me", - ), - array( - "execute_data", - "return \\1".($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)", - "'return '.helper_name('\\1',$spec,'$op1','$op2').'(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)'", - "'return '.helper_name('\\1',$spec,'$op1','$op2').'(\\2, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);'", + "/ZEND_VM_DISPATCH_TO_HELPER\(\s*([A-Za-z_]*)\s*\)/m", + "/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*[A-Za-z_]*\s*,\s*(.*)\s*\);/m", ), + function($matches) use ($spec, $prefix, $op1, $op2) { + if (strncasecmp($matches[0], "EXECUTE_DATA", strlen("EXECUTE_DATA")) == 0) { + return "execute_data"; + } else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HANDLER", strlen("ZEND_VM_DISPATCH_TO_HANDLER")) == 0) { + return "return " . $matches[1] . ($spec?"_SPEC":"") . $prefix[$op1] . $prefix[$op2] . "_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)"; + } else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HELPER_EX", strlen("ZEND_VM_DISPATCH_TO_HELPER_EX")) == 0) { + return "return " . helper_name($matches[1], $spec, $op1, $op2) . "(" . $matches[2]. ", ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);"; + } else { + return "return " . helper_name($matches[1], $spec, $op1, $op2) . "(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)"; + } + }, $code); break; case ZEND_VM_KIND_SWITCH: - $code = preg_replace( + $code = preg_replace_callback( array( "/EXECUTE_DATA/m", "/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m", - "/ZEND_VM_DISPATCH_TO_HELPER\(\s*([A-Za-z_]*)\s*\)/me", - "/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*([A-Za-z_]*)\s*,\s*(.*)\s*\);/me", - ), - array( - "execute_data", - "goto \\1".($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_LABEL", - "'goto '.helper_name('\\1',$spec,'$op1','$op2')", - "'\\2 = \\3; goto '.helper_name('\\1',$spec,'$op1','$op2').';'", + "/ZEND_VM_DISPATCH_TO_HELPER\(\s*([A-Za-z_]*)\s*\)/m", + "/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*([A-Za-z_]*)\s*,\s*(.*)\s*\);/m", ), - $code); + function($matches) use ($spec, $prefix, $op1, $op2) { + if (strncasecmp($matches[0], "EXECUTE_DATA", strlen("EXECUTE_DATA")) == 0) { + return "execute_data"; + } else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HANDLER", strlen("ZEND_VM_DISPATCH_TO_HANDLER")) == 0) { + return "goto " . $matches[1] . ($spec?"_SPEC":"") . $prefix[$op1] . $prefix[$op2] . "_LABEL"; + } else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HELPER_EX", strlen("ZEND_VM_DISPATCH_TO_HELPER_EX")) == 0) { + return $matches[2] . " = " . $matches[3] . "; goto " . helper_name($matches[1], $spec, $op1, $op2) . ";"; + } else { + return "goto " . helper_name($matches[1], $spec, $op1, $op2); + } + }, + $code); break; case ZEND_VM_KIND_GOTO: - $code = preg_replace( + $code = preg_replace_callback( array( "/EXECUTE_DATA/m", "/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m", - "/ZEND_VM_DISPATCH_TO_HELPER\(\s*([A-Za-z_]*)\s*\)/me", - "/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*([A-Za-z_]*)\s*,\s*(.*)\s*\);/me", + "/ZEND_VM_DISPATCH_TO_HELPER\(\s*([A-Za-z_]*)\s*\)/m", + "/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*([A-Za-z_]*)\s*,\s*(.*)\s*\);/m", ), - array( - "execute_data", - "goto \\1".($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_HANDLER", - "'goto '.helper_name('\\1',$spec,'$op1','$op2')", - "'\\2 = \\3; goto '.helper_name('\\1',$spec,'$op1','$op2').';'", - ), - $code); + function($matches) use ($spec, $prefix, $op1, $op2) { + if (strncasecmp($matches[0], "EXECUTE_DATA", strlen("EXECUTE_DATA")) == 0) { + return "execute_data"; + } else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HANDLER", strlen("ZEND_VM_DISPATCH_TO_HANDLER")) == 0) { + return "goto " . $matches[1] . ($spec?"_SPEC":"") . $prefix[$op1] . $prefix[$op2] . "_HANDLER"; + } else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HELPER_EX", strlen("ZEND_VM_DISPATCH_TO_HELPER_EX")) == 0) { + return $matches[2] . " = " . $matches[3] . "; goto " . helper_name($matches[1], $spec, $op1, $op2) . ";"; + } else { + return "goto " . helper_name($matches[1], $spec, $op1, $op2); + } + }, + $code); break; } @@ -695,6 +710,7 @@ function gen_null_handler($f) { out($f,"static int ZEND_FASTCALL ZEND_NULL_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n"); out($f,"{\n"); out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n"); + out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n"); out($f,"}\n\n"); } } @@ -769,10 +785,12 @@ function gen_executor_code($f, $spec, $kind, $prolog) { case ZEND_VM_KIND_SWITCH: out($f,"default:\n"); out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n"); + out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n"); break; case ZEND_VM_KIND_GOTO: out($f,"ZEND_NULL_HANDLER:\n"); out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n"); + out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n"); break; } } @@ -824,16 +842,6 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, out($f,"#define ZEND_VM_LEAVE() return 3\n"); out($f,"#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\n"); out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n"); - out($f,"#undef EX\n"); - out($f,"#define EX(element) execute_data->element\n\n"); - out($f,"#undef EX_CV\n"); - out($f,"#define EX_CV(var) EX(CVs)[var]\n"); - out($f,"#undef EX_CVs\n"); - out($f,"#define EX_CVs() EX(CVs)\n"); - out($f,"#undef EX_T\n"); - out($f,"#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset))\n"); - out($f,"#undef EX_Ts\n"); - out($f,"#define EX_Ts() EX(Ts)\n\n"); break; case ZEND_VM_KIND_SWITCH: out($f,"\n"); @@ -853,23 +861,13 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, out($f,"#define CHECK_EXCEPTION() LOAD_OPLINE()\n"); out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n"); out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n"); - out($f,"#define LOAD_REGS() do {Ts = EX(Ts); CVs = EX(CVs);} while (0)\n"); + out($f,"#define LOAD_REGS()\n"); out($f,"#define ZEND_VM_CONTINUE() goto zend_vm_continue\n"); out($f,"#define ZEND_VM_RETURN() EG(in_execution) = original_in_execution; return\n"); - out($f,"#define ZEND_VM_ENTER() op_array = EG(active_op_array); goto zend_vm_enter\n"); + out($f,"#define ZEND_VM_ENTER() goto zend_vm_enter\n"); out($f,"#define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n"); out($f,"#define ZEND_VM_DISPATCH(opcode, opline) dispatch_handler = zend_vm_get_opcode_handler(opcode, opline); goto zend_vm_dispatch;\n\n"); out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n"); - out($f,"#undef EX\n"); - out($f,"#define EX(element) execute_data->element\n\n"); - out($f,"#undef EX_CV\n"); - out($f,"#define EX_CV(var) CVs[var]\n"); - out($f,"#undef EX_CVs\n"); - out($f,"#define EX_CVs() CVs\n"); - out($f,"#undef EX_T\n"); - out($f,"#define EX_T(offset) T(offset)\n"); - out($f,"#undef EX_Ts\n"); - out($f,"#define EX_Ts() Ts\n\n"); break; case ZEND_VM_KIND_GOTO: out($f,"\n"); @@ -889,23 +887,13 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, out($f,"#define CHECK_EXCEPTION() if (UNEXPECTED(EG(exception) != NULL)) goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n"); out($f,"#define HANDLE_EXCEPTION() goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n"); out($f,"#define HANDLE_EXCEPTION_LEAVE() goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n"); - out($f,"#define LOAD_REGS() do {Ts = EX(Ts); CVs = EX(CVs);} while (0)\n"); + out($f,"#define LOAD_REGS()\n"); out($f,"#define ZEND_VM_CONTINUE() goto *(void**)(OPLINE->handler)\n"); out($f,"#define ZEND_VM_RETURN() EG(in_execution) = original_in_execution; return\n"); - out($f,"#define ZEND_VM_ENTER() op_array = EG(active_op_array); goto zend_vm_enter\n"); + out($f,"#define ZEND_VM_ENTER() goto zend_vm_enter\n"); out($f,"#define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n"); out($f,"#define ZEND_VM_DISPATCH(opcode, opline) goto *(void**)(zend_vm_get_opcode_handler(opcode, opline));\n\n"); out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n"); - out($f,"#undef EX\n"); - out($f,"#define EX(element) execute_data->element\n\n"); - out($f,"#undef EX_CV\n"); - out($f,"#define EX_CV(var) CVs[var]\n"); - out($f,"#undef EX_CVs\n"); - out($f,"#define EX_CVs() CVs\n"); - out($f,"#undef EX_T\n"); - out($f,"#define EX_T(offset) T(offset)\n\n"); - out($f,"#undef EX_Ts\n"); - out($f,"#define EX_Ts() Ts\n\n"); break; } break; @@ -914,8 +902,6 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, break; case "HELPER_VARS": if ($kind != ZEND_VM_KIND_CALL) { - out($f,$m[1]."temp_variable *Ts;\n"); - out($f,$m[1]."zval ***CVs;\n"); if ($kind == ZEND_VM_KIND_SWITCH) { out($f,$m[1]."opcode_handler_t dispatch_handler;\n"); } @@ -927,19 +913,12 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, skip_blanks($f, $m[1], $m[3]."\n"); } break; - case "EXECUTION_STATUS": - if ($kind != ZEND_VM_KIND_GOTO) { - out($f, $m[1] . "zend_bool original_in_execution = EG(in_execution);\n"); - } else { - out($f, $m[1] . "zend_bool original_in_execution = op_array? EG(in_execution) : 0;\n"); - } - break; case "INTERNAL_LABELS": if ($kind == ZEND_VM_KIND_GOTO) { // Emit array of labels of opcode handlers and code for // zend_opcode_handlers initialization $prolog = $m[1]; - out($f,$prolog."if (op_array == NULL) {\n"); + out($f,$prolog."if (execute_data == NULL) {\n"); out($f,$prolog."\tstatic const opcode_handler_t labels[] = {\n"); gen_labels($f, $spec, $kind, $prolog."\t\t"); out($f,$prolog."\t};\n"); @@ -983,10 +962,11 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, $m[1]."\t\tEG(in_execution) = original_in_execution;\n". $m[1]."\t\treturn;\n". $m[1]."\tcase 2:\n" . - $m[1]."\t\top_array = EG(active_op_array);\n". $m[1]."\t\tgoto zend_vm_enter;\n". + $m[1]."\t\tbreak;\n" . $m[1]."\tcase 3:\n" . $m[1]."\t\texecute_data = EG(current_execute_data);\n". + $m[1]."\t\tbreak;\n" . $m[1]."\tdefault:\n". $m[1]."\t\tbreak;\n". $m[1]."}".$m[3]."\n"); @@ -1013,9 +993,9 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, $prolog = $m[1]; if ($kind == ZEND_VM_KIND_GOTO) { // Labels are defined in the executor itself, so we call it - // with op_array NULL and it sets zend_opcode_handlers array + // with execute_data NULL and it sets zend_opcode_handlers array out($f,$prolog."TSRMLS_FETCH();\n"); - out($f,$prolog."zend_execute(NULL TSRMLS_CC);\n"); + out($f,$prolog.$executor_name."_ex(NULL TSRMLS_CC);\n"); } else { if ($old) { // Reserving space for user-defined opcodes @@ -1189,7 +1169,7 @@ function gen_vm($def, $skel) { // Generate opcode #defines (zend_vm_opcodes.h) $code_len = strlen((string)$max_opcode); - $f = fopen("zend_vm_opcodes.h", "w+") or die("ERROR: Cannot create zend_vm_opcodes.h\n"); + $f = fopen(__DIR__ . "/zend_vm_opcodes.h", "w+") or die("ERROR: Cannot create zend_vm_opcodes.h\n"); // Insert header out($f, $GLOBALS['header_text']); @@ -1203,8 +1183,8 @@ function gen_vm($def, $skel) { echo "zend_vm_opcodes.h generated successfully.\n"; // Generate zend_vm_execute.h - $f = fopen("zend_vm_execute.h", "w+") or die("ERROR: Cannot create zend_vm_execute.h\n"); - $executor_file = realpath("zend_vm_execute.h"); + $f = fopen(__DIR__ . "/zend_vm_execute.h", "w+") or die("ERROR: Cannot create zend_vm_execute.h\n"); + $executor_file = realpath(__DIR__ . "/zend_vm_execute.h"); // Insert header out($f, $GLOBALS['header_text']); @@ -1232,14 +1212,6 @@ function gen_vm($def, $skel) { // Generate un-specialized executor if (ZEND_VM_OLD_EXECUTOR) { out($f,"\n/* Old executor */\n\n"); - out($f,"#undef EX\n"); - out($f,"#define EX(element) execute_data.element\n\n"); - out($f,"#undef EX_CV\n"); - out($f,"#define EX_CV(var) EX(CVs)[var]\n"); - out($f,"#undef EX_CVs\n"); - out($f,"#define EX_CVs() EX(CVs)\n"); - out($f,"#undef EX_T\n"); - out($f,"#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset))\n\n"); out($f,"#undef ZEND_VM_CONTINUE\n\n"); out($f,"#undef ZEND_VM_RETURN\n\n"); out($f,"#undef ZEND_VM_ENTER\n\n"); @@ -1312,14 +1284,6 @@ function gen_vm($def, $skel) { out($f,"#define CHECK_EXCEPTION() LOAD_OPLINE()\n"); out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n"); out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n"); - out($f,"#undef EX\n"); - out($f,"#define EX(element) execute_data->element\n\n"); - out($f,"#undef EX_CV\n"); - out($f,"#define EX_CV(var) EX(CVs)[var]\n"); - out($f,"#undef EX_CVs\n"); - out($f,"#define EX_CVs() EX(CVs)\n"); - out($f,"#undef EX_T\n"); - out($f,"#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset))\n\n"); out($f,"#undef ZEND_VM_CONTINUE\n"); out($f,"#undef ZEND_VM_RETURN\n"); out($f,"#undef ZEND_VM_ENTER\n"); @@ -1447,6 +1411,6 @@ function usage() { define("ZEND_VM_LINES", 0); } -gen_vm("zend_vm_def.h", "zend_vm_execute.skl"); +gen_vm(__DIR__ . "/zend_vm_def.h", __DIR__ . "/zend_vm_execute.skl"); ?> diff --git a/Zend/zend_vm_opcodes.h b/Zend/zend_vm_opcodes.h index 94e69abf1e886..859258a440bef 100644 --- a/Zend/zend_vm_opcodes.h +++ b/Zend/zend_vm_opcodes.h @@ -159,3 +159,8 @@ #define ZEND_SEPARATE 156 #define ZEND_QM_ASSIGN_VAR 157 #define ZEND_JMP_SET_VAR 158 +#define ZEND_DISCARD_EXCEPTION 159 +#define ZEND_YIELD 160 +#define ZEND_GENERATOR_RETURN 161 +#define ZEND_FAST_CALL 162 +#define ZEND_FAST_RET 163 diff --git a/acinclude.m4 b/acinclude.m4 index adb9599ce4887..aadf4c06ee8dc 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -2226,7 +2226,7 @@ AC_DEFUN([PHP_SETUP_ICU],[ AC_MSG_RESULT([$icu_install_prefix]) dnl Check ICU version - AC_MSG_CHECKING([for ICU 3.4 or greater]) + AC_MSG_CHECKING([for ICU 4.0 or greater]) icu_version_full=`$ICU_CONFIG --version` ac_IFS=$IFS IFS="." @@ -2235,8 +2235,8 @@ AC_DEFUN([PHP_SETUP_ICU],[ icu_version=`expr [$]1 \* 1000 + [$]2` AC_MSG_RESULT([found $icu_version_full]) - if test "$icu_version" -lt "3004"; then - AC_MSG_ERROR([ICU version 3.4 or later is required]) + if test "$icu_version" -lt "4000"; then + AC_MSG_ERROR([ICU version 4.0 or later is required]) fi ICU_VERSION=$icu_version @@ -2932,6 +2932,9 @@ dnl Add providerdesc.o into global objects when needed *solaris*) PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.o" ;; + *linux*) + PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.o" + ;; esac dnl DTrace objects @@ -2960,12 +2963,12 @@ dnl Generate Makefile.objects entries cat>>Makefile.objects<. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,16 +25,16 @@ timestamp='2008-01-23' # the same distribution terms that you use for the rest of that program. -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# Originally written by Per Bothner. Please send patches (context +# diff format) to and include a ChangeLog +# entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` @@ -56,8 +54,9 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, +2012, 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -144,7 +143,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -170,7 +169,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null + | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? @@ -180,7 +179,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in fi ;; *) - os=netbsd + os=netbsd ;; esac # The OS release @@ -201,6 +200,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} @@ -223,7 +226,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -269,7 +272,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead @@ -295,12 +301,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo s390-ibm-zvmoe exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 + echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) + arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -324,14 +330,33 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize @@ -375,23 +400,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; @@ -461,8 +486,8 @@ EOF echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ @@ -475,7 +500,7 @@ EOF else echo i586-dg-dgux${UNAME_RELEASE} fi - exit ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; @@ -575,52 +600,52 @@ EOF 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + esac ;; + esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + sed 's/^ //' << EOF >$dummy.c - #define _HPUX_SOURCE - #include - #include + #define _HPUX_SOURCE + #include + #include - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa @@ -640,7 +665,7 @@ EOF # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null + grep -q __LP64__ then HP_ARCH="hppa2.0w" else @@ -711,22 +736,22 @@ EOF exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit ;; + exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; @@ -750,14 +775,14 @@ EOF exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} @@ -769,34 +794,39 @@ EOF echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) - case ${UNAME_MACHINE} in - pc98) - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; + i*:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; - *:Interix*:[3456]*) - case ${UNAME_MACHINE} in + *:Interix*:*) + case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; - EM64T | authenticamd) + authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) @@ -806,6 +836,9 @@ EOF [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we @@ -835,6 +868,27 @@ EOF i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ @@ -842,20 +896,40 @@ EOF then echo ${UNAME_MACHINE}-unknown-linux-gnu else - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) - echo cris-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) - echo frv-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + LIBC=gnu + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -866,74 +940,33 @@ EOF m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; - mips:Linux:*:*) + mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU - #undef mips - #undef mipsel + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel + CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips + CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) - echo or32-unknown-linux-gnu - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu + padre:Linux:*:*) + echo sparc-unknown-linux-gnu exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level @@ -943,14 +976,17 @@ EOF *) echo hppa-unknown-linux-gnu ;; esac exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -958,78 +994,18 @@ EOF sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^LIBC/{ - s: ::g - p - }'`" - test x"${LIBC}" != x && { - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit - } - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } - ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both @@ -1037,11 +1013,11 @@ EOF echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. + # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) @@ -1058,7 +1034,7 @@ EOF i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) @@ -1073,7 +1049,7 @@ EOF fi exit ;; i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; @@ -1101,10 +1077,13 @@ EOF exit ;; pc:*:*:*) # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit ;; + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; @@ -1139,8 +1118,18 @@ EOF /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; @@ -1153,7 +1142,7 @@ EOF rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) @@ -1173,10 +1162,10 @@ EOF echo ns32k-sni-sysv fi exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm @@ -1202,11 +1191,11 @@ EOF exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv${UNAME_RELEASE} fi - exit ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; @@ -1216,6 +1205,12 @@ EOF BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; @@ -1243,6 +1238,16 @@ EOF *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in + i386) + eval $set_cc_for_build + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + UNAME_PROCESSOR="x86_64" + fi + fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} @@ -1258,7 +1263,10 @@ EOF *:QNX:*:4*) echo i386-pc-qnx exit ;; - NSE-?:NONSTOP_KERNEL:*:*) + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) @@ -1303,13 +1311,13 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` + UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; @@ -1324,11 +1332,14 @@ EOF i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; esac -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - eval $set_cc_for_build cat >$dummy.c < printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 - "4" + "4" #else - "" + "" #endif - ); exit (0); + ); exit (0); #endif #endif diff --git a/config.sub b/config.sub index 6759825a5b7fc..eee8dccb05c1b 100644 --- a/config.sub +++ b/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 -# Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011, 2012, 2013 Free Software Foundation, Inc. -timestamp='2008-01-16' +timestamp='2012-12-23' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -21,9 +21,7 @@ timestamp='2008-01-16' # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -32,13 +30,16 @@ timestamp='2008-01-16' # Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. @@ -72,8 +73,9 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, +2012, 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -120,12 +122,18 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] @@ -148,10 +156,13 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) + -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; + -bluegene*) + os=-cnk + ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 @@ -166,10 +177,10 @@ case $os in os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -chorusrdb) + os=-chorusrdb basic_machine=$1 - ;; + ;; -hiux*) os=-hiuxwe2 ;; @@ -214,6 +225,12 @@ case $os in -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; -lynx*) os=-lynxos ;; @@ -238,24 +255,34 @@ case $basic_machine in # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ + | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | arc \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ + | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | le32 | le64 \ + | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ - | mips64vr | mips64vrel \ + | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ @@ -268,29 +295,42 @@ case $basic_machine in | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | moxie \ | mt \ | msp430 \ + | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ + | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ + | rl78 | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) basic_machine=$basic_machine-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; @@ -300,6 +340,21 @@ case $basic_machine in basic_machine=mt-unknown ;; + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. @@ -314,29 +369,37 @@ case $basic_machine in # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ + | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | be32-* | be64-* \ | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | le32-* | le64-* \ + | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ + | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ @@ -351,27 +414,32 @@ case $basic_machine in | mmix-* \ | mt-* \ | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ | tron-* \ - | v850-* | v850e-* | vax-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ - | z8k-*) + | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) @@ -393,7 +461,7 @@ case $basic_machine in basic_machine=a29k-amd os=-udi ;; - abacus) + abacus) basic_machine=abacus-unknown ;; adobe68k) @@ -439,6 +507,10 @@ case $basic_machine in basic_machine=m68k-apollo os=-bsd ;; + aros) + basic_machine=i386-pc + os=-aros + ;; aux) basic_machine=m68k-apple os=-aux @@ -455,10 +527,27 @@ case $basic_machine in basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; c90) basic_machine=c90-cray os=-unicos ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; convex-c1) basic_machine=c1-convex os=-bsd @@ -487,7 +576,7 @@ case $basic_machine in basic_machine=craynv-cray os=-unicosmp ;; - cr16) + cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; @@ -526,6 +615,10 @@ case $basic_machine in basic_machine=m88k-motorola os=-sysv3 ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp @@ -641,7 +734,6 @@ case $basic_machine in i370-ibm* | ibm*) basic_machine=i370-ibm ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 @@ -699,6 +791,13 @@ case $basic_machine in basic_machine=ns32k-utek os=-sysv ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; mingw32) basic_machine=i386-pc os=-mingw32 @@ -735,10 +834,18 @@ case $basic_machine in ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; + msys) + basic_machine=i386-pc + os=-msys + ;; mvs) basic_machine=i370-ibm os=-mvs ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -803,6 +910,12 @@ case $basic_machine in np1) basic_machine=np1-gould ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -885,9 +998,10 @@ case $basic_machine in ;; power) basic_machine=power-ibm ;; - ppc) basic_machine=powerpc-unknown + ppc | ppcbe) basic_machine=powerpc-unknown ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown @@ -912,7 +1026,11 @@ case $basic_machine in basic_machine=i586-unknown os=-pw32 ;; - rdos) + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) basic_machine=i386-pc os=-rdos ;; @@ -981,6 +1099,9 @@ case $basic_machine in basic_machine=i860-stratus os=-sysv4 ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; sun2) basic_machine=m68000-sun ;; @@ -1037,20 +1158,8 @@ case $basic_machine in basic_machine=t90-cray os=-unicos ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; tile*) - basic_machine=tile-unknown + basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) @@ -1120,6 +1229,9 @@ case $basic_machine in xps | xps100) basic_machine=xps100-honeywell ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; ymp) basic_machine=ymp-cray os=-unicos @@ -1128,6 +1240,10 @@ case $basic_machine in basic_machine=z8k-unknown os=-sim ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; none) basic_machine=none-none os=-none @@ -1166,7 +1282,7 @@ case $basic_machine in we32k) basic_machine=we32k-att ;; - sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) @@ -1213,9 +1329,12 @@ esac if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; @@ -1236,21 +1355,23 @@ case $os in # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ + | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ @@ -1258,7 +1379,7 @@ case $os in | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1297,7 +1418,7 @@ case $os in -opened*) os=-openedition ;; - -os400*) + -os400*) os=-os400 ;; -wince*) @@ -1346,7 +1467,7 @@ case $os in -sinix*) os=-sysv4 ;; - -tpf*) + -tpf*) os=-tpf ;; -triton*) @@ -1388,6 +1509,11 @@ case $os in -zvmoe) os=-zvmoe ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; -none) ;; *) @@ -1410,10 +1536,10 @@ else # system, and we'll never get to this point. case $basic_machine in - score-*) + score-*) os=-elf ;; - spu-*) + spu-*) os=-elf ;; *-acorn) @@ -1425,8 +1551,20 @@ case $basic_machine in arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff + c4x-* | tic4x-*) + os=-coff + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1446,14 +1584,11 @@ case $basic_machine in ;; m68000-sun) os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 ;; m68*-cisco) os=-aout ;; - mep-*) + mep-*) os=-elf ;; mips*-cisco) @@ -1480,7 +1615,7 @@ case $basic_machine in *-ibm) os=-aix ;; - *-knuth) + *-knuth) os=-mmixware ;; *-wec) @@ -1585,7 +1720,7 @@ case $basic_machine in -sunos*) vendor=sun ;; - -aix*) + -cnk*|-aix*) vendor=ibm ;; -beos*) diff --git a/configure.in b/configure.in index 3597c24afa02f..9811236f12dd8 100644 --- a/configure.in +++ b/configure.in @@ -118,8 +118,8 @@ int zend_sprintf(char *buffer, const char *format, ...); ]) PHP_MAJOR_VERSION=5 -PHP_MINOR_VERSION=4 -PHP_RELEASE_VERSION=13 +PHP_MINOR_VERSION=6 +PHP_RELEASE_VERSION=0 PHP_EXTRA_VERSION="-dev" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION` @@ -784,7 +784,7 @@ if test "$PHP_GCOV" = "yes"; then AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) fi - ltp_version_list="1.5 1.6 1.7" + ltp_version_list="1.5 1.6 1.7 1.9" AC_CHECK_PROG(LTP, lcov, lcov) AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml) @@ -1443,7 +1443,7 @@ PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c php_sprintf.c \ fopen_wrappers.c alloca.c php_scandir.c \ php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \ strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c \ - network.c php_open_temporary_file.c php_logos.c \ + network.c php_open_temporary_file.c \ output.c getopt.c) PHP_ADD_SOURCES(main/streams, streams.c cast.c memory.c filter.c \ @@ -1472,7 +1472,7 @@ PHP_ADD_SOURCES(Zend, \ zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \ zend_ini.c zend_qsort.c zend_multibyte.c zend_ts_hash.c zend_stream.c \ zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c zend_gc.c \ - zend_closures.c zend_float.c zend_string.c zend_signal.c) + zend_closures.c zend_float.c zend_string.c zend_signal.c zend_generators.c) if test -r "$abs_srcdir/Zend/zend_objects.c"; then PHP_ADD_SOURCES(Zend, zend_objects.c zend_object_handlers.c zend_objects_API.c zend_default_classes.c) @@ -1587,9 +1587,9 @@ cat <month_name_short[month], 1); - add_assoc_string(return_value, "monthname", calendar->month_name_long[month], 1); + if(cal == CAL_JEWISH) { + /* special case for Jewish calendar */ + add_assoc_string(return_value, "abbrevmonth", JEWISH_MONTH_NAME(year)[month], 1); + add_assoc_string(return_value, "monthname", JEWISH_MONTH_NAME(year)[month], 1); + } else { + add_assoc_string(return_value, "abbrevmonth", calendar->month_name_short[month], 1); + add_assoc_string(return_value, "monthname", calendar->month_name_long[month], 1); + } } /* }}} */ @@ -608,7 +617,7 @@ PHP_FUNCTION(jdtojewish) RETURN_FALSE; } - snprintf(hebdate, sizeof(hebdate), "%s %s %s", heb_number_to_chars(day, fl, &dayp), JewishMonthHebName[month], heb_number_to_chars(year, fl, &yearp)); + snprintf(hebdate, sizeof(hebdate), "%s %s %s", heb_number_to_chars(day, fl, &dayp), JEWISH_HEB_MONTH_NAME(year)[month], heb_number_to_chars(year, fl, &yearp)); if (dayp) { efree(dayp); @@ -728,7 +737,7 @@ PHP_FUNCTION(jdmonthname) break; case CAL_MONTH_JEWISH: /* jewish month */ SdnToJewish(julday, &year, &month, &day); - monthname = JewishMonthName[month]; + monthname = JEWISH_MONTH_NAME(year)[month]; break; case CAL_MONTH_FRENCH: /* french month */ SdnToFrench(julday, &year, &month, &day); diff --git a/ext/calendar/jewish.c b/ext/calendar/jewish.c index f4dc7c35ae57c..9e5b0beced7ab 100644 --- a/ext/calendar/jewish.c +++ b/ext/calendar/jewish.c @@ -85,8 +85,8 @@ * 3 Kislev 29 30 30 29 30 30 (variable) * 4 Tevet 29 29 29 29 29 29 * 5 Shevat 30 30 30 30 30 30 - * 6 Adar I 29 29 29 30 30 30 (variable) - * 7 Adar II -- -- -- 29 29 29 (optional) + * 6 Adar I -- -- -- 30 30 30 (optional) + * 7 Adar (II) 29 29 29 29 29 29 * 8 Nisan 30 30 30 30 30 30 * 9 Iyyar 29 29 29 29 29 29 * 10 Sivan 30 30 30 30 30 30 @@ -100,8 +100,8 @@ * have multiple possible spellings in the Roman character set. I have * chosen to use the spellings found in the Encyclopedia Judaica. * - * Adar II, the month added for leap years, is sometimes referred to as - * the 13th month, but I have chosen to assign it the number 7 to keep + * Adar I, the month added for leap years, is sometimes referred to as + * the 13th month, but I have chosen to assign it the number 6 to keep * the months in chronological order. This may not be consistent with * other numbering schemes. * @@ -286,7 +286,7 @@ #define AM3_11_20 ((9 * HALAKIM_PER_HOUR) + 204) #define AM9_32_43 ((15 * HALAKIM_PER_HOUR) + 589) -static int monthsPerYear[19] = +int monthsPerYear[19] = { 12, 12, 13, 12, 12, 13, 12, 13, 12, 12, 13, 12, 12, 13, 12, 12, 13, 12, 13 }; @@ -297,16 +297,36 @@ static int yearOffset[19] = 136, 148, 160, 173, 185, 197, 210, 222 }; +/* names for leap (13-month) year */ +char *JewishMonthNameLeap[14] = +{ + "", + "Tishri", + "Heshvan", + "Kislev", + "Tevet", + "Shevat", + "Adar I", + "Adar II", + "Nisan", + "Iyyar", + "Sivan", + "Tammuz", + "Av", + "Elul" +}; + +/* names for regular year */ char *JewishMonthName[14] = { - "", + "", "Tishri", "Heshvan", "Kislev", "Tevet", "Shevat", - "AdarI", - "AdarII", + "", + "Adar", "Nisan", "Iyyar", "Sivan", @@ -315,16 +335,36 @@ char *JewishMonthName[14] = "Elul" }; +/* names for leap (13-month) year */ +char *JewishMonthHebNameLeap[14] = +{ + "", + "", + "", + "", + "", + "", + " '", + " '", + "", + "", + "", + "", + "", + "" +}; + +/* names for regular year */ char *JewishMonthHebName[14] = { - "", + "", "", "", "", "", "", + "", "", - "' ", "", "", "", @@ -587,11 +627,11 @@ void SdnToJewish( (*pMonth)--; (*pDay) += 30; } else { - *pMonth = 6; + *pMonth = 7; *pDay = inputDay - tishri1 + 207; if (*pDay > 0) return; - (*pMonth)--; + (*pMonth) -= 2; (*pDay) += 30; } if (*pDay > 0) diff --git a/ext/calendar/sdncal.h b/ext/calendar/sdncal.h index 81328d1369cf5..c0463c80d45e6 100644 --- a/ext/calendar/sdncal.h +++ b/ext/calendar/sdncal.h @@ -79,7 +79,10 @@ long int JulianToSdn(int year, int month, int day); void SdnToJewish(long int sdn, int *pYear, int *pMonth, int *pDay); long int JewishToSdn(int year, int month, int day); extern char *JewishMonthName[14]; +extern char *JewishMonthNameLeap[14]; extern char *JewishMonthHebName[14]; +extern char *JewishMonthHebNameLeap[14]; +extern int monthsPerYear[19]; /* French republic calendar conversions. */ void SdnToFrench(long int sdn, int *pYear, int *pMonth, int *pDay); diff --git a/ext/calendar/tests/bug54254.phpt b/ext/calendar/tests/bug54254.phpt new file mode 100644 index 0000000000000..df9362320c0a6 --- /dev/null +++ b/ext/calendar/tests/bug54254.phpt @@ -0,0 +1,59 @@ +--TEST-- +Bug #54254 (cal_days_in_month incompatible with jdtojewish in non-leap-years) +--SKIPIF-- + +--FILE-- + Kislev [4] => Tevet [5] => Shevat - [6] => AdarI - [7] => AdarII + [6] => Adar I + [7] => Adar II [8] => Nisan [9] => Iyyar [10] => Sivan @@ -117,8 +117,8 @@ Array [3] => Kislev [4] => Tevet [5] => Shevat - [6] => AdarI - [7] => AdarII + [6] => Adar I + [7] => Adar II [8] => Nisan [9] => Iyyar [10] => Sivan diff --git a/ext/calendar/tests/jdmonthname.phpt b/ext/calendar/tests/jdmonthname.phpt index d05d3c595efca..07ed1161b1753 100644 --- a/ext/calendar/tests/jdmonthname.phpt +++ b/ext/calendar/tests/jdmonthname.phpt @@ -75,8 +75,8 @@ December --- mode 4 --- Tevet Shevat -AdarI -AdarII +Adar I +Adar II Nisan Iyyar Sivan @@ -178,7 +178,7 @@ Heshvan Kislev Tevet Shevat -AdarI +Adar Nisan Iyyar Sivan @@ -279,7 +279,7 @@ Heshvan Kislev Tevet Shevat -AdarI +Adar Nisan Iyyar Sivan diff --git a/ext/calendar/tests/jdtojewish.phpt b/ext/calendar/tests/jdtojewish.phpt index 484b95749cca9..bc0ecbdd88ec2 100644 --- a/ext/calendar/tests/jdtojewish.phpt +++ b/ext/calendar/tests/jdtojewish.phpt @@ -14,10 +14,11 @@ var_dump(jdtojewish(gregoriantojd(10,28,2002))."\r\n". jdtojewish(gregoriantojd(10,8,2002),true, CAL_JEWISH_ADD_GERESHAYIM)."\r\n". jdtojewish(gregoriantojd(10,8,2002),true, CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM_GERESH)."\r\n". jdtojewish(gregoriantojd(10,8,2002),true, CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM)."\r\n". - jdtojewish(gregoriantojd(10,8,2002),true, CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM+CAL_JEWISH_ADD_ALAFIM_GERESH)."\r\n"); + jdtojewish(gregoriantojd(10,8,2002),true, CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM+CAL_JEWISH_ADD_ALAFIM_GERESH)."\r\n". + jdtojewish(gregoriantojd(3,10,2007))."\r\n"); ?> ---EXPECT-- -string(184) "2/22/5763 +--EXPECTF-- +string(%d) "2/22/5763 ' @@ -27,4 +28,5 @@ string(184) "2/22/5763 ' '" ' " ' ' " +7/20/5767 " diff --git a/ext/curl/config.m4 b/ext/curl/config.m4 index fbb4f5b4e59de..e549330c50c1b 100644 --- a/ext/curl/config.m4 +++ b/ext/curl/config.m4 @@ -131,13 +131,6 @@ int main(int argc, char *argv[]) $CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR ]) - PHP_CHECK_LIBRARY(curl,curl_version_info, - [ - AC_DEFINE(HAVE_CURL_VERSION_INFO,1,[ ]) - ],[],[ - $CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR - ]) - PHP_CHECK_LIBRARY(curl,curl_easy_strerror, [ AC_DEFINE(HAVE_CURL_EASY_STRERROR,1,[ ]) @@ -156,6 +149,6 @@ int main(int argc, char *argv[]) AC_DEFINE(PHP_CURL_URL_WRAPPERS,1,[ ]) fi - PHP_NEW_EXTENSION(curl, interface.c multi.c streams.c, $ext_shared) + PHP_NEW_EXTENSION(curl, interface.c multi.c share.c streams.c curl_file.c, $ext_shared) PHP_SUBST(CURL_SHARED_LIBADD) fi diff --git a/ext/curl/config.w32 b/ext/curl/config.w32 index 930adcfd412e7..5acda7ec9e957 100644 --- a/ext/curl/config.w32 +++ b/ext/curl/config.w32 @@ -13,12 +13,11 @@ if (PHP_CURL != "no") { && (((PHP_ZLIB=="no") && (CHECK_LIB("zlib_a.lib;zlib.lib", "curl", PHP_CURL))) || (PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "curl", PHP_CURL)) || (PHP_ZLIB == "yes" && (!PHP_ZLIB_SHARED))) ) { - EXTENSION("curl", "interface.c multi.c streams.c", true); + EXTENSION("curl", "interface.c multi.c share.c streams.c curl_file.c", true); AC_DEFINE('HAVE_CURL', 1, 'Have cURL library'); AC_DEFINE('HAVE_CURL_SSL', 1, 'Have SSL suppurt in cURL'); AC_DEFINE('HAVE_CURL_EASY_STRERROR', 1, 'Have curl_easy_strerror in cURL'); AC_DEFINE('HAVE_CURL_MULTI_STRERROR', 1, 'Have curl_multi_strerror in cURL'); - AC_DEFINE('HAVE_CURL_VERSION_INFO', 1, 'Have curl_version_info in cURL'); ADD_FLAG("CFLAGS_CURL", "/D CURL_STATICLIB"); // TODO: check for curl_version_info // AC_DEFINE('PHP_CURL_URL_WRAPPERS', 0, 'Use curl for URL wrappers [experimental]'); diff --git a/ext/curl/curl.dsp b/ext/curl/curl.dsp index 81d823183d28a..6524fceb89974 100644 --- a/ext/curl/curl.dsp +++ b/ext/curl/curl.dsp @@ -165,6 +165,10 @@ SOURCE=.\interface.c SOURCE=.\multi.c # End Source File +# Begin Source File +SOURCE=.\share.c +# End Source File + # Begin Source File SOURCE=.\streams.c # End Source File diff --git a/ext/curl/curl_file.c b/ext/curl/curl_file.c new file mode 100644 index 0000000000000..b7cc4495015d8 --- /dev/null +++ b/ext/curl/curl_file.c @@ -0,0 +1,177 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Stanislav Malyshev | + +----------------------------------------------------------------------+ + */ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "php.h" +#include "Zend/zend_exceptions.h" +#include "php_curl.h" +#if HAVE_CURL + +PHP_CURL_API zend_class_entry *curl_CURLFile_class; + +static void curlfile_ctor(INTERNAL_FUNCTION_PARAMETERS) +{ + char *fname = NULL, *mime = NULL, *postname = NULL; + int fname_len, mime_len, postname_len; + zval *cf = return_value; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ss", &fname, &fname_len, &mime, &mime_len, &postname, &postname_len) == FAILURE) { + return; + } + + if (fname) { + zend_update_property_string(curl_CURLFile_class, cf, "name", sizeof("name")-1, fname TSRMLS_CC); + } + + if (mime) { + zend_update_property_string(curl_CURLFile_class, cf, "mime", sizeof("mime")-1, mime TSRMLS_CC); + } + + if (postname) { + zend_update_property_string(curl_CURLFile_class, cf, "postname", sizeof("postname")-1, postname TSRMLS_CC); + } +} + +/* {{{ proto string CURLFile::__construct(string $name, [string $mimetype [, string $postfilename]]) + Create the CURLFile object */ +ZEND_METHOD(CURLFile, __construct) +{ + return_value = getThis(); + curlfile_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ proto string curl_file_create(string $name, [string $mimetype [, string $postfilename]]) + Create the CURLFile object */ +PHP_FUNCTION(curl_file_create) +{ + object_init_ex( return_value, curl_CURLFile_class ); + curlfile_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +static void curlfile_get_property(char *name, INTERNAL_FUNCTION_PARAMETERS) +{ + zval *res; + if (zend_parse_parameters_none() == FAILURE) { + return; + } + res = zend_read_property(curl_CURLFile_class, getThis(), name, strlen(name), 1 TSRMLS_CC); + *return_value = *res; + zval_copy_ctor(return_value); + INIT_PZVAL(return_value); +} + +static void curlfile_set_property(char *name, INTERNAL_FUNCTION_PARAMETERS) +{ + char *arg = NULL; + int arg_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { + return; + } + zend_update_property_string(curl_CURLFile_class, getThis(), name, strlen(name), arg TSRMLS_CC); +} + +/* {{{ proto string CURLFile::getFilename() + Get file name */ +ZEND_METHOD(CURLFile, getFilename) +{ + curlfile_get_property("name", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ proto string CURLFile::getMimeType() + Get MIME type */ +ZEND_METHOD(CURLFile, getMimeType) +{ + curlfile_get_property("mime", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ proto string CURLFile::getPostFilename() + Get file name for POST */ +ZEND_METHOD(CURLFile, getPostFilename) +{ + curlfile_get_property("postname", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ proto string CURLFile::setMimeType(string $mime) + Set MIME type */ +ZEND_METHOD(CURLFile, setMimeType) +{ + curlfile_set_property("mime", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ proto string CURLFile::setPostFilename(string $name) + Set file name for POST */ +ZEND_METHOD(CURLFile, setPostFilename) +{ + curlfile_set_property("postname", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ proto string CURLFile::__wakeup() + Unserialization handler */ +ZEND_METHOD(CURLFile, __wakeup) +{ + zend_update_property_string(curl_CURLFile_class, getThis(), "name", sizeof("name")-1, "" TSRMLS_CC); + zend_throw_exception(NULL, "Unserialization of CURLFile instances is not allowed", 0 TSRMLS_CC); +} +/* }}} */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_curlfile_create, 0, 0, 1) + ZEND_ARG_INFO(0, filename) + ZEND_ARG_INFO(0, mimetype) + ZEND_ARG_INFO(0, postname) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_curlfile_name, 0) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + + +static const zend_function_entry curlfile_funcs[] = { + PHP_ME(CURLFile, __construct, arginfo_curlfile_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(CURLFile, getFilename, NULL, ZEND_ACC_PUBLIC) + PHP_ME(CURLFile, getMimeType, NULL, ZEND_ACC_PUBLIC) + PHP_ME(CURLFile, setMimeType, arginfo_curlfile_name, ZEND_ACC_PUBLIC) + PHP_ME(CURLFile, getPostFilename, NULL, ZEND_ACC_PUBLIC) + PHP_ME(CURLFile, setPostFilename, arginfo_curlfile_name, ZEND_ACC_PUBLIC) + PHP_ME(CURLFile, __wakeup, NULL, ZEND_ACC_PUBLIC) + PHP_FE_END +}; + +void curlfile_register_class(TSRMLS_D) +{ + zend_class_entry ce; + INIT_CLASS_ENTRY( ce, "CURLFile", curlfile_funcs ); + curl_CURLFile_class = zend_register_internal_class(&ce TSRMLS_CC); + zend_declare_property_string(curl_CURLFile_class, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_string(curl_CURLFile_class, "mime", sizeof("mime")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_string(curl_CURLFile_class, "postname", sizeof("postname")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); +} + +#endif diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 531f15ba15f81..ab9e12cd96a25 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -90,6 +90,7 @@ int le_curl; int le_curl_multi_handle; +int le_curl_share_handle; #ifdef PHP_CURL_NEED_OPENSSL_TSL /* {{{ */ static MUTEX_T *php_curl_openssl_tsl = NULL; @@ -261,7 +262,6 @@ int _php_curl_verify_handlers(php_curl *ch, int reporterror TSRMLS_DC) /* {{{ */ ch->handlers->write->stream = NULL; ch->handlers->write->method = PHP_CURL_STDOUT; - ch->handlers->write->type = PHP_CURL_ASCII; curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch); } } @@ -314,6 +314,30 @@ ZEND_BEGIN_ARG_INFO(arginfo_curl_close, 0) ZEND_ARG_INFO(0, ch) ZEND_END_ARG_INFO() +#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */ +ZEND_BEGIN_ARG_INFO(arginfo_curl_reset, 0) + ZEND_ARG_INFO(0, ch) +ZEND_END_ARG_INFO() +#endif + +#if LIBCURL_VERSION_NUM > 0x070f03 /* 7.15.4 */ +ZEND_BEGIN_ARG_INFO(arginfo_curl_escape, 0) + ZEND_ARG_INFO(0, ch) + ZEND_ARG_INFO(0, str) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_curl_unescape, 0) + ZEND_ARG_INFO(0, ch) + ZEND_ARG_INFO(0, str) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_curl_multi_setopt, 0) + ZEND_ARG_INFO(0, sh) + ZEND_ARG_INFO(0, option) + ZEND_ARG_INFO(0, value) +ZEND_END_ARG_INFO() +#endif + ZEND_BEGIN_ARG_INFO(arginfo_curl_multi_init, 0) ZEND_END_ARG_INFO() @@ -349,6 +373,42 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_curl_multi_close, 0) ZEND_ARG_INFO(0, mh) ZEND_END_ARG_INFO() + +#if LIBCURL_VERSION_NUM >= 0x070c00 /* Available since 7.12.0 */ +ZEND_BEGIN_ARG_INFO(arginfo_curl_strerror, 0) + ZEND_ARG_INFO(0, errornum) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_curl_multi_strerror, 0) + ZEND_ARG_INFO(0, errornum) +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_INFO(arginfo_curl_share_init, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_curl_share_close, 0) + ZEND_ARG_INFO(0, sh) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_curl_share_setopt, 0) + ZEND_ARG_INFO(0, sh) + ZEND_ARG_INFO(0, option) + ZEND_ARG_INFO(0, value) +ZEND_END_ARG_INFO() + +#if LIBCURL_VERSION_NUM >= 0x071200 /* Available since 7.18.0 */ +ZEND_BEGIN_ARG_INFO(arginfo_curl_pause, 0) + ZEND_ARG_INFO(0, ch) + ZEND_ARG_INFO(0, bitmask) +ZEND_END_ARG_INFO() +#endif + +ZEND_BEGIN_ARG_INFO_EX(arginfo_curlfile_create, 0, 0, 1) + ZEND_ARG_INFO(0, filename) + ZEND_ARG_INFO(0, mimetype) + ZEND_ARG_INFO(0, postname) +ZEND_END_ARG_INFO() /* }}} */ /* {{{ curl_functions[] @@ -364,6 +424,20 @@ const zend_function_entry curl_functions[] = { PHP_FE(curl_error, arginfo_curl_error) PHP_FE(curl_errno, arginfo_curl_errno) PHP_FE(curl_close, arginfo_curl_close) +#if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */ + PHP_FE(curl_strerror, arginfo_curl_strerror) + PHP_FE(curl_multi_strerror, arginfo_curl_multi_strerror) +#endif +#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */ + PHP_FE(curl_reset, arginfo_curl_reset) +#endif +#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */ + PHP_FE(curl_escape, arginfo_curl_escape) + PHP_FE(curl_unescape, arginfo_curl_unescape) +#endif +#if LIBCURL_VERSION_NUM >= 0x071200 /* 7.18.0 */ + PHP_FE(curl_pause, arginfo_curl_pause) +#endif PHP_FE(curl_multi_init, arginfo_curl_multi_init) PHP_FE(curl_multi_add_handle, arginfo_curl_multi_add_handle) PHP_FE(curl_multi_remove_handle, arginfo_curl_multi_remove_handle) @@ -372,6 +446,13 @@ const zend_function_entry curl_functions[] = { PHP_FE(curl_multi_getcontent, arginfo_curl_multi_getcontent) PHP_FE(curl_multi_info_read, arginfo_curl_multi_info_read) PHP_FE(curl_multi_close, arginfo_curl_multi_close) +#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */ + PHP_FE(curl_multi_setopt, arginfo_curl_multi_setopt) +#endif + PHP_FE(curl_share_init, arginfo_curl_share_init) + PHP_FE(curl_share_close, arginfo_curl_share_close) + PHP_FE(curl_share_setopt, arginfo_curl_share_setopt) + PHP_FE(curl_file_create, arginfo_curlfile_create) PHP_FE_END }; /* }}} */ @@ -428,42 +509,40 @@ PHP_MINFO_FUNCTION(curl) unsigned int i; static const struct feat feats[] = { -#if LIBCURL_VERSION_NUM > 0x070a06 /* 7.10.7 */ +#if LIBCURL_VERSION_NUM >= 0x070a07 /* 7.10.7 */ {"AsynchDNS", CURL_VERSION_ASYNCHDNS}, #endif -#if LIBCURL_VERSION_NUM > 0x070a05 /* 7.10.6 */ +#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */ + {"CharConv", CURL_VERSION_CONV}, +#endif +#if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */ {"Debug", CURL_VERSION_DEBUG}, {"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE}, #endif -#if LIBCURL_VERSION_NUM > 0x070b02 /* 7.12.0 */ +#if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */ {"IDN", CURL_VERSION_IDN}, #endif -#ifdef CURL_VERSION_IPV6 {"IPv6", CURL_VERSION_IPV6}, -#endif -#if LIBCURL_VERSION_NUM > 0x070b00 /* 7.11.1 */ + {"krb4", CURL_VERSION_KERBEROS4}, +#if LIBCURL_VERSION_NUM >= 0x070b01 /* 7.11.1 */ {"Largefile", CURL_VERSION_LARGEFILE}, #endif -#if LIBCURL_VERSION_NUM > 0x070a05 /* 7.10.6 */ + {"libz", CURL_VERSION_LIBZ}, +#if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */ {"NTLM", CURL_VERSION_NTLM}, #endif -#if LIBCURL_VERSION_NUM > 0x070a07 /* 7.10.8 */ +#if LIBCURL_VERSION_NUM >= 0x071600 /* 7.22.0 */ + {"NTLMWB", CURL_VERSION_NTLM_WB}, +#endif +#if LIBCURL_VERSION_NUM >= 0x070a08 /* 7.10.8 */ {"SPNEGO", CURL_VERSION_SPNEGO}, #endif -#ifdef CURL_VERSION_SSL {"SSL", CURL_VERSION_SSL}, -#endif -#if LIBCURL_VERSION_NUM > 0x070d01 /* 7.13.2 */ +#if LIBCURL_VERSION_NUM >= 0x070d02 /* 7.13.2 */ {"SSPI", CURL_VERSION_SSPI}, #endif -#ifdef CURL_VERSION_KERBEROS4 - {"krb4", CURL_VERSION_KERBEROS4}, -#endif -#ifdef CURL_VERSION_LIBZ - {"libz", CURL_VERSION_LIBZ}, -#endif -#if LIBCURL_VERSION_NUM > 0x070f03 /* 7.15.4 */ - {"CharConv", CURL_VERSION_CONV}, +#if LIBCURL_VERSION_NUM >= 0x071504 /* 7.21.4 */ + {"TLS-SRP", CURL_VERSION_TLSAUTH_SRP}, #endif {NULL, 0} }; @@ -528,6 +607,7 @@ PHP_MINIT_FUNCTION(curl) { le_curl = zend_register_list_destructors_ex(_php_curl_close, NULL, "curl", module_number); le_curl_multi_handle = zend_register_list_destructors_ex(_php_curl_multi_close, NULL, "curl_multi", module_number); + le_curl_share_handle = zend_register_list_destructors_ex(_php_curl_share_close, NULL, "curl_share", module_number); REGISTER_INI_ENTRIES(); @@ -536,357 +616,585 @@ PHP_MINIT_FUNCTION(curl) of options and which version they were introduced */ /* Constants for curl_setopt() */ -#if LIBCURL_VERSION_NUM > 0x070a07 /* CURLOPT_IPRESOLVE is available since curl 7.10.8 */ - REGISTER_CURL_CONSTANT(CURLOPT_IPRESOLVE); - REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_WHATEVER); - REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V4); - REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V6); -#endif - REGISTER_CURL_CONSTANT(CURLOPT_DNS_USE_GLOBAL_CACHE); + REGISTER_CURL_CONSTANT(CURLOPT_AUTOREFERER); + REGISTER_CURL_CONSTANT(CURLOPT_BINARYTRANSFER); + REGISTER_CURL_CONSTANT(CURLOPT_BUFFERSIZE); + REGISTER_CURL_CONSTANT(CURLOPT_CAINFO); + REGISTER_CURL_CONSTANT(CURLOPT_CAPATH); + REGISTER_CURL_CONSTANT(CURLOPT_CLOSEPOLICY); + REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT); + REGISTER_CURL_CONSTANT(CURLOPT_COOKIE); + REGISTER_CURL_CONSTANT(CURLOPT_COOKIEFILE); + REGISTER_CURL_CONSTANT(CURLOPT_COOKIEJAR); + REGISTER_CURL_CONSTANT(CURLOPT_COOKIESESSION); + REGISTER_CURL_CONSTANT(CURLOPT_CRLF); + REGISTER_CURL_CONSTANT(CURLOPT_CUSTOMREQUEST); REGISTER_CURL_CONSTANT(CURLOPT_DNS_CACHE_TIMEOUT); - REGISTER_CURL_CONSTANT(CURLOPT_PORT); + REGISTER_CURL_CONSTANT(CURLOPT_DNS_USE_GLOBAL_CACHE); + REGISTER_CURL_CONSTANT(CURLOPT_EGDSOCKET); + REGISTER_CURL_CONSTANT(CURLOPT_ENCODING); + REGISTER_CURL_CONSTANT(CURLOPT_FAILONERROR); REGISTER_CURL_CONSTANT(CURLOPT_FILE); - REGISTER_CURL_CONSTANT(CURLOPT_READDATA); - REGISTER_CURL_CONSTANT(CURLOPT_INFILE); - REGISTER_CURL_CONSTANT(CURLOPT_INFILESIZE); - REGISTER_CURL_CONSTANT(CURLOPT_URL); - REGISTER_CURL_CONSTANT(CURLOPT_PROXY); - REGISTER_CURL_CONSTANT(CURLOPT_VERBOSE); + REGISTER_CURL_CONSTANT(CURLOPT_FILETIME); + REGISTER_CURL_CONSTANT(CURLOPT_FOLLOWLOCATION); + REGISTER_CURL_CONSTANT(CURLOPT_FORBID_REUSE); + REGISTER_CURL_CONSTANT(CURLOPT_FRESH_CONNECT); + REGISTER_CURL_CONSTANT(CURLOPT_FTPAPPEND); + REGISTER_CURL_CONSTANT(CURLOPT_FTPLISTONLY); + REGISTER_CURL_CONSTANT(CURLOPT_FTPPORT); + REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPRT); + REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPSV); REGISTER_CURL_CONSTANT(CURLOPT_HEADER); + REGISTER_CURL_CONSTANT(CURLOPT_HEADERFUNCTION); + REGISTER_CURL_CONSTANT(CURLOPT_HTTP200ALIASES); + REGISTER_CURL_CONSTANT(CURLOPT_HTTPGET); REGISTER_CURL_CONSTANT(CURLOPT_HTTPHEADER); - REGISTER_CURL_CONSTANT(CURLOPT_NOPROGRESS); - REGISTER_CURL_CONSTANT(CURLOPT_PROGRESSFUNCTION); + REGISTER_CURL_CONSTANT(CURLOPT_HTTPPROXYTUNNEL); + REGISTER_CURL_CONSTANT(CURLOPT_HTTP_VERSION); + REGISTER_CURL_CONSTANT(CURLOPT_INFILE); + REGISTER_CURL_CONSTANT(CURLOPT_INFILESIZE); + REGISTER_CURL_CONSTANT(CURLOPT_INTERFACE); + REGISTER_CURL_CONSTANT(CURLOPT_KRB4LEVEL); + REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_LIMIT); + REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_TIME); + REGISTER_CURL_CONSTANT(CURLOPT_MAXCONNECTS); + REGISTER_CURL_CONSTANT(CURLOPT_MAXREDIRS); + REGISTER_CURL_CONSTANT(CURLOPT_NETRC); REGISTER_CURL_CONSTANT(CURLOPT_NOBODY); - REGISTER_CURL_CONSTANT(CURLOPT_FAILONERROR); - REGISTER_CURL_CONSTANT(CURLOPT_UPLOAD); + REGISTER_CURL_CONSTANT(CURLOPT_NOPROGRESS); + REGISTER_CURL_CONSTANT(CURLOPT_NOSIGNAL); + REGISTER_CURL_CONSTANT(CURLOPT_PORT); REGISTER_CURL_CONSTANT(CURLOPT_POST); - REGISTER_CURL_CONSTANT(CURLOPT_FTPLISTONLY); - REGISTER_CURL_CONSTANT(CURLOPT_FTPAPPEND); - REGISTER_CURL_CONSTANT(CURLOPT_NETRC); - REGISTER_CURL_CONSTANT(CURLOPT_FOLLOWLOCATION); -#if CURLOPT_FTPASCII != 0 - REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII); -#endif - REGISTER_CURL_CONSTANT(CURLOPT_PUT); -#if CURLOPT_MUTE != 0 - REGISTER_CURL_CONSTANT(CURLOPT_MUTE); -#endif - REGISTER_CURL_CONSTANT(CURLOPT_USERPWD); + REGISTER_CURL_CONSTANT(CURLOPT_POSTFIELDS); + REGISTER_CURL_CONSTANT(CURLOPT_POSTQUOTE); + REGISTER_CURL_CONSTANT(CURLOPT_PREQUOTE); + REGISTER_CURL_CONSTANT(CURLOPT_PRIVATE); + REGISTER_CURL_CONSTANT(CURLOPT_PROGRESSFUNCTION); + REGISTER_CURL_CONSTANT(CURLOPT_PROXY); + REGISTER_CURL_CONSTANT(CURLOPT_PROXYPORT); + REGISTER_CURL_CONSTANT(CURLOPT_PROXYTYPE); REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERPWD); + REGISTER_CURL_CONSTANT(CURLOPT_PUT); + REGISTER_CURL_CONSTANT(CURLOPT_QUOTE); + REGISTER_CURL_CONSTANT(CURLOPT_RANDOM_FILE); REGISTER_CURL_CONSTANT(CURLOPT_RANGE); - REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT); -#if LIBCURL_VERSION_NUM > 0x071002 - REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT_MS); -#endif - REGISTER_CURL_CONSTANT(CURLOPT_POSTFIELDS); + REGISTER_CURL_CONSTANT(CURLOPT_READDATA); + REGISTER_CURL_CONSTANT(CURLOPT_READFUNCTION); REGISTER_CURL_CONSTANT(CURLOPT_REFERER); - REGISTER_CURL_CONSTANT(CURLOPT_USERAGENT); - REGISTER_CURL_CONSTANT(CURLOPT_FTPPORT); - REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPSV); - REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_LIMIT); - REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_TIME); REGISTER_CURL_CONSTANT(CURLOPT_RESUME_FROM); - REGISTER_CURL_CONSTANT(CURLOPT_COOKIE); - REGISTER_CURL_CONSTANT(CURLOPT_COOKIESESSION); - REGISTER_CURL_CONSTANT(CURLOPT_AUTOREFERER); + REGISTER_CURL_CONSTANT(CURLOPT_RETURNTRANSFER); + REGISTER_CURL_CONSTANT(CURLOPT_SHARE); REGISTER_CURL_CONSTANT(CURLOPT_SSLCERT); REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTPASSWD); - REGISTER_CURL_CONSTANT(CURLOPT_WRITEHEADER); - REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYHOST); - REGISTER_CURL_CONSTANT(CURLOPT_COOKIEFILE); + REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTTYPE); + REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE); + REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE_DEFAULT); + REGISTER_CURL_CONSTANT(CURLOPT_SSLKEY); + REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYPASSWD); + REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYTYPE); REGISTER_CURL_CONSTANT(CURLOPT_SSLVERSION); + REGISTER_CURL_CONSTANT(CURLOPT_SSL_CIPHER_LIST); + REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYHOST); + REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYPEER); + REGISTER_CURL_CONSTANT(CURLOPT_STDERR); + REGISTER_CURL_CONSTANT(CURLOPT_TELNETOPTIONS); REGISTER_CURL_CONSTANT(CURLOPT_TIMECONDITION); + REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT); REGISTER_CURL_CONSTANT(CURLOPT_TIMEVALUE); - REGISTER_CURL_CONSTANT(CURLOPT_CUSTOMREQUEST); - REGISTER_CURL_CONSTANT(CURLOPT_STDERR); REGISTER_CURL_CONSTANT(CURLOPT_TRANSFERTEXT); - REGISTER_CURL_CONSTANT(CURLOPT_RETURNTRANSFER); - REGISTER_CURL_CONSTANT(CURLOPT_QUOTE); - REGISTER_CURL_CONSTANT(CURLOPT_POSTQUOTE); - REGISTER_CURL_CONSTANT(CURLOPT_INTERFACE); - REGISTER_CURL_CONSTANT(CURLOPT_KRB4LEVEL); - REGISTER_CURL_CONSTANT(CURLOPT_HTTPPROXYTUNNEL); - REGISTER_CURL_CONSTANT(CURLOPT_FILETIME); - REGISTER_CURL_CONSTANT(CURLOPT_WRITEFUNCTION); - REGISTER_CURL_CONSTANT(CURLOPT_READFUNCTION); -#if CURLOPT_PASSWDFUNCTION != 0 - REGISTER_CURL_CONSTANT(CURLOPT_PASSWDFUNCTION); -#endif - REGISTER_CURL_CONSTANT(CURLOPT_HEADERFUNCTION); - REGISTER_CURL_CONSTANT(CURLOPT_MAXREDIRS); - REGISTER_CURL_CONSTANT(CURLOPT_MAXCONNECTS); - REGISTER_CURL_CONSTANT(CURLOPT_CLOSEPOLICY); - REGISTER_CURL_CONSTANT(CURLOPT_FRESH_CONNECT); - REGISTER_CURL_CONSTANT(CURLOPT_FORBID_REUSE); - REGISTER_CURL_CONSTANT(CURLOPT_RANDOM_FILE); - REGISTER_CURL_CONSTANT(CURLOPT_EGDSOCKET); - REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT); -#if LIBCURL_VERSION_NUM > 0x071002 - REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT_MS); -#endif - REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYPEER); - REGISTER_CURL_CONSTANT(CURLOPT_CAINFO); - REGISTER_CURL_CONSTANT(CURLOPT_CAPATH); - REGISTER_CURL_CONSTANT(CURLOPT_COOKIEJAR); - REGISTER_CURL_CONSTANT(CURLOPT_SSL_CIPHER_LIST); - REGISTER_CURL_CONSTANT(CURLOPT_BINARYTRANSFER); - REGISTER_CURL_CONSTANT(CURLOPT_NOSIGNAL); - REGISTER_CURL_CONSTANT(CURLOPT_PROXYTYPE); - REGISTER_CURL_CONSTANT(CURLOPT_BUFFERSIZE); - REGISTER_CURL_CONSTANT(CURLOPT_HTTPGET); - REGISTER_CURL_CONSTANT(CURLOPT_HTTP_VERSION); - REGISTER_CURL_CONSTANT(CURLOPT_SSLKEY); - REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYTYPE); - REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYPASSWD); - REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE); - REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE_DEFAULT); - REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTTYPE); - REGISTER_CURL_CONSTANT(CURLOPT_CRLF); - REGISTER_CURL_CONSTANT(CURLOPT_ENCODING); - REGISTER_CURL_CONSTANT(CURLOPT_PROXYPORT); REGISTER_CURL_CONSTANT(CURLOPT_UNRESTRICTED_AUTH); - REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPRT); -#if LIBCURL_VERSION_NUM > 0x070b01 /* CURLOPT_TCP_NODELAY is available since curl 7.11.2 */ - REGISTER_CURL_CONSTANT(CURLOPT_TCP_NODELAY); -#endif - REGISTER_CURL_CONSTANT(CURLOPT_HTTP200ALIASES); - REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFMODSINCE); - REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFUNMODSINCE); - REGISTER_CURL_CONSTANT(CURL_TIMECOND_LASTMOD); - -#if LIBCURL_VERSION_NUM > 0x070f04 /* CURLOPT_MAX_RECV_SPEED_LARGE & CURLOPT_MAX_SEND_SPEED_LARGE are available since curl 7.15.5 */ - REGISTER_CURL_CONSTANT(CURLOPT_MAX_RECV_SPEED_LARGE); - REGISTER_CURL_CONSTANT(CURLOPT_MAX_SEND_SPEED_LARGE); -#endif - -#if LIBCURL_VERSION_NUM > 0x070a05 /* CURLOPT_HTTPAUTH is available since curl 7.10.6 */ - REGISTER_CURL_CONSTANT(CURLOPT_HTTPAUTH); - /* http authentication options */ - REGISTER_CURL_CONSTANT(CURLAUTH_BASIC); - REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST); - REGISTER_CURL_CONSTANT(CURLAUTH_GSSNEGOTIATE); - REGISTER_CURL_CONSTANT(CURLAUTH_NTLM); - REGISTER_CURL_CONSTANT(CURLAUTH_ANY); - REGISTER_CURL_CONSTANT(CURLAUTH_ANYSAFE); -#endif - -#if LIBCURL_VERSION_NUM > 0x070a06 /* CURLOPT_PROXYAUTH & CURLOPT_FTP_CREATE_MISSING_DIRS are available since curl 7.10.7 */ - REGISTER_CURL_CONSTANT(CURLOPT_PROXYAUTH); - REGISTER_CURL_CONSTANT(CURLOPT_FTP_CREATE_MISSING_DIRS); -#endif - - REGISTER_CURL_CONSTANT(CURLOPT_PRIVATE); + REGISTER_CURL_CONSTANT(CURLOPT_UPLOAD); + REGISTER_CURL_CONSTANT(CURLOPT_URL); + REGISTER_CURL_CONSTANT(CURLOPT_USERAGENT); + REGISTER_CURL_CONSTANT(CURLOPT_USERPWD); + REGISTER_CURL_CONSTANT(CURLOPT_VERBOSE); + REGISTER_CURL_CONSTANT(CURLOPT_WRITEFUNCTION); + REGISTER_CURL_CONSTANT(CURLOPT_WRITEHEADER); /* Constants effecting the way CURLOPT_CLOSEPOLICY works */ + REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_CALLBACK); REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_LEAST_RECENTLY_USED); REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_LEAST_TRAFFIC); - REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_SLOWEST); - REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_CALLBACK); REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_OLDEST); + REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_SLOWEST); - /* Info constants */ - REGISTER_CURL_CONSTANT(CURLINFO_EFFECTIVE_URL); - REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CODE); - REGISTER_CURL_CONSTANT(CURLINFO_HEADER_SIZE); - REGISTER_CURL_CONSTANT(CURLINFO_REQUEST_SIZE); - REGISTER_CURL_CONSTANT(CURLINFO_TOTAL_TIME); - REGISTER_CURL_CONSTANT(CURLINFO_NAMELOOKUP_TIME); - REGISTER_CURL_CONSTANT(CURLINFO_CONNECT_TIME); - REGISTER_CURL_CONSTANT(CURLINFO_PRETRANSFER_TIME); - REGISTER_CURL_CONSTANT(CURLINFO_SIZE_UPLOAD); - REGISTER_CURL_CONSTANT(CURLINFO_SIZE_DOWNLOAD); - REGISTER_CURL_CONSTANT(CURLINFO_SPEED_DOWNLOAD); - REGISTER_CURL_CONSTANT(CURLINFO_SPEED_UPLOAD); - REGISTER_CURL_CONSTANT(CURLINFO_FILETIME); - REGISTER_CURL_CONSTANT(CURLINFO_SSL_VERIFYRESULT); - REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_DOWNLOAD); - REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_UPLOAD); - REGISTER_CURL_CONSTANT(CURLINFO_STARTTRANSFER_TIME); - REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_TYPE); - REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_TIME); - REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_COUNT); - REGISTER_CURL_CONSTANT(CURLINFO_HEADER_OUT); - REGISTER_CURL_CONSTANT(CURLINFO_PRIVATE); -#if LIBCURL_VERSION_NUM > 0x071301 - REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO); -#endif -#if LIBCURL_VERSION_NUM >= 0x071202 - REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL); -#endif -#if LIBCURL_VERSION_NUM >= 0x071300 /* 7.19.0 */ - REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_IP); -#endif -#if LIBCURL_VERSION_NUM >= 0x071500 /* 7.21.0 */ - REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_PORT); - REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_IP); - REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_PORT); -#endif - - - /* cURL protocol constants (curl_version) */ - REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6); - REGISTER_CURL_CONSTANT(CURL_VERSION_KERBEROS4); - REGISTER_CURL_CONSTANT(CURL_VERSION_SSL); - REGISTER_CURL_CONSTANT(CURL_VERSION_LIBZ); - - /* version constants */ - REGISTER_CURL_CONSTANT(CURLVERSION_NOW); - - /* Error Constants */ - REGISTER_CURL_CONSTANT(CURLE_OK); - REGISTER_CURL_CONSTANT(CURLE_UNSUPPORTED_PROTOCOL); - REGISTER_CURL_CONSTANT(CURLE_FAILED_INIT); - REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT); - REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT_USER); - REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_PROXY); - REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_HOST); + /* */ + REGISTER_CURL_CONSTANT(CURLE_ABORTED_BY_CALLBACK); + REGISTER_CURL_CONSTANT(CURLE_BAD_CALLING_ORDER); + REGISTER_CURL_CONSTANT(CURLE_BAD_CONTENT_ENCODING); + REGISTER_CURL_CONSTANT(CURLE_BAD_DOWNLOAD_RESUME); + REGISTER_CURL_CONSTANT(CURLE_BAD_FUNCTION_ARGUMENT); + REGISTER_CURL_CONSTANT(CURLE_BAD_PASSWORD_ENTERED); REGISTER_CURL_CONSTANT(CURLE_COULDNT_CONNECT); - REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_SERVER_REPLY); + REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_HOST); + REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_PROXY); + REGISTER_CURL_CONSTANT(CURLE_FAILED_INIT); + REGISTER_CURL_CONSTANT(CURLE_FILE_COULDNT_READ_FILE); REGISTER_CURL_CONSTANT(CURLE_FTP_ACCESS_DENIED); - REGISTER_CURL_CONSTANT(CURLE_FTP_USER_PASSWORD_INCORRECT); - REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASS_REPLY); - REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_USER_REPLY); - REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASV_REPLY); - REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_227_FORMAT); + REGISTER_CURL_CONSTANT(CURLE_FTP_BAD_DOWNLOAD_RESUME); REGISTER_CURL_CONSTANT(CURLE_FTP_CANT_GET_HOST); REGISTER_CURL_CONSTANT(CURLE_FTP_CANT_RECONNECT); - REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_BINARY); - REGISTER_CURL_CONSTANT(CURLE_PARTIAL_FILE); + REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_GET_SIZE); REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_RETR_FILE); - REGISTER_CURL_CONSTANT(CURLE_FTP_WRITE_ERROR); - REGISTER_CURL_CONSTANT(CURLE_FTP_QUOTE_ERROR); - REGISTER_CURL_CONSTANT(CURLE_HTTP_NOT_FOUND); - REGISTER_CURL_CONSTANT(CURLE_WRITE_ERROR); - REGISTER_CURL_CONSTANT(CURLE_MALFORMAT_USER); - REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_STOR_FILE); - REGISTER_CURL_CONSTANT(CURLE_READ_ERROR); - REGISTER_CURL_CONSTANT(CURLE_OUT_OF_MEMORY); - REGISTER_CURL_CONSTANT(CURLE_OPERATION_TIMEOUTED); REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_ASCII); - REGISTER_CURL_CONSTANT(CURLE_FTP_PORT_FAILED); + REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_BINARY); + REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_STOR_FILE); REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_USE_REST); - REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_GET_SIZE); - REGISTER_CURL_CONSTANT(CURLE_HTTP_RANGE_ERROR); + REGISTER_CURL_CONSTANT(CURLE_FTP_PARTIAL_FILE); + REGISTER_CURL_CONSTANT(CURLE_FTP_PORT_FAILED); + REGISTER_CURL_CONSTANT(CURLE_FTP_QUOTE_ERROR); + REGISTER_CURL_CONSTANT(CURLE_FTP_USER_PASSWORD_INCORRECT); + REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_227_FORMAT); + REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASS_REPLY); + REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASV_REPLY); + REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_SERVER_REPLY); + REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_USER_REPLY); + REGISTER_CURL_CONSTANT(CURLE_FTP_WRITE_ERROR); + REGISTER_CURL_CONSTANT(CURLE_FUNCTION_NOT_FOUND); + REGISTER_CURL_CONSTANT(CURLE_GOT_NOTHING); + REGISTER_CURL_CONSTANT(CURLE_HTTP_NOT_FOUND); + REGISTER_CURL_CONSTANT(CURLE_HTTP_PORT_FAILED); REGISTER_CURL_CONSTANT(CURLE_HTTP_POST_ERROR); - REGISTER_CURL_CONSTANT(CURLE_SSL_CONNECT_ERROR); - REGISTER_CURL_CONSTANT(CURLE_FTP_BAD_DOWNLOAD_RESUME); - REGISTER_CURL_CONSTANT(CURLE_FILE_COULDNT_READ_FILE); + REGISTER_CURL_CONSTANT(CURLE_HTTP_RANGE_ERROR); + REGISTER_CURL_CONSTANT(CURLE_HTTP_RETURNED_ERROR); REGISTER_CURL_CONSTANT(CURLE_LDAP_CANNOT_BIND); REGISTER_CURL_CONSTANT(CURLE_LDAP_SEARCH_FAILED); REGISTER_CURL_CONSTANT(CURLE_LIBRARY_NOT_FOUND); - REGISTER_CURL_CONSTANT(CURLE_FUNCTION_NOT_FOUND); - REGISTER_CURL_CONSTANT(CURLE_ABORTED_BY_CALLBACK); - REGISTER_CURL_CONSTANT(CURLE_BAD_FUNCTION_ARGUMENT); - REGISTER_CURL_CONSTANT(CURLE_BAD_CALLING_ORDER); - REGISTER_CURL_CONSTANT(CURLE_HTTP_PORT_FAILED); - REGISTER_CURL_CONSTANT(CURLE_BAD_PASSWORD_ENTERED); - REGISTER_CURL_CONSTANT(CURLE_TOO_MANY_REDIRECTS); - REGISTER_CURL_CONSTANT(CURLE_UNKNOWN_TELNET_OPTION); - REGISTER_CURL_CONSTANT(CURLE_TELNET_OPTION_SYNTAX); + REGISTER_CURL_CONSTANT(CURLE_MALFORMAT_USER); REGISTER_CURL_CONSTANT(CURLE_OBSOLETE); - REGISTER_CURL_CONSTANT(CURLE_SSL_PEER_CERTIFICATE); - REGISTER_CURL_CONSTANT(CURLE_GOT_NOTHING); - REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_NOTFOUND); - REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_SETFAILED); - REGISTER_CURL_CONSTANT(CURLE_SEND_ERROR); + REGISTER_CURL_CONSTANT(CURLE_OK); + REGISTER_CURL_CONSTANT(CURLE_OPERATION_TIMEDOUT); + REGISTER_CURL_CONSTANT(CURLE_OPERATION_TIMEOUTED); + REGISTER_CURL_CONSTANT(CURLE_OUT_OF_MEMORY); + REGISTER_CURL_CONSTANT(CURLE_PARTIAL_FILE); + REGISTER_CURL_CONSTANT(CURLE_READ_ERROR); REGISTER_CURL_CONSTANT(CURLE_RECV_ERROR); + REGISTER_CURL_CONSTANT(CURLE_SEND_ERROR); REGISTER_CURL_CONSTANT(CURLE_SHARE_IN_USE); + REGISTER_CURL_CONSTANT(CURLE_SSL_CACERT); REGISTER_CURL_CONSTANT(CURLE_SSL_CERTPROBLEM); REGISTER_CURL_CONSTANT(CURLE_SSL_CIPHER); - REGISTER_CURL_CONSTANT(CURLE_SSL_CACERT); - REGISTER_CURL_CONSTANT(CURLE_BAD_CONTENT_ENCODING); -#if LIBCURL_VERSION_NUM >= 0x070a08 - REGISTER_CURL_CONSTANT(CURLE_LDAP_INVALID_URL); - REGISTER_CURL_CONSTANT(CURLE_FILESIZE_EXCEEDED); -#endif -#if LIBCURL_VERSION_NUM >= 0x070b00 - REGISTER_CURL_CONSTANT(CURLE_FTP_SSL_FAILED); -#endif + REGISTER_CURL_CONSTANT(CURLE_SSL_CONNECT_ERROR); + REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_NOTFOUND); + REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_SETFAILED); + REGISTER_CURL_CONSTANT(CURLE_SSL_PEER_CERTIFICATE); + REGISTER_CURL_CONSTANT(CURLE_TELNET_OPTION_SYNTAX); + REGISTER_CURL_CONSTANT(CURLE_TOO_MANY_REDIRECTS); + REGISTER_CURL_CONSTANT(CURLE_UNKNOWN_TELNET_OPTION); + REGISTER_CURL_CONSTANT(CURLE_UNSUPPORTED_PROTOCOL); + REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT); + REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT_USER); + REGISTER_CURL_CONSTANT(CURLE_WRITE_ERROR); + + /* cURL info constants */ + REGISTER_CURL_CONSTANT(CURLINFO_CONNECT_TIME); + REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_DOWNLOAD); + REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_UPLOAD); + REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_TYPE); + REGISTER_CURL_CONSTANT(CURLINFO_EFFECTIVE_URL); + REGISTER_CURL_CONSTANT(CURLINFO_FILETIME); + REGISTER_CURL_CONSTANT(CURLINFO_HEADER_OUT); + REGISTER_CURL_CONSTANT(CURLINFO_HEADER_SIZE); + REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CODE); + REGISTER_CURL_CONSTANT(CURLINFO_LASTONE); + REGISTER_CURL_CONSTANT(CURLINFO_NAMELOOKUP_TIME); + REGISTER_CURL_CONSTANT(CURLINFO_PRETRANSFER_TIME); + REGISTER_CURL_CONSTANT(CURLINFO_PRIVATE); + REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_COUNT); + REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_TIME); + REGISTER_CURL_CONSTANT(CURLINFO_REQUEST_SIZE); + REGISTER_CURL_CONSTANT(CURLINFO_SIZE_DOWNLOAD); + REGISTER_CURL_CONSTANT(CURLINFO_SIZE_UPLOAD); + REGISTER_CURL_CONSTANT(CURLINFO_SPEED_DOWNLOAD); + REGISTER_CURL_CONSTANT(CURLINFO_SPEED_UPLOAD); + REGISTER_CURL_CONSTANT(CURLINFO_SSL_VERIFYRESULT); + REGISTER_CURL_CONSTANT(CURLINFO_STARTTRANSFER_TIME); + REGISTER_CURL_CONSTANT(CURLINFO_TOTAL_TIME); + + /* Other */ + REGISTER_CURL_CONSTANT(CURLMSG_DONE); + REGISTER_CURL_CONSTANT(CURLVERSION_NOW); + + /* Curl Multi Constants */ + REGISTER_CURL_CONSTANT(CURLM_BAD_EASY_HANDLE); + REGISTER_CURL_CONSTANT(CURLM_BAD_HANDLE); + REGISTER_CURL_CONSTANT(CURLM_CALL_MULTI_PERFORM); + REGISTER_CURL_CONSTANT(CURLM_INTERNAL_ERROR); + REGISTER_CURL_CONSTANT(CURLM_OK); + REGISTER_CURL_CONSTANT(CURLM_OUT_OF_MEMORY); + + /* Curl proxy constants */ REGISTER_CURL_CONSTANT(CURLPROXY_HTTP); REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS4); REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS5); - REGISTER_CURL_CONSTANT(CURL_NETRC_OPTIONAL); - REGISTER_CURL_CONSTANT(CURL_NETRC_IGNORED); - REGISTER_CURL_CONSTANT(CURL_NETRC_REQUIRED); + /* Curl Share constants */ + REGISTER_CURL_CONSTANT(CURLSHOPT_NONE); + REGISTER_CURL_CONSTANT(CURLSHOPT_SHARE); + REGISTER_CURL_CONSTANT(CURLSHOPT_UNSHARE); - REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_NONE); + /* Curl Http Version constants (CURLOPT_HTTP_VERSION) */ REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_0); REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_1); + REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_NONE); - REGISTER_CURL_CONSTANT(CURLM_CALL_MULTI_PERFORM); - REGISTER_CURL_CONSTANT(CURLM_OK); - REGISTER_CURL_CONSTANT(CURLM_BAD_HANDLE); - REGISTER_CURL_CONSTANT(CURLM_BAD_EASY_HANDLE); - REGISTER_CURL_CONSTANT(CURLM_OUT_OF_MEMORY); - REGISTER_CURL_CONSTANT(CURLM_INTERNAL_ERROR); + /* Curl Lock constants */ + REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_COOKIE); + REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_DNS); + REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_SSL_SESSION); - REGISTER_CURL_CONSTANT(CURLMSG_DONE); + /* Curl NETRC constants (CURLOPT_NETRC) */ + REGISTER_CURL_CONSTANT(CURL_NETRC_IGNORED); + REGISTER_CURL_CONSTANT(CURL_NETRC_OPTIONAL); + REGISTER_CURL_CONSTANT(CURL_NETRC_REQUIRED); -#if LIBCURL_VERSION_NUM >= 0x070c02 - REGISTER_CURL_CONSTANT(CURLOPT_FTPSSLAUTH); + /* Curl SSL Version constants (CURLOPT_SSLVERSION) */ + REGISTER_CURL_CONSTANT(CURL_SSLVERSION_DEFAULT); + REGISTER_CURL_CONSTANT(CURL_SSLVERSION_SSLv2); + REGISTER_CURL_CONSTANT(CURL_SSLVERSION_SSLv3); + REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1); + + /* Curl TIMECOND constants (CURLOPT_TIMECONDITION) */ + REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFMODSINCE); + REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFUNMODSINCE); + REGISTER_CURL_CONSTANT(CURL_TIMECOND_LASTMOD); + REGISTER_CURL_CONSTANT(CURL_TIMECOND_NONE); + + /* Curl version constants */ + REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6); + REGISTER_CURL_CONSTANT(CURL_VERSION_KERBEROS4); + REGISTER_CURL_CONSTANT(CURL_VERSION_LIBZ); + REGISTER_CURL_CONSTANT(CURL_VERSION_SSL); + +#if LIBCURL_VERSION_NUM >= 0x070a06 /* Available since 7.10.6 */ + REGISTER_CURL_CONSTANT(CURLOPT_HTTPAUTH); + /* http authentication options */ + REGISTER_CURL_CONSTANT(CURLAUTH_ANY); + REGISTER_CURL_CONSTANT(CURLAUTH_ANYSAFE); + REGISTER_CURL_CONSTANT(CURLAUTH_BASIC); + REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST); + REGISTER_CURL_CONSTANT(CURLAUTH_GSSNEGOTIATE); + REGISTER_CURL_CONSTANT(CURLAUTH_NONE); + REGISTER_CURL_CONSTANT(CURLAUTH_NTLM); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070a07 /* Available since 7.10.7 */ + REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CONNECTCODE); + REGISTER_CURL_CONSTANT(CURLOPT_FTP_CREATE_MISSING_DIRS); + REGISTER_CURL_CONSTANT(CURLOPT_PROXYAUTH); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070a08 /* Available since 7.10.8 */ + REGISTER_CURL_CONSTANT(CURLE_FILESIZE_EXCEEDED); + REGISTER_CURL_CONSTANT(CURLE_LDAP_INVALID_URL); + REGISTER_CURL_CONSTANT(CURLINFO_HTTPAUTH_AVAIL); + REGISTER_CURL_CONSTANT(CURLINFO_RESPONSE_CODE); + REGISTER_CURL_CONSTANT(CURLINFO_PROXYAUTH_AVAIL); + REGISTER_CURL_CONSTANT(CURLOPT_FTP_RESPONSE_TIMEOUT); + REGISTER_CURL_CONSTANT(CURLOPT_IPRESOLVE); + REGISTER_CURL_CONSTANT(CURLOPT_MAXFILESIZE); + REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V4); + REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V6); + REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_WHATEVER); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */ + REGISTER_CURL_CONSTANT(CURLE_FTP_SSL_FAILED); + REGISTER_CURL_CONSTANT(CURLFTPSSL_ALL); + REGISTER_CURL_CONSTANT(CURLFTPSSL_CONTROL); + REGISTER_CURL_CONSTANT(CURLFTPSSL_NONE); + REGISTER_CURL_CONSTANT(CURLFTPSSL_TRY); + REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL); + REGISTER_CURL_CONSTANT(CURLOPT_NETRC_FILE); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */ REGISTER_CURL_CONSTANT(CURLFTPAUTH_DEFAULT); REGISTER_CURL_CONSTANT(CURLFTPAUTH_SSL); REGISTER_CURL_CONSTANT(CURLFTPAUTH_TLS); + REGISTER_CURL_CONSTANT(CURLOPT_FTPSSLAUTH); #endif -#if LIBCURL_VERSION_NUM > 0x070b00 - REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL); - REGISTER_CURL_CONSTANT(CURLFTPSSL_NONE); - REGISTER_CURL_CONSTANT(CURLFTPSSL_TRY); - REGISTER_CURL_CONSTANT(CURLFTPSSL_CONTROL); - REGISTER_CURL_CONSTANT(CURLFTPSSL_ALL); +#if LIBCURL_VERSION_NUM >= 0x070d00 /* Available since 7.13.0 */ + REGISTER_CURL_CONSTANT(CURLOPT_FTP_ACCOUNT); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070b02 /* Available since 7.11.2 */ + REGISTER_CURL_CONSTANT(CURLOPT_TCP_NODELAY); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */ + REGISTER_CURL_CONSTANT(CURLINFO_OS_ERRNO); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070c03 /* Available since 7.12.3 */ + REGISTER_CURL_CONSTANT(CURLINFO_NUM_CONNECTS); + REGISTER_CURL_CONSTANT(CURLINFO_SSL_ENGINES); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */ + REGISTER_CURL_CONSTANT(CURLINFO_COOKIELIST); + REGISTER_CURL_CONSTANT(CURLOPT_COOKIELIST); + REGISTER_CURL_CONSTANT(CURLOPT_IGNORE_CONTENT_LENGTH); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070f00 /* Available since 7.15.0 */ + REGISTER_CURL_CONSTANT(CURLOPT_FTP_SKIP_PASV_IP); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070f01 /* Available since 7.15.1 */ + REGISTER_CURL_CONSTANT(CURLOPT_FTP_FILEMETHOD); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070f02 /* Available since 7.15.2 */ + REGISTER_CURL_CONSTANT(CURLOPT_CONNECT_ONLY); + REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORT); + REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORTRANGE); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070f03 /* Available since 7.15.3 */ + REGISTER_CURL_CONSTANT(CURLFTPMETHOD_MULTICWD); + REGISTER_CURL_CONSTANT(CURLFTPMETHOD_NOCWD); + REGISTER_CURL_CONSTANT(CURLFTPMETHOD_SINGLECWD); +#endif + +#if LIBCURL_VERSION_NUM >- 0x070f04 /* Available since 7.15.4 */ + REGISTER_CURL_CONSTANT(CURLINFO_FTP_ENTRY_PATH); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */ + REGISTER_CURL_CONSTANT(CURLOPT_FTP_ALTERNATIVE_TO_USER); + REGISTER_CURL_CONSTANT(CURLOPT_MAX_RECV_SPEED_LARGE); + REGISTER_CURL_CONSTANT(CURLOPT_MAX_SEND_SPEED_LARGE); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071000 /* Available since 7.16.0 */ + REGISTER_CURL_CONSTANT(CURLOPT_SSL_SESSIONID_CACHE); + REGISTER_CURL_CONSTANT(CURLMOPT_PIPELINING); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */ + REGISTER_CURL_CONSTANT(CURLE_SSH); + REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL_CCC); + REGISTER_CURL_CONSTANT(CURLOPT_SSH_AUTH_TYPES); + REGISTER_CURL_CONSTANT(CURLOPT_SSH_PRIVATE_KEYFILE); + REGISTER_CURL_CONSTANT(CURLOPT_SSH_PUBLIC_KEYFILE); + REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_ACTIVE); + REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_NONE); + REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_PASSIVE); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071002 /* Available since 7.16.2 */ + REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT_MS); + REGISTER_CURL_CONSTANT(CURLOPT_HTTP_CONTENT_DECODING); + REGISTER_CURL_CONSTANT(CURLOPT_HTTP_TRANSFER_DECODING); + REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT_MS); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071003 /* Available since 7.16.3 */ + REGISTER_CURL_CONSTANT(CURLMOPT_MAXCONNECTS); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071004 /* Available since 7.16.4 */ + REGISTER_CURL_CONSTANT(CURLOPT_KRBLEVEL); + REGISTER_CURL_CONSTANT(CURLOPT_NEW_DIRECTORY_PERMS); + REGISTER_CURL_CONSTANT(CURLOPT_NEW_FILE_PERMS); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */ + REGISTER_CURL_CONSTANT(CURLOPT_APPEND); + REGISTER_CURL_CONSTANT(CURLOPT_DIRLISTONLY); + REGISTER_CURL_CONSTANT(CURLOPT_USE_SSL); + /* Curl SSL Constants */ + REGISTER_CURL_CONSTANT(CURLUSESSL_ALL); + REGISTER_CURL_CONSTANT(CURLUSESSL_CONTROL); + REGISTER_CURL_CONSTANT(CURLUSESSL_NONE); + REGISTER_CURL_CONSTANT(CURLUSESSL_TRY); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071101 /* Available since 7.17.1 */ + REGISTER_CURL_CONSTANT(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071200 /* Available since 7.18.0 */ + REGISTER_CURL_CONSTANT(CURLOPT_PROXY_TRANSFER_MODE); + REGISTER_CURL_CONSTANT(CURLPAUSE_ALL); + REGISTER_CURL_CONSTANT(CURLPAUSE_CONT); + REGISTER_CURL_CONSTANT(CURLPAUSE_RECV); + REGISTER_CURL_CONSTANT(CURLPAUSE_RECV_CONT); + REGISTER_CURL_CONSTANT(CURLPAUSE_SEND); + REGISTER_CURL_CONSTANT(CURLPAUSE_SEND_CONT); + REGISTER_CURL_CONSTANT(CURL_READFUNC_PAUSE); + REGISTER_CURL_CONSTANT(CURL_WRITEFUNC_PAUSE); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */ + REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */ + REGISTER_CURL_CONSTANT(CURLINFO_APPCONNECT_TIME); + REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_IP); + + REGISTER_CURL_CONSTANT(CURLOPT_ADDRESS_SCOPE); + REGISTER_CURL_CONSTANT(CURLOPT_CRLFILE); + REGISTER_CURL_CONSTANT(CURLOPT_ISSUERCERT); + REGISTER_CURL_CONSTANT(CURLOPT_KEYPASSWD); + + REGISTER_CURL_CONSTANT(CURLSSH_AUTH_ANY); + REGISTER_CURL_CONSTANT(CURLSSH_AUTH_DEFAULT); + REGISTER_CURL_CONSTANT(CURLSSH_AUTH_HOST); + REGISTER_CURL_CONSTANT(CURLSSH_AUTH_KEYBOARD); + REGISTER_CURL_CONSTANT(CURLSSH_AUTH_NONE); + REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PASSWORD); + REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PUBLICKEY); #endif -#if LIBCURL_VERSION_NUM > 0x071301 +#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */ + REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO); REGISTER_CURL_CONSTANT(CURLOPT_CERTINFO); + REGISTER_CURL_CONSTANT(CURLOPT_PASSWORD); REGISTER_CURL_CONSTANT(CURLOPT_POSTREDIR); + REGISTER_CURL_CONSTANT(CURLOPT_PROXYPASSWORD); + REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERNAME); + REGISTER_CURL_CONSTANT(CURLOPT_USERNAME); #endif -/* SSH support works in 7.19.0+ using libssh2 */ -#if LIBCURL_VERSION_NUM >= 0x071300 - REGISTER_CURL_CONSTANT(CURLSSH_AUTH_NONE); - REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PUBLICKEY); - REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PASSWORD); - REGISTER_CURL_CONSTANT(CURLSSH_AUTH_HOST); - REGISTER_CURL_CONSTANT(CURLSSH_AUTH_KEYBOARD); - REGISTER_CURL_CONSTANT(CURLSSH_AUTH_DEFAULT); - REGISTER_CURL_CONSTANT(CURLOPT_SSH_AUTH_TYPES); - REGISTER_CURL_CONSTANT(CURLOPT_KEYPASSWD); - REGISTER_CURL_CONSTANT(CURLOPT_SSH_PUBLIC_KEYFILE); - REGISTER_CURL_CONSTANT(CURLOPT_SSH_PRIVATE_KEYFILE); - REGISTER_CURL_CONSTANT(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5); - REGISTER_CURL_CONSTANT(CURLE_SSH); +#if LIBCURL_VERSION_NUM >= 0x071303 /* Available since 7.19.3 */ + REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST_IE); #endif -#if LIBCURL_VERSION_NUM >= 0x071304 - REGISTER_CURL_CONSTANT(CURLOPT_REDIR_PROTOCOLS); +#if LIBCURL_VERSION_NUM >= 0x071304 /* Available since 7.19.4 */ + REGISTER_CURL_CONSTANT(CURLINFO_CONDITION_UNMET); + + REGISTER_CURL_CONSTANT(CURLOPT_NOPROXY); REGISTER_CURL_CONSTANT(CURLOPT_PROTOCOLS); - REGISTER_CURL_CONSTANT(CURLPROTO_HTTP); - REGISTER_CURL_CONSTANT(CURLPROTO_HTTPS); + REGISTER_CURL_CONSTANT(CURLOPT_REDIR_PROTOCOLS); + REGISTER_CURL_CONSTANT(CURLOPT_SOCKS5_GSSAPI_NEC); + REGISTER_CURL_CONSTANT(CURLOPT_SOCKS5_GSSAPI_SERVICE); + REGISTER_CURL_CONSTANT(CURLOPT_TFTP_BLKSIZE); + + REGISTER_CURL_CONSTANT(CURLPROTO_ALL); + REGISTER_CURL_CONSTANT(CURLPROTO_DICT); + REGISTER_CURL_CONSTANT(CURLPROTO_FILE); REGISTER_CURL_CONSTANT(CURLPROTO_FTP); REGISTER_CURL_CONSTANT(CURLPROTO_FTPS); + REGISTER_CURL_CONSTANT(CURLPROTO_HTTP); + REGISTER_CURL_CONSTANT(CURLPROTO_HTTPS); + REGISTER_CURL_CONSTANT(CURLPROTO_LDAP); + REGISTER_CURL_CONSTANT(CURLPROTO_LDAPS); REGISTER_CURL_CONSTANT(CURLPROTO_SCP); REGISTER_CURL_CONSTANT(CURLPROTO_SFTP); REGISTER_CURL_CONSTANT(CURLPROTO_TELNET); - REGISTER_CURL_CONSTANT(CURLPROTO_LDAP); - REGISTER_CURL_CONSTANT(CURLPROTO_LDAPS); - REGISTER_CURL_CONSTANT(CURLPROTO_DICT); - REGISTER_CURL_CONSTANT(CURLPROTO_FILE); REGISTER_CURL_CONSTANT(CURLPROTO_TFTP); - REGISTER_CURL_CONSTANT(CURLPROTO_ALL); #endif -#if LIBCURL_VERSION_NUM >= 0x070f01 - REGISTER_CURL_CONSTANT(CURLOPT_FTP_FILEMETHOD); - REGISTER_CURL_CONSTANT(CURLOPT_FTP_SKIP_PASV_IP); +#if LIBCURL_VERSION_NUM >= 0x071306 /* Available since 7.19.6 */ + REGISTER_CURL_CONSTANT(CURLOPT_SSH_KNOWNHOSTS); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */ + REGISTER_CURL_CONSTANT(CURLINFO_RTSP_CLIENT_CSEQ); + REGISTER_CURL_CONSTANT(CURLINFO_RTSP_CSEQ_RECV); + REGISTER_CURL_CONSTANT(CURLINFO_RTSP_SERVER_CSEQ); + REGISTER_CURL_CONSTANT(CURLINFO_RTSP_SESSION_ID); + REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_PRET); + REGISTER_CURL_CONSTANT(CURLOPT_MAIL_FROM); + REGISTER_CURL_CONSTANT(CURLOPT_MAIL_RCPT); + REGISTER_CURL_CONSTANT(CURLOPT_RTSP_CLIENT_CSEQ); + REGISTER_CURL_CONSTANT(CURLOPT_RTSP_REQUEST); + REGISTER_CURL_CONSTANT(CURLOPT_RTSP_SERVER_CSEQ); + REGISTER_CURL_CONSTANT(CURLOPT_RTSP_SESSION_ID); + REGISTER_CURL_CONSTANT(CURLOPT_RTSP_STREAM_URI); + REGISTER_CURL_CONSTANT(CURLOPT_RTSP_TRANSPORT); + REGISTER_CURL_CONSTANT(CURLPROTO_IMAP); + REGISTER_CURL_CONSTANT(CURLPROTO_IMAPS); + REGISTER_CURL_CONSTANT(CURLPROTO_POP3); + REGISTER_CURL_CONSTANT(CURLPROTO_POP3S); + REGISTER_CURL_CONSTANT(CURLPROTO_RTSP); + REGISTER_CURL_CONSTANT(CURLPROTO_SMTP); + REGISTER_CURL_CONSTANT(CURLPROTO_SMTPS); + REGISTER_CURL_CONSTANT(CURL_RTSPREQ_ANNOUNCE); + REGISTER_CURL_CONSTANT(CURL_RTSPREQ_DESCRIBE); + REGISTER_CURL_CONSTANT(CURL_RTSPREQ_GET_PARAMETER); + REGISTER_CURL_CONSTANT(CURL_RTSPREQ_OPTIONS); + REGISTER_CURL_CONSTANT(CURL_RTSPREQ_PAUSE); + REGISTER_CURL_CONSTANT(CURL_RTSPREQ_PLAY); + REGISTER_CURL_CONSTANT(CURL_RTSPREQ_RECEIVE); + REGISTER_CURL_CONSTANT(CURL_RTSPREQ_RECORD); + REGISTER_CURL_CONSTANT(CURL_RTSPREQ_SETUP); + REGISTER_CURL_CONSTANT(CURL_RTSPREQ_SET_PARAMETER); + REGISTER_CURL_CONSTANT(CURL_RTSPREQ_TEARDOWN); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */ + REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_IP); + REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_PORT); + REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_PORT); + REGISTER_CURL_CONSTANT(CURLOPT_FNMATCH_FUNCTION); + REGISTER_CURL_CONSTANT(CURLOPT_WILDCARDMATCH); + REGISTER_CURL_CONSTANT(CURLPROTO_RTMP); + REGISTER_CURL_CONSTANT(CURLPROTO_RTMPE); + REGISTER_CURL_CONSTANT(CURLPROTO_RTMPS); + REGISTER_CURL_CONSTANT(CURLPROTO_RTMPT); + REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTE); + REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTS); + REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_FAIL); + REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_MATCH); + REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_NOMATCH); #endif -#if LIBCURL_VERSION_NUM >= 0x071001 - REGISTER_CURL_CONSTANT(CURLFTPMETHOD_MULTICWD); - REGISTER_CURL_CONSTANT(CURLFTPMETHOD_NOCWD); - REGISTER_CURL_CONSTANT(CURLFTPMETHOD_SINGLECWD); +#if LIBCURL_VERSION_NUM >= 0x071502 /* Available since 7.21.2 */ + REGISTER_CURL_CONSTANT(CURLPROTO_GOPHER); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */ + REGISTER_CURL_CONSTANT(CURLAUTH_ONLY); + REGISTER_CURL_CONSTANT(CURLOPT_RESOLVE); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */ + REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_PASSWORD); + REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_TYPE); + REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_USERNAME); + REGISTER_CURL_CONSTANT(CURL_TLSAUTH_SRP); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071506 /* Available since 7.21.6 */ + REGISTER_CURL_CONSTANT(CURLOPT_ACCEPT_ENCODING); + REGISTER_CURL_CONSTANT(CURLOPT_TRANSFER_ENCODING); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071600 /* Available since 7.22.0 */ + REGISTER_CURL_CONSTANT(CURLGSSAPI_DELEGATION_FLAG); + REGISTER_CURL_CONSTANT(CURLGSSAPI_DELEGATION_POLICY_FLAG); + REGISTER_CURL_CONSTANT(CURLOPT_GSSAPI_DELEGATION); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071800 /* Available since 7.24.0 */ + REGISTER_CURL_CONSTANT(CURLOPT_ACCEPTTIMEOUT_MS); + REGISTER_CURL_CONSTANT(CURLOPT_DNS_SERVERS); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071900 /* Available since 7.25.0 */ + REGISTER_CURL_CONSTANT(CURLOPT_MAIL_AUTH); + REGISTER_CURL_CONSTANT(CURLOPT_SSL_OPTIONS); + REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPALIVE); + REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPIDLE); + REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPINTVL); + REGISTER_CURL_CONSTANT(CURLSSLOPT_ALLOW_BEAST); +#endif + +#if CURLOPT_FTPASCII != 0 + REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII); +#endif +#if CURLOPT_MUTE != 0 + REGISTER_CURL_CONSTANT(CURLOPT_MUTE); #endif +#if CURLOPT_PASSWDFUNCTION != 0 + REGISTER_CURL_CONSTANT(CURLOPT_PASSWDFUNCTION); +#endif + REGISTER_CURL_CONSTANT(CURLOPT_SAFE_UPLOAD); #ifdef PHP_CURL_NEED_OPENSSL_TSL if (!CRYPTO_get_id_callback()) { @@ -914,7 +1222,6 @@ PHP_MINIT_FUNCTION(curl) } #ifdef PHP_CURL_URL_WRAPPERS -# if HAVE_CURL_VERSION_INFO { curl_version_info_data *info = curl_version_info(CURLVERSION_NOW); char **p = (char **)info->protocols; @@ -928,20 +1235,10 @@ PHP_MINIT_FUNCTION(curl) (void) *p++; } } -# else - php_unregister_url_stream_wrapper("http"); - php_register_url_stream_wrapper("http", &php_curl_wrapper TSRMLS_CC); - php_unregister_url_stream_wrapper("https"); - php_register_url_stream_wrapper("https", &php_curl_wrapper TSRMLS_CC); - php_unregister_url_stream_wrapper("ftp"); - php_register_url_stream_wrapper("ftp", &php_curl_wrapper TSRMLS_CC); - php_unregister_url_stream_wrapper("ftps"); - php_register_url_stream_wrapper("ftps", &php_curl_wrapper TSRMLS_CC); - php_unregister_url_stream_wrapper("ldap"); - php_register_url_stream_wrapper("ldap", &php_curl_wrapper TSRMLS_CC); -# endif #endif + curlfile_register_class(TSRMLS_C); + return SUCCESS; } /* }}} */ @@ -951,10 +1248,18 @@ PHP_MINIT_FUNCTION(curl) PHP_MSHUTDOWN_FUNCTION(curl) { #ifdef PHP_CURL_URL_WRAPPERS - php_unregister_url_stream_wrapper("http" TSRMLS_CC); - php_unregister_url_stream_wrapper("https" TSRMLS_CC); - php_unregister_url_stream_wrapper("ftp" TSRMLS_CC); - php_unregister_url_stream_wrapper("ldap" TSRMLS_CC); + { + curl_version_info_data *info = curl_version_info(CURLVERSION_NOW); + char **p = (char **)info->protocols; + + while (*p != NULL) { + /* Do not enable cURL "file" protocol and make sure cURL is always used when --with-curlwrappers is enabled */ + if (strncasecmp(*p, "file", sizeof("file")-1) != 0) { + php_unregister_url_stream_wrapper(*p TSRMLS_CC); + } + (void) *p++; + } + } #endif curl_global_cleanup(); #ifdef PHP_CURL_NEED_OPENSSL_TSL @@ -980,7 +1285,7 @@ PHP_MSHUTDOWN_FUNCTION(curl) /* {{{ curl_write_nothing * Used as a work around. See _php_curl_close_ex */ -static size_t curl_write_nothing(char *data, size_t size, size_t nmemb, void *ctx) +static size_t curl_write_nothing(char *data, size_t size, size_t nmemb, void *ctx) { return size * nmemb; } @@ -1062,13 +1367,77 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) } /* }}} */ +#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */ +/* {{{ curl_fnmatch + */ +static int curl_fnmatch(void *ctx, const char *pattern, const char *string) +{ + php_curl *ch = (php_curl *) ctx; + php_curl_fnmatch *t = ch->handlers->fnmatch; + int rval = CURL_FNMATCHFUNC_FAIL; + switch (t->method) { + case PHP_CURL_USER: { + zval **argv[3]; + zval *zhandle = NULL; + zval *zpattern = NULL; + zval *zstring = NULL; + zval *retval_ptr; + int error; + zend_fcall_info fci; + TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); + + MAKE_STD_ZVAL(zhandle); + MAKE_STD_ZVAL(zpattern); + MAKE_STD_ZVAL(zstring); + + ZVAL_RESOURCE(zhandle, ch->id); + zend_list_addref(ch->id); + ZVAL_STRING(zpattern, pattern, 1); + ZVAL_STRING(zstring, string, 1); + + argv[0] = &zhandle; + argv[1] = &zpattern; + argv[2] = &zstring; + + fci.size = sizeof(fci); + fci.function_table = EG(function_table); + fci.function_name = t->func_name; + fci.object_ptr = NULL; + fci.retval_ptr_ptr = &retval_ptr; + fci.param_count = 3; + fci.params = argv; + fci.no_separation = 0; + fci.symbol_table = NULL; + + ch->in_callback = 1; + error = zend_call_function(&fci, &t->fci_cache TSRMLS_CC); + ch->in_callback = 0; + if (error == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_FNMATCH_FUNCTION"); + } else if (retval_ptr) { + if (Z_TYPE_P(retval_ptr) != IS_LONG) { + convert_to_long_ex(&retval_ptr); + } + rval = Z_LVAL_P(retval_ptr); + zval_ptr_dtor(&retval_ptr); + } + zval_ptr_dtor(argv[0]); + zval_ptr_dtor(argv[1]); + zval_ptr_dtor(argv[2]); + break; + } + } + return rval; +} +/* }}} */ +#endif + /* {{{ curl_progress */ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) { php_curl *ch = (php_curl *) clientp; php_curl_progress *t = ch->handlers->progress; - int length = -1; size_t rval = 0; #if PHP_CURL_DEBUG @@ -1078,7 +1447,8 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double switch (t->method) { case PHP_CURL_USER: { - zval **argv[4]; + zval **argv[5]; + zval *handle = NULL; zval *zdltotal = NULL; zval *zdlnow = NULL; zval *zultotal = NULL; @@ -1088,27 +1458,31 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double zend_fcall_info fci; TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); + MAKE_STD_ZVAL(handle); MAKE_STD_ZVAL(zdltotal); MAKE_STD_ZVAL(zdlnow); MAKE_STD_ZVAL(zultotal); MAKE_STD_ZVAL(zulnow); + ZVAL_RESOURCE(handle, ch->id); + zend_list_addref(ch->id); ZVAL_LONG(zdltotal, (long) dltotal); ZVAL_LONG(zdlnow, (long) dlnow); ZVAL_LONG(zultotal, (long) ultotal); ZVAL_LONG(zulnow, (long) ulnow); - argv[0] = &zdltotal; - argv[1] = &zdlnow; - argv[2] = &zultotal; - argv[3] = &zulnow; + argv[0] = &handle; + argv[1] = &zdltotal; + argv[2] = &zdlnow; + argv[3] = &zultotal; + argv[4] = &zulnow; fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = t->func_name; fci.object_ptr = NULL; fci.retval_ptr_ptr = &retval_ptr; - fci.param_count = 4; + fci.param_count = 5; fci.params = argv; fci.no_separation = 0; fci.symbol_table = NULL; @@ -1118,7 +1492,6 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double ch->in_callback = 0; if (error == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION"); - length = -1; } else if (retval_ptr) { if (Z_TYPE_P(retval_ptr) != IS_LONG) { convert_to_long_ex(&retval_ptr); @@ -1132,6 +1505,7 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double zval_ptr_dtor(argv[1]); zval_ptr_dtor(argv[2]); zval_ptr_dtor(argv[3]); + zval_ptr_dtor(argv[4]); break; } } @@ -1432,7 +1806,10 @@ static void alloc_curl_handle(php_curl **ch) (*ch)->handlers->write = ecalloc(1, sizeof(php_curl_write)); (*ch)->handlers->write_header = ecalloc(1, sizeof(php_curl_write)); (*ch)->handlers->read = ecalloc(1, sizeof(php_curl_read)); - (*ch)->handlers->progress = ecalloc(1, sizeof(php_curl_progress)); + (*ch)->handlers->progress = NULL; +#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */ + (*ch)->handlers->fnmatch = NULL; +#endif (*ch)->in_callback = 0; (*ch)->header.str_len = 0; @@ -1445,10 +1822,11 @@ static void alloc_curl_handle(php_curl **ch) zend_llist_init(&(*ch)->to_free->str, sizeof(char *), (llist_dtor_func_t) curl_free_string, 0); zend_llist_init(&(*ch)->to_free->slist, sizeof(struct curl_slist), (llist_dtor_func_t) curl_free_slist, 0); zend_llist_init(&(*ch)->to_free->post, sizeof(struct HttpPost), (llist_dtor_func_t) curl_free_post, 0); + (*ch)->safe_upload = 1; /* for now, for BC reason we allow unsafe API */ } /* }}} */ -#if LIBCURL_VERSION_NUM > 0x071301 +#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */ /* {{{ split_certinfo */ static void split_certinfo(char *string, zval *hash) @@ -1458,15 +1836,15 @@ static void split_certinfo(char *string, zval *hash) char *split; if(org) { - do { + do { char *key; char *val; char *tmp; - split = strstr(s, "; "); - if(split) - *split = '\0'; - + split = strstr(s, "; "); + if(split) + *split = '\0'; + key = s; tmp = memchr(key, '=', 64); if(tmp) { @@ -1486,13 +1864,13 @@ static void split_certinfo(char *string, zval *hash) static void create_certinfo(struct curl_certinfo *ci, zval *listcode TSRMLS_DC) { int i; - + if(ci) { zval *certhash = NULL; - + for(i=0; inum_of_certs; i++) { struct curl_slist *slist; - + MAKE_STD_ZVAL(certhash); array_init(certhash); for(slist = ci->certinfo[i]; slist; slist = slist->next) { @@ -1509,14 +1887,14 @@ static void create_certinfo(struct curl_certinfo *ci, zval *listcode TSRMLS_DC) MAKE_STD_ZVAL(hash); array_init(hash); - + split_certinfo(&slist->data[len+1], hash); add_assoc_zval(certhash, s, hash); } else { add_assoc_string(certhash, s, &slist->data[len+1], 1); } } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not extract hash key from certificate info"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not extract hash key from certificate info"); } } add_next_index_zval(listcode, certhash); @@ -1526,6 +1904,36 @@ static void create_certinfo(struct curl_certinfo *ci, zval *listcode TSRMLS_DC) /* }}} */ #endif +/* {{{ _php_curl_set_default_options() + Set default options for a handle */ +static void _php_curl_set_default_options(php_curl *ch) +{ + char *cainfo; + + curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1); + curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); + curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str); + curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write); + curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch); + curl_easy_setopt(ch->cp, CURLOPT_READFUNCTION, curl_read); + curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch); + curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header); + curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch); + curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1); + curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120); + curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */ + + cainfo = INI_STR("curl.cainfo"); + if (cainfo && strlen(cainfo) > 0) { + curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo); + } + +#if defined(ZTS) + curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1); +#endif +} +/* }}} */ + /* {{{ proto resource curl_init([string url]) Initialize a cURL session */ PHP_FUNCTION(curl_init) @@ -1535,7 +1943,6 @@ PHP_FUNCTION(curl_init) zval *clone; char *url = NULL; int url_len = 0; - char *cainfo; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &url, &url_len) == FAILURE) { return; @@ -1553,36 +1960,13 @@ PHP_FUNCTION(curl_init) ch->cp = cp; ch->handlers->write->method = PHP_CURL_STDOUT; - ch->handlers->write->type = PHP_CURL_ASCII; ch->handlers->read->method = PHP_CURL_DIRECT; ch->handlers->write_header->method = PHP_CURL_IGNORE; - ch->uses = 0; - MAKE_STD_ZVAL(clone); ch->clone = clone; - curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1); - curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); - curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str); - curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write); - curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch); - curl_easy_setopt(ch->cp, CURLOPT_READFUNCTION, curl_read); - curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch); - curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header); - curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch); - curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1); - curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120); - curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */ - - cainfo = INI_STR("curl.cainfo"); - if (cainfo && strlen(cainfo) > 0) { - curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo); - } - -#if defined(ZTS) - curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1); -#endif + _php_curl_set_default_options(ch); if (url) { if (!php_curl_option_url(ch, url, url_len TSRMLS_CC)) { @@ -1620,14 +2004,12 @@ PHP_FUNCTION(curl_copy_handle) TSRMLS_SET_CTX(dupch->thread_ctx); dupch->cp = cp; - dupch->uses = 0; - ch->uses++; + zend_list_addref(Z_LVAL_P(zid)); if (ch->handlers->write->stream) { Z_ADDREF_P(ch->handlers->write->stream); } dupch->handlers->write->stream = ch->handlers->write->stream; dupch->handlers->write->method = ch->handlers->write->method; - dupch->handlers->write->type = ch->handlers->write->type; if (ch->handlers->read->stream) { Z_ADDREF_P(ch->handlers->read->stream); } @@ -1662,18 +2044,34 @@ PHP_FUNCTION(curl_copy_handle) zval_add_ref(&ch->handlers->write_header->func_name); dupch->handlers->write_header->func_name = ch->handlers->write_header->func_name; } - - if (ch->handlers->progress->func_name) { - zval_add_ref(&ch->handlers->progress->func_name); - dupch->handlers->progress->func_name = ch->handlers->progress->func_name; - } - dupch->handlers->progress->method = ch->handlers->progress->method; curl_easy_setopt(dupch->cp, CURLOPT_ERRORBUFFER, dupch->err.str); curl_easy_setopt(dupch->cp, CURLOPT_FILE, (void *) dupch); curl_easy_setopt(dupch->cp, CURLOPT_INFILE, (void *) dupch); curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER, (void *) dupch); - curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch); + + if (ch->handlers->progress) { + dupch->handlers->progress = ecalloc(1, sizeof(php_curl_progress)); + if (ch->handlers->progress->func_name) { + zval_add_ref(&ch->handlers->progress->func_name); + dupch->handlers->progress->func_name = ch->handlers->progress->func_name; + } + dupch->handlers->progress->method = ch->handlers->progress->method; + curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch); + } + +/* Available since 7.21.0 */ +#if LIBCURL_VERSION_NUM >= 0x071500 + if (ch->handlers->fnmatch) { + dupch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch)); + if (ch->handlers->fnmatch->func_name) { + zval_add_ref(&ch->handlers->fnmatch->func_name); + dupch->handlers->fnmatch->func_name = ch->handlers->fnmatch->func_name; + } + dupch->handlers->fnmatch->method = ch->handlers->fnmatch->method; + curl_easy_setopt(dupch->cp, CURLOPT_FNMATCH_DATA, (void *) dupch); + } +#endif efree(dupch->to_free); dupch->to_free = ch->to_free; @@ -1703,89 +2101,151 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu break; #endif } - case CURLOPT_INFILESIZE: - case CURLOPT_VERBOSE: - case CURLOPT_HEADER: - case CURLOPT_NOPROGRESS: - case CURLOPT_NOBODY: - case CURLOPT_FAILONERROR: - case CURLOPT_UPLOAD: - case CURLOPT_POST: - case CURLOPT_FTPLISTONLY: - case CURLOPT_FTPAPPEND: - case CURLOPT_NETRC: - case CURLOPT_PUT: -#if CURLOPT_MUTE != 0 - case CURLOPT_MUTE: -#endif - case CURLOPT_TIMEOUT: -#if LIBCURL_VERSION_NUM > 0x071002 - case CURLOPT_TIMEOUT_MS: -#endif - case CURLOPT_FTP_USE_EPSV: - case CURLOPT_LOW_SPEED_LIMIT: - case CURLOPT_SSLVERSION: - case CURLOPT_LOW_SPEED_TIME: - case CURLOPT_RESUME_FROM: - case CURLOPT_TIMEVALUE: - case CURLOPT_TIMECONDITION: - case CURLOPT_TRANSFERTEXT: - case CURLOPT_HTTPPROXYTUNNEL: - case CURLOPT_FILETIME: - case CURLOPT_MAXREDIRS: - case CURLOPT_MAXCONNECTS: + case CURLOPT_AUTOREFERER: + case CURLOPT_BUFFERSIZE: case CURLOPT_CLOSEPOLICY: - case CURLOPT_FRESH_CONNECT: - case CURLOPT_FORBID_REUSE: case CURLOPT_CONNECTTIMEOUT: -#if LIBCURL_VERSION_NUM > 0x071002 - case CURLOPT_CONNECTTIMEOUT_MS: -#endif - case CURLOPT_SSL_VERIFYPEER: + case CURLOPT_COOKIESESSION: + case CURLOPT_CRLF: + case CURLOPT_DNS_CACHE_TIMEOUT: case CURLOPT_DNS_USE_GLOBAL_CACHE: - case CURLOPT_NOSIGNAL: - case CURLOPT_PROXYTYPE: - case CURLOPT_BUFFERSIZE: + case CURLOPT_FAILONERROR: + case CURLOPT_FILETIME: + case CURLOPT_FORBID_REUSE: + case CURLOPT_FRESH_CONNECT: + case CURLOPT_FTP_USE_EPRT: + case CURLOPT_FTP_USE_EPSV: + case CURLOPT_HEADER: case CURLOPT_HTTPGET: + case CURLOPT_HTTPPROXYTUNNEL: case CURLOPT_HTTP_VERSION: - case CURLOPT_CRLF: - case CURLOPT_DNS_CACHE_TIMEOUT: + case CURLOPT_INFILESIZE: + case CURLOPT_LOW_SPEED_LIMIT: + case CURLOPT_LOW_SPEED_TIME: + case CURLOPT_MAXCONNECTS: + case CURLOPT_MAXREDIRS: + case CURLOPT_NETRC: + case CURLOPT_NOBODY: + case CURLOPT_NOPROGRESS: + case CURLOPT_NOSIGNAL: + case CURLOPT_PORT: + case CURLOPT_POST: case CURLOPT_PROXYPORT: - case CURLOPT_FTP_USE_EPRT: -#if LIBCURL_VERSION_NUM > 0x070a05 /* CURLOPT_HTTPAUTH is available since curl 7.10.6 */ + case CURLOPT_PROXYTYPE: + case CURLOPT_PUT: + case CURLOPT_RESUME_FROM: + case CURLOPT_SSLVERSION: + case CURLOPT_SSL_VERIFYPEER: + case CURLOPT_TIMECONDITION: + case CURLOPT_TIMEOUT: + case CURLOPT_TIMEVALUE: + case CURLOPT_TRANSFERTEXT: + case CURLOPT_UNRESTRICTED_AUTH: + case CURLOPT_UPLOAD: + case CURLOPT_VERBOSE: +#if LIBCURL_VERSION_NUM >= 0x070a06 /* Available since 7.10.6 */ case CURLOPT_HTTPAUTH: #endif -#if LIBCURL_VERSION_NUM > 0x070a06 /* CURLOPT_PROXYAUTH & CURLOPT_FTP_CREATE_MISSING_DIRS are available since curl 7.10.7 */ - case CURLOPT_PROXYAUTH: +#if LIBCURL_VERSION_NUM >= 0x070a07 /* Available since 7.10.7 */ case CURLOPT_FTP_CREATE_MISSING_DIRS: + case CURLOPT_PROXYAUTH: #endif - -#if LIBCURL_VERSION_NUM >= 0x070c02 +#if LIBCURL_VERSION_NUM >= 0x070a08 /* Available since 7.10.8 */ + case CURLOPT_FTP_RESPONSE_TIMEOUT: + case CURLOPT_IPRESOLVE: + case CURLOPT_MAXFILESIZE: +#endif +#if LIBCURL_VERSION_NUM >= 0x070b02 /* Available since 7.11.2 */ + case CURLOPT_TCP_NODELAY: +#endif +#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */ case CURLOPT_FTPSSLAUTH: #endif -#if LIBCURL_VERSION_NUM > 0x070b00 +#if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */ + case CURLOPT_IGNORE_CONTENT_LENGTH: +#endif +#if LIBCURL_VERSION_NUM >= 0x070f00 /* Available since 7.15.0 */ + case CURLOPT_FTP_SKIP_PASV_IP: +#endif +#if LIBCURL_VERSION_NUM >= 0x070f01 /* Available since 7.15.1 */ + case CURLOPT_FTP_FILEMETHOD: +#endif +#if LIBCURL_VERSION_NUM >= 0x070f02 /* Available since 7.15.2 */ + case CURLOPT_CONNECT_ONLY: + case CURLOPT_LOCALPORT: + case CURLOPT_LOCALPORTRANGE: +#endif +#if LIBCURL_VERSION_NUM >= 0x071000 /* Available since 7.16.0 */ + case CURLOPT_SSL_SESSIONID_CACHE: +#endif +#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */ + case CURLOPT_FTP_SSL_CCC: + case CURLOPT_SSH_AUTH_TYPES: +#endif +#if LIBCURL_VERSION_NUM >= 0x071002 /* Available since 7.16.2 */ + case CURLOPT_CONNECTTIMEOUT_MS: + case CURLOPT_HTTP_CONTENT_DECODING: + case CURLOPT_HTTP_TRANSFER_DECODING: + case CURLOPT_TIMEOUT_MS: +#endif +#if LIBCURL_VERSION_NUM >= 0x071004 /* Available since 7.16.4 */ + case CURLOPT_NEW_DIRECTORY_PERMS: + case CURLOPT_NEW_FILE_PERMS: +#endif +#if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */ + case CURLOPT_USE_SSL: +#elif LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */ case CURLOPT_FTP_SSL: #endif - case CURLOPT_UNRESTRICTED_AUTH: - case CURLOPT_PORT: - case CURLOPT_AUTOREFERER: - case CURLOPT_COOKIESESSION: -#if LIBCURL_VERSION_NUM > 0x070b01 /* CURLOPT_TCP_NODELAY is available since curl 7.11.2 */ - case CURLOPT_TCP_NODELAY: +#if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */ + case CURLOPT_APPEND: + case CURLOPT_DIRLISTONLY: +#else + case CURLOPT_FTPAPPEND: + case CURLOPT_FTPLISTONLY: #endif -#if LIBCURL_VERSION_NUM >= 0x71304 - case CURLOPT_REDIR_PROTOCOLS: +#if LIBCURL_VERSION_NUM >= 0x071200 /* Available since 7.18.0 */ + case CURLOPT_PROXY_TRANSFER_MODE: +#endif +#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */ + case CURLOPT_ADDRESS_SCOPE: +#endif +#if LIBCURL_VERSION_NUM > 0x071301 /* Available since 7.19.1 */ + case CURLOPT_CERTINFO: +#endif +#if LIBCURL_VERSION_NUM >= 0x071304 /* Available since 7.19.4 */ + case CURLOPT_NOPROXY: case CURLOPT_PROTOCOLS: + case CURLOPT_REDIR_PROTOCOLS: + case CURLOPT_SOCKS5_GSSAPI_NEC: + case CURLOPT_TFTP_BLKSIZE: #endif -#if LIBCURL_VERSION_NUM > 0x070a07 /* CURLOPT_IPRESOLVE is available since curl 7.10.8 */ - case CURLOPT_IPRESOLVE: +#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */ + case CURLOPT_FTP_USE_PRET: + case CURLOPT_RTSP_CLIENT_CSEQ: + case CURLOPT_RTSP_REQUEST: + case CURLOPT_RTSP_SERVER_CSEQ: #endif -#if LIBCURL_VERSION_NUM >= 0x070f01 - case CURLOPT_FTP_FILEMETHOD: - case CURLOPT_FTP_SKIP_PASV_IP: +#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */ + case CURLOPT_WILDCARDMATCH: #endif -#if LIBCURL_VERSION_NUM > 0x071301 - case CURLOPT_CERTINFO: +#if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */ + case CURLOPT_TLSAUTH_TYPE: +#endif +#if LIBCURL_VERSION_NUM >= 0x071600 /* Available since 7.22.0 */ + case CURLOPT_GSSAPI_DELEGATION: +#endif +#if LIBCURL_VERSION_NUM >= 0x071800 /* Available since 7.24.0 */ + case CURLOPT_ACCEPTTIMEOUT_MS: +#endif +#if LIBCURL_VERSION_NUM >= 0x071900 /* Available since 7.25.0 */ + case CURLOPT_SSL_OPTIONS: + case CURLOPT_TCP_KEEPALIVE: + case CURLOPT_TCP_KEEPIDLE: + case CURLOPT_TCP_KEEPINTVL: +#endif +#if CURLOPT_MUTE != 0 + case CURLOPT_MUTE: #endif convert_to_long_ex(zvalue); #if LIBCURL_VERSION_NUM >= 0x71304 @@ -1798,71 +2258,84 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu #endif error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); break; -#if LIBCURL_VERSION_NUM > 0x070f04 - case CURLOPT_MAX_RECV_SPEED_LARGE: - case CURLOPT_MAX_SEND_SPEED_LARGE: - convert_to_long_ex(zvalue); - error = curl_easy_setopt(ch->cp, option, (curl_off_t)Z_LVAL_PP(zvalue)); - break; -#endif - case CURLOPT_FOLLOWLOCATION: - convert_to_long_ex(zvalue); - if (PG(open_basedir) && *PG(open_basedir)) { - if (Z_LVAL_PP(zvalue) != 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set"); - RETVAL_FALSE; - return 1; - } - } - error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); - break; -#if LIBCURL_VERSION_NUM > 0x071301 - case CURLOPT_POSTREDIR: + case CURLOPT_SAFE_UPLOAD: convert_to_long_ex(zvalue); - error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, Z_LVAL_PP(zvalue) & CURL_REDIR_POST_ALL); + ch->safe_upload = (Z_LVAL_PP(zvalue) != 0); break; -#endif + + /* String options */ + case CURLOPT_CAINFO: + case CURLOPT_CAPATH: + case CURLOPT_COOKIE: + case CURLOPT_CUSTOMREQUEST: + case CURLOPT_EGDSOCKET: + case CURLOPT_FTPPORT: + case CURLOPT_INTERFACE: case CURLOPT_PRIVATE: - case CURLOPT_URL: case CURLOPT_PROXY: - case CURLOPT_USERPWD: case CURLOPT_PROXYUSERPWD: case CURLOPT_RANGE: - case CURLOPT_CUSTOMREQUEST: - case CURLOPT_USERAGENT: - case CURLOPT_FTPPORT: - case CURLOPT_COOKIE: case CURLOPT_REFERER: - case CURLOPT_INTERFACE: - case CURLOPT_KRB4LEVEL: - case CURLOPT_EGDSOCKET: - case CURLOPT_CAINFO: - case CURLOPT_CAPATH: - case CURLOPT_SSL_CIPHER_LIST: - case CURLOPT_SSLKEY: - case CURLOPT_SSLKEYTYPE: - case CURLOPT_SSLKEYPASSWD: + case CURLOPT_SSLCERTTYPE: case CURLOPT_SSLENGINE: case CURLOPT_SSLENGINE_DEFAULT: - case CURLOPT_SSLCERTTYPE: + case CURLOPT_SSLKEY: + case CURLOPT_SSLKEYPASSWD: + case CURLOPT_SSLKEYTYPE: + case CURLOPT_SSL_CIPHER_LIST: + case CURLOPT_URL: + case CURLOPT_USERAGENT: + case CURLOPT_USERPWD: +#if LIBCURL_VERSION_NUM >= 0x070d00 /* Available since 7.13.0 */ + case CURLOPT_FTP_ACCOUNT: +#endif +#if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */ + case CURLOPT_COOKIELIST: +#endif +#if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */ + case CURLOPT_FTP_ALTERNATIVE_TO_USER: +#endif +#if LIBCURL_VERSION_NUM >= 0x071004 /* Available since 7.16.4 */ + case CURLOPT_KRBLEVEL: +#else + case CURLOPT_KRB4LEVEL: +#endif +#if LIBCURL_VERSION_NUM >= 0x071101 /* Available since 7.17.1 */ + case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5: +#endif +#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */ + case CURLOPT_PASSWORD: + case CURLOPT_PROXYPASSWORD: + case CURLOPT_PROXYUSERNAME: + case CURLOPT_USERNAME: +#endif +#if LIBCURL_VERSION_NUM >= 0x071304 /* Available since 7.19.4 */ + case CURLOPT_SOCKS5_GSSAPI_SERVICE: +#endif +#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */ + case CURLOPT_MAIL_FROM: + case CURLOPT_RTSP_SESSION_ID: + case CURLOPT_RTSP_STREAM_URI: + case CURLOPT_RTSP_TRANSPORT: +#endif +#if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */ + case CURLOPT_TLSAUTH_PASSWORD: + case CURLOPT_TLSAUTH_USERNAME: +#endif +#if LIBCURL_VERSION_NUM >= 0x071506 /* Available since 7.21.6 */ + case CURLOPT_ACCEPT_ENCODING: + case CURLOPT_TRANSFER_ENCODING: +#else case CURLOPT_ENCODING: -#if LIBCURL_VERSION_NUM >= 0x071300 - case CURLOPT_SSH_PUBLIC_KEYFILE: - case CURLOPT_SSH_PRIVATE_KEYFILE: +#endif +#if LIBCURL_VERSION_NUM >= 0x071800 /* Available since 7.24.0 */ + case CURLOPT_DNS_SERVERS: +#endif +#if LIBCURL_VERSION_NUM >= 0x071900 /* Available since 7.25.0 */ + case CURLOPT_MAIL_AUTH: #endif { convert_to_string_ex(zvalue); -#if LIBCURL_VERSION_NUM >= 0x071300 - if ( - option == CURLOPT_SSH_PUBLIC_KEYFILE || option == CURLOPT_SSH_PRIVATE_KEYFILE - - ) { - if (php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) { - RETVAL_FALSE; - return 1; - } - } -#endif if (option == CURLOPT_URL) { if (!php_curl_option_url(ch, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue) TSRMLS_CC)) { RETVAL_FALSE; @@ -1881,17 +2354,19 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu #if LIBCURL_VERSION_NUM >= 0x071100 /* Strings passed to libcurl as ’char *’ arguments, are copied by the library... NOTE: before 7.17.0 strings were not copied. */ error = curl_easy_setopt(ch->cp, option, Z_STRVAL_PP(zvalue)); -#else - goto string_copy; +#else + goto string_copy; #endif } } break; } + + /* Curl file handle options */ case CURLOPT_FILE: case CURLOPT_INFILE: - case CURLOPT_WRITEHEADER: - case CURLOPT_STDERR: { + case CURLOPT_STDERR: + case CURLOPT_WRITEHEADER: { FILE *fp = NULL; int type; void * what; @@ -1970,56 +2445,102 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu error = curl_easy_setopt(ch->cp, option, fp); break; } - break; } - case CURLOPT_RETURNTRANSFER: - convert_to_long_ex(zvalue); - if (Z_LVAL_PP(zvalue)) { - ch->handlers->write->method = PHP_CURL_RETURN; - } else { - ch->handlers->write->method = PHP_CURL_STDOUT; - } - break; - case CURLOPT_BINARYTRANSFER: - convert_to_long_ex(zvalue); + /* Curl linked list options */ + case CURLOPT_HTTP200ALIASES: + case CURLOPT_HTTPHEADER: + case CURLOPT_POSTQUOTE: + case CURLOPT_PREQUOTE: + case CURLOPT_QUOTE: + case CURLOPT_TELNETOPTIONS: +#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */ + case CURLOPT_MAIL_RCPT: +#endif +#if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */ + case CURLOPT_RESOLVE: +#endif + { + zval **current; + HashTable *ph; + struct curl_slist *slist = NULL; - if (Z_LVAL_PP(zvalue)) { - ch->handlers->write->type = PHP_CURL_BINARY; - } else { - ch->handlers->write->type = PHP_CURL_ASCII; + ph = HASH_OF(*zvalue); + if (!ph) { + char *name; + switch (option) { + case CURLOPT_HTTPHEADER: + name = "CURLOPT_HTTPHEADER"; + break; + case CURLOPT_QUOTE: + name = "CURLOPT_QUOTE"; + break; + case CURLOPT_HTTP200ALIASES: + name = "CURLOPT_HTTP200ALIASES"; + break; + case CURLOPT_POSTQUOTE: + name = "CURLOPT_POSTQUOTE"; + break; + case CURLOPT_PREQUOTE: + name = "CURLOPT_PREQUOTE"; + break; + case CURLOPT_TELNETOPTIONS: + name = "CURLOPT_TELNETOPTIONS"; + break; +#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */ + case CURLOPT_MAIL_RCPT: + name = "CURLOPT_MAIL_RCPT"; + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */ + case CURLOPT_RESOLVE: + name = "CURLOPT_RESOLVE"; + break; +#endif + } + php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must pass either an object or an array with the %s argument", name); + RETVAL_FALSE; + return 1; } - break; - case CURLOPT_WRITEFUNCTION: - if (ch->handlers->write->func_name) { - zval_ptr_dtor(&ch->handlers->write->func_name); - ch->handlers->write->fci_cache = empty_fcall_info_cache; + + for (zend_hash_internal_pointer_reset(ph); + zend_hash_get_current_data(ph, (void **) ¤t) == SUCCESS; + zend_hash_move_forward(ph) + ) { + SEPARATE_ZVAL(current); + convert_to_string_ex(current); + + slist = curl_slist_append(slist, Z_STRVAL_PP(current)); + if (!slist) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not build curl_slist"); + RETVAL_FALSE; + return 1; + } } - zval_add_ref(zvalue); - ch->handlers->write->func_name = *zvalue; - ch->handlers->write->method = PHP_CURL_USER; + zend_llist_add_element(&ch->to_free->slist, &slist); + + error = curl_easy_setopt(ch->cp, option, slist); + break; - case CURLOPT_READFUNCTION: - if (ch->handlers->read->func_name) { - zval_ptr_dtor(&ch->handlers->read->func_name); - ch->handlers->read->fci_cache = empty_fcall_info_cache; - } - zval_add_ref(zvalue); - ch->handlers->read->func_name = *zvalue; - ch->handlers->read->method = PHP_CURL_USER; + } + + case CURLOPT_BINARYTRANSFER: + /* Do nothing, just backward compatibility */ break; - case CURLOPT_PROGRESSFUNCTION: - curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION, curl_progress); - curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch); - if (ch->handlers->progress->func_name) { - zval_ptr_dtor(&ch->handlers->progress->func_name); - ch->handlers->progress->fci_cache = empty_fcall_info_cache; + + case CURLOPT_FOLLOWLOCATION: + convert_to_long_ex(zvalue); + if (PG(open_basedir) && *PG(open_basedir)) { + if (Z_LVAL_PP(zvalue) != 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set"); + RETVAL_FALSE; + return 1; + } } - zval_add_ref(zvalue); - ch->handlers->progress->func_name = *zvalue; - ch->handlers->progress->method = PHP_CURL_USER; + error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); break; + case CURLOPT_HEADERFUNCTION: if (ch->handlers->write_header->func_name) { zval_ptr_dtor(&ch->handlers->write_header->func_name); @@ -2029,17 +2550,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu ch->handlers->write_header->func_name = *zvalue; ch->handlers->write_header->method = PHP_CURL_USER; break; -#if CURLOPT_PASSWDFUNCTION != 0 - case CURLOPT_PASSWDFUNCTION: - if (ch->handlers->passwd) { - zval_ptr_dtor(&ch->handlers->passwd); - } - zval_add_ref(zvalue); - ch->handlers->passwd = *zvalue; - error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDFUNCTION, curl_passwd); - error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) ch); - break; -#endif + case CURLOPT_POSTFIELDS: if (Z_TYPE_PP(zvalue) == IS_ARRAY || Z_TYPE_PP(zvalue) == IS_OBJECT) { zval **current; @@ -2058,14 +2569,11 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu zend_hash_get_current_data(postfields, (void **) ¤t) == SUCCESS; zend_hash_move_forward(postfields) ) { - char *postval; - char *string_key = NULL; - uint string_key_len; - ulong num_key; - int numeric_key; - - SEPARATE_ZVAL(current); - convert_to_string_ex(current); + char *postval; + char *string_key = NULL; + uint string_key_len; + ulong num_key; + int numeric_key; zend_hash_get_current_key_ex(postfields, &string_key, &string_key_len, &num_key, 0, NULL); @@ -2078,15 +2586,59 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu numeric_key = 0; } + if(Z_TYPE_PP(current) == IS_OBJECT && instanceof_function(Z_OBJCE_PP(current), curl_CURLFile_class TSRMLS_CC)) { + /* new-style file upload */ + zval *prop; + char *type = NULL, *filename = NULL; + + prop = zend_read_property(curl_CURLFile_class, *current, "name", sizeof("name")-1, 0 TSRMLS_CC); + if(Z_TYPE_P(prop) != IS_STRING) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filename for key %s", string_key); + } else { + postval = Z_STRVAL_P(prop); + + if (php_check_open_basedir(postval TSRMLS_CC)) { + RETVAL_FALSE; + return 1; + } + + prop = zend_read_property(curl_CURLFile_class, *current, "mime", sizeof("mime")-1, 0 TSRMLS_CC); + if(Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) { + type = Z_STRVAL_P(prop); + } + prop = zend_read_property(curl_CURLFile_class, *current, "postname", sizeof("postname")-1, 0 TSRMLS_CC); + if(Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) { + filename = Z_STRVAL_P(prop); + } + error = curl_formadd(&first, &last, + CURLFORM_COPYNAME, string_key, + CURLFORM_NAMELENGTH, (long)string_key_len - 1, + CURLFORM_FILENAME, filename ? filename : postval, + CURLFORM_CONTENTTYPE, type ? type : "application/octet-stream", + CURLFORM_FILE, postval, + CURLFORM_END); + } + + if (numeric_key) { + efree(string_key); + } + continue; + } + + SEPARATE_ZVAL(current); + convert_to_string_ex(current); + postval = Z_STRVAL_PP(current); /* The arguments after _NAMELENGTH and _CONTENTSLENGTH * must be explicitly cast to long in curl_formadd * use since curl needs a long not an int. */ - if (*postval == '@') { + if (!ch->safe_upload && *postval == '@') { char *type, *filename; ++postval; + php_error_docref("curl.curlfile" TSRMLS_CC, E_DEPRECATED, "The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead"); + if ((type = php_memnstr(postval, ";type=", sizeof(";type=") - 1, postval + Z_STRLEN_PP(current)))) { *type = '\0'; } @@ -2155,48 +2707,99 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu #endif } break; - case CURLOPT_HTTPHEADER: - case CURLOPT_QUOTE: - case CURLOPT_HTTP200ALIASES: - case CURLOPT_POSTQUOTE: { - zval **current; - HashTable *ph; - struct curl_slist *slist = NULL; - ph = HASH_OF(*zvalue); - if (!ph) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must pass either an object or an array with the CURLOPT_HTTPHEADER, CURLOPT_QUOTE, CURLOPT_HTTP200ALIASES and CURLOPT_POSTQUOTE arguments"); - RETVAL_FALSE; - return 1; + case CURLOPT_PROGRESSFUNCTION: + curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION, curl_progress); + curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch); + if (ch->handlers->progress == NULL) { + ch->handlers->progress = ecalloc(1, sizeof(php_curl_progress)); + } else if (ch->handlers->progress->func_name) { + zval_ptr_dtor(&ch->handlers->progress->func_name); + ch->handlers->progress->fci_cache = empty_fcall_info_cache; + } + zval_add_ref(zvalue); + ch->handlers->progress->func_name = *zvalue; + ch->handlers->progress->method = PHP_CURL_USER; + break; + + case CURLOPT_READFUNCTION: + if (ch->handlers->read->func_name) { + zval_ptr_dtor(&ch->handlers->read->func_name); + ch->handlers->read->fci_cache = empty_fcall_info_cache; } + zval_add_ref(zvalue); + ch->handlers->read->func_name = *zvalue; + ch->handlers->read->method = PHP_CURL_USER; + break; - for (zend_hash_internal_pointer_reset(ph); - zend_hash_get_current_data(ph, (void **) ¤t) == SUCCESS; - zend_hash_move_forward(ph) - ) { - SEPARATE_ZVAL(current); - convert_to_string_ex(current); + case CURLOPT_RETURNTRANSFER: + convert_to_long_ex(zvalue); + if (Z_LVAL_PP(zvalue)) { + ch->handlers->write->method = PHP_CURL_RETURN; + } else { + ch->handlers->write->method = PHP_CURL_STDOUT; + } + break; - slist = curl_slist_append(slist, Z_STRVAL_PP(current)); - if (!slist) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not build curl_slist"); - RETVAL_FALSE; - return 1; - } + case CURLOPT_WRITEFUNCTION: + if (ch->handlers->write->func_name) { + zval_ptr_dtor(&ch->handlers->write->func_name); + ch->handlers->write->fci_cache = empty_fcall_info_cache; } - zend_llist_add_element(&ch->to_free->slist, &slist); + zval_add_ref(zvalue); + ch->handlers->write->func_name = *zvalue; + ch->handlers->write->method = PHP_CURL_USER; + break; - error = curl_easy_setopt(ch->cp, option, slist); +#if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */ + case CURLOPT_MAX_RECV_SPEED_LARGE: + case CURLOPT_MAX_SEND_SPEED_LARGE: + convert_to_long_ex(zvalue); + error = curl_easy_setopt(ch->cp, option, (curl_off_t)Z_LVAL_PP(zvalue)); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */ + case CURLOPT_POSTREDIR: + convert_to_long_ex(zvalue); + error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, Z_LVAL_PP(zvalue) & CURL_REDIR_POST_ALL); break; - } +#endif + +#if CURLOPT_PASSWDFUNCTION != 0 + case CURLOPT_PASSWDFUNCTION: + if (ch->handlers->passwd) { + zval_ptr_dtor(&ch->handlers->passwd); + } + zval_add_ref(zvalue); + ch->handlers->passwd = *zvalue; + error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDFUNCTION, curl_passwd); + error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) ch); + break; +#endif + /* the following options deal with files, therefore the open_basedir check * is required. */ + case CURLOPT_COOKIEFILE: case CURLOPT_COOKIEJAR: - case CURLOPT_SSLCERT: case CURLOPT_RANDOM_FILE: - case CURLOPT_COOKIEFILE: { + case CURLOPT_SSLCERT: +#if LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */ + case CURLOPT_NETRC_FILE: +#endif +#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */ + case CURLOPT_SSH_PRIVATE_KEYFILE: + case CURLOPT_SSH_PUBLIC_KEYFILE: +#endif +#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */ + case CURLOPT_CRLFILE: + case CURLOPT_ISSUERCERT: +#endif +#if LIBCURL_VERSION_NUM >= 0x071306 /* Available since 7.19.6 */ + case CURLOPT_SSH_KNOWNHOSTS: +#endif + { #if LIBCURL_VERSION_NUM < 0x071100 char *copystr = NULL; #endif @@ -2218,6 +2821,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu #endif break; } + case CURLINFO_HEADER_OUT: convert_to_long_ex(zvalue); if (Z_LVAL_PP(zvalue) == 1) { @@ -2230,6 +2834,32 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); } break; + + case CURLOPT_SHARE: + { + php_curlsh *sh = NULL; + ZEND_FETCH_RESOURCE_NO_RETURN(sh, php_curlsh *, zvalue, -1, le_curl_share_handle_name, le_curl_share_handle); + if (sh) { + curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share); + } + } + +#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */ + case CURLOPT_FNMATCH_FUNCTION: + curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_FUNCTION, curl_fnmatch); + curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_DATA, ch); + if (ch->handlers->fnmatch == NULL) { + ch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch)); + } else if (ch->handlers->fnmatch->func_name) { + zval_ptr_dtor(&ch->handlers->fnmatch->func_name); + ch->handlers->fnmatch->fci_cache = empty_fcall_info_cache; + } + zval_add_ref(zvalue); + ch->handlers->fnmatch->func_name = *zvalue; + ch->handlers->fnmatch->method = PHP_CURL_USER; + break; +#endif + } SAVE_CURL_ERROR(ch, error); @@ -2255,7 +2885,7 @@ PHP_FUNCTION(curl_setopt) ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); - if (options <= 0) { + if (options <= 0 && options != CURLOPT_SAFE_UPLOAD) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid curl configuration option"); RETURN_FALSE; } @@ -2466,7 +3096,17 @@ PHP_FUNCTION(curl_getinfo) if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code) == CURLE_OK) { CAAD("redirect_time", d_code); } -#if LIBCURL_VERSION_NUM > 0x071301 +#if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */ + if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) { + CAAS("redirect_url", s_code); + } +#endif +#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */ + if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) { + CAAS("primary_ip", s_code); + } +#endif +#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */ if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) { MAKE_STD_ZVAL(listcode); array_init(listcode); @@ -2474,12 +3114,7 @@ PHP_FUNCTION(curl_getinfo) CAAZ("certinfo", listcode); } #endif -#if LIBCURL_VERSION_NUM >= 0x071300 /* 7.19.0 */ - if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) { - CAAS("primary_ip", s_code); - } -#endif -#if LIBCURL_VERSION_NUM > 0x071500 +#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */ if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_PORT, &l_code) == CURLE_OK) { CAAL("primary_port", l_code); } @@ -2489,94 +3124,24 @@ PHP_FUNCTION(curl_getinfo) if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_PORT, &l_code) == CURLE_OK) { CAAL("local_port", l_code); } -#endif -#if LIBCURL_VERSION_NUM >= 0x071202 - if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) { - CAAS("redirect_url", s_code); - } #endif if (ch->header.str_len > 0) { CAAS("request_header", ch->header.str); } } else { switch (option) { - /* string variable types */ -#if LIBCURL_VERSION_NUM >= 0x071300 /* 7.19.0 */ - case CURLINFO_PRIMARY_IP: -#endif -#if LIBCURL_VERSION_NUM >= 0x071500 /* 7.21.0 */ - case CURLINFO_LOCAL_IP: -#endif - case CURLINFO_PRIVATE: - case CURLINFO_EFFECTIVE_URL: - case CURLINFO_CONTENT_TYPE: -#if LIBCURL_VERSION_NUM >= 0x071202 - case CURLINFO_REDIRECT_URL: -#endif - { - char *s_code = NULL; - - if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) { - RETURN_STRING(s_code, 1); - } else { - RETURN_FALSE; - } - break; - } - /* Long variable types */ -#if LIBCURL_VERSION_NUM >= 0x071500 /* 7.21.0 */ - case CURLINFO_PRIMARY_PORT: - case CURLINFO_LOCAL_PORT: -#endif - case CURLINFO_HTTP_CODE: - case CURLINFO_HEADER_SIZE: - case CURLINFO_REQUEST_SIZE: - case CURLINFO_FILETIME: - case CURLINFO_SSL_VERIFYRESULT: - case CURLINFO_REDIRECT_COUNT: { - long code = 0; - - if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) { - RETURN_LONG(code); - } else { - RETURN_FALSE; - } - break; - } - /* Double variable types */ - case CURLINFO_TOTAL_TIME: - case CURLINFO_NAMELOOKUP_TIME: - case CURLINFO_CONNECT_TIME: - case CURLINFO_PRETRANSFER_TIME: - case CURLINFO_SIZE_UPLOAD: - case CURLINFO_SIZE_DOWNLOAD: - case CURLINFO_SPEED_DOWNLOAD: - case CURLINFO_SPEED_UPLOAD: - case CURLINFO_CONTENT_LENGTH_DOWNLOAD: - case CURLINFO_CONTENT_LENGTH_UPLOAD: - case CURLINFO_STARTTRANSFER_TIME: - case CURLINFO_REDIRECT_TIME: { - double code = 0.0; - - if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) { - RETURN_DOUBLE(code); - } else { - RETURN_FALSE; - } - break; - } case CURLINFO_HEADER_OUT: if (ch->header.str_len > 0) { RETURN_STRINGL(ch->header.str, ch->header.str_len, 1); } else { RETURN_FALSE; } -#if LIBCURL_VERSION_NUM > 0x071301 +#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */ case CURLINFO_CERTINFO: { struct curl_certinfo *ci = NULL; array_init(return_value); - + if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) { create_certinfo(ci, return_value TSRMLS_CC); } else { @@ -2585,6 +3150,61 @@ PHP_FUNCTION(curl_getinfo) break; } #endif + default: { + int type = CURLINFO_TYPEMASK & option; + switch (type) { + case CURLINFO_STRING: + { + char *s_code = NULL; + + if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) { + RETURN_STRING(s_code, 1); + } else { + RETURN_FALSE; + } + break; + } + case CURLINFO_LONG: + { + long code = 0; + + if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) { + RETURN_LONG(code); + } else { + RETURN_FALSE; + } + break; + } + case CURLINFO_DOUBLE: + { + double code = 0.0; + + if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) { + RETURN_DOUBLE(code); + } else { + RETURN_FALSE; + } + break; + } + case CURLINFO_SLIST: + { + struct curl_slist *slist; + array_init(return_value); + if (curl_easy_getinfo(ch->cp, option, &slist) == CURLE_OK) { + while (slist) { + add_next_index_string(return_value, slist->data, 1); + slist = slist->next; + } + curl_slist_free_all(slist); + } else { + RETURN_FALSE; + } + break; + } + default: + RETURN_FALSE; + } + } } } } @@ -2643,11 +3263,7 @@ PHP_FUNCTION(curl_close) return; } - if (ch->uses) { - ch->uses--; - } else { - zend_list_delete(Z_LVAL_P(zid)); - } + zend_list_delete(Z_LVAL_P(zid)); } /* }}} */ @@ -2661,16 +3277,16 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC) _php_curl_verify_handlers(ch, 0 TSRMLS_CC); - /* + /* * Libcurl is doing connection caching. When easy handle is cleaned up, - * if the handle was previously used by the curl_multi_api, the connection + * if the handle was previously used by the curl_multi_api, the connection * remains open un the curl multi handle is cleaned up. Some protocols are - * sending content like the FTP one, and libcurl try to use the + * sending content like the FTP one, and libcurl try to use the * WRITEFUNCTION or the HEADERFUNCTION. Since structures used in those * callback are freed, we need to use an other callback to which avoid * segfaults. * - * Libcurl commit d021f2e8a00 fix this issue and should be part of 7.28.2 + * Libcurl commit d021f2e8a00 fix this issue and should be part of 7.28.2 */ curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_nothing); curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write_nothing); @@ -2700,12 +3316,11 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC) if (ch->handlers->write_header->func_name) { zval_ptr_dtor(&ch->handlers->write_header->func_name); } - if (ch->handlers->progress->func_name) { - zval_ptr_dtor(&ch->handlers->progress->func_name); - } +#if CURLOPT_PASSWDFUNCTION != 0 if (ch->handlers->passwd) { zval_ptr_dtor(&ch->handlers->passwd); } +#endif if (ch->handlers->std_err) { zval_ptr_dtor(&ch->handlers->std_err); } @@ -2726,7 +3341,23 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC) efree(ch->handlers->write); efree(ch->handlers->write_header); efree(ch->handlers->read); - efree(ch->handlers->progress); + + if (ch->handlers->progress) { + if (ch->handlers->progress->func_name) { + zval_ptr_dtor(&ch->handlers->progress->func_name); + } + efree(ch->handlers->progress); + } + +#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */ + if (ch->handlers->fnmatch) { + if (ch->handlers->fnmatch->func_name) { + zval_ptr_dtor(&ch->handlers->fnmatch->func_name); + } + efree(ch->handlers->fnmatch); + } +#endif + efree(ch->handlers); efree(ch); } @@ -2741,6 +3372,176 @@ static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC) } /* }}} */ +#if LIBCURL_VERSION_NUM >= 0x070c00 /* Available since 7.12.0 */ +/* {{{ proto bool curl_strerror(int code) + return string describing error code */ +PHP_FUNCTION(curl_strerror) +{ + long code; + const char *str; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &code) == FAILURE) { + return; + } + + str = curl_easy_strerror(code); + if (str) { + RETURN_STRING(str, 1); + } else { + RETURN_NULL(); + } +} +/* }}} */ +#endif + +#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */ +/* {{{ _php_curl_reset_handlers() + Reset all handlers of a given php_curl */ +static void _php_curl_reset_handlers(php_curl *ch) +{ + if (ch->handlers->write->stream) { + Z_DELREF_P(ch->handlers->write->stream); + ch->handlers->write->stream = NULL; + } + ch->handlers->write->fp = NULL; + ch->handlers->write->method = PHP_CURL_STDOUT; + + if (ch->handlers->write_header->stream) { + Z_DELREF_P(ch->handlers->write_header->stream); + ch->handlers->write_header->stream = NULL; + } + ch->handlers->write_header->fp = NULL; + ch->handlers->write_header->method = PHP_CURL_IGNORE; + + if (ch->handlers->read->stream) { + Z_DELREF_P(ch->handlers->read->stream); + ch->handlers->read->stream = NULL; + } + ch->handlers->read->fp = NULL; + ch->handlers->read->fd = 0; + ch->handlers->read->method = PHP_CURL_DIRECT; + + if (ch->handlers->std_err) { + zval_ptr_dtor(&ch->handlers->std_err); + ch->handlers->std_err = NULL; + } + + if (ch->handlers->progress) { + if (ch->handlers->progress->func_name) { + zval_ptr_dtor(&ch->handlers->progress->func_name); + } + efree(ch->handlers->progress); + ch->handlers->progress = NULL; + } + +#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */ + if (ch->handlers->fnmatch) { + if (ch->handlers->fnmatch->func_name) { + zval_ptr_dtor(&ch->handlers->fnmatch->func_name); + } + efree(ch->handlers->fnmatch); + ch->handlers->fnmatch = NULL; + } +#endif + +} +/* }}} */ + +/* {{{ proto void curl_reset(resource ch) + Reset all options of a libcurl session handle */ +PHP_FUNCTION(curl_reset) +{ + zval *zid; + php_curl *ch; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zid) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); + + if (ch->in_callback) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reset cURL handle from a callback"); + return; + } + + curl_easy_reset(ch->cp); + _php_curl_reset_handlers(ch); + _php_curl_set_default_options(ch); +} +/* }}} */ +#endif + +#if LIBCURL_VERSION_NUM > 0x070f03 /* 7.15.4 */ +/* {{{ proto void curl_escape(resource ch, string str) + URL encodes the given string */ +PHP_FUNCTION(curl_escape) +{ + char *str = NULL, *res = NULL; + int str_len = 0; + zval *zid; + php_curl *ch; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &zid, &str, &str_len) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); + + if ((res = curl_easy_escape(ch->cp, str, str_len))) { + RETVAL_STRING(res, 1); + free(res); + } else { + RETURN_FALSE; + } +} +/* }}} */ + +/* {{{ proto void curl_unescape(resource ch, string str) + URL decodes the given string */ +PHP_FUNCTION(curl_unescape) +{ + char *str = NULL, *out = NULL; + int str_len = 0, out_len; + zval *zid; + php_curl *ch; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &zid, &str, &str_len) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); + + if ((out = curl_easy_unescape(ch->cp, str, str_len, &out_len))) { + RETVAL_STRINGL(out, out_len, 1); + free(out); + } else { + RETURN_FALSE; + } +} +/* }}} */ +#endif + +#if LIBCURL_VERSION_NUM >= 0x071200 /* 7.18.0 */ +/* {{{ proto void curl_pause(resource ch, int bitmask) + pause and unpause a connection */ +PHP_FUNCTION(curl_pause) +{ + long bitmask; + zval *zid; + php_curl *ch; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &zid, &bitmask) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); + + RETURN_LONG(curl_easy_pause(ch->cp, bitmask)); +} +/* }}} */ +#endif + #endif /* HAVE_CURL */ /* diff --git a/ext/curl/multi.c b/ext/curl/multi.c index 38c1f1a53fb4f..af78651ba16ef 100644 --- a/ext/curl/multi.c +++ b/ext/curl/multi.c @@ -86,7 +86,6 @@ PHP_FUNCTION(curl_multi_add_handle) ZEND_FETCH_RESOURCE(ch, php_curl *, &z_ch, -1, le_curl_name, le_curl); _php_curl_cleanup_handle(ch); - ch->uses++; /* we want to create a copy of this zval that we store in the multihandle structure element "easyh" */ tmp_val = *z_ch; @@ -113,11 +112,7 @@ void _php_curl_multi_cleanup_list(void *data) /* {{{ */ return; } - if (ch->uses) { - ch->uses--; - } else { - zend_list_delete(Z_LVAL_P(z_ch)); - } + zend_list_delete(Z_LVAL_P(z_ch)); } /* }}} */ @@ -125,8 +120,8 @@ void _php_curl_multi_cleanup_list(void *data) /* {{{ */ static int curl_compare_resources( zval *z1, zval **z2 ) /* {{{ */ { return (Z_TYPE_P( z1 ) == Z_TYPE_PP( z2 ) && - Z_TYPE_P( z1 ) == IS_RESOURCE && - Z_LVAL_P( z1 ) == Z_LVAL_PP( z2 ) ); + Z_TYPE_P( z1 ) == IS_RESOURCE && + Z_LVAL_P( z1 ) == Z_LVAL_PP( z2 ) ); } /* }}} */ @@ -146,12 +141,12 @@ PHP_FUNCTION(curl_multi_remove_handle) ZEND_FETCH_RESOURCE(mh, php_curlm *, &z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle); ZEND_FETCH_RESOURCE(ch, php_curl *, &z_ch, -1, le_curl_name, le_curl); - --ch->uses; + + RETVAL_LONG((long) curl_multi_remove_handle(mh->multi, ch->cp)); zend_llist_del_element( &mh->easyh, &z_ch, (int (*)(void *, void *)) curl_compare_resources ); - - RETURN_LONG((long) curl_multi_remove_handle(mh->multi, ch->cp)); + } /* }}} */ @@ -359,6 +354,81 @@ void _php_curl_multi_close(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */ } /* }}} */ +#if LIBCURL_VERSION_NUM >= 0x070c00 /* Available since 7.12.0 */ +/* {{{ proto bool curl_multi_strerror(int code) + return string describing error code */ +PHP_FUNCTION(curl_multi_strerror) +{ + long code; + const char *str; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &code) == FAILURE) { + return; + } + + str = curl_multi_strerror(code); + if (str) { + RETURN_STRING(str, 1); + } else { + RETURN_NULL(); + } +} +/* }}} */ +#endif + +#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */ +static int _php_curl_multi_setopt(php_curlm *mh, long option, zval **zvalue, zval *return_value TSRMLS_DC) /* {{{ */ +{ + CURLMcode error = CURLM_OK; + + switch (option) { +#if LIBCURL_VERSION_NUM >= 0x071000 /* 7.16.0 */ + case CURLMOPT_PIPELINING: +#endif +#if LIBCURL_VERSION_NUM >= 0x071003 /* 7.16.3 */ + case CURLMOPT_MAXCONNECTS: +#endif + convert_to_long_ex(zvalue); + error = curl_multi_setopt(mh->multi, option, Z_LVAL_PP(zvalue)); + break; + + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid curl multi configuration option"); + error = CURLM_UNKNOWN_OPTION; + break; + } + + if (error != CURLM_OK) { + return 1; + } else { + return 0; + } +} +/* }}} */ + +/* {{{ proto int curl_multi_setopt(resource mh, int option, mixed value) + Set an option for the curl multi handle */ +PHP_FUNCTION(curl_multi_setopt) +{ + zval *z_mh, **zvalue; + long options; + php_curlm *mh; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlZ", &z_mh, &options, &zvalue) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(mh, php_curlm *, &z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle); + + if (!_php_curl_multi_setopt(mh, options, zvalue, return_value TSRMLS_CC)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} +/* }}} */ +#endif + #endif /* diff --git a/ext/curl/package.xml b/ext/curl/package.xml index 85cb634c63133..c14321738df23 100644 --- a/ext/curl/package.xml +++ b/ext/curl/package.xml @@ -39,6 +39,7 @@ package.xml added to support installation using pear installer + diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h index 945f0a4307cfe..c4222c05883b8 100644 --- a/ext/curl/php_curl.h +++ b/ext/curl/php_curl.h @@ -34,6 +34,14 @@ #define PHP_CURL_DEBUG 0 +#ifdef PHP_WIN32 +# define PHP_CURL_API __declspec(dllexport) +#elif defined(__GNUC__) && __GNUC__ >= 4 +# define PHP_CURL_API __attribute__ ((visibility("default"))) +#else +# define PHP_CURL_API +#endif + #include #include @@ -41,43 +49,73 @@ extern zend_module_entry curl_module_entry; #define curl_module_ptr &curl_module_entry #define CURLOPT_RETURNTRANSFER 19913 -#define CURLOPT_BINARYTRANSFER 19914 +#define CURLOPT_BINARYTRANSFER 19914 /* For Backward compatibility */ #define PHP_CURL_STDOUT 0 #define PHP_CURL_FILE 1 #define PHP_CURL_USER 2 #define PHP_CURL_DIRECT 3 #define PHP_CURL_RETURN 4 -#define PHP_CURL_ASCII 5 -#define PHP_CURL_BINARY 6 #define PHP_CURL_IGNORE 7 extern int le_curl; #define le_curl_name "cURL handle" extern int le_curl_multi_handle; #define le_curl_multi_handle_name "cURL Multi Handle" +extern int le_curl_share_handle; +#define le_curl_share_handle_name "cURL Share Handle" PHP_MINIT_FUNCTION(curl); PHP_MSHUTDOWN_FUNCTION(curl); PHP_MINFO_FUNCTION(curl); -PHP_FUNCTION(curl_version); -PHP_FUNCTION(curl_init); + +PHP_FUNCTION(curl_close); PHP_FUNCTION(curl_copy_handle); -PHP_FUNCTION(curl_setopt); -PHP_FUNCTION(curl_setopt_array); +PHP_FUNCTION(curl_errno); +PHP_FUNCTION(curl_error); PHP_FUNCTION(curl_exec); PHP_FUNCTION(curl_getinfo); -PHP_FUNCTION(curl_error); -PHP_FUNCTION(curl_errno); -PHP_FUNCTION(curl_close); -PHP_FUNCTION(curl_multi_init); +PHP_FUNCTION(curl_init); +PHP_FUNCTION(curl_setopt); +PHP_FUNCTION(curl_setopt_array); +PHP_FUNCTION(curl_version); + PHP_FUNCTION(curl_multi_add_handle); -PHP_FUNCTION(curl_multi_remove_handle); -PHP_FUNCTION(curl_multi_select); +PHP_FUNCTION(curl_multi_close); PHP_FUNCTION(curl_multi_exec); PHP_FUNCTION(curl_multi_getcontent); PHP_FUNCTION(curl_multi_info_read); -PHP_FUNCTION(curl_multi_close); +PHP_FUNCTION(curl_multi_init); +PHP_FUNCTION(curl_multi_remove_handle); +PHP_FUNCTION(curl_multi_select); + +PHP_FUNCTION(curl_share_close); +PHP_FUNCTION(curl_share_init); +PHP_FUNCTION(curl_share_setopt); + +#if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */ +PHP_FUNCTION(curl_strerror); +PHP_FUNCTION(curl_multi_strerror); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */ +PHP_FUNCTION(curl_reset); +#endif + +#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */ +PHP_FUNCTION(curl_escape); +PHP_FUNCTION(curl_unescape); + +PHP_FUNCTION(curl_multi_setopt); +#endif + +#if LIBCURL_VERSION_NUM >= 0x071200 /* 7.18.0 */ +PHP_FUNCTION(curl_pause); +#endif +PHP_FUNCTION(curl_file_create); + + void _php_curl_multi_close(zend_rsrc_list_entry * TSRMLS_DC); +void _php_curl_share_close(zend_rsrc_list_entry * TSRMLS_DC); typedef struct { zval *func_name; @@ -85,7 +123,6 @@ typedef struct { FILE *fp; smart_str buf; int method; - int type; zval *stream; } php_curl_write; @@ -102,15 +139,20 @@ typedef struct { zval *func_name; zend_fcall_info_cache fci_cache; int method; -} php_curl_progress; +} php_curl_progress, php_curl_fnmatch; typedef struct { php_curl_write *write; php_curl_write *write_header; php_curl_read *read; +#if CURLOPT_PASSWDFUNCTION != 0 zval *passwd; +#endif zval *std_err; php_curl_progress *progress; +#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */ + php_curl_fnmatch *fnmatch; +#endif } php_curl_handlers; struct _php_curl_error { @@ -137,17 +179,23 @@ typedef struct { CURL *cp; php_curl_handlers *handlers; long id; - unsigned int uses; zend_bool in_callback; zval *clone; + zend_bool safe_upload; } php_curl; +#define CURLOPT_SAFE_UPLOAD -1 + typedef struct { int still_running; CURLM *multi; zend_llist easyh; } php_curlm; +typedef struct { + CURLSH *share; +} php_curlsh; + void _php_curl_cleanup_handle(php_curl *); void _php_curl_multi_cleanup_list(void *data); int _php_curl_verify_handlers(php_curl *ch, int reporterror TSRMLS_DC); @@ -176,7 +224,7 @@ typedef struct { fd_set readfds, writefds, excfds; int maxfd; - + char errstr[CURL_ERROR_SIZE + 1]; CURLMcode mcode; int pending; @@ -184,6 +232,8 @@ typedef struct { struct curl_slist *headers_slist; /* holds custom headers sent out in the request */ } php_curl_stream; +void curlfile_register_class(TSRMLS_D); +PHP_CURL_API extern zend_class_entry *curl_CURLFile_class; #else #define curl_module_ptr NULL diff --git a/ext/curl/share.c b/ext/curl/share.c new file mode 100644 index 0000000000000..d1aed879402b8 --- /dev/null +++ b/ext/curl/share.c @@ -0,0 +1,136 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Pierrick Charron | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" + +#if HAVE_CURL + +#include "php_curl.h" + +#include + +/* {{{ proto void curl_share_init() + Initialize a share curl handle */ +PHP_FUNCTION(curl_share_init) +{ + php_curlsh *sh; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + sh = ecalloc(1, sizeof(php_curlsh)); + + sh->share = curl_share_init(); + + ZEND_REGISTER_RESOURCE(return_value, sh, le_curl_share_handle); +} +/* }}} */ + +/* {{{ proto void curl_share_close(resource sh) + Close a set of cURL handles */ +PHP_FUNCTION(curl_share_close) +{ + zval *z_sh; + php_curlsh *sh; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_sh) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(sh, php_curlsh *, &z_sh, -1, le_curl_share_handle_name, le_curl_share_handle); + zend_list_delete(Z_LVAL_P(z_sh)); +} +/* }}} */ + +static int _php_curl_share_setopt(php_curlsh *sh, long option, zval **zvalue, zval *return_value TSRMLS_DC) /* {{{ */ +{ + CURLSHcode error = CURLSHE_OK; + + switch (option) { + case CURLSHOPT_SHARE: + case CURLSHOPT_UNSHARE: + convert_to_long_ex(zvalue); + error = curl_share_setopt(sh->share, option, Z_LVAL_PP(zvalue)); + break; + + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid curl share configuration option"); + error = CURLSHE_BAD_OPTION; + break; + } + + if (error != CURLSHE_OK) { + return 1; + } else { + return 0; + } +} +/* }}} */ + +/* {{{ proto bool curl_share_setopt(resource sh, int option, mixed value) + Set an option for a cURL transfer */ +PHP_FUNCTION(curl_share_setopt) +{ + zval *zid, **zvalue; + long options; + php_curlsh *sh; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlZ", &zid, &options, &zvalue) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(sh, php_curlsh *, &zid, -1, le_curl_share_handle_name, le_curl_share_handle); + + if (!_php_curl_share_setopt(sh, options, zvalue, return_value TSRMLS_CC)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} +/* }}} */ + +void _php_curl_share_close(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */ +{ + php_curlsh *sh = (php_curlsh *) rsrc->ptr; + if (sh) { + curl_share_cleanup(sh->share); + efree(sh); + rsrc->ptr = NULL; + } +} +/* }}} */ + +#endif + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/curl/tests/bug27023.phpt b/ext/curl/tests/bug27023.phpt index b738c956e9280..62effec990be4 100644 --- a/ext/curl/tests/bug27023.phpt +++ b/ext/curl/tests/bug27023.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files) +--INI-- +error_reporting = E_ALL & ~E_DEPRECATED --SKIPIF-- 0x070a08) { + exit("skip: tests works a versions of curl >= 7.10.8"); +} +if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { + exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); +} +?> +--FILE-- + +--EXPECTF-- +bool(true) diff --git a/ext/curl/tests/curl_basic_022.phpt b/ext/curl/tests/curl_basic_022.phpt new file mode 100644 index 0000000000000..d4277a3f89966 --- /dev/null +++ b/ext/curl/tests/curl_basic_022.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test curl_getinfo() function with CURLINFO_COOKIELIST parameter +--SKIPIF-- += 7.14.1"); +} +?> +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + string(38) ".php.net TRUE / FALSE 2145916799 C1 v1" + [1]=> + string(38) ".php.net TRUE / FALSE 2145916799 C2 v2" +} diff --git a/ext/curl/tests/curl_escape.phpt b/ext/curl/tests/curl_escape.phpt new file mode 100644 index 0000000000000..e759144c8ac87 Binary files /dev/null and b/ext/curl/tests/curl_escape.phpt differ diff --git a/ext/curl/tests/curl_file_serialize.phpt b/ext/curl/tests/curl_file_serialize.phpt new file mode 100644 index 0000000000000..43b272ad64a01 --- /dev/null +++ b/ext/curl/tests/curl_file_serialize.phpt @@ -0,0 +1,21 @@ +--TEST-- +CURL file uploading +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught exception 'Exception' with message 'Unserialization of CURLFile instances is not allowed' in %s +Stack trace: +#0 [internal function]: CURLFile->__wakeup() +#1 %s +#2 {main} + thrown in %s on line %d + diff --git a/ext/curl/tests/curl_file_upload.phpt b/ext/curl/tests/curl_file_upload.phpt new file mode 100644 index 0000000000000..d3168e578ac98 --- /dev/null +++ b/ext/curl/tests/curl_file_upload.phpt @@ -0,0 +1,85 @@ +--TEST-- +CURL file uploading +--SKIPIF-- + +--FILE-- + $file)); + var_dump(curl_exec($ch)); +} + +$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file"); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + +testcurl($ch, __DIR__ . '/curl_testdata1.txt'); +testcurl($ch, __DIR__ . '/curl_testdata1.txt', 'text/plain'); +testcurl($ch, __DIR__ . '/curl_testdata1.txt', '', 'foo.txt'); +testcurl($ch, __DIR__ . '/curl_testdata1.txt', 'text/plain', 'foo.txt'); + +$file = new CurlFile(__DIR__ . '/curl_testdata1.txt'); +$file->setMimeType('text/plain'); +var_dump($file->getMimeType()); +var_dump($file->getFilename()); +curl_setopt($ch, CURLOPT_POSTFIELDS, array("file" => $file)); +var_dump(curl_exec($ch)); + +$file = curl_file_create(__DIR__ . '/curl_testdata1.txt'); +$file->setPostFilename('foo.txt'); +var_dump($file->getPostFilename()); +curl_setopt($ch, CURLOPT_POSTFIELDS, array("file" => $file)); +var_dump(curl_exec($ch)); + +$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt'); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true); +$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt'); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=post"); +$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt'); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +curl_close($ch); +?> +--EXPECTF-- +string(%d) "curl_testdata1.txt|application/octet-stream" +string(%d) "curl_testdata1.txt|text/plain" +string(%d) "foo.txt|application/octet-stream" +string(%d) "foo.txt|text/plain" +string(%d) "text/plain" +string(%d) "%s/curl_testdata1.txt" +string(%d) "curl_testdata1.txt|text/plain" +string(%d) "foo.txt" +string(%d) "foo.txt|application/octet-stream" + +Deprecated: curl_setopt(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead in %s on line %d +string(%d) "curl_testdata1.txt|application/octet-stream" +string(0) "" +string(%d) "array(1) { + ["file"]=> + string(%d) "@%s/curl_testdata1.txt" +} +" diff --git a/ext/curl/tests/curl_multi_setopt_basic001.phpt b/ext/curl/tests/curl_multi_setopt_basic001.phpt new file mode 100644 index 0000000000000..a13cf6d7160b3 --- /dev/null +++ b/ext/curl/tests/curl_multi_setopt_basic001.phpt @@ -0,0 +1,25 @@ +--TEST-- +curl_multi_setopt basic test +--SKIPIF-- += 7.16.0"); +} +?> +--FILE-- + +--EXPECTF-- +bool(true) + +Warning: curl_multi_setopt(): Invalid curl multi configuration option in %s on line %d +bool(false) diff --git a/ext/curl/tests/curl_multi_strerror_001.phpt b/ext/curl/tests/curl_multi_strerror_001.phpt new file mode 100644 index 0000000000000..ac330acaee2f2 --- /dev/null +++ b/ext/curl/tests/curl_multi_strerror_001.phpt @@ -0,0 +1,22 @@ +--TEST-- +curl_multi_strerror basic test +--SKIPIF-- += 7.12.0"); +} +?> +--FILE-- + +--EXPECTF-- +string(8) "no error" +string(20) "invalid multi handle" diff --git a/ext/curl/tests/curl_reset.phpt b/ext/curl/tests/curl_reset.phpt new file mode 100644 index 0000000000000..c78a8e0953b62 --- /dev/null +++ b/ext/curl/tests/curl_reset.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test curl_reset +--SKIPIF-- += 7.12.1)"); +?> +--FILE-- + +--EXPECT-- +testtest diff --git a/ext/curl/tests/curl_setopt_basic003.phpt b/ext/curl/tests/curl_setopt_basic003.phpt index 7849140766d64..aa225c6e3370a 100644 --- a/ext/curl/tests/curl_setopt_basic003.phpt +++ b/ext/curl/tests/curl_setopt_basic003.phpt @@ -38,6 +38,6 @@ var_dump( $curl_content ); --EXPECTF-- *** curl_setopt() call with CURLOPT_HTTPHEADER -Warning: curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER, CURLOPT_QUOTE, CURLOPT_HTTP200ALIASES and CURLOPT_POSTQUOTE arguments in %s on line %d +Warning: curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER argument in %s on line %d bool(false) bool(true) diff --git a/ext/curl/tests/curl_setopt_error.phpt b/ext/curl/tests/curl_setopt_error.phpt index ad73318f1cc3f..01593aff22c90 100644 --- a/ext/curl/tests/curl_setopt_error.phpt +++ b/ext/curl/tests/curl_setopt_error.phpt @@ -14,14 +14,14 @@ curl_setopt(false); curl_setopt($ch); curl_setopt($ch, false); -curl_setopt($ch, -1); +curl_setopt($ch, -10); curl_setopt($ch, ''); curl_setopt($ch, 1, false); curl_setopt(false, false, false); curl_setopt($ch, '', false); curl_setopt($ch, 1, ''); -curl_setopt($ch, -1, 0); +curl_setopt($ch, -10, 0); ?> --EXPECTF-- *** curl_setopt() call with incorrect parameters diff --git a/ext/curl/tests/curl_share_setopt_basic001.phpt b/ext/curl/tests/curl_share_setopt_basic001.phpt new file mode 100644 index 0000000000000..33c03e3337e33 --- /dev/null +++ b/ext/curl/tests/curl_share_setopt_basic001.phpt @@ -0,0 +1,23 @@ +--TEST-- +curl_share_setopt basic test +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) +bool(true) + +Warning: curl_share_setopt(): Invalid curl share configuration option in %s on line %d +bool(false) diff --git a/ext/curl/tests/curl_strerror_001.phpt b/ext/curl/tests/curl_strerror_001.phpt new file mode 100644 index 0000000000000..f8a0de311b4c5 --- /dev/null +++ b/ext/curl/tests/curl_strerror_001.phpt @@ -0,0 +1,24 @@ +--TEST-- +curl_strerror basic test +--SKIPIF-- += 7.12.0"); +} +?> +--FILE-- + +--EXPECTF-- +string(8) "no error" +string(20) "unsupported protocol" +string(13) "unknown error" diff --git a/ext/date/TODO b/ext/date/TODO index 4b1237c4a918a..a585b055167c0 100644 --- a/ext/date/TODO +++ b/ext/date/TODO @@ -1,6 +1,5 @@ - Port over my 200 test cases to .phpt format. - Write an error handler for unexpected characters while parsing dates. - Cache lookups for timezone information. -- Optimize parsing @ with a negative timestamp. - Make sure that date_default_timezone_set() validates the passed timezone identifier. diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index 5d43efe1e38bd..90622f956f4be 100644 --- a/ext/date/lib/parse_date.c +++ b/ext/date/lib/parse_date.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Sun Sep 30 20:14:42 2012 */ +/* Generated by re2c 0.13.5 */ #line 1 "ext/date/lib/parse_date.re" /* +----------------------------------------------------------------------+ diff --git a/ext/date/lib/parse_iso_intervals.c b/ext/date/lib/parse_iso_intervals.c index bd1ad05ddd4e6..7d05e324a30b1 100644 --- a/ext/date/lib/parse_iso_intervals.c +++ b/ext/date/lib/parse_iso_intervals.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Mon Dec 5 22:02:27 2011 */ +/* Generated by re2c 0.13.5 */ #line 1 "ext/date/lib/parse_iso_intervals.re" /* +----------------------------------------------------------------------+ diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c index e15a38150c3f7..23fe202ba9f44 100644 --- a/ext/date/lib/tm2unixtime.c +++ b/ext/date/lib/tm2unixtime.c @@ -220,55 +220,52 @@ static void do_adjust_relative(timelib_time* time) static void do_adjust_special_weekday(timelib_time* time) { - timelib_sll current_dow, count; + timelib_sll count, dow, rem; count = time->relative.special.amount; + dow = timelib_day_of_week(time->y, time->m, time->d); - current_dow = timelib_day_of_week(time->y, time->m, time->d); - if (count == 0) { - /* skip over saturday and sunday */ - if (current_dow == 6) { - time->d += 2; - } - /* skip over sunday */ - if (current_dow == 0) { - time->d += 1; - } - } else if (count > 0) { - /* skip over saturday and sunday */ - if (current_dow == 5) { - time->d += 2; - } - /* skip over sunday */ - if (current_dow == 6) { + /* Add increments of 5 weekdays as a week, leaving the DOW unchanged. */ + time->d += (count / 5) * 7; + + /* Deal with the remainder. */ + rem = (count % 5); + + if (count > 0) { + if (rem == 0) { + /* Head back to Friday if we stop on the weekend. */ + if (dow == 0) { + time->d -= 2; + } else if (dow == 6) { + time->d -= 1; + } + } else if (dow == 6) { + /* We ended up on Saturday, but there's still work to do, so move + * to Sunday and continue from there. */ time->d += 1; - } - /* add increments of 5 weekdays as a week */ - time->d += (count / 5) * 7; - /* if current DOW plus the remainder > 5, add two days */ - current_dow = timelib_day_of_week(time->y, time->m, time->d); - time->d += (count % 5); - if ((count % 5) + current_dow > 5) { + } else if (dow + rem > 5) { + /* We're on a weekday, but we're going past Friday, so skip right + * over the weekend. */ time->d += 2; } - } else if (count < 0) { - /* skip over sunday and saturday */ - if (current_dow == 1) { - time->d -= 2; - } - /* skip over satruday */ - if (current_dow == 0 ) { + } else { + /* Completely mirror the forward direction. This also covers the 0 + * case, since if we start on the weekend, we want to move forward as + * if we stopped there while going backwards. */ + if (rem == 0) { + if (dow == 6) { + time->d += 2; + } else if (dow == 0) { + time->d += 1; + } + } else if (dow == 0) { time->d -= 1; - } - /* subtract increments of 5 weekdays as a week */ - time->d += (count / 5) * 7; - /* if current DOW minus the remainder < 0, subtract two days */ - current_dow = timelib_day_of_week(time->y, time->m, time->d); - time->d += (count % 5); - if ((count % 5) + current_dow < 1) { + } else if (dow + rem < 1) { time->d -= 2; } } + + time->d += rem; } static void do_adjust_special(timelib_time* time) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index fd6453f5d8cf6..f4115dc7e1d21 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -385,7 +385,9 @@ const zend_function_entry date_functions[] = { /* Advanced Interface */ PHP_FE(date_create, arginfo_date_create) + PHP_FE(date_create_immutable, arginfo_date_create) PHP_FE(date_create_from_format, arginfo_date_create_from_format) + PHP_FE(date_create_immutable_from_format, arginfo_date_create_from_format) PHP_FE(date_parse, arginfo_date_parse) PHP_FE(date_parse_from_format, arginfo_date_parse_from_format) PHP_FE(date_get_last_errors, arginfo_date_get_last_errors) @@ -450,6 +452,20 @@ const zend_function_entry date_funcs_date[] = { PHP_FE_END }; +const zend_function_entry date_funcs_immutable[] = { + PHP_ME(DateTimeImmutable, __construct, arginfo_date_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(DateTimeImmutable, __set_state, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(DateTimeImmutable, modify, arginfo_date_method_modify, 0) + PHP_ME(DateTimeImmutable, add, arginfo_date_method_add, 0) + PHP_ME(DateTimeImmutable, sub, arginfo_date_method_sub, 0) + PHP_ME(DateTimeImmutable, setTimezone, arginfo_date_method_timezone_set, 0) + PHP_ME(DateTimeImmutable, setTime, arginfo_date_method_time_set, 0) + PHP_ME(DateTimeImmutable, setDate, arginfo_date_method_date_set, 0) + PHP_ME(DateTimeImmutable, setISODate, arginfo_date_method_isodate_set, 0) + PHP_ME(DateTimeImmutable, setTimestamp, arginfo_date_method_timestamp_set, 0) + PHP_FE_END +}; + const zend_function_entry date_funcs_timezone[] = { PHP_ME(DateTimeZone, __construct, arginfo_timezone_open, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) PHP_ME_MAPPING(getName, timezone_name_get, arginfo_timezone_method_name_get, 0) @@ -508,6 +524,7 @@ PHP_INI_END() /* }}} */ zend_class_entry *date_ce_date, *date_ce_timezone, *date_ce_interval, *date_ce_period; +zend_class_entry *date_ce_immutable; PHPAPI zend_class_entry *php_date_get_date_ce(void) @@ -515,12 +532,18 @@ PHPAPI zend_class_entry *php_date_get_date_ce(void) return date_ce_date; } +PHPAPI zend_class_entry *php_date_get_immutable_ce(void) +{ + return date_ce_immutable; +} + PHPAPI zend_class_entry *php_date_get_timezone_ce(void) { return date_ce_timezone; } static zend_object_handlers date_object_handlers_date; +static zend_object_handlers date_object_handlers_immutable; static zend_object_handlers date_object_handlers_timezone; static zend_object_handlers date_object_handlers_interval; static zend_object_handlers date_object_handlers_period; @@ -555,11 +578,13 @@ static void date_object_free_storage_interval(void *object TSRMLS_DC); static void date_object_free_storage_period(void *object TSRMLS_DC); static zend_object_value date_object_new_date(zend_class_entry *class_type TSRMLS_DC); +static zend_object_value date_object_new_immutable(zend_class_entry *class_type TSRMLS_DC); static zend_object_value date_object_new_timezone(zend_class_entry *class_type TSRMLS_DC); static zend_object_value date_object_new_interval(zend_class_entry *class_type TSRMLS_DC); static zend_object_value date_object_new_period(zend_class_entry *class_type TSRMLS_DC); static zend_object_value date_object_clone_date(zval *this_ptr TSRMLS_DC); +static zend_object_value date_object_clone_immutable(zval *this_ptr TSRMLS_DC); static zend_object_value date_object_clone_timezone(zval *this_ptr TSRMLS_DC); static zend_object_value date_object_clone_interval(zval *this_ptr TSRMLS_DC); static zend_object_value date_object_clone_period(zval *this_ptr TSRMLS_DC); @@ -743,7 +768,6 @@ PHP_RSHUTDOWN_FUNCTION(date) #define SUNFUNCS_RET_STRING 1 #define SUNFUNCS_RET_DOUBLE 2 - /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(date) { @@ -1356,7 +1380,6 @@ PHPAPI signed long php_parse_date(char *string, signed long *now) } /* }}} */ - /* {{{ proto int strtotime(string time [, int now ]) Convert string representation of date and time to a timestamp */ PHP_FUNCTION(strtotime) @@ -1417,7 +1440,6 @@ PHP_FUNCTION(strtotime) } /* }}} */ - /* {{{ php_mktime - (gm)mktime helper */ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt) { @@ -1526,7 +1548,6 @@ PHP_FUNCTION(gmmktime) } /* }}} */ - /* {{{ proto bool checkdate(int month, int day, int year) Returns true(1) if it is a valid date in gregorian calendar */ PHP_FUNCTION(checkdate) @@ -1826,7 +1847,7 @@ static void date_period_it_current_data(zend_object_iterator *iter, zval ***data /* Create new object */ MAKE_STD_ZVAL(iterator->current); - php_date_instantiate(date_ce_date, iterator->current TSRMLS_CC); + php_date_instantiate(object->start_ce, iterator->current TSRMLS_CC); newdateobj = (php_date_obj *) zend_object_store_get_object(iterator->current TSRMLS_CC); newdateobj->time = timelib_time_ctor(); *newdateobj->time = *it_time; @@ -1912,7 +1933,7 @@ zend_object_iterator *date_object_period_get_iterator(zend_class_entry *ce, zval static void date_register_classes(TSRMLS_D) { - zend_class_entry ce_date, ce_timezone, ce_interval, ce_period; + zend_class_entry ce_date, ce_immutable, ce_timezone, ce_interval, ce_period; INIT_CLASS_ENTRY(ce_date, "DateTime", date_funcs_date); ce_date.create_object = date_object_new_date; @@ -1938,6 +1959,13 @@ static void date_register_classes(TSRMLS_D) REGISTER_DATE_CLASS_CONST_STRING("RSS", DATE_FORMAT_RFC1123); REGISTER_DATE_CLASS_CONST_STRING("W3C", DATE_FORMAT_RFC3339); + INIT_CLASS_ENTRY(ce_immutable, "DateTimeImmutable", date_funcs_immutable); + ce_immutable.create_object = date_object_new_date; + date_ce_immutable = zend_register_internal_class_ex(&ce_immutable, date_ce_date, "DateTime" TSRMLS_CC); + memcpy(&date_object_handlers_immutable, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + date_object_handlers_immutable.clone_obj = date_object_clone_date; + date_object_handlers_immutable.compare_objects = date_object_compare_date; + date_object_handlers_immutable.get_properties = date_object_get_properties; INIT_CLASS_ENTRY(ce_timezone, "DateTimeZone", date_funcs_timezone); ce_timezone.create_object = date_object_new_timezone; @@ -2038,6 +2066,19 @@ static zend_object_value date_object_clone_date(zval *this_ptr TSRMLS_DC) return new_ov; } +static zval* date_clone_immutable(zval *object TSRMLS_DC) +{ + zval *new_object; + + ALLOC_ZVAL(new_object); + Z_OBJVAL_P(new_object) = date_object_clone_date(object TSRMLS_CC); + Z_SET_REFCOUNT_P(new_object, 1); + Z_SET_ISREF_P(new_object); + Z_TYPE_P(new_object) = IS_OBJECT; + + return new_object; +} + static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC) { if (Z_TYPE_P(d1) == IS_OBJECT && Z_TYPE_P(d2) == IS_OBJECT && @@ -2474,6 +2515,26 @@ PHP_FUNCTION(date_create) } /* }}} */ +/* {{{ proto DateTime date_create_immutable([string time[, DateTimeZone object]]) + Returns new DateTime object +*/ +PHP_FUNCTION(date_create_immutable) +{ + zval *timezone_object = NULL; + char *time_str = NULL; + int time_str_len = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) { + RETURN_FALSE; + } + + php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC); + if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) { + RETURN_FALSE; + } +} +/* }}} */ + /* {{{ proto DateTime date_create_from_format(string format, string time[, DateTimeZone object]) Returns new DateTime object formatted according to the specified format */ @@ -2494,6 +2555,26 @@ PHP_FUNCTION(date_create_from_format) } /* }}} */ +/* {{{ proto DateTime date_create_immutable_from_format(string format, string time[, DateTimeZone object]) + Returns new DateTime object formatted according to the specified format +*/ +PHP_FUNCTION(date_create_immutable_from_format) +{ + zval *timezone_object = NULL; + char *time_str = NULL, *format_str = NULL; + int time_str_len = 0, format_str_len = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|O", &format_str, &format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) { + RETURN_FALSE; + } + + php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC); + if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) { + RETURN_FALSE; + } +} +/* }}} */ + /* {{{ proto DateTime::__construct([string time[, DateTimeZone object]]) Creates new DateTime object */ @@ -2512,6 +2593,24 @@ PHP_METHOD(DateTime, __construct) } /* }}} */ +/* {{{ proto DateTimeImmutable::__construct([string time[, DateTimeZone object]]) + Creates new DateTimeImmutable object +*/ +PHP_METHOD(DateTimeImmutable, __construct) +{ + zval *timezone_object = NULL; + char *time_str = NULL; + int time_str_len = 0; + zend_error_handling error_handling; + + zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); + if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) { + php_date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 1 TSRMLS_CC); + } + zend_restore_error_handling(&error_handling TSRMLS_CC); +} +/* }}} */ + static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dateobj, HashTable *myht TSRMLS_DC) { zval **z_date = NULL; @@ -2579,6 +2678,26 @@ PHP_METHOD(DateTime, __set_state) } /* }}} */ +/* {{{ proto DateTimeImmutable::__set_state() +*/ +PHP_METHOD(DateTimeImmutable, __set_state) +{ + php_date_obj *dateobj; + zval *array; + HashTable *myht; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) { + RETURN_FALSE; + } + + myht = HASH_OF(array); + + php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC); + dateobj = (php_date_obj *) zend_object_store_get_object(return_value TSRMLS_CC); + php_date_initialize_from_hash(&return_value, &dateobj, myht TSRMLS_CC); +} +/* }}} */ + /* {{{ proto DateTime::__wakeup() */ PHP_METHOD(DateTime, __wakeup) @@ -2764,23 +2883,18 @@ PHP_FUNCTION(date_format) } /* }}} */ -/* {{{ proto DateTime date_modify(DateTime object, string modify) - Alters the timestamp. -*/ -PHP_FUNCTION(date_modify) +static int php_date_modify(zval *object, char *modify, int modify_len TSRMLS_DC) { - zval *object; php_date_obj *dateobj; - char *modify; - int modify_len; timelib_time *tmp_time; timelib_error_container *err = NULL; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &modify, &modify_len) == FAILURE) { - RETURN_FALSE; - } dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); - DATE_CHECK_INITIALIZED(dateobj->time, DateTime); + + if (!(dateobj->time)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "The DateTime object has not been correctly initialized by its constructor"); + return 0; + } tmp_time = timelib_strtotime(modify, modify_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); @@ -2791,7 +2905,7 @@ PHP_FUNCTION(date_modify) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to parse time string (%s) at position %d (%c): %s", modify, err->error_messages[0].position, err->error_messages[0].character, err->error_messages[0].message); timelib_time_dtor(tmp_time); - RETURN_FALSE; + return 0; } memcpy(&dateobj->time->relative, &tmp_time->relative, sizeof(struct timelib_rel_time)); @@ -2827,30 +2941,63 @@ PHP_FUNCTION(date_modify) timelib_update_ts(dateobj->time, NULL); timelib_update_from_sse(dateobj->time); dateobj->time->have_relative = 0; + + return 1; +} - RETURN_ZVAL(object, 1, 0); +/* {{{ proto DateTime date_modify(DateTime object, string modify) + Alters the timestamp. +*/ +PHP_FUNCTION(date_modify) +{ + zval *object; + char *modify; + int modify_len; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &modify, &modify_len) == FAILURE) { + RETURN_FALSE; + } + + if (php_date_modify(object, modify, modify_len TSRMLS_CC)) { + RETURN_ZVAL(object, 1, 0); + } + + RETURN_FALSE; } /* }}} */ -/* {{{ proto DateTime date_add(DateTime object, DateInterval interval) - Adds an interval to the current date in object. +/* {{{ proto DateTimeImmutable::modify() */ -PHP_FUNCTION(date_add) +PHP_METHOD(DateTimeImmutable, modify) { - zval *object, *interval; - php_date_obj *dateobj; - php_interval_obj *intobj; - int bias = 1; + zval *object, *new_object; + char *modify; + int modify_len; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &interval, date_ce_interval) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &modify, &modify_len) == FAILURE) { RETURN_FALSE; } + + new_object = date_clone_immutable(object TSRMLS_CC); + if (php_date_modify(new_object, modify, modify_len TSRMLS_CC)) { + RETURN_ZVAL(new_object, 0, 1); + } + + RETURN_FALSE; +} +/* }}} */ + +static void php_date_add(zval *object, zval *interval, zval *return_value TSRMLS_DC) +{ + php_date_obj *dateobj; + php_interval_obj *intobj; + int bias = 1; + dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(dateobj->time, DateTime); intobj = (php_interval_obj *) zend_object_store_get_object(interval TSRMLS_CC); DATE_CHECK_INITIALIZED(intobj->initialized, DateInterval); - if (intobj->diff->have_weekday_relative || intobj->diff->have_special_relative) { memcpy(&dateobj->time->relative, intobj->diff, sizeof(struct timelib_rel_time)); } else { @@ -2871,24 +3018,48 @@ PHP_FUNCTION(date_add) timelib_update_ts(dateobj->time, NULL); timelib_update_from_sse(dateobj->time); dateobj->time->have_relative = 0; +} + +/* {{{ proto DateTime date_add(DateTime object, DateInterval interval) + Adds an interval to the current date in object. +*/ +PHP_FUNCTION(date_add) +{ + zval *object, *interval; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &interval, date_ce_interval) == FAILURE) { + RETURN_FALSE; + } + + php_date_add(object, interval, return_value TSRMLS_CC); RETURN_ZVAL(object, 1, 0); } /* }}} */ -/* {{{ proto DateTime date_sub(DateTime object, DateInterval interval) - Subtracts an interval to the current date in object. +/* {{{ proto DateTimeImmutable::add() */ -PHP_FUNCTION(date_sub) +PHP_METHOD(DateTimeImmutable, add) { - zval *object, *interval; - php_date_obj *dateobj; - php_interval_obj *intobj; - int bias = 1; + zval *object, *interval, *new_object; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &interval, date_ce_interval) == FAILURE) { RETURN_FALSE; } + + new_object = date_clone_immutable(object TSRMLS_CC); + php_date_add(new_object, interval, return_value TSRMLS_CC); + + RETURN_ZVAL(new_object, 0, 1); +} +/* }}} */ + +static void php_date_sub(zval *object, zval *interval, zval *return_value TSRMLS_DC) +{ + php_date_obj *dateobj; + php_interval_obj *intobj; + int bias = 1; + dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(dateobj->time, DateTime); intobj = (php_interval_obj *) zend_object_store_get_object(interval TSRMLS_CC); @@ -2917,11 +3088,42 @@ PHP_FUNCTION(date_sub) timelib_update_from_sse(dateobj->time); dateobj->time->have_relative = 0; +} + +/* {{{ proto DateTime date_sub(DateTime object, DateInterval interval) + Subtracts an interval to the current date in object. +*/ +PHP_FUNCTION(date_sub) +{ + zval *object, *interval; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &interval, date_ce_interval) == FAILURE) { + RETURN_FALSE; + } + + php_date_sub(object, interval, return_value TSRMLS_CC); RETURN_ZVAL(object, 1, 0); } /* }}} */ +/* {{{ proto DateTimeImmutable::sub() +*/ +PHP_METHOD(DateTimeImmutable, sub) +{ + zval *object, *interval, *new_object; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &interval, date_ce_interval) == FAILURE) { + RETURN_FALSE; + } + + new_object = date_clone_immutable(object TSRMLS_CC); + php_date_sub(new_object, interval, return_value TSRMLS_CC); + + RETURN_ZVAL(new_object, 0, 1); +} +/* }}} */ + /* {{{ proto DateTimeZone date_timezone_get(DateTime object) Return new DateTimeZone object relative to give DateTime */ @@ -2960,19 +3162,11 @@ PHP_FUNCTION(date_timezone_get) } /* }}} */ -/* {{{ proto DateTime date_timezone_set(DateTime object, DateTimeZone object) - Sets the timezone for the DateTime object. -*/ -PHP_FUNCTION(date_timezone_set) +static void php_date_timezone_set(zval *object, zval *timezone_object, zval *return_value TSRMLS_DC) { - zval *object; - zval *timezone_object; php_date_obj *dateobj; php_timezone_obj *tzobj; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &timezone_object, date_ce_timezone) == FAILURE) { - RETURN_FALSE; - } dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(dateobj->time, DateTime); tzobj = (php_timezone_obj *) zend_object_store_get_object(timezone_object TSRMLS_CC); @@ -2982,11 +3176,44 @@ PHP_FUNCTION(date_timezone_set) } timelib_set_timezone(dateobj->time, tzobj->tzi.tz); timelib_unixtime2local(dateobj->time, dateobj->time->sse); +} + +/* {{{ proto DateTime date_timezone_set(DateTime object, DateTimeZone object) + Sets the timezone for the DateTime object. +*/ +PHP_FUNCTION(date_timezone_set) +{ + zval *object; + zval *timezone_object; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &timezone_object, date_ce_timezone) == FAILURE) { + RETURN_FALSE; + } + + php_date_timezone_set(object, timezone_object, return_value TSRMLS_CC); RETURN_ZVAL(object, 1, 0); } /* }}} */ +/* {{{ proto DateTimeImmutable::setTimezone() +*/ +PHP_METHOD(DateTimeImmutable, setTimezone) +{ + zval *object, *new_object; + zval *timezone_object; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &timezone_object, date_ce_timezone) == FAILURE) { + RETURN_FALSE; + } + + new_object = date_clone_immutable(object TSRMLS_CC); + php_date_timezone_set(new_object, timezone_object, return_value TSRMLS_CC); + + RETURN_ZVAL(new_object, 0, 1); +} +/* }}} */ + /* {{{ proto long date_offset_get(DateTime object) Returns the DST offset. */ @@ -3022,64 +3249,106 @@ PHP_FUNCTION(date_offset_get) } /* }}} */ -/* {{{ proto DateTime date_time_set(DateTime object, long hour, long minute[, long second]) - Sets the time. -*/ -PHP_FUNCTION(date_time_set) +static void php_date_time_set(zval *object, long h, long i, long s, zval *return_value TSRMLS_DC) { - zval *object; php_date_obj *dateobj; - long h, i, s = 0; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &h, &i, &s) == FAILURE) { - RETURN_FALSE; - } dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(dateobj->time, DateTime); dateobj->time->h = h; dateobj->time->i = i; dateobj->time->s = s; timelib_update_ts(dateobj->time, NULL); +} + +/* {{{ proto DateTime date_time_set(DateTime object, long hour, long minute[, long second]) + Sets the time. +*/ +PHP_FUNCTION(date_time_set) +{ + zval *object; + long h, i, s = 0; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &h, &i, &s) == FAILURE) { + RETURN_FALSE; + } + + php_date_time_set(object, h, i, s, return_value TSRMLS_CC); RETURN_ZVAL(object, 1, 0); } /* }}} */ -/* {{{ proto DateTime date_date_set(DateTime object, long year, long month, long day) - Sets the date. +/* {{{ proto DateTimeImmutable::setTime() */ -PHP_FUNCTION(date_date_set) +PHP_METHOD(DateTimeImmutable, setTime) { - zval *object; - php_date_obj *dateobj; - long y, m, d; + zval *object, *new_object; + long h, i, s = 0; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olll", &object, date_ce_date, &y, &m, &d) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &h, &i, &s) == FAILURE) { RETURN_FALSE; } + + new_object = date_clone_immutable(object TSRMLS_CC); + php_date_time_set(new_object, h, i, s, return_value TSRMLS_CC); + + RETURN_ZVAL(new_object, 0, 1); +} +/* }}} */ + +static void php_date_date_set(zval *object, long y, long m, long d, zval *return_value TSRMLS_DC) +{ + php_date_obj *dateobj; + dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(dateobj->time, DateTime); dateobj->time->y = y; dateobj->time->m = m; dateobj->time->d = d; timelib_update_ts(dateobj->time, NULL); +} + +/* {{{ proto DateTime date_date_set(DateTime object, long year, long month, long day) + Sets the date. +*/ +PHP_FUNCTION(date_date_set) +{ + zval *object; + long y, m, d; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olll", &object, date_ce_date, &y, &m, &d) == FAILURE) { + RETURN_FALSE; + } + + php_date_date_set(object, y, m, d, return_value TSRMLS_CC); RETURN_ZVAL(object, 1, 0); } /* }}} */ -/* {{{ proto DateTime date_isodate_set(DateTime object, long year, long week[, long day]) - Sets the ISO date. +/* {{{ proto DateTimeImmutable::setDate() */ -PHP_FUNCTION(date_isodate_set) +PHP_METHOD(DateTimeImmutable, setDate) { - zval *object; - php_date_obj *dateobj; - long y, w, d = 1; + zval *object, *new_object; + long y, m, d; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &y, &w, &d) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olll", &object, date_ce_date, &y, &m, &d) == FAILURE) { RETURN_FALSE; } + + new_object = date_clone_immutable(object TSRMLS_CC); + php_date_date_set(new_object, y, m, d, return_value TSRMLS_CC); + + RETURN_ZVAL(new_object, 0, 1); +} +/* }}} */ + +static void php_date_isodate_set(zval *object, long y, long w, long d, zval *return_value TSRMLS_DC) +{ + php_date_obj *dateobj; + dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(dateobj->time, DateTime); dateobj->time->y = y; @@ -3090,32 +3359,90 @@ PHP_FUNCTION(date_isodate_set) dateobj->time->have_relative = 1; timelib_update_ts(dateobj->time, NULL); +} + +/* {{{ proto DateTime date_isodate_set(DateTime object, long year, long week[, long day]) + Sets the ISO date. +*/ +PHP_FUNCTION(date_isodate_set) +{ + zval *object; + long y, w, d = 1; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &y, &w, &d) == FAILURE) { + RETURN_FALSE; + } + + php_date_isodate_set(object, y, w, d, return_value TSRMLS_CC); RETURN_ZVAL(object, 1, 0); } /* }}} */ -/* {{{ proto DateTime date_timestamp_set(DateTime object, long unixTimestamp) - Sets the date and time based on an Unix timestamp. +/* {{{ proto DateTimeImmutable::setISODate() */ -PHP_FUNCTION(date_timestamp_set) +PHP_METHOD(DateTimeImmutable, setISODate) { - zval *object; - php_date_obj *dateobj; - long timestamp; + zval *object, *new_object; + long y, w, d = 1; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &object, date_ce_date, ×tamp) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &y, &w, &d) == FAILURE) { RETURN_FALSE; } + + new_object = date_clone_immutable(object TSRMLS_CC); + php_date_isodate_set(new_object, y, w, d, return_value TSRMLS_CC); + + RETURN_ZVAL(new_object, 0, 1); +} +/* }}} */ + +static void php_date_timestamp_set(zval *object, long timestamp, zval *return_value TSRMLS_DC) +{ + php_date_obj *dateobj; + dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(dateobj->time, DateTime); timelib_unixtime2local(dateobj->time, (timelib_sll)timestamp); timelib_update_ts(dateobj->time, NULL); +} + +/* {{{ proto DateTime date_timestamp_set(DateTime object, long unixTimestamp) + Sets the date and time based on an Unix timestamp. +*/ +PHP_FUNCTION(date_timestamp_set) +{ + zval *object; + long timestamp; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &object, date_ce_date, ×tamp) == FAILURE) { + RETURN_FALSE; + } + + php_date_timestamp_set(object, timestamp, return_value TSRMLS_CC); RETURN_ZVAL(object, 1, 0); } /* }}} */ +/* {{{ proto DateTimeImmutable::setTimestamp() +*/ +PHP_METHOD(DateTimeImmutable, setTimestamp) +{ + zval *object, *new_object; + long timestamp; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &object, date_ce_date, ×tamp) == FAILURE) { + RETURN_FALSE; + } + + new_object = date_clone_immutable(object TSRMLS_CC); + php_date_timestamp_set(new_object, timestamp, return_value TSRMLS_CC); + + RETURN_ZVAL(new_object, 0, 1); +} +/* }}} */ + /* {{{ proto long date_timestamp_get(DateTime object) Gets the Unix timestamp. */ @@ -3865,6 +4192,7 @@ PHP_METHOD(DatePeriod, __construct) if (dpobj->end) { timelib_update_ts(dpobj->end, NULL); } + dpobj->start_ce = date_ce_date; } else { /* init */ intobj = (php_interval_obj *) zend_object_store_get_object(interval TSRMLS_CC); @@ -3880,6 +4208,7 @@ PHP_METHOD(DatePeriod, __construct) clone->tz_info = dateobj->time->tz_info; } dpobj->start = clone; + dpobj->start_ce = Z_OBJCE_P(start); /* interval */ dpobj->interval = timelib_rel_time_clone(intobj->diff); diff --git a/ext/date/php_date.h b/ext/date/php_date.h index f0b662b5d9f35..3af3fa42ede90 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -51,7 +51,9 @@ PHP_METHOD(DateTime, __construct); PHP_METHOD(DateTime, __wakeup); PHP_METHOD(DateTime, __set_state); PHP_FUNCTION(date_create); +PHP_FUNCTION(date_create_immutable); PHP_FUNCTION(date_create_from_format); +PHP_FUNCTION(date_create_immutable_from_format); PHP_FUNCTION(date_parse); PHP_FUNCTION(date_parse_from_format); PHP_FUNCTION(date_get_last_errors); @@ -70,6 +72,17 @@ PHP_FUNCTION(date_isodate_set); PHP_FUNCTION(date_timestamp_set); PHP_FUNCTION(date_timestamp_get); +PHP_METHOD(DateTimeImmutable, __construct); +PHP_METHOD(DateTimeImmutable, __set_state); +PHP_METHOD(DateTimeImmutable, modify); +PHP_METHOD(DateTimeImmutable, add); +PHP_METHOD(DateTimeImmutable, sub); +PHP_METHOD(DateTimeImmutable, setTimezone); +PHP_METHOD(DateTimeImmutable, setTime); +PHP_METHOD(DateTimeImmutable, setDate); +PHP_METHOD(DateTimeImmutable, setISODate); +PHP_METHOD(DateTimeImmutable, setTimestamp); + PHP_METHOD(DateTimeZone, __construct); PHP_FUNCTION(timezone_open); PHP_FUNCTION(timezone_name_get); @@ -141,6 +154,7 @@ struct _php_interval_obj { struct _php_period_obj { zend_object std; timelib_time *start; + zend_class_entry *start_ce; timelib_time *current; timelib_time *end; timelib_rel_time *interval; diff --git a/ext/date/tests/bug61642.phpt b/ext/date/tests/bug61642.phpt new file mode 100644 index 0000000000000..d03a814d88279 --- /dev/null +++ b/ext/date/tests/bug61642.phpt @@ -0,0 +1,62 @@ +--TEST-- +Bug #61642 (modify("+5 weekdays") returns Sunday) +--INI-- +date.timezone=UTC +--FILE-- +format('Y-m-d D'); +} + +echo '### ', implode(' ', $header), "\n\n"; + +foreach ($weekdays as $days) { + $line = array(); + + printf('%+3d ', $days); + + foreach ($dates as $startdate) { + $date = new DateTime($startdate); + $date->modify("{$days} weekdays"); + + $line[] = $date->format('Y-m-d D'); + } + + echo implode(' ', $line), "\n"; +} +?> +--EXPECTF-- +### 2012-03-29 Thu 2012-03-30 Fri 2012-03-31 Sat 2012-04-01 Sun 2012-04-02 Mon 2012-04-03 Tue 2012-04-04 Wed 2012-04-05 Thu + +-11 2012-03-14 Wed 2012-03-15 Thu 2012-03-16 Fri 2012-03-16 Fri 2012-03-16 Fri 2012-03-19 Mon 2012-03-20 Tue 2012-03-21 Wed +-10 2012-03-15 Thu 2012-03-16 Fri 2012-03-19 Mon 2012-03-19 Mon 2012-03-19 Mon 2012-03-20 Tue 2012-03-21 Wed 2012-03-22 Thu + -9 2012-03-16 Fri 2012-03-19 Mon 2012-03-20 Tue 2012-03-20 Tue 2012-03-20 Tue 2012-03-21 Wed 2012-03-22 Thu 2012-03-23 Fri + -8 2012-03-19 Mon 2012-03-20 Tue 2012-03-21 Wed 2012-03-21 Wed 2012-03-21 Wed 2012-03-22 Thu 2012-03-23 Fri 2012-03-26 Mon + -7 2012-03-20 Tue 2012-03-21 Wed 2012-03-22 Thu 2012-03-22 Thu 2012-03-22 Thu 2012-03-23 Fri 2012-03-26 Mon 2012-03-27 Tue + -6 2012-03-21 Wed 2012-03-22 Thu 2012-03-23 Fri 2012-03-23 Fri 2012-03-23 Fri 2012-03-26 Mon 2012-03-27 Tue 2012-03-28 Wed + -5 2012-03-22 Thu 2012-03-23 Fri 2012-03-26 Mon 2012-03-26 Mon 2012-03-26 Mon 2012-03-27 Tue 2012-03-28 Wed 2012-03-29 Thu + -4 2012-03-23 Fri 2012-03-26 Mon 2012-03-27 Tue 2012-03-27 Tue 2012-03-27 Tue 2012-03-28 Wed 2012-03-29 Thu 2012-03-30 Fri + -3 2012-03-26 Mon 2012-03-27 Tue 2012-03-28 Wed 2012-03-28 Wed 2012-03-28 Wed 2012-03-29 Thu 2012-03-30 Fri 2012-04-02 Mon + -2 2012-03-27 Tue 2012-03-28 Wed 2012-03-29 Thu 2012-03-29 Thu 2012-03-29 Thu 2012-03-30 Fri 2012-04-02 Mon 2012-04-03 Tue + -1 2012-03-28 Wed 2012-03-29 Thu 2012-03-30 Fri 2012-03-30 Fri 2012-03-30 Fri 2012-04-02 Mon 2012-04-03 Tue 2012-04-04 Wed + +0 2012-03-29 Thu 2012-03-30 Fri 2012-04-02 Mon 2012-04-02 Mon 2012-04-02 Mon 2012-04-03 Tue 2012-04-04 Wed 2012-04-05 Thu + +1 2012-03-30 Fri 2012-04-02 Mon 2012-04-02 Mon 2012-04-02 Mon 2012-04-03 Tue 2012-04-04 Wed 2012-04-05 Thu 2012-04-06 Fri + +2 2012-04-02 Mon 2012-04-03 Tue 2012-04-03 Tue 2012-04-03 Tue 2012-04-04 Wed 2012-04-05 Thu 2012-04-06 Fri 2012-04-09 Mon + +3 2012-04-03 Tue 2012-04-04 Wed 2012-04-04 Wed 2012-04-04 Wed 2012-04-05 Thu 2012-04-06 Fri 2012-04-09 Mon 2012-04-10 Tue + +4 2012-04-04 Wed 2012-04-05 Thu 2012-04-05 Thu 2012-04-05 Thu 2012-04-06 Fri 2012-04-09 Mon 2012-04-10 Tue 2012-04-11 Wed + +5 2012-04-05 Thu 2012-04-06 Fri 2012-04-06 Fri 2012-04-06 Fri 2012-04-09 Mon 2012-04-10 Tue 2012-04-11 Wed 2012-04-12 Thu + +6 2012-04-06 Fri 2012-04-09 Mon 2012-04-09 Mon 2012-04-09 Mon 2012-04-10 Tue 2012-04-11 Wed 2012-04-12 Thu 2012-04-13 Fri + +7 2012-04-09 Mon 2012-04-10 Tue 2012-04-10 Tue 2012-04-10 Tue 2012-04-11 Wed 2012-04-12 Thu 2012-04-13 Fri 2012-04-16 Mon + +8 2012-04-10 Tue 2012-04-11 Wed 2012-04-11 Wed 2012-04-11 Wed 2012-04-12 Thu 2012-04-13 Fri 2012-04-16 Mon 2012-04-17 Tue + +9 2012-04-11 Wed 2012-04-12 Thu 2012-04-12 Thu 2012-04-12 Thu 2012-04-13 Fri 2012-04-16 Mon 2012-04-17 Tue 2012-04-18 Wed ++10 2012-04-12 Thu 2012-04-13 Fri 2012-04-13 Fri 2012-04-13 Fri 2012-04-16 Mon 2012-04-17 Tue 2012-04-18 Wed 2012-04-19 Thu ++11 2012-04-13 Fri 2012-04-16 Mon 2012-04-16 Mon 2012-04-16 Mon 2012-04-17 Tue 2012-04-18 Wed 2012-04-19 Thu 2012-04-20 Fri diff --git a/ext/date/tests/date_period-immutable.phpt b/ext/date/tests/date_period-immutable.phpt new file mode 100644 index 0000000000000..0ec4b4a13025b --- /dev/null +++ b/ext/date/tests/date_period-immutable.phpt @@ -0,0 +1,56 @@ +--TEST-- +DatePeriod +--FILE-- +format( "l Y-m-d\n" ); + echo $dt->modify( "3 tuesday" )->format( "l Y-m-d\n" ); + echo $dt->format( "l Y-m-d\n\n" ); +} + +foreach ( new DatePeriod( $db2, $di, $de ) as $dt ) +{ + echo get_class( $dt ), "\n"; + echo $dt->format( "l Y-m-d\n" ); + echo $dt->modify( "3 tuesday" )->format( "l Y-m-d\n" ); + echo $dt->format( "l Y-m-d\n\n" ); +} +?> +--EXPECT-- +DateTimeImmutable +Tuesday 2008-01-01 +Tuesday 2008-01-15 +Tuesday 2008-01-01 + +DateTimeImmutable +Friday 2008-02-01 +Tuesday 2008-02-19 +Friday 2008-02-01 + +DateTimeImmutable +Saturday 2008-03-01 +Tuesday 2008-03-18 +Saturday 2008-03-01 + +DateTime +Tuesday 2008-01-01 +Tuesday 2008-01-15 +Tuesday 2008-01-15 + +DateTime +Friday 2008-02-01 +Tuesday 2008-02-19 +Tuesday 2008-02-19 + +DateTime +Saturday 2008-03-01 +Tuesday 2008-03-18 +Tuesday 2008-03-18 diff --git a/ext/date/tests/date_time_immutable-inherited.phpt b/ext/date/tests/date_time_immutable-inherited.phpt new file mode 100644 index 0000000000000..ad8b7edb84f7f --- /dev/null +++ b/ext/date/tests/date_time_immutable-inherited.phpt @@ -0,0 +1,25 @@ +--TEST-- +Tests for DateTimeImmutable. +--INI-- +date.timezone=Europe/London +--FILE-- +getTimezone(); +var_dump($x->getName()); + +echo "\ngetTimestamp():\n"; +$v = date_create_immutable($current); +$x = $v->getTimestamp(); +var_dump($x); +?> +--EXPECT-- +getTimezone(): +string(13) "Europe/London" + +getTimestamp(): +int(1356625448) diff --git a/ext/date/tests/date_time_immutable.phpt b/ext/date/tests/date_time_immutable.phpt new file mode 100644 index 0000000000000..b4a576570e225 --- /dev/null +++ b/ext/date/tests/date_time_immutable.phpt @@ -0,0 +1,167 @@ +--TEST-- +Tests for DateTimeImmutable. +--INI-- +date.timezone=Europe/London +--FILE-- +format('Y-m-d H:i:s e'), "\n"; + echo 'copy: ', $b->format('Y-m-d H:i:s e'), "\n"; + echo 'changed: ', $c->format('Y-m-d H:i:s e'), "\n"; +} + +echo "modify():\n"; +$v = date_create_immutable($current); +$z = $v; +$x = $z->modify("+2 days"); +dump($v, $z, $x); +$v = date_create($current); +$z = $v; +$x = $z->modify("+2 days"); +dump($v, $z, $x); + +echo "\nadd():\n"; +$v = date_create_immutable($current); +$z = $v; +$x = $z->add(new DateInterval("P2DT2S")); +dump($v, $z, $x); +$v = date_create($current); +$z = $v; +$x = $z->add(new DateInterval("P2DT2S")); +dump($v, $z, $x); + +echo "\nsub():\n"; +$v = date_create_immutable($current); +$z = $v; +$x = $z->sub(new DateInterval("P2DT2S")); +dump($v, $z, $x); +$v = date_create($current); +$z = $v; +$x = $z->sub(new DateInterval("P2DT2S")); +dump($v, $z, $x); + +echo "\nsetTimezone():\n"; +$v = date_create_immutable($current); +$z = $v; +$x = $z->setTimezone($tz); +dump($v, $z, $x); +$v = date_create($current); +$z = $v; +$x = $z->setTimezone($tz); +dump($v, $z, $x); +$v = new DateTimeImmutable($current); +$z = $v; +$x = $z->setTimezone($tz); +dump($v, $z, $x); + +echo "\nsetTime():\n"; +$v = date_create_immutable($current); +$z = $v; +$x = $z->setTime(5, 7, 19); +dump($v, $z, $x); +$v = date_create($current); +$z = $v; +$x = $z->setTime(5, 7, 19); +dump($v, $z, $x); + +echo "\nsetDate():\n"; +$v = date_create_immutable($current); +$z = $v; +$x = $z->setDate(5, 7, 19); +dump($v, $z, $x); +$v = date_create($current); +$z = $v; +$x = $z->setDate(5, 7, 19); +dump($v, $z, $x); + +echo "\nsetIsoDate():\n"; +$v = date_create_immutable($current); +$z = $v; +$x = $z->setIsoDate(2012, 2, 6); +dump($v, $z, $x); +$v = date_create($current); +$z = $v; +$x = $z->setIsoDate(2012, 2, 6); +dump($v, $z, $x); + +echo "\nsetTimestamp():\n"; +$v = date_create_immutable($current); +$z = $v; +$x = $z->setTimestamp(2012234222); +dump($v, $z, $x); +$v = date_create($current); +$z = $v; +$x = $z->setTimestamp(2012234222); +dump($v, $z, $x); +?> +--EXPECT-- +modify(): +orig: 2012-12-27 16:24:08 Europe/London +copy: 2012-12-27 16:24:08 Europe/London +changed: 2012-12-29 16:24:08 Europe/London +orig: 2012-12-29 16:24:08 Europe/London +copy: 2012-12-29 16:24:08 Europe/London +changed: 2012-12-29 16:24:08 Europe/London + +add(): +orig: 2012-12-27 16:24:08 Europe/London +copy: 2012-12-27 16:24:08 Europe/London +changed: 2012-12-29 16:24:10 Europe/London +orig: 2012-12-29 16:24:10 Europe/London +copy: 2012-12-29 16:24:10 Europe/London +changed: 2012-12-29 16:24:10 Europe/London + +sub(): +orig: 2012-12-27 16:24:08 Europe/London +copy: 2012-12-27 16:24:08 Europe/London +changed: 2012-12-25 16:24:06 Europe/London +orig: 2012-12-25 16:24:06 Europe/London +copy: 2012-12-25 16:24:06 Europe/London +changed: 2012-12-25 16:24:06 Europe/London + +setTimezone(): +orig: 2012-12-27 16:24:08 Europe/London +copy: 2012-12-27 16:24:08 Europe/London +changed: 2012-12-28 01:24:08 Asia/Tokyo +orig: 2012-12-28 01:24:08 Asia/Tokyo +copy: 2012-12-28 01:24:08 Asia/Tokyo +changed: 2012-12-28 01:24:08 Asia/Tokyo +orig: 2012-12-27 16:24:08 Europe/London +copy: 2012-12-27 16:24:08 Europe/London +changed: 2012-12-28 01:24:08 Asia/Tokyo + +setTime(): +orig: 2012-12-27 16:24:08 Europe/London +copy: 2012-12-27 16:24:08 Europe/London +changed: 2012-12-27 05:07:19 Europe/London +orig: 2012-12-27 05:07:19 Europe/London +copy: 2012-12-27 05:07:19 Europe/London +changed: 2012-12-27 05:07:19 Europe/London + +setDate(): +orig: 2012-12-27 16:24:08 Europe/London +copy: 2012-12-27 16:24:08 Europe/London +changed: 0005-07-19 16:24:08 Europe/London +orig: 0005-07-19 16:24:08 Europe/London +copy: 0005-07-19 16:24:08 Europe/London +changed: 0005-07-19 16:24:08 Europe/London + +setIsoDate(): +orig: 2012-12-27 16:24:08 Europe/London +copy: 2012-12-27 16:24:08 Europe/London +changed: 2012-01-14 16:24:08 Europe/London +orig: 2012-01-14 16:24:08 Europe/London +copy: 2012-01-14 16:24:08 Europe/London +changed: 2012-01-14 16:24:08 Europe/London + +setTimestamp(): +orig: 2012-12-27 16:24:08 Europe/London +copy: 2012-12-27 16:24:08 Europe/London +changed: 2033-10-06 18:57:02 Europe/London +orig: 2033-10-06 18:57:02 Europe/London +copy: 2033-10-06 18:57:02 Europe/London +changed: 2033-10-06 18:57:02 Europe/London diff --git a/ext/dba/dba_flatfile.c b/ext/dba/dba_flatfile.c index 082aa5cdb6c9b..34aa635a5430c 100644 --- a/ext/dba/dba_flatfile.c +++ b/ext/dba/dba_flatfile.c @@ -88,15 +88,16 @@ DBA_UPDATE_FUNC(flatfile) gval.dsize = vallen; switch(flatfile_store(dba, gkey, gval, mode==1 ? FLATFILE_INSERT : FLATFILE_REPLACE TSRMLS_CC)) { - case -1: - php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Operation not possible"); - return FAILURE; - default: - case 0: - return SUCCESS; - case 1: - php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Key already exists"); - return FAILURE; + case 0: + return SUCCESS; + case 1: + return FAILURE; + case -1: + php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Operation not possible"); + return FAILURE; + default: + php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "Unknown return value"); + return FAILURE; } } diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c index 7534568d39c2d..47dd576496633 100644 --- a/ext/dba/dba_gdbm.c +++ b/ext/dba/dba_gdbm.c @@ -104,11 +104,18 @@ DBA_UPDATE_FUNC(gdbm) gval.dptr = (char *) val; gval.dsize = vallen; - if(gdbm_store(dba->dbf, gkey, gval, - mode == 1 ? GDBM_INSERT : GDBM_REPLACE) == 0) - return SUCCESS; - php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", gdbm_strerror(gdbm_errno)); - return FAILURE; + switch (gdbm_store(dba->dbf, gkey, gval, mode == 1 ? GDBM_INSERT : GDBM_REPLACE)) { + case 0: + return SUCCESS; + case 1: + return FAILURE; + case -1: + php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", gdbm_strerror(gdbm_errno)); + return FAILURE; + default: + php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "Unknown return value"); + return FAILURE; + } } DBA_EXISTS_FUNC(gdbm) diff --git a/ext/dba/dba_inifile.c b/ext/dba/dba_inifile.c index e1359b65e984d..05ee95c0ecbce 100644 --- a/ext/dba/dba_inifile.c +++ b/ext/dba/dba_inifile.c @@ -101,7 +101,6 @@ DBA_UPDATE_FUNC(inifile) case 0: return SUCCESS; case 1: - php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Key already exists"); return FAILURE; } } diff --git a/ext/dba/dba_qdbm.c b/ext/dba/dba_qdbm.c index 485b1997e6219..eeece57011d66 100644 --- a/ext/dba/dba_qdbm.c +++ b/ext/dba/dba_qdbm.c @@ -96,13 +96,15 @@ DBA_FETCH_FUNC(qdbm) DBA_UPDATE_FUNC(qdbm) { QDBM_DATA; - int result; - result = dpput(dba->dbf, key, keylen, val, vallen, mode == 1 ? DP_DKEEP : DP_DOVER); - if (result) + if (dpput(dba->dbf, key, keylen, val, vallen, mode == 1 ? DP_DKEEP : DP_DOVER)) { return SUCCESS; + } + + if (dpecode != DP_EKEEP) { + php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", dperrmsg(dpecode)); + } - php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", dperrmsg(dpecode)); return FAILURE; } diff --git a/ext/dba/libinifile/inifile.c b/ext/dba/libinifile/inifile.c index 89373b1e33a62..cc09b3dd80cbc 100644 --- a/ext/dba/libinifile/inifile.c +++ b/ext/dba/libinifile/inifile.c @@ -402,7 +402,7 @@ static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifi return FAILURE; } php_stream_seek(dba->fp, pos_start, SEEK_SET); - if (!php_stream_copy_to_stream(dba->fp, fp, pos_end - pos_start)) { + if (!php_stream_copy_to_stream_ex(dba->fp, fp, pos_end - pos_start, NULL)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy group [%zu - %zu] to temporary stream", pos_start, pos_end); return FAILURE; } @@ -427,7 +427,7 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRML pos_curr = php_stream_tell(from->fp); if (pos_start != pos_next) { php_stream_seek(from->fp, pos_start, SEEK_SET); - if (!php_stream_copy_to_stream(from->fp, dba->fp, pos_next - pos_start)) { + if (!php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start); ret = FAILURE; } @@ -446,13 +446,13 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRML } if (pos_start != pos_next) { php_stream_seek(from->fp, pos_start, SEEK_SET); - if (!php_stream_copy_to_stream(from->fp, dba->fp, pos_next - pos_start)) { + if (!php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start); ret = FAILURE; } } inifile_line_free(&ln); - return SUCCESS; + return ret; } /* }}} */ @@ -460,7 +460,7 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRML */ static int inifile_delete_replace_append(inifile *dba, const key_type *key, const val_type *value, int append TSRMLS_DC) { - size_t pos_grp_start, pos_grp_next; + size_t pos_grp_start=0, pos_grp_next; inifile *ini_tmp = NULL; php_stream *fp_tmp = NULL; int ret; @@ -497,7 +497,7 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons php_stream_seek(dba->fp, 0, SEEK_END); if (pos_grp_next != (size_t)php_stream_tell(dba->fp)) { php_stream_seek(dba->fp, pos_grp_next, SEEK_SET); - if (!php_stream_copy_to_stream(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL)) { + if (!php_stream_copy_to_stream_ex(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL, NULL)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy remainder to temporary stream"); ret = FAILURE; } @@ -538,7 +538,7 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons if (fp_tmp && php_stream_tell(fp_tmp)) { php_stream_seek(fp_tmp, 0, SEEK_SET); php_stream_seek(dba->fp, 0, SEEK_END); - if (!php_stream_copy_to_stream(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL)) { + if (!php_stream_copy_to_stream_ex(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL, NULL)) { php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Could not copy from temporary stream - ini file truncated"); ret = FAILURE; } diff --git a/ext/dba/tests/dba_db1.phpt b/ext/dba/tests/dba_db1.phpt index a24600350f551..d0e530e026f1b 100644 --- a/ext/dba/tests/dba_db1.phpt +++ b/ext/dba/tests/dba_db1.phpt @@ -18,6 +18,8 @@ database handler: db1 Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { @@ -33,6 +35,8 @@ array(3) { Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/dba/tests/dba_db2.phpt b/ext/dba/tests/dba_db2.phpt index 89d8a926e125a..1cfbb3e340c2e 100644 --- a/ext/dba/tests/dba_db2.phpt +++ b/ext/dba/tests/dba_db2.phpt @@ -18,6 +18,8 @@ database handler: db2 Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { @@ -33,6 +35,8 @@ array(3) { Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/dba/tests/dba_db3.phpt b/ext/dba/tests/dba_db3.phpt index 257c88217524e..5de7e5a0417ba 100644 --- a/ext/dba/tests/dba_db3.phpt +++ b/ext/dba/tests/dba_db3.phpt @@ -18,6 +18,8 @@ database handler: db3 Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { @@ -33,6 +35,8 @@ array(3) { Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/dba/tests/dba_db4_000.phpt b/ext/dba/tests/dba_db4_000.phpt index bbbc52c9f18c1..17db4bb62dfa8 100644 --- a/ext/dba/tests/dba_db4_000.phpt +++ b/ext/dba/tests/dba_db4_000.phpt @@ -22,6 +22,8 @@ database handler: db4 Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { @@ -37,6 +39,8 @@ array(3) { Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/dba/tests/dba_dbm.phpt b/ext/dba/tests/dba_dbm.phpt index dd1fe1e31cdab..8bea8463da76c 100644 --- a/ext/dba/tests/dba_dbm.phpt +++ b/ext/dba/tests/dba_dbm.phpt @@ -18,6 +18,8 @@ database handler: dbm Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { @@ -33,6 +35,8 @@ array(3) { Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/dba/tests/dba_flatfile.phpt b/ext/dba/tests/dba_flatfile.phpt index 8e1ca6a93340e..ac7f86ebdaafb 100644 --- a/ext/dba/tests/dba_flatfile.phpt +++ b/ext/dba/tests/dba_flatfile.phpt @@ -22,6 +22,8 @@ database handler: flatfile Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { @@ -37,6 +39,8 @@ array(3) { Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/dba/tests/dba_gdbm.phpt b/ext/dba/tests/dba_gdbm.phpt index 33d7d206159ac..e68e8b7409024 100644 --- a/ext/dba/tests/dba_gdbm.phpt +++ b/ext/dba/tests/dba_gdbm.phpt @@ -21,6 +21,8 @@ database handler: gdbm Content String 2 Content 2 replaced Read during write:%sallowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/dba/tests/dba_handler.inc b/ext/dba/tests/dba_handler.inc index 1c3f5127ef384..a950e903af426 100644 --- a/ext/dba/tests/dba_handler.inc +++ b/ext/dba/tests/dba_handler.inc @@ -46,8 +46,16 @@ do { echo "Read during write: allowed\n"; } if ($db_writer!==FALSE) { - dba_insert("key number 6", "The 6th value", $db_writer); - @dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer); + if (dba_insert("key number 6", "The 6th value", $db_writer)) { + echo '"key number 6" written' . "\n"; + } else { + echo 'Failed to write "key number 6"' . "\n"; + } + if (dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer)) { + echo '"key number 6" written 2nd time' . "\n"; + } else { + echo 'Failed to write "key number 6" 2nd time' . "\n"; + } dba_replace("key2", "Content 2 replaced 2nd time", $db_writer); dba_delete("key4", $db_writer); echo dba_fetch("key2", $db_writer)."\n"; diff --git a/ext/dba/tests/dba_inifile.phpt b/ext/dba/tests/dba_inifile.phpt index 81ab738796315..5975d25f4dc54 100644 --- a/ext/dba/tests/dba_inifile.phpt +++ b/ext/dba/tests/dba_inifile.phpt @@ -18,6 +18,8 @@ database handler: inifile Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { @@ -33,6 +35,8 @@ array(3) { Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/dba/tests/dba_ndbm.phpt b/ext/dba/tests/dba_ndbm.phpt index b0f5542de4969..193db6f94d748 100644 --- a/ext/dba/tests/dba_ndbm.phpt +++ b/ext/dba/tests/dba_ndbm.phpt @@ -18,6 +18,8 @@ database handler: ndbm Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { @@ -33,6 +35,8 @@ array(3) { Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/dba/tests/dba_qdbm.phpt b/ext/dba/tests/dba_qdbm.phpt index ef216d9258bc4..e2205baa267dd 100644 --- a/ext/dba/tests/dba_qdbm.phpt +++ b/ext/dba/tests/dba_qdbm.phpt @@ -19,6 +19,8 @@ database handler: qdbm Content String 2 Content 2 replaced Read during write:%sallowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/dba/tests/dba_tcadb.phpt b/ext/dba/tests/dba_tcadb.phpt index 52dd4de3361fe..28b6dd8f0b5a0 100644 --- a/ext/dba/tests/dba_tcadb.phpt +++ b/ext/dba/tests/dba_tcadb.phpt @@ -22,6 +22,8 @@ database handler: tcadb Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { @@ -37,6 +39,8 @@ array(3) { Content String 2 Content 2 replaced Read during write: not allowed +"key number 6" written +Failed to write "key number 6" 2nd time Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c index 3d50cb80a6388..e4b42637663d4 100644 --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@ -23,10 +23,10 @@ #include "config.h" #endif -#include #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" +#include #include "php_enchant.h" typedef EnchantBroker * EnchantBrokerPtr; diff --git a/ext/ereg/regex.patch b/ext/ereg/regex.patch new file mode 100644 index 0000000000000..864e6bb6d81c9 --- /dev/null +++ b/ext/ereg/regex.patch @@ -0,0 +1,72 @@ +diff -u regex.orig/regerror.c regex/regerror.c +--- regex.orig/regerror.c 2011-08-09 19:49:30.000000000 +0800 ++++ regex/regerror.c 2011-08-12 10:45:57.000000000 +0800 +@@ -8,6 +8,7 @@ + #include "regex.h" + #include "utils.h" + #include "regerror.ih" ++#include "php.h" + + /* + = #define REG_OKAY 0 +@@ -74,17 +75,19 @@ + char convbuf[50]; + + if (errcode == REG_ATOI) +- s = regatoi(preg, convbuf); ++ s = regatoi(preg, convbuf, sizeof(convbuf)); + else { + for (r = rerrs; r->code >= 0; r++) + if (r->code == target) + break; + + if (errcode®_ITOA) { +- if (r->code >= 0) +- (void) strcpy(convbuf, r->name); +- else +- sprintf(convbuf, "REG_0x%x", target); ++ if (r->code >= 0) { ++ (void) strncpy(convbuf, r->name, sizeof(convbuf) - 1); ++ convbuf[sizeof(convbuf) - 1] = '\0'; ++ } else { ++ snprintf(convbuf, sizeof(convbuf), "REG_0x%x", target); ++ } + assert(strlen(convbuf) < sizeof(convbuf)); + s = convbuf; + } else +@@ -106,12 +109,13 @@ + + /* + - regatoi - internal routine to implement REG_ATOI +- == static char *regatoi(const regex_t *preg, char *localbuf); ++ == static char *regatoi(const regex_t *preg, char *localbuf, int bufsize); + */ + static char * +-regatoi(preg, localbuf) ++regatoi(preg, localbuf, bufsize) + const regex_t *preg; + char *localbuf; ++int bufsize; + { + register const struct rerr *r; + +@@ -121,6 +125,6 @@ + if (r->code < 0) + return("0"); + +- sprintf(localbuf, "%d", r->code); ++ snprintf(localbuf, bufsize, "%d", r->code); + return(localbuf); + } +diff -u regex.orig/regerror.ih regex/regerror.ih +--- regex.orig/regerror.ih 2011-08-09 19:49:00.000000000 +0800 ++++ regex/regerror.ih 2011-08-09 19:41:07.000000000 +0800 +@@ -4,7 +4,7 @@ + #endif + + /* === regerror.c === */ +-static char *regatoi(const regex_t *preg, char *localbuf); ++static char *regatoi(const regex_t *preg, char *localbuf, int bufsize); + + #ifdef __cplusplus + } diff --git a/ext/fileinfo/libmagic/print.c b/ext/fileinfo/libmagic/print.c index 8370f50c283f8..89c51b04cde4b 100644 --- a/ext/fileinfo/libmagic/print.c +++ b/ext/fileinfo/libmagic/print.c @@ -28,7 +28,6 @@ /* * print.c - debugging printout routines */ - #define _GNU_SOURCE #include "php.h" diff --git a/ext/fileinfo/php_fileinfo.h b/ext/fileinfo/php_fileinfo.h index 14bd256a42d28..4a34357ccf70a 100644 --- a/ext/fileinfo/php_fileinfo.h +++ b/ext/fileinfo/php_fileinfo.h @@ -24,7 +24,7 @@ extern zend_module_entry fileinfo_module_entry; #define phpext_fileinfo_ptr &fileinfo_module_entry -#define PHP_FILEINFO_VERSION "1.0.5" +#define PHP_FILEINFO_VERSION "1.0.5-dev" #ifdef PHP_WIN32 #define PHP_FILEINFO_API __declspec(dllexport) diff --git a/ext/filter/filter.c b/ext/filter/filter.c index 2aa8dd57d9c0c..da951feb042dd 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -47,6 +47,7 @@ static const filter_list_entry filter_list[] = { { "validate_url", FILTER_VALIDATE_URL, php_filter_validate_url }, { "validate_email", FILTER_VALIDATE_EMAIL, php_filter_validate_email }, { "validate_ip", FILTER_VALIDATE_IP, php_filter_validate_ip }, + { "validate_mac", FILTER_VALIDATE_MAC, php_filter_validate_mac }, { "string", FILTER_SANITIZE_STRING, php_filter_string }, { "stripped", FILTER_SANITIZE_STRING, php_filter_string }, @@ -233,6 +234,7 @@ PHP_MINIT_FUNCTION(filter) REGISTER_LONG_CONSTANT("FILTER_VALIDATE_URL", FILTER_VALIDATE_URL, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_VALIDATE_EMAIL", FILTER_VALIDATE_EMAIL, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_VALIDATE_IP", FILTER_VALIDATE_IP, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("FILTER_VALIDATE_MAC", FILTER_VALIDATE_MAC, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_DEFAULT", FILTER_DEFAULT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_UNSAFE_RAW", FILTER_UNSAFE_RAW, CONST_CS | CONST_PERSISTENT); diff --git a/ext/filter/filter_private.h b/ext/filter/filter_private.h index 9bc53a0e4757f..65e61dfea7fdb 100644 --- a/ext/filter/filter_private.h +++ b/ext/filter/filter_private.h @@ -63,7 +63,8 @@ #define FILTER_VALIDATE_URL 0x0111 #define FILTER_VALIDATE_EMAIL 0x0112 #define FILTER_VALIDATE_IP 0x0113 -#define FILTER_VALIDATE_LAST 0x0113 +#define FILTER_VALIDATE_MAC 0x0114 +#define FILTER_VALIDATE_LAST 0x0114 #define FILTER_VALIDATE_ALL 0x0100 diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 58d5870c112e1..b8df2183b9d86 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -784,6 +784,67 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ } /* }}} */ +void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ +{ + char *input = Z_STRVAL_P(value); + int input_len = Z_STRLEN_P(value); + int tokens, length, i, offset, exp_separator_set, exp_separator_len; + char separator; + char *exp_separator; + long ret = 0; + zval **option_val; + + FETCH_STRING_OPTION(exp_separator, "separator"); + + if (exp_separator_set && exp_separator_len != 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Separator must be exactly one character long"); + RETURN_VALIDATION_FAILED; + } + + if (14 == input_len) { + /* EUI-64 format: Four hexadecimal digits separated by dots. Less + * commonly used but valid nonetheless. + */ + tokens = 3; + length = 4; + separator = '.'; + } else if (17 == input_len && input[2] == '-') { + /* IEEE 802 format: Six hexadecimal digits separated by hyphens. */ + tokens = 6; + length = 2; + separator = '-'; + } else if (17 == input_len && input[2] == ':') { + /* IEEE 802 format: Six hexadecimal digits separated by colons. */ + tokens = 6; + length = 2; + separator = ':'; + } else { + RETURN_VALIDATION_FAILED; + } + + if (exp_separator_set && separator != exp_separator[0]) { + RETURN_VALIDATION_FAILED; + } + + /* Essentially what we now have is a set of tokens each consisting of + * a hexadecimal number followed by a separator character. (With the + * exception of the last token which does not have the separator.) + */ + for (i = 0; i < tokens; i++) { + offset = i * (length + 1); + + if (i < tokens - 1 && input[offset + length] != separator) { + /* The current token did not end with e.g. a "." */ + RETURN_VALIDATION_FAILED + } + if (php_filter_parse_hex(input + offset, length, &ret TSRMLS_CC) < 0) { + /* The current token is no valid hexadecimal digit */ + RETURN_VALIDATION_FAILED + } + } +} +/* }}} */ + /* * Local variables: * tab-width: 4 diff --git a/ext/filter/php_filter.h b/ext/filter/php_filter.h index cbe1c4720093b..e31f0f08175d3 100644 --- a/ext/filter/php_filter.h +++ b/ext/filter/php_filter.h @@ -78,6 +78,7 @@ void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL); void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL); void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL); void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL); +void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL); void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL); void php_filter_encoded(PHP_INPUT_FILTER_PARAM_DECL); diff --git a/ext/filter/tests/008.phpt b/ext/filter/tests/008.phpt index 8a4340542f2d4..a499219ee76e5 100644 --- a/ext/filter/tests/008.phpt +++ b/ext/filter/tests/008.phpt @@ -11,7 +11,7 @@ var_dump(filter_list(array())); echo "Done\n"; ?> --EXPECTF-- -array(19) { +array(20) { [0]=> string(3) "int" [1]=> @@ -27,28 +27,30 @@ array(19) { [6]=> string(11) "validate_ip" [7]=> - string(6) "string" + string(12) "validate_mac" [8]=> - string(8) "stripped" + string(6) "string" [9]=> - string(7) "encoded" + string(8) "stripped" [10]=> - string(13) "special_chars" + string(7) "encoded" [11]=> - string(18) "full_special_chars" + string(13) "special_chars" [12]=> - string(10) "unsafe_raw" + string(18) "full_special_chars" [13]=> - string(5) "email" + string(10) "unsafe_raw" [14]=> - string(3) "url" + string(5) "email" [15]=> - string(10) "number_int" + string(3) "url" [16]=> - string(12) "number_float" + string(10) "number_int" [17]=> - string(12) "magic_quotes" + string(12) "number_float" [18]=> + string(12) "magic_quotes" + [19]=> string(8) "callback" } diff --git a/ext/filter/tests/033.phpt b/ext/filter/tests/033.phpt index 04daa61333970..d76f9ab3b8a55 100644 --- a/ext/filter/tests/033.phpt +++ b/ext/filter/tests/033.phpt @@ -10,22 +10,23 @@ default_charset=UTF-8 include dirname(__FILE__) . '/033_run.inc'; ?> --EXPECT-- -int 1 123 -boolean 1 -float 1 123 -validate_regexp O'Henry -validate_url http://a.b.c -validate_email foo@bar.com -validate_ip 1.2.3.4 -string PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc() O'Henry 하퍼 -stripped PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc() O'Henry 하퍼 -encoded PHP 1 foo%40bar.com http%3A%2F%2Fa.b.c 1.2.3.4 123 123abc%3C%3E%28%29 O%27Henry %ED%95%98%ED%8D%BC -special_chars PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry 하퍼 -full_special_chars PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry 하퍼 -unsafe_raw PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry 하퍼 -email PHP 1 foo@bar.com httpa.b.c 1.2.3.4 123 123abc O'Henry -url PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry -number_int 1 1234 123 123 -number_float 1 1234 123 123 -magic_quotes PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O\'Henry 하퍼 -callback PHP 1 FOO@BAR.COM HTTP://A.B.C 1.2.3.4 123 123ABC<>() O'HENRY 하퍼 +int 1 123 +boolean 1 +float 1 123 +validate_regexp O'Henry +validate_url http://a.b.c +validate_email foo@bar.com +validate_ip 1.2.3.4 +validate_mac aa:bb:cc:dd:ee:ff +string PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc() O'Henry 하퍼 aa:bb:cc:dd:ee:ff +stripped PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc() O'Henry 하퍼 aa:bb:cc:dd:ee:ff +encoded PHP 1 foo%40bar.com http%3A%2F%2Fa.b.c 1.2.3.4 123 123abc%3C%3E%28%29 O%27Henry %ED%95%98%ED%8D%BCaa%3Abb%3Acc%3Add%3Aee%3Aff +special_chars PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry 하퍼 aa:bb:cc:dd:ee:ff +full_special_chars PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry 하퍼 aa:bb:cc:dd:ee:ff +unsafe_raw PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry 하퍼 aa:bb:cc:dd:ee:ff +email PHP 1 foo@bar.com httpa.b.c 1.2.3.4 123 123abc O'Henry aabbccddeeff +url PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry aa:bb:cc:dd:ee:ff +number_int 1 1234 123 123 +number_float 1 1234 123 123 +magic_quotes PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O\'Henry 하퍼 aa:bb:cc:dd:ee:ff +callback PHP 1 FOO@BAR.COM HTTP://A.B.C 1.2.3.4 123 123ABC<>() O'HENRY 하퍼 AA:BB:CC:DD:EE:FF \ No newline at end of file diff --git a/ext/filter/tests/033_run.inc b/ext/filter/tests/033_run.inc index e3b67387ca2a9..ecb2cf7be160d 100644 --- a/ext/filter/tests/033_run.inc +++ b/ext/filter/tests/033_run.inc @@ -16,7 +16,8 @@ $data = array( "123", "123abc<>()", "O'Henry", - "하퍼" + "하퍼", + "aa:bb:cc:dd:ee:ff", ); @@ -35,6 +36,7 @@ foreach(filter_list() as $filter) { printf("%-5s",$result[5]); printf("%-20s",$result[6]); printf("%-15s",$result[7]); - printf("%-10s\n",$result[8]); + printf("%-10s",$result[8]); + printf("%-10s\n",$result[9]); } ?> diff --git a/ext/filter/tests/055.phpt b/ext/filter/tests/055.phpt new file mode 100644 index 0000000000000..688dbb2b54034 --- /dev/null +++ b/ext/filter/tests/055.phpt @@ -0,0 +1,48 @@ +--TEST-- +filter_var() and FILTER_VALIDATE_MAC +--SKIPIF-- + +--FILE-- + array("separator" => "-"))), + array("01-23-45-67-89-ab", array("options" => array("separator" => "."))), + array("01-23-45-67-89-ab", array("options" => array("separator" => ":"))), + array("01-23-45-67-89-AB", null), + array("01-23-45-67-89-aB", null), + array("01:23:45:67:89:ab", null), + array("01:23:45:67:89:AB", null), + array("01:23:45:67:89:aB", null), + array("01:23:45-67:89:aB", null), + array("xx:23:45:67:89:aB", null), + array("0123.4567.89ab", null), + array("01-23-45-67-89-ab", array("options" => array("separator" => "--"))), + array("01-23-45-67-89-ab", array("options" => array("separator" => ""))), +); +foreach ($values as $value) { + var_dump(filter_var($value[0], FILTER_VALIDATE_MAC, $value[1])); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(17) "01-23-45-67-89-ab" +string(17) "01-23-45-67-89-ab" +bool(false) +bool(false) +string(17) "01-23-45-67-89-AB" +string(17) "01-23-45-67-89-aB" +string(17) "01:23:45:67:89:ab" +string(17) "01:23:45:67:89:AB" +string(17) "01:23:45:67:89:aB" +bool(false) +bool(false) +string(14) "0123.4567.89ab" + +Warning: filter_var(): Separator must be exactly one character long in %s055.php on line %d +bool(false) + +Warning: filter_var(): Separator must be exactly one character long in %s055.php on line %d +bool(false) +Done diff --git a/ext/gd/config.w32 b/ext/gd/config.w32 index 8c932a037c1cb..cf7dd9bfd3d34 100644 --- a/ext/gd/config.w32 +++ b/ext/gd/config.w32 @@ -3,15 +3,16 @@ ARG_WITH("gd", "Bundled GD support", "yes,shared"); ARG_WITH("t1lib", "t1lib support", "yes"); +ARG_WITH("libvpx", "vpx support", "yes"); if (PHP_GD != "no") { if ( - CHECK_LIB("vpxmt.lib", "gd", PHP_GD) && CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) && CHECK_LIB("freetype_a.lib;freetype.lib", "gd", PHP_GD) && CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) && CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd") && - CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng12") && + (CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng15") || + CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng12")) && (CHECK_LIB("libiconv_a.lib;libiconv.lib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) && CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD) && (((PHP_ZLIB=="no") && (CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD) )) || @@ -29,6 +30,14 @@ if (PHP_GD != "no") { } } + if (PHP_LIBVPX != "no") { + if (CHECK_LIB("vpxmt.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("vp8.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\vpx")) { + ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBVPX /D HAVE_GD_WEBP"); + } else { + WARNING("libvpx not enabled; libraries and headers not found"); + } + } CHECK_LIB("User32.lib", "gd", PHP_GD); CHECK_LIB("Gdi32.lib", "gd", PHP_GD); @@ -59,14 +68,12 @@ if (PHP_GD != "no") { /D HAVE_GD_WBMP \ /D HAVE_GD_XBM \ /D HAVE_GD_XPM \ -/D HAVE_GD_WEBP \ /D HAVE_LIBFREETYPE=1 \ /D HAVE_LIBGD13=1 \ /D HAVE_LIBGD15=1 \ /D HAVE_LIBGD20=1 \ /D HAVE_LIBGD204=1 \ /D HAVE_LIBJPEG \ -/D HAVE_LIBVPX \ /D HAVE_LIBPNG \ /D HAVE_XPM \ /D HAVE_COLORCLOSESTHWB \ @@ -76,7 +83,7 @@ if (PHP_GD != "no") { "); PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd" ); - } else { + } else { WARNING("gd not enabled; libraries and headers not found"); } } diff --git a/ext/hash/hash.c b/ext/hash/hash.c index f5dca3fe547c1..9492387dbb714 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -23,6 +23,7 @@ #include "config.h" #endif +#include #include "php_hash.h" #include "ext/standard/info.h" #include "ext/standard/file.h" @@ -202,10 +203,45 @@ PHP_FUNCTION(hash_file) } /* }}} */ +static inline void php_hash_string_xor_char(unsigned char *out, const unsigned char *in, const unsigned char xor_with, const int length) { + int i; + for (i=0; i < length; i++) { + out[i] = in[i] ^ xor_with; + } +} + +static inline void php_hash_string_xor(unsigned char *out, const unsigned char *in, const unsigned char *xor_with, const int length) { + int i; + for (i=0; i < length; i++) { + out[i] = in[i] ^ xor_with[i]; + } +} + +static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops *ops, void *context, const unsigned char *key, const int key_len) { + memset(K, 0, ops->block_size); + if (key_len > ops->block_size) { + /* Reduce the key first */ + ops->hash_init(context); + ops->hash_update(context, key, key_len); + ops->hash_final(K, context); + } else { + memcpy(K, key, key_len); + } + /* XOR the key with 0x36 to get the ipad) */ + php_hash_string_xor_char(K, K, 0x36, ops->block_size); +} + +static inline void php_hash_hmac_round(unsigned char *final, const php_hash_ops *ops, void *context, const unsigned char *key, const unsigned char *data, const long data_size) { + ops->hash_init(context); + ops->hash_update(context, key, ops->block_size); + ops->hash_update(context, data, data_size); + ops->hash_final(final, context); +} + static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_bool raw_output_default) /* {{{ */ { char *algo, *data, *digest, *key, *K; - int algo_len, data_len, key_len, i; + int algo_len, data_len, key_len; zend_bool raw_output = raw_output_default; const php_hash_ops *ops; void *context; @@ -230,52 +266,29 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename, } context = emalloc(ops->context_size); - ops->hash_init(context); K = emalloc(ops->block_size); - memset(K, 0, ops->block_size); + digest = emalloc(ops->digest_size + 1); - if (key_len > ops->block_size) { - /* Reduce the key first */ - ops->hash_update(context, (unsigned char *) key, key_len); - ops->hash_final((unsigned char *) K, context); - /* Make the context ready to start over */ - ops->hash_init(context); - } else { - memcpy(K, key, key_len); - } - - /* XOR ipad */ - for(i=0; i < ops->block_size; i++) { - K[i] ^= 0x36; - } - ops->hash_update(context, (unsigned char *) K, ops->block_size); + php_hash_hmac_prep_key((unsigned char *) K, ops, context, (unsigned char *) key, key_len); if (isfilename) { char buf[1024]; int n; - + ops->hash_init(context); + ops->hash_update(context, (unsigned char *) K, ops->block_size); while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) { ops->hash_update(context, (unsigned char *) buf, n); } php_stream_close(stream); + ops->hash_final((unsigned char *) digest, context); } else { - ops->hash_update(context, (unsigned char *) data, data_len); + php_hash_hmac_round((unsigned char *) digest, ops, context, (unsigned char *) K, (unsigned char *) data, data_len); } - digest = emalloc(ops->digest_size + 1); - ops->hash_final((unsigned char *) digest, context); - - /* Convert K to opad -- 0x6A = 0x36 ^ 0x5C */ - for(i=0; i < ops->block_size; i++) { - K[i] ^= 0x6A; - } + php_hash_string_xor_char((unsigned char *) K, (unsigned char *) K, 0x6A, ops->block_size); - /* Feed this result into the outter hash */ - ops->hash_init(context); - ops->hash_update(context, (unsigned char *) K, ops->block_size); - ops->hash_update(context, (unsigned char *) digest, ops->digest_size); - ops->hash_final((unsigned char *) digest, context); + php_hash_hmac_round((unsigned char *) digest, ops, context, (unsigned char *) K, (unsigned char *) digest, ops->digest_size); /* Zero the key */ memset(K, 0, ops->block_size); @@ -591,6 +604,128 @@ PHP_FUNCTION(hash_algos) } /* }}} */ +/* {{{ proto string hash_pbkdf2(string algo, string password, string salt, int iterations [, int length = 0, bool raw_output = false]) +Generate a PBKDF2 hash of the given password and salt +Returns lowercase hexits by default */ +PHP_FUNCTION(hash_pbkdf2) +{ + char *returnval, *algo, *salt, *pass = NULL; + unsigned char *computed_salt, *digest, *temp, *result, *K1, *K2 = NULL; + long loops, i, j, algo_len, pass_len, iterations, length, digest_length = 0; + int argc, salt_len = 0; + zend_bool raw_output = 0; + const php_hash_ops *ops; + void *context; + + argc = ZEND_NUM_ARGS(); + if (zend_parse_parameters(argc TSRMLS_CC, "sssl|lb", &algo, &algo_len, &pass, &pass_len, &salt, &salt_len, &iterations, &length, &raw_output) == FAILURE) { + return; + } + + ops = php_hash_fetch_ops(algo, algo_len); + if (!ops) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown hashing algorithm: %s", algo); + RETURN_FALSE; + } + + if (iterations <= 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Iterations must be a positive integer: %ld", iterations); + RETURN_FALSE; + } + + if (length < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to 0: %ld", length); + RETURN_FALSE; + } + + if (salt_len > INT_MAX - 4) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied salt is too long, max of INT_MAX - 4 bytes: %d supplied", salt_len); + RETURN_FALSE; + } + + context = emalloc(ops->context_size); + ops->hash_init(context); + + K1 = emalloc(ops->block_size); + K2 = emalloc(ops->block_size); + digest = emalloc(ops->digest_size); + temp = emalloc(ops->digest_size); + + /* Setup Keys that will be used for all hmac rounds */ + php_hash_hmac_prep_key(K1, ops, context, (unsigned char *) pass, pass_len); + /* Convert K1 to opad -- 0x6A = 0x36 ^ 0x5C */ + php_hash_string_xor_char(K2, K1, 0x6A, ops->block_size); + + /* Setup Main Loop to build a long enough result */ + if (length == 0) { + length = ops->digest_size; + } + digest_length = length; + if (!raw_output) { + digest_length = (long) ceil((float) length / 2.0); + } + + loops = (long) ceil((float) digest_length / (float) ops->digest_size); + + result = safe_emalloc(loops, ops->digest_size, 0); + + computed_salt = safe_emalloc(salt_len, 1, 4); + memcpy(computed_salt, (unsigned char *) salt, salt_len); + + for (i = 1; i <= loops; i++) { + /* digest = hash_hmac(salt + pack('N', i), password) { */ + + /* pack("N", i) */ + computed_salt[salt_len] = (unsigned char) (i >> 24); + computed_salt[salt_len + 1] = (unsigned char) ((i & 0xFF0000) >> 16); + computed_salt[salt_len + 2] = (unsigned char) ((i & 0xFF00) >> 8); + computed_salt[salt_len + 3] = (unsigned char) (i & 0xFF); + + php_hash_hmac_round(digest, ops, context, K1, computed_salt, (long) salt_len + 4); + php_hash_hmac_round(digest, ops, context, K2, digest, ops->digest_size); + /* } */ + + /* temp = digest */ + memcpy(temp, digest, ops->digest_size); + + /* + * Note that the loop starting at 1 is intentional, since we've already done + * the first round of the algorithm. + */ + for (j = 1; j < iterations; j++) { + /* digest = hash_hmac(digest, password) { */ + php_hash_hmac_round(digest, ops, context, K1, digest, ops->digest_size); + php_hash_hmac_round(digest, ops, context, K2, digest, ops->digest_size); + /* } */ + /* temp ^= digest */ + php_hash_string_xor(temp, temp, digest, ops->digest_size); + } + /* result += temp */ + memcpy(result + ((i - 1) * ops->digest_size), temp, ops->digest_size); + } + /* Zero potentially sensitive variables */ + memset(K1, 0, ops->block_size); + memset(K2, 0, ops->block_size); + memset(computed_salt, 0, salt_len + 4); + efree(K1); + efree(K2); + efree(computed_salt); + efree(context); + efree(digest); + efree(temp); + + returnval = safe_emalloc(length, 1, 1); + if (raw_output) { + memcpy(returnval, result, length); + } else { + php_hash_bin2hex(returnval, result, digest_length); + } + returnval[length] = 0; + efree(result); + RETURN_STRINGL(returnval, length, 0); +} +/* }}} */ + /* Module Housekeeping */ static void php_hash_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */ @@ -1003,6 +1138,15 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_hash_algos, 0) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_pbkdf2, 0, 0, 4) + ZEND_ARG_INFO(0, algo) + ZEND_ARG_INFO(0, password) + ZEND_ARG_INFO(0, salt) + ZEND_ARG_INFO(0, iterations) + ZEND_ARG_INFO(0, length) + ZEND_ARG_INFO(0, raw_output) +ZEND_END_ARG_INFO() + /* BC Land */ #ifdef PHP_MHASH_BC ZEND_BEGIN_ARG_INFO(arginfo_mhash_get_block_size, 0) @@ -1049,6 +1193,7 @@ const zend_function_entry hash_functions[] = { PHP_FE(hash_copy, arginfo_hash_copy) PHP_FE(hash_algos, arginfo_hash_algos) + PHP_FE(hash_pbkdf2, arginfo_hash_pbkdf2) /* BC Land */ #ifdef PHP_HASH_MD5_NOT_IN_CORE @@ -1105,3 +1250,4 @@ ZEND_GET_MODULE(hash) * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ + diff --git a/ext/hash/php_hash.h b/ext/hash/php_hash.h index 4acf4a4c2fffe..4bfddbacd9c45 100644 --- a/ext/hash/php_hash.h +++ b/ext/hash/php_hash.h @@ -127,6 +127,7 @@ PHP_FUNCTION(hash_update_stream); PHP_FUNCTION(hash_update_file); PHP_FUNCTION(hash_final); PHP_FUNCTION(hash_algos); +PHP_FUNCTION(hash_pbkdf2); PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_len); PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops *ops); diff --git a/ext/hash/tests/hash_pbkdf2_basic.phpt b/ext/hash/tests/hash_pbkdf2_basic.phpt new file mode 100644 index 0000000000000..fdccc4b6ea460 --- /dev/null +++ b/ext/hash/tests/hash_pbkdf2_basic.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test hash_pbkdf2() function : basic functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECT-- +*** Testing hash_pbkdf2() : basic functionality *** +sha1: 0c60c80f961f0e71f3a9 +sha1(raw): 0c60c80f961f0e71f3a9b524af6012062fe037a6 +sha1(rounds): 3d2eec4fe41c849b80c8d8366 +sha1(rounds)(raw): 3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038 +sha256: 120fb6cffcf8b32c43e7 +sha256(raw): 120fb6cffcf8b32c43e7225256c4f837a86548c9 +sha256(rounds): 348c89dbcbd32b2f32d814b8116e84cf2b17347e +sha256(rounds)(raw): 348c89dbcbd32b2f32d814b8116e84cf2b17347ebc1800181c4e2a1fb8dd53e1c635518c7dac47e9 +===Done=== diff --git a/ext/hash/tests/hash_pbkdf2_error.phpt b/ext/hash/tests/hash_pbkdf2_error.phpt new file mode 100644 index 0000000000000..fd70cca581ea8 --- /dev/null +++ b/ext/hash/tests/hash_pbkdf2_error.phpt @@ -0,0 +1,78 @@ +--TEST-- +Test hash_pbkdf2() function : error functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECT-- +*** Testing hash_pbkdf2() : error conditions *** + +-- Testing hash_pbkdf2() function with less than expected no. of arguments -- +NULL +hash_pbkdf2() expects at least 4 parameters, 0 given +NULL +hash_pbkdf2() expects at least 4 parameters, 1 given +NULL +hash_pbkdf2() expects at least 4 parameters, 2 given +NULL +hash_pbkdf2() expects at least 4 parameters, 3 given + +-- Testing hash_pbkdf2() function with more than expected no. of arguments -- +NULL +hash_pbkdf2() expects at most 6 parameters, 7 given + +-- Testing hash_pbkdf2() function with invalid hash algorithm -- +bool(false) +hash_pbkdf2(): Unknown hashing algorithm: foo + +-- Testing hash_pbkdf2() function with invalid iterations -- +bool(false) +hash_pbkdf2(): Iterations must be a positive integer: 0 +bool(false) +hash_pbkdf2(): Iterations must be a positive integer: -1 + +-- Testing hash_pbkdf2() function with invalid length -- +bool(false) +hash_pbkdf2(): Length must be greater than or equal to 0: -1 + +===Done=== diff --git a/ext/interbase/tests/skipif.inc b/ext/interbase/tests/skipif.inc index 79813f69e681a..8f903a5ea549f 100644 --- a/ext/interbase/tests/skipif.inc +++ b/ext/interbase/tests/skipif.inc @@ -1,9 +1,8 @@ diff --git a/ext/intl/ERROR.CONVENTIONS b/ext/intl/ERROR.CONVENTIONS new file mode 100644 index 0000000000000..6f9079c56d04c --- /dev/null +++ b/ext/intl/ERROR.CONVENTIONS @@ -0,0 +1,115 @@ +The intl extension has particular conventions regarding error reporting. +These conventions are enumerated in this document. + +:: The last error is always stored globally. + +The global error code can be obtained in userland with intl_get_error_code(). +This is a U_* error code defined by ICU, but it does not have necessarily to be +returned obtained after a call to an ICU function. That is to say, the internal +PHP wrapper functions can set these error codes when appropriate. For instance, +in response to bad arguments (e.g. zend_parse_parameters() failure), the PHP +wrapper function should set the global error code to U_ILLEGAL_ARGUMENT_ERROR). + +The error code (an integer) can be converter to the corresponding enum name +string in userland with intl_error_name(). + +The associated message can be obtained with intl_get_error_message(). This is a +message set by the PHP wrapping code, not by ICU. The message should include the +name of the function that failed in order to make debugging easier (though if +you activate warnings with intl.error_level or exceptions with +intl.use_exceptions you get more fine-grained information about where the +error ocurred). + +The internal PHP code can set the global last error with: +void intl_error_set_code(intl_error* err, UErrorCode err_code TSRMLS_DC); +void intl_error_set_custom_msg(intl_error* err, char* msg, int copyMsg TSRMLS_DC); +void intl_error_set(intl_error* err, UErrorCode code, char* msg, int copyMsg TSRMLS_DC); + +and by passing NULL as the first parameter. The last function is a combination +of the first two. If the message is not a static buffer, copyMsg should be 1. +This makes the message string be copied and freed when no longer needed. There's +no way to pass ownership of the string without it being copied. + + +:: The last is ALSO stored in the object whose method call triggered the error, + unless the error is due to bad arguments, in which case only the global error + should be set + +Objects store an intl_error structed in their private data. For instance: +typedef struct { + zend_object zo; + intl_error err; + Calendar* ucal; +} Calendar_object; + +The global error and the object error can be SIMULTANEOUSLY set with these +functions: +void intl_errors_set_custom_msg(intl_error* err, char* msg, int copyMsg TSRMLS_DC); +void intl_errors_set_code(intl_error* err, UErrorCode err_code TSRMLS_DC); +void intl_errors_set(intl_error* err, UErrorCode code, char* msg, int copyMsg TSRMLS_DC); + +by passing a pointer to the object's intl_error structed as the first parameter. +Node the extra 's' in the functions' names ('errors', not 'error'). + +Static methods should only set the global error. + + +:: Intl classes that can be instantiated should provide ::getErrorCode() and + getErrorMessage() methods + +These methods are used to retrieve the error codes stored in the object's +private intl_error structured and mirror the global intl_get_error_code() and +intl_get_error_message(). + + +:: Intl methods and functions should return FALSE on error (even argument + parsing errors), not NULL. Constructors and factory methods are the + exception; these should return NULL, not FALSE. + +Not that constructors in Intl generally (always?) don't throws exceptions. +They instead destroy the object to that the result of new IntlClass() can +be NULL. This may be surprising. + + +:: Intl functions and methods should reset the global error before doing + anything else (even parse the arguments); instance methods should also reset + the object's private error + +Errors should be lost after a function call. This is different from the way +ICU operates, where functions return immediately if an error is set. + +Error resetting can be done with: +void intl_error_reset(NULL TSRMLS_DC); /* reset global error */ +void intl_errors_reset(intl_error* err TSRMLS_DC ); /* reset global and object error */ + +In practice, intl_errors_reset() is not used because most classes have also +plain functions mapped to the same internal functions as their instance methods. +Fetching of the object is done with zend_parse_method_parameters() instead of +directly using getThis(). Therefore, no reference to object is obtained until +the arguments are fully parsed. Without a reference to the object, there's no +way to reset the object's internal error code. Instead, resetting of the +object's internal error code is done upon fetching the object from its zval. + +Example: +U_CFUNC PHP_FUNCTION(breakiter_set_text) +{ + /* ... variable declations ... */ + BREAKITER_METHOD_INIT_VARS; /* macro also resets global error */ + object = getThis(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", + &text, &text_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_set_text: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + /* ... */ + + BREAKITER_METHOD_FETCH_OBJECT; /* macro also resets object's error */ + + /* ... */ +} + +Implementations of ::getErrorCode() and ::getErrorMessage() should not reset the +object's error code. diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp new file mode 100644 index 0000000000000..7bf271a344f3b --- /dev/null +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -0,0 +1,397 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include "codepointiterator_internal.h" + +#include "breakiterator_iterators.h" + +#include + +extern "C" { +#define USE_BREAKITERATOR_POINTER 1 +#include "breakiterator_class.h" +#include "breakiterator_methods.h" +#include "rulebasedbreakiterator_methods.h" +#include "codepointiterator_methods.h" +#include +#include +#include +} + +using PHP::CodePointBreakIterator; + +/* {{{ Global variables */ +zend_class_entry *BreakIterator_ce_ptr; +zend_class_entry *RuleBasedBreakIterator_ce_ptr; +zend_class_entry *CodePointBreakIterator_ce_ptr; +zend_object_handlers BreakIterator_handlers; +/* }}} */ + +U_CFUNC void breakiterator_object_create(zval *object, + BreakIterator *biter TSRMLS_DC) +{ + UClassID classId = biter->getDynamicClassID(); + zend_class_entry *ce; + + if (classId == RuleBasedBreakIterator::getStaticClassID()) { + ce = RuleBasedBreakIterator_ce_ptr; + } else if (classId == CodePointBreakIterator::getStaticClassID()) { + ce = CodePointBreakIterator_ce_ptr; + } else { + ce = BreakIterator_ce_ptr; + } + + object_init_ex(object, ce); + breakiterator_object_construct(object, biter TSRMLS_CC); +} + +U_CFUNC void breakiterator_object_construct(zval *object, + BreakIterator *biter TSRMLS_DC) +{ + BreakIterator_object *bio; + + BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK; //populate to from object + assert(bio->biter == NULL); + bio->biter = biter; +} + +/* {{{ compare handler for BreakIterator */ +static int BreakIterator_compare_objects(zval *object1, + zval *object2 TSRMLS_DC) +{ + BreakIterator_object *bio1, + *bio2; + + bio1 = (BreakIterator_object*)zend_object_store_get_object(object1 TSRMLS_CC); + bio2 = (BreakIterator_object*)zend_object_store_get_object(object2 TSRMLS_CC); + + if (bio1->biter == NULL || bio2->biter == NULL) { + return bio1->biter == bio2->biter ? 0 : 1; + } + + return *bio1->biter == *bio2->biter ? 0 : 1; +} +/* }}} */ + +/* {{{ clone handler for BreakIterator */ +static zend_object_value BreakIterator_clone_obj(zval *object TSRMLS_DC) +{ + BreakIterator_object *bio_orig, + *bio_new; + zend_object_value ret_val; + + bio_orig = (BreakIterator_object*)zend_object_store_get_object(object TSRMLS_CC); + intl_errors_reset(INTL_DATA_ERROR_P(bio_orig) TSRMLS_CC); + + ret_val = BreakIterator_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC); + bio_new = (BreakIterator_object*)zend_object_store_get_object_by_handle( + ret_val.handle TSRMLS_CC); + + zend_objects_clone_members(&bio_new->zo, ret_val, + &bio_orig->zo, Z_OBJ_HANDLE_P(object) TSRMLS_CC); + + if (bio_orig->biter != NULL) { + BreakIterator *new_biter; + + new_biter = bio_orig->biter->clone(); + if (!new_biter) { + char *err_msg; + intl_errors_set_code(BREAKITER_ERROR_P(bio_orig), + U_MEMORY_ALLOCATION_ERROR TSRMLS_CC); + intl_errors_set_custom_msg(BREAKITER_ERROR_P(bio_orig), + "Could not clone BreakIterator", 0 TSRMLS_CC); + err_msg = intl_error_get_message(BREAKITER_ERROR_P(bio_orig) TSRMLS_CC); + zend_throw_exception(NULL, err_msg, 0 TSRMLS_CC); + efree(err_msg); + } else { + bio_new->biter = new_biter; + bio_new->text = bio_orig->text; + if (bio_new->text) { + zval_add_ref(&bio_new->text); + } + } + } else { + zend_throw_exception(NULL, "Cannot clone unconstructed BreakIterator", 0 TSRMLS_CC); + } + + return ret_val; +} +/* }}} */ + +/* {{{ get_debug_info handler for BreakIterator */ +static HashTable *BreakIterator_get_debug_info(zval *object, int *is_temp TSRMLS_DC) +{ + zval zv = zval_used_for_init; + BreakIterator_object *bio; + const BreakIterator *biter; + + *is_temp = 1; + + array_init_size(&zv, 8); + + bio = (BreakIterator_object*)zend_object_store_get_object(object TSRMLS_CC); + biter = bio->biter; + + if (biter == NULL) { + add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 0); + return Z_ARRVAL(zv); + } + add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 1); + + if (bio->text == NULL) { + add_assoc_null_ex(&zv, "text", sizeof("text")); + } else { + zval_add_ref(&bio->text); + add_assoc_zval_ex(&zv, "text", sizeof("text"), bio->text); + } + + add_assoc_string_ex(&zv, "type", sizeof("type"), + const_cast(typeid(*biter).name()), 1); + + return Z_ARRVAL(zv); +} +/* }}} */ + +/* {{{ void breakiterator_object_init(BreakIterator_object* to) + * Initialize internals of BreakIterator_object not specific to zend standard objects. + */ +static void breakiterator_object_init(BreakIterator_object *bio TSRMLS_DC) +{ + intl_error_init(BREAKITER_ERROR_P(bio) TSRMLS_CC); + bio->biter = NULL; + bio->text = NULL; +} +/* }}} */ + +/* {{{ BreakIterator_objects_dtor */ +static void BreakIterator_objects_dtor(void *object, + zend_object_handle handle TSRMLS_DC) +{ + zend_objects_destroy_object((zend_object*)object, handle TSRMLS_CC); +} +/* }}} */ + +/* {{{ BreakIterator_objects_free */ +static void BreakIterator_objects_free(zend_object *object TSRMLS_DC) +{ + BreakIterator_object* bio = (BreakIterator_object*) object; + + if (bio->text) { + zval_ptr_dtor(&bio->text); + } + if (bio->biter) { + delete bio->biter; + bio->biter = NULL; + } + intl_error_reset(BREAKITER_ERROR_P(bio) TSRMLS_CC); + + zend_object_std_dtor(&bio->zo TSRMLS_CC); + + efree(bio); +} +/* }}} */ + +/* {{{ BreakIterator_object_create */ +static zend_object_value BreakIterator_object_create(zend_class_entry *ce TSRMLS_DC) +{ + zend_object_value retval; + BreakIterator_object* intern; + + intern = (BreakIterator_object*)ecalloc(1, sizeof(BreakIterator_object)); + + zend_object_std_init(&intern->zo, ce TSRMLS_CC); +#if PHP_VERSION_ID < 50399 + zend_hash_copy(intern->zo.properties, &(ce->default_properties), + (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*)); +#else + object_properties_init((zend_object*) intern, ce); +#endif + breakiterator_object_init(intern TSRMLS_CC); + + retval.handle = zend_objects_store_put( + intern, + BreakIterator_objects_dtor, + (zend_objects_free_object_storage_t) BreakIterator_objects_free, + NULL TSRMLS_CC); + + retval.handlers = &BreakIterator_handlers; + + return retval; +} +/* }}} */ + +/* {{{ BreakIterator/RuleBasedBreakIterator methods arguments info */ + +ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_void, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_locale, 0, 0, 0) + ZEND_ARG_INFO(0, "locale") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_setText, 0, 0, 1) + ZEND_ARG_INFO(0, "text") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_next, 0, 0, 0) + ZEND_ARG_INFO(0, "offset") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_offset, 0, 0, 1) + ZEND_ARG_INFO(0, "offset") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_get_locale, 0, 0, 1) + ZEND_ARG_INFO(0, "locale_type") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_getPartsIterator, 0, 0, 0) + ZEND_ARG_INFO(0, "key_type") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_rbbi___construct, 0, 0, 1) + ZEND_ARG_INFO(0, "rules") + ZEND_ARG_INFO(0, "areCompiled") +ZEND_END_ARG_INFO() + +/* }}} */ + +/* {{{ BreakIterator_class_functions + * Every 'BreakIterator' class method has an entry in this table + */ +static const zend_function_entry BreakIterator_class_functions[] = { + PHP_ME(BreakIterator, __construct, ainfo_biter_void, ZEND_ACC_PRIVATE) + PHP_ME_MAPPING(createWordInstance, breakiter_create_word_instance, ainfo_biter_locale, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(createLineInstance, breakiter_create_line_instance, ainfo_biter_locale, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(createCharacterInstance, breakiter_create_character_instance, ainfo_biter_locale, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(createSentenceInstance, breakiter_create_sentence_instance, ainfo_biter_locale, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(createTitleInstance, breakiter_create_title_instance, ainfo_biter_locale, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(createCodePointInstance, breakiter_create_code_point_instance, ainfo_biter_void, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getText, breakiter_get_text, ainfo_biter_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(setText, breakiter_set_text, ainfo_biter_setText, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(first, breakiter_first, ainfo_biter_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(last, breakiter_last, ainfo_biter_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(previous, breakiter_previous, ainfo_biter_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(next, breakiter_next, ainfo_biter_next, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(current, breakiter_current, ainfo_biter_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(following, breakiter_following, ainfo_biter_offset, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(preceding, breakiter_preceding, ainfo_biter_offset, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(isBoundary, breakiter_is_boundary, ainfo_biter_offset, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getLocale, breakiter_get_locale, ainfo_biter_get_locale, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getPartsIterator, breakiter_get_parts_iterator, ainfo_biter_getPartsIterator, ZEND_ACC_PUBLIC) + + PHP_ME_MAPPING(getErrorCode, breakiter_get_error_code, ainfo_biter_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getErrorMessage, breakiter_get_error_message, ainfo_biter_void, ZEND_ACC_PUBLIC) + PHP_FE_END +}; +/* }}} */ + +/* {{{ RuleBasedBreakIterator_class_functions + */ +static const zend_function_entry RuleBasedBreakIterator_class_functions[] = { + PHP_ME(IntlRuleBasedBreakIterator, __construct, ainfo_rbbi___construct, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getRules, rbbi_get_rules, ainfo_biter_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getRuleStatus, rbbi_get_rule_status, ainfo_biter_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getRuleStatusVec, rbbi_get_rule_status_vec, ainfo_biter_void, ZEND_ACC_PUBLIC) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 + PHP_ME_MAPPING(getBinaryRules, rbbi_get_binary_rules, ainfo_biter_void, ZEND_ACC_PUBLIC) +#endif + PHP_FE_END +}; +/* }}} */ + +/* {{{ CodePointBreakIterator_class_functions + */ +static const zend_function_entry CodePointBreakIterator_class_functions[] = { + PHP_ME_MAPPING(getLastCodePoint, cpbi_get_last_code_point, ainfo_biter_void, ZEND_ACC_PUBLIC) + PHP_FE_END +}; +/* }}} */ + + +/* {{{ breakiterator_register_BreakIterator_class + * Initialize 'BreakIterator' class + */ +U_CFUNC void breakiterator_register_BreakIterator_class(TSRMLS_D) +{ + zend_class_entry ce; + + /* Create and register 'BreakIterator' class. */ + INIT_CLASS_ENTRY(ce, "IntlBreakIterator", BreakIterator_class_functions); + ce.create_object = BreakIterator_object_create; + ce.get_iterator = _breakiterator_get_iterator; + BreakIterator_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC); + + memcpy(&BreakIterator_handlers, zend_get_std_object_handlers(), + sizeof BreakIterator_handlers); + BreakIterator_handlers.compare_objects = BreakIterator_compare_objects; + BreakIterator_handlers.clone_obj = BreakIterator_clone_obj; + BreakIterator_handlers.get_debug_info = BreakIterator_get_debug_info; + + zend_class_implements(BreakIterator_ce_ptr TSRMLS_CC, 1, + zend_ce_traversable); + + zend_declare_class_constant_long(BreakIterator_ce_ptr, + "DONE", sizeof("DONE") - 1, BreakIterator::DONE TSRMLS_CC ); + + /* Declare constants that are defined in the C header */ +#define BREAKITER_DECL_LONG_CONST(name) \ + zend_declare_class_constant_long(BreakIterator_ce_ptr, #name, \ + sizeof(#name) - 1, UBRK_ ## name TSRMLS_CC) + + BREAKITER_DECL_LONG_CONST(WORD_NONE); + BREAKITER_DECL_LONG_CONST(WORD_NONE_LIMIT); + BREAKITER_DECL_LONG_CONST(WORD_NUMBER); + BREAKITER_DECL_LONG_CONST(WORD_NUMBER_LIMIT); + BREAKITER_DECL_LONG_CONST(WORD_LETTER); + BREAKITER_DECL_LONG_CONST(WORD_LETTER_LIMIT); + BREAKITER_DECL_LONG_CONST(WORD_KANA); + BREAKITER_DECL_LONG_CONST(WORD_KANA_LIMIT); + BREAKITER_DECL_LONG_CONST(WORD_IDEO); + BREAKITER_DECL_LONG_CONST(WORD_IDEO_LIMIT); + + BREAKITER_DECL_LONG_CONST(LINE_SOFT); + BREAKITER_DECL_LONG_CONST(LINE_SOFT_LIMIT); + BREAKITER_DECL_LONG_CONST(LINE_HARD); + BREAKITER_DECL_LONG_CONST(LINE_HARD_LIMIT); + + BREAKITER_DECL_LONG_CONST(SENTENCE_TERM); + BREAKITER_DECL_LONG_CONST(SENTENCE_TERM_LIMIT); + BREAKITER_DECL_LONG_CONST(SENTENCE_SEP); + BREAKITER_DECL_LONG_CONST(SENTENCE_SEP_LIMIT); + +#undef BREAKITER_DECL_LONG_CONST + + + /* Create and register 'RuleBasedBreakIterator' class. */ + INIT_CLASS_ENTRY(ce, "IntlRuleBasedBreakIterator", + RuleBasedBreakIterator_class_functions); + RuleBasedBreakIterator_ce_ptr = zend_register_internal_class_ex(&ce, + BreakIterator_ce_ptr, NULL TSRMLS_CC); + + /* Create and register 'CodePointBreakIterator' class. */ + INIT_CLASS_ENTRY(ce, "IntlCodePointBreakIterator", + CodePointBreakIterator_class_functions); + CodePointBreakIterator_ce_ptr = zend_register_internal_class_ex(&ce, + BreakIterator_ce_ptr, NULL TSRMLS_CC); +} +/* }}} */ diff --git a/ext/intl/breakiterator/breakiterator_class.h b/ext/intl/breakiterator/breakiterator_class.h new file mode 100644 index 0000000000000..cc5d51256f926 --- /dev/null +++ b/ext/intl/breakiterator/breakiterator_class.h @@ -0,0 +1,71 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#ifndef BREAKITERATOR_CLASS_H +#define BREAKITERATOR_CLASS_H + +//redefinition of inline in PHP headers causes problems, so include this before +#include + +#include +#include "../intl_error.h" +#include "../intl_data.h" + +#ifndef USE_BREAKITERATOR_POINTER +typedef void BreakIterator; +#endif + +typedef struct { + zend_object zo; + + // error handling + intl_error err; + + // ICU break iterator + BreakIterator* biter; + + // current text + zval *text; +} BreakIterator_object; + +#define BREAKITER_ERROR(bio) (bio)->err +#define BREAKITER_ERROR_P(bio) &(BREAKITER_ERROR(bio)) + +#define BREAKITER_ERROR_CODE(bio) INTL_ERROR_CODE(BREAKITER_ERROR(bio)) +#define BREAKITER_ERROR_CODE_P(bio) &(INTL_ERROR_CODE(BREAKITER_ERROR(bio))) + +#define BREAKITER_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(BreakIterator, bio) +#define BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(BreakIterator, bio) +#define BREAKITER_METHOD_FETCH_OBJECT \ + BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK; \ + if (bio->biter == NULL) \ + { \ + intl_errors_set(&bio->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed BreakIterator", 0 TSRMLS_CC); \ + RETURN_FALSE; \ + } + +void breakiterator_object_create(zval *object, BreakIterator *break_iter TSRMLS_DC); + +void breakiterator_object_construct(zval *object, BreakIterator *break_iter TSRMLS_DC); + +void breakiterator_register_BreakIterator_class(TSRMLS_D); + +extern zend_class_entry *BreakIterator_ce_ptr, + *RuleBasedBreakIterator_ce_ptr; + +extern zend_object_handlers BreakIterator_handlers; + +#endif /* #ifndef BREAKITERATOR_CLASS_H */ diff --git a/ext/intl/breakiterator/breakiterator_iterators.cpp b/ext/intl/breakiterator/breakiterator_iterators.cpp new file mode 100644 index 0000000000000..d88ad8a712d5b --- /dev/null +++ b/ext/intl/breakiterator/breakiterator_iterators.cpp @@ -0,0 +1,346 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "breakiterator_iterators.h" +#include "../common/common_enum.h" + +extern "C" { +#define USE_BREAKITERATOR_POINTER +#include "breakiterator_class.h" +#include "../intl_convert.h" +#include "../locale/locale.h" +#include +} + +static zend_class_entry *IntlPartsIterator_ce_ptr; +static zend_object_handlers IntlPartsIterator_handlers; + +/* BreakIterator's iterator */ + +inline BreakIterator *_breakiter_prolog(zend_object_iterator *iter TSRMLS_DC) +{ + BreakIterator_object *bio; + bio = (BreakIterator_object*)zend_object_store_get_object( + (const zval*)iter->data TSRMLS_CC); + intl_errors_reset(BREAKITER_ERROR_P(bio) TSRMLS_CC); + if (bio->biter == NULL) { + intl_errors_set(BREAKITER_ERROR_P(bio), U_INVALID_STATE_ERROR, + "The BreakIterator object backing the PHP iterator is not " + "properly constructed", 0 TSRMLS_CC); + } + return bio->biter; +} + +static void _breakiterator_destroy_it(zend_object_iterator *iter TSRMLS_DC) +{ + zval_ptr_dtor((zval**)&iter->data); +} + +static void _breakiterator_move_forward(zend_object_iterator *iter TSRMLS_DC) +{ + BreakIterator *biter = _breakiter_prolog(iter TSRMLS_CC); + zoi_with_current *zoi_iter = (zoi_with_current*)iter; + + iter->funcs->invalidate_current(iter TSRMLS_CC); + + if (biter == NULL) { + return; + } + + int32_t pos = biter->next(); + if (pos != BreakIterator::DONE) { + MAKE_STD_ZVAL(zoi_iter->current); + ZVAL_LONG(zoi_iter->current, (long)pos); + } //else we've reached the end of the enum, nothing more is required +} + +static void _breakiterator_rewind(zend_object_iterator *iter TSRMLS_DC) +{ + BreakIterator *biter = _breakiter_prolog(iter TSRMLS_CC); + zoi_with_current *zoi_iter = (zoi_with_current*)iter; + + int32_t pos = biter->first(); + MAKE_STD_ZVAL(zoi_iter->current); + ZVAL_LONG(zoi_iter->current, (long)pos); +} + +static zend_object_iterator_funcs breakiterator_iterator_funcs = { + zoi_with_current_dtor, + zoi_with_current_valid, + zoi_with_current_get_current_data, + NULL, + _breakiterator_move_forward, + _breakiterator_rewind, + zoi_with_current_invalidate_current +}; + +U_CFUNC zend_object_iterator *_breakiterator_get_iterator( + zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) +{ + BreakIterator_object *bio; + if (by_ref) { + zend_throw_exception(NULL, + "Iteration by reference is not supported", 0 TSRMLS_CC); + return NULL; + } + + bio = (BreakIterator_object*)zend_object_store_get_object(object TSRMLS_CC); + BreakIterator *biter = bio->biter; + + if (biter == NULL) { + zend_throw_exception(NULL, + "The BreakIterator is not properly constructed", 0 TSRMLS_CC); + return NULL; + } + + zoi_with_current *zoi_iter = + static_cast(emalloc(sizeof *zoi_iter)); + zoi_iter->zoi.data = static_cast(object); + zoi_iter->zoi.funcs = &breakiterator_iterator_funcs; + zoi_iter->zoi.index = 0; + zoi_iter->destroy_it = _breakiterator_destroy_it; + zoi_iter->wrapping_obj = NULL; /* not used; object is in zoi.data */ + zoi_iter->current = NULL; + + zval_add_ref(&object); + + return reinterpret_cast(zoi_iter); +} + +/* BreakIterator parts iterator */ + +typedef struct zoi_break_iter_parts { + zoi_with_current zoi_cur; + parts_iter_key_type key_type; + BreakIterator_object *bio; /* so we don't have to fetch it all the time */ +} zoi_break_iter_parts; + +static void _breakiterator_parts_destroy_it(zend_object_iterator *iter TSRMLS_DC) +{ + zval_ptr_dtor(reinterpret_cast(&iter->data)); +} + +static int _breakiterator_parts_get_current_key(zend_object_iterator *iter, + char **str_key, + uint *str_key_len, + ulong *int_key TSRMLS_DC) +{ + /* the actual work is done in move_forward and rewind */ + *int_key = iter->index; + return HASH_KEY_IS_LONG; +} + +static void _breakiterator_parts_move_forward(zend_object_iterator *iter TSRMLS_DC) +{ + zoi_break_iter_parts *zoi_bit = (zoi_break_iter_parts*)iter; + BreakIterator_object *bio = zoi_bit->bio; + + iter->funcs->invalidate_current(iter TSRMLS_CC); + + int32_t cur, + next; + + cur = bio->biter->current(); + if (cur == BreakIterator::DONE) { + return; + } + next = bio->biter->next(); + if (next == BreakIterator::DONE) { + return; + } + + if (zoi_bit->key_type == PARTS_ITERATOR_KEY_LEFT) { + iter->index = cur; + } else if (zoi_bit->key_type == PARTS_ITERATOR_KEY_RIGHT) { + iter->index = next; + } + /* else zoi_bit->key_type == PARTS_ITERATOR_KEY_SEQUENTIAL + * No need to do anything, the engine increments ->index */ + + const char *s = Z_STRVAL_P(bio->text); + int32_t slen = Z_STRLEN_P(bio->text), + len; + char *res; + + if (next == BreakIterator::DONE) { + next = slen; + } + assert(next <= slen && next >= cur); + len = next - cur; + res = static_cast(emalloc(len + 1)); + + memcpy(res, &s[cur], len); + res[len] = '\0'; + + MAKE_STD_ZVAL(zoi_bit->zoi_cur.current); + ZVAL_STRINGL(zoi_bit->zoi_cur.current, res, len, 0); +} + +static void _breakiterator_parts_rewind(zend_object_iterator *iter TSRMLS_DC) +{ + zoi_break_iter_parts *zoi_bit = (zoi_break_iter_parts*)iter; + BreakIterator_object *bio = zoi_bit->bio; + + if (zoi_bit->zoi_cur.current) { + iter->funcs->invalidate_current(iter TSRMLS_CC); + } + + bio->biter->first(); + + iter->funcs->move_forward(iter TSRMLS_CC); +} + +static zend_object_iterator_funcs breakiterator_parts_it_funcs = { + zoi_with_current_dtor, + zoi_with_current_valid, + zoi_with_current_get_current_data, + _breakiterator_parts_get_current_key, + _breakiterator_parts_move_forward, + _breakiterator_parts_rewind, + zoi_with_current_invalidate_current +}; + +void IntlIterator_from_BreakIterator_parts(zval *break_iter_zv, + zval *object, + parts_iter_key_type key_type TSRMLS_DC) +{ + IntlIterator_object *ii; + + zval_add_ref(&break_iter_zv); + + object_init_ex(object, IntlPartsIterator_ce_ptr); + ii = (IntlIterator_object*)zend_object_store_get_object(object TSRMLS_CC); + + ii->iterator = (zend_object_iterator*)emalloc(sizeof(zoi_break_iter_parts)); + ii->iterator->data = break_iter_zv; + ii->iterator->funcs = &breakiterator_parts_it_funcs; + ii->iterator->index = 0; + ((zoi_with_current*)ii->iterator)->destroy_it = _breakiterator_parts_destroy_it; + ((zoi_with_current*)ii->iterator)->wrapping_obj = object; + ((zoi_with_current*)ii->iterator)->current = NULL; + + ((zoi_break_iter_parts*)ii->iterator)->bio = (BreakIterator_object*) + zend_object_store_get_object(break_iter_zv TSRMLS_CC); + assert(((zoi_break_iter_parts*)ii->iterator)->bio->biter != NULL); + ((zoi_break_iter_parts*)ii->iterator)->key_type = key_type; +} + +U_CFUNC zend_object_value IntlPartsIterator_object_create(zend_class_entry *ce TSRMLS_DC) +{ + zend_object_value retval; + + retval = IntlIterator_ce_ptr->create_object(ce TSRMLS_CC); + retval.handlers = &IntlPartsIterator_handlers; + + return retval; +} + +U_CFUNC zend_function *IntlPartsIterator_get_method(zval **object_ptr, + char *method, int method_len, const zend_literal *key TSRMLS_DC) +{ + zend_literal local_literal = {0}; + zend_function *ret; + ALLOCA_FLAG(use_heap) + + if (key == NULL) { + Z_STRVAL(local_literal.constant) = static_cast( + do_alloca(method_len + 1, use_heap)); + zend_str_tolower_copy(Z_STRVAL(local_literal.constant), + method, method_len); + local_literal.hash_value = zend_hash_func( + Z_STRVAL(local_literal.constant), method_len + 1); + key = &local_literal; + } + + if ((key->hash_value & 0xFFFFFFFF) == 0xA2B486A1 /* hash of getrulestatus\0 */ + && method_len == sizeof("getrulestatus") - 1 + && memcmp("getrulestatus", Z_STRVAL(key->constant), method_len) == 0) { + IntlIterator_object *obj = (IntlIterator_object*) + zend_object_store_get_object(*object_ptr TSRMLS_CC); + if (obj->iterator && obj->iterator->data) { + zval *break_iter_zv = static_cast(obj->iterator->data); + *object_ptr = break_iter_zv; + ret = Z_OBJ_HANDLER_P(break_iter_zv, get_method)(object_ptr, + method, method_len, key TSRMLS_CC); + goto end; + } + } + + ret = std_object_handlers.get_method(object_ptr, + method, method_len, key TSRMLS_CC); + +end: + if (key == &local_literal) { + free_alloca(Z_STRVAL(local_literal.constant), use_heap); + } + + return ret; +} + +U_CFUNC PHP_METHOD(IntlPartsIterator, getBreakIterator) +{ + INTLITERATOR_METHOD_INIT_VARS; + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "IntlPartsIterator::getBreakIterator: bad arguments", 0 TSRMLS_CC); + return; + } + + INTLITERATOR_METHOD_FETCH_OBJECT; + + zval *biter_zval = static_cast(ii->iterator->data); + RETURN_ZVAL(biter_zval, 1, 0); +} + +ZEND_BEGIN_ARG_INFO_EX(ainfo_parts_it_void, 0, 0, 0) +ZEND_END_ARG_INFO() + +static const zend_function_entry IntlPartsIterator_class_functions[] = { + PHP_ME(IntlPartsIterator, getBreakIterator, ainfo_parts_it_void, ZEND_ACC_PUBLIC) + PHP_FE_END +}; + +U_CFUNC void breakiterator_register_IntlPartsIterator_class(TSRMLS_D) +{ + zend_class_entry ce; + + /* Create and register 'BreakIterator' class. */ + INIT_CLASS_ENTRY(ce, "IntlPartsIterator", IntlPartsIterator_class_functions); + IntlPartsIterator_ce_ptr = zend_register_internal_class_ex(&ce, + IntlIterator_ce_ptr, NULL TSRMLS_CC); + IntlPartsIterator_ce_ptr->create_object = IntlPartsIterator_object_create; + + memcpy(&IntlPartsIterator_handlers, &IntlIterator_handlers, + sizeof IntlPartsIterator_handlers); + IntlPartsIterator_handlers.get_method = IntlPartsIterator_get_method; + +#define PARTSITER_DECL_LONG_CONST(name) \ + zend_declare_class_constant_long(IntlPartsIterator_ce_ptr, #name, \ + sizeof(#name) - 1, PARTS_ITERATOR_ ## name TSRMLS_CC) + + PARTSITER_DECL_LONG_CONST(KEY_SEQUENTIAL); + PARTSITER_DECL_LONG_CONST(KEY_LEFT); + PARTSITER_DECL_LONG_CONST(KEY_RIGHT); + +#undef PARTSITER_DECL_LONG_CONST +} \ No newline at end of file diff --git a/ext/intl/breakiterator/breakiterator_iterators.h b/ext/intl/breakiterator/breakiterator_iterators.h new file mode 100644 index 0000000000000..71620724147ec --- /dev/null +++ b/ext/intl/breakiterator/breakiterator_iterators.h @@ -0,0 +1,42 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ +#ifndef INTL_BREAKITERATOR_ITERATORS_H +#define INTL_BREAKITERATOR_ITERATORS_H + +#include + +U_CDECL_BEGIN +#include +#include +U_CDECL_END + +typedef enum { + PARTS_ITERATOR_KEY_SEQUENTIAL, + PARTS_ITERATOR_KEY_LEFT, + PARTS_ITERATOR_KEY_RIGHT, +} parts_iter_key_type; + +#ifdef __cplusplus +void IntlIterator_from_BreakIterator_parts(zval *break_iter_zv, + zval *object, + parts_iter_key_type key_type TSRMLS_DC); +#endif + +U_CFUNC zend_object_iterator *_breakiterator_get_iterator( + zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC); +U_CFUNC void breakiterator_register_IntlPartsIterator_class(TSRMLS_D); + +#endif \ No newline at end of file diff --git a/ext/intl/breakiterator/breakiterator_methods.cpp b/ext/intl/breakiterator/breakiterator_methods.cpp new file mode 100644 index 0000000000000..6a61f8cb93ed6 --- /dev/null +++ b/ext/intl/breakiterator/breakiterator_methods.cpp @@ -0,0 +1,452 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "codepointiterator_internal.h" + +#include "breakiterator_iterators.h" + +extern "C" { +#include "../php_intl.h" +#define USE_BREAKITERATOR_POINTER 1 +#include "breakiterator_class.h" +#include "../locale/locale.h" +#include +} + +using PHP::CodePointBreakIterator; + +U_CFUNC PHP_METHOD(BreakIterator, __construct) +{ + zend_throw_exception( NULL, + "An object of this type cannot be created with the new operator", + 0 TSRMLS_CC ); +} + +static void _breakiter_factory(const char *func_name, + BreakIterator *(*func)(const Locale&, UErrorCode&), + INTERNAL_FUNCTION_PARAMETERS) +{ + BreakIterator *biter; + const char *locale_str = NULL; + int dummy; + char *msg; + UErrorCode status = UErrorCode(); + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!", + &locale_str, &dummy) == FAILURE) { + spprintf(&msg, NULL, "%s: bad arguments", func_name); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC); + efree(msg); + RETURN_NULL(); + } + + if (locale_str == NULL) { + locale_str = intl_locale_get_default(TSRMLS_C); + } + + biter = func(Locale::createFromName(locale_str), status); + intl_error_set_code(NULL, status TSRMLS_CC); + if (U_FAILURE(status)) { + spprintf(&msg, NULL, "%s: error creating BreakIterator", + func_name); + intl_error_set_custom_msg(NULL, msg, 1 TSRMLS_CC); + efree(msg); + RETURN_NULL(); + } + + breakiterator_object_create(return_value, biter TSRMLS_CC); +} + +U_CFUNC PHP_FUNCTION(breakiter_create_word_instance) +{ + _breakiter_factory("breakiter_create_word_instance", + &BreakIterator::createWordInstance, + INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(breakiter_create_line_instance) +{ + _breakiter_factory("breakiter_create_line_instance", + &BreakIterator::createLineInstance, + INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(breakiter_create_character_instance) +{ + _breakiter_factory("breakiter_create_character_instance", + &BreakIterator::createCharacterInstance, + INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(breakiter_create_sentence_instance) +{ + _breakiter_factory("breakiter_create_sentence_instance", + &BreakIterator::createSentenceInstance, + INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(breakiter_create_title_instance) +{ + _breakiter_factory("breakiter_create_title_instance", + &BreakIterator::createTitleInstance, + INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(breakiter_create_code_point_instance) +{ + UErrorCode status = UErrorCode(); + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_create_code_point_instance: bad arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + + CodePointBreakIterator *cpbi = new CodePointBreakIterator(); + breakiterator_object_create(return_value, cpbi TSRMLS_CC); +} + +U_CFUNC PHP_FUNCTION(breakiter_get_text) +{ + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_get_text: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + if (bio->text == NULL) { + RETURN_NULL(); + } else { + RETURN_ZVAL(bio->text, 1, 0); + } +} + +U_CFUNC PHP_FUNCTION(breakiter_set_text) +{ + char *text; + int text_len; + UText *ut = NULL; + zval **textzv; + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", + &text, &text_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_set_text: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + int res = zend_get_parameters_ex(1, &textzv); + assert(res == SUCCESS); + + BREAKITER_METHOD_FETCH_OBJECT; + + /* assert it's safe to use text and text_len because zpp changes the + * arguments in the stack */ + assert(text == Z_STRVAL_PP(textzv)); + + ut = utext_openUTF8(ut, text, text_len, BREAKITER_ERROR_CODE_P(bio)); + INTL_CTOR_CHECK_STATUS(bio, "breakiter_set_text: error opening UText"); + + bio->biter->setText(ut, BREAKITER_ERROR_CODE(bio)); + utext_close(ut); /* ICU shallow clones the UText */ + INTL_CTOR_CHECK_STATUS(bio, "breakiter_set_text: error calling " + "BreakIterator::setText()"); + + /* When ICU clones the UText, it does not copy the buffer, so we have to + * keep the string buffer around by holding a reference to its zval. This + * also allows a faste implementation of getText() */ + if (bio->text != NULL) { + zval_ptr_dtor(&bio->text); + } + bio->text = *textzv; + zval_add_ref(&bio->text); + + RETURN_TRUE; +} + +static void _breakiter_no_args_ret_int32( + const char *func_name, + int32_t (BreakIterator::*func)(), + INTERNAL_FUNCTION_PARAMETERS) +{ + char *msg; + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters_none() == FAILURE) { + spprintf(&msg, NULL, "%s: bad arguments", func_name); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC); + efree(msg); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + int32_t res = (bio->biter->*func)(); + + RETURN_LONG((long)res); +} + +static void _breakiter_int32_ret_int32( + const char *func_name, + int32_t (BreakIterator::*func)(int32_t), + INTERNAL_FUNCTION_PARAMETERS) +{ + char *msg; + long arg; + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &arg) == FAILURE) { + spprintf(&msg, NULL, "%s: bad arguments", func_name); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC); + efree(msg); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + if (arg < INT32_MIN || arg > INT32_MAX) { + spprintf(&msg, NULL, "%s: offset argument is outside bounds of " + "a 32-bit wide integer", func_name); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC); + efree(msg); + RETURN_FALSE; + } + + int32_t res = (bio->biter->*func)((int32_t)arg); + + RETURN_LONG((long)res); +} + +U_CFUNC PHP_FUNCTION(breakiter_first) +{ + _breakiter_no_args_ret_int32("breakiter_first", + &BreakIterator::first, + INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(breakiter_last) +{ + _breakiter_no_args_ret_int32("breakiter_last", + &BreakIterator::last, + INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(breakiter_previous) +{ + _breakiter_no_args_ret_int32("breakiter_previous", + &BreakIterator::previous, + INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(breakiter_next) +{ + bool no_arg_version = false; + + if (ZEND_NUM_ARGS() == 0) { + no_arg_version = true; + } else if (ZEND_NUM_ARGS() == 1) { + zval **arg; + int res = zend_get_parameters_ex(1, &arg); + assert(res == SUCCESS); + if (Z_TYPE_PP(arg) == IS_NULL) { + no_arg_version = true; + ht = 0; /* pretend we don't have any argument */ + } else { + no_arg_version = false; + } + } + + if (no_arg_version) { + _breakiter_no_args_ret_int32("breakiter_next", + &BreakIterator::next, + INTERNAL_FUNCTION_PARAM_PASSTHRU); + } else { + _breakiter_int32_ret_int32("breakiter_next", + &BreakIterator::next, + INTERNAL_FUNCTION_PARAM_PASSTHRU); + } +} + +U_CFUNC PHP_FUNCTION(breakiter_current) +{ + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_current: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + int32_t res = bio->biter->current(); + + RETURN_LONG((long)res); +} + +U_CFUNC PHP_FUNCTION(breakiter_following) +{ + _breakiter_int32_ret_int32("breakiter_following", + &BreakIterator::following, + INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(breakiter_preceding) +{ + _breakiter_int32_ret_int32("breakiter_preceding", + &BreakIterator::preceding, + INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(breakiter_is_boundary) +{ + long offset; + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", + &offset) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_is_boundary: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (offset < INT32_MIN || offset > INT32_MAX) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_is_boundary: offset argument is outside bounds of " + "a 32-bit wide integer", 0 TSRMLS_CC); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + UBool res = bio->biter->isBoundary((int32_t)offset); + + RETURN_BOOL((long)res); +} + +U_CFUNC PHP_FUNCTION(breakiter_get_locale) +{ + long locale_type; + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &locale_type) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_get_locale: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (locale_type != ULOC_ACTUAL_LOCALE && locale_type != ULOC_VALID_LOCALE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_get_locale: invalid locale type", 0 TSRMLS_CC); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + Locale locale = bio->biter->getLocale((ULocDataLocaleType)locale_type, + BREAKITER_ERROR_CODE(bio)); + INTL_METHOD_CHECK_STATUS(bio, + "breakiter_get_locale: Call to ICU method has failed"); + + RETURN_STRING(locale.getName(), 1); +} + +U_CFUNC PHP_FUNCTION(breakiter_get_parts_iterator) +{ + long key_type = 0; + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &key_type) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_get_parts_iterator: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (key_type != PARTS_ITERATOR_KEY_SEQUENTIAL + && key_type != PARTS_ITERATOR_KEY_LEFT + && key_type != PARTS_ITERATOR_KEY_RIGHT) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_get_parts_iterator: bad key type", 0 TSRMLS_CC); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + IntlIterator_from_BreakIterator_parts( + object, return_value, (parts_iter_key_type)key_type TSRMLS_CC); +} + +U_CFUNC PHP_FUNCTION(breakiter_get_error_code) +{ + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_get_error_code: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + /* Fetch the object (without resetting its last error code ). */ + bio = (BreakIterator_object*)zend_object_store_get_object(object TSRMLS_CC); + if (bio == NULL) + RETURN_FALSE; + + RETURN_LONG((long)BREAKITER_ERROR_CODE(bio)); +} + +U_CFUNC PHP_FUNCTION(breakiter_get_error_message) +{ + const char* message = NULL; + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_get_error_message: bad arguments", 0 TSRMLS_CC ); + RETURN_FALSE; + } + + + /* Fetch the object (without resetting its last error code ). */ + bio = (BreakIterator_object*)zend_object_store_get_object(object TSRMLS_CC); + if (bio == NULL) + RETURN_FALSE; + + /* Return last error message. */ + message = intl_error_get_message(BREAKITER_ERROR_P(bio) TSRMLS_CC); + RETURN_STRING(message, 0); +} diff --git a/ext/intl/breakiterator/breakiterator_methods.h b/ext/intl/breakiterator/breakiterator_methods.h new file mode 100644 index 0000000000000..a479ac92e8549 --- /dev/null +++ b/ext/intl/breakiterator/breakiterator_methods.h @@ -0,0 +1,64 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#ifndef BREAKITERATOR_METHODS_H +#define BREAKITERATOR_METHODS_H + +#include + +PHP_METHOD(BreakIterator, __construct); + +PHP_FUNCTION(breakiter_create_word_instance); + +PHP_FUNCTION(breakiter_create_line_instance); + +PHP_FUNCTION(breakiter_create_character_instance); + +PHP_FUNCTION(breakiter_create_sentence_instance); + +PHP_FUNCTION(breakiter_create_title_instance); + +PHP_FUNCTION(breakiter_create_code_point_instance); + +PHP_FUNCTION(breakiter_get_text); + +PHP_FUNCTION(breakiter_set_text); + +PHP_FUNCTION(breakiter_first); + +PHP_FUNCTION(breakiter_last); + +PHP_FUNCTION(breakiter_previous); + +PHP_FUNCTION(breakiter_next); + +PHP_FUNCTION(breakiter_current); + +PHP_FUNCTION(breakiter_following); + +PHP_FUNCTION(breakiter_preceding); + +PHP_FUNCTION(breakiter_is_boundary); + +PHP_FUNCTION(breakiter_get_locale); + +PHP_FUNCTION(breakiter_get_parts_iterator); + +PHP_FUNCTION(breakiter_get_error_code); + +PHP_FUNCTION(breakiter_get_error_message); + +#endif \ No newline at end of file diff --git a/ext/intl/breakiterator/codepointiterator_internal.cpp b/ext/intl/breakiterator/codepointiterator_internal.cpp new file mode 100644 index 0000000000000..bf9239d531ffc --- /dev/null +++ b/ext/intl/breakiterator/codepointiterator_internal.cpp @@ -0,0 +1,291 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#include "codepointiterator_internal.h" +#include +#include + +//copied from cmemory.h, which is not public +typedef union { + long t1; + double t2; + void *t3; +} UAlignedMemory; + +#define U_POINTER_MASK_LSB(ptr, mask) (((ptrdiff_t)(char *)(ptr)) & (mask)) +#define U_ALIGNMENT_OFFSET(ptr) U_POINTER_MASK_LSB(ptr, sizeof(UAlignedMemory) - 1) +#define U_ALIGNMENT_OFFSET_UP(ptr) (sizeof(UAlignedMemory) - U_ALIGNMENT_OFFSET(ptr)) + +using namespace PHP; + +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CodePointBreakIterator); + +CodePointBreakIterator::CodePointBreakIterator() +: BreakIterator(), fCharIter(NULL), lastCodePoint(U_SENTINEL) +{ + UErrorCode uec = UErrorCode(); + this->fText = utext_openUChars(NULL, NULL, 0, &uec); +} + +CodePointBreakIterator::CodePointBreakIterator(const PHP::CodePointBreakIterator &other) +: BreakIterator(other), fText(NULL), fCharIter(NULL), lastCodePoint(U_SENTINEL) +{ + *this = other; +} + +CodePointBreakIterator& CodePointBreakIterator::operator=(const CodePointBreakIterator& that) +{ + UErrorCode uec = UErrorCode(); + UText *ut_clone = NULL; + + if (this == &that) { + return *this; + } + + this->fText = utext_clone(this->fText, that.fText, FALSE, TRUE, &uec); + + //don't bother copying the character iterator, getText() is deprecated + clearCurrentCharIter(); + + this->lastCodePoint = that.lastCodePoint; + return *this; +} + +CodePointBreakIterator::~CodePointBreakIterator() +{ + if (this->fText) { + utext_close(this->fText); + } + clearCurrentCharIter(); +} + +UBool CodePointBreakIterator::operator==(const BreakIterator& that) const +{ + if (typeid(*this) != typeid(that)) { + return FALSE; + } + + const CodePointBreakIterator& that2 = + static_cast(that); + + if (!utext_equals(this->fText, that2.fText)) { + return FALSE; + } + + return TRUE; +} + +CodePointBreakIterator* CodePointBreakIterator::clone(void) const +{ + return new CodePointBreakIterator(*this); +} + +CharacterIterator& CodePointBreakIterator::getText(void) const +{ + if (this->fCharIter == NULL) { + //this method is deprecated anyway; setup bogus iterator + static const UChar c = 0; + this->fCharIter = new UCharCharacterIterator(&c, 0); + } + + return *this->fCharIter; +} + +UText *CodePointBreakIterator::getUText(UText *fillIn, UErrorCode &status) const +{ + return utext_clone(fillIn, this->fText, FALSE, TRUE, &status); +} + +void CodePointBreakIterator::setText(const UnicodeString &text) +{ + UErrorCode uec = UErrorCode(); + + //this closes the previous utext, if any + this->fText = utext_openConstUnicodeString(this->fText, &text, &uec); + + clearCurrentCharIter(); +} + +void CodePointBreakIterator::setText(UText *text, UErrorCode &status) +{ + if (U_FAILURE(status)) { + return; + } + + this->fText = utext_clone(this->fText, text, FALSE, TRUE, &status); + + clearCurrentCharIter(); +} + +void CodePointBreakIterator::adoptText(CharacterIterator* it) +{ + UErrorCode uec = UErrorCode(); + clearCurrentCharIter(); + + this->fCharIter = it; + this->fText = utext_openCharacterIterator(this->fText, it, &uec); +} + +int32_t CodePointBreakIterator::first(void) +{ + UTEXT_SETNATIVEINDEX(this->fText, 0); + this->lastCodePoint = U_SENTINEL; + + return 0; +} + +int32_t CodePointBreakIterator::last(void) +{ + int32_t pos = (int32_t)utext_nativeLength(this->fText); + UTEXT_SETNATIVEINDEX(this->fText, pos); + this->lastCodePoint = U_SENTINEL; + + return pos; +} + +int32_t CodePointBreakIterator::previous(void) +{ + this->lastCodePoint = UTEXT_PREVIOUS32(this->fText); + if (this->lastCodePoint == U_SENTINEL) { + return BreakIterator::DONE; + } + + return (int32_t)UTEXT_GETNATIVEINDEX(this->fText); +} + +int32_t CodePointBreakIterator::next(void) +{ + this->lastCodePoint = UTEXT_NEXT32(this->fText); + if (this->lastCodePoint == U_SENTINEL) { + return BreakIterator::DONE; + } + + return (int32_t)UTEXT_GETNATIVEINDEX(this->fText); +} + +int32_t CodePointBreakIterator::current(void) const +{ + return (int32_t)UTEXT_GETNATIVEINDEX(this->fText); +} + +int32_t CodePointBreakIterator::following(int32_t offset) +{ + this->lastCodePoint = utext_next32From(this->fText, offset); + if (this->lastCodePoint == U_SENTINEL) { + return BreakIterator::DONE; + } + + return (int32_t)UTEXT_GETNATIVEINDEX(this->fText); +} + +int32_t CodePointBreakIterator::preceding(int32_t offset) +{ + this->lastCodePoint = utext_previous32From(this->fText, offset); + if (this->lastCodePoint == U_SENTINEL) { + return BreakIterator::DONE; + } + + return (int32_t)UTEXT_GETNATIVEINDEX(this->fText); +} + +UBool CodePointBreakIterator::isBoundary(int32_t offset) +{ + //this function has side effects, and it's supposed to + utext_setNativeIndex(this->fText, offset); + return (offset == utext_getNativeIndex(this->fText)); +} + +int32_t CodePointBreakIterator::next(int32_t n) +{ + UBool res = utext_moveIndex32(this->fText, n); + +#ifndef UTEXT_CURRENT32 +#define UTEXT_CURRENT32 utext_current32 +#endif + + if (res) { + this->lastCodePoint = UTEXT_CURRENT32(this->fText); + return (int32_t)UTEXT_GETNATIVEINDEX(this->fText); + } else { + this->lastCodePoint = U_SENTINEL; + return BreakIterator::DONE; + } +} + +CodePointBreakIterator *CodePointBreakIterator::createBufferClone( + void *stackBuffer, int32_t &bufferSize, UErrorCode &status) +{ + //see implementation of RuleBasedBreakIterator::createBufferClone() + if (U_FAILURE(status)) { + return NULL; + } + + if (bufferSize <= 0) { + bufferSize = sizeof(CodePointBreakIterator) + U_ALIGNMENT_OFFSET_UP(0); + return NULL; + } + + char *buf = (char*)stackBuffer; + uint32_t s = bufferSize; + + if (stackBuffer == NULL) { + s = 0; + } + + if (U_ALIGNMENT_OFFSET(stackBuffer) != 0) { + uint32_t offsetUp = (uint32_t)U_ALIGNMENT_OFFSET_UP(buf); + s -= offsetUp; + buf += offsetUp; + } + + if (s < sizeof(CodePointBreakIterator)) { + CodePointBreakIterator *clonedBI = new CodePointBreakIterator(*this); + if (clonedBI == NULL) { + status = U_MEMORY_ALLOCATION_ERROR; + } else { + status = U_SAFECLONE_ALLOCATED_WARNING; + } + + return clonedBI; + } + + return new(buf) CodePointBreakIterator(*this); +} + +CodePointBreakIterator &CodePointBreakIterator::refreshInputText(UText *input, UErrorCode &status) +{ + //see implementation of RuleBasedBreakIterator::createBufferClone() + if (U_FAILURE(status)) { + return *this; + } + if (input == NULL) { + status = U_ILLEGAL_ARGUMENT_ERROR; + return *this; + } + + int64_t pos = utext_getNativeIndex(this->fText); + this->fText = utext_clone(this->fText, input, FALSE, TRUE, &status); + if (U_FAILURE(status)) { + return *this; + } + + utext_setNativeIndex(this->fText, pos); + if (utext_getNativeIndex(fText) != pos) { + status = U_ILLEGAL_ARGUMENT_ERROR; + } + + return *this; +} diff --git a/ext/intl/breakiterator/codepointiterator_internal.h b/ext/intl/breakiterator/codepointiterator_internal.h new file mode 100644 index 0000000000000..988b91c2009cf --- /dev/null +++ b/ext/intl/breakiterator/codepointiterator_internal.h @@ -0,0 +1,98 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#ifndef CODEPOINTITERATOR_INTERNAL_H +#define CODEPOINTITERATOR_INTERNAL_H + +#include + +using U_ICU_NAMESPACE::BreakIterator; + +namespace PHP { + + class CodePointBreakIterator : public BreakIterator { + + public: + static UClassID getStaticClassID(); + + CodePointBreakIterator(); + + CodePointBreakIterator(const CodePointBreakIterator &other); + + CodePointBreakIterator& operator=(const CodePointBreakIterator& that); + + virtual ~CodePointBreakIterator(); + + virtual UBool operator==(const BreakIterator& that) const; + + virtual CodePointBreakIterator* clone(void) const; + + virtual UClassID getDynamicClassID(void) const; + + virtual CharacterIterator& getText(void) const; + + virtual UText *getUText(UText *fillIn, UErrorCode &status) const; + + virtual void setText(const UnicodeString &text); + + virtual void setText(UText *text, UErrorCode &status); + + virtual void adoptText(CharacterIterator* it); + + virtual int32_t first(void); + + virtual int32_t last(void); + + virtual int32_t previous(void); + + virtual int32_t next(void); + + virtual int32_t current(void) const; + + virtual int32_t following(int32_t offset); + + virtual int32_t preceding(int32_t offset); + + virtual UBool isBoundary(int32_t offset); + + virtual int32_t next(int32_t n); + + virtual CodePointBreakIterator *createBufferClone(void *stackBuffer, + int32_t &BufferSize, + UErrorCode &status); + + virtual CodePointBreakIterator &refreshInputText(UText *input, UErrorCode &status); + + inline UChar32 getLastCodePoint() + { + return this->lastCodePoint; + } + + private: + UText *fText; + UChar32 lastCodePoint; + mutable CharacterIterator *fCharIter; + + inline void clearCurrentCharIter() + { + delete this->fCharIter; + this->fCharIter = NULL; + this->lastCodePoint = U_SENTINEL; + } + }; +} + +#endif \ No newline at end of file diff --git a/ext/intl/breakiterator/codepointiterator_methods.cpp b/ext/intl/breakiterator/codepointiterator_methods.cpp new file mode 100644 index 0000000000000..ae7e526eadac4 --- /dev/null +++ b/ext/intl/breakiterator/codepointiterator_methods.cpp @@ -0,0 +1,44 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#include "codepointiterator_internal.h" + +extern "C" { +#define USE_BREAKITERATOR_POINTER 1 +#include "breakiterator_class.h" +} + +using PHP::CodePointBreakIterator; + +static inline CodePointBreakIterator *fetch_cpbi(BreakIterator_object *bio) { + return (CodePointBreakIterator*)bio->biter; +} + +U_CFUNC PHP_FUNCTION(cpbi_get_last_code_point) +{ + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "cpbi_get_last_code_point: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + RETURN_LONG(fetch_cpbi(bio)->getLastCodePoint()); +} \ No newline at end of file diff --git a/ext/intl/breakiterator/codepointiterator_methods.h b/ext/intl/breakiterator/codepointiterator_methods.h new file mode 100644 index 0000000000000..d34e5b61e2211 --- /dev/null +++ b/ext/intl/breakiterator/codepointiterator_methods.h @@ -0,0 +1,24 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#ifndef CODEPOINTITERATOR_METHODS_H +#define CODEPOINTITERATOR_METHODS_H + +#include + +PHP_FUNCTION(cpbi_get_last_code_point); + +#endif \ No newline at end of file diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp new file mode 100644 index 0000000000000..454e5249fde96 --- /dev/null +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp @@ -0,0 +1,221 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#include + +extern "C" { +#define USE_BREAKITERATOR_POINTER 1 +#include "breakiterator_class.h" +#include +#include +} + +#include "../intl_convertcpp.h" + +static inline RuleBasedBreakIterator *fetch_rbbi(BreakIterator_object *bio) { + return (RuleBasedBreakIterator*)bio->biter; +} + +static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS) +{ + zval *object = getThis(); + char *rules; + int rules_len; + zend_bool compiled = 0; + UErrorCode status = U_ZERO_ERROR; + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", + &rules, &rules_len, &compiled) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "rbbi_create_instance: bad arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + + // instantiation of ICU object + RuleBasedBreakIterator *rbbi; + + if (!compiled) { + UnicodeString rulesStr; + UParseError parseError = UParseError(); + if (intl_stringFromChar(rulesStr, rules, rules_len, &status) + == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "rbbi_create_instance: rules were not a valid UTF-8 string", + 0 TSRMLS_CC); + RETURN_NULL(); + } + + rbbi = new RuleBasedBreakIterator(rulesStr, parseError, status); + intl_error_set_code(NULL, status TSRMLS_CC); + if (U_FAILURE(status)) { + char *msg; + smart_str parse_error_str; + parse_error_str = intl_parse_error_to_string(&parseError); + spprintf(&msg, 0, "rbbi_create_instance: unable to create " + "RuleBasedBreakIterator from rules (%s)", parse_error_str.c); + smart_str_free(&parse_error_str); + intl_error_set_custom_msg(NULL, msg, 1 TSRMLS_CC); + efree(msg); + delete rbbi; + RETURN_NULL(); + } + } else { // compiled +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 + rbbi = new RuleBasedBreakIterator((uint8_t*)rules, rules_len, status); + if (U_FAILURE(status)) { + intl_error_set(NULL, status, "rbbi_create_instance: unable to " + "create instance from compiled rules", 0 TSRMLS_CC); + delete rbbi; + RETURN_NULL(); + } +#else + intl_error_set(NULL, U_UNSUPPORTED_ERROR, "rbbi_create_instance: " + "compiled rules require ICU >= 4.8", 0 TSRMLS_CC); + RETURN_NULL(); +#endif + } + + breakiterator_object_create(return_value, rbbi TSRMLS_CC); +} + +U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, __construct) +{ + zval orig_this = *getThis(); + + return_value = getThis(); + //changes this to IS_NULL (without first destroying) if there's an error + _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU); + + if (Z_TYPE_P(return_value) == IS_NULL) { + zend_object_store_ctor_failed(&orig_this TSRMLS_CC); + zval_dtor(&orig_this); + } +} + +U_CFUNC PHP_FUNCTION(rbbi_get_rules) +{ + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "rbbi_get_rules: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + const UnicodeString rules = fetch_rbbi(bio)->getRules(); + + Z_TYPE_P(return_value) = IS_STRING; + if (intl_charFromString(rules, &Z_STRVAL_P(return_value), + &Z_STRLEN_P(return_value), BREAKITER_ERROR_CODE_P(bio)) == FAILURE) + { + intl_errors_set(BREAKITER_ERROR_P(bio), BREAKITER_ERROR_CODE(bio), + "rbbi_hash_code: Error converting result to UTF-8 string", + 0 TSRMLS_CC); + RETURN_FALSE; + } +} + +U_CFUNC PHP_FUNCTION(rbbi_get_rule_status) +{ + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "rbbi_get_rule_status: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + RETURN_LONG(fetch_rbbi(bio)->getRuleStatus()); +} + +U_CFUNC PHP_FUNCTION(rbbi_get_rule_status_vec) +{ + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "rbbi_get_rule_status_vec: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + int32_t num_rules = fetch_rbbi(bio)->getRuleStatusVec(NULL, 0, + BREAKITER_ERROR_CODE(bio)); + if (BREAKITER_ERROR_CODE(bio) == U_BUFFER_OVERFLOW_ERROR) { + BREAKITER_ERROR_CODE(bio) = U_ZERO_ERROR; + } else { + // should not happen + INTL_METHOD_CHECK_STATUS(bio, "rbbi_get_rule_status_vec: failed " + " determining the number of status values"); + } + int32_t *rules = new int32_t[num_rules]; + num_rules = fetch_rbbi(bio)->getRuleStatusVec(rules, num_rules, + BREAKITER_ERROR_CODE(bio)); + if (U_FAILURE(BREAKITER_ERROR_CODE(bio))) { + delete[] rules; + intl_errors_set(BREAKITER_ERROR_P(bio), BREAKITER_ERROR_CODE(bio), + "rbbi_get_rule_status_vec: failed obtaining the status values", + 0 TSRMLS_CC); + RETURN_FALSE; + } + + array_init_size(return_value, num_rules); + for (int32_t i = 0; i < num_rules; i++) { + add_next_index_long(return_value, rules[i]); + } + delete[] rules; +} + +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 +U_CFUNC PHP_FUNCTION(rbbi_get_binary_rules) +{ + BREAKITER_METHOD_INIT_VARS; + object = getThis(); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "rbbi_get_binary_rules: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + BREAKITER_METHOD_FETCH_OBJECT; + + uint32_t rules_len; + const uint8_t *rules = fetch_rbbi(bio)->getBinaryRules(rules_len); + + if (rules_len > INT_MAX - 1) { + intl_errors_set(BREAKITER_ERROR_P(bio), BREAKITER_ERROR_CODE(bio), + "rbbi_get_binary_rules: the rules are too large", + 0 TSRMLS_CC); + RETURN_FALSE; + } + + char *ret_rules = static_cast(emalloc(rules_len + 1)); + memcpy(ret_rules, rules, rules_len); + ret_rules[rules_len] = '\0'; + + RETURN_STRINGL(ret_rules, rules_len, 0); +} +#endif diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.h b/ext/intl/breakiterator/rulebasedbreakiterator_methods.h new file mode 100644 index 0000000000000..edea4ea2a6976 --- /dev/null +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.h @@ -0,0 +1,32 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#ifndef RULEBASEDBREAKITERATOR_METHODS_H +#define RULEBASEDBREAKITERATOR_METHODS_H + +#include + +PHP_METHOD(IntlRuleBasedBreakIterator, __construct); + +PHP_FUNCTION(rbbi_get_rules); + +PHP_FUNCTION(rbbi_get_rule_status); + +PHP_FUNCTION(rbbi_get_rule_status_vec); + +PHP_FUNCTION(rbbi_get_binary_rules); + +#endif \ No newline at end of file diff --git a/ext/intl/calendar/calendar_class.cpp b/ext/intl/calendar/calendar_class.cpp new file mode 100644 index 0000000000000..beb65f718f43f --- /dev/null +++ b/ext/intl/calendar/calendar_class.cpp @@ -0,0 +1,550 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "../intl_cppshims.h" + +#include +#include + +extern "C" { +#define USE_TIMEZONE_POINTER 1 +#include "../timezone/timezone_class.h" +#define USE_CALENDAR_POINTER 1 +#include "calendar_class.h" +#include "calendar_methods.h" +#include "gregoriancalendar_methods.h" +#include +#include +} + +/* {{{ Global variables */ +zend_class_entry *Calendar_ce_ptr; +zend_class_entry *GregorianCalendar_ce_ptr; +zend_object_handlers Calendar_handlers; +/* }}} */ + +U_CFUNC void calendar_object_create(zval *object, + Calendar *calendar TSRMLS_DC) +{ + UClassID classId = calendar->getDynamicClassID(); + zend_class_entry *ce; + + //if (dynamic_cast(calendar) != NULL) { + if (classId == GregorianCalendar::getStaticClassID()) { + ce = GregorianCalendar_ce_ptr; + } else { + ce = Calendar_ce_ptr; + } + + object_init_ex(object, ce); + calendar_object_construct(object, calendar TSRMLS_CC); +} + +U_CFUNC Calendar *calendar_fetch_native_calendar(zval *object TSRMLS_DC) +{ + Calendar_object *co = (Calendar_object*) + zend_object_store_get_object(object TSRMLS_CC); + + return co->ucal; +} + +U_CFUNC void calendar_object_construct(zval *object, + Calendar *calendar TSRMLS_DC) +{ + Calendar_object *co; + + CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; //populate to from object + assert(co->ucal == NULL); + co->ucal = (Calendar*)calendar; +} + +/* {{{ clone handler for Calendar */ +static zend_object_value Calendar_clone_obj(zval *object TSRMLS_DC) +{ + Calendar_object *co_orig, + *co_new; + zend_object_value ret_val; + intl_error_reset(NULL TSRMLS_CC); + + co_orig = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC); + intl_error_reset(INTL_DATA_ERROR_P(co_orig) TSRMLS_CC); + + ret_val = Calendar_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC); + co_new = (Calendar_object*)zend_object_store_get_object_by_handle(ret_val.handle TSRMLS_CC); + + zend_objects_clone_members(&co_new->zo, ret_val, + &co_orig->zo, Z_OBJ_HANDLE_P(object) TSRMLS_CC); + + if (co_orig->ucal != NULL) { + Calendar *newCalendar; + + newCalendar = co_orig->ucal->clone(); + if (!newCalendar) { + char *err_msg; + intl_errors_set_code(CALENDAR_ERROR_P(co_orig), + U_MEMORY_ALLOCATION_ERROR TSRMLS_CC); + intl_errors_set_custom_msg(CALENDAR_ERROR_P(co_orig), + "Could not clone IntlCalendar", 0 TSRMLS_CC); + err_msg = intl_error_get_message(CALENDAR_ERROR_P(co_orig) TSRMLS_CC); + zend_throw_exception(NULL, err_msg, 0 TSRMLS_CC); + efree(err_msg); + } else { + co_new->ucal = newCalendar; + } + } else { + zend_throw_exception(NULL, "Cannot clone unconstructed IntlCalendar", 0 TSRMLS_CC); + } + + return ret_val; +} +/* }}} */ + +static const struct { + UCalendarDateFields field; + const char *name; +} debug_info_fields[] = { + {UCAL_ERA, "era"}, + {UCAL_YEAR, "year"}, + {UCAL_MONTH, "month"}, + {UCAL_WEEK_OF_YEAR, "week of year"}, + {UCAL_WEEK_OF_MONTH, "week of month"}, + {UCAL_DAY_OF_YEAR, "day of year"}, + {UCAL_DAY_OF_MONTH, "day of month"}, + {UCAL_DAY_OF_WEEK, "day of week"}, + {UCAL_DAY_OF_WEEK_IN_MONTH, "day of week in month"}, + {UCAL_AM_PM, "AM/PM"}, + {UCAL_HOUR, "hour"}, + {UCAL_HOUR_OF_DAY, "hour of day"}, + {UCAL_MINUTE, "minute"}, + {UCAL_SECOND, "second"}, + {UCAL_MILLISECOND, "millisecond"}, + {UCAL_ZONE_OFFSET, "zone offset"}, + {UCAL_DST_OFFSET, "DST offset"}, + {UCAL_YEAR_WOY, "year for week of year"}, + {UCAL_DOW_LOCAL, "localized day of week"}, + {UCAL_EXTENDED_YEAR, "extended year"}, + {UCAL_JULIAN_DAY, "julian day"}, + {UCAL_MILLISECONDS_IN_DAY, "milliseconds in day"}, + {UCAL_IS_LEAP_MONTH, "is leap month"}, +}; + +/* {{{ get_debug_info handler for Calendar */ +static HashTable *Calendar_get_debug_info(zval *object, int *is_temp TSRMLS_DC) +{ + zval zv = zval_used_for_init, + *zfields; + Calendar_object *co; + const Calendar *cal; + + *is_temp = 1; + + array_init_size(&zv, 8); + + co = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC); + cal = co->ucal; + + if (cal == NULL) { + add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 0); + return Z_ARRVAL(zv); + } + + add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 1); + + add_assoc_string_ex(&zv, "type", sizeof("type"), + const_cast(cal->getType()), 1); + + { + zval ztz = zval_used_for_init, + *ztz_debug; + int is_tmp; + HashTable *debug_info; + + timezone_object_construct(&cal->getTimeZone(), &ztz , 0 TSRMLS_CC); + debug_info = Z_OBJ_HANDLER(ztz, get_debug_info)(&ztz, &is_tmp TSRMLS_CC); + assert(is_tmp == 1); + + ALLOC_INIT_ZVAL(ztz_debug); + Z_TYPE_P(ztz_debug) = IS_ARRAY; + Z_ARRVAL_P(ztz_debug) = debug_info; + add_assoc_zval_ex(&zv, "timeZone", sizeof("timeZone"), ztz_debug); + } + + { + UErrorCode uec = U_ZERO_ERROR; + Locale locale = cal->getLocale(ULOC_VALID_LOCALE, uec); + if (U_SUCCESS(uec)) { + add_assoc_string_ex(&zv, "locale", sizeof("locale"), + const_cast(locale.getName()), 1); + } else { + add_assoc_string_ex(&zv, "locale", sizeof("locale"), + const_cast(u_errorName(uec)), 1); + } + } + + ALLOC_INIT_ZVAL(zfields); + array_init_size(zfields, UCAL_FIELD_COUNT); + + for (int i = 0; + i < sizeof(debug_info_fields) / sizeof(*debug_info_fields); + i++) { + UErrorCode uec = U_ZERO_ERROR; + const char *name = debug_info_fields[i].name; + int32_t res = cal->get(debug_info_fields[i].field, uec); + if (U_SUCCESS(uec)) { + add_assoc_long(zfields, name, (long)res); + } else { + add_assoc_string(zfields, name, const_cast(u_errorName(uec)), 1); + } + } + + add_assoc_zval_ex(&zv, "fields", sizeof("fields"), zfields); + + return Z_ARRVAL(zv); +} +/* }}} */ + +/* {{{ void calendar_object_init(Calendar_object* to) + * Initialize internals of Calendar_object not specific to zend standard objects. + */ +static void calendar_object_init(Calendar_object *co TSRMLS_DC) +{ + intl_error_init(CALENDAR_ERROR_P(co) TSRMLS_CC); + co->ucal = NULL; +} +/* }}} */ + +/* {{{ Calendar_objects_dtor */ +static void Calendar_objects_dtor(void *object, + zend_object_handle handle TSRMLS_DC) +{ + zend_objects_destroy_object((zend_object*)object, handle TSRMLS_CC); +} +/* }}} */ + +/* {{{ Calendar_objects_free */ +static void Calendar_objects_free(zend_object *object TSRMLS_DC) +{ + Calendar_object* co = (Calendar_object*) object; + + if (co->ucal) { + delete co->ucal; + co->ucal = NULL; + } + intl_error_reset(CALENDAR_ERROR_P(co) TSRMLS_CC); + + zend_object_std_dtor(&co->zo TSRMLS_CC); + + efree(co); +} +/* }}} */ + +/* {{{ Calendar_object_create */ +static zend_object_value Calendar_object_create(zend_class_entry *ce TSRMLS_DC) +{ + zend_object_value retval; + Calendar_object* intern; + + intern = (Calendar_object*)ecalloc(1, sizeof(Calendar_object)); + + zend_object_std_init(&intern->zo, ce TSRMLS_CC); +#if PHP_VERSION_ID < 50399 + zend_hash_copy(intern->zo.properties, &(ce->default_properties), + (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*)); +#else + object_properties_init((zend_object*) intern, ce); +#endif + calendar_object_init(intern TSRMLS_CC); + + retval.handle = zend_objects_store_put( + intern, + Calendar_objects_dtor, + (zend_objects_free_object_storage_t) Calendar_objects_free, + NULL TSRMLS_CC); + + retval.handlers = &Calendar_handlers; + + return retval; +} +/* }}} */ + +/* {{{ Calendar methods arguments info */ + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_void, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_field, 0, 0, 1) + ZEND_ARG_INFO(0, field) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_dow, 0, 0, 1) + ZEND_ARG_INFO(0, dayOfWeek) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_other_cal, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_date, 0, 0, 1) + ZEND_ARG_INFO(0, date) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_date_optional, 0, 0, 0) + ZEND_ARG_INFO(0, date) +ZEND_END_ARG_INFO() + + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_createInstance, 0, 0, 0) + ZEND_ARG_INFO(0, timeZone) + ZEND_ARG_INFO(0, locale) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_get_keyword_values_for_locale, 0, 0, 3) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, locale) + ZEND_ARG_INFO(0, commonlyUsed) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_add, 0, 0, 2) + ZEND_ARG_INFO(0, field) + ZEND_ARG_INFO(0, amount) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_setTimeZone, 0, 0, 1) + ZEND_ARG_INFO(0, timeZone) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_set, 0, 0, 2) + ZEND_ARG_INFO(0, fieldOrYear) + ZEND_ARG_INFO(0, valueOrMonth) + ZEND_ARG_INFO(0, dayOfMonth) + ZEND_ARG_INFO(0, hour) + ZEND_ARG_INFO(0, minute) + ZEND_ARG_INFO(0, second) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_roll, 0, 0, 2) + ZEND_ARG_INFO(0, field) + ZEND_ARG_INFO(0, amountOrUpOrDown) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_clear, 0, 0, 0) + ZEND_ARG_INFO(0, field) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_field_difference, 0, 0, 2) + ZEND_ARG_INFO(0, when) + ZEND_ARG_INFO(0, field) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_get_locale, 0, 0, 1) + ZEND_ARG_INFO(0, localeType) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_setLenient, 0, 0, 1) + ZEND_ARG_INFO(0, isLenient) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_from_date_time, 0, 0, 1) + ZEND_ARG_INFO(0, dateTime) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_wall_time_option, 0, 0, 1) + ZEND_ARG_INFO(0, wallTimeOption) +ZEND_END_ARG_INFO() + +/* Gregorian Calendar */ +ZEND_BEGIN_ARG_INFO_EX(ainfo_gregcal___construct, 0, 0, 0) + ZEND_ARG_INFO(0, timeZoneOrYear) + ZEND_ARG_INFO(0, localeOrMonth) + ZEND_ARG_INFO(0, dayOfMonth) + ZEND_ARG_INFO(0, hour) + ZEND_ARG_INFO(0, minute) + ZEND_ARG_INFO(0, second) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_gregcal_isLeapYear, 0, 0, 1) + ZEND_ARG_INFO(0, year) +ZEND_END_ARG_INFO() + +/* }}} */ + +/* {{{ Calendar_class_functions + * Every 'IntlCalendar' class method has an entry in this table + */ +static const zend_function_entry Calendar_class_functions[] = { + PHP_ME(IntlCalendar, __construct, ainfo_cal_void, ZEND_ACC_PRIVATE) + PHP_ME_MAPPING(createInstance, intlcal_create_instance, ainfo_cal_createInstance, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42 + PHP_ME_MAPPING(getKeywordValuesForLocale, intlcal_get_keyword_values_for_locale, ainfo_cal_get_keyword_values_for_locale, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) +#endif + PHP_ME_MAPPING(getNow, intlcal_get_now, ainfo_cal_void, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getAvailableLocales, intlcal_get_available_locales, ainfo_cal_void, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(get, intlcal_get, ainfo_cal_field, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getTime, intlcal_get_time, ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(setTime, intlcal_set_time, ainfo_cal_date, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(add, intlcal_add, ainfo_cal_add, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(setTimeZone, intlcal_set_time_zone, ainfo_cal_setTimeZone, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(after, intlcal_after, ainfo_cal_other_cal, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(before, intlcal_before, ainfo_cal_other_cal, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(set, intlcal_set, ainfo_cal_set, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(roll, intlcal_roll, ainfo_cal_roll, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(clear, intlcal_clear, ainfo_cal_clear, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(fieldDifference, intlcal_field_difference, ainfo_cal_field_difference, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getActualMaximum, intlcal_get_actual_maximum, ainfo_cal_field, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getActualMinimum, intlcal_get_actual_minimum, ainfo_cal_field, ZEND_ACC_PUBLIC) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 + PHP_ME_MAPPING(getDayOfWeekType, intlcal_get_day_of_week_type, ainfo_cal_dow, ZEND_ACC_PUBLIC) +#endif + PHP_ME_MAPPING(getFirstDayOfWeek, intlcal_get_first_day_of_week, ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getGreatestMinimum, intlcal_get_greatest_minimum, ainfo_cal_field, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getLeastMaximum, intlcal_get_least_maximum, ainfo_cal_field, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getLocale, intlcal_get_locale, ainfo_cal_get_locale, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getMaximum, intlcal_get_maximum, ainfo_cal_field, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getMinimalDaysInFirstWeek, intlcal_get_minimal_days_in_first_week, ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getMinimum, intlcal_get_minimum, ainfo_cal_field, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getTimeZone, intlcal_get_time_zone, ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getType, intlcal_get_type, ainfo_cal_void, ZEND_ACC_PUBLIC) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 + PHP_ME_MAPPING(getWeekendTransition,intlcal_get_weekend_transition, ainfo_cal_dow, ZEND_ACC_PUBLIC) +#endif + PHP_ME_MAPPING(inDaylightTime, intlcal_in_daylight_time, ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(isEquivalentTo, intlcal_is_equivalent_to, ainfo_cal_other_cal, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(isLenient, intlcal_is_lenient, ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(isSet, intlcal_is_set, ainfo_cal_field, ZEND_ACC_PUBLIC) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 + PHP_ME_MAPPING(isWeekend, intlcal_is_weekend, ainfo_cal_date_optional, ZEND_ACC_PUBLIC) +#endif + PHP_ME_MAPPING(setFirstDayOfWeek, intlcal_set_first_day_of_week, ainfo_cal_dow, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(setLenient, intlcal_set_lenient, ainfo_cal_setLenient, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(equals, intlcal_equals, ainfo_cal_other_cal, ZEND_ACC_PUBLIC) +#if U_ICU_VERSION_MAJOR_NUM >= 49 + PHP_ME_MAPPING(getRepeatedWallTimeOption,intlcal_get_repeated_wall_time_option,ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getSkippedWallTimeOption,intlcal_get_skipped_wall_time_option,ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(setRepeatedWallTimeOption,intlcal_set_repeated_wall_time_option,ainfo_cal_wall_time_option,ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(setSkippedWallTimeOption,intlcal_set_skipped_wall_time_option,ainfo_cal_wall_time_option,ZEND_ACC_PUBLIC) +#endif + PHP_ME_MAPPING(fromDateTime, intlcal_from_date_time, ainfo_cal_from_date_time, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(toDateTime, intlcal_to_date_time, ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getErrorCode, intlcal_get_error_code, ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getErrorMessage, intlcal_get_error_message, ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_FE_END +}; +/* }}} */ + +/* {{{ GregorianCalendar_class_functions + */ +static const zend_function_entry GregorianCalendar_class_functions[] = { + PHP_ME(IntlGregorianCalendar, __construct, ainfo_gregcal___construct, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(setGregorianChange, intlgregcal_set_gregorian_change, ainfo_cal_date, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getGregorianChange, intlgregcal_get_gregorian_change, ainfo_cal_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(isLeapYear, intlgregcal_is_leap_year, ainfo_gregcal_isLeapYear, ZEND_ACC_PUBLIC) + PHP_FE_END +}; +/* }}} */ + + +/* {{{ calendar_register_IntlCalendar_class + * Initialize 'IntlCalendar' class + */ +void calendar_register_IntlCalendar_class(TSRMLS_D) +{ + zend_class_entry ce; + + /* Create and register 'IntlCalendar' class. */ + INIT_CLASS_ENTRY(ce, "IntlCalendar", Calendar_class_functions); + ce.create_object = Calendar_object_create; + Calendar_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC); + if (!Calendar_ce_ptr) { + //can't happen now without bigger problems before + php_error_docref0(NULL TSRMLS_CC, E_ERROR, + "IntlCalendar: class registration has failed."); + return; + } + memcpy( &Calendar_handlers, zend_get_std_object_handlers(), + sizeof Calendar_handlers); + Calendar_handlers.clone_obj = Calendar_clone_obj; + Calendar_handlers.get_debug_info = Calendar_get_debug_info; + + /* Create and register 'IntlGregorianCalendar' class. */ + INIT_CLASS_ENTRY(ce, "IntlGregorianCalendar", GregorianCalendar_class_functions); + GregorianCalendar_ce_ptr = zend_register_internal_class_ex(&ce, + Calendar_ce_ptr, NULL TSRMLS_CC); + if (!GregorianCalendar_ce_ptr) { + //can't happen know without bigger problems before + php_error_docref0(NULL TSRMLS_CC, E_ERROR, + "IntlGregorianCalendar: class registration has failed."); + return; + } + + /* Declare 'IntlCalendar' class constants */ +#define CALENDAR_DECL_LONG_CONST(name, val) \ + zend_declare_class_constant_long(Calendar_ce_ptr, name, sizeof(name) - 1, \ + val TSRMLS_CC) + + CALENDAR_DECL_LONG_CONST("FIELD_ERA", UCAL_ERA); + CALENDAR_DECL_LONG_CONST("FIELD_YEAR", UCAL_YEAR); + CALENDAR_DECL_LONG_CONST("FIELD_MONTH", UCAL_MONTH); + CALENDAR_DECL_LONG_CONST("FIELD_WEEK_OF_YEAR", UCAL_WEEK_OF_YEAR); + CALENDAR_DECL_LONG_CONST("FIELD_WEEK_OF_MONTH", UCAL_WEEK_OF_MONTH); + CALENDAR_DECL_LONG_CONST("FIELD_DATE", UCAL_DATE); + CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_YEAR", UCAL_DAY_OF_YEAR); + CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_WEEK", UCAL_DAY_OF_WEEK); + CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_WEEK_IN_MONTH", UCAL_DAY_OF_WEEK_IN_MONTH); + CALENDAR_DECL_LONG_CONST("FIELD_AM_PM", UCAL_AM_PM); + CALENDAR_DECL_LONG_CONST("FIELD_HOUR", UCAL_HOUR); + CALENDAR_DECL_LONG_CONST("FIELD_HOUR_OF_DAY", UCAL_HOUR_OF_DAY); + CALENDAR_DECL_LONG_CONST("FIELD_HOUR", UCAL_HOUR); + CALENDAR_DECL_LONG_CONST("FIELD_HOUR_OF_DAY", UCAL_HOUR_OF_DAY); + CALENDAR_DECL_LONG_CONST("FIELD_MINUTE", UCAL_MINUTE); + CALENDAR_DECL_LONG_CONST("FIELD_SECOND", UCAL_SECOND); + CALENDAR_DECL_LONG_CONST("FIELD_MILLISECOND", UCAL_MILLISECOND); + CALENDAR_DECL_LONG_CONST("FIELD_ZONE_OFFSET", UCAL_ZONE_OFFSET); + CALENDAR_DECL_LONG_CONST("FIELD_DST_OFFSET", UCAL_DST_OFFSET); + CALENDAR_DECL_LONG_CONST("FIELD_YEAR_WOY", UCAL_YEAR_WOY); + CALENDAR_DECL_LONG_CONST("FIELD_DOW_LOCAL", UCAL_DOW_LOCAL); + CALENDAR_DECL_LONG_CONST("FIELD_EXTENDED_YEAR", UCAL_EXTENDED_YEAR); + CALENDAR_DECL_LONG_CONST("FIELD_JULIAN_DAY", UCAL_JULIAN_DAY); + CALENDAR_DECL_LONG_CONST("FIELD_MILLISECONDS_IN_DAY", UCAL_MILLISECONDS_IN_DAY); + CALENDAR_DECL_LONG_CONST("FIELD_IS_LEAP_MONTH", UCAL_IS_LEAP_MONTH); + CALENDAR_DECL_LONG_CONST("FIELD_FIELD_COUNT ", UCAL_FIELD_COUNT); + CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_MONTH", UCAL_DAY_OF_MONTH); + + CALENDAR_DECL_LONG_CONST("DOW_SUNDAY", UCAL_SUNDAY); + CALENDAR_DECL_LONG_CONST("DOW_MONDAY", UCAL_MONDAY); + CALENDAR_DECL_LONG_CONST("DOW_TUESDAY", UCAL_TUESDAY); + CALENDAR_DECL_LONG_CONST("DOW_WEDNESDAY", UCAL_WEDNESDAY); + CALENDAR_DECL_LONG_CONST("DOW_THURSDAY", UCAL_THURSDAY); + CALENDAR_DECL_LONG_CONST("DOW_FRIDAY", UCAL_FRIDAY); + CALENDAR_DECL_LONG_CONST("DOW_SATURDAY", UCAL_SATURDAY); + +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 + CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKDAY", UCAL_WEEKDAY); + CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND", UCAL_WEEKEND); + CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND_OFFSET", UCAL_WEEKEND_ONSET); + CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND_CEASE", UCAL_WEEKEND_CEASE); +#endif + +#if U_ICU_VERSION_MAJOR_NUM >= 49 + CALENDAR_DECL_LONG_CONST("WALLTIME_FIRST", UCAL_WALLTIME_FIRST); + CALENDAR_DECL_LONG_CONST("WALLTIME_LAST", UCAL_WALLTIME_LAST); + CALENDAR_DECL_LONG_CONST("WALLTIME_NEXT_VALID", UCAL_WALLTIME_NEXT_VALID); +#endif +} +/* }}} */ diff --git a/ext/intl/calendar/calendar_class.h b/ext/intl/calendar/calendar_class.h new file mode 100644 index 0000000000000..140389b639378 --- /dev/null +++ b/ext/intl/calendar/calendar_class.h @@ -0,0 +1,70 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#ifndef CALENDAR_CLASS_H +#define CALENDAR_CLASS_H + +//redefinition of inline in PHP headers causes problems, so include this before +#include + +#include +#include "intl_error.h" +#include "intl_data.h" + +#ifndef USE_CALENDAR_POINTER +typedef void Calendar; +#endif + +typedef struct { + zend_object zo; + + // error handling + intl_error err; + + // ICU calendar + Calendar* ucal; +} Calendar_object; + +#define CALENDAR_ERROR(co) (co)->err +#define CALENDAR_ERROR_P(co) &(CALENDAR_ERROR(co)) + +#define CALENDAR_ERROR_CODE(co) INTL_ERROR_CODE(CALENDAR_ERROR(co)) +#define CALENDAR_ERROR_CODE_P(co) &(INTL_ERROR_CODE(CALENDAR_ERROR(co))) + +#define CALENDAR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(Calendar, co) +#define CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(Calendar, co) +#define CALENDAR_METHOD_FETCH_OBJECT \ + CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; \ + if (co->ucal == NULL) \ + { \ + intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlCalendar", 0 TSRMLS_CC); \ + RETURN_FALSE; \ + } + +void calendar_object_create(zval *object, Calendar *calendar TSRMLS_DC); + +Calendar *calendar_fetch_native_calendar(zval *object TSRMLS_DC); + +void calendar_object_construct(zval *object, Calendar *calendar TSRMLS_DC); + +void calendar_register_IntlCalendar_class(TSRMLS_D); + +extern zend_class_entry *Calendar_ce_ptr, + *GregorianCalendar_ce_ptr; + +extern zend_object_handlers Calendar_handlers; + +#endif /* #ifndef CALENDAR_CLASS_H */ diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp new file mode 100644 index 0000000000000..2d33bd1952f2f --- /dev/null +++ b/ext/intl/calendar/calendar_methods.cpp @@ -0,0 +1,1328 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "../intl_cppshims.h" + +#include +#include +#include + +#include "../intl_convertcpp.h" +#include "../common/common_date.h" + +extern "C" { +#include "../php_intl.h" +#define USE_TIMEZONE_POINTER 1 +#include "../timezone/timezone_class.h" +#define USE_CALENDAR_POINTER 1 +#include "calendar_class.h" +#include "../intl_convert.h" +#include +#include +#include +} +#include "../common/common_enum.h" + +U_CFUNC PHP_METHOD(IntlCalendar, __construct) +{ + zend_throw_exception( NULL, + "An object of this type cannot be created with the new operator", + 0 TSRMLS_CC ); +} + +U_CFUNC PHP_FUNCTION(intlcal_create_instance) +{ + zval **zv_timezone = NULL; + const char *locale_str = NULL; + int dummy; + TimeZone *timeZone; + UErrorCode status = U_ZERO_ERROR; + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Zs!", + &zv_timezone, &locale_str, &dummy) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_create_calendar: bad arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + + timeZone = timezone_process_timezone_argument(zv_timezone, NULL, + "intlcal_create_instance" TSRMLS_CC); + if (timeZone == NULL) { + RETURN_NULL(); + } + + if (!locale_str) { + locale_str = intl_locale_get_default(TSRMLS_C); + } + + Calendar *cal = Calendar::createInstance(timeZone, + Locale::createFromName(locale_str), status); + if (cal == NULL) { + delete timeZone; + intl_error_set(NULL, status, "Error creating ICU Calendar object", 0 TSRMLS_CC); + RETURN_NULL(); + } + + calendar_object_create(return_value, cal TSRMLS_CC); +} + +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42 +class BugStringCharEnumeration : public StringEnumeration +{ +public: + BugStringCharEnumeration(UEnumeration* _uenum) : uenum(_uenum) {} + + ~BugStringCharEnumeration() + { + uenum_close(uenum); + } + + int32_t count(UErrorCode& status) const { + return uenum_count(uenum, &status); + } + + virtual const UnicodeString* snext(UErrorCode& status) + { + int32_t length; + const UChar* str = uenum_unext(uenum, &length, &status); + if (str == 0 || U_FAILURE(status)) { + return 0; + } + return &unistr.setTo(str, length); + } + + virtual const char* next(int32_t *resultLength, UErrorCode &status) + { + int32_t length = -1; + const char* str = uenum_next(uenum, &length, &status); + if (str == 0 || U_FAILURE(status)) { + return 0; + } + if (resultLength) { + //the bug is that uenum_next doesn't set the length + *resultLength = (length == -1) ? strlen(str) : length; + } + + return str; + } + + void reset(UErrorCode& status) + { + uenum_reset(uenum, &status); + } + + virtual UClassID getDynamicClassID() const; + + static UClassID U_EXPORT2 getStaticClassID(); + +private: + UEnumeration *uenum; +}; +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(BugStringCharEnumeration) + +U_CFUNC PHP_FUNCTION(intlcal_get_keyword_values_for_locale) +{ + UErrorCode status = U_ZERO_ERROR; + char *key, + *locale; + int key_len, + locale_len; + zend_bool commonly_used; + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssb", + &key, &key_len, &locale, &locale_len, &commonly_used) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_keyword_values_for_locale: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + //does not work; see ICU bug 9194 +#if 0 + StringEnumeration *se = Calendar::getKeywordValuesForLocale(key, + Locale::createFromName(locale), (UBool)commonly_used, + status); + if (se == NULL) { + intl_error_set(NULL, status, "intlcal_get_keyword_values_for_locale: " + "error calling underlying method", 0 TSRMLS_CC); + RETURN_FALSE; + } +#else + UEnumeration *uenum = ucal_getKeywordValuesForLocale( + key, locale, !!commonly_used, &status); + if (U_FAILURE(status)) { + uenum_close(uenum); + intl_error_set(NULL, status, "intlcal_get_keyword_values_for_locale: " + "error calling underlying method", 0 TSRMLS_CC); + RETURN_FALSE; + } + + StringEnumeration *se = new BugStringCharEnumeration(uenum); +#endif + + IntlIterator_from_StringEnumeration(se, return_value TSRMLS_CC); +} +#endif //ICU 4.2 only + +U_CFUNC PHP_FUNCTION(intlcal_get_now) +{ + UErrorCode status = U_ZERO_ERROR; + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_now: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + RETURN_DOUBLE((double)Calendar::getNow()); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_available_locales) +{ + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_available_locales: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + int32_t count; + const Locale *availLocales = Calendar::getAvailableLocales(count); + array_init(return_value); + for (int i = 0; i < count; i++) { + Locale locale = availLocales[i]; + add_next_index_string(return_value, locale.getName(), 1); + } +} + +static void _php_intlcal_field_uec_ret_in32t_method( + int32_t (Calendar::*func)(UCalendarDateFields, UErrorCode&) const, + const char *method_name, + INTERNAL_FUNCTION_PARAMETERS) +{ + long field; + char *message; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Ol", &object, Calendar_ce_ptr, &field) == FAILURE) { + spprintf(&message, 0, "%s: bad arguments", method_name); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); + efree(message); + RETURN_FALSE; + } + + if (field < 0 || field >= UCAL_FIELD_COUNT) { + spprintf(&message, 0, "%s: invalid field", method_name); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); + efree(message); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + int32_t result = (co->ucal->*func)( + (UCalendarDateFields)field, CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed"); + + RETURN_LONG((long)result); +} + +U_CFUNC PHP_FUNCTION(intlcal_get) +{ + _php_intlcal_field_uec_ret_in32t_method(&Calendar::get, + "intlcal_get", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_time) +{ + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_time: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + UDate result = co->ucal->getTime(CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, + "intlcal_get_time: error calling ICU Calendar::getTime"); + + RETURN_DOUBLE((double)result); +} + +U_CFUNC PHP_FUNCTION(intlcal_set_time) +{ + double time_arg; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", + &object, Calendar_ce_ptr, &time_arg) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set_time: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + co->ucal->setTime((UDate)time_arg, CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, "Call to underlying method failed"); + + RETURN_TRUE; +} + +U_CFUNC PHP_FUNCTION(intlcal_add) +{ + long field, + amount; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Oll", &object, Calendar_ce_ptr, &field, &amount) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_add: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (field < 0 || field >= UCAL_FIELD_COUNT) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_add: invalid field", 0 TSRMLS_CC); + RETURN_FALSE; + } + if (amount < INT32_MIN || amount > INT32_MAX) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_add: amount out of bounds", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + co->ucal->add((UCalendarDateFields)field, (int32_t)amount, CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, "intlcal_add: Call to underlying method failed"); + + RETURN_TRUE; +} + +U_CFUNC PHP_FUNCTION(intlcal_set_time_zone) +{ + zval *zv_timezone; + TimeZone *timeZone; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Oz!", &object, Calendar_ce_ptr, &zv_timezone) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set_time_zone: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + if (zv_timezone == NULL) { + RETURN_TRUE; /* the method does nothing if passed null */ + } + + timeZone = timezone_process_timezone_argument(&zv_timezone, + CALENDAR_ERROR_P(co), "intlcal_set_time_zone" TSRMLS_CC); + if (timeZone == NULL) { + RETURN_FALSE; + } + + co->ucal->adoptTimeZone(timeZone); + + RETURN_TRUE; +} + + +static void _php_intlcal_before_after( + UBool (Calendar::*func)(const Calendar&, UErrorCode&) const, + INTERNAL_FUNCTION_PARAMETERS) +{ + zval *when_object; + Calendar_object *when_co; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "OO", &object, Calendar_ce_ptr, &when_object, Calendar_ce_ptr) + == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_before/after: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + when_co = static_cast( + zend_object_store_get_object(when_object TSRMLS_CC)); + if (when_co->ucal == NULL) { + intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_before/after: Other IntlCalendar was unconstructed", 0 TSRMLS_CC); + RETURN_FALSE; + } + + UBool res = (co->ucal->*func)(*when_co->ucal, CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, "intlcal_before/after: Error calling ICU method"); + + RETURN_BOOL((int)res); +} + +U_CFUNC PHP_FUNCTION(intlcal_after) +{ + _php_intlcal_before_after(&Calendar::after, INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(intlcal_before) +{ + _php_intlcal_before_after(&Calendar::before, INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(intlcal_set) +{ + long arg1, arg2, arg3, arg4, arg5, arg6; + zval **args_a[7] = {0}, + ***args = &args_a[0]; + int i; + int variant; /* number of args of the set() overload */ + CALENDAR_METHOD_INIT_VARS; + + /* must come before zpp because zpp would convert the args in the stack to 0 */ + if (ZEND_NUM_ARGS() > (getThis() ? 6 : 7) || + zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set: too many arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + if (!getThis()) { + args++; + } + variant = ZEND_NUM_ARGS() - (getThis() ? 0 : 1); + while (variant > 2 && Z_TYPE_PP(args[variant - 1]) == IS_NULL) { + variant--; + } + + if (variant == 4 || + zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Oll|llll", &object, Calendar_ce_ptr, &arg1, &arg2, &arg3, &arg4, + &arg5, &arg6) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + for (i = 0; i < variant; i++) { + if (Z_LVAL_PP(args[i]) < INT32_MIN || Z_LVAL_PP(args[i]) > INT32_MAX) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set: at least one of the arguments has an absolute " + "value that is too large", 0 TSRMLS_CC); + RETURN_FALSE; + } + } + + if (variant == 2 && (arg1 < 0 || arg1 >= UCAL_FIELD_COUNT)) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set: invalid field", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + if (variant == 2) { + co->ucal->set((UCalendarDateFields)arg1, (int32_t)arg2); + } else if (variant == 3) { + co->ucal->set((int32_t)arg1, (int32_t)arg2, (int32_t)arg3); + } else if (variant == 5) { + co->ucal->set((int32_t)arg1, (int32_t)arg2, (int32_t)arg3, (int32_t)arg4, (int32_t)arg5); + } else if (variant == 6) { + co->ucal->set((int32_t)arg1, (int32_t)arg2, (int32_t)arg3, (int32_t)arg4, (int32_t)arg5, (int32_t)arg6); + } + + RETURN_TRUE; +} + +U_CFUNC PHP_FUNCTION(intlcal_roll) +{ + long field, + value; + zval **args_a[3] = {0}, + ***args = &args_a[0]; + zend_bool bool_variant_val = (zend_bool)-1; + CALENDAR_METHOD_INIT_VARS; + + if (ZEND_NUM_ARGS() > (getThis() ? 2 :3) || + zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set: too many arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + if (!getThis()) { + args++; + } + if (args[1] != NULL && Z_TYPE_PP(args[1]) == IS_BOOL) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Olb", &object, Calendar_ce_ptr, &field, &bool_variant_val) + == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_roll: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + bool_variant_val = Z_BVAL_PP(args[1]); + } else if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Oll", &object, Calendar_ce_ptr, &field, &value) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_roll: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (field < 0 || field >= UCAL_FIELD_COUNT) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_roll: invalid field", 0 TSRMLS_CC); + RETURN_FALSE; + } + if (bool_variant_val == (zend_bool)-1 && + (value < INT32_MIN || value > INT32_MAX)) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_roll: value out of bounds", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + if (bool_variant_val != (zend_bool)-1) { + co->ucal->roll((UCalendarDateFields)field, (UBool)bool_variant_val, + CALENDAR_ERROR_CODE(co)); + } else { + co->ucal->roll((UCalendarDateFields)field, (int32_t)value, + CALENDAR_ERROR_CODE(co)); + } + INTL_METHOD_CHECK_STATUS(co, "intlcal_roll: Error calling ICU Calendar::roll"); + + RETURN_TRUE; +} + +U_CFUNC PHP_FUNCTION(intlcal_clear) +{ + zval **args_a[2] = {0}, + ***args = &args_a[0]; + long field; + int variant; + CALENDAR_METHOD_INIT_VARS; + + if (ZEND_NUM_ARGS() > (getThis() ? 1 : 2) || + zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_clear: too many arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + if (!getThis()) { + args++; + } + if (args[0] == NULL || Z_TYPE_PP(args[0]) == IS_NULL) { + zval *dummy; /* we know it's null */ + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, + getThis(), "O|z", &object, Calendar_ce_ptr, &dummy) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_clear: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + variant = 0; + } else if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, + getThis(), "Ol", &object, Calendar_ce_ptr, &field) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_clear: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } else if (field < 0 || field >= UCAL_FIELD_COUNT) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_clear: invalid field", 0 TSRMLS_CC); + RETURN_FALSE; + } else { + variant = 1; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + if (variant == 0) { + co->ucal->clear(); + } else { + co->ucal->clear((UCalendarDateFields)field); + } + + RETURN_TRUE; +} + +U_CFUNC PHP_FUNCTION(intlcal_field_difference) +{ + long field; + double when; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Odl", &object, Calendar_ce_ptr, &when, &field) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_field_difference: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (field < 0 || field >= UCAL_FIELD_COUNT) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_field_difference: invalid field", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + int32_t result = co->ucal->fieldDifference((UDate)when, + (UCalendarDateFields)field, CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, + "intlcal_field_difference: Call to ICU method has failed"); + + RETURN_LONG((long)result); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_actual_maximum) +{ + _php_intlcal_field_uec_ret_in32t_method(&Calendar::getActualMaximum, + "intlcal_get_actual_maximum", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_actual_minimum) +{ + _php_intlcal_field_uec_ret_in32t_method(&Calendar::getActualMinimum, + "intlcal_get_actual_minimum", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 +U_CFUNC PHP_FUNCTION(intlcal_get_day_of_week_type) +{ + long dow; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Ol", &object, Calendar_ce_ptr, &dow) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_day_of_week_type: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (dow < UCAL_SUNDAY || dow > UCAL_SATURDAY) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_day_of_week_type: invalid day of week", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + int32_t result = co->ucal->getDayOfWeekType( + (UCalendarDaysOfWeek)dow, CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, + "intlcal_get_day_of_week_type: Call to ICU method has failed"); + + RETURN_LONG((long)result); +} +#endif + +U_CFUNC PHP_FUNCTION(intlcal_get_first_day_of_week) +{ + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_first_day_of_week: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + int32_t result = co->ucal->getFirstDayOfWeek(CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, + "intlcal_get_first_day_of_week: Call to ICU method has failed"); + + RETURN_LONG((long)result); +} + +static void _php_intlcal_field_ret_in32t_method( + int32_t (Calendar::*func)(UCalendarDateFields) const, + const char *method_name, + INTERNAL_FUNCTION_PARAMETERS) +{ + long field; + char *message; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Ol", &object, Calendar_ce_ptr, &field) == FAILURE) { + spprintf(&message, 0, "%s: bad arguments", method_name); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); + efree(message); + RETURN_FALSE; + } + + if (field < 0 || field >= UCAL_FIELD_COUNT) { + spprintf(&message, 0, "%s: invalid field", method_name); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); + efree(message); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + int32_t result = (co->ucal->*func)((UCalendarDateFields)field); + INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed"); + + RETURN_LONG((long)result); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_greatest_minimum) +{ + _php_intlcal_field_ret_in32t_method(&Calendar::getGreatestMinimum, + "intlcal_get_greatest_minimum", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_least_maximum) +{ + _php_intlcal_field_ret_in32t_method(&Calendar::getLeastMaximum, + "intlcal_get_least_maximum", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_locale) +{ + long locale_type; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Ol", &object, Calendar_ce_ptr, &locale_type) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_locale: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (locale_type != ULOC_ACTUAL_LOCALE && locale_type != ULOC_VALID_LOCALE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_locale: invalid locale type", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + Locale locale = co->ucal->getLocale((ULocDataLocaleType)locale_type, + CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, + "intlcal_get_locale: Call to ICU method has failed"); + + RETURN_STRING(locale.getName(), 1); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_maximum) +{ + _php_intlcal_field_ret_in32t_method(&Calendar::getMaximum, + "intlcal_get_maximum", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_minimal_days_in_first_week) +{ + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_minimal_days_in_first_week: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + uint8_t result = co->ucal->getMinimalDaysInFirstWeek(); + INTL_METHOD_CHECK_STATUS(co, + "intlcal_get_first_day_of_week: Call to ICU method has failed"); + + RETURN_LONG((long)result); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_minimum) +{ + _php_intlcal_field_ret_in32t_method(&Calendar::getMinimum, + "intlcal_get_minimum", INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_time_zone) +{ + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_time_zone: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + TimeZone *tz = co->ucal->getTimeZone().clone(); + if (tz == NULL) { + intl_errors_set(CALENDAR_ERROR_P(co), U_MEMORY_ALLOCATION_ERROR, + "intlcal_get_time_zone: could not clone TimeZone", 0 TSRMLS_CC); + RETURN_FALSE; + } + + timezone_object_construct(tz, return_value, 1 TSRMLS_CC); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_type) +{ + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_type: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + RETURN_STRING(co->ucal->getType(), 1); +} + +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 +U_CFUNC PHP_FUNCTION(intlcal_get_weekend_transition) +{ + long dow; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Ol", &object, Calendar_ce_ptr, &dow) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_weekend_transition: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (dow < UCAL_SUNDAY || dow > UCAL_SATURDAY) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_weekend_transition: invalid day of week", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + int32_t res = co->ucal->getWeekendTransition((UCalendarDaysOfWeek)dow, + CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, "intlcal_get_weekend_transition: " + "Error calling ICU method"); + + RETURN_LONG((long)res); +} +#endif + +U_CFUNC PHP_FUNCTION(intlcal_in_daylight_time) +{ + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_in_daylight_time: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + UBool ret = co->ucal->inDaylightTime(CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, "intlcal_in_daylight_time: " + "Error calling ICU method"); + + RETURN_BOOL((int)ret); +} + +U_CFUNC PHP_FUNCTION(intlcal_is_equivalent_to) +{ + zval *other_object; + Calendar_object *other_co; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "OO", &object, Calendar_ce_ptr, &other_object, Calendar_ce_ptr) + == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_is_equivalent_to: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + other_co = (Calendar_object*)zend_object_store_get_object(other_object TSRMLS_CC); + if (other_co->ucal == NULL) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_is_equivalent_to:" + " Other IntlCalendar is unconstructed", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + RETURN_BOOL((int)co->ucal->isEquivalentTo(*other_co->ucal)); +} + +U_CFUNC PHP_FUNCTION(intlcal_is_lenient) +{ + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_is_lenient: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + RETURN_BOOL((int)co->ucal->isLenient()); +} + +U_CFUNC PHP_FUNCTION(intlcal_is_set) +{ + long field; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Ol", &object, Calendar_ce_ptr, &field) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_is_set: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (field < 0 || field >= UCAL_FIELD_COUNT) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_is_set: invalid field", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + RETURN_BOOL((int)co->ucal->isSet((UCalendarDateFields)field)); +} + +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 +U_CFUNC PHP_FUNCTION(intlcal_is_weekend) +{ + double date; + zval *rawDate = NULL; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters_ex(ZEND_PARSE_PARAMS_QUIET, + ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O|z!", &object, Calendar_ce_ptr, &rawDate) == FAILURE + || (rawDate != NULL && + zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O|d", &object, Calendar_ce_ptr, &date) == FAILURE)) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_is_weekend: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + if (rawDate == NULL) { + RETURN_BOOL((int)co->ucal->isWeekend()); + } else { + UBool ret = co->ucal->isWeekend((UDate)date, CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, "intlcal_is_weekend: " + "Error calling ICU method"); + RETURN_BOOL((int)ret); + } +} +#endif + + +U_CFUNC PHP_FUNCTION(intlcal_set_first_day_of_week) +{ + long dow; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Ol", &object, Calendar_ce_ptr, &dow) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set_first_day_of_week: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (dow < UCAL_SUNDAY || dow > UCAL_SATURDAY) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set_first_day_of_week: invalid day of week", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + co->ucal->setFirstDayOfWeek((UCalendarDaysOfWeek)dow); + + RETURN_TRUE; +} + +U_CFUNC PHP_FUNCTION(intlcal_set_lenient) +{ + zend_bool is_lenient; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Ob", &object, Calendar_ce_ptr, &is_lenient) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set_lenient: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + co->ucal->setLenient((UBool) is_lenient); + + RETURN_TRUE; +} + +U_CFUNC PHP_FUNCTION(intlcal_equals) +{ + zval *other_object; + Calendar_object *other_co; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "OO", &object, Calendar_ce_ptr, &other_object, Calendar_ce_ptr) + == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_equals: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + other_co = (Calendar_object *) zend_object_store_get_object(other_object TSRMLS_CC); + if (other_co->ucal == NULL) { + intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_equals: The second IntlCalendar is unconstructed", 0 TSRMLS_CC); + RETURN_FALSE; + } + + UBool result = co->ucal->equals(*other_co->ucal, CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, "intlcal_equals: error calling ICU Calendar::equals"); + + RETURN_BOOL((int)result); +} + +#if U_ICU_VERSION_MAJOR_NUM >= 49 + +U_CFUNC PHP_FUNCTION(intlcal_get_repeated_wall_time_option) +{ + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_repeated_wall_time_option: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + RETURN_LONG(co->ucal->getRepeatedWallTimeOption()); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_skipped_wall_time_option) +{ + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_skipped_wall_time_option: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + RETURN_LONG(co->ucal->getSkippedWallTimeOption()); +} + +U_CFUNC PHP_FUNCTION(intlcal_set_repeated_wall_time_option) +{ + long option; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Ol", &object, Calendar_ce_ptr, &option) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set_repeated_wall_time_option: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (option != UCAL_WALLTIME_FIRST && option != UCAL_WALLTIME_LAST) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set_repeated_wall_time_option: invalid option", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + co->ucal->setRepeatedWallTimeOption((UCalendarWallTimeOption)option); + + RETURN_TRUE; +} + +U_CFUNC PHP_FUNCTION(intlcal_set_skipped_wall_time_option) +{ + long option; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Ol", &object, Calendar_ce_ptr, &option) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set_skipped_wall_time_option: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (option != UCAL_WALLTIME_FIRST && option != UCAL_WALLTIME_LAST + && option != UCAL_WALLTIME_NEXT_VALID) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_set_skipped_wall_time_option: invalid option", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + co->ucal->setSkippedWallTimeOption((UCalendarWallTimeOption)option); + + RETURN_TRUE; +} + +#endif + +U_CFUNC PHP_FUNCTION(intlcal_from_date_time) +{ + zval **zv_arg, + *zv_datetime = NULL, + *zv_timestamp = NULL; + php_date_obj *datetime; + char *locale_str = NULL; + int locale_str_len; + TimeZone *timeZone; + UErrorCode status = U_ZERO_ERROR; + Calendar *cal; + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|s!", + &zv_arg, &locale_str, &locale_str_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_from_date_time: bad arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + + if (!(Z_TYPE_PP(zv_arg) == IS_OBJECT && instanceof_function( + Z_OBJCE_PP(zv_arg), php_date_get_date_ce() TSRMLS_CC))) { + ALLOC_INIT_ZVAL(zv_datetime); + object_init_ex(zv_datetime, php_date_get_date_ce()); + zend_call_method_with_1_params(&zv_datetime, NULL, NULL, "__construct", + NULL, *zv_arg); + if (EG(exception)) { + zend_object_store_ctor_failed(zv_datetime TSRMLS_CC); + goto error; + } + } else { + zv_datetime = *zv_arg; + } + + datetime = (php_date_obj*)zend_object_store_get_object(zv_datetime TSRMLS_CC); + if (!datetime->time) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_from_date_time: DateTime object is unconstructed", + 0 TSRMLS_CC); + goto error; + } + + zend_call_method_with_0_params(&zv_datetime, php_date_get_date_ce(), + NULL, "gettimestamp", &zv_timestamp); + if (!zv_timestamp || Z_TYPE_P(zv_timestamp) != IS_LONG) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_from_date_time: bad DateTime; call to " + "DateTime::getTimestamp() failed", 0 TSRMLS_CC); + goto error; + } + + if (!datetime->time->is_localtime) { + timeZone = TimeZone::getGMT()->clone(); + } else { + timeZone = timezone_convert_datetimezone(datetime->time->zone_type, + datetime, 1, NULL, "intlcal_from_date_time" TSRMLS_CC); + if (timeZone == NULL) { + goto error; + } + } + + if (!locale_str) { + locale_str = const_cast(intl_locale_get_default(TSRMLS_C)); + } + + cal = Calendar::createInstance(timeZone, + Locale::createFromName(locale_str), status); + if (cal == NULL) { + delete timeZone; + intl_error_set(NULL, status, "intlcal_from_date_time: " + "error creating ICU Calendar object", 0 TSRMLS_CC); + goto error; + } + cal->setTime(((UDate)Z_LVAL_P(zv_timestamp)) * 1000., status); + if (U_FAILURE(status)) { + /* time zone was adopted by cal; should not be deleted here */ + delete cal; + intl_error_set(NULL, status, "intlcal_from_date_time: " + "error creating ICU Calendar::setTime()", 0 TSRMLS_CC); + goto error; + } + + calendar_object_create(return_value, cal TSRMLS_CC); + +error: + if (zv_datetime != *zv_arg) { + zval_ptr_dtor(&zv_datetime); + } + if (zv_timestamp) { + zval_ptr_dtor(&zv_timestamp); + } +} + +U_CFUNC PHP_FUNCTION(intlcal_to_date_time) +{ + zval *retval = NULL; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_to_date_time: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + /* There are no exported functions in ext/date to this + * in a more native fashion */ + double date = co->ucal->getTime(CALENDAR_ERROR_CODE(co)) / 1000.; + int64_t ts; + char ts_str[sizeof("@-9223372036854775808")]; + int ts_str_len; + zval ts_zval = zval_used_for_init; + + INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed"); + + if (date > (double)U_INT64_MAX || date < (double)U_INT64_MIN) { + intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_to_date_time: The calendar date is out of the " + "range for a 64-bit integer", 0 TSRMLS_CC); + RETURN_FALSE; + } + + ts = (int64_t)date; + + ts_str_len = slprintf(ts_str, sizeof(ts_str), "@%I64d", ts); + ZVAL_STRINGL(&ts_zval, ts_str, ts_str_len, 0); + + /* Now get the time zone */ + const TimeZone& tz = co->ucal->getTimeZone(); + zval *timezone_zval = timezone_convert_to_datetimezone( + &tz, CALENDAR_ERROR_P(co), "intlcal_to_date_time" TSRMLS_CC); + if (timezone_zval == NULL) { + RETURN_FALSE; + } + + /* resources allocated from now on */ + + /* Finally, instantiate object and call constructor */ + object_init_ex(return_value, php_date_get_date_ce()); + zend_call_method_with_2_params(&return_value, NULL, NULL, "__construct", + NULL, &ts_zval, timezone_zval); + if (EG(exception)) { + intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_to_date_time: DateTime constructor has thrown exception", + 1 TSRMLS_CC); + zend_object_store_ctor_failed(return_value TSRMLS_CC); + zval_ptr_dtor(&return_value); + + RETVAL_FALSE; + goto error; + } + + /* due to bug #40743, we have to set the time zone again */ + zend_call_method_with_1_params(&return_value, NULL, NULL, "settimezone", + &retval, timezone_zval); + if (retval == NULL || Z_TYPE_P(retval) == IS_BOOL) { + intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_to_date_time: call to DateTime::setTimeZone has failed", + 1 TSRMLS_CC); + zval_ptr_dtor(&return_value); + RETVAL_FALSE; + goto error; + } + +error: + zval_ptr_dtor(&timezone_zval); + if (retval != NULL) { + zval_ptr_dtor(&retval); + } +} + +U_CFUNC PHP_FUNCTION(intlcal_get_error_code) +{ + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_error_code: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + /* Fetch the object (without resetting its last error code ). */ + co = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC); + if (co == NULL) + RETURN_FALSE; + + RETURN_LONG((long)CALENDAR_ERROR_CODE(co)); +} + +U_CFUNC PHP_FUNCTION(intlcal_get_error_message) +{ + const char* message = NULL; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, Calendar_ce_ptr) == FAILURE) { + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlcal_get_error_message: bad arguments", 0 TSRMLS_CC ); + RETURN_FALSE; + } + + + /* Fetch the object (without resetting its last error code ). */ + co = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC); + if (co == NULL) + RETURN_FALSE; + + /* Return last error message. */ + message = intl_error_get_message(CALENDAR_ERROR_P(co) TSRMLS_CC); + RETURN_STRING(message, 0); +} diff --git a/ext/intl/calendar/calendar_methods.h b/ext/intl/calendar/calendar_methods.h new file mode 100644 index 0000000000000..2be13e4920224 --- /dev/null +++ b/ext/intl/calendar/calendar_methods.h @@ -0,0 +1,112 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#ifndef CALENDAR_METHODS_H +#define CALENDAR_METHODS_H + +#include + +PHP_METHOD(IntlCalendar, __construct); + +PHP_FUNCTION(intlcal_create_instance); + +PHP_FUNCTION(intlcal_get_keyword_values_for_locale); + +PHP_FUNCTION(intlcal_get_now); + +PHP_FUNCTION(intlcal_get_available_locales); + +PHP_FUNCTION(intlcal_get); + +PHP_FUNCTION(intlcal_get_time); + +PHP_FUNCTION(intlcal_set_time); + +PHP_FUNCTION(intlcal_add); + +PHP_FUNCTION(intlcal_set_time_zone); + +PHP_FUNCTION(intlcal_after); + +PHP_FUNCTION(intlcal_before); + +PHP_FUNCTION(intlcal_set); + +PHP_FUNCTION(intlcal_roll); + +PHP_FUNCTION(intlcal_clear); + +PHP_FUNCTION(intlcal_field_difference); + +PHP_FUNCTION(intlcal_get_actual_maximum); + +PHP_FUNCTION(intlcal_get_actual_minimum); + +PHP_FUNCTION(intlcal_get_day_of_week_type); + +PHP_FUNCTION(intlcal_get_first_day_of_week); + +PHP_FUNCTION(intlcal_get_greatest_minimum); + +PHP_FUNCTION(intlcal_get_least_maximum); + +PHP_FUNCTION(intlcal_get_locale); + +PHP_FUNCTION(intlcal_get_maximum); + +PHP_FUNCTION(intlcal_get_minimal_days_in_first_week); + +PHP_FUNCTION(intlcal_get_minimum); + +PHP_FUNCTION(intlcal_get_time_zone); + +PHP_FUNCTION(intlcal_get_type); + +PHP_FUNCTION(intlcal_get_weekend_transition); + +PHP_FUNCTION(intlcal_in_daylight_time); + +PHP_FUNCTION(intlcal_is_equivalent_to); + +PHP_FUNCTION(intlcal_is_lenient); + +PHP_FUNCTION(intlcal_is_set); + +PHP_FUNCTION(intlcal_is_weekend); + +PHP_FUNCTION(intlcal_set_first_day_of_week); + +PHP_FUNCTION(intlcal_set_lenient); + +PHP_FUNCTION(intlcal_equals); + +PHP_FUNCTION(intlcal_get_repeated_wall_time_option); + +PHP_FUNCTION(intlcal_get_skipped_wall_time_option); + +PHP_FUNCTION(intlcal_set_repeated_wall_time_option); + +PHP_FUNCTION(intlcal_set_skipped_wall_time_option); + +PHP_FUNCTION(intlcal_from_date_time); + +PHP_FUNCTION(intlcal_to_date_time); + +PHP_FUNCTION(intlcal_get_error_code); + +PHP_FUNCTION(intlcal_get_error_message); + +#endif /* #ifndef CALENDAR_METHODS_H */ diff --git a/ext/intl/calendar/gregoriancalendar_methods.cpp b/ext/intl/calendar/gregoriancalendar_methods.cpp new file mode 100644 index 0000000000000..3c05253de1e19 --- /dev/null +++ b/ext/intl/calendar/gregoriancalendar_methods.cpp @@ -0,0 +1,256 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "../intl_cppshims.h" + +#include +#include +#include +extern "C" { +#include "../php_intl.h" +#define USE_TIMEZONE_POINTER 1 +#include "../timezone/timezone_class.h" +#define USE_CALENDAR_POINTER 1 +#include "calendar_class.h" +#include +} + +static inline GregorianCalendar *fetch_greg(Calendar_object *co) { + return (GregorianCalendar*)co->ucal; +} + +static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS) +{ + zval *object = getThis(); + zval **tz_object = NULL; + zval **args_a[6] = {0}, + ***args = &args_a[0]; + char *locale = NULL; + int locale_len; + long largs[6]; + UErrorCode status = U_ZERO_ERROR; + int variant; + intl_error_reset(NULL TSRMLS_CC); + + // parameter number validation / variant determination + if (ZEND_NUM_ARGS() > 6 || + zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlgregcal_create_instance: too many arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + for (variant = ZEND_NUM_ARGS(); + variant > 0 && Z_TYPE_PP(args[variant - 1]) == IS_NULL; + variant--) {} + if (variant == 4) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlgregcal_create_instance: no variant with 4 arguments " + "(excluding trailing NULLs)", 0 TSRMLS_CC); + RETURN_NULL(); + } + + // argument parsing + if (variant <= 2) { + if (zend_parse_parameters(MIN(ZEND_NUM_ARGS(), 2) TSRMLS_CC, + "|Z!s!", &tz_object, &locale, &locale_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlgregcal_create_instance: bad arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + } + if (variant > 2 && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, + "lll|lll", &largs[0], &largs[1], &largs[2], &largs[3], &largs[4], + &largs[5]) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlgregcal_create_instance: bad arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + + // instantion of ICU object + GregorianCalendar *gcal; + + if (variant <= 2) { + // From timezone and locale (0 to 2 arguments) + TimeZone *tz = timezone_process_timezone_argument(tz_object, NULL, + "intlgregcal_create_instance" TSRMLS_CC); + if (tz == NULL) { + RETURN_NULL(); + } + if (!locale) { + locale = const_cast(intl_locale_get_default(TSRMLS_C)); + } + + gcal = new GregorianCalendar(tz, Locale::createFromName(locale), + status); + if (U_FAILURE(status)) { + intl_error_set(NULL, status, "intlgregcal_create_instance: error " + "creating ICU GregorianCalendar from time zone and locale", 0 TSRMLS_CC); + if (gcal) { + delete gcal; + } + delete tz; + RETURN_NULL(); + } + } else { + // From date/time (3, 5 or 6 arguments) + for (int i = 0; i < variant; i++) { + if (largs[i] < INT32_MIN || largs[i] > INT32_MAX) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlgregcal_create_instance: at least one of the arguments" + " has an absolute value that is too large", 0 TSRMLS_CC); + RETURN_NULL(); + } + } + + if (variant == 3) { + gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1], + (int32_t)largs[2], status); + } else if (variant == 5) { + gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1], + (int32_t)largs[2], (int32_t)largs[3], (int32_t)largs[4], status); + } else if (variant == 6) { + gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1], + (int32_t)largs[2], (int32_t)largs[3], (int32_t)largs[4], (int32_t)largs[5], + status); + } + if (U_FAILURE(status)) { + intl_error_set(NULL, status, "intlgregcal_create_instance: error " + "creating ICU GregorianCalendar from date", 0 TSRMLS_CC); + if (gcal) { + delete gcal; + } + RETURN_NULL(); + } + + timelib_tzinfo *tzinfo = get_timezone_info(TSRMLS_C); +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42 + UnicodeString tzstr = UnicodeString::fromUTF8(StringPiece(tzinfo->name)); +#else + UnicodeString tzstr = UnicodeString(tzinfo->name, + strlen(tzinfo->name), US_INV); +#endif + if (tzstr.isBogus()) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlgregcal_create_instance: could not create UTF-8 string " + "from PHP's default timezone name (see date_default_timezone_get())", + 0 TSRMLS_CC); + delete gcal; + RETURN_NULL(); + } + + TimeZone *tz = TimeZone::createTimeZone(tzstr); + gcal->adoptTimeZone(tz); + } + + Calendar_object *co = (Calendar_object*)zend_object_store_get_object( + return_value TSRMLS_CC); + co->ucal = gcal; +} + +U_CFUNC PHP_FUNCTION(intlgregcal_create_instance) +{ + zval orig; + intl_error_reset(NULL TSRMLS_CC); + + object_init_ex(return_value, GregorianCalendar_ce_ptr); + orig = *return_value; + + _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU); + + if (Z_TYPE_P(return_value) == IS_NULL) { + zend_object_store_ctor_failed(&orig TSRMLS_CC); + zval_dtor(&orig); + } +} + +U_CFUNC PHP_METHOD(IntlGregorianCalendar, __construct) +{ + zval orig_this = *getThis(); + intl_error_reset(NULL TSRMLS_CC); + + return_value = getThis(); + //changes this to IS_NULL (without first destroying) if there's an error + _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU); + + if (Z_TYPE_P(return_value) == IS_NULL) { + zend_object_store_ctor_failed(&orig_this TSRMLS_CC); + zval_dtor(&orig_this); + } +} + +U_CFUNC PHP_FUNCTION(intlgregcal_set_gregorian_change) +{ + double date; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Od", &object, GregorianCalendar_ce_ptr, &date) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlgregcal_set_gregorian_change: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + fetch_greg(co)->setGregorianChange(date, CALENDAR_ERROR_CODE(co)); + INTL_METHOD_CHECK_STATUS(co, "intlgregcal_set_gregorian_change: error " + "calling ICU method"); + + RETURN_TRUE; +} + +U_CFUNC PHP_FUNCTION(intlgregcal_get_gregorian_change) +{ + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, GregorianCalendar_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlgregcal_get_gregorian_change: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + RETURN_DOUBLE((double)fetch_greg(co)->getGregorianChange()); +} + +U_CFUNC PHP_FUNCTION(intlgregcal_is_leap_year) +{ + long year; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Ol", &object, GregorianCalendar_ce_ptr, &year) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlgregcal_is_leap_year: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (year < INT32_MIN || year > INT32_MAX) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intlgregcal_is_leap_year: year out of bounds", 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + RETURN_BOOL((int)fetch_greg(co)->isLeapYear((int32_t)year)); +} diff --git a/ext/intl/calendar/gregoriancalendar_methods.h b/ext/intl/calendar/gregoriancalendar_methods.h new file mode 100644 index 0000000000000..f911752cc73b2 --- /dev/null +++ b/ext/intl/calendar/gregoriancalendar_methods.h @@ -0,0 +1,32 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#ifndef GREORIANCALENDAR_METHODS_H +#define GREORIANCALENDAR_METHODS_H + +#include + +PHP_FUNCTION(intlgregcal_create_instance); + +PHP_METHOD(IntlGregorianCalendar, __construct); + +PHP_FUNCTION(intlgregcal_set_gregorian_change); + +PHP_FUNCTION(intlgregcal_get_gregorian_change); + +PHP_FUNCTION(intlgregcal_is_leap_year); + +#endif diff --git a/ext/intl/collator/collator_create.c b/ext/intl/collator/collator_create.c index b2a9968af49a6..b2a8c7f6bac07 100644 --- a/ext/intl/collator/collator_create.c +++ b/ext/intl/collator/collator_create.c @@ -48,7 +48,7 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS) COLLATOR_METHOD_FETCH_OBJECT; if(locale_len == 0) { - locale = INTL_G(default_locale); + locale = intl_locale_get_default(TSRMLS_C); } /* Open ICU collator. */ diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c index 0785111c964b4..04a24f013e8af 100644 --- a/ext/intl/collator/collator_sort.c +++ b/ext/intl/collator/collator_sort.c @@ -78,6 +78,7 @@ static int collator_regular_compare_function(zval *result, zval *op1, zval *op2 intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Object not initialized", 0 TSRMLS_CC ); php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized"); + } /* Compare the strings using ICU. */ diff --git a/ext/intl/common/common_date.cpp b/ext/intl/common/common_date.cpp new file mode 100644 index 0000000000000..ee998818d989f --- /dev/null +++ b/ext/intl/common/common_date.cpp @@ -0,0 +1,250 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#include "../intl_cppshims.h" + +#include + +extern "C" { +#include "../php_intl.h" +#define USE_CALENDAR_POINTER 1 +#include "../calendar/calendar_class.h" +#include +} + +#ifndef INFINITY +#define INFINITY (DBL_MAX+DBL_MAX) +#endif + +#ifndef NAN +#define NAN (INFINITY-INFINITY) +#endif + +/* {{{ timezone_convert_datetimezone + * The timezone in DateTime and DateTimeZone is not unified. */ +U_CFUNC TimeZone *timezone_convert_datetimezone(int type, + void *object, + int is_datetime, + intl_error *outside_error, + const char *func TSRMLS_DC) +{ + char *id = NULL, + offset_id[] = "GMT+00:00"; + int id_len = 0; + char *message; + TimeZone *timeZone; + + switch (type) { + case TIMELIB_ZONETYPE_ID: + id = is_datetime + ? ((php_date_obj*)object)->time->tz_info->name + : ((php_timezone_obj*)object)->tzi.tz->name; + id_len = strlen(id); + break; + case TIMELIB_ZONETYPE_OFFSET: { + int offset_mins = is_datetime + ? -((php_date_obj*)object)->time->z + : -(int)((php_timezone_obj*)object)->tzi.utc_offset, + hours = offset_mins / 60, + minutes = offset_mins - hours * 60; + minutes *= minutes > 0 ? 1 : -1; + + if (offset_mins <= -24 * 60 || offset_mins >= 24 * 60) { + spprintf(&message, 0, "%s: object has an time zone offset " + "that's too large", func); + intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, + message, 1 TSRMLS_CC); + efree(message); + return NULL; + } + + id = offset_id; + id_len = slprintf(id, sizeof(offset_id), "GMT%+03d:%02d", + hours, minutes); + break; + } + case TIMELIB_ZONETYPE_ABBR: + id = is_datetime + ? ((php_date_obj*)object)->time->tz_abbr + : ((php_timezone_obj*)object)->tzi.z.abbr; + id_len = strlen(id); + break; + } + + UnicodeString s = UnicodeString(id, id_len, US_INV); + timeZone = TimeZone::createTimeZone(s); +#if U_ICU_VERSION_MAJOR_NUM >= 49 + if (*timeZone == TimeZone::getUnknown()) { +#else + UnicodeString resultingId; + timeZone->getID(resultingId); + if (resultingId == UnicodeString("Etc/Unknown", -1, US_INV) + || resultingId == UnicodeString("GMT", -1, US_INV)) { +#endif + spprintf(&message, 0, "%s: time zone id '%s' " + "extracted from ext/date DateTimeZone not recognized", func, id); + intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, + message, 1 TSRMLS_CC); + efree(message); + delete timeZone; + return NULL; + } + return timeZone; +} +/* }}} */ + +U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz, + intl_error *err, const char *func TSRMLS_DC) +{ + zval retval; + zval *zfuncname; + char *message; + + if (err && U_FAILURE(err->code)) { + return FAILURE; + } + + if (millis) { + *millis = NAN; + } + if (tz) { + *tz = NULL; + } + + if (millis) { + INIT_ZVAL(retval); + MAKE_STD_ZVAL(zfuncname); + ZVAL_STRING(zfuncname, "getTimestamp", 1); + if (call_user_function(NULL, &(z), zfuncname, &retval, 0, NULL TSRMLS_CC) + != SUCCESS || Z_TYPE(retval) != IS_LONG) { + spprintf(&message, 0, "%s: error calling ::getTimeStamp() on the " + "object", func); + intl_errors_set(err, U_INTERNAL_PROGRAM_ERROR, + message, 1 TSRMLS_CC); + efree(message); + zval_ptr_dtor(&zfuncname); + return FAILURE; + } + + *millis = U_MILLIS_PER_SECOND * (double)Z_LVAL(retval); + zval_ptr_dtor(&zfuncname); + } + + if (tz) { + php_date_obj *datetime; + datetime = (php_date_obj*)zend_object_store_get_object(z TSRMLS_CC); + if (!datetime->time) { + spprintf(&message, 0, "%s: the DateTime object is not properly " + "initialized", func); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, + message, 1 TSRMLS_CC); + efree(message); + return FAILURE; + } + if (!datetime->time->is_localtime) { + *tz = TimeZone::getGMT()->clone(); + } else { + *tz = timezone_convert_datetimezone(datetime->time->zone_type, + datetime, 1, NULL, func TSRMLS_CC); + if (*tz == NULL) { + spprintf(&message, 0, "%s: could not convert DateTime's " + "time zone", func); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, + message, 1 TSRMLS_CC); + efree(message); + return FAILURE; + } + } + } + + return SUCCESS; +} + +U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func TSRMLS_DC) +{ + double rv = NAN; + long lv; + int type; + char *message; + + if (err && U_FAILURE(err->code)) { + return NAN; + } + + switch (Z_TYPE_P(z)) { + case IS_STRING: + type = is_numeric_string(Z_STRVAL_P(z), Z_STRLEN_P(z), &lv, &rv, 0); + if (type == IS_DOUBLE) { + rv *= U_MILLIS_PER_SECOND; + } else if (type == IS_LONG) { + rv = U_MILLIS_PER_SECOND * (double)lv; + } else { + spprintf(&message, 0, "%s: string '%s' is not numeric, " + "which would be required for it to be a valid date", func, + Z_STRVAL_P(z)); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, + message, 1 TSRMLS_CC); + efree(message); + } + break; + case IS_LONG: + rv = U_MILLIS_PER_SECOND * (double)Z_LVAL_P(z); + break; + case IS_DOUBLE: + rv = U_MILLIS_PER_SECOND * Z_DVAL_P(z); + break; + case IS_OBJECT: + if (instanceof_function(Z_OBJCE_P(z), php_date_get_date_ce() TSRMLS_CC)) { + intl_datetime_decompose(z, &rv, NULL, err, func TSRMLS_CC); + } else if (instanceof_function(Z_OBJCE_P(z), Calendar_ce_ptr TSRMLS_CC)) { + Calendar_object *co = (Calendar_object *) + zend_object_store_get_object(z TSRMLS_CC ); + if (co->ucal == NULL) { + spprintf(&message, 0, "%s: IntlCalendar object is not properly " + "constructed", func); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, + message, 1 TSRMLS_CC); + efree(message); + } else { + UErrorCode status = UErrorCode(); + rv = (double)co->ucal->getTime(status); + if (U_FAILURE(status)) { + spprintf(&message, 0, "%s: call to internal " + "Calendar::getTime() has failed", func); + intl_errors_set(err, status, message, 1 TSRMLS_CC); + efree(message); + } + } + } else { + /* TODO: try with cast(), get() to obtain a number */ + spprintf(&message, 0, "%s: invalid object type for date/time " + "(only IntlCalendar and DateTime permitted)", func); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, + message, 1 TSRMLS_CC); + efree(message); + } + break; + default: + spprintf(&message, 0, "%s: invalid PHP type for date", func); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, + message, 1 TSRMLS_CC); + efree(message); + break; + } + + return rv; +} + diff --git a/ext/intl/common/common_date.h b/ext/intl/common/common_date.h new file mode 100644 index 0000000000000..d2396cbf5afa6 --- /dev/null +++ b/ext/intl/common/common_date.h @@ -0,0 +1,40 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#ifndef COMMON_DATE_H +#define COMMON_DATE_H + +#include + +U_CDECL_BEGIN +#include +#include "../intl_error.h" +U_CDECL_END + +#ifdef __cplusplus + +#include + +U_CFUNC TimeZone *timezone_convert_datetimezone(int type, void *object, int is_datetime, intl_error *outside_error, const char *func TSRMLS_DC); +U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz, + intl_error *err, const char *func TSRMLS_DC); + +#endif + +U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func TSRMLS_DC); + +#endif /* COMMON_DATE_H */ + diff --git a/ext/intl/common/common_enum.cpp b/ext/intl/common/common_enum.cpp new file mode 100644 index 0000000000000..da47a437a67b3 --- /dev/null +++ b/ext/intl/common/common_enum.cpp @@ -0,0 +1,354 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "../intl_cppshims.h" + +// Fix build on Windows/old versions of ICU +#include + +#include "common_enum.h" + +extern "C" { +#include +#include +} + +zend_class_entry *IntlIterator_ce_ptr; +zend_object_handlers IntlIterator_handlers; + +void zoi_with_current_dtor(zend_object_iterator *iter TSRMLS_DC) +{ + zoi_with_current *zoiwc = (zoi_with_current*)iter; + + if (zoiwc->wrapping_obj) { + /* we have to copy the pointer because zoiwc->wrapping_obj may be + * changed midway the execution of zval_ptr_dtor() */ + zval *zwo = zoiwc->wrapping_obj; + + /* object is still here, we can rely on it to call this again and + * destroy this object */ + zval_ptr_dtor(&zwo); + } else { + /* Object not here anymore (we've been called by the object free handler) + * Note that the iterator wrapper objects (that also depend on this + * structure) call this function earlier, in the destruction phase, which + * precedes the object free phase. Therefore there's no risk on this + * function being called by the iterator wrapper destructor function and + * not finding the memory of this iterator allocated anymore. */ + iter->funcs->invalidate_current(iter TSRMLS_CC); + zoiwc->destroy_it(iter TSRMLS_CC); + efree(iter); + } +} + +U_CFUNC int zoi_with_current_valid(zend_object_iterator *iter TSRMLS_DC) +{ + return ((zoi_with_current*)iter)->current != NULL ? SUCCESS : FAILURE; +} + +U_CFUNC void zoi_with_current_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC) +{ + *data = &((zoi_with_current*)iter)->current; +} + +U_CFUNC void zoi_with_current_invalidate_current(zend_object_iterator *iter TSRMLS_DC) +{ + zoi_with_current *zoi_iter = (zoi_with_current*)iter; + if (zoi_iter->current) { + zval_ptr_dtor(&zoi_iter->current); + zoi_iter->current = NULL; //valid would return FAILURE now + } +} + +static void string_enum_current_move_forward(zend_object_iterator *iter TSRMLS_DC) +{ + zoi_with_current *zoi_iter = (zoi_with_current*)iter; + INTLITERATOR_METHOD_INIT_VARS; + + iter->funcs->invalidate_current(iter TSRMLS_CC); + + object = zoi_iter->wrapping_obj; + INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; + + int32_t result_length; + const char *result = ((StringEnumeration*)iter->data)->next( + &result_length, INTLITERATOR_ERROR_CODE(ii)); + + intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii) TSRMLS_CC); + if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) { + intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii), + "Error fetching next iteration element", 0 TSRMLS_CC); + } else if (result) { + MAKE_STD_ZVAL(zoi_iter->current); + ZVAL_STRINGL(zoi_iter->current, result, result_length, 1); + } //else we've reached the end of the enum, nothing more is required +} + +static void string_enum_rewind(zend_object_iterator *iter TSRMLS_DC) +{ + zoi_with_current *zoi_iter = (zoi_with_current*)iter; + INTLITERATOR_METHOD_INIT_VARS; + + if (zoi_iter->current) { + iter->funcs->invalidate_current(iter TSRMLS_CC); + } + + object = zoi_iter->wrapping_obj; + INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; + + ((StringEnumeration*)iter->data)->reset(INTLITERATOR_ERROR_CODE(ii)); + + intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii) TSRMLS_CC); + if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) { + intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii), + "Error resetting enumeration", 0 TSRMLS_CC); + } else { + iter->funcs->move_forward(iter TSRMLS_CC); + } +} + +static void string_enum_destroy_it(zend_object_iterator *iter TSRMLS_DC) +{ + delete (StringEnumeration*)iter->data; +} + +static zend_object_iterator_funcs string_enum_object_iterator_funcs = { + zoi_with_current_dtor, + zoi_with_current_valid, + zoi_with_current_get_current_data, + NULL, + string_enum_current_move_forward, + string_enum_rewind, + zoi_with_current_invalidate_current +}; + +U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object TSRMLS_DC) +{ + IntlIterator_object *ii; + object_init_ex(object, IntlIterator_ce_ptr); + ii = (IntlIterator_object*)zend_object_store_get_object(object TSRMLS_CC); + ii->iterator = (zend_object_iterator*)emalloc(sizeof(zoi_with_current)); + ii->iterator->data = (void*)se; + ii->iterator->funcs = &string_enum_object_iterator_funcs; + ii->iterator->index = 0; + ((zoi_with_current*)ii->iterator)->destroy_it = string_enum_destroy_it; + ((zoi_with_current*)ii->iterator)->wrapping_obj = object; + ((zoi_with_current*)ii->iterator)->current = NULL; +} + +static void IntlIterator_objects_free(zend_object *object TSRMLS_DC) +{ + IntlIterator_object *ii = (IntlIterator_object*) object; + + if (ii->iterator) { + zval **wrapping_objp = &((zoi_with_current*)ii->iterator)->wrapping_obj; + *wrapping_objp = NULL; + ii->iterator->funcs->dtor(ii->iterator TSRMLS_CC); + } + intl_error_reset(INTLITERATOR_ERROR_P(ii) TSRMLS_CC); + + zend_object_std_dtor(&ii->zo TSRMLS_CC); + + efree(ii); +} + +static zend_object_iterator *IntlIterator_get_iterator( + zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) +{ + if (by_ref) { + zend_throw_exception(NULL, + "Iteration by reference is not supported", 0 TSRMLS_CC); + return NULL; + } + + IntlIterator_object *ii = (IntlIterator_object*) + zend_object_store_get_object(object TSRMLS_CC); + + if (ii->iterator == NULL) { + zend_throw_exception(NULL, + "The IntlIterator is not properly constructed", 0 TSRMLS_CC); + return NULL; + } + + zval_add_ref(&object); + + return ii->iterator; +} + +static zend_object_value IntlIterator_object_create(zend_class_entry *ce TSRMLS_DC) +{ + zend_object_value retval; + IntlIterator_object *intern; + + intern = (IntlIterator_object*)ecalloc(1, sizeof(IntlIterator_object)); + + zend_object_std_init(&intern->zo, ce TSRMLS_CC); +#if PHP_VERSION_ID < 50399 + zend_hash_copy(intern->zo.properties, &(ce->default_properties), + (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*)); +#else + object_properties_init((zend_object*) intern, ce); +#endif + intl_error_init(INTLITERATOR_ERROR_P(intern) TSRMLS_CC); + intern->iterator = NULL; + + retval.handle = zend_objects_store_put( + intern, + (zend_objects_store_dtor_t)zend_objects_destroy_object, + (zend_objects_free_object_storage_t)IntlIterator_objects_free, + NULL TSRMLS_CC); + + retval.handlers = &IntlIterator_handlers; + + return retval; +} + +static PHP_METHOD(IntlIterator, current) +{ + zval **data; + INTLITERATOR_METHOD_INIT_VARS; + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "IntlIterator::current: bad arguments", 0 TSRMLS_CC); + return; + } + + INTLITERATOR_METHOD_FETCH_OBJECT; + ii->iterator->funcs->get_current_data(ii->iterator, &data TSRMLS_CC); + if (data && *data) { + RETURN_ZVAL(*data, 1, 0); + } +} + +static PHP_METHOD(IntlIterator, key) +{ + INTLITERATOR_METHOD_INIT_VARS; + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "IntlIterator::key: bad arguments", 0 TSRMLS_CC); + return; + } + + INTLITERATOR_METHOD_FETCH_OBJECT; + + if (ii->iterator->funcs->get_current_key) { + char *str_key; + uint str_key_len; + ulong int_key; + + switch (ii->iterator->funcs->get_current_key( + ii->iterator, &str_key, &str_key_len, &int_key TSRMLS_CC)) { + case HASH_KEY_IS_LONG: + RETURN_LONG(int_key); + break; + case HASH_KEY_IS_STRING: + RETURN_STRINGL(str_key, str_key_len-1, 0); + break; + } + } else { + RETURN_LONG(ii->iterator->index); + } +} + +static PHP_METHOD(IntlIterator, next) +{ + INTLITERATOR_METHOD_INIT_VARS; + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "IntlIterator::next: bad arguments", 0 TSRMLS_CC); + return; + } + + INTLITERATOR_METHOD_FETCH_OBJECT; + ii->iterator->funcs->move_forward(ii->iterator TSRMLS_CC); + /* foreach also advances the index after the last iteration, + * so I see no problem in incrementing the index here unconditionally */ + ii->iterator->index++; +} + +static PHP_METHOD(IntlIterator, rewind) +{ + INTLITERATOR_METHOD_INIT_VARS; + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "IntlIterator::rewind: bad arguments", 0 TSRMLS_CC); + return; + } + + INTLITERATOR_METHOD_FETCH_OBJECT; + if (ii->iterator->funcs->rewind) { + ii->iterator->funcs->rewind(ii->iterator TSRMLS_CC); + } else { + intl_errors_set(INTLITERATOR_ERROR_P(ii), U_UNSUPPORTED_ERROR, + "IntlIterator::rewind: rewind not supported", 0 TSRMLS_CC); + } +} + +static PHP_METHOD(IntlIterator, valid) +{ + INTLITERATOR_METHOD_INIT_VARS; + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "IntlIterator::valid: bad arguments", 0 TSRMLS_CC); + return; + } + + INTLITERATOR_METHOD_FETCH_OBJECT; + RETURN_BOOL(ii->iterator->funcs->valid(ii->iterator TSRMLS_CC) == SUCCESS); +} + +ZEND_BEGIN_ARG_INFO_EX(ainfo_se_void, 0, 0, 0) +ZEND_END_ARG_INFO() + +static zend_function_entry IntlIterator_class_functions[] = { + PHP_ME(IntlIterator, current, ainfo_se_void, ZEND_ACC_PUBLIC) + PHP_ME(IntlIterator, key, ainfo_se_void, ZEND_ACC_PUBLIC) + PHP_ME(IntlIterator, next, ainfo_se_void, ZEND_ACC_PUBLIC) + PHP_ME(IntlIterator, rewind, ainfo_se_void, ZEND_ACC_PUBLIC) + PHP_ME(IntlIterator, valid, ainfo_se_void, ZEND_ACC_PUBLIC) + PHP_FE_END +}; + + +/* {{{ intl_register_IntlIterator_class + * Initialize 'IntlIterator' class + */ +U_CFUNC void intl_register_IntlIterator_class(TSRMLS_D) +{ + zend_class_entry ce; + + /* Create and register 'IntlIterator' class. */ + INIT_CLASS_ENTRY(ce, "IntlIterator", IntlIterator_class_functions); + ce.create_object = IntlIterator_object_create; + IntlIterator_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC); + IntlIterator_ce_ptr->get_iterator = IntlIterator_get_iterator; + zend_class_implements(IntlIterator_ce_ptr TSRMLS_CC, 1, + zend_ce_iterator); + + memcpy(&IntlIterator_handlers, zend_get_std_object_handlers(), + sizeof IntlIterator_handlers); + IntlIterator_handlers.clone_obj = NULL; + +} diff --git a/ext/intl/common/common_enum.h b/ext/intl/common/common_enum.h new file mode 100644 index 0000000000000..4c6abdb8f5494 --- /dev/null +++ b/ext/intl/common/common_enum.h @@ -0,0 +1,77 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Vadim Savchuk | + | Dmitry Lakhtyuk | + +----------------------------------------------------------------------+ + */ + +#ifndef INTL_COMMON_ENUM_H +#define INTL_COMMON_ENUM_H + +#include +#ifdef __cplusplus +#include +extern "C" { +#include +#endif +#include +#include "../intl_error.h" +#include "../intl_data.h" +#ifdef __cplusplus +} +#endif + +#define INTLITERATOR_ERROR(ii) (ii)->err +#define INTLITERATOR_ERROR_P(ii) &(INTLITERATOR_ERROR(ii)) + +#define INTLITERATOR_ERROR_CODE(ii) INTL_ERROR_CODE(INTLITERATOR_ERROR(ii)) +#define INTLITERATOR_ERROR_CODE_P(ii) &(INTL_ERROR_CODE(INTLITERATOR_ERROR(ii))) + +#define INTLITERATOR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(IntlIterator, ii) +#define INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(IntlIterator, ii) +#define INTLITERATOR_METHOD_FETCH_OBJECT\ + object = getThis(); \ + INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; \ + if (ii->iterator == NULL) { \ + intl_errors_set(&ii->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlIterator", 0 TSRMLS_CC); \ + RETURN_FALSE; \ + } + +typedef struct { + zend_object zo; + intl_error err; + zend_object_iterator *iterator; +} IntlIterator_object; + +typedef struct { + zend_object_iterator zoi; + zval *current; + zval *wrapping_obj; + void (*destroy_it)(zend_object_iterator *iterator TSRMLS_DC); +} zoi_with_current; + +extern zend_class_entry *IntlIterator_ce_ptr; +extern zend_object_handlers IntlIterator_handlers; + +U_CFUNC void zoi_with_current_dtor(zend_object_iterator *iter TSRMLS_DC); +U_CFUNC int zoi_with_current_valid(zend_object_iterator *iter TSRMLS_DC); +U_CFUNC void zoi_with_current_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC); +U_CFUNC void zoi_with_current_invalidate_current(zend_object_iterator *iter TSRMLS_DC); + +#ifdef __cplusplus +U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object TSRMLS_DC); +#endif + +U_CFUNC void intl_register_IntlIterator_class(TSRMLS_D); + +#endif // INTL_COMMON_ENUM_H diff --git a/ext/intl/common/common_error.c b/ext/intl/common/common_error.c index 282172224c074..a0ee7c145ffd5 100644 --- a/ext/intl/common/common_error.c +++ b/ext/intl/common/common_error.c @@ -240,9 +240,7 @@ void intl_expose_icu_error_codes( INIT_FUNC_ARGS ) INTL_EXPOSE_CONST( U_IDNA_ACE_PREFIX_ERROR ); INTL_EXPOSE_CONST( U_IDNA_VERIFICATION_ERROR ); INTL_EXPOSE_CONST( U_IDNA_LABEL_TOO_LONG_ERROR ); -#if U_ICU_VERSION_MAJOR_NUM > 3 || U_ICU_VERSION_MAJOR_NUM == 3 && U_ICU_VERSION_MINOR_NUM >= 6 INTL_EXPOSE_CONST( U_IDNA_ZERO_LENGTH_LABEL_ERROR ); -#endif #if U_ICU_VERSION_MAJOR_NUM > 3 || U_ICU_VERSION_MAJOR_NUM == 3 && U_ICU_VERSION_MINOR_NUM >= 8 INTL_EXPOSE_CONST( U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR ); #endif diff --git a/ext/intl/config.m4 b/ext/intl/config.m4 index 0477c7f59dd02..4630a302ef891 100644 --- a/ext/intl/config.m4 +++ b/ext/intl/config.m4 @@ -20,6 +20,7 @@ if test "$PHP_INTL" != "no"; then PHP_NEW_EXTENSION(intl, php_intl.c \ intl_error.c \ intl_convert.c \ + intl_convertcpp.cpp \ collator/collator.c \ collator/collator_class.c \ collator/collator_sort.c \ @@ -31,6 +32,9 @@ if test "$PHP_INTL" != "no"; then collator/collator_is_numeric.c \ collator/collator_error.c \ common/common_error.c \ + common/common_enum.cpp \ + common/common_date.cpp \ + converter/converter.c \ formatter/formatter.c \ formatter/formatter_main.c \ formatter/formatter_class.c \ @@ -49,7 +53,11 @@ if test "$PHP_INTL" != "no"; then dateformat/dateformat_attr.c \ dateformat/dateformat_data.c \ dateformat/dateformat_format.c \ + dateformat/dateformat_format_object.cpp \ dateformat/dateformat_parse.c \ + dateformat/dateformat_create.cpp \ + dateformat/dateformat_attrcpp.cpp \ + dateformat/dateformat_helpers.cpp \ msgformat/msgformat.c \ msgformat/msgformat_attr.c \ msgformat/msgformat_class.c \ @@ -65,9 +73,21 @@ if test "$PHP_INTL" != "no"; then transliterator/transliterator.c \ transliterator/transliterator_class.c \ transliterator/transliterator_methods.c \ + timezone/timezone_class.cpp \ + timezone/timezone_methods.cpp \ + calendar/calendar_class.cpp \ + calendar/calendar_methods.cpp \ + calendar/gregoriancalendar_methods.cpp \ + breakiterator/breakiterator_class.cpp \ + breakiterator/breakiterator_iterators.cpp \ + breakiterator/breakiterator_methods.cpp \ + breakiterator/rulebasedbreakiterator_methods.cpp \ + breakiterator/codepointiterator_internal.cpp \ + breakiterator/codepointiterator_methods.cpp \ idn/idn.c \ - $icu_spoof_src, $ext_shared,,$ICU_INCS) + $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings) PHP_ADD_BUILD_DIR($ext_builddir/collator) + PHP_ADD_BUILD_DIR($ext_builddir/converter) PHP_ADD_BUILD_DIR($ext_builddir/common) PHP_ADD_BUILD_DIR($ext_builddir/formatter) PHP_ADD_BUILD_DIR($ext_builddir/normalizer) @@ -77,6 +97,9 @@ if test "$PHP_INTL" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/grapheme) PHP_ADD_BUILD_DIR($ext_builddir/resourcebundle) PHP_ADD_BUILD_DIR($ext_builddir/transliterator) + PHP_ADD_BUILD_DIR($ext_builddir/timezone) + PHP_ADD_BUILD_DIR($ext_builddir/calendar) PHP_ADD_BUILD_DIR($ext_builddir/idn) PHP_ADD_BUILD_DIR($ext_builddir/spoofchecker) + PHP_ADD_BUILD_DIR($ext_builddir/breakiterator) fi diff --git a/ext/intl/config.w32 b/ext/intl/config.w32 index 437fedb7d3bc9..bb1dca8124a5a 100644 --- a/ext/intl/config.w32 +++ b/ext/intl/config.w32 @@ -7,7 +7,7 @@ if (PHP_INTL != "no") { if (CHECK_LIB("icuuc.lib", "intl", PHP_INTL) && CHECK_HEADER_ADD_INCLUDE("unicode/utf.h", "CFLAGS_INTL")) { // always build as shared - zend_strtod.c/ICU type conflict - EXTENSION("intl", "php_intl.c intl_convert.c intl_error.c ", true, + EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", true, "/I \"" + configure_module_dirname + "\""); ADD_SOURCES(configure_module_dirname + "/collator", "\ collator.c \ @@ -23,6 +23,11 @@ if (PHP_INTL != "no") { ", "intl"); ADD_SOURCES(configure_module_dirname + "/common", "\ common_error.c \ + common_enum.cpp \ + common_date.cpp \ + ", "intl"); + ADD_SOURCES(configure_module_dirname + "/converter", "\ + converter.c \ ", "intl"); ADD_SOURCES(configure_module_dirname + "/formatter", "\ formatter.c \ @@ -60,8 +65,12 @@ if (PHP_INTL != "no") { dateformat_class.c \ dateformat_attr.c \ dateformat_format.c \ + dateformat_format_object.cpp \ dateformat_parse.c \ dateformat_data.c \ + dateformat_attrcpp.cpp \ + dateformat_helpers.cpp \ + dateformat_create.cpp \ ", "intl"); ADD_SOURCES(configure_module_dirname + "/idn", "\ idn.c", @@ -87,6 +96,27 @@ if (PHP_INTL != "no") { transliterator_class.c \ transliterator_methods.c", "intl"); + + ADD_SOURCES(configure_module_dirname + "/timezone", "\ + timezone_class.cpp \ + timezone_methods.cpp", + "intl"); + + ADD_SOURCES(configure_module_dirname + "/calendar", "\ + calendar_methods.cpp \ + gregoriancalendar_methods.cpp \ + calendar_class.cpp", + "intl"); + + ADD_SOURCES(configure_module_dirname + "/breakiterator", "\ + breakiterator_class.cpp \ + breakiterator_methods.cpp \ + breakiterator_iterators.cpp \ + rulebasedbreakiterator_methods.cpp \ + codepointiterator_internal.cpp \ + codepointiterator_methods.cpp ", + "intl"); + ADD_FLAG("LIBS_INTL", "icudt.lib icuin.lib icuio.lib icule.lib iculx.lib"); AC_DEFINE("HAVE_INTL", 1, "Internationalization support enabled"); } else { diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c new file mode 100644 index 0000000000000..387760a9d18c8 --- /dev/null +++ b/ext/intl/converter/converter.c @@ -0,0 +1,1173 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Sara Golemon | + +----------------------------------------------------------------------+ + */ + +#include "converter.h" +#include "zend_exceptions.h" + +#include +#include +#include + +#include "ext/intl/intl_error.h" + +typedef struct _php_converter_object { + zend_object obj; +#ifdef ZTS + void ***tsrm_ls; +#endif + UConverter *src, *dest; + zend_fcall_info to_cb, from_cb; + zend_fcall_info_cache to_cache, from_cache; + intl_error error; +} php_converter_object; + +static zend_class_entry *php_converter_ce; +static zend_object_handlers php_converter_object_handlers; + +#define CONV_GET(pzv) ((php_converter_object*)zend_objects_get_address((pzv) TSRMLS_CC)) +#define THROW_UFAILURE(obj, fname, error) php_converter_throw_failure(obj, error TSRMLS_CC, \ + fname "() returned error %ld: %s", (long)error, u_errorName(error)) + +/* {{{ php_converter_throw_failure */ +static inline void php_converter_throw_failure(php_converter_object *objval, UErrorCode error TSRMLS_DC, const char *format, ...) { + intl_error *err = objval ? &(objval->error) : NULL; + char message[1024]; + va_list vargs; + + va_start(vargs, format); + vsnprintf(message, sizeof(message), format, vargs); + va_end(vargs); + + intl_errors_set(err, error, message, 1 TSRMLS_CC); +} +/* }}} */ + +/* {{{ php_converter_default_callback */ +static void php_converter_default_callback(zval *return_value, zval *zobj, long reason, zval *error TSRMLS_DC) { + /* Basic functionality so children can call parent::toUCallback() */ + switch (reason) { + case UCNV_UNASSIGNED: + case UCNV_ILLEGAL: + case UCNV_IRREGULAR: + { + php_converter_object *objval = (php_converter_object*)CONV_GET(zobj); + char chars[127]; + int8_t chars_len = sizeof(chars); + UErrorCode error = U_ZERO_ERROR; + + /* Yes, this is fairly wasteful at first glance, + * but considering that the alternative is to store + * what's sent into setSubstChars() and the fact + * that this is an extremely unlikely codepath + * I'd rather take the CPU hit here, than waste time + * storing a value I'm unlikely to use. + */ + ucnv_getSubstChars(objval->src, chars, &chars_len, &error); + if (U_FAILURE(error)) { + THROW_UFAILURE(objval, "ucnv_getSubstChars", error); + chars[0] = 0x1A; + chars[1] = 0; + chars_len = 1; + } + RETVAL_STRINGL(chars, chars_len, 1); + } + } + zval_dtor(error); + ZVAL_LONG(error, U_ZERO_ERROR); +} +/* }}} */ + +/* {{{ proto void UConverter::toUCallback(long $reason, + string $source, string $codeUnits, + long &$error) */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_toUCallback_arginfo, 0, ZEND_RETURN_VALUE, 4) + ZEND_ARG_INFO(0, reason) + ZEND_ARG_INFO(0, source) + ZEND_ARG_INFO(0, codeUnits) + ZEND_ARG_INFO(1, error) +ZEND_END_ARG_INFO(); +static PHP_METHOD(UConverter, toUCallback) { + long reason; + zval *source, *codeUnits, *error; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lzzz", + &reason, &source, &codeUnits, &error) == FAILURE) { + return; + } + + php_converter_default_callback(return_value, getThis(), reason, error TSRMLS_CC); +} +/* }}} */ + +/* {{{ proto void UConverter::fromUCallback(long $reason, + Array $source, long $codePoint, + long &$error) */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_fromUCallback_arginfo, 0, ZEND_RETURN_VALUE, 4) + ZEND_ARG_INFO(0, reason) + ZEND_ARG_INFO(0, source) + ZEND_ARG_INFO(0, codePoint) + ZEND_ARG_INFO(1, error) +ZEND_END_ARG_INFO(); +static PHP_METHOD(UConverter, fromUCallback) { + long reason; + zval *source, *codePoint, *error; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lzzz", + &reason, &source, &codePoint, &error) == FAILURE) { + return; + } + + php_converter_default_callback(return_value, getThis(), reason, error TSRMLS_CC); +} +/* }}} */ + +/* {{{ php_converter_check_limits */ +static inline zend_bool php_converter_check_limits(php_converter_object *objval, long available, long needed TSRMLS_DC) { + if (available < needed) { + php_converter_throw_failure(objval, U_BUFFER_OVERFLOW_ERROR TSRMLS_CC, "Buffer overrun %ld bytes needed, %ld available", needed, available); + return 0; + } + return 1; +} +/* }}} */ + +#define TARGET_CHECK(cnvargs, needed) php_converter_check_limits(objval, cnvargs->targetLimit - cnvargs->target, needed TSRMLS_CC) + +/* {{{ php_converter_append_toUnicode_target */ +static void php_converter_append_toUnicode_target(zval *val, UConverterToUnicodeArgs *args, php_converter_object *objval TSRMLS_DC) { + switch (Z_TYPE_P(val)) { + case IS_NULL: + /* Code unit is being skipped */ + return; + case IS_LONG: + { + long lval = Z_LVAL_P(val); + if ((lval < 0) || (lval > 0x10FFFF)) { + php_converter_throw_failure(objval, U_ILLEGAL_ARGUMENT_ERROR TSRMLS_CC, "Invalid codepoint U+%04lx", lval); + return; + } + if (lval > 0xFFFF) { + /* Supplemental planes U+010000 - U+10FFFF */ + if (TARGET_CHECK(args, 2)) { + /* TODO: Find the ICU call which does this properly */ + *(args->target++) = (UChar)(((lval - 0x10000) >> 10) | 0xD800); + *(args->target++) = (UChar)(((lval - 0x10000) & 0x3FF) | 0xDC00); + } + return; + } + /* Non-suggogate BMP codepoint */ + if (TARGET_CHECK(args, 1)) { + *(args->target++) = (UChar)lval; + } + return; + } + case IS_STRING: + { + const char *strval = Z_STRVAL_P(val); + int i = 0, strlen = Z_STRLEN_P(val); + + while((i != strlen) && TARGET_CHECK(args, 1)) { + UChar c; + U8_NEXT(strval, i, strlen, c); + *(args->target++) = c; + } + return; + } + case IS_ARRAY: + { + HashTable *ht = Z_ARRVAL_P(val); + HashPosition pos; + zval **tmpzval; + + for(zend_hash_internal_pointer_reset_ex(ht, &pos); + zend_hash_get_current_data_ex(ht, (void**)&tmpzval, &pos) == SUCCESS; + zend_hash_move_forward_ex(ht, &pos)) { + php_converter_append_toUnicode_target(*tmpzval, args, objval TSRMLS_CC); + } + return; + } + default: + php_converter_throw_failure(objval, U_ILLEGAL_ARGUMENT_ERROR TSRMLS_CC, + "toUCallback() specified illegal type for substitution character"); + } +} +/* }}} */ + +/* {{{ php_converter_to_u_callback */ +static void php_converter_to_u_callback(const void *context, + UConverterToUnicodeArgs *args, + const char *codeUnits, int32_t length, + UConverterCallbackReason reason, + UErrorCode *pErrorCode) { + php_converter_object *objval = (php_converter_object*)context; + zval *zreason, *zsource, *zcodeunits, *zerror, *retval = NULL; + zval **zargs[4]; +#ifdef ZTS + TSRMLS_D = objval->tsrm_ls; +#endif + + MAKE_STD_ZVAL(zreason); + ZVAL_LONG(zreason, reason); + zargs[0] = &zreason; + + MAKE_STD_ZVAL(zsource); + ZVAL_STRINGL(zsource, args->source, args->sourceLimit - args->source, 1); + zargs[1] = &zsource; + + MAKE_STD_ZVAL(zcodeunits); + ZVAL_STRINGL(zcodeunits, codeUnits, length, 1); + zargs[2] = &zcodeunits; + + MAKE_STD_ZVAL(zerror); + ZVAL_LONG(zerror, *pErrorCode); + zargs[3] = &zerror; + + objval->to_cb.param_count = 4; + objval->to_cb.params = zargs; + objval->to_cb.retval_ptr_ptr = &retval; + objval->to_cb.no_separation = 0; + if (zend_call_function(&(objval->to_cb), &(objval->to_cache) TSRMLS_CC) == FAILURE) { + /* Unlikely */ + php_converter_throw_failure(objval, U_INTERNAL_PROGRAM_ERROR TSRMLS_CC, "Unexpected failure calling toUCallback()"); + } else if (retval) { + php_converter_append_toUnicode_target(retval, args, objval TSRMLS_CC); + zval_ptr_dtor(&retval); + } + + if (Z_TYPE_P(zerror) == IS_LONG) { + *pErrorCode = Z_LVAL_P(zerror); + } + + zval_ptr_dtor(&zreason); + zval_ptr_dtor(&zsource); + zval_ptr_dtor(&zcodeunits); + zval_ptr_dtor(&zerror); +} +/* }}} */ + +/* {{{ php_converter_append_fromUnicode_target */ +static void php_converter_append_fromUnicode_target(zval *val, UConverterFromUnicodeArgs *args, php_converter_object *objval TSRMLS_DC) { + switch (Z_TYPE_P(val)) { + case IS_NULL: + /* Ignore */ + return; + case IS_LONG: + if (TARGET_CHECK(args, 1)) { + *(args->target++) = Z_LVAL_P(val); + } + return; + case IS_STRING: + { + int vallen = Z_STRLEN_P(val); + if (TARGET_CHECK(args, vallen)) { + memcpy(args->target, Z_STRVAL_P(val), vallen); + args->target += vallen; + } + return; + } + case IS_ARRAY: + { + HashTable *ht = Z_ARRVAL_P(val); + HashPosition pos; + zval **tmpzval; + for(zend_hash_internal_pointer_reset_ex(ht, &pos); + zend_hash_get_current_data_ex(ht, (void**)&tmpzval, &pos) == SUCCESS; + zend_hash_move_forward_ex(ht, &pos)) { + php_converter_append_fromUnicode_target(*tmpzval, args, objval TSRMLS_CC); + } + return; + } + default: + php_converter_throw_failure(objval, U_ILLEGAL_ARGUMENT_ERROR TSRMLS_CC, "fromUCallback() specified illegal type for substitution character"); + } +} +/* }}} */ + +/* {{{ php_converter_from_u_callback */ +static void php_converter_from_u_callback(const void *context, + UConverterFromUnicodeArgs *args, + const UChar *codeUnits, int32_t length, UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode *pErrorCode) { + php_converter_object *objval = (php_converter_object*)context; + zval *zreason, *zsource, *zcodepoint, *zerror, *retval = NULL; + zval **zargs[4]; + int i; +#ifdef ZTS + TSRMLS_D = objval->tsrm_ls; +#endif + + MAKE_STD_ZVAL(zreason); + ZVAL_LONG(zreason, reason); + zargs[0] = &zreason; + + MAKE_STD_ZVAL(zsource); + array_init(zsource); + i = 0; + while (i < length) { + UChar32 c; + U16_NEXT(codeUnits, i, length, c); + add_next_index_long(zsource, c); + } + zargs[1] = &zsource; + + MAKE_STD_ZVAL(zcodepoint); + ZVAL_LONG(zcodepoint, codePoint); + zargs[2] = &zcodepoint; + + MAKE_STD_ZVAL(zerror); + ZVAL_LONG(zerror, *pErrorCode); + zargs[3] = &zerror; + + objval->from_cb.param_count = 4; + objval->from_cb.params = zargs; + objval->from_cb.retval_ptr_ptr = &retval; + objval->from_cb.no_separation = 0; + if (zend_call_function(&(objval->from_cb), &(objval->from_cache) TSRMLS_CC) == FAILURE) { + /* Unlikely */ + php_converter_throw_failure(objval, U_INTERNAL_PROGRAM_ERROR TSRMLS_CC, "Unexpected failure calling fromUCallback()"); + } else if (retval) { + php_converter_append_fromUnicode_target(retval, args, objval TSRMLS_CC); + zval_ptr_dtor(&retval); + } + + if (Z_TYPE_P(zerror) == IS_LONG) { + *pErrorCode = Z_LVAL_P(zerror); + } + + zval_ptr_dtor(&zreason); + zval_ptr_dtor(&zsource); + zval_ptr_dtor(&zcodepoint); + zval_ptr_dtor(&zerror); +} +/* }}} */ + +/* {{{ php_converter_set_callbacks */ +static inline zend_bool php_converter_set_callbacks(php_converter_object *objval, UConverter *cnv TSRMLS_DC) { + zend_bool ret = 1; + UErrorCode error = U_ZERO_ERROR; + + if (objval->obj.ce == php_converter_ce) { + /* Short-circuit having to go through method calls and data marshalling + * when we're using default behavior + */ + return 1; + } + + ucnv_setToUCallBack(cnv, (UConverterToUCallback)php_converter_to_u_callback, (const void*)objval, + NULL, NULL, &error); + if (U_FAILURE(error)) { + THROW_UFAILURE(objval, "ucnv_setToUCallBack", error); + ret = 0; + } + + error = U_ZERO_ERROR; + ucnv_setFromUCallBack(cnv, (UConverterFromUCallback)php_converter_from_u_callback, (const void*)objval, + NULL, NULL, &error); + if (U_FAILURE(error)) { + THROW_UFAILURE(objval, "ucnv_setFromUCallBack", error); + ret = 0; + } + return ret; +} +/* }}} */ + +/* {{{ php_converter_set_encoding */ +static zend_bool php_converter_set_encoding(php_converter_object *objval, + UConverter **pcnv, + const char *enc, int enc_len + TSRMLS_DC) { + UErrorCode error = U_ZERO_ERROR; + UConverter *cnv = ucnv_open(enc, &error); + + if (error == U_AMBIGUOUS_ALIAS_WARNING) { + UErrorCode getname_error = U_ZERO_ERROR; + const char *actual_encoding = ucnv_getName(cnv, &getname_error); + if (U_FAILURE(getname_error)) { + /* Should never happen */ + actual_encoding = "(unknown)"; + } + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Ambiguous encoding specified, using %s", actual_encoding); + } else if (U_FAILURE(error)) { + if (objval) { + THROW_UFAILURE(objval, "ucnv_open", error); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting encoding: %d - %s", (int)error, u_errorName(error)); + } + return 0; + } + + if (objval && !php_converter_set_callbacks(objval, cnv TSRMLS_CC)) { + return 0; + } + + if (*pcnv) { + ucnv_close(*pcnv); + } + *pcnv = cnv; + return 1; +} +/* }}} */ + +/* {{{ php_converter_do_set_encoding */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_set_encoding_arginfo, 0, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, encoding) +ZEND_END_ARG_INFO(); +static void php_converter_do_set_encoding(UConverter *cnv, INTERNAL_FUNCTION_PARAMETERS) { + php_converter_object *objval = CONV_GET(getThis()); + char *enc; + int enc_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &enc, &enc_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "Bad arguments, " + "expected one string argument", 0 TSRMLS_CC); + RETURN_FALSE; + } + intl_errors_reset(&objval->error TSRMLS_CC); + + RETURN_BOOL(php_converter_set_encoding(objval, &(objval->src), enc, enc_len TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto bool UConverter::setSourceEncoding(string encoding) */ +static PHP_METHOD(UConverter, setSourceEncoding) { + php_converter_object *objval = CONV_GET(getThis()); + php_converter_do_set_encoding(objval->src, INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ proto bool UConverter::setDestinationEncoding(string encoding) */ +static PHP_METHOD(UConverter, setDestinationEncoding) { + php_converter_object *objval = CONV_GET(getThis()); + php_converter_do_set_encoding(objval->dest, INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ php_converter_do_get_encoding */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_get_encoding_arginfo, 0, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO(); +static void php_converter_do_get_encoding(php_converter_object *objval, UConverter *cnv, INTERNAL_FUNCTION_PARAMETERS) { + const char *name; + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "Expected no arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + intl_errors_reset(&objval->error TSRMLS_CC); + + if (!cnv) { + RETURN_NULL(); + } + + name = ucnv_getName(cnv, &objval->error.code); + if (U_FAILURE(objval->error.code)) { + THROW_UFAILURE(objval, "ucnv_getName()", objval->error.code); + RETURN_FALSE; + } + + RETURN_STRING(name, 1); +} +/* }}} */ + +/* {{{ proto string UConverter::getSourceEncoding() */ +static PHP_METHOD(UConverter, getSourceEncoding) { + php_converter_object *objval = CONV_GET(getThis()); + php_converter_do_get_encoding(objval, objval->src, INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ proto string UConverter::getDestinationEncoding() */ +static PHP_METHOD(UConverter, getDestinationEncoding) { + php_converter_object *objval = CONV_GET(getThis()); + php_converter_do_get_encoding(objval, objval->dest, INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ php_converter_do_get_type */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_get_type_arginfo, 0, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO(); +static void php_converter_do_get_type(php_converter_object *objval, UConverter *cnv, INTERNAL_FUNCTION_PARAMETERS) { + UConverterType t; + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "Expected no arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + intl_errors_reset(&objval->error TSRMLS_CC); + + if (!cnv) { + RETURN_NULL(); + } + + t = ucnv_getType(cnv); + if (U_FAILURE(objval->error.code)) { + THROW_UFAILURE(objval, "ucnv_getType", objval->error.code); + RETURN_FALSE; + } + + RETURN_LONG(t); +} +/* }}} */ + +/* {{{ proto long UConverter::getSourceType() */ +static PHP_METHOD(UConverter, getSourceType) { + php_converter_object *objval = CONV_GET(getThis()); + php_converter_do_get_type(objval, objval->src, INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ proto long UConverter::getDestinationType() */ +static PHP_METHOD(UConverter, getDestinationType) { + php_converter_object *objval = CONV_GET(getThis()); + php_converter_do_get_type(objval, objval->dest, INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ php_converter_resolve_callback */ +static void php_converter_resolve_callback(zval *zobj, + php_converter_object *objval, + const char *callback_name, + zend_fcall_info *finfo, + zend_fcall_info_cache *fcache TSRMLS_DC) { + char *errstr = NULL; + zval caller; + + array_init(&caller); + Z_ADDREF_P(zobj); + add_index_zval(&caller, 0, zobj); + add_index_string(&caller, 1, callback_name, 1); + if (zend_fcall_info_init(&caller, 0, finfo, fcache, NULL, &errstr TSRMLS_CC) == FAILURE) { + php_converter_throw_failure(objval, U_INTERNAL_PROGRAM_ERROR TSRMLS_CC, "Error setting converter callback: %s", errstr); + } + zval_dtor(&caller); + if (errstr) { + efree(errstr); + } +} +/* }}} */ + +/* {{{ proto void UConverter::__construct([string dest = 'utf-8',[string src = 'utf-8']]) */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_arginfo, 0, ZEND_RETURN_VALUE, 0) + ZEND_ARG_INFO(0, destination_encoding) + ZEND_ARG_INFO(0, source_encoding) +ZEND_END_ARG_INFO(); + +static PHP_METHOD(UConverter, __construct) { + php_converter_object *objval = CONV_GET(getThis()); + char *src = "utf-8"; + int src_len = sizeof("utf-8") - 1; + char *dest = src; + int dest_len = src_len; + + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!", + &dest, &dest_len, &src, &src_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "UConverter::__construct(): bad arguments", 0 TSRMLS_CC); + return; + } + + php_converter_set_encoding(objval, &(objval->src), src, src_len TSRMLS_CC); + php_converter_set_encoding(objval, &(objval->dest), dest, dest_len TSRMLS_CC); + php_converter_resolve_callback(getThis(), objval, "toUCallback", &(objval->to_cb), &(objval->to_cache) TSRMLS_CC); + php_converter_resolve_callback(getThis(), objval, "fromUCallback", &(objval->from_cb), &(objval->from_cache) TSRMLS_CC); +} +/* }}} */ + +/* {{{ proto bool UConverter::setSubstChars(string $chars) */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_setSubstChars_arginfo, 0, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, chars) +ZEND_END_ARG_INFO(); + +static PHP_METHOD(UConverter, setSubstChars) { + php_converter_object *objval = CONV_GET(getThis()); + char *chars; + int chars_len, ret = 1; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &chars, &chars_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "UConverter::setSubstChars(): bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + intl_errors_reset(&objval->error TSRMLS_CC); + + if (objval->src) { + UErrorCode error = U_ZERO_ERROR; + ucnv_setSubstChars(objval->src, chars, chars_len, &error); + if (U_FAILURE(error)) { + THROW_UFAILURE(objval, "ucnv_setSubstChars", error); + ret = 0; + } + } else { + php_converter_throw_failure(objval, U_INVALID_STATE_ERROR TSRMLS_CC, "Source Converter has not been initialized yet"); + ret = 0; + } + + if (objval->dest) { + UErrorCode error = U_ZERO_ERROR; + ucnv_setSubstChars(objval->dest, chars, chars_len, &error); + if (U_FAILURE(error)) { + THROW_UFAILURE(objval, "ucnv_setSubstChars", error); + ret = 0; + } + } else { + php_converter_throw_failure(objval, U_INVALID_STATE_ERROR TSRMLS_CC, "Destination Converter has not been initialized yet"); + ret = 0; + } + + RETURN_BOOL(ret); +} +/* }}} */ + +/* {{{ proto string UConverter::getSubstChars() */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_getSubstChars_arginfo, 0, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO(); + +static PHP_METHOD(UConverter, getSubstChars) { + php_converter_object *objval = CONV_GET(getThis()); + char chars[127]; + int8_t chars_len = sizeof(chars); + UErrorCode error = U_ZERO_ERROR; + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "UConverter::getSubstChars(): expected no arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + intl_errors_reset(&objval->error TSRMLS_CC); + + if (!objval->src) { + RETURN_NULL(); + } + + /* src and dest get the same subst chars set, + * so it doesn't really matter which one we read from + */ + ucnv_getSubstChars(objval->src, chars, &chars_len, &error); + if (U_FAILURE(error)) { + THROW_UFAILURE(objval, "ucnv_getSubstChars", error); + RETURN_FALSE; + } + + RETURN_STRINGL(chars, chars_len, 1); +} +/* }}} */ + +/* {{{ php_converter_do_convert */ +static zend_bool php_converter_do_convert(UConverter *dest_cnv, char **pdest, int32_t *pdest_len, + UConverter *src_cnv, const char *src, int32_t src_len, + php_converter_object *objval + TSRMLS_DC) { + UErrorCode error = U_ZERO_ERROR; + int32_t dest_len, + temp_len; + char *dest; + UChar *temp; + + if (!src_cnv || !dest_cnv) { + php_converter_throw_failure(objval, U_INVALID_STATE_ERROR TSRMLS_CC, + "Internal converters not initialized"); + return 0; + } + + /* Get necessary buffer size first */ + temp_len = 1 + ucnv_toUChars(src_cnv, NULL, 0, src, src_len, &error); + if (U_FAILURE(error) && error != U_BUFFER_OVERFLOW_ERROR) { + THROW_UFAILURE(objval, "ucnv_toUChars", error); + return 0; + } + temp = safe_emalloc(sizeof(UChar), temp_len, sizeof(UChar)); + + /* Convert to intermediate UChar* array */ + error = U_ZERO_ERROR; + temp_len = ucnv_toUChars(src_cnv, temp, temp_len, src, src_len, &error); + if (U_FAILURE(error)) { + THROW_UFAILURE(objval, "ucnv_toUChars", error); + efree(temp); + return 0; + } + temp[temp_len] = 0; + + /* Get necessary output buffer size */ + dest_len = 1 + ucnv_fromUChars(dest_cnv, NULL, 0, temp, temp_len, &error); + if (U_FAILURE(error) && error != U_BUFFER_OVERFLOW_ERROR) { + THROW_UFAILURE(objval, "ucnv_fromUChars", error); + efree(temp); + return 0; + } + dest = safe_emalloc(sizeof(char), dest_len, sizeof(char)); + + /* Convert to final encoding */ + error = U_ZERO_ERROR; + dest_len = ucnv_fromUChars(dest_cnv, dest, dest_len, temp, temp_len, &error); + efree(temp); + if (U_FAILURE(error)) { + THROW_UFAILURE(objval, "ucnv_fromUChars", error); + efree(dest); + return 0; + } + + *pdest = dest; + if (pdest_len) { + *pdest_len = dest_len; + } + + return 1; +} +/* }}} */ + +/* {{{ proto string UConverter::reasonText(long reason) */ +#define UCNV_REASON_CASE(v) case (UCNV_ ## v) : RETURN_STRINGL( "REASON_" #v , sizeof( "REASON_" #v ) - 1, 1); +ZEND_BEGIN_ARG_INFO_EX(php_converter_reasontext_arginfo, 0, ZEND_RETURN_VALUE, 0) + ZEND_ARG_INFO(0, reason) +ZEND_END_ARG_INFO(); +static PHP_METHOD(UConverter, reasonText) { + long reason; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &reason) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "UConverter::reasonText(): bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + intl_error_reset(NULL TSRMLS_CC); + + switch (reason) { + UCNV_REASON_CASE(UNASSIGNED) + UCNV_REASON_CASE(ILLEGAL) + UCNV_REASON_CASE(IRREGULAR) + UCNV_REASON_CASE(RESET) + UCNV_REASON_CASE(CLOSE) + UCNV_REASON_CASE(CLONE) + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown UConverterCallbackReason: %ld", reason); + RETURN_FALSE; + } +} +/* }}} */ + +/* {{{ proto string UConverter::convert(string str[, bool reverse]) */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_convert_arginfo, 0, ZEND_RETURN_VALUE, 1) + ZEND_ARG_INFO(0, str) + ZEND_ARG_INFO(0, reverse) +ZEND_END_ARG_INFO(); + +static PHP_METHOD(UConverter, convert) { + php_converter_object *objval = CONV_GET(getThis()); + char *str, *dest; + int str_len, dest_len; + zend_bool reverse = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", + &str, &str_len, &reverse) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "UConverter::convert(): bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + intl_errors_reset(&objval->error TSRMLS_CC); + + if (php_converter_do_convert(reverse ? objval->src : objval->dest, + &dest, &dest_len, + reverse ? objval->dest : objval->src, + str, str_len, + objval TSRMLS_CC)) { + RETURN_STRINGL(dest, dest_len, 0); + } else { + RETURN_FALSE; + } +} +/* }}} */ + +/* {{{ proto string UConverter::transcode(string $str, string $toEncoding, string $fromEncoding[, Array $options = array()]) */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_transcode_arginfo, 0, ZEND_RETURN_VALUE, 3) + ZEND_ARG_INFO(0, str) + ZEND_ARG_INFO(0, toEncoding) + ZEND_ARG_INFO(0, fromEncoding) + ZEND_ARG_ARRAY_INFO(0, options, 1) +ZEND_END_ARG_INFO(); + +static PHP_METHOD(UConverter, transcode) { + char *str, *src, *dest; + int str_len, src_len, dest_len; + zval *options = NULL; + UConverter *src_cnv = NULL, *dest_cnv = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|a!", + &str, &str_len, &dest, &dest_len, &src, &src_len, &options) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "UConverter::transcode(): bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + intl_error_reset(NULL TSRMLS_CC); + + if (php_converter_set_encoding(NULL, &src_cnv, src, src_len TSRMLS_CC) && + php_converter_set_encoding(NULL, &dest_cnv, dest, dest_len TSRMLS_CC)) { + char *out = NULL; + int out_len = 0; + UErrorCode error = U_ZERO_ERROR; + + if (options && zend_hash_num_elements(Z_ARRVAL_P(options))) { + zval **tmpzval; + + if (U_SUCCESS(error) && + zend_hash_find(Z_ARRVAL_P(options), "from_subst", sizeof("from_subst"), (void**)&tmpzval) == SUCCESS && + Z_TYPE_PP(tmpzval) == IS_STRING) { + error = U_ZERO_ERROR; + ucnv_setSubstChars(src_cnv, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval) & 0x7F, &error); + } + if (U_SUCCESS(error) && + zend_hash_find(Z_ARRVAL_P(options), "to_subst", sizeof("to_subst"), (void**)&tmpzval) == SUCCESS && + Z_TYPE_PP(tmpzval) == IS_STRING) { + error = U_ZERO_ERROR; + ucnv_setSubstChars(dest_cnv, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval) & 0x7F, &error); + } + } + + if (U_SUCCESS(error) && + php_converter_do_convert(dest_cnv, &out, &out_len, src_cnv, str, str_len, NULL TSRMLS_CC)) { + RETVAL_STRINGL(out, out_len, 0); + } + + if (U_FAILURE(error)) { + THROW_UFAILURE(NULL, "transcode", error); + RETVAL_FALSE; + } + } else { + RETVAL_FALSE; + } + + if (src_cnv) { + ucnv_close(src_cnv); + } + if (dest_cnv) { + ucnv_close(dest_cnv); + } +} +/* }}} */ + +/* {{{ proto int UConverter::getErrorCode() */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_geterrorcode_arginfo, 0, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO(); +static PHP_METHOD(UConverter, getErrorCode) { + php_converter_object *objval = CONV_GET(getThis()); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "UConverter::getErrorCode(): expected no arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + RETURN_LONG(intl_error_get_code(&(objval->error) TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto string UConverter::getErrorMessage() */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_geterrormsg_arginfo, 0, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO(); +static PHP_METHOD(UConverter, getErrorMessage) { + php_converter_object *objval = CONV_GET(getThis()); + char *message = intl_error_get_message(&(objval->error) TSRMLS_CC); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "UConverter::getErrorMessage(): expected no arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (message) { + RETURN_STRING(message, 1); + } else { + RETURN_NULL(); + } +} +/* }}} */ + +/* {{{ proto array UConverter::getAvailable() */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_getavailable_arginfo, 0, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO(); +static PHP_METHOD(UConverter, getAvailable) { + int32_t i, + count = ucnv_countAvailable(); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "UConverter::getErrorMessage(): expected no arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + intl_error_reset(NULL TSRMLS_CC); + + array_init(return_value); + for(i = 0; i < count; i++) { + const char *name = ucnv_getAvailableName(i); + add_next_index_string(return_value, name, 1); + } +} +/* }}} */ + +/* {{{ proto array UConverter::getAliases(string name) */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_getaliases_arginfo, 0, ZEND_RETURN_VALUE, 0) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO(); +static PHP_METHOD(UConverter, getAliases) { + char *name; + int name_len; + UErrorCode error = U_ZERO_ERROR; + uint16_t i, count; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "UConverter::getAliases(): bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + intl_error_reset(NULL TSRMLS_CC); + + count = ucnv_countAliases(name, &error); + if (U_FAILURE(error)) { + THROW_UFAILURE(NULL, "ucnv_countAliases", error); + RETURN_FALSE; + } + + array_init(return_value); + for(i = 0; i < count; i++) { + const char *alias; + + error = U_ZERO_ERROR; + alias = ucnv_getAlias(name, i, &error); + if (U_FAILURE(error)) { + THROW_UFAILURE(NULL, "ucnv_getAlias", error); + zval_dtor(return_value); + RETURN_NULL(); + } + add_next_index_string(return_value, alias, 1); + } +} +/* }}} */ + +/* {{{ proto array UConverter::getStandards() */ +ZEND_BEGIN_ARG_INFO_EX(php_converter_getstandards_arginfo, 0, ZEND_RETURN_VALUE, 0) +ZEND_END_ARG_INFO(); +static PHP_METHOD(UConverter, getStandards) { + uint16_t i, count; + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "UConverter::getStandards(): expected no arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + intl_error_reset(NULL TSRMLS_CC); + + array_init(return_value); + count = ucnv_countStandards(); + for(i = 0; i < count; i++) { + UErrorCode error = U_ZERO_ERROR; + const char *name = ucnv_getStandard(i, &error); + if (U_FAILURE(error)) { + THROW_UFAILURE(NULL, "ucnv_getStandard", error); + zval_dtor(return_value); + RETURN_NULL(); + } + add_next_index_string(return_value, name, 1); + } +} +/* }}} */ + +static zend_function_entry php_converter_methods[] = { + PHP_ME(UConverter, __construct, php_converter_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) + + /* Encoding selection */ + PHP_ME(UConverter, setSourceEncoding, php_converter_set_encoding_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(UConverter, setDestinationEncoding, php_converter_set_encoding_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(UConverter, getSourceEncoding, php_converter_get_encoding_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(UConverter, getDestinationEncoding, php_converter_get_encoding_arginfo, ZEND_ACC_PUBLIC) + + /* Introspection for algorithmic converters */ + PHP_ME(UConverter, getSourceType, php_converter_get_type_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(UConverter, getDestinationType, php_converter_get_type_arginfo, ZEND_ACC_PUBLIC) + + /* Basic codeunit error handling */ + PHP_ME(UConverter, getSubstChars, php_converter_getSubstChars_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(UConverter, setSubstChars, php_converter_setSubstChars_arginfo, ZEND_ACC_PUBLIC) + + /* Default callback handlers */ + PHP_ME(UConverter, toUCallback, php_converter_toUCallback_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(UConverter, fromUCallback, php_converter_fromUCallback_arginfo, ZEND_ACC_PUBLIC) + + /* Core conversion workhorses */ + PHP_ME(UConverter, convert, php_converter_convert_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(UConverter, transcode, php_converter_transcode_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + + /* Error inspection */ + PHP_ME(UConverter, getErrorCode, php_converter_geterrorcode_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(UConverter, getErrorMessage, php_converter_geterrormsg_arginfo, ZEND_ACC_PUBLIC) + + /* Ennumeration and lookup */ + PHP_ME(UConverter, reasonText, php_converter_reasontext_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME(UConverter, getAvailable, php_converter_getavailable_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME(UConverter, getAliases, php_converter_getaliases_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME(UConverter, getStandards, php_converter_getstandards_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + { NULL, NULL, NULL } +}; + +/* {{{ Converter create/clone/destroy */ +static void php_converter_free_object(php_converter_object *objval TSRMLS_DC) { + if (objval->src) { + ucnv_close(objval->src); + } + + if (objval->dest) { + ucnv_close(objval->dest); + } + + intl_error_reset(&(objval->error) TSRMLS_CC); + zend_object_std_dtor(&(objval->obj) TSRMLS_CC); + + efree(objval); +} + +static zend_object_value php_converter_object_ctor(zend_class_entry *ce, php_converter_object **pobjval TSRMLS_DC) { + php_converter_object *objval; + zend_object_value retval; + + objval = ecalloc(1, sizeof(php_converter_object)); + objval->obj.ce = ce; + +#ifdef ZTS + objval->tsrm_ls = TSRMLS_C; +#endif + intl_error_init(&(objval->error) TSRMLS_CC); + + retval.handle = zend_objects_store_put(objval, NULL, (zend_objects_free_object_storage_t)php_converter_free_object, NULL TSRMLS_CC); + retval.handlers = &php_converter_object_handlers; + *pobjval = objval; + + return retval; +} + +static zend_object_value php_converter_create_object(zend_class_entry *ce TSRMLS_DC) { + php_converter_object *objval = NULL; + zend_object_value retval = php_converter_object_ctor(ce, &objval TSRMLS_CC); + + object_properties_init(&(objval->obj), ce); + + return retval; +} + +static zend_object_value php_converter_clone_object(zval *object TSRMLS_DC) { + php_converter_object *objval, *oldobj = (php_converter_object*)zend_objects_get_address(object TSRMLS_CC); + zend_object_value retval = php_converter_object_ctor(Z_OBJCE_P(object), &objval TSRMLS_CC); + UErrorCode error = U_ZERO_ERROR; + + intl_errors_reset(&oldobj->error TSRMLS_CC); + + objval->src = ucnv_safeClone(oldobj->src, NULL, NULL, &error); + if (U_SUCCESS(error)) { + error = U_ZERO_ERROR; + objval->dest = ucnv_safeClone(oldobj->dest, NULL, NULL, &error); + } + if (U_FAILURE(error)) { + char *err_msg; + THROW_UFAILURE(oldobj, "ucnv_safeClone", error); + + err_msg = intl_error_get_message(&oldobj->error TSRMLS_CC); + zend_throw_exception(NULL, err_msg, 0 TSRMLS_CC); + efree(err_msg); + + return retval; + } + + /* Update contexts for converter error handlers */ + php_converter_set_callbacks(objval, objval->src TSRMLS_CC); + php_converter_set_callbacks(objval, objval->dest TSRMLS_CC); + + zend_objects_clone_members(&(objval->obj), retval, &(oldobj->obj), Z_OBJ_HANDLE_P(object) TSRMLS_CC); + + /* Newly cloned object deliberately does not inherit error state from original object */ + + return retval; +} +/* }}} */ + +#define CONV_REASON_CONST(v) zend_declare_class_constant_long(php_converter_ce, "REASON_" #v, sizeof("REASON_" #v) - 1, UCNV_ ## v TSRMLS_CC) +#define CONV_TYPE_CONST(v) zend_declare_class_constant_long(php_converter_ce, #v , sizeof(#v) - 1, UCNV_ ## v TSRMLS_CC) + +/* {{{ php_converter_minit */ +int php_converter_minit(INIT_FUNC_ARGS) { + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, "UConverter", php_converter_methods); + php_converter_ce = zend_register_internal_class(&ce TSRMLS_CC); + php_converter_ce->create_object = php_converter_create_object; + memcpy(&php_converter_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + php_converter_object_handlers.clone_obj = php_converter_clone_object; + + /* enum UConverterCallbackReason */ + CONV_REASON_CONST(UNASSIGNED); + CONV_REASON_CONST(ILLEGAL); + CONV_REASON_CONST(IRREGULAR); + CONV_REASON_CONST(RESET); + CONV_REASON_CONST(CLOSE); + CONV_REASON_CONST(CLONE); + + /* enum UConverterType */ + CONV_TYPE_CONST(UNSUPPORTED_CONVERTER); + CONV_TYPE_CONST(SBCS); + CONV_TYPE_CONST(DBCS); + CONV_TYPE_CONST(MBCS); + CONV_TYPE_CONST(LATIN_1); + CONV_TYPE_CONST(UTF8); + CONV_TYPE_CONST(UTF16_BigEndian); + CONV_TYPE_CONST(UTF16_LittleEndian); + CONV_TYPE_CONST(UTF32_BigEndian); + CONV_TYPE_CONST(UTF32_LittleEndian); + CONV_TYPE_CONST(EBCDIC_STATEFUL); + CONV_TYPE_CONST(ISO_2022); + CONV_TYPE_CONST(LMBCS_1); + CONV_TYPE_CONST(LMBCS_2); + CONV_TYPE_CONST(LMBCS_3); + CONV_TYPE_CONST(LMBCS_4); + CONV_TYPE_CONST(LMBCS_5); + CONV_TYPE_CONST(LMBCS_6); + CONV_TYPE_CONST(LMBCS_8); + CONV_TYPE_CONST(LMBCS_11); + CONV_TYPE_CONST(LMBCS_16); + CONV_TYPE_CONST(LMBCS_17); + CONV_TYPE_CONST(LMBCS_18); + CONV_TYPE_CONST(LMBCS_19); + CONV_TYPE_CONST(LMBCS_LAST); + CONV_TYPE_CONST(HZ); + CONV_TYPE_CONST(SCSU); + CONV_TYPE_CONST(ISCII); + CONV_TYPE_CONST(US_ASCII); + CONV_TYPE_CONST(UTF7); + CONV_TYPE_CONST(BOCU1); + CONV_TYPE_CONST(UTF16); + CONV_TYPE_CONST(UTF32); + CONV_TYPE_CONST(CESU8); + CONV_TYPE_CONST(IMAP_MAILBOX); + + return SUCCESS; +} +/* }}} */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/intl/converter/converter.h b/ext/intl/converter/converter.h new file mode 100644 index 0000000000000..bd316fcf983ad --- /dev/null +++ b/ext/intl/converter/converter.h @@ -0,0 +1,28 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Sara Golemon | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHP_INTL_CONVERTER_H +#define PHP_INTL_CONVERTER_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" + +int php_converter_minit(INIT_FUNC_ARGS); + +#endif /* PHP_INTL_CONVERTER_H */ diff --git a/ext/intl/dateformat/dateformat.c b/ext/intl/dateformat/dateformat.c index 8aded18bd64b3..fb83eeef05b76 100644 --- a/ext/intl/dateformat/dateformat.c +++ b/ext/intl/dateformat/dateformat.c @@ -17,12 +17,9 @@ #include "config.h" #endif -#include #include -#include #include "php_intl.h" -#include "intl_convert.h" #include "dateformat_class.h" #include "dateformat.h" @@ -67,157 +64,6 @@ void dateformat_register_constants( INIT_FUNC_ARGS ) } /* }}} */ -/* {{{ */ -static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) -{ - char* locale; - int locale_len = 0; - zval* object; - long date_type = 0; - long time_type = 0; - long calendar = UCAL_GREGORIAN; - char* timezone_str = NULL; - int timezone_str_len = 0; - char* pattern_str = NULL; - int pattern_str_len = 0; - UChar* svalue = NULL; /* UTF-16 pattern_str */ - int slength = 0; - UChar* timezone_utf16 = NULL; /* UTF-16 timezone_str */ - int timezone_utf16_len = 0; - UCalendar ucal_obj = NULL; - IntlDateFormatter_object* dfo; - - intl_error_reset( NULL TSRMLS_CC ); - object = return_value; - /* Parse parameters. */ - if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "sll|sls", - &locale, &locale_len, &date_type, &time_type, &timezone_str, &timezone_str_len, &calendar,&pattern_str, &pattern_str_len ) == FAILURE ) - { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: unable to parse input parameters", 0 TSRMLS_CC ); - zval_dtor(return_value); - RETURN_NULL(); - } - - INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value); - - if (calendar != UCAL_TRADITIONAL && calendar != UCAL_GREGORIAN) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: " - "invalid value for calendar type; it must be one of " - "IntlDateFormatter::TRADITIONAL (locale's default calendar) " - "or IntlDateFormatter::GREGORIAN", 0 TSRMLS_CC); - goto error; - } - - DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; - - if (DATE_FORMAT_OBJECT(dfo) != NULL) { - intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_create: cannot call constructor twice", 0 TSRMLS_CC); - return; - } - - /* Convert pattern (if specified) to UTF-16. */ - if( pattern_str && pattern_str_len>0 ){ - intl_convert_utf8_to_utf16(&svalue, &slength, - pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo)); - if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { - /* object construction -> only set global error */ - intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: " - "error converting pattern to UTF-16", 0 TSRMLS_CC); - goto error; - } - } - - /* resources allocated from now on */ - - /* Convert pattern (if specified) to UTF-16. */ - if( timezone_str && timezone_str_len >0 ){ - intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len, - timezone_str, timezone_str_len, &INTL_DATA_ERROR_CODE(dfo)); - if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { - intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: " - "error converting timezone_str to UTF-16", 0 TSRMLS_CC); - goto error; - } - } - - if(locale_len == 0) { - locale = INTL_G(default_locale); - } - - if( pattern_str && pattern_str_len>0 ){ - DATE_FORMAT_OBJECT(dfo) = udat_open(UDAT_IGNORE, UDAT_IGNORE, locale, timezone_utf16, timezone_utf16_len, svalue, slength, &INTL_DATA_ERROR_CODE(dfo)); - } else { - DATE_FORMAT_OBJECT(dfo) = udat_open(time_type, date_type, locale, timezone_utf16, timezone_utf16_len, svalue, slength, &INTL_DATA_ERROR_CODE(dfo)); - } - - if (!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { - if (calendar != UCAL_TRADITIONAL) { - ucal_obj = ucal_open(timezone_utf16, timezone_utf16_len, locale, - calendar, &INTL_DATA_ERROR_CODE(dfo)); - if (!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { - udat_setCalendar(DATE_FORMAT_OBJECT(dfo), ucal_obj); - ucal_close(ucal_obj); - } else { - intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create" - ": error opening calendar", 0 TSRMLS_CC); - goto error; - } - } - } else { - intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date " - "formatter creation failed", 0 TSRMLS_CC); - goto error; - } - - /* Set the class variables */ - dfo->date_type = date_type; - dfo->time_type = time_type; - dfo->calendar = calendar; - if( timezone_str && timezone_str_len > 0){ - dfo->timezone_id = estrndup( timezone_str, timezone_str_len); - } - -error: - if (svalue) { - efree(svalue); - } - if (timezone_utf16) { - efree(timezone_utf16); - } - if (U_FAILURE(intl_error_get_code(NULL TSRMLS_CC))) { - /* free_object handles partially constructed instances fine */ - zval_dtor(return_value); - RETVAL_NULL(); - } -} -/* }}} */ - -/* {{{ proto IntlDateFormatter IntlDateFormatter::create(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern] ) - * Create formatter. }}} */ -/* {{{ proto IntlDateFormatter datefmt_create(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern] ) - - * Create formatter. - */ -PHP_FUNCTION( datefmt_create ) -{ - object_init_ex( return_value, IntlDateFormatter_ce_ptr ); - datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU); -} -/* }}} */ - -/* {{{ proto void IntlDateFormatter::__construct(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern]) - * IntlDateFormatter object constructor. - */ -PHP_METHOD( IntlDateFormatter, __construct ) -{ - /* return_value param is being changed, therefore we will always return - * NULL here */ - return_value = getThis(); - datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU); -} -/* }}} */ - /* {{{ proto int IntlDateFormatter::getErrorCode() * Get formatter's last error code. }}} */ /* {{{ proto int datefmt_get_error_code( IntlDateFormatter $nf ) diff --git a/ext/intl/dateformat/dateformat_attr.c b/ext/intl/dateformat/dateformat_attr.c index b8c5f25e3aa03..bf6b544667623 100644 --- a/ext/intl/dateformat/dateformat_attr.c +++ b/ext/intl/dateformat/dateformat_attr.c @@ -25,39 +25,6 @@ #include #include -#include - -static void internal_set_calendar(IntlDateFormatter_object *dfo, char* timezone_id, int timezone_id_len, int calendar, zval* return_value TSRMLS_DC){ - int timezone_utf16_len = 0; - UChar* timezone_utf16 = NULL; /* timezone_id in UTF-16 */ - char* locale = NULL; - - UCalendar* ucal_obj = NULL; - - /* check for the validity of value of calendar passed */ - intl_error_reset( NULL TSRMLS_CC ); - if( calendar > 1){ - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_set_calendar: calendar value specified is out of valid range", 0 TSRMLS_CC); - RETURN_FALSE; - } - - /* Convert timezone to UTF-16. */ - intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len, timezone_id, timezone_id_len, &INTL_DATA_ERROR_CODE(dfo)); - INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" ); - - /* Get the locale for the dateformatter */ - locale = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(dfo)); - - /* Set the calendar if passed */ - ucal_obj = ucal_open(timezone_utf16, timezone_utf16_len, locale, calendar, &INTL_DATA_ERROR_CODE(dfo) ); - udat_setCalendar( DATE_FORMAT_OBJECT(dfo), ucal_obj ); - INTL_METHOD_CHECK_STATUS(dfo, "Error setting the calendar."); - - if( timezone_utf16){ - efree(timezone_utf16); - } -} /* {{{ proto unicode IntlDateFormatter::getDateType( ) * Get formatter datetype. }}} */ @@ -111,97 +78,6 @@ PHP_FUNCTION( datefmt_get_timetype ) } /* }}} */ - -/* {{{ proto unicode IntlDateFormatter::getCalendar( ) - * Get formatter calendar. }}} */ -/* {{{ proto string datefmt_get_calendar( IntlDateFormatter $mf ) - * Get formatter calendar. - */ -PHP_FUNCTION( datefmt_get_calendar ) -{ - DATE_FORMAT_METHOD_INIT_VARS; - - /* Parse parameters. */ - if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE ) - { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_get_calendar: unable to parse input params", 0 TSRMLS_CC ); - RETURN_FALSE; - } - - /* Fetch the object. */ - DATE_FORMAT_METHOD_FETCH_OBJECT; - - INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter calendar." ); - - RETURN_LONG(dfo->calendar); -} -/* }}} */ - -/* {{{ proto unicode IntlDateFormatter::getTimeZoneId( ) - * Get formatter timezone_id. }}} */ -/* {{{ proto string datefmt_get_timezone_id( IntlDateFormatter $mf ) - * Get formatter timezone_id. - */ -PHP_FUNCTION( datefmt_get_timezone_id ) -{ - DATE_FORMAT_METHOD_INIT_VARS; - - /* Parse parameters. */ - if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE ) - { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_get_timezone_id: unable to parse input params", 0 TSRMLS_CC ); - RETURN_FALSE; - } - - /* Fetch the object. */ - DATE_FORMAT_METHOD_FETCH_OBJECT; - - INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter timezone_id." ); - - if( dfo->timezone_id ){ - RETURN_STRING((char*)dfo->timezone_id, TRUE ); - }else{ - RETURN_NULL(); - } -} - -/* {{{ proto boolean IntlDateFormatter::setTimeZoneId( $timezone_id) - * Set formatter timezone_id. }}} */ -/* {{{ proto boolean datefmt_set_timezone_id( IntlDateFormatter $mf,$timezone_id) - * Set formatter timezone_id. - */ -PHP_FUNCTION( datefmt_set_timezone_id ) -{ - char* timezone_id = NULL; - int timezone_id_len = 0; - - DATE_FORMAT_METHOD_INIT_VARS; - - /* Parse parameters. */ - if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, IntlDateFormatter_ce_ptr,&timezone_id, &timezone_id_len) == FAILURE ) - { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_set_timezone_id: unable to parse input params", 0 TSRMLS_CC ); - RETURN_FALSE; - } - - /* Fetch the object. */ - DATE_FORMAT_METHOD_FETCH_OBJECT; - - /* set the timezone for the calendar */ - internal_set_calendar( dfo, timezone_id, timezone_id_len, dfo->calendar, return_value TSRMLS_CC ); - - /* Set the IntlDateFormatter variable */ - if( dfo->timezone_id ){ - efree(dfo->timezone_id); - } - dfo->timezone_id = estrndup(timezone_id, timezone_id_len); - - RETURN_TRUE; -} - /* {{{ proto string IntlDateFormatter::getPattern( ) * Get formatter pattern. }}} */ /* {{{ proto string datefmt_get_pattern( IntlDateFormatter $mf ) @@ -370,43 +246,3 @@ PHP_FUNCTION( datefmt_set_lenient ) udat_setLenient(DATE_FORMAT_OBJECT(dfo), (UBool)isLenient ); } /* }}} */ - -/* {{{ proto bool IntlDateFormatter::setPattern( int $calendar ) - * Set formatter calendar. }}} */ -/* {{{ proto bool datefmt_set_calendar( IntlDateFormatter $mf, int $calendar ) - * Set formatter calendar. - */ -PHP_FUNCTION( datefmt_set_calendar ) -{ - long calendar = 0; - - DATE_FORMAT_METHOD_INIT_VARS; - - /* Parse parameters. */ - if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", - &object, IntlDateFormatter_ce_ptr, &calendar ) == FAILURE ) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_set_calendar: unable to parse input params", 0 TSRMLS_CC); - RETURN_FALSE; - } - - /* check for the validity of value of calendar passed */ - intl_error_reset( NULL TSRMLS_CC ); - if (calendar > 1) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_set_calendar: calendar value specified is out of valid range", 0 TSRMLS_CC); - RETURN_FALSE; - } - - DATE_FORMAT_METHOD_FETCH_OBJECT; - - internal_set_calendar( dfo, dfo->timezone_id, strlen(dfo->timezone_id), calendar, return_value TSRMLS_CC ); - - /* Set the calendar value in the IntlDateFormatter object */ - dfo->calendar = calendar; - - RETURN_TRUE; -} -/* }}} */ - - diff --git a/ext/intl/dateformat/dateformat_attr.h b/ext/intl/dateformat/dateformat_attr.h index bf28824d636a6..6fe82a6e00c22 100644 --- a/ext/intl/dateformat/dateformat_attr.h +++ b/ext/intl/dateformat/dateformat_attr.h @@ -21,11 +21,7 @@ //PHP_FUNCTION( datefmt_get_timezone ); PHP_FUNCTION( datefmt_get_datetype ); PHP_FUNCTION( datefmt_get_timetype ); -PHP_FUNCTION( datefmt_get_calendar ); -PHP_FUNCTION( datefmt_set_calendar ); PHP_FUNCTION( datefmt_get_locale ); -PHP_FUNCTION( datefmt_get_timezone_id ); -PHP_FUNCTION( datefmt_set_timezone_id ); PHP_FUNCTION( datefmt_get_pattern ); PHP_FUNCTION( datefmt_set_pattern ); PHP_FUNCTION( datefmt_is_lenient ); diff --git a/ext/intl/dateformat/dateformat_attrcpp.cpp b/ext/intl/dateformat/dateformat_attrcpp.cpp new file mode 100644 index 0000000000000..b68abec65915a --- /dev/null +++ b/ext/intl/dateformat/dateformat_attrcpp.cpp @@ -0,0 +1,261 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#include "../intl_cppshims.h" + +#include +#include +#include + +extern "C" { +#include "../php_intl.h" +#include "dateformat_class.h" +#include "dateformat_attrcpp.h" +#define USE_TIMEZONE_POINTER 1 +#include "../timezone/timezone_class.h" +#define USE_CALENDAR_POINTER 1 +#include "../calendar/calendar_class.h" +} + +#include "../intl_convertcpp.h" +#include "dateformat_helpers.h" + +static inline DateFormat *fetch_datefmt(IntlDateFormatter_object *dfo) { + return (DateFormat *)dfo->datef_data.udatf; +} + +/* {{{ proto string IntlDateFormatter::getTimeZoneId() + * Get formatter timezone_id. }}} */ +/* {{{ proto string datefmt_get_timezone_id(IntlDateFormatter $mf) + * Get formatter timezone_id. + */ +U_CFUNC PHP_FUNCTION(datefmt_get_timezone_id) +{ + DATE_FORMAT_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, IntlDateFormatter_ce_ptr ) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_get_timezone_" + "id: unable to parse input params", 0 TSRMLS_CC); + RETURN_FALSE; + } + + DATE_FORMAT_METHOD_FETCH_OBJECT; + + UnicodeString res = UnicodeString(); + fetch_datefmt(dfo)->getTimeZone().getID(res); + intl_charFromString(res, &Z_STRVAL_P(return_value), + &Z_STRLEN_P(return_value), &INTL_DATA_ERROR_CODE(dfo)); + INTL_METHOD_CHECK_STATUS(dfo, "Could not convert time zone id to UTF-8"); + + Z_TYPE_P(return_value) = IS_STRING; +} + +/* {{{ proto IntlTimeZone IntlDateFormatter::getTimeZone() + * Get formatter timezone. }}} */ +/* {{{ proto IntlTimeZone datefmt_get_timezone(IntlDateFormatter $mf) + * Get formatter timezone. + */ +U_CFUNC PHP_FUNCTION(datefmt_get_timezone) +{ + DATE_FORMAT_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, IntlDateFormatter_ce_ptr ) == FAILURE) { + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_get_timezone: unable to parse input params", 0 TSRMLS_CC ); + RETURN_FALSE; + } + + DATE_FORMAT_METHOD_FETCH_OBJECT; + + const TimeZone& tz = fetch_datefmt(dfo)->getTimeZone(); + TimeZone *tz_clone = tz.clone(); + if (tz_clone == NULL) { + intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR, + "datefmt_get_timezone: Out of memory when cloning time zone", + 0 TSRMLS_CC); + RETURN_FALSE; + } + + object_init_ex(return_value, TimeZone_ce_ptr); + timezone_object_construct(tz_clone, return_value, 1 TSRMLS_CC); +} + +U_CFUNC PHP_FUNCTION(datefmt_set_timezone_id) +{ + php_error_docref0(NULL TSRMLS_CC, E_DEPRECATED, + "Use datefmt_set_timezone() instead, which also accepts a plain " + "time zone identifier and for which this function is now an " + "alias"); + PHP_FN(datefmt_set_timezone)(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +/* {{{ proto boolean IntlDateFormatter::setTimeZone(mixed $timezone) + * Set formatter's timezone. }}} */ +/* {{{ proto boolean datefmt_set_timezone_id(IntlDateFormatter $mf, $timezone_id) + * Set formatter timezone_id. + */ +U_CFUNC PHP_FUNCTION(datefmt_set_timezone) +{ + zval **timezone_zv; + TimeZone *timezone; + + DATE_FORMAT_METHOD_INIT_VARS; + + if ( zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "OZ", &object, IntlDateFormatter_ce_ptr, &timezone_zv) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_set_timezone: " + "unable to parse input params", 0 TSRMLS_CC); + RETURN_FALSE; + } + + DATE_FORMAT_METHOD_FETCH_OBJECT; + + timezone = timezone_process_timezone_argument(timezone_zv, + INTL_DATA_ERROR_P(dfo), "datefmt_set_timezone" TSRMLS_CC); + if (timezone == NULL) { + RETURN_FALSE; + } + + fetch_datefmt(dfo)->adoptTimeZone(timezone); +} + +/* {{{ proto int IntlDateFormatter::getCalendar( ) + * Get formatter calendar type. }}} */ +/* {{{ proto int datefmt_get_calendar(IntlDateFormatter $mf) + * Get formatter calendar type. + */ +U_CFUNC PHP_FUNCTION(datefmt_get_calendar) +{ + DATE_FORMAT_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, IntlDateFormatter_ce_ptr ) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_get_calendar: unable to parse input params", 0 TSRMLS_CC); + RETURN_FALSE; + } + + DATE_FORMAT_METHOD_FETCH_OBJECT; + + if (dfo->calendar == -1) { + /* an IntlCalendar was provided to the constructor */ + RETURN_FALSE; + } + + RETURN_LONG(dfo->calendar); +} +/* }}} */ + +/* {{{ proto IntlCalendar IntlDateFormatter::getCalendarObject() + * Get formatter calendar. }}} */ +/* {{{ proto IntlCalendar datefmt_get_calendar_object(IntlDateFormatter $mf) + * Get formatter calendar. + */ +U_CFUNC PHP_FUNCTION(datefmt_get_calendar_object) +{ + DATE_FORMAT_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, IntlDateFormatter_ce_ptr ) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_get_calendar_object: unable to parse input params", + 0 TSRMLS_CC); + RETURN_FALSE; + } + + DATE_FORMAT_METHOD_FETCH_OBJECT; + + const Calendar *cal = fetch_datefmt(dfo)->getCalendar(); + if (cal == NULL) { + RETURN_NULL(); + } + + Calendar *cal_clone = cal->clone(); + if (cal_clone == NULL) { + intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR, + "datefmt_get_calendar_object: Out of memory when cloning " + "calendar", 0 TSRMLS_CC); + RETURN_FALSE; + } + + calendar_object_create(return_value, cal_clone TSRMLS_CC); +} +/* }}} */ + +/* {{{ proto bool IntlDateFormatter::setCalendar(mixed $calendar) + * Set formatter's calendar. }}} */ +/* {{{ proto bool datefmt_set_calendar(IntlDateFormatter $mf, mixed $calendar) + * Set formatter's calendar. + */ +U_CFUNC PHP_FUNCTION(datefmt_set_calendar) +{ + zval *calendar_zv; + DATE_FORMAT_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz", + &object, IntlDateFormatter_ce_ptr, &calendar_zv) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_set_calendar: unable to parse input params", 0 TSRMLS_CC); + RETURN_FALSE; + } + + DATE_FORMAT_METHOD_FETCH_OBJECT; + + Calendar *cal; + long cal_type; + bool cal_owned; + Locale locale = Locale::createFromName(dfo->requested_locale); + // getting the actual locale from the DateFormat is not enough + // because we would have lost modifiers such as @calendar. We + // must store the requested locale on object creation + + if (datefmt_process_calendar_arg(calendar_zv, locale, + "datefmt_set_calendar", INTL_DATA_ERROR_P(dfo), cal, cal_type, + cal_owned TSRMLS_CC) == FAILURE) { + RETURN_FALSE; + } + + if (cal_owned) { + /* a non IntlCalendar was specified, we want to keep the timezone */ + TimeZone *old_timezone = fetch_datefmt(dfo)->getTimeZone().clone(); + if (old_timezone == NULL) { + intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR, + "datefmt_set_calendar: Out of memory when cloning calendar", + 0 TSRMLS_CC); + delete cal; + RETURN_FALSE; + } + cal->adoptTimeZone(old_timezone); + } else { + cal = cal->clone(); + if (cal == NULL) { + intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR, + "datefmt_set_calendar: Out of memory when cloning calendar", + 0 TSRMLS_CC); + RETURN_FALSE; + } + } + + fetch_datefmt(dfo)->adoptCalendar(cal); + + dfo->calendar = cal_type; + + RETURN_TRUE; +} +/* }}} */ + diff --git a/ext/intl/dateformat/dateformat_attrcpp.h b/ext/intl/dateformat/dateformat_attrcpp.h new file mode 100644 index 0000000000000..408232f9400c3 --- /dev/null +++ b/ext/intl/dateformat/dateformat_attrcpp.h @@ -0,0 +1,35 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#ifndef DATEFORMAT_ATTRCPP_H +#define DATEFORMAT_ATTRCPP_H + +PHP_FUNCTION(datefmt_get_timezone_id); + +PHP_FUNCTION(datefmt_set_timezone_id); + +PHP_FUNCTION(datefmt_get_timezone); + +PHP_FUNCTION(datefmt_set_timezone); + +PHP_FUNCTION(datefmt_get_calendar); + +PHP_FUNCTION(datefmt_set_calendar); + +PHP_FUNCTION(datefmt_get_calendar_object); + +#endif /* DATEFORMAT_ATTRCPP_H */ + diff --git a/ext/intl/dateformat/dateformat_class.c b/ext/intl/dateformat/dateformat_class.c index 49f316f7876c6..211c87f59f308 100644 --- a/ext/intl/dateformat/dateformat_class.c +++ b/ext/intl/dateformat/dateformat_class.c @@ -19,9 +19,11 @@ #include "php_intl.h" #include "dateformat_data.h" #include "dateformat_format.h" +#include "dateformat_format_object.h" #include "dateformat_parse.h" #include "dateformat.h" #include "dateformat_attr.h" +#include "dateformat_attrcpp.h" #include @@ -46,12 +48,12 @@ void IntlDateFormatter_object_free( zend_object *object TSRMLS_DC ) zend_object_std_dtor( &dfo->zo TSRMLS_CC ); - dateformat_data_free( &dfo->datef_data TSRMLS_CC ); - - if( dfo->timezone_id ){ - efree(dfo->timezone_id); + if (dfo->requested_locale) { + efree( dfo->requested_locale ); } + dateformat_data_free( &dfo->datef_data TSRMLS_CC ); + efree( dfo ); } /* }}} */ @@ -66,10 +68,10 @@ zend_object_value IntlDateFormatter_object_create(zend_class_entry *ce TSRMLS_DC dateformat_data_init( &intern->datef_data TSRMLS_CC ); zend_object_std_init( &intern->zo, ce TSRMLS_CC ); object_properties_init(&intern->zo, ce); - intern->date_type = 0; - intern->time_type = 0; - intern->calendar = 1; /* Gregorian calendar */ - intern->timezone_id = NULL; + intern->date_type = 0; + intern->time_type = 0; + intern->calendar = -1; + intern->requested_locale = NULL; retval.handle = zend_objects_store_put( intern, @@ -127,6 +129,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_intldateformatter_format, 0, 0, 0) ZEND_ARG_INFO(0, array) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_intldateformatter_format_object, 0, 0, 1) + ZEND_ARG_INFO(0, object) + ZEND_ARG_INFO(0, format) + ZEND_ARG_INFO(0, locale) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO(arginfo_intldateformatter_getdatetype, 0) ZEND_END_ARG_INFO() @@ -165,15 +173,19 @@ static zend_function_entry IntlDateFormatter_class_functions[] = { PHP_NAMED_FE( getDateType, ZEND_FN( datefmt_get_datetype ), arginfo_intldateformatter_getdatetype ) PHP_NAMED_FE( getTimeType, ZEND_FN( datefmt_get_timetype ), arginfo_intldateformatter_getdatetype ) PHP_NAMED_FE( getCalendar, ZEND_FN( datefmt_get_calendar ), arginfo_intldateformatter_getdatetype ) + PHP_NAMED_FE( getCalendarObject, ZEND_FN( datefmt_get_calendar_object ), arginfo_intldateformatter_getdatetype ) PHP_NAMED_FE( setCalendar, ZEND_FN( datefmt_set_calendar ), arginfo_intldateformatter_setcalendar ) PHP_NAMED_FE( getTimeZoneId, ZEND_FN( datefmt_get_timezone_id ), arginfo_intldateformatter_getdatetype ) PHP_NAMED_FE( setTimeZoneId, ZEND_FN( datefmt_set_timezone_id ), arginfo_intldateformatter_settimezoneid ) + PHP_NAMED_FE( getTimeZone, ZEND_FN( datefmt_get_timezone ), arginfo_intldateformatter_getdatetype ) + PHP_NAMED_FE( setTimeZone, ZEND_FN( datefmt_set_timezone ), arginfo_intldateformatter_settimezoneid ) PHP_NAMED_FE( setPattern, ZEND_FN( datefmt_set_pattern ), arginfo_intldateformatter_setpattern ) PHP_NAMED_FE( getPattern, ZEND_FN( datefmt_get_pattern ), arginfo_intldateformatter_getdatetype ) PHP_NAMED_FE( getLocale, ZEND_FN( datefmt_get_locale ), arginfo_intldateformatter_getdatetype ) PHP_NAMED_FE( setLenient, ZEND_FN( datefmt_set_lenient ), arginfo_intldateformatter_setlenient ) PHP_NAMED_FE( isLenient, ZEND_FN( datefmt_is_lenient ), arginfo_intldateformatter_getdatetype ) PHP_NAMED_FE( format, ZEND_FN( datefmt_format ), arginfo_intldateformatter_format ) + PHP_ME_MAPPING( formatObject, datefmt_format_object, arginfo_intldateformatter_format_object, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_NAMED_FE( parse, ZEND_FN( datefmt_parse), datefmt_parse_args ) PHP_NAMED_FE( localtime, ZEND_FN( datefmt_localtime ), datefmt_parse_args ) PHP_NAMED_FE( getErrorCode, ZEND_FN( datefmt_get_error_code ), arginfo_intldateformatter_getdatetype ) diff --git a/ext/intl/dateformat/dateformat_class.h b/ext/intl/dateformat/dateformat_class.h index d58abe42f586e..b4304660e236b 100644 --- a/ext/intl/dateformat/dateformat_class.h +++ b/ext/intl/dateformat/dateformat_class.h @@ -24,12 +24,12 @@ #include "dateformat_data.h" typedef struct { - zend_object zo; - dateformat_data datef_data; - int date_type ; - int time_type ; - int calendar ; - char* timezone_id; + zend_object zo; + dateformat_data datef_data; + int date_type; + int time_type; + int calendar; + char *requested_locale; } IntlDateFormatter_object; void dateformat_register_IntlDateFormatter_class( TSRMLS_D ); diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp new file mode 100644 index 0000000000000..a2899f7974618 --- /dev/null +++ b/ext/intl/dateformat/dateformat_create.cpp @@ -0,0 +1,193 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Kirti Velankar | + | Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#include "../intl_cppshims.h" + +#include +#include +#include + +extern "C" { +#include +#include + +#include "php_intl.h" +#include "dateformat_create.h" +#include "dateformat_class.h" +#define USE_TIMEZONE_POINTER 1 +#include "../timezone/timezone_class.h" +#include "../intl_convert.h" +} + +#include "dateformat_helpers.h" + +/* {{{ */ +static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) +{ + zval *object; + + const char *locale_str; + int locale_len = 0; + Locale locale; + long date_type = 0; + long time_type = 0; + zval *calendar_zv = NULL; + Calendar *calendar = NULL; + long calendar_type; + bool calendar_owned; + zval **timezone_zv = NULL; + TimeZone *timezone = NULL; + bool explicit_tz; + char* pattern_str = NULL; + int pattern_str_len = 0; + UChar* svalue = NULL; /* UTF-16 pattern_str */ + int slength = 0; + IntlDateFormatter_object* dfo; + + intl_error_reset(NULL TSRMLS_CC); + object = return_value; + /* Parse parameters. */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sll|Zzs", + &locale_str, &locale_len, &date_type, &time_type, &timezone_zv, + &calendar_zv, &pattern_str, &pattern_str_len) == FAILURE) { + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: " + "unable to parse input parameters", 0 TSRMLS_CC); + zval_dtor(return_value); + RETURN_NULL(); + } + + INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value); + if (locale_len == 0) { + locale_str = intl_locale_get_default(TSRMLS_C); + } + locale = Locale::createFromName(locale_str); + + DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; + + if (DATE_FORMAT_OBJECT(dfo) != NULL) { + intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_create: cannot call constructor twice", 0 TSRMLS_CC); + return; + } + + /* process calendar */ + if (datefmt_process_calendar_arg(calendar_zv, locale, "datefmt_create", + INTL_DATA_ERROR_P(dfo), calendar, calendar_type, + calendar_owned TSRMLS_CC) + == FAILURE) { + goto error; + } + + /* process timezone */ + explicit_tz = timezone_zv != NULL && Z_TYPE_PP(timezone_zv) != IS_NULL; + + if (explicit_tz || calendar_owned ) { + //we have an explicit time zone or a non-object calendar + timezone = timezone_process_timezone_argument(timezone_zv, + INTL_DATA_ERROR_P(dfo), "datefmt_create" TSRMLS_CC); + if (timezone == NULL) { + goto error; + } + } + + /* Convert pattern (if specified) to UTF-16. */ + if (pattern_str && pattern_str_len > 0) { + intl_convert_utf8_to_utf16(&svalue, &slength, + pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo)); + if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { + /* object construction -> only set global error */ + intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: " + "error converting pattern to UTF-16", 0 TSRMLS_CC); + goto error; + } + } + + if (pattern_str && pattern_str_len > 0) { + DATE_FORMAT_OBJECT(dfo) = udat_open(UDAT_IGNORE, UDAT_IGNORE, + locale_str, NULL, 0, svalue, slength, + &INTL_DATA_ERROR_CODE(dfo)); + } else { + DATE_FORMAT_OBJECT(dfo) = udat_open((UDateFormatStyle)time_type, + (UDateFormatStyle)date_type, locale_str, NULL, 0, svalue, + slength, &INTL_DATA_ERROR_CODE(dfo)); + } + + if (!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { + DateFormat *df = (DateFormat*)DATE_FORMAT_OBJECT(dfo); + if (calendar_owned) { + df->adoptCalendar(calendar); + calendar_owned = false; + } else { + df->setCalendar(*calendar); + } + + if (timezone != NULL) { + df->adoptTimeZone(timezone); + } + } else { + intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date " + "formatter creation failed", 0 TSRMLS_CC); + goto error; + } + + /* Set the class variables */ + dfo->date_type = date_type; + dfo->time_type = time_type; + dfo->calendar = calendar_type; + dfo->requested_locale = estrdup(locale_str); + +error: + if (svalue) { + efree(svalue); + } + if (timezone != NULL && DATE_FORMAT_OBJECT(dfo) == NULL) { + delete timezone; + } + if (calendar != NULL && calendar_owned) { + delete calendar; + } + if (U_FAILURE(intl_error_get_code(NULL TSRMLS_CC))) { + /* free_object handles partially constructed instances fine */ + zval_dtor(return_value); + RETVAL_NULL(); + } +} +/* }}} */ + +/* {{{ proto IntlDateFormatter IntlDateFormatter::create(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern] ) + * Create formatter. }}} */ +/* {{{ proto IntlDateFormatter datefmt_create(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern) + * Create formatter. + */ +U_CFUNC PHP_FUNCTION( datefmt_create ) +{ + object_init_ex( return_value, IntlDateFormatter_ce_ptr ); + datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ + +/* {{{ proto void IntlDateFormatter::__construct(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern]) + * IntlDateFormatter object constructor. + */ +U_CFUNC PHP_METHOD( IntlDateFormatter, __construct ) +{ + /* return_value param is being changed, therefore we will always return + * NULL here */ + return_value = getThis(); + datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} +/* }}} */ diff --git a/ext/intl/dateformat/dateformat_create.h b/ext/intl/dateformat/dateformat_create.h new file mode 100644 index 0000000000000..47e67c2f45ac0 --- /dev/null +++ b/ext/intl/dateformat/dateformat_create.h @@ -0,0 +1,25 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ +#ifndef DATE_FORMATTER_H +#define DATE_FORMATTER_H + +#include + +PHP_FUNCTION( datefmt_create ); +PHP_METHOD( IntlDateFormatter, __construct ); +void dateformat_register_constants( INIT_FUNC_ARGS ); + +#endif // DATE_FORMATTER_H diff --git a/ext/intl/dateformat/dateformat_format.c b/ext/intl/dateformat/dateformat_format.c index 4d03d924c8564..ffae15518b08e 100644 --- a/ext/intl/dateformat/dateformat_format.c +++ b/ext/intl/dateformat/dateformat_format.c @@ -21,13 +21,13 @@ #include #include -#include "php_intl.h" -#include "intl_convert.h" +#include "../php_intl.h" +#include "../intl_convert.h" +#include "../common/common_date.h" #include "dateformat.h" #include "dateformat_class.h" #include "dateformat_format.h" #include "dateformat_data.h" -#include "ext/date/php_date.h" /* {{{ * Internal function which calls the udat_format @@ -59,20 +59,38 @@ static void internal_format(IntlDateFormatter_object *dfo, UDate timestamp, zval /* {{{ * Internal function which fetches an element from the passed array for the key_name passed */ -static double internal_get_arr_ele(IntlDateFormatter_object *dfo, HashTable* hash_arr, char* key_name TSRMLS_DC) +static int32_t internal_get_arr_ele(IntlDateFormatter_object *dfo, + HashTable* hash_arr, char* key_name, intl_error *err TSRMLS_DC) { - zval** ele_value = NULL; - UDate result = -1; - - if( zend_hash_find( hash_arr, key_name, strlen(key_name) + 1, (void **)&ele_value ) == SUCCESS ){ - if( Z_TYPE_PP(ele_value)!= IS_LONG ){ - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_format: parameter array does not contain a long element.", 0 TSRMLS_CC ); - }else{ - result = Z_LVAL_PP(ele_value); + zval **ele_value = NULL; + int32_t result = 0; + char *message; + + if (U_FAILURE(err->code)) { + return result; + } + + if (zend_hash_find(hash_arr, key_name, strlen(key_name) + 1, + (void **)&ele_value) == SUCCESS) { + if(Z_TYPE_PP(ele_value) != IS_LONG) { + spprintf(&message, 0, "datefmt_format: parameter array contains " + "a non-integer element for key '%s'", key_name); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); + efree(message); + } else { + if (Z_LVAL_PP(ele_value) > INT32_MAX || + Z_LVAL_PP(ele_value) < INT32_MIN) { + spprintf(&message, 0, "datefmt_format: value %ld is out of " + "bounds for a 32-bit integer in key '%s'", + Z_LVAL_PP(ele_value), key_name); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); + efree(message); + } else { + result = Z_LVAL_PP(ele_value); + } } } - /* printf("\n Inside internal_get_arr_ele key_name= %s, result = %g \n", key_name, result); */ + return result; } /* }}} */ @@ -80,41 +98,51 @@ static double internal_get_arr_ele(IntlDateFormatter_object *dfo, HashTable* has /* {{{ * Internal function which sets UCalendar from the passed array and retrieves timestamp */ -static UDate internal_get_timestamp(IntlDateFormatter_object *dfo, HashTable* hash_arr TSRMLS_DC) +static UDate internal_get_timestamp(IntlDateFormatter_object *dfo, + HashTable *hash_arr TSRMLS_DC) { - long year =0; - long month =0; - long hour =0; - long minute =0; - long second =0; - long wday =0; - long yday =0; - long mday =0; - UBool isInDST = FALSE; - UCalendar *pcal; + int32_t year, + month, + hour, + minute, + second, + mday; + UCalendar *pcal; + UDate result; + intl_error *err = &dfo->datef_data.error; + +#define INTL_GET_ELEM(elem) \ + internal_get_arr_ele(dfo, hash_arr, (elem), err TSRMLS_CC) /* Fetch values from the incoming array */ - year = internal_get_arr_ele( dfo, hash_arr, CALENDAR_YEAR TSRMLS_CC) + 1900; /* tm_year is years since 1900 */ + year = INTL_GET_ELEM(CALENDAR_YEAR) + 1900; /* tm_year is years since 1900 */ /* Month in ICU and PHP starts from January =0 */ - month = internal_get_arr_ele( dfo, hash_arr, CALENDAR_MON TSRMLS_CC); - hour = internal_get_arr_ele( dfo, hash_arr, CALENDAR_HOUR TSRMLS_CC); - minute = internal_get_arr_ele( dfo, hash_arr, CALENDAR_MIN TSRMLS_CC); - second = internal_get_arr_ele( dfo, hash_arr, CALENDAR_SEC TSRMLS_CC); - wday = internal_get_arr_ele( dfo, hash_arr, CALENDAR_WDAY TSRMLS_CC); - yday = internal_get_arr_ele( dfo, hash_arr, CALENDAR_YDAY TSRMLS_CC); - isInDST = internal_get_arr_ele( dfo, hash_arr, CALENDAR_ISDST TSRMLS_CC); + month = INTL_GET_ELEM(CALENDAR_MON); + hour = INTL_GET_ELEM(CALENDAR_HOUR); + minute = INTL_GET_ELEM(CALENDAR_MIN); + second = INTL_GET_ELEM(CALENDAR_SEC); /* For the ucal_setDateTime() function, this is the 'date' value */ - mday = internal_get_arr_ele( dfo, hash_arr, CALENDAR_MDAY TSRMLS_CC); + mday = INTL_GET_ELEM(CALENDAR_MDAY); - pcal = udat_getCalendar(DATE_FORMAT_OBJECT(dfo)); - /* set the incoming values for the calendar */ - ucal_setDateTime( pcal, year, month, mday, hour, minute, second, &INTL_DATA_ERROR_CODE(dfo)); - if( INTL_DATA_ERROR_CODE(dfo) != U_ZERO_ERROR){ +#undef INTL_GET_ELEM + + pcal = ucal_clone(udat_getCalendar(DATE_FORMAT_OBJECT(dfo)), + &INTL_DATA_ERROR_CODE(dfo)); + + if (INTL_DATA_ERROR_CODE(dfo) != U_ZERO_ERROR) { + intl_errors_set(err, INTL_DATA_ERROR_CODE(dfo), "datefmt_format: " + "error cloning calendar", 0 TSRMLS_CC); return 0; } - + + /* set the incoming values for the calendar */ + ucal_setDateTime(pcal, year, month, mday, hour, minute, second, &INTL_DATA_ERROR_CODE(dfo)); + /* actually, ucal_setDateTime cannot fail */ + /* Fetch the timestamp from the UCalendar */ - return ucal_getMillis(pcal, &INTL_DATA_ERROR_CODE(dfo) ); + result = ucal_getMillis(pcal, &INTL_DATA_ERROR_CODE(dfo)); + ucal_close(pcal); + return result; } @@ -124,70 +152,39 @@ static UDate internal_get_timestamp(IntlDateFormatter_object *dfo, HashTable* ha * Format the time value as a string. }}}*/ PHP_FUNCTION(datefmt_format) { - UDate timestamp =0; - UDate p_timestamp =0; - HashTable* hash_arr = NULL; - zval* zarg = NULL; + UDate timestamp = 0; + HashTable *hash_arr = NULL; + zval *zarg = NULL; DATE_FORMAT_METHOD_INIT_VARS; /* Parse parameters. */ - if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz", &object, IntlDateFormatter_ce_ptr,&zarg ) == FAILURE ) - { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format: unable to parse input params", 0 TSRMLS_CC ); + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz", + &object, IntlDateFormatter_ce_ptr, &zarg) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format: unable " + "to parse input params", 0 TSRMLS_CC ); RETURN_FALSE; } - /* Fetch the object. */ DATE_FORMAT_METHOD_FETCH_OBJECT; - switch(Z_TYPE_P(zarg) ){ - case IS_LONG: - p_timestamp = Z_LVAL_P(zarg) ; - timestamp = p_timestamp * 1000; - break; - case IS_DOUBLE: - /* timestamp*1000 since ICU expects it in milliseconds */ - p_timestamp = Z_DVAL_P(zarg) ; - timestamp = p_timestamp * 1000; - break; - case IS_ARRAY: - hash_arr = Z_ARRVAL_P(zarg); - if( !hash_arr || zend_hash_num_elements( hash_arr ) == 0 ) - RETURN_FALSE; - - timestamp = internal_get_timestamp(dfo, hash_arr TSRMLS_CC); - INTL_METHOD_CHECK_STATUS( dfo, "datefmt_format: Date formatting failed" ) - break; - case IS_OBJECT: { - zend_class_entry *date_ce = php_date_get_date_ce(); - zval retval; - zval *zfuncname; - if(!instanceof_function(Z_OBJCE_P(zarg), date_ce TSRMLS_CC)) { - intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format: object must be an instance of DateTime", 0 TSRMLS_CC ); - RETURN_FALSE; - } - INIT_ZVAL(retval); - MAKE_STD_ZVAL(zfuncname); - ZVAL_STRING(zfuncname, "getTimestamp", 1); - if(call_user_function(NULL, &zarg, zfuncname, &retval, 0, NULL TSRMLS_CC) != SUCCESS || Z_TYPE(retval) != IS_LONG) { - intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format: cannot get timestamp", 0 TSRMLS_CC ); - zval_ptr_dtor(&zfuncname); - RETURN_FALSE; - } - zval_ptr_dtor(&zfuncname); - p_timestamp = Z_LVAL(retval); - timestamp = p_timestamp*1000; + if (Z_TYPE_P(zarg) == IS_ARRAY) { + hash_arr = Z_ARRVAL_P(zarg); + if (!hash_arr || zend_hash_num_elements(hash_arr) == 0) { + RETURN_FALSE; } - break; - default: - intl_errors_set( INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_format: takes either an array or an integer timestamp value or a DateTime object", 0 TSRMLS_CC ); + + timestamp = internal_get_timestamp(dfo, hash_arr TSRMLS_CC); + INTL_METHOD_CHECK_STATUS(dfo, "datefmt_format: date formatting failed") + } else { + timestamp = intl_zval_to_millis(zarg, INTL_DATA_ERROR_P(dfo), + "datefmt_format" TSRMLS_CC); + if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { RETURN_FALSE; + } } - - internal_format( dfo, timestamp, return_value TSRMLS_CC); + internal_format( dfo, timestamp, return_value TSRMLS_CC); } /* }}} */ diff --git a/ext/intl/dateformat/dateformat_format_object.cpp b/ext/intl/dateformat/dateformat_format_object.cpp new file mode 100644 index 0000000000000..e8981faa2676f --- /dev/null +++ b/ext/intl/dateformat/dateformat_format_object.cpp @@ -0,0 +1,230 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#include "../intl_cppshims.h" + +#include +#include +#include +#include +#include + +#include "../intl_convertcpp.h" + +extern "C" { +#include "../php_intl.h" +#include "../locale/locale.h" +#define USE_CALENDAR_POINTER 1 +#include "../calendar/calendar_class.h" +#include +#include "../common/common_date.h" +} + +static const DateFormat::EStyle valid_styles[] = { + DateFormat::kNone, + DateFormat::kFull, + DateFormat::kLong, + DateFormat::kMedium, + DateFormat::kShort, + DateFormat::kFullRelative, + DateFormat::kLongRelative, + DateFormat::kMediumRelative, + DateFormat::kShortRelative, +}; + +static bool valid_format(zval **z) { + if (Z_TYPE_PP(z) == IS_LONG) { + long lval = Z_LVAL_PP(z); + for (int i = 0; i < sizeof(valid_styles) / sizeof(*valid_styles); i++) { + if ((long)valid_styles[i] == lval) { + return true; + } + } + } + + return false; +} + +U_CFUNC PHP_FUNCTION(datefmt_format_object) +{ + zval *object, + **format = NULL; + const char *locale_str = NULL; + int locale_len; + bool pattern = false; + UDate date; + TimeZone *timeZone = NULL; + UErrorCode status = U_ZERO_ERROR; + DateFormat *df = NULL; + Calendar *cal = NULL; + DateFormat::EStyle dateStyle = DateFormat::kDefault, + timeStyle = DateFormat::kDefault; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|Zs!", + &object, &format, &locale_str, &locale_len) == FAILURE) { + RETURN_FALSE; + } + + if (!locale_str) { + locale_str = intl_locale_get_default(TSRMLS_C); + } + + if (format == NULL || Z_TYPE_PP(format) == IS_NULL) { + //nothing + } else if (Z_TYPE_PP(format) == IS_ARRAY) { + HashTable *ht = Z_ARRVAL_PP(format); + HashPosition pos = {0}; + zval **z; + if (zend_hash_num_elements(ht) != 2) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_format_object: bad format; if array, it must have " + "two elements", 0 TSRMLS_CC); + RETURN_FALSE; + } + + zend_hash_internal_pointer_reset_ex(ht, &pos); + zend_hash_get_current_data_ex(ht, (void**)&z, &pos); + if (!valid_format(z)) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_format_object: bad format; the date format (first " + "element of the array) is not valid", 0 TSRMLS_CC); + RETURN_FALSE; + } + dateStyle = (DateFormat::EStyle)Z_LVAL_PP(z); + + zend_hash_move_forward_ex(ht, &pos); + zend_hash_get_current_data_ex(ht, (void**)&z, &pos); + if (!valid_format(z)) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_format_object: bad format; the time format (" + "second element of the array) is not valid", 0 TSRMLS_CC); + RETURN_FALSE; + } + timeStyle = (DateFormat::EStyle)Z_LVAL_PP(z); + } else if (Z_TYPE_PP(format) == IS_LONG) { + if (!valid_format(format)) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_format_object: the date/time format type is invalid", + 0 TSRMLS_CC); + RETURN_FALSE; + } + dateStyle = timeStyle = (DateFormat::EStyle)Z_LVAL_PP(format); + } else { + convert_to_string_ex(format); + if (Z_STRLEN_PP(format) == 0) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_format_object: the format is empty", 0 TSRMLS_CC); + RETURN_FALSE; + } + pattern = true; + } + + //there's no support for relative time in ICU yet + timeStyle = (DateFormat::EStyle)(timeStyle & ~DateFormat::kRelative); + + zend_class_entry *instance_ce = Z_OBJCE_P(object); + if (instanceof_function(instance_ce, Calendar_ce_ptr TSRMLS_CC)) { + Calendar *obj_cal = calendar_fetch_native_calendar(object TSRMLS_CC); + if (obj_cal == NULL) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_format_object: bad IntlCalendar instance: " + "not initialized properly", 0 TSRMLS_CC); + RETURN_FALSE; + } + timeZone = obj_cal->getTimeZone().clone(); + date = obj_cal->getTime(status); + if (U_FAILURE(status)) { + intl_error_set(NULL, status, + "datefmt_format_object: error obtaining instant from " + "IntlCalendar", 0 TSRMLS_CC); + RETVAL_FALSE; + goto cleanup; + } + cal = obj_cal->clone(); + } else if (instanceof_function(instance_ce, php_date_get_date_ce() TSRMLS_CC)) { + if (intl_datetime_decompose(object, &date, &timeZone, NULL, + "datefmt_format_object" TSRMLS_CC) == FAILURE) { + RETURN_FALSE; + } + cal = new GregorianCalendar(Locale::createFromName(locale_str), status); + if (U_FAILURE(status)) { + intl_error_set(NULL, status, + "datefmt_format_object: could not create GregorianCalendar", + 0 TSRMLS_CC); + RETVAL_FALSE; + goto cleanup; + } + } else { + intl_error_set(NULL, status, "datefmt_format_object: the passed object " + "must be an instance of either IntlCalendar or DateTime", + 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (pattern) { + df = new SimpleDateFormat( + UnicodeString(Z_STRVAL_PP(format), Z_STRLEN_PP(format), + UnicodeString::kInvariant), + Locale::createFromName(locale_str), + status); + + if (U_FAILURE(status)) { + intl_error_set(NULL, status, + "datefmt_format_object: could not create SimpleDateFormat", + 0 TSRMLS_CC); + RETVAL_FALSE; + goto cleanup; + } + } else { + df = DateFormat::createDateTimeInstance(dateStyle, timeStyle, + Locale::createFromName(locale_str)); + + if (df == NULL) { /* according to ICU sources, this should never happen */ + intl_error_set(NULL, status, + "datefmt_format_object: could not create DateFormat", + 0 TSRMLS_CC); + RETVAL_FALSE; + goto cleanup; + } + } + + //must be in this order (or have the cal adopt the tz) + df->adoptCalendar(cal); + cal = NULL; + df->adoptTimeZone(timeZone); + timeZone = NULL; + + { + UnicodeString result = UnicodeString(); + df->format(date, result); + + Z_TYPE_P(return_value) = IS_STRING; + if (intl_charFromString(result, &Z_STRVAL_P(return_value), + &Z_STRLEN_P(return_value), &status) == FAILURE) { + intl_error_set(NULL, status, + "datefmt_format_object: error converting result to UTF-8", + 0 TSRMLS_CC); + RETVAL_FALSE; + goto cleanup; + } + } + + +cleanup: + delete df; + delete timeZone; + delete cal; +} diff --git a/ext/intl/dateformat/dateformat_format_object.h b/ext/intl/dateformat/dateformat_format_object.h new file mode 100644 index 0000000000000..d80ea87e0f813 --- /dev/null +++ b/ext/intl/dateformat/dateformat_format_object.h @@ -0,0 +1,19 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#include + +PHP_FUNCTION(datefmt_format_object); diff --git a/ext/intl/dateformat/dateformat_helpers.cpp b/ext/intl/dateformat/dateformat_helpers.cpp new file mode 100644 index 0000000000000..74758bbec92b5 --- /dev/null +++ b/ext/intl/dateformat/dateformat_helpers.cpp @@ -0,0 +1,106 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#include "../intl_cppshims.h" + +#include +#include + +#include "dateformat_helpers.h" + +extern "C" { +#include "../php_intl.h" +#include +#define USE_CALENDAR_POINTER 1 +#include "../calendar/calendar_class.h" +} + +int datefmt_process_calendar_arg(zval* calendar_zv, + Locale const& locale, + const char *func_name, + intl_error *err, + Calendar*& cal, + long& cal_int_type, + bool& calendar_owned TSRMLS_DC) +{ + char *msg; + UErrorCode status = UErrorCode(); + + if (calendar_zv == NULL || Z_TYPE_P(calendar_zv) == IS_NULL) { + + // default requested + cal = new GregorianCalendar(locale, status); + calendar_owned = true; + + cal_int_type = UCAL_GREGORIAN; + + } else if (Z_TYPE_P(calendar_zv) == IS_LONG) { + + long v = Z_LVAL_P(calendar_zv); + if (v != (long)UCAL_TRADITIONAL && v != (long)UCAL_GREGORIAN) { + spprintf(&msg, 0, "%s: invalid value for calendar type; it must be " + "one of IntlDateFormatter::TRADITIONAL (locale's default " + "calendar) or IntlDateFormatter::GREGORIAN. " + "Alternatively, it can be an IntlCalendar object", + func_name); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC); + efree(msg); + return FAILURE; + } else if (v == (long)UCAL_TRADITIONAL) { + cal = Calendar::createInstance(locale, status); + } else { //UCAL_GREGORIAN + cal = new GregorianCalendar(locale, status); + } + calendar_owned = true; + + cal_int_type = Z_LVAL_P(calendar_zv); + + } else if (Z_TYPE_P(calendar_zv) == IS_OBJECT && + instanceof_function_ex(Z_OBJCE_P(calendar_zv), + Calendar_ce_ptr, 0 TSRMLS_CC)) { + + cal = calendar_fetch_native_calendar(calendar_zv TSRMLS_CC); + if (cal == NULL) { + spprintf(&msg, 0, "%s: Found unconstructed IntlCalendar object", + func_name); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC); + efree(msg); + return FAILURE; + } + calendar_owned = false; + + cal_int_type = -1; + + } else { + spprintf(&msg, 0, "%s: Invalid calendar argument; should be an integer " + "or an IntlCalendar instance", func_name); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC); + efree(msg); + return FAILURE; + } + + if (cal == NULL && !U_FAILURE(status)) { + status = U_MEMORY_ALLOCATION_ERROR; + } + if (U_FAILURE(status)) { + spprintf(&msg, 0, "%s: Failure instantiating calendar", func_name); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC); + efree(msg); + return FAILURE; + } + + return SUCCESS; +} diff --git a/ext/intl/dateformat/dateformat_helpers.h b/ext/intl/dateformat/dateformat_helpers.h new file mode 100644 index 0000000000000..bded0b7d7811d --- /dev/null +++ b/ext/intl/dateformat/dateformat_helpers.h @@ -0,0 +1,39 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#ifndef DATEFORMAT_HELPERS_H +#define DATEFORMAT_HELPERS_H + +#ifndef __cplusplus +#error For C++ only +#endif + +#include + +extern "C" { +#include "../php_intl.h" +} + +int datefmt_process_calendar_arg(zval* calendar_zv, + Locale const& locale, + const char *func_name, + intl_error *err, + Calendar*& cal, + long& cal_int_type, + bool& calendar_owned TSRMLS_DC); + +#endif /* DATEFORMAT_HELPERS_H */ + diff --git a/ext/intl/formatter/formatter_main.c b/ext/intl/formatter/formatter_main.c index 5cb648332600a..d0671a88b5e47 100644 --- a/ext/intl/formatter/formatter_main.c +++ b/ext/intl/formatter/formatter_main.c @@ -56,7 +56,7 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) } if(locale_len == 0) { - locale = INTL_G(default_locale); + locale = intl_locale_get_default(TSRMLS_C); } /* Create an ICU number formatter. */ diff --git a/ext/intl/grapheme/grapheme.h b/ext/intl/grapheme/grapheme.h index c0e697ac1e55f..756ce9173e834 100644 --- a/ext/intl/grapheme/grapheme.h +++ b/ext/intl/grapheme/grapheme.h @@ -19,7 +19,6 @@ #include #include -#include PHP_FUNCTION(grapheme_strlen); PHP_FUNCTION(grapheme_strpos); diff --git a/ext/intl/intl_convertcpp.cpp b/ext/intl/intl_convertcpp.cpp new file mode 100644 index 0000000000000..f699a3c61c9a4 --- /dev/null +++ b/ext/intl/intl_convertcpp.cpp @@ -0,0 +1,89 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#include "intl_cppshims.h" + +#include "intl_convertcpp.h" +#include +extern "C" { +#include +} + +/* {{{ intl_stringFromChar */ +int intl_stringFromChar(UnicodeString &ret, char *str, int32_t str_len, UErrorCode *status) +{ + //the number of UTF-16 code units is not larger than that of UTF-8 code + //units, + 1 for the terminator + int32_t capacity = str_len + 1; + + //no check necessary -- if NULL will fail ahead + UChar *utf16 = ret.getBuffer(capacity); + int32_t utf16_len = 0; + *status = U_ZERO_ERROR; + u_strFromUTF8WithSub(utf16, ret.getCapacity(), &utf16_len, + str, str_len, U_SENTINEL /* no substitution */, NULL, + status); + ret.releaseBuffer(utf16_len); + if (U_FAILURE(*status)) { + ret.setToBogus(); + return FAILURE; + } + return SUCCESS; +} +/* }}} */ + +/* {{{ intl_charFromString + * faster than doing intl_convert_utf16_to_utf8(&res, &res_len, + * from.getBuffer(), from.length(), &status), + * but consumes more memory */ +int intl_charFromString(const UnicodeString &from, char **res, int *res_len, UErrorCode *status) +{ + if (from.isBogus()) { + return FAILURE; + } + + //the number of UTF-8 code units is not larger than that of UTF-16 code + //units * 3 + 1 for the terminator + int32_t capacity = from.length() * 3 + 1; + + if (from.isEmpty()) { + *res = (char*)emalloc(1); + **res = '\0'; + *res_len = 0; + return SUCCESS; + } + + *res = (char*)emalloc(capacity); + *res_len = 0; //tbd + + const UChar *utf16buf = from.getBuffer(); + int32_t actual_len; + u_strToUTF8WithSub(*res, capacity - 1, &actual_len, utf16buf, from.length(), + U_SENTINEL, NULL, status); + + if (U_FAILURE(*status)) { + efree(*res); + *res = NULL; + return FAILURE; + } + (*res)[actual_len] = '\0'; + *res_len = (int)actual_len; + + return SUCCESS; +} +/* }}} */ diff --git a/ext/intl/intl_convertcpp.h b/ext/intl/intl_convertcpp.h new file mode 100644 index 0000000000000..89d4209dd3f26 --- /dev/null +++ b/ext/intl/intl_convertcpp.h @@ -0,0 +1,32 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef INTL_CONVERTCPP_H +#define INTL_CONVERTCPP_H + +#ifndef __cplusplus +#error Should be included only in C++ Files +#endif + +#include + +int intl_stringFromChar(UnicodeString &ret, char *str, int32_t str_len, UErrorCode *status); + +int intl_charFromString(const UnicodeString &from, char **res, int *res_len, UErrorCode *status); + +#endif /* INTL_CONVERTCPP_H */ diff --git a/ext/intl/intl_cppshims.h b/ext/intl/intl_cppshims.h new file mode 100644 index 0000000000000..2fb70edfd0e20 --- /dev/null +++ b/ext/intl/intl_cppshims.h @@ -0,0 +1,34 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#ifndef INTL_CPPSHIMS_H +#define INTL_CPPSHIMS_H + +#ifndef __cplusplus +#error For inclusion form C++ files only +#endif + +#ifdef _MSC_VER +//This is only required for old versions of ICU only +#include + +#include + +/* avoid redefinition of int8_t, also defined in unicode/pwin32.h */ +#define _MSC_STDINT_H_ 1 +#endif + +#endif \ No newline at end of file diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c index 9c2e13dfd5c47..99b1c6001cd01 100644 --- a/ext/intl/intl_error.c +++ b/ext/intl/intl_error.c @@ -21,12 +21,16 @@ #endif #include +#include #include "php_intl.h" #include "intl_error.h" +#include "intl_convert.h" ZEND_EXTERN_MODULE_GLOBALS( intl ) +static zend_class_entry *IntlException_ce_ptr; + /* {{{ intl_error* intl_g_error_get() * Return global error structure. */ @@ -102,8 +106,11 @@ void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg TSRMLS_D if( !msg ) return; - if(!err && INTL_G(error_level)) { - php_error_docref(NULL TSRMLS_CC, INTL_G(error_level), "%s", msg); + if( !err ) { + if( INTL_G( error_level ) ) + php_error_docref( NULL TSRMLS_CC, INTL_G( error_level ), "%s", msg ); + if( INTL_G( use_exceptions ) ) + zend_throw_exception_ex( IntlException_ce_ptr, 0 TSRMLS_CC, "%s", msg ); } if( !err && !( err = intl_g_error_get( TSRMLS_C ) ) ) return; @@ -223,6 +230,96 @@ void intl_errors_set_code( intl_error* err, UErrorCode err_code TSRMLS_DC ) } /* }}} */ +void intl_register_IntlException_class( TSRMLS_D ) +{ + zend_class_entry ce, + *default_exception_ce; + + default_exception_ce = zend_exception_get_default( TSRMLS_C ); + + /* Create and register 'IntlException' class. */ + INIT_CLASS_ENTRY_EX( ce, "IntlException", sizeof( "IntlException" ) - 1, NULL ); + IntlException_ce_ptr = zend_register_internal_class_ex( &ce, + default_exception_ce, NULL TSRMLS_CC ); + IntlException_ce_ptr->create_object = default_exception_ce->create_object; +} + +smart_str intl_parse_error_to_string( UParseError* pe ) +{ + smart_str ret = {0}; + char *buf; + int u8len; + UErrorCode status; + int any = 0; + + assert( pe != NULL ); + + smart_str_appends( &ret, "parse error " ); + if( pe->line > 0 ) + { + smart_str_appends( &ret, "on line " ); + smart_str_append_long( &ret, (long ) pe->line ); + any = 1; + } + if( pe->offset >= 0 ) { + if( any ) + smart_str_appends( &ret, ", " ); + else + smart_str_appends( &ret, "at " ); + + smart_str_appends( &ret, "offset " ); + smart_str_append_long( &ret, (long ) pe->offset ); + any = 1; + } + + if (pe->preContext[0] != 0 ) { + if( any ) + smart_str_appends( &ret, ", " ); + + smart_str_appends( &ret, "after \"" ); + intl_convert_utf16_to_utf8( &buf, &u8len, pe->preContext, -1, &status ); + if( U_FAILURE( status ) ) + { + smart_str_appends( &ret, "(could not convert parser error pre-context to UTF-8)" ); + } + else { + smart_str_appendl( &ret, buf, u8len ); + efree( buf ); + } + smart_str_appends( &ret, "\"" ); + any = 1; + } + + if( pe->postContext[0] != 0 ) + { + if( any ) + smart_str_appends( &ret, ", " ); + + smart_str_appends( &ret, "before or at \"" ); + intl_convert_utf16_to_utf8( &buf, &u8len, pe->postContext, -1, &status ); + if( U_FAILURE( status ) ) + { + smart_str_appends( &ret, "(could not convert parser error post-context to UTF-8)" ); + } + else + { + smart_str_appendl( &ret, buf, u8len ); + efree( buf ); + } + smart_str_appends( &ret, "\"" ); + any = 1; + } + + if( !any ) + { + smart_str_free( &ret ); + smart_str_appends( &ret, "no parse error" ); + } + + smart_str_0( &ret ); + return ret; +} + /* * Local variables: * tab-width: 4 diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h index 3adae85474199..4d8eb79327f1e 100644 --- a/ext/intl/intl_error.h +++ b/ext/intl/intl_error.h @@ -20,6 +20,8 @@ #define INTL_ERROR_H #include +#include +#include #define INTL_ERROR_CODE(e) (e).code @@ -44,4 +46,10 @@ void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg void intl_errors_set_code( intl_error* err, UErrorCode err_code TSRMLS_DC ); void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg TSRMLS_DC ); +// Other error helpers +smart_str intl_parse_error_to_string( UParseError* pe ); + +// exported to be called on extension MINIT +void intl_register_IntlException_class( TSRMLS_D ); + #endif // INTL_ERROR_H diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index 1707c69f93324..d1a86d8ee27f4 100644 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c @@ -208,10 +208,7 @@ static int getSingletonPos(char* str) Get default locale */ PHP_NAMED_FUNCTION(zif_locale_get_default) { - if( INTL_G(default_locale) == NULL ) { - INTL_G(default_locale) = pestrdup( uloc_getDefault(), 1); - } - RETURN_STRING( INTL_G(default_locale), TRUE ); + RETURN_STRING( intl_locale_get_default( TSRMLS_C ), TRUE ); } /* }}} */ @@ -393,7 +390,7 @@ static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS) } if(loc_name_len == 0) { - loc_name = INTL_G(default_locale); + loc_name = intl_locale_get_default(TSRMLS_C); } /* Call ICU get */ @@ -499,7 +496,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME } if(loc_name_len == 0) { - loc_name = INTL_G(default_locale); + loc_name = intl_locale_get_default(TSRMLS_C); } if( strcmp(tag_name, DISP_NAME) != 0 ){ @@ -521,7 +518,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME /* Check if disp_loc_name passed , if not use default locale */ if( !disp_loc_name){ - disp_loc_name = estrdup(INTL_G(default_locale)); + disp_loc_name = estrdup(intl_locale_get_default(TSRMLS_C)); free_loc_name = 1; } @@ -693,7 +690,7 @@ PHP_FUNCTION( locale_get_keywords ) } if(loc_name_len == 0) { - loc_name = INTL_G(default_locale); + loc_name = intl_locale_get_default(TSRMLS_C); } /* Get the keywords */ @@ -1100,7 +1097,7 @@ PHP_FUNCTION(locale_parse) } if(loc_name_len == 0) { - loc_name = INTL_G(default_locale); + loc_name = intl_locale_get_default(TSRMLS_C); } array_init( return_value ); @@ -1148,7 +1145,7 @@ PHP_FUNCTION(locale_get_all_variants) } if(loc_name_len == 0) { - loc_name = INTL_G(default_locale); + loc_name = intl_locale_get_default(TSRMLS_C); } @@ -1254,7 +1251,7 @@ PHP_FUNCTION(locale_filter_matches) } if(loc_range_len == 0) { - loc_range = INTL_G(default_locale); + loc_range = intl_locale_get_default(TSRMLS_C); } if( strcmp(loc_range,"*")==0){ @@ -1540,7 +1537,7 @@ PHP_FUNCTION(locale_lookup) } if(loc_range_len == 0) { - loc_range = INTL_G(default_locale); + loc_range = intl_locale_get_default(TSRMLS_C); } hash_arr = HASH_OF(arr); diff --git a/ext/intl/msgformat/msgformat.c b/ext/intl/msgformat/msgformat.c index e3fb9425a9c52..6a9f04f32b463 100644 --- a/ext/intl/msgformat/msgformat.c +++ b/ext/intl/msgformat/msgformat.c @@ -61,7 +61,7 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) } if(locale_len == 0) { - locale = INTL_G(default_locale); + locale = intl_locale_get_default(TSRMLS_C); } #ifdef MSG_FORMAT_QUOTE_APOS diff --git a/ext/intl/msgformat/msgformat_attr.c b/ext/intl/msgformat/msgformat_attr.c index ed2dae27d1318..c333a24ee1d1e 100644 --- a/ext/intl/msgformat/msgformat_attr.c +++ b/ext/intl/msgformat/msgformat_attr.c @@ -102,6 +102,12 @@ PHP_FUNCTION( msgfmt_set_pattern ) } mfo->mf_data.orig_format = estrndup(value, value_len); mfo->mf_data.orig_format_len = value_len; + /* invalidate cached format types */ + if (mfo->mf_data.arg_types) { + zend_hash_destroy(mfo->mf_data.arg_types); + efree(mfo->mf_data.arg_types); + mfo->mf_data.arg_types = NULL; + } RETURN_TRUE; } diff --git a/ext/intl/msgformat/msgformat_data.c b/ext/intl/msgformat/msgformat_data.c index 527c1d4d179a4..5d490544735fa 100644 --- a/ext/intl/msgformat/msgformat_data.c +++ b/ext/intl/msgformat/msgformat_data.c @@ -31,8 +31,10 @@ void msgformat_data_init( msgformat_data* mf_data TSRMLS_DC ) if( !mf_data ) return; - mf_data->umsgf = NULL; - mf_data->orig_format = NULL; + mf_data->umsgf = NULL; + mf_data->orig_format = NULL; + mf_data->arg_types = NULL; + mf_data->tz_set = 0; intl_error_reset( &mf_data->error TSRMLS_CC ); } /* }}} */ @@ -40,21 +42,27 @@ void msgformat_data_init( msgformat_data* mf_data TSRMLS_DC ) /* {{{ void msgformat_data_free( msgformat_data* mf_data ) * Clean up memory allocated for msgformat_data */ -void msgformat_data_free( msgformat_data* mf_data TSRMLS_DC ) +void msgformat_data_free(msgformat_data* mf_data TSRMLS_DC) { - if( !mf_data ) + if (!mf_data) return; - if( mf_data->umsgf ) - umsg_close( mf_data->umsgf ); + if (mf_data->umsgf) + umsg_close(mf_data->umsgf); - if(mf_data->orig_format) { + if (mf_data->orig_format) { efree(mf_data->orig_format); mf_data->orig_format = NULL; } + if (mf_data->arg_types) { + zend_hash_destroy(mf_data->arg_types); + efree(mf_data->arg_types); + mf_data->arg_types = NULL; + } + mf_data->umsgf = NULL; - intl_error_reset( &mf_data->error TSRMLS_CC ); + intl_error_reset(&mf_data->error TSRMLS_CC); } /* }}} */ diff --git a/ext/intl/msgformat/msgformat_data.h b/ext/intl/msgformat/msgformat_data.h index 6479888f8fcf3..51d7687a3a5e4 100644 --- a/ext/intl/msgformat/msgformat_data.h +++ b/ext/intl/msgformat/msgformat_data.h @@ -31,6 +31,8 @@ typedef struct { UMessageFormat* umsgf; char* orig_format; ulong orig_format_len; + HashTable* arg_types; + int tz_set; /* if we've already the time zone in sub-formats */ } msgformat_data; msgformat_data* msgformat_data_create( TSRMLS_D ); diff --git a/ext/intl/msgformat/msgformat_format.c b/ext/intl/msgformat/msgformat_format.c index 9a18ac0a70fbf..4b81cfe2b454c 100644 --- a/ext/intl/msgformat/msgformat_format.c +++ b/ext/intl/msgformat/msgformat_format.c @@ -32,51 +32,34 @@ #endif /* {{{ */ -static void msgfmt_do_format(MessageFormatter_object *mfo, zval *args, zval *return_value TSRMLS_DC) +static void msgfmt_do_format(MessageFormatter_object *mfo, zval *args, zval *return_value TSRMLS_DC) { - zval **fargs; int count; UChar* formatted = NULL; int formatted_len = 0; - HashPosition pos; - int i; + HashTable *args_copy; count = zend_hash_num_elements(Z_ARRVAL_P(args)); - if(count < umsg_format_arg_count(MSG_FORMAT_OBJECT(mfo))) { - /* Not enough aguments for format! */ - intl_error_set( INTL_DATA_ERROR_P(mfo), U_ILLEGAL_ARGUMENT_ERROR, - "msgfmt_format: not enough parameters", 0 TSRMLS_CC ); - RETVAL_FALSE; - return; - } - - fargs = safe_emalloc(count, sizeof(zval *), 0); + ALLOC_HASHTABLE(args_copy); + zend_hash_init(args_copy, count, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(args_copy, Z_ARRVAL_P(args), (copy_ctor_func_t)zval_add_ref, + NULL, sizeof(zval*)); - zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos); - for(i=0;i +#include "../intl_cppshims.h" + +#include #include #include +#include +#include +#include +#include + +#include + +#include "../intl_convertcpp.h" +#include "../common/common_date.h" extern "C" { #include "php_intl.h" @@ -28,8 +39,14 @@ extern "C" { #include "msgformat_format.h" #include "msgformat_helpers.h" #include "intl_convert.h" +#define USE_TIMEZONE_POINTER +#include "../timezone/timezone_class.h" } +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 +#define HAS_MESSAGE_PATTERN 1 +#endif + U_NAMESPACE_BEGIN /** * This class isolates our access to private internal methods of @@ -40,96 +57,578 @@ class MessageFormatAdapter { public: static const Formattable::Type* getArgTypeList(const MessageFormat& m, int32_t& count); +#ifdef HAS_MESSAGE_PATTERN + static const MessagePattern getMessagePattern(MessageFormat* m); +#endif }; + const Formattable::Type* MessageFormatAdapter::getArgTypeList(const MessageFormat& m, int32_t& count) { return m.getArgTypeList(count); } + +#ifdef HAS_MESSAGE_PATTERN +const MessagePattern +MessageFormatAdapter::getMessagePattern(MessageFormat* m) { + return m->msgPattern; +} +#endif U_NAMESPACE_END -U_CFUNC int32_t umsg_format_arg_count(UMessageFormat *fmt) +U_CFUNC int32_t umsg_format_arg_count(UMessageFormat *fmt) { int32_t fmt_count = 0; MessageFormatAdapter::getArgTypeList(*(const MessageFormat*)fmt, fmt_count); return fmt_count; } -U_CFUNC void umsg_format_helper(UMessageFormat *fmt, int arg_count, zval **args, UChar **formatted, int *formatted_len, UErrorCode *status TSRMLS_DC) +static HashTable *umsg_get_numeric_types(MessageFormatter_object *mfo, + intl_error& err TSRMLS_DC) { - int fmt_count = 0; - const Formattable::Type* argTypes = - MessageFormatAdapter::getArgTypeList(*(const MessageFormat*)fmt, fmt_count); - Formattable* fargs = new Formattable[fmt_count ? fmt_count : 1]; + HashTable *ret; + int32_t parts_count; - for(int32_t i = 0; i < fmt_count; ++i) { - UChar *stringVal = NULL; - int stringLen = 0; - int64_t tInt64 = 0; + if (U_FAILURE(err.code)) { + return NULL; + } - switch(argTypes[i]) { - case Formattable::kDate: - convert_to_long_ex(&args[i]); - fargs[i].setDate(U_MILLIS_PER_SECOND * (double)Z_LVAL_P(args[i])); - break; + if (mfo->mf_data.arg_types) { + /* already cached */ + return mfo->mf_data.arg_types; + } - case Formattable::kDouble: - convert_to_double_ex(&args[i]); - fargs[i].setDouble(Z_DVAL_P(args[i])); - break; - - case Formattable::kLong: - convert_to_long_ex(&args[i]); - fargs[i].setLong(Z_LVAL_P(args[i])); - break; + const Formattable::Type *types = MessageFormatAdapter::getArgTypeList( + *(MessageFormat*)mfo->mf_data.umsgf, parts_count); + + /* Hash table will store Formattable::Type objects directly, + * so no need for destructor */ + ALLOC_HASHTABLE(ret); + zend_hash_init(ret, parts_count, NULL, NULL, 0); + + for (int i = 0; i < parts_count; i++) { + const Formattable::Type t = types[i]; + if (zend_hash_index_update(ret, (ulong)i, (void*)&t, sizeof(t), NULL) + == FAILURE) { + intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR, + "Write to argument types hash table failed", 0 TSRMLS_CC); + break; + } + } + + if (U_FAILURE(err.code)) { + zend_hash_destroy(ret); + efree(ret); + + return NULL; + } + + mfo->mf_data.arg_types = ret; - case Formattable::kInt64: - if(Z_TYPE_P(args[i]) == IS_DOUBLE) { - tInt64 = (int64_t)Z_DVAL_P(args[i]); - } else if(Z_TYPE_P(args[i]) == IS_LONG) { - tInt64 = (int64_t)Z_LVAL_P(args[i]); + return ret; +} + +#ifdef HAS_MESSAGE_PATTERN +static HashTable *umsg_parse_format(MessageFormatter_object *mfo, + const MessagePattern& mp, + intl_error& err TSRMLS_DC) +{ + HashTable *ret; + int32_t parts_count; + + if (U_FAILURE(err.code)) { + return NULL; + } + + if (!((MessageFormat *)mfo->mf_data.umsgf)->usesNamedArguments()) { + return umsg_get_numeric_types(mfo, err TSRMLS_CC); + } + + if (mfo->mf_data.arg_types) { + /* already cached */ + return mfo->mf_data.arg_types; + } + + /* Hash table will store Formattable::Type objects directly, + * so no need for destructor */ + ALLOC_HASHTABLE(ret); + zend_hash_init(ret, 32, NULL, NULL, 0); + + parts_count = mp.countParts(); + + // See MessageFormat::cacheExplicitFormats() + /* + * Looking through the pattern, go to each arg_start part type. + * The arg-typeof that tells us the argument type (simple, complicated) + * then the next part is either the arg_name or arg number + * and then if it's simple after that there could be a part-type=arg-type + * while substring will tell us number, spellout, etc. + * If the next thing isn't an arg-type then assume string. + */ + /* The last two "parts" can at most be ARG_LIMIT and MSG_LIMIT + * which we need not examine. */ + for (int32_t i = 0; i < parts_count - 2 && U_SUCCESS(err.code); i++) { + MessagePattern::Part p = mp.getPart(i); + + if (p.getType() != UMSGPAT_PART_TYPE_ARG_START) { + continue; + } + + MessagePattern::Part name_part = mp.getPart(++i); /* Getting name, advancing i */ + Formattable::Type type, + *storedType; + + if (name_part.getType() == UMSGPAT_PART_TYPE_ARG_NAME) { + UnicodeString argName = mp.getSubstring(name_part); + if (zend_hash_find(ret, (char*)argName.getBuffer(), argName.length(), + (void**)&storedType) == FAILURE) { + /* not found already; create new entry in HT */ + Formattable::Type bogusType = Formattable::kObject; + if (zend_hash_update(ret, (char*)argName.getBuffer(), argName.length(), + (void*)&bogusType, sizeof(bogusType), (void**)&storedType) == FAILURE) { + intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR, + "Write to argument types hash table failed", 0 TSRMLS_CC); + continue; + } + } + } else if (name_part.getType() == UMSGPAT_PART_TYPE_ARG_NUMBER) { + int32_t argNumber = name_part.getValue(); + if (argNumber < 0) { + intl_errors_set(&err, U_INVALID_FORMAT_ERROR, + "Found part with negative number", 0 TSRMLS_CC); + continue; + } + if (zend_hash_index_find(ret, (ulong)argNumber, (void**)&storedType) + == FAILURE) { + /* not found already; create new entry in HT */ + Formattable::Type bogusType = Formattable::kObject; + if (zend_hash_index_update(ret, (ulong)argNumber, (void*)&bogusType, + sizeof(bogusType), (void**)&storedType) == FAILURE) { + intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR, + "Write to argument types hash table failed", 0 TSRMLS_CC); + continue; + } + } + } + + UMessagePatternArgType argType = p.getArgType(); + /* No type specified, treat it as a string */ + if (argType == UMSGPAT_ARG_TYPE_NONE) { + type = Formattable::kString; + } else { /* Some type was specified, might be simple or complicated */ + if (argType == UMSGPAT_ARG_TYPE_SIMPLE) { + /* For a SIMPLE arg, after the name part, there should be + * an ARG_TYPE part whose string value tells us what to do */ + MessagePattern::Part type_part = mp.getPart(++i); /* Getting type, advancing i */ + if (type_part.getType() == UMSGPAT_PART_TYPE_ARG_TYPE) { + UnicodeString typeString = mp.getSubstring(type_part); + /* This is all based on the rules in the docs for MessageFormat + * @see http://icu-project.org/apiref/icu4c/classMessageFormat.html */ + if (typeString == "number") { + MessagePattern::Part style_part = mp.getPart(i + 1); /* Not advancing i */ + if (style_part.getType() == UMSGPAT_PART_TYPE_ARG_STYLE) { + UnicodeString styleString = mp.getSubstring(style_part); + if (styleString == "integer") { + type = Formattable::kInt64; + } else if (styleString == "currency") { + type = Formattable::kDouble; + } else if (styleString == "percent") { + type = Formattable::kDouble; + } else { /* some style invalid/unknown to us */ + type = Formattable::kDouble; + } + } else { // if missing style, part, make it a double + type = Formattable::kDouble; + } + } else if ((typeString == "date") || (typeString == "time")) { + type = Formattable::kDate; + } else if ((typeString == "spellout") || (typeString == "ordinal") + || (typeString == "duration")) { + type = Formattable::kDouble; + } } else { - SEPARATE_ZVAL_IF_NOT_REF(&args[i]); - convert_scalar_to_number( args[i] TSRMLS_CC ); - tInt64 = (Z_TYPE_P(args[i]) == IS_DOUBLE)?(int64_t)Z_DVAL_P(args[i]):Z_LVAL_P(args[i]); + /* If there's no UMSGPAT_PART_TYPE_ARG_TYPE right after a + * UMSGPAT_ARG_TYPE_SIMPLE argument, then the pattern + * is broken. */ + intl_errors_set(&err, U_PARSE_ERROR, + "Expected UMSGPAT_PART_TYPE_ARG_TYPE part following " + "UMSGPAT_ARG_TYPE_SIMPLE part", 0 TSRMLS_CC); + continue; + } + } else if (argType == UMSGPAT_ARG_TYPE_PLURAL) { + type = Formattable::kDouble; + } else if (argType == UMSGPAT_ARG_TYPE_CHOICE) { + type = Formattable::kDouble; + } else if (argType == UMSGPAT_ARG_TYPE_SELECT) { + type = Formattable::kString; + } else { + type = Formattable::kString; + } + } /* was type specified? */ + + /* We found a different type for the same arg! */ + if (*storedType != Formattable::kObject && *storedType != type) { + intl_errors_set(&err, U_ARGUMENT_TYPE_MISMATCH, + "Inconsistent types declared for an argument", 0 TSRMLS_CC); + continue; + } + + *storedType = type; + } /* visiting each part */ + + if (U_FAILURE(err.code)) { + zend_hash_destroy(ret); + efree(ret); + + return NULL; + } + + mfo->mf_data.arg_types = ret; + + return ret; +} +#endif + +static HashTable *umsg_get_types(MessageFormatter_object *mfo, + intl_error& err TSRMLS_DC) +{ + MessageFormat *mf = (MessageFormat *)mfo->mf_data.umsgf; + +#ifdef HAS_MESSAGE_PATTERN + const MessagePattern mp = MessageFormatAdapter::getMessagePattern(mf); + + return umsg_parse_format(mfo, mp, err TSRMLS_CC); +#else + if (mf->usesNamedArguments()) { + intl_errors_set(&err, U_UNSUPPORTED_ERROR, + "This extension supports named arguments only on ICU 4.8+", + 0 TSRMLS_CC); + return NULL; + } + return umsg_get_numeric_types(mfo, err TSRMLS_CC); +#endif +} + +static void umsg_set_timezone(MessageFormatter_object *mfo, + intl_error& err TSRMLS_DC) +{ + MessageFormat *mf = (MessageFormat *)mfo->mf_data.umsgf; + TimeZone *used_tz = NULL; + const Format **formats; + int32_t count; + + /* Unfortanely, this cannot change the time zone for arguments that + * appear inside complex formats because ::getFormats() returns NULL + * for all uncached formats, which is the case for complex formats + * unless they were set via one of the ::setFormat() methods */ + + if (mfo->mf_data.tz_set) { + return; /* already done */ + } + + formats = mf->getFormats(count); + + if (formats == NULL) { + intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR, + "Out of memory retrieving subformats", 0 TSRMLS_CC); + } + + for (int i = 0; U_SUCCESS(err.code) && i < count; i++) { + DateFormat* df = dynamic_cast( + const_cast(formats[i])); + if (df == NULL) { + continue; + } + + if (used_tz == NULL) { + zval nullzv = zval_used_for_init, + *zvptr = &nullzv; + used_tz = timezone_process_timezone_argument(&zvptr, &err, + "msgfmt_format" TSRMLS_CC); + if (used_tz == NULL) { + continue; + } + } + + df->setTimeZone(*used_tz); + } + + if (U_SUCCESS(err.code)) { + mfo->mf_data.tz_set = 1; + } +} + +U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, + HashTable *args, + UChar **formatted, + int *formatted_len TSRMLS_DC) +{ + int arg_count = zend_hash_num_elements(args); + std::vector fargs; + std::vector farg_names; + MessageFormat *mf = (MessageFormat *)mfo->mf_data.umsgf; + HashTable *types; + intl_error& err = INTL_DATA_ERROR(mfo); + + if (U_FAILURE(err.code)) { + return; + } + + types = umsg_get_types(mfo, err TSRMLS_CC); + + umsg_set_timezone(mfo, err TSRMLS_CC); + + fargs.resize(arg_count); + farg_names.resize(arg_count); + + int argNum = 0; + HashPosition pos; + zval **elem; + + // Key related variables + int key_type; + char *str_index; + uint str_len; + ulong num_index; + + for (zend_hash_internal_pointer_reset_ex(args, &pos); + U_SUCCESS(err.code) && + (key_type = zend_hash_get_current_key_ex( + args, &str_index, &str_len, &num_index, 0, &pos), + zend_hash_get_current_data_ex(args, (void **)&elem, &pos) + ) == SUCCESS; + zend_hash_move_forward_ex(args, &pos), argNum++) + { + Formattable& formattable = fargs[argNum]; + UnicodeString& key = farg_names[argNum]; + Formattable::Type argType = Formattable::kObject, //unknown + *storedArgType = NULL; + + /* Process key and retrieve type */ + if (key_type == HASH_KEY_IS_LONG) { + /* includes case where index < 0 because it's exposed as unsigned */ + if (num_index > (ulong)INT32_MAX) { + intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, + "Found negative or too large array key", 0 TSRMLS_CC); + continue; + } + + UChar temp[16]; + int32_t len = u_sprintf(temp, "%u", (uint32_t)num_index); + key.append(temp, len); + + zend_hash_index_find(types, (ulong)num_index, (void**)&storedArgType); + } else { //string; assumed to be in UTF-8 + intl_stringFromChar(key, str_index, str_len-1, &err.code); + + if (U_FAILURE(err.code)) { + char *message; + spprintf(&message, 0, + "Invalid UTF-8 data in argument key: '%s'", str_index); + intl_errors_set(&err, err.code, message, 1 TSRMLS_CC); + efree(message); + continue; + } + + zend_hash_find(types, (char*)key.getBuffer(), key.length(), + (void**)&storedArgType); + } + + if (storedArgType != NULL) { + argType = *storedArgType; + } + + /* Convert zval to formattable according to message format type + * or (as a fallback) the zval type */ + if (argType != Formattable::kObject) { + switch (argType) { + case Formattable::kString: + { + string_arg: + /* This implicitly converts objects + * Note that our vectors will leak if object conversion fails + * and PHP ends up with a fatal error and calls longjmp + * as a result of that. + */ + convert_to_string_ex(elem); + + UnicodeString *text = new UnicodeString(); + intl_stringFromChar(*text, + Z_STRVAL_PP(elem), Z_STRLEN_PP(elem), &err.code); + + if (U_FAILURE(err.code)) { + char *message; + spprintf(&message, 0, "Invalid UTF-8 data in string argument: " + "'%s'", Z_STRVAL_PP(elem)); + intl_errors_set(&err, err.code, message, 1 TSRMLS_CC); + efree(message); + delete text; + continue; + } + formattable.adoptString(text); + break; } - fargs[i].setInt64(tInt64); + case Formattable::kDouble: + { + double d; + if (Z_TYPE_PP(elem) == IS_DOUBLE) { + d = Z_DVAL_PP(elem); + } else if (Z_TYPE_PP(elem) == IS_LONG) { + d = (double)Z_LVAL_PP(elem); + } else { + SEPARATE_ZVAL_IF_NOT_REF(elem); + convert_scalar_to_number(*elem TSRMLS_CC); + d = (Z_TYPE_PP(elem) == IS_DOUBLE) + ? Z_DVAL_PP(elem) + : (double)Z_LVAL_PP(elem); + } + formattable.setDouble(d); + break; + } + case Formattable::kLong: + { + int32_t tInt32; +retry_klong: + if (Z_TYPE_PP(elem) == IS_DOUBLE) { + if (Z_DVAL_PP(elem) > (double)INT32_MAX || + Z_DVAL_PP(elem) < (double)INT32_MIN) { + intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, + "Found PHP float with absolute value too large for " + "32 bit integer argument", 0 TSRMLS_CC); + } else { + tInt32 = (int32_t)Z_DVAL_PP(elem); + } + } else if (Z_TYPE_PP(elem) == IS_LONG) { + if (Z_LVAL_PP(elem) > INT32_MAX || + Z_LVAL_PP(elem) < INT32_MIN) { + intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, + "Found PHP integer with absolute value too large " + "for 32 bit integer argument", 0 TSRMLS_CC); + } else { + tInt32 = (int32_t)Z_LVAL_PP(elem); + } + } else { + SEPARATE_ZVAL_IF_NOT_REF(elem); + convert_scalar_to_number(*elem TSRMLS_CC); + goto retry_klong; + } + formattable.setLong(tInt32); + break; + } + case Formattable::kInt64: + { + int64_t tInt64; +retry_kint64: + if (Z_TYPE_PP(elem) == IS_DOUBLE) { + if (Z_DVAL_PP(elem) > (double)U_INT64_MAX || + Z_DVAL_PP(elem) < (double)U_INT64_MIN) { + intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, + "Found PHP float with absolute value too large for " + "64 bit integer argument", 0 TSRMLS_CC); + } else { + tInt64 = (int64_t)Z_DVAL_PP(elem); + } + } else if (Z_TYPE_PP(elem) == IS_LONG) { + /* assume long is not wider than 64 bits */ + tInt64 = (int64_t)Z_LVAL_PP(elem); + } else { + SEPARATE_ZVAL_IF_NOT_REF(elem); + convert_scalar_to_number(*elem TSRMLS_CC); + goto retry_kint64; + } + formattable.setInt64(tInt64); + break; + } + case Formattable::kDate: + { + double dd = intl_zval_to_millis(*elem, &err, "msgfmt_format" TSRMLS_CC); + if (U_FAILURE(err.code)) { + char *message, *key_char; + int key_len; + UErrorCode status = UErrorCode(); + if (intl_charFromString(key, &key_char, &key_len, + &status) == SUCCESS) { + spprintf(&message, 0, "The argument for key '%s' " + "cannot be used as a date or time", key_char); + intl_errors_set(&err, err.code, message, 1 TSRMLS_CC); + efree(key_char); + efree(message); + } + continue; + } + formattable.setDate(dd); + break; + } + default: + intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, + "Found unsupported argument type", 0 TSRMLS_CC); + break; + } + } else { + /* We couldn't find any information about the argument in the pattern, this + * means it's an extra argument. So convert it to a number if it's a number or + * bool or null and to a string if it's anything else except arrays . */ + switch (Z_TYPE_PP(elem)) { + case IS_DOUBLE: + formattable.setDouble(Z_DVAL_PP(elem)); break; - - case Formattable::kString: - convert_to_string_ex(&args[i]); - intl_convert_utf8_to_utf16(&stringVal, &stringLen, Z_STRVAL_P(args[i]), Z_STRLEN_P(args[i]), status); - if(U_FAILURE(*status)){ - delete[] fargs; - return; + case IS_BOOL: + convert_to_long_ex(elem); + /* Intentional fallthrough */ + case IS_LONG: + formattable.setInt64((int64_t)Z_LVAL_PP(elem)); + break; + case IS_NULL: + formattable.setInt64((int64_t)0); + break; + case IS_STRING: + case IS_OBJECT: + goto string_arg; + default: + { + char *message, *key_char; + int key_len; + UErrorCode status = UErrorCode(); + if (intl_charFromString(key, &key_char, &key_len, + &status) == SUCCESS) { + spprintf(&message, 0, "No strategy to convert the " + "value given for the argument with key '%s' " + "is available", key_char); + intl_errors_set(&err, + U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); + efree(key_char); + efree(message); + } } - fargs[i].setString(stringVal); - efree(stringVal); - break; - - case Formattable::kArray: - case Formattable::kObject: - *status = U_UNSUPPORTED_ERROR; - delete[] fargs; - return; - } + } + } + } // visiting each argument + + if (U_FAILURE(err.code)) { + return; } - UnicodeString resultStr; - FieldPosition fieldPosition(0); - - /* format the message */ - ((const MessageFormat*)fmt)->format(fargs, fmt_count, resultStr, fieldPosition, *status); + UnicodeString resultStr; + FieldPosition fieldPosition(0); - delete[] fargs; + /* format the message */ + mf->format(farg_names.empty() ? NULL : &farg_names[0], + fargs.empty() ? NULL : &fargs[0], arg_count, resultStr, err.code); - if(U_FAILURE(*status)){ - return; - } + if (U_FAILURE(err.code)) { + intl_errors_set(&err, err.code, + "Call to ICU MessageFormat::format() has failed", 0 TSRMLS_CC); + return; + } *formatted_len = resultStr.length(); *formatted = eumalloc(*formatted_len+1); - resultStr.extract(*formatted, *formatted_len+1, *status); + resultStr.extract(*formatted, *formatted_len+1, err.code); + if (U_FAILURE(err.code)) { + intl_errors_set(&err, err.code, + "Error copying format() result", 0 TSRMLS_CC); + return; + } } #define cleanup_zvals() for(int j=i;j>=0;j--) { zval_ptr_dtor((*args)+i); } @@ -154,15 +653,11 @@ U_CFUNC void umsg_parse_helper(UMessageFormat *fmt, int *count, zval ***args, UC int stmp_len; ALLOC_INIT_ZVAL((*args)[i]); - + switch(fargs[i].getType()) { case Formattable::kDate: aDate = ((double)fargs[i].getDate())/U_MILLIS_PER_SECOND; - if(aDate > LONG_MAX || aDate < -LONG_MAX) { - ZVAL_DOUBLE((*args)[i], aDate<0?ceil(aDate):floor(aDate)); - } else { - ZVAL_LONG((*args)[i], (long)aDate); - } + ZVAL_DOUBLE((*args)[i], aDate); break; case Formattable::kDouble: diff --git a/ext/intl/msgformat/msgformat_helpers.h b/ext/intl/msgformat/msgformat_helpers.h index 30c7e3930fa01..e6eda087d2e26 100644 --- a/ext/intl/msgformat/msgformat_helpers.h +++ b/ext/intl/msgformat/msgformat_helpers.h @@ -17,9 +17,9 @@ #ifndef MSG_FORMAT_HELPERS_H #define MSG_FORMAT_HELPERS_H -int32_t umsg_format_arg_count(UMessageFormat *fmt); -void umsg_format_helper(UMessageFormat *fmt, int arg_count, zval **args, - UChar **formatted, int *formatted_len, UErrorCode *status TSRMLS_DC); +int32_t umsg_format_arg_count(UMessageFormat *fmt); +void umsg_format_helper(MessageFormatter_object *mfo, HashTable *args, + UChar **formatted, int *formatted_len TSRMLS_DC); void umsg_parse_helper(UMessageFormat *fmt, int *count, zval ***args, UChar *source, int source_len, UErrorCode *status); #endif // MSG_FORMAT_HELPERS_H diff --git a/ext/intl/msgformat/msgformat_parse.c b/ext/intl/msgformat/msgformat_parse.c index f540b1d0c4a4a..413d3b1f15d89 100644 --- a/ext/intl/msgformat/msgformat_parse.c +++ b/ext/intl/msgformat/msgformat_parse.c @@ -126,7 +126,7 @@ PHP_FUNCTION( msgfmt_parse_message ) } if(slocale_len == 0) { - slocale = INTL_G(default_locale); + slocale = intl_locale_get_default(TSRMLS_C); } #ifdef MSG_FORMAT_QUOTE_APOS diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index 90e3573c1b51d..a2c4d77651d4b 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -34,6 +34,8 @@ #include "collator/collator_create.h" #include "collator/collator_error.h" +#include "converter/converter.h" + #include "formatter/formatter.h" #include "formatter/formatter_class.h" #include "formatter/formatter_attr.h" @@ -41,6 +43,8 @@ #include "formatter/formatter_main.h" #include "formatter/formatter_parse.h" +#include "grapheme/grapheme.h" + #include "msgformat/msgformat.h" #include "msgformat/msgformat_class.h" #include "msgformat/msgformat_attr.h" @@ -58,7 +62,9 @@ #include "dateformat/dateformat.h" #include "dateformat/dateformat_class.h" #include "dateformat/dateformat_attr.h" +#include "dateformat/dateformat_attrcpp.h" #include "dateformat/dateformat_format.h" +#include "dateformat/dateformat_format_object.h" #include "dateformat/dateformat_parse.h" #include "dateformat/dateformat_data.h" @@ -68,6 +74,16 @@ #include "transliterator/transliterator_class.h" #include "transliterator/transliterator_methods.h" +#include "timezone/timezone_class.h" +#include "timezone/timezone_methods.h" + +#include "calendar/calendar_class.h" +#include "calendar/calendar_methods.h" +#include "calendar/gregoriancalendar_methods.h" + +#include "breakiterator/breakiterator_class.h" +#include "breakiterator/breakiterator_iterators.h" + #include "idn/idn.h" #if U_ICU_VERSION_MAJOR_NUM * 1000 + U_ICU_VERSION_MINOR_NUM >= 4002 @@ -79,8 +95,10 @@ #include "msgformat/msgformat.h" #include "common/common_error.h" +#include "common/common_enum.h" #include +#include #include #include "php_ini.h" @@ -98,6 +116,14 @@ ZEND_DECLARE_MODULE_GLOBALS( intl ) +const char *intl_locale_get_default( TSRMLS_D ) +{ + if( INTL_G(default_locale) == NULL ) { + return uloc_getDefault(); + } + return INTL_G(default_locale); +} + /* {{{ Arguments info */ ZEND_BEGIN_ARG_INFO_EX(collator_static_0_args, 0, 0, 0) ZEND_END_ARG_INFO() @@ -313,6 +339,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_set_pattern, 0, 0, 2) ZEND_ARG_INFO(0, pattern) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_set_timezone, 0, 0, 2) + ZEND_ARG_INFO(0, mf) + ZEND_ARG_INFO(0, timezone) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_set_calendar, 0, 0, 2) ZEND_ARG_INFO(0, mf) ZEND_ARG_INFO(0, calendar) @@ -323,6 +354,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_format, 0, 0, 0) ZEND_ARG_INFO(0, array) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_format_object, 0, 0, 1) + ZEND_ARG_INFO(0, object) + ZEND_ARG_INFO(0, format) + ZEND_ARG_INFO(0, locale) +ZEND_END_ARG_INFO() + + ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_create, 0, 0, 3) ZEND_ARG_INFO(0, locale) ZEND_ARG_INFO(0, date_type) @@ -402,6 +440,189 @@ ZEND_BEGIN_ARG_INFO_EX( arginfo_transliterator_error, 0, 0, 1 ) ZEND_ARG_OBJ_INFO( 0, trans, Transliterator, 0 ) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_idarg_static, 0, 0, 1 ) + ZEND_ARG_INFO( 0, zoneId ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_from_date_time_zone, 0, 0, 1 ) + ZEND_ARG_OBJ_INFO( 0, dateTimeZone, IntlDateTimeZone, 0 ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_create_enumeration, 0, 0, 0 ) + ZEND_ARG_INFO( 0, countryOrRawOffset ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_count_equivalent_ids, 0, 0, 1 ) + ZEND_ARG_INFO( 0, zoneId ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_create_time_zone_id_enumeration, 0, 0, 1 ) + ZEND_ARG_INFO( 0, zoneType ) + ZEND_ARG_INFO( 0, region ) + ZEND_ARG_INFO( 0, rawOffset ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_canonical_id, 0, 0, 1 ) + ZEND_ARG_INFO( 0, zoneId ) + ZEND_ARG_INFO( 1, isSystemID ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_equivalent_id, 0, 0, 2 ) + ZEND_ARG_INFO( 0, zoneId ) + ZEND_ARG_INFO( 0, index ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_offset, 0, 0, 5 ) + ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 ) + ZEND_ARG_INFO( 0, date ) + ZEND_ARG_INFO( 0, local ) + ZEND_ARG_INFO( 1, rawOffset ) + ZEND_ARG_INFO( 1, dstOffset ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_has_same_rules, 0, 0, 1 ) + ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 ) + ZEND_ARG_OBJ_INFO( 0, otherTimeZone, IntlTimeZone, 0 ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_display_name, 0, 0, 1 ) + ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 ) + ZEND_ARG_INFO( 0, isDaylight ) + ZEND_ARG_INFO( 0, style ) + ZEND_ARG_INFO( 0, locale ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_only_tz, 0, 0, 1 ) + ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_void, 0, 0, 0 ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_create_instance, 0, 0, 0 ) + ZEND_ARG_INFO( 0, timeZone ) + ZEND_ARG_INFO( 0, locale ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_only_cal, 0, 0, 1 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_void, 0, 0, 0 ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_field, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, field ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_dow, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, dayOfWeek ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_other_cal, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_OBJ_INFO( 0, otherCalendar, IntlCalendar, 0 ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_date, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, date ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_date_optional, 0, 0, 1 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, date ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_get_keyword_values_for_locale, 0, 0, 3) + ZEND_ARG_INFO( 0, key ) + ZEND_ARG_INFO( 0, locale ) + ZEND_ARG_INFO( 0, commonlyUsed ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_add, 0, 0, 3 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, field ) + ZEND_ARG_INFO( 0, amount ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set_time_zone, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, timeZone ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set, 0, 0, 3 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, fieldOrYear ) + ZEND_ARG_INFO( 0, valueOrMonth ) + ZEND_ARG_INFO( 0, dayOfMonth ) + ZEND_ARG_INFO( 0, hour ) + ZEND_ARG_INFO( 0, minute ) + ZEND_ARG_INFO( 0, second ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_roll, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, field ) + ZEND_ARG_INFO( 0, amountOrUpOrDown ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_clear, 0, 0, 1 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, field ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_field_difference, 0, 0, 3 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, when ) + ZEND_ARG_INFO( 0, field ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_get_locale, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, localeType ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set_lenient, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, isLenient ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_from_date_time, 0, 0, 1) + ZEND_ARG_INFO(0, dateTime) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_wall_time_option, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, wallTimeOption ) +ZEND_END_ARG_INFO() + +/* Gregorian Calendar */ +ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_create_instance, 0, 0, 0 ) + ZEND_ARG_INFO(0, timeZoneOrYear) + ZEND_ARG_INFO(0, localeOrMonth) + ZEND_ARG_INFO(0, dayOfMonth) + ZEND_ARG_INFO(0, hour) + ZEND_ARG_INFO(0, minute) + ZEND_ARG_INFO(0, second) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_is_leap_year, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlGregorianCalendar, 0 ) + ZEND_ARG_INFO( 0, year ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_only_gregcal, 0, 0, 1 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlGregorianCalendar, 0 ) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_set_gregorian_change, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlGregorianCalendar, 0 ) + ZEND_ARG_INFO( 0, date ) +ZEND_END_ARG_INFO() + /* }}} */ /* {{{ intl_functions @@ -484,15 +705,19 @@ zend_function_entry intl_functions[] = { PHP_FE( datefmt_get_datetype, arginfo_msgfmt_get_locale ) PHP_FE( datefmt_get_timetype, arginfo_msgfmt_get_locale ) PHP_FE( datefmt_get_calendar, arginfo_msgfmt_get_locale ) + PHP_FE( datefmt_get_calendar_object, arginfo_msgfmt_get_locale ) PHP_FE( datefmt_set_calendar, arginfo_datefmt_set_calendar ) PHP_FE( datefmt_get_locale, arginfo_msgfmt_get_locale ) PHP_FE( datefmt_get_timezone_id, arginfo_msgfmt_get_locale ) - PHP_FE( datefmt_set_timezone_id, arginfo_msgfmt_get_locale ) + PHP_FE( datefmt_set_timezone_id, arginfo_datefmt_set_timezone ) + PHP_FE( datefmt_get_timezone, arginfo_msgfmt_get_locale ) + PHP_FE( datefmt_set_timezone, arginfo_datefmt_set_timezone ) PHP_FE( datefmt_get_pattern, arginfo_msgfmt_get_locale ) PHP_FE( datefmt_set_pattern, arginfo_datefmt_set_pattern ) PHP_FE( datefmt_is_lenient, arginfo_msgfmt_get_locale ) PHP_FE( datefmt_set_lenient, arginfo_msgfmt_get_locale ) PHP_FE( datefmt_format, arginfo_datefmt_format ) + PHP_FE( datefmt_format_object, arginfo_datefmt_format_object ) PHP_FE( datefmt_parse, datefmt_parse_args ) PHP_FE( datefmt_localtime , datefmt_parse_args ) PHP_FE( datefmt_get_error_code, arginfo_msgfmt_get_error_code ) @@ -530,6 +755,96 @@ zend_function_entry intl_functions[] = { PHP_FE( transliterator_get_error_code, arginfo_transliterator_error ) PHP_FE( transliterator_get_error_message, arginfo_transliterator_error ) + /* TimeZone functions */ + PHP_FE( intltz_create_time_zone, arginfo_tz_idarg_static ) + PHP_FE( intltz_from_date_time_zone, arginfo_tz_from_date_time_zone ) + PHP_FE( intltz_create_default, arginfo_tz_void ) + PHP_FE( intltz_get_id, arginfo_tz_only_tz ) + PHP_FE( intltz_get_gmt, arginfo_tz_void ) +#if U_ICU_VERSION_MAJOR_NUM >= 49 + PHP_FE( intltz_get_unknown, arginfo_tz_void ) +#endif + PHP_FE( intltz_create_enumeration, arginfo_tz_create_enumeration ) + PHP_FE( intltz_count_equivalent_ids, arginfo_tz_idarg_static ) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 + PHP_FE( intltz_create_time_zone_id_enumeration, arginfo_tz_create_time_zone_id_enumeration ) +#endif + PHP_FE( intltz_get_canonical_id, arginfo_tz_get_canonical_id ) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 + PHP_FE( intltz_get_region, arginfo_tz_idarg_static ) +#endif + PHP_FE( intltz_get_tz_data_version, arginfo_tz_void ) + PHP_FE( intltz_get_equivalent_id, arginfo_tz_get_equivalent_id ) + PHP_FE( intltz_use_daylight_time, arginfo_tz_only_tz ) + PHP_FE( intltz_get_offset, arginfo_tz_get_offset ) + PHP_FE( intltz_get_raw_offset, arginfo_tz_only_tz ) + PHP_FE( intltz_has_same_rules, arginfo_tz_has_same_rules ) + PHP_FE( intltz_get_display_name, arginfo_tz_get_display_name ) + PHP_FE( intltz_get_dst_savings, arginfo_tz_only_tz ) + PHP_FE( intltz_to_date_time_zone, arginfo_tz_only_tz ) + PHP_FE( intltz_get_error_code, arginfo_tz_only_tz ) + PHP_FE( intltz_get_error_message, arginfo_tz_only_tz ) + + PHP_FE( intlcal_create_instance, ainfo_cal_create_instance ) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42 + PHP_FE( intlcal_get_keyword_values_for_locale, ainfo_cal_get_keyword_values_for_locale ) +#endif + PHP_FE( intlcal_get_now, ainfo_cal_void ) + PHP_FE( intlcal_get_available_locales, ainfo_cal_void ) + PHP_FE( intlcal_get, ainfo_cal_field ) + PHP_FE( intlcal_get_time, ainfo_cal_only_cal ) + PHP_FE( intlcal_set_time, ainfo_cal_date ) + PHP_FE( intlcal_add, ainfo_cal_add ) + PHP_FE( intlcal_set_time_zone, ainfo_cal_set_time_zone ) + PHP_FE( intlcal_after, ainfo_cal_other_cal ) + PHP_FE( intlcal_before, ainfo_cal_other_cal ) + PHP_FE( intlcal_set, ainfo_cal_set ) + PHP_FE( intlcal_roll, ainfo_cal_roll ) + PHP_FE( intlcal_clear, ainfo_cal_clear ) + PHP_FE( intlcal_field_difference, ainfo_cal_field_difference ) + PHP_FE( intlcal_get_actual_maximum, ainfo_cal_field ) + PHP_FE( intlcal_get_actual_minimum, ainfo_cal_field ) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 + PHP_FE( intlcal_get_day_of_week_type, ainfo_cal_dow ) +#endif + PHP_FE( intlcal_get_first_day_of_week, ainfo_cal_only_cal ) + PHP_FE( intlcal_get_greatest_minimum, ainfo_cal_field ) + PHP_FE( intlcal_get_least_maximum, ainfo_cal_field ) + PHP_FE( intlcal_get_locale, ainfo_cal_get_locale ) + PHP_FE( intlcal_get_maximum, ainfo_cal_field ) + PHP_FE( intlcal_get_minimal_days_in_first_week, ainfo_cal_only_cal ) + PHP_FE( intlcal_get_minimum, ainfo_cal_field ) + PHP_FE( intlcal_get_time_zone, ainfo_cal_only_cal ) + PHP_FE( intlcal_get_type, ainfo_cal_only_cal ) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 + PHP_FE( intlcal_get_weekend_transition, ainfo_cal_dow ) +#endif + PHP_FE( intlcal_in_daylight_time, ainfo_cal_only_cal ) + PHP_FE( intlcal_is_equivalent_to, ainfo_cal_other_cal ) + PHP_FE( intlcal_is_lenient, ainfo_cal_only_cal ) + PHP_FE( intlcal_is_set, ainfo_cal_field ) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 + PHP_FE( intlcal_is_weekend, ainfo_cal_date_optional ) +#endif + PHP_FE( intlcal_set_first_day_of_week, ainfo_cal_dow ) + PHP_FE( intlcal_set_lenient, ainfo_cal_set_lenient ) + PHP_FE( intlcal_equals, ainfo_cal_other_cal ) + PHP_FE( intlcal_from_date_time, ainfo_cal_from_date_time ) + PHP_FE( intlcal_to_date_time, ainfo_cal_only_cal ) +#if U_ICU_VERSION_MAJOR_NUM >= 49 + PHP_FE( intlcal_get_repeated_wall_time_option, ainfo_cal_only_cal ) + PHP_FE( intlcal_get_skipped_wall_time_option, ainfo_cal_only_cal ) + PHP_FE( intlcal_set_repeated_wall_time_option, ainfo_cal_wall_time_option ) + PHP_FE( intlcal_set_skipped_wall_time_option, ainfo_cal_wall_time_option ) +#endif + PHP_FE( intlcal_get_error_code, ainfo_cal_only_cal ) + PHP_FE( intlcal_get_error_message, ainfo_cal_only_cal ) + + PHP_FE( intlgregcal_create_instance, ainfo_gregcal_create_instance ) + PHP_FE( intlgregcal_set_gregorian_change, ainfo_gregcal_set_gregorian_change ) + PHP_FE( intlgregcal_get_gregorian_change, ainfo_gregcal_only_gregcal ) + PHP_FE( intlgregcal_is_leap_year, ainfo_gregcal_is_leap_year ) + /* common functions */ PHP_FE( intl_get_error_code, intl_0_args ) PHP_FE( intl_get_error_message, intl_0_args ) @@ -540,16 +855,14 @@ zend_function_entry intl_functions[] = { }; /* }}} */ - /* {{{ INI Settings */ PHP_INI_BEGIN() STD_PHP_INI_ENTRY(LOCALE_INI_NAME, NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_locale, zend_intl_globals, intl_globals) STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateLong, error_level, zend_intl_globals, intl_globals) - + STD_PHP_INI_ENTRY("intl.use_exceptions", "0", PHP_INI_ALL, OnUpdateBool, use_exceptions, zend_intl_globals, intl_globals) PHP_INI_END() /* }}} */ - static PHP_GINIT_FUNCTION(intl); /* {{{ intl_module_entry */ @@ -640,6 +953,12 @@ PHP_MINIT_FUNCTION( intl ) /* Register Transliterator constants */ transliterator_register_constants( INIT_FUNC_ARGS_PASSTHRU ); + /* Register 'IntlTimeZone' PHP class */ + timezone_register_IntlTimeZone_class( TSRMLS_C ); + + /* Register 'IntlCalendar' PHP class */ + calendar_register_IntlCalendar_class( TSRMLS_C ); + /* Expose ICU error codes to PHP scripts. */ intl_expose_icu_error_codes( INIT_FUNC_ARGS_PASSTHRU ); @@ -653,25 +972,44 @@ PHP_MINIT_FUNCTION( intl ) /* Expose Spoofchecker constants to PHP scripts */ spoofchecker_register_constants( INIT_FUNC_ARGS_PASSTHRU ); #endif + + /* Register 'IntlException' PHP class */ + intl_register_IntlException_class( TSRMLS_C ); + + /* Register 'IntlIterator' PHP class */ + intl_register_IntlIterator_class( TSRMLS_C ); + + /* Register 'BreakIterator' class */ + breakiterator_register_BreakIterator_class( TSRMLS_C ); + + /* Register 'IntlPartsIterator' class */ + breakiterator_register_IntlPartsIterator_class( TSRMLS_C ); + /* Global error handling. */ intl_error_init( NULL TSRMLS_CC ); - /* Set the default_locale value */ - if( INTL_G(default_locale) == NULL ) { - INTL_G(default_locale) = pestrdup(uloc_getDefault(), 1) ; - } + /* 'Converter' class for codepage conversions */ + php_converter_minit(INIT_FUNC_ARGS_PASSTHRU); return SUCCESS; } /* }}} */ +#define EXPLICIT_CLEANUP_ENV_VAR "INTL_EXPLICIT_CLEANUP" + /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION( intl ) { + const char *cleanup; /* For the default locale php.ini setting */ UNREGISTER_INI_ENTRIES(); + cleanup = getenv(EXPLICIT_CLEANUP_ENV_VAR); + if (cleanup != NULL && !(cleanup[0] == '0' && cleanup[1] == '\0')) { + u_cleanup(); + } + return SUCCESS; } /* }}} */ @@ -680,10 +1018,6 @@ PHP_MSHUTDOWN_FUNCTION( intl ) */ PHP_RINIT_FUNCTION( intl ) { - /* Set the default_locale value */ - if( INTL_G(default_locale) == NULL ) { - INTL_G(default_locale) = pestrdup(uloc_getDefault(), 1) ; - } return SUCCESS; } /* }}} */ diff --git a/ext/intl/php_intl.h b/ext/intl/php_intl.h index 4ede069e2a041..7a7112317de1d 100644 --- a/ext/intl/php_intl.h +++ b/ext/intl/php_intl.h @@ -22,8 +22,13 @@ #include +/* Even if we're included from C++, don't introduce C++ definitions + * because we were included with extern "C". The effect would be that + * when the headers defined any method, they would do so with C linkage */ +#undef U_SHOW_CPLUSPLUS_API +#define U_SHOW_CPLUSPLUS_API 0 #include "collator/collator_sort.h" -#include "grapheme/grapheme.h" +#include #include "intl_error.h" extern zend_module_entry intl_module_entry; @@ -46,6 +51,7 @@ ZEND_BEGIN_MODULE_GLOBALS(intl) UBreakIterator* grapheme_iterator; intl_error g_error; long error_level; + zend_bool use_exceptions; ZEND_END_MODULE_GLOBALS(intl) /* Macro to access request-wide global variables. */ @@ -63,6 +69,8 @@ PHP_RINIT_FUNCTION(intl); PHP_RSHUTDOWN_FUNCTION(intl); PHP_MINFO_FUNCTION(intl); +const char *intl_locale_get_default( TSRMLS_D ); + #define PHP_INTL_VERSION "1.1.0" #endif /* PHP_INTL_H */ diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index a6a73f5f04a13..db46bf5b16c89 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -79,13 +79,11 @@ static zend_object_value ResourceBundle_object_create( zend_class_entry *ce TSRM /* {{{ ResourceBundle_ctor */ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) { - char * bundlename; - int bundlename_len = 0; - char * locale; - int locale_len = 0; - zend_bool fallback = 1; - - char * pbuf; + const char *bundlename; + int bundlename_len = 0; + const char *locale; + int locale_len = 0; + zend_bool fallback = 1; zval *object = return_value; ResourceBundle_object *rb = (ResourceBundle_object *) zend_object_store_get_object( object TSRMLS_CC); @@ -104,7 +102,7 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value); if (locale == NULL) { - locale = INTL_G(default_locale); + locale = intl_locale_get_default(TSRMLS_C); } if (fallback) { @@ -117,6 +115,7 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) { + char *pbuf; intl_errors_set_code(NULL, INTL_DATA_ERROR_CODE(rb) TSRMLS_CC); spprintf(&pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource " "'%s' without fallback from %s to %s", diff --git a/ext/intl/tests/badargs.phpt b/ext/intl/tests/badargs.phpt index 9232bbf0c187a..b8f48b371eb3a 100644 --- a/ext/intl/tests/badargs.phpt +++ b/ext/intl/tests/badargs.phpt @@ -13,7 +13,10 @@ foreach($funcs as $func) { if($rfunc->getNumberOfRequiredParameters() == 0) { continue; } - $res = $func($arg); + + try { + $res = $func($arg); + } catch (Exception $e) { continue; } if($res != false) { echo "$func: "; var_dump($res); diff --git a/ext/intl/tests/breakiter___construct.phpt b/ext/intl/tests/breakiter___construct.phpt new file mode 100644 index 0000000000000..a818075a30c2a --- /dev/null +++ b/ext/intl/tests/breakiter___construct.phpt @@ -0,0 +1,14 @@ +--TEST-- +IntlBreakIterator::__construct() should not be callable +--SKIPIF-- + += 4.8 only'; ?> +--FILE-- +setText('foobar'); +$bi_clone = clone $bi; +var_dump(get_class($bi), get_class($bi_clone)); +var_dump($bi == $bi_clone); + +--EXPECT-- +string(26) "IntlRuleBasedBreakIterator" +string(26) "IntlRuleBasedBreakIterator" +bool(true) +string(26) "IntlRuleBasedBreakIterator" +string(26) "IntlRuleBasedBreakIterator" +bool(true) diff --git a/ext/intl/tests/breakiter_createCodePointInstance_basic.phpt b/ext/intl/tests/breakiter_createCodePointInstance_basic.phpt new file mode 100644 index 0000000000000..a43e82760ccd7 --- /dev/null +++ b/ext/intl/tests/breakiter_createCodePointInstance_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlBreakIterator::createCodePointInstance(): basic test +--SKIPIF-- +setText($text); + +print_r(iterator_to_array($codepoint_it)); + +?> +==DONE== +--EXPECT-- +string(26) "IntlCodePointBreakIterator" +Array +( + [0] => 0 + [1] => 3 + [2] => 6 + [3] => 9 + [4] => 12 + [5] => 15 + [6] => 18 + [7] => 21 + [8] => 24 + [9] => 27 + [10] => 30 + [11] => 33 + [12] => 36 + [13] => 39 + [14] => 42 + [15] => 45 +) +==DONE== diff --git a/ext/intl/tests/breakiter_createCodePointInstance_error.phpt b/ext/intl/tests/breakiter_createCodePointInstance_error.phpt new file mode 100644 index 0000000000000..90228e128f6db --- /dev/null +++ b/ext/intl/tests/breakiter_createCodePointInstance_error.phpt @@ -0,0 +1,18 @@ +--TEST-- +IntlBreakIterator::createCodePointInstance(): bad arguments +--SKIPIF-- +current()); +$bi->setText('foo bar trans zoo bee'); + +var_dump($bi->first()); +var_dump($bi->current()); +var_dump($bi->next()); +var_dump($bi->current()); +?> +==DONE== +--EXPECT-- +int(0) +int(0) +int(0) +int(3) +int(3) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/breakiter_factories_basic.phpt b/ext/intl/tests/breakiter_factories_basic.phpt new file mode 100644 index 0000000000000..dcfcedef0cad3 --- /dev/null +++ b/ext/intl/tests/breakiter_factories_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +IntlBreakIterator factories: basic tests +--SKIPIF-- +setText('foo bar trans'); + +var_dump($bi->current()); +var_dump($bi->next()); +var_dump($bi->first()); +var_dump($bi->current()); +--EXPECT-- +int(0) +int(3) +int(0) +int(0) diff --git a/ext/intl/tests/breakiter_first_last_previous_current_error.phpt b/ext/intl/tests/breakiter_first_last_previous_current_error.phpt new file mode 100644 index 0000000000000..2ab681228e5fa --- /dev/null +++ b/ext/intl/tests/breakiter_first_last_previous_current_error.phpt @@ -0,0 +1,39 @@ +--TEST-- +IntlBreakIterator::first()/last()/previous()/current(): arg errors +--SKIPIF-- +setText("\x80sdfé\x90d888 dfsa9"); + +var_dump($bi->first(1)); +var_dump($bi->last(1)); +var_dump($bi->previous(1)); +var_dump($bi->current(1)); + +--EXPECTF-- + +Warning: IntlBreakIterator::first() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlBreakIterator::first(): breakiter_first: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::last() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlBreakIterator::last(): breakiter_last: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::previous() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlBreakIterator::previous(): breakiter_previous: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::current() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlBreakIterator::current(): breakiter_current: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/breakiter_following_basic.phpt b/ext/intl/tests/breakiter_following_basic.phpt new file mode 100644 index 0000000000000..30798d99a3355 --- /dev/null +++ b/ext/intl/tests/breakiter_following_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlBreakIterator::following(): basic test +--SKIPIF-- +setText('foo bar trans zoo bee'); + +var_dump($bi->following(5)); +var_dump($bi->following(50)); +var_dump($bi->following(-1)); +?> +==DONE== +--EXPECT-- +int(7) +int(-1) +int(0) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/breakiter_following_preceding_isBoundary_error.phpt b/ext/intl/tests/breakiter_following_preceding_isBoundary_error.phpt new file mode 100644 index 0000000000000..5550ccf0a08f5 --- /dev/null +++ b/ext/intl/tests/breakiter_following_preceding_isBoundary_error.phpt @@ -0,0 +1,51 @@ +--TEST-- +IntlBreakIterator::following()/preceding()/isBoundary(): arg errors +--SKIPIF-- +setText("\x80sdfé\x90d888 dfsa9"); + +var_dump($bi->following(1, 2)); +var_dump($bi->following(array())); +var_dump($bi->preceding(1, 2)); +var_dump($bi->preceding(array())); +var_dump($bi->isBoundary(1, 2)); +var_dump($bi->isBoundary(array())); + +--EXPECTF-- + +Warning: IntlBreakIterator::following() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::following(): breakiter_following: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::following() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::following(): breakiter_following: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::preceding() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::preceding(): breakiter_preceding: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::preceding() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::preceding(): breakiter_preceding: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::isBoundary() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::isBoundary(): breakiter_is_boundary: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::isBoundary() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::isBoundary(): breakiter_is_boundary: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/breakiter_getLocale_basic.phpt b/ext/intl/tests/breakiter_getLocale_basic.phpt new file mode 100644 index 0000000000000..b0112cc847fae --- /dev/null +++ b/ext/intl/tests/breakiter_getLocale_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +IntlBreakIterator::getLocale(): basic test +--SKIPIF-- +getLocale(0)); +var_dump($bi->getLocale(1)); +?> +==DONE== +--EXPECT-- +string(4) "root" +string(4) "root" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/breakiter_getLocale_error.phpt b/ext/intl/tests/breakiter_getLocale_error.phpt new file mode 100644 index 0000000000000..9acd08ab634a1 --- /dev/null +++ b/ext/intl/tests/breakiter_getLocale_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlBreakIterator::getLocale(): arg errors +--SKIPIF-- +setText("\x80sdfé\x90d888 dfsa9"); + +var_dump($bi->getLocale(1, 2)); +var_dump($bi->getLocale(array())); +var_dump($bi->getLocale()); + +--EXPECTF-- + +Warning: IntlBreakIterator::getLocale() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::getLocale(): breakiter_get_locale: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::getLocale() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::getLocale(): breakiter_get_locale: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::getLocale() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlBreakIterator::getLocale(): breakiter_get_locale: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/breakiter_getPartsIterator_basic.phpt b/ext/intl/tests/breakiter_getPartsIterator_basic.phpt new file mode 100644 index 0000000000000..36ad80d5fb0f5 --- /dev/null +++ b/ext/intl/tests/breakiter_getPartsIterator_basic.phpt @@ -0,0 +1,37 @@ +--TEST-- +IntlBreakIterator::getPartsIterator(): basic test +--SKIPIF-- +getPartsIterator(); +var_dump(get_class($pi)); +print_r(iterator_to_array($pi)); + +$bi->setText("foo bar"); +$pi = $bi->getPartsIterator(); +var_dump(get_class($pi->getBreakIterator())); +print_r(iterator_to_array($pi)); +var_dump($pi->getRuleStatus()); +?> +==DONE== +--EXPECT-- +string(17) "IntlPartsIterator" +Array +( +) +string(26) "IntlRuleBasedBreakIterator" +Array +( + [0] => foo + [1] => + [2] => bar +) +int(0) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/breakiter_getPartsIterator_error.phpt b/ext/intl/tests/breakiter_getPartsIterator_error.phpt new file mode 100644 index 0000000000000..973761803388f --- /dev/null +++ b/ext/intl/tests/breakiter_getPartsIterator_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlBreakIterator::getPartsIterator(): bad args +--SKIPIF-- +getPartsIterator(array())); +var_dump($it->getPartsIterator(1, 2)); +var_dump($it->getPartsIterator(-1)); + +?> +==DONE== +--EXPECTF-- + +Warning: IntlBreakIterator::getPartsIterator() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::getPartsIterator(): breakiter_get_parts_iterator: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::getPartsIterator() expects at most 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::getPartsIterator(): breakiter_get_parts_iterator: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::getPartsIterator(): breakiter_get_parts_iterator: bad key type in %s on line %d +bool(false) +==DONE== diff --git a/ext/intl/tests/breakiter_getPartsIterator_var1.phpt b/ext/intl/tests/breakiter_getPartsIterator_var1.phpt new file mode 100644 index 0000000000000..7bbd27ea45112 --- /dev/null +++ b/ext/intl/tests/breakiter_getPartsIterator_var1.phpt @@ -0,0 +1,60 @@ +--TEST-- +IntlBreakIterator::getPartsIterator(): argument variations +--SKIPIF-- +setText($text); + +var_dump(iterator_to_array($it->getPartsIterator(IntlPartsIterator::KEY_SEQUENTIAL))); +var_dump(iterator_to_array($it->getPartsIterator(IntlPartsIterator::KEY_LEFT))); +var_dump(iterator_to_array($it->getPartsIterator(IntlPartsIterator::KEY_RIGHT))); + +?> +==DONE== +--EXPECT-- +array(5) { + [0]=> + string(3) "foo" + [1]=> + string(1) " " + [2]=> + string(3) "bar" + [3]=> + string(1) " " + [4]=> + string(3) "tao" +} +array(5) { + [0]=> + string(3) "foo" + [4]=> + string(1) " " + [5]=> + string(3) "bar" + [8]=> + string(1) " " + [9]=> + string(3) "tao" +} +array(5) { + [3]=> + string(3) "foo" + [5]=> + string(1) " " + [8]=> + string(3) "bar" + [9]=> + string(1) " " + [12]=> + string(3) "tao" +} +==DONE== diff --git a/ext/intl/tests/breakiter_getText_basic.phpt b/ext/intl/tests/breakiter_getText_basic.phpt new file mode 100644 index 0000000000000..0e5a26c16a17d --- /dev/null +++ b/ext/intl/tests/breakiter_getText_basic.phpt @@ -0,0 +1,17 @@ +--TEST-- +IntlBreakIterator::getText(): basic test +--SKIPIF-- +getText()); +$bi->setText('foo bar'); +var_dump($bi->getText()); +--EXPECTF-- +NULL +string(7) "foo bar" diff --git a/ext/intl/tests/breakiter_getText_error.phpt b/ext/intl/tests/breakiter_getText_error.phpt new file mode 100644 index 0000000000000..91e9919c15ecb --- /dev/null +++ b/ext/intl/tests/breakiter_getText_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlBreakIterator::getText(): arg errors +--SKIPIF-- +getText(array())); + +--EXPECTF-- + +Warning: IntlBreakIterator::getText() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlBreakIterator::getText(): breakiter_get_text: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/breakiter_isBoundary_basic.phpt b/ext/intl/tests/breakiter_isBoundary_basic.phpt new file mode 100644 index 0000000000000..1f416630a0d47 --- /dev/null +++ b/ext/intl/tests/breakiter_isBoundary_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlBreakIterator::isBoundary(): basic test +--SKIPIF-- +setText('foo bar trans zoo bee'); + +var_dump($bi->isBoundary(0)); +var_dump($bi->isBoundary(7)); +var_dump($bi->isBoundary(-1)); +var_dump($bi->isBoundary(1)); +var_dump($bi->isBoundary(50)); +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/breakiter_last_basic.phpt b/ext/intl/tests/breakiter_last_basic.phpt new file mode 100644 index 0000000000000..cf816c3670e7b --- /dev/null +++ b/ext/intl/tests/breakiter_last_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +IntlBreakIterator::last(): basic test +--SKIPIF-- +setText('foo bar trans'); + +var_dump($bi->current()); +var_dump($bi->last()); +var_dump($bi->current()); +--EXPECTF-- +int(0) +int(13) +int(13) diff --git a/ext/intl/tests/breakiter_next_basic.phpt b/ext/intl/tests/breakiter_next_basic.phpt new file mode 100644 index 0000000000000..4deb4144e3b1f --- /dev/null +++ b/ext/intl/tests/breakiter_next_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +IntlBreakIterator::next(): basic test +--SKIPIF-- +setText('foo bar trans zoo bee'); + +var_dump($bi->first()); +var_dump($bi->next()); +var_dump($bi->next(2)); +var_dump($bi->next(-1)); +var_dump($bi->next(0)); +var_dump($bi->next(NULL)); +?> +==DONE== +--EXPECT-- +int(0) +int(3) +int(7) +int(4) +int(4) +int(7) +==DONE== diff --git a/ext/intl/tests/breakiter_next_error.phpt b/ext/intl/tests/breakiter_next_error.phpt new file mode 100644 index 0000000000000..ed718bc2a507e --- /dev/null +++ b/ext/intl/tests/breakiter_next_error.phpt @@ -0,0 +1,27 @@ +--TEST-- +IntlBreakIterator::next(): arg errors +--SKIPIF-- +setText("\x80sdfé\x90d888 dfsa9"); + +var_dump($bi->next(1, 2)); +var_dump($bi->next(array())); + +--EXPECTF-- + +Warning: IntlBreakIterator::next() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::next(): breakiter_next: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::next() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::next(): breakiter_next: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/breakiter_preceding_basic.phpt b/ext/intl/tests/breakiter_preceding_basic.phpt new file mode 100644 index 0000000000000..6fa8dd7fa7161 --- /dev/null +++ b/ext/intl/tests/breakiter_preceding_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlBreakIterator::preceding(): basic test +--SKIPIF-- +setText('foo bar trans zoo bee'); + +var_dump($bi->preceding(5)); +var_dump($bi->preceding(50)); +var_dump($bi->preceding(-1)); +?> +==DONE== +--EXPECT-- +int(4) +int(21) +int(0) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/breakiter_previous_basic.phpt b/ext/intl/tests/breakiter_previous_basic.phpt new file mode 100644 index 0000000000000..c3343af57c0f8 --- /dev/null +++ b/ext/intl/tests/breakiter_previous_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlBreakIterator::previous(): basic test +--SKIPIF-- +setText('foo bar trans'); + +var_dump($bi->last()); +var_dump($bi->previous()); +?> +==DONE== +--EXPECT-- +int(13) +int(8) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/breakiter_setText_basic.phpt b/ext/intl/tests/breakiter_setText_basic.phpt new file mode 100644 index 0000000000000..a5e4f86b6528f --- /dev/null +++ b/ext/intl/tests/breakiter_setText_basic.phpt @@ -0,0 +1,36 @@ +--TEST-- +IntlBreakIterator::setText(): basic test +--SKIPIF-- +setText('foo bar')); +var_dump($bi->getText()); +var_dump($bi->setText(1)); +var_dump($bi->getText()); +var_dump($bi->setText(new A)); +var_dump($bi->getText()); + +/* setText resets the pointer */ +var_dump($bi->next()); +var_dump($bi->setText('foo bar')); +var_dump($bi->current()); +--EXPECT-- +bool(true) +string(7) "foo bar" +bool(true) +string(1) "1" +bool(true) +string(3) "aaa" +int(3) +bool(true) +int(0) diff --git a/ext/intl/tests/breakiter_setText_error.phpt b/ext/intl/tests/breakiter_setText_error.phpt new file mode 100644 index 0000000000000..a7a73a08d82f6 --- /dev/null +++ b/ext/intl/tests/breakiter_setText_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +IntlBreakIterator::setText(): arg errors +--SKIPIF-- +setText()); +var_dump($bi->setText(array())); +var_dump($bi->setText(1,2)); + +class A { +function __destruct() { var_dump('destructed'); throw new Exception('e'); } +function __tostring() { return 'foo'; } +} + +try { +var_dump($bi->setText(new A)); +} catch (Exception $e) { +var_dump($e->getMessage()); +} + +--EXPECTF-- + +Warning: IntlBreakIterator::setText() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlBreakIterator::setText(): breakiter_set_text: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::setText() expects parameter 1 to be string, array given in %s on line %d + +Warning: IntlBreakIterator::setText(): breakiter_set_text: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::setText() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::setText(): breakiter_set_text: bad arguments in %s on line %d +bool(false) +string(10) "destructed" +string(1) "e" diff --git a/ext/intl/tests/bug50590.phpt b/ext/intl/tests/bug50590.phpt index c39c333b23ad7..4784d378773e3 100644 --- a/ext/intl/tests/bug50590.phpt +++ b/ext/intl/tests/bug50590.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #50590 (IntlDateFormatter::parse result is limited to the integer range) +--INI-- +date.timezone=Atlantic/Azores --SKIPIF-- --FILE-- diff --git a/ext/intl/tests/bug58756_MessageFormatter.phpt b/ext/intl/tests/bug58756_MessageFormatter.phpt new file mode 100644 index 0000000000000..bbe96b7045a10 --- /dev/null +++ b/ext/intl/tests/bug58756_MessageFormatter.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #58756: w.r.t MessageFormatter +--SKIPIF-- +format(array($time)) . "\n"; + +//NOT FIXED: +/*$msgf = new MessageFormatter('en_US', +'{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); + +echo "msgf2: ", $msgf->format(array($time, 'date')), " ", + $msgf->format(array($time, 'time')), "\n"; +*/ + +?> +==DONE== +--EXPECT-- +date: Tuesday, July 7, 2009 8:41:13 PM EDT +msgf: Tuesday, July 7, 2009 8:41:13 PM EDT +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/bug62017.phpt b/ext/intl/tests/bug62017.phpt index 13c4fe5df0be7..50aeae48061a4 100644 --- a/ext/intl/tests/bug62017.phpt +++ b/ext/intl/tests/bug62017.phpt @@ -14,7 +14,7 @@ var_dump( new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon", IntlDateFormatter::GREGORIAN, "\x80")); --EXPECTF-- -Warning: datefmt_create(): datefmt_create: error converting timezone_str to UTF-16 in %s on line %d +Warning: datefmt_create(): datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d NULL Warning: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %s on line %d diff --git a/ext/intl/tests/bug62081.phpt b/ext/intl/tests/bug62081.phpt index 7d9e2cec47ff4..44ad4beec7fab 100644 --- a/ext/intl/tests/bug62081.phpt +++ b/ext/intl/tests/bug62081.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #62081: IntlDateFormatter leaks memory if called twice +--INI-- +date.timezone=Atlantic/Azores --SKIPIF-- __construct(1,1,1,1,1)); +$x = new IntlDateFormatter('en', 1, 1); +var_dump($x->__construct('en', 1, 1)); --EXPECTF-- Warning: IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice in %s on line %d NULL diff --git a/ext/intl/tests/bug62915.phpt b/ext/intl/tests/bug62915.phpt new file mode 100644 index 0000000000000..e541d72d637ee --- /dev/null +++ b/ext/intl/tests/bug62915.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #62915: incomplete cloning of IntlTimeZone objects +--SKIPIF-- +getMessage()); +} +--EXPECT-- +string(39) "Cannot clone unconstructed IntlTimeZone" diff --git a/ext/intl/tests/calendar_add_basic.phpt b/ext/intl/tests/calendar_add_basic.phpt new file mode 100644 index 0000000000000..b0e44d58950b8 --- /dev/null +++ b/ext/intl/tests/calendar_add_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlCalendar::add() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setTime($time * 1000); +$intlcal->add(IntlCalendar::FIELD_DAY_OF_MONTH, 1); +$intlcal->add(IntlCalendar::FIELD_HOUR, 5); +$intlcal->add(IntlCalendar::FIELD_MINUTE, 6); +intlcal_add($intlcal, IntlCalendar::FIELD_SECOND, 7); + +var_dump( + (float)$time2*1000, + $intlcal->getTime()); + +?> +==DONE== +--EXPECT-- +float(1330578367000) +float(1330578367000) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_add_error.phpt b/ext/intl/tests/calendar_add_error.phpt new file mode 100644 index 0000000000000..2e5fadb4ec968 --- /dev/null +++ b/ext/intl/tests/calendar_add_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlCalendar::add(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +add(1, 2, 3)); +var_dump($c->add(-1, 2)); +var_dump($c->add(1)); + +var_dump(intlcal_add($c, 1, 2, 3)); +var_dump(intlcal_add(1, 2, 3)); +--EXPECTF-- + +Warning: IntlCalendar::add() expects exactly 2 parameters, 3 given in %s on line %d + +Warning: IntlCalendar::add(): intlcal_add: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::add(): intlcal_add: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::add() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::add(): intlcal_add: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_add() expects exactly 3 parameters, 4 given in %s on line %d + +Warning: intlcal_add(): intlcal_add: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_add() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_before_after_error.phpt b/ext/intl/tests/calendar_before_after_error.phpt new file mode 100644 index 0000000000000..10011ef852d16 --- /dev/null +++ b/ext/intl/tests/calendar_before_after_error.phpt @@ -0,0 +1,57 @@ +--TEST-- +IntlCalendar::before()/after(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +after()); +var_dump($c->before()); + +var_dump($c->after(1)); +var_dump($c->before(1)); + +var_dump($c->after($c, 1)); +var_dump($c->before($c, 1)); + +var_dump(intlcal_after($c)); +var_dump(intlcal_before($c)); +--EXPECT-- +error: 2, IntlCalendar::after() expects exactly 1 parameter, 0 given +error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments +bool(false) +error: 2, IntlCalendar::before() expects exactly 1 parameter, 0 given +error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments +bool(false) +error: 4096, Argument 1 passed to IntlCalendar::after() must be an instance of IntlCalendar, integer given +error: 2, IntlCalendar::after() expects parameter 1 to be IntlCalendar, integer given +error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments +bool(false) +error: 4096, Argument 1 passed to IntlCalendar::before() must be an instance of IntlCalendar, integer given +error: 2, IntlCalendar::before() expects parameter 1 to be IntlCalendar, integer given +error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments +bool(false) +error: 2, IntlCalendar::after() expects exactly 1 parameter, 2 given +error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments +bool(false) +error: 2, IntlCalendar::before() expects exactly 1 parameter, 2 given +error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments +bool(false) +error: 2, intlcal_after() expects exactly 2 parameters, 1 given +error: 2, intlcal_after(): intlcal_before/after: bad arguments +bool(false) +error: 2, intlcal_before() expects exactly 2 parameters, 1 given +error: 2, intlcal_before(): intlcal_before/after: bad arguments +bool(false) diff --git a/ext/intl/tests/calendar_clear_basic.phpt b/ext/intl/tests/calendar_clear_basic.phpt new file mode 100644 index 0000000000000..f7e4371d9207a --- /dev/null +++ b/ext/intl/tests/calendar_clear_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +IntlCalendar::clear() basic test +--SKIPIF-- +clear()); +var_dump( + $intlcal->get(IntlCalendar::FIELD_YEAR), + $intlcal->get(IntlCalendar::FIELD_MONTH), + $intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->get(IntlCalendar::FIELD_HOUR), + $intlcal->get(IntlCalendar::FIELD_MINUTE), + $intlcal->get(IntlCalendar::FIELD_SECOND), + $intlcal->get(IntlCalendar::FIELD_MILLISECOND) +); + +$intlcal2 = IntlCalendar::createInstance('Europe/Amsterdam'); +intlcal_clear($intlcal2, null); +var_dump($intlcal2->getTime()); + +?> +==DONE== +--EXPECT-- +bool(true) +int(1970) +int(0) +int(1) +int(0) +int(0) +int(0) +int(0) +float(-3600000) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_clear_error.phpt b/ext/intl/tests/calendar_clear_error.phpt new file mode 100644 index 0000000000000..9bde7e2c8d6bb --- /dev/null +++ b/ext/intl/tests/calendar_clear_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +IntlCalendar::clear(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +clear(1, 2)); +var_dump($c->clear(-1)); + +var_dump(intlcal_clear($c, -1)); +var_dump(intlcal_clear(1, 2)); +--EXPECTF-- + +Warning: IntlCalendar::clear(): intlcal_clear: too many arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::clear(): intlcal_clear: invalid field in %s on line %d +bool(false) + +Warning: intlcal_clear(): intlcal_clear: invalid field in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_clear() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_clear_variation1.phpt b/ext/intl/tests/calendar_clear_variation1.phpt new file mode 100644 index 0000000000000..6adbcaa353616 --- /dev/null +++ b/ext/intl/tests/calendar_clear_variation1.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlCalendar::clear() 1 arg variation +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); +//print_R($intlcal); +var_dump($intlcal->isSet(IntlCalendar::FIELD_MONTH)); +var_dump($intlcal->clear(IntlCalendar::FIELD_MONTH)); +var_dump($intlcal->isSet(IntlCalendar::FIELD_MONTH)); +//print_R($intlcal); +var_dump( + $intlcal->getTime(), + strtotime('2012-01-29 05:06:07 +0000') * 1000. +); +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +bool(false) +float(1327813567000) +float(1327813567000) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_createInstance_basic.phpt b/ext/intl/tests/calendar_createInstance_basic.phpt new file mode 100644 index 0000000000000..e062030fece90 --- /dev/null +++ b/ext/intl/tests/calendar_createInstance_basic.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlCalendar::createInstance() basic test +--SKIPIF-- +getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; +print_R($cal->getType()); +echo "\n"; + +$timeMillis = $cal->getTime(); +$time = time(); + +var_dump(abs($timeMillis - $time * 1000) < 1000); + +?> +==DONE== + +--EXPECTF-- +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Amsterdam + [rawOffset] => 3600000 + [currentOffset] => %d +) +nl +gregorian +bool(true) +==DONE== diff --git a/ext/intl/tests/calendar_createInstance_error.phpt b/ext/intl/tests/calendar_createInstance_error.phpt new file mode 100644 index 0000000000000..bf655bee793c5 --- /dev/null +++ b/ext/intl/tests/calendar_createInstance_error.phpt @@ -0,0 +1,38 @@ +--TEST-- +IntlCalendar::createInstance: bad arguments +--SKIPIF-- +getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; + +$cal = intlcal_create_instance('Europe/Lisbon', null); +print_R($cal->getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; + +$cal = intlcal_create_instance(IntlTimeZone::createTimeZone('Europe/Lisbon')); +print_R($cal->getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; + +$cal = intlcal_create_instance(null, "pt"); +print_R($cal->getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; + +$cal = intlcal_create_instance("Europe/Lisbon", "pt"); +print_R($cal->getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; + +?> +==DONE== +--EXPECTF-- +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Amsterdam + [rawOffset] => 3600000 + [currentOffset] => %d +) +nl +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Lisbon + [rawOffset] => 0 + [currentOffset] => %d +) +nl +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Lisbon + [rawOffset] => 0 + [currentOffset] => %d +) +nl +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Amsterdam + [rawOffset] => 3600000 + [currentOffset] => %d +) +pt +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Lisbon + [rawOffset] => 0 + [currentOffset] => %d +) +pt +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_equals_before_after_basic.phpt b/ext/intl/tests/calendar_equals_before_after_basic.phpt new file mode 100644 index 0000000000000..50543ad0b42b2 --- /dev/null +++ b/ext/intl/tests/calendar_equals_before_after_basic.phpt @@ -0,0 +1,59 @@ +--TEST-- +IntlCalendar::equals(), ::before() and ::after() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setTime($intlcal1->getTime()); + +var_dump($intlcal2->getType()); + +var_dump("1 eq 1", $intlcal1->equals($intlcal1)); + +var_dump("1 eq 2", $intlcal1->equals($intlcal2)); +var_dump("1 before 2", $intlcal1->before($intlcal2)); +var_dump("1 after 2", $intlcal1->after($intlcal2)); + +var_dump("1 eq 3", $intlcal1->equals($intlcal3)); +var_dump("1 before 3", $intlcal1->before($intlcal3)); +var_dump("1 after 3", $intlcal1->after($intlcal3)); + +var_dump("3 eq 2", intlcal_equals($intlcal3, $intlcal2)); +var_dump("3 before 2", intlcal_before($intlcal3, $intlcal2)); +var_dump("3 after 2", intlcal_after($intlcal3, $intlcal2)); + +?> +==DONE== +--EXPECT-- +string(8) "japanese" +string(6) "1 eq 1" +bool(true) +string(6) "1 eq 2" +bool(true) +string(10) "1 before 2" +bool(false) +string(9) "1 after 2" +bool(false) +string(6) "1 eq 3" +bool(false) +string(10) "1 before 3" +bool(true) +string(9) "1 after 3" +bool(false) +string(6) "3 eq 2" +bool(false) +string(10) "3 before 2" +bool(false) +string(9) "3 after 2" +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_equals_error.phpt b/ext/intl/tests/calendar_equals_error.phpt new file mode 100644 index 0000000000000..a947b42bfe320 --- /dev/null +++ b/ext/intl/tests/calendar_equals_error.phpt @@ -0,0 +1,46 @@ +--TEST-- +IntlCalendar::equals(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +equals()); +var_dump($c->equals(new stdclass)); +var_dump($c->equals(1, 2)); + +var_dump(intlcal_equals($c, array())); +var_dump(intlcal_equals(1, $c)); + +--EXPECT-- +error: 2, IntlCalendar::equals() expects exactly 1 parameter, 0 given +error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments +bool(false) +error: 4096, Argument 1 passed to IntlCalendar::equals() must be an instance of IntlCalendar, instance of stdClass given +error: 2, IntlCalendar::equals() expects parameter 1 to be IntlCalendar, object given +error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments +bool(false) +error: 4096, Argument 1 passed to IntlCalendar::equals() must be an instance of IntlCalendar, integer given +error: 2, IntlCalendar::equals() expects exactly 1 parameter, 2 given +error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments +bool(false) +error: 4096, Argument 2 passed to intlcal_equals() must be an instance of IntlCalendar, array given +error: 2, intlcal_equals() expects parameter 2 to be IntlCalendar, array given +error: 2, intlcal_equals(): intlcal_equals: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_equals() must be an instance of IntlCalendar, integer given +error: 2, intlcal_equals() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_equals(): intlcal_equals: bad arguments +bool(false) diff --git a/ext/intl/tests/calendar_fieldDifference_basic.phpt b/ext/intl/tests/calendar_fieldDifference_basic.phpt new file mode 100644 index 0000000000000..3432420df407a --- /dev/null +++ b/ext/intl/tests/calendar_fieldDifference_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +IntlCalendar::fieldDifference() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); +var_dump( + $intlcal->fieldDifference( + strtotime('2012-02-29 06:06:08 +0000') * 1000, + IntlCalendar::FIELD_SECOND), + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY)); + + +$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); +var_dump( + intlcal_field_difference( + $intlcal, + strtotime('2012-02-29 06:07:08 +0000') * 1000, + IntlCalendar::FIELD_MINUTE)); +?> +==DONE== +--EXPECT-- +int(3601) +int(6) +int(61) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_fieldDifference_error.phpt b/ext/intl/tests/calendar_fieldDifference_error.phpt new file mode 100644 index 0000000000000..ef7e4fc8dca36 --- /dev/null +++ b/ext/intl/tests/calendar_fieldDifference_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlCalendar::fieldDifference(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +fieldDifference($c, 2, 3)); +var_dump($c->fieldDifference(INF, 2)); +var_dump($c->fieldDifference(1)); + +var_dump(intlcal_field_difference($c, 0, 1, 2)); +var_dump(intlcal_field_difference(1, 0, 1)); + +--EXPECTF-- + +Warning: IntlCalendar::fieldDifference() expects exactly 2 parameters, 3 given in %s on line %d + +Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d +bool(false) + +Warning: IntlCalendar::fieldDifference() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_field_difference() expects exactly 3 parameters, 4 given in %s on line %d + +Warning: intlcal_field_difference(): intlcal_field_difference: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_field_difference() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_fromDateTime_basic.phpt b/ext/intl/tests/calendar_fromDateTime_basic.phpt new file mode 100644 index 0000000000000..1863b7815c9af --- /dev/null +++ b/ext/intl/tests/calendar_fromDateTime_basic.phpt @@ -0,0 +1,52 @@ +--TEST-- +IntlCalendar::fromDateTime(): basic test +--SKIPIF-- +getTime(), + strtotime('2012-01-01 00:00:00 Europe/Rome') * 1000., + $cal->getTimeZone()->getID(), + $cal->getLocale(1) +); +echo "\n"; + +$cal = IntlCalendar::fromDateTime(new DateTime('2012-01-01 00:00:00 PST'), "pt_PT"); +var_dump( + $cal->getTime(), + strtotime('2012-01-01 00:00:00 PST') * 1000., + $cal->getTimeZone()->getID(), + $cal->getLocale(1) +); + +echo "\n"; + +$cal = intlcal_from_date_time(new DateTime('2012-01-01 00:00:00 +03:40')); +var_dump( + $cal->getTime(), + strtotime('2012-01-01 00:00:00 +03:40') * 1000., + $cal->getTimeZone()->getID() +); + +--EXPECTF-- +float(1325372400000) +float(1325372400000) +string(11) "Europe/Rome" +string(5) "nl_NL" + +float(1325404800000) +float(1325404800000) +string(3) "PST" +string(5) "pt_PT" + +float(1325362800000) +float(1325362800000) +string(%d) "GMT+03%S40" diff --git a/ext/intl/tests/calendar_fromDateTime_error.phpt b/ext/intl/tests/calendar_fromDateTime_error.phpt new file mode 100644 index 0000000000000..2fbf7196f92e6 --- /dev/null +++ b/ext/intl/tests/calendar_fromDateTime_error.phpt @@ -0,0 +1,59 @@ +--TEST-- +IntlCalendar::fromDateTime(): errors +--SKIPIF-- + 100); + +$locales = intlcal_get_available_locales(); +var_dump(in_array('pt', $locales)); + +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getAvailableLocales_error.phpt b/ext/intl/tests/calendar_getAvailableLocales_error.phpt new file mode 100644 index 0000000000000..e9edc468e5944 --- /dev/null +++ b/ext/intl/tests/calendar_getAvailableLocales_error.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlCalendar::getAvailableLocales(): bad arguments +--SKIPIF-- +setTime(strtotime('2012-02-29 00:00:00 +0000') * 1000); +var_dump( + intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY) +); + +?> +==DONE== +--EXPECT-- +int(3) +int(0) +int(0) +int(0) +int(1) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getDayOfWeekType_error.phpt b/ext/intl/tests/calendar_getDayOfWeekType_error.phpt new file mode 100644 index 0000000000000..3926655615cde --- /dev/null +++ b/ext/intl/tests/calendar_getDayOfWeekType_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +IntlCalendar::getDayOfWeekOfType(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getDayOfWeekType(1, 2)); +var_dump($c->getDayOfWeekType(0)); +var_dump($c->getDayOfWeekType()); + +var_dump(intlcal_get_day_of_week_type($c, "foo")); +var_dump(intlcal_get_day_of_week_type(1, 1)); + +--EXPECTF-- + +Warning: IntlCalendar::getDayOfWeekType() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: invalid day of week in %s on line %d +bool(false) + +Warning: IntlCalendar::getDayOfWeekType() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_day_of_week_type() expects parameter 2 to be long, string given in %s on line %d + +Warning: intlcal_get_day_of_week_type(): intlcal_get_day_of_week_type: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_day_of_week_type() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getErrorCode_error.phpt b/ext/intl/tests/calendar_getErrorCode_error.phpt new file mode 100644 index 0000000000000..13aab819233e7 --- /dev/null +++ b/ext/intl/tests/calendar_getErrorCode_error.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlCalendar::getErrorCode(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getErrorCode(array())); + +var_dump(intlcal_get_error_code(null)); + +--EXPECTF-- + +Warning: IntlCalendar::getErrorCode() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getErrorCode(): intlcal_get_error_code: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_error_code() must be an instance of IntlCalendar, null given in %s on line %d diff --git a/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt b/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt new file mode 100644 index 0000000000000..71c053492f15c --- /dev/null +++ b/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlCalendar::getErrorCode(), ::getErrorMessage() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getErrorCode(), + intlcal_get_error_code($intlcal), + $intlcal->getErrorMessage(), + intlcal_get_error_message($intlcal) +); +$intlcal->add(IntlCalendar::FIELD_SECOND, 2147483647); +$intlcal->fieldDifference(-PHP_INT_MAX, IntlCalendar::FIELD_SECOND); + +var_dump( + $intlcal->getErrorCode(), + intlcal_get_error_code($intlcal), + $intlcal->getErrorMessage(), + intlcal_get_error_message($intlcal) +); +?> +==DONE== +--EXPECTF-- +int(0) +int(0) +string(12) "U_ZERO_ERROR" +string(12) "U_ZERO_ERROR" + +Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d +int(1) +int(1) +string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR" +string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR" +==DONE== diff --git a/ext/intl/tests/calendar_getErrorMessage_error.phpt b/ext/intl/tests/calendar_getErrorMessage_error.phpt new file mode 100644 index 0000000000000..6081833904d38 --- /dev/null +++ b/ext/intl/tests/calendar_getErrorMessage_error.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlCalendar::getErrorMessage(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getErrorMessage(array())); + +var_dump(intlcal_get_error_message(null)); + +--EXPECTF-- + +Warning: IntlCalendar::getErrorMessage() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getErrorMessage(): intlcal_get_error_message: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_error_message() must be an instance of IntlCalendar, null given in %s on line %d diff --git a/ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt b/ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt new file mode 100644 index 0000000000000..82a0bc85cc277 --- /dev/null +++ b/ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +IntlCalendar::getFirstDayOfWeek() basic test +--SKIPIF-- +getFirstDayOfWeek()); +var_dump(intlcal_get_first_day_of_week($intlcal)); +?> +==DONE== +--EXPECT-- +int(2) +int(2) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt b/ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt new file mode 100644 index 0000000000000..e13b5138a72ee --- /dev/null +++ b/ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::getFirstDayOfWeek(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getFirstDayOfWeek(1)); + +var_dump(intlcal_get_first_day_of_week($c, 1)); +var_dump(intlcal_get_first_day_of_week(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getFirstDayOfWeek() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getFirstDayOfWeek(): intlcal_get_first_day_of_week: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_first_day_of_week() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_first_day_of_week(): intlcal_get_first_day_of_week: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_first_day_of_week() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt b/ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt new file mode 100644 index 0000000000000..dedfcea8fee14 --- /dev/null +++ b/ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt @@ -0,0 +1,36 @@ +--TEST-- +IntlCalendar::getKeywordValuesForLocale() basic test +--SKIPIF-- + 8); +var_dump(in_array('japanese', $var)); + +?> +==DONE== +--EXPECT-- +Array +( + [0] => gregorian +) + +bool(true) +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt b/ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt new file mode 100644 index 0000000000000..2aa8002bd1b52 --- /dev/null +++ b/ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlCalendar::getKeywordValuesForLocale(): bad arguments +--SKIPIF-- +getLocale(Locale::ACTUAL_LOCALE)); +var_dump(intlcal_get_locale($intlcal, Locale::VALID_LOCALE)); +?> +==DONE== +--EXPECT-- +string(2) "nl" +string(5) "nl_NL" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getLocale_error.phpt b/ext/intl/tests/calendar_getLocale_error.phpt new file mode 100644 index 0000000000000..42970a9e7fa93 --- /dev/null +++ b/ext/intl/tests/calendar_getLocale_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlCalendar::getLocale(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getLocale()); +var_dump($c->getLocale(2)); +var_dump($c->getLocale(2, 3)); + +var_dump(intlcal_get_locale($c)); +var_dump(intlcal_get_locale(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getLocale() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getLocale(): intlcal_get_locale: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getLocale(): intlcal_get_locale: invalid locale type in %s on line %d +bool(false) + +Warning: IntlCalendar::getLocale() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::getLocale(): intlcal_get_locale: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_locale() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlcal_get_locale(): intlcal_get_locale: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_locale() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt new file mode 100644 index 0000000000000..eeaa3104a8eb8 --- /dev/null +++ b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlCalendar::getMinimalDaysInFirstWeek() basic test +--SKIPIF-- +getMinimalDaysInFirstWeek()); +var_dump(intlcal_get_minimal_days_in_first_week($intlcal)); +?> +==DONE== +--EXPECT-- +int(4) +int(4) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt new file mode 100644 index 0000000000000..8e1971dc2b085 --- /dev/null +++ b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::getMinimalDaysInFirstWeek(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getMinimalDaysInFirstWeek(1)); + +var_dump(intlcal_get_minimal_days_in_first_week($c, 1)); +var_dump(intlcal_get_minimal_days_in_first_week(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getMinimalDaysInFirstWeek() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getMinimalDaysInFirstWeek(): intlcal_get_minimal_days_in_first_week: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_minimal_days_in_first_week() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_minimal_days_in_first_week(): intlcal_get_minimal_days_in_first_week: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_minimal_days_in_first_week() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getNow_basic.phpt b/ext/intl/tests/calendar_getNow_basic.phpt new file mode 100644 index 0000000000000..18325dfa605d9 --- /dev/null +++ b/ext/intl/tests/calendar_getNow_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlCalendar::getNow() basic test +--SKIPIF-- + +==DONE== +--EXPECT-- +bool(true) +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getNow_error.phpt b/ext/intl/tests/calendar_getNow_error.phpt new file mode 100644 index 0000000000000..31991bb591af6 --- /dev/null +++ b/ext/intl/tests/calendar_getNow_error.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlCalendar::getNow(): bad arguments +--SKIPIF-- +getSkippedWallTimeOption(1)); +var_dump($c->getRepeatedWallTimeOption(1)); + +var_dump(intlcal_get_skipped_wall_time_option($c, 1)); +var_dump(intlcal_get_repeated_wall_time_option($c, 1)); + +var_dump(intlcal_get_skipped_wall_time_option(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getSkippedWallTimeOption() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getSkippedWallTimeOption(): intlcal_get_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getRepeatedWallTimeOption() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getRepeatedWallTimeOption(): intlcal_get_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_skipped_wall_time_option() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_skipped_wall_time_option(): intlcal_get_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_repeated_wall_time_option() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_repeated_wall_time_option(): intlcal_get_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_skipped_wall_time_option() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getTimeZone_basic.phpt b/ext/intl/tests/calendar_getTimeZone_basic.phpt new file mode 100644 index 0000000000000..fd9aff1f99128 --- /dev/null +++ b/ext/intl/tests/calendar_getTimeZone_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlCalendar::getTimeZone() basic test +--SKIPIF-- +getTimeZone()); +print_r(intlcal_get_time_zone($intlcal)); +?> +==DONE== +--EXPECT-- +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT+00:01 + [rawOffset] => 60000 + [currentOffset] => 60000 +) +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT+00:01 + [rawOffset] => 60000 + [currentOffset] => 60000 +) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getTimeZone_error.phpt b/ext/intl/tests/calendar_getTimeZone_error.phpt new file mode 100644 index 0000000000000..470701cd9150e --- /dev/null +++ b/ext/intl/tests/calendar_getTimeZone_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::getTimeZone(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getTimeZone(1)); + +var_dump(intlcal_get_time_zone($c, 1)); +var_dump(intlcal_get_time_zone(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getTimeZone() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getTimeZone(): intlcal_get_time_zone: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_time_zone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_time_zone(): intlcal_get_time_zone: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_time_zone() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getTime_basic.phpt b/ext/intl/tests/calendar_getTime_basic.phpt new file mode 100644 index 0000000000000..659c71c961c2e --- /dev/null +++ b/ext/intl/tests/calendar_getTime_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +IntlCalendar::getTime() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +clear(); +$intlcal->set(IntlCalendar::FIELD_YEAR, 2012); +$intlcal->set(IntlCalendar::FIELD_MONTH, 1 /* Feb */); +$intlcal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 29); + +$time = strtotime('2012-02-29 00:00:00 +0000'); + +var_dump((float)$time*1000, $intlcal->getTime()); + +?> +==DONE== +--EXPECT-- +float(1330473600000) +float(1330473600000) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getTime_error.phpt b/ext/intl/tests/calendar_getTime_error.phpt new file mode 100644 index 0000000000000..5d27e21101dcf --- /dev/null +++ b/ext/intl/tests/calendar_getTime_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +IntlCalendar::getTime(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getTime(1)); + +var_dump(intlcal_get_time($c, 1)); +var_dump(intlcal_get_time(1)); +--EXPECTF-- + +Warning: IntlCalendar::getTime() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getTime(): intlcal_get_time: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_time() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_time(): intlcal_get_time: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_time() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getType_basic.phpt b/ext/intl/tests/calendar_getType_basic.phpt new file mode 100644 index 0000000000000..ba32dd0526524 --- /dev/null +++ b/ext/intl/tests/calendar_getType_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlCalendar::getType() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getType()); +$intlcal = IntlCalendar::createInstance(null, "nl_NL@calendar=hebrew"); +VAR_DUMP(intlcal_get_type($intlcal)); +?> +==DONE== +--EXPECT-- +string(9) "gregorian" +string(6) "hebrew" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getType_error.phpt b/ext/intl/tests/calendar_getType_error.phpt new file mode 100644 index 0000000000000..668ebeafb47b5 --- /dev/null +++ b/ext/intl/tests/calendar_getType_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::getType(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getType(1)); + +var_dump(intlcal_get_type($c, 1)); +var_dump(intlcal_get_type(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getType() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getType(): intlcal_get_type: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_type() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_type(): intlcal_get_type: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_type() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getWeekendTransition_basic.phpt b/ext/intl/tests/calendar_getWeekendTransition_basic.phpt new file mode 100644 index 0000000000000..e7257430061de --- /dev/null +++ b/ext/intl/tests/calendar_getWeekendTransition_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlCalendar::getWeekendTransition() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getWeekendTransition(IntlCalendar::DOW_SUNDAY)); +var_dump(intlcal_get_weekend_transition($intlcal, IntlCalendar::DOW_SUNDAY)); +?> +==DONE== +--EXPECT-- +int(86400000) +int(86400000) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getWeekendTransition_error.phpt b/ext/intl/tests/calendar_getWeekendTransition_error.phpt new file mode 100644 index 0000000000000..f7c9cc7ed1d03 --- /dev/null +++ b/ext/intl/tests/calendar_getWeekendTransition_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +IntlCalendar::getWeekendTransition(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getWeekendTransition()); +var_dump($c->getWeekendTransition(1, 2)); +var_dump($c->getWeekendTransition(0)); + +var_dump(intlcal_get_weekend_transition($c)); +var_dump(intlcal_get_weekend_transition(1, 1)); + +--EXPECTF-- + +Warning: IntlCalendar::getWeekendTransition() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getWeekendTransition() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: invalid day of week in %s on line %d +bool(false) + +Warning: intlcal_get_weekend_transition() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlcal_get_weekend_transition(): intlcal_get_weekend_transition: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_weekend_transition() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getXMaximum_basic.phpt b/ext/intl/tests/calendar_getXMaximum_basic.phpt new file mode 100644 index 0000000000000..9b840212d924d --- /dev/null +++ b/ext/intl/tests/calendar_getXMaximum_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlCalendar::getMaximum(), ::getActualMaximum(), ::getLeastMaximum() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); +var_dump( + $intlcal->getLeastMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_least_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_actual_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH) +); + +?> +==DONE== +--EXPECT-- +int(28) +int(28) +int(29) +int(29) +int(31) +int(31) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_getXMinimum_basic.phpt b/ext/intl/tests/calendar_getXMinimum_basic.phpt new file mode 100644 index 0000000000000..83fd16380986f --- /dev/null +++ b/ext/intl/tests/calendar_getXMinimum_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlCalendar::getMinimum(), ::getActualMinimum(), ::getGreatestMinimum() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); +var_dump( + $intlcal->getGreatestMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_greatest_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getActualMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_actual_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH) +); + +?> +==DONE== +--EXPECT-- +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt b/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt new file mode 100644 index 0000000000000..acd9b58c1dc1b --- /dev/null +++ b/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt @@ -0,0 +1,100 @@ +--TEST-- +IntlCalendar::get/Least/Greatest/Minimum/Maximum(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getLeastMaximum()); +var_dump($c->getMaximum()); +var_dump($c->getGreatestMinimum()); +var_dump($c->getMinimum()); + +var_dump($c->getLeastMaximum(-1)); +var_dump($c->getMaximum(-1)); +var_dump($c->getGreatestMinimum(-1)); +var_dump($c->getMinimum(-1)); + +var_dump(intlcal_get_least_maximum($c, -1)); +var_dump(intlcal_get_maximum($c, -1)); +var_dump(intlcal_get_greatest_minimum($c, -1)); +var_dump(intlcal_get_minimum($c, -1)); + +function eh($errno, $errstr) { +echo "error: $errno, $errstr\n"; +} +set_error_handler('eh'); + +var_dump(intlcal_get_least_maximum(1, 1)); +var_dump(intlcal_get_maximum(1, 1)); +var_dump(intlcal_get_greatest_minimum(1, -1)); +var_dump(intlcal_get_minimum(1, -1)); + +--EXPECTF-- + +Warning: IntlCalendar::getLeastMaximum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getLeastMaximum(): intlcal_get_least_maximum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getMaximum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getMaximum(): intlcal_get_maximum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getGreatestMinimum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getGreatestMinimum(): intlcal_get_greatest_minimum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getMinimum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getMinimum(): intlcal_get_minimum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getLeastMaximum(): intlcal_get_least_maximum: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::getMaximum(): intlcal_get_maximum: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::getGreatestMinimum(): intlcal_get_greatest_minimum: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::getMinimum(): intlcal_get_minimum: invalid field in %s on line %d +bool(false) + +Warning: intlcal_get_least_maximum(): intlcal_get_least_maximum: invalid field in %s on line %d +bool(false) + +Warning: intlcal_get_maximum(): intlcal_get_maximum: invalid field in %s on line %d +bool(false) + +Warning: intlcal_get_greatest_minimum(): intlcal_get_greatest_minimum: invalid field in %s on line %d +bool(false) + +Warning: intlcal_get_minimum(): intlcal_get_minimum: invalid field in %s on line %d +bool(false) +error: 4096, Argument 1 passed to intlcal_get_least_maximum() must be an instance of IntlCalendar, integer given +error: 2, intlcal_get_least_maximum() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_get_least_maximum(): intlcal_get_least_maximum: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_get_maximum() must be an instance of IntlCalendar, integer given +error: 2, intlcal_get_maximum() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_get_maximum(): intlcal_get_maximum: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_get_greatest_minimum() must be an instance of IntlCalendar, integer given +error: 2, intlcal_get_greatest_minimum() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_get_greatest_minimum(): intlcal_get_greatest_minimum: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_get_minimum() must be an instance of IntlCalendar, integer given +error: 2, intlcal_get_minimum() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_get_minimum(): intlcal_get_minimum: bad arguments +bool(false) diff --git a/ext/intl/tests/calendar_get_basic.phpt b/ext/intl/tests/calendar_get_basic.phpt new file mode 100644 index 0000000000000..c617639610f33 --- /dev/null +++ b/ext/intl/tests/calendar_get_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlCalendar::get() basic test +--SKIPIF-- +set(IntlCalendar::FIELD_DAY_OF_MONTH, 4); + +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); +var_dump(intlcal_get($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH)); + +?> +==DONE== +--EXPECT-- +int(4) +int(4) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error.phpt b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error.phpt new file mode 100644 index 0000000000000..f6ccb128eef69 --- /dev/null +++ b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error.phpt @@ -0,0 +1,84 @@ +--TEST-- +IntlCalendar::get/getActualMaximum/getActualMinimum(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +get()); +var_dump($c->getActualMaximum()); +var_dump($c->getActualMinimum()); + +var_dump($c->get(-1)); +var_dump($c->getActualMaximum(-1)); +var_dump($c->getActualMinimum(-1)); + +var_dump($c->get("s")); +var_dump($c->getActualMaximum("s")); +var_dump($c->getActualMinimum("s")); + +var_dump($c->get(1, 2)); +var_dump($c->getActualMaximum(1, 2)); +var_dump($c->getActualMinimum(1, 2)); +--EXPECTF-- + +Warning: IntlCalendar::get() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMaximum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMinimum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::get(): intlcal_get: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::get() expects parameter 1 to be long, string given in %s on line %d + +Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMaximum() expects parameter 1 to be long, string given in %s on line %d + +Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMinimum() expects parameter 1 to be long, string given in %s on line %d + +Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::get() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMaximum() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMinimum() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt new file mode 100644 index 0000000000000..a8d1a4aa2fbce --- /dev/null +++ b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt @@ -0,0 +1,71 @@ +--TEST-- +IntlCalendar::get/getActualMaximum/getActualMinimum(): bad arguments (procedural) +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setRepeatedWallTimeOption(IntlCalendar::WALLTIME_LAST)); +var_dump($intlcal->getRepeatedWallTimeOption()); +$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 30); +var_dump( + strtotime('2012-10-28 02:30:00 +0100'), + (int)($intlcal->getTime() /1000) +); + +var_dump(intlcal_set_repeated_wall_time_option($intlcal, IntlCalendar::WALLTIME_FIRST)); +var_dump(intlcal_get_repeated_wall_time_option($intlcal)); +$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 30); +var_dump( + strtotime('2012-10-28 02:30:00 +0200'), + (int)($intlcal->getTime() /1000) +); + +?> +==DONE== +--EXPECT-- + +bool(true) +int(0) +int(1351387800) +int(1351387800) +bool(true) +int(1) +int(1351384200) +int(1351384200) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt b/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt new file mode 100644 index 0000000000000..bbbf031c8860a --- /dev/null +++ b/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt @@ -0,0 +1,67 @@ +--TEST-- +IntlCalendar::get/setSkippedWallTimeOption(): basic test +--SKIPIF-- +getSkippedWallTimeOption()); +$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 30); +echo "Should be 3h30\n"; +var_dump( + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), + $intlcal->get(IntlCalendar::FIELD_MINUTE) +); + +var_dump($intlcal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_FIRST)); +var_dump(intlcal_get_skipped_wall_time_option($intlcal)); +$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 30); +echo "Should be 1h30\n"; +var_dump( + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), + $intlcal->get(IntlCalendar::FIELD_MINUTE) +); + +var_dump(intlcal_set_skipped_wall_time_option($intlcal, IntlCalendar::WALLTIME_NEXT_VALID)); +var_dump($intlcal->getSkippedWallTimeOption()); +$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 30); +echo "Should be 3h00\n"; +var_dump( + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), + $intlcal->get(IntlCalendar::FIELD_MINUTE) +); + + +?> +==DONE== +--EXPECT-- + +int(0) +Should be 3h30 +int(3) +int(30) +bool(true) +int(1) +Should be 1h30 +int(1) +int(30) +bool(true) +int(2) +Should be 3h00 +int(3) +int(0) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_inDaylightTime_basic.phpt b/ext/intl/tests/calendar_inDaylightTime_basic.phpt new file mode 100644 index 0000000000000..dff8ef50d3c49 --- /dev/null +++ b/ext/intl/tests/calendar_inDaylightTime_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlCalendar::inDaylightTime() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setTime(strtotime('2012-01-01') * 1000); +var_dump($intlcal->inDaylightTime()); +$intlcal->setTime(strtotime('2012-04-01') * 1000); +var_dump(intlcal_in_daylight_time($intlcal)); +?> +==DONE== +--EXPECT-- +bool(false) +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_inDaylightTime_error.phpt b/ext/intl/tests/calendar_inDaylightTime_error.phpt new file mode 100644 index 0000000000000..9af9aa5048f4b --- /dev/null +++ b/ext/intl/tests/calendar_inDaylightTime_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::inDaylightTime(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +inDaylightTime(1)); + +var_dump(intlcal_in_daylight_time($c, 1)); +var_dump(intlcal_in_daylight_time(1)); + +--EXPECTF-- + +Warning: IntlCalendar::inDaylightTime() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::inDaylightTime(): intlcal_in_daylight_time: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_in_daylight_time() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_in_daylight_time(): intlcal_in_daylight_time: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_in_daylight_time() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_isEquivalentTo_basic.phpt b/ext/intl/tests/calendar_isEquivalentTo_basic.phpt new file mode 100644 index 0000000000000..f71fd8ad5b4ad --- /dev/null +++ b/ext/intl/tests/calendar_isEquivalentTo_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +IntlCalendar::isEquivalentTo() basic test +--SKIPIF-- +roll(IntlCalendar::FIELD_MONTH, true); + +var_dump( + "1 - 1", + $intlcal1->isEquivalentTo($intlcal1), + "1 - 2", + $intlcal1->isEquivalentTo($intlcal2), + "1 - 3", + $intlcal1->isEquivalentTo($intlcal3), + "1 - 4", + $intlcal1->isEquivalentTo($intlcal4) +); + +?> +==DONE== +--EXPECT-- +string(5) "1 - 1" +bool(true) +string(5) "1 - 2" +bool(false) +string(5) "1 - 3" +bool(false) +string(5) "1 - 4" +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_isEquivalentTo_error.phpt b/ext/intl/tests/calendar_isEquivalentTo_error.phpt new file mode 100644 index 0000000000000..4fa7da5eb62eb --- /dev/null +++ b/ext/intl/tests/calendar_isEquivalentTo_error.phpt @@ -0,0 +1,50 @@ +--TEST-- +IntlCalendar::isEquivalentTo(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +isEquivalentTo(0)); +var_dump($c->isEquivalentTo($c, 1)); +var_dump($c->isEquivalentTo(1)); + +var_dump(intlcal_is_equivalent_to($c)); +var_dump(intlcal_is_equivalent_to($c, 1)); +var_dump(intlcal_is_equivalent_to(1, $c)); + +--EXPECT-- +error: 4096, Argument 1 passed to IntlCalendar::isEquivalentTo() must be an instance of IntlCalendar, integer given +error: 2, IntlCalendar::isEquivalentTo() expects parameter 1 to be IntlCalendar, integer given +error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments +bool(false) +error: 2, IntlCalendar::isEquivalentTo() expects exactly 1 parameter, 2 given +error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments +bool(false) +error: 4096, Argument 1 passed to IntlCalendar::isEquivalentTo() must be an instance of IntlCalendar, integer given +error: 2, IntlCalendar::isEquivalentTo() expects parameter 1 to be IntlCalendar, integer given +error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments +bool(false) +error: 2, intlcal_is_equivalent_to() expects exactly 2 parameters, 1 given +error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments +bool(false) +error: 4096, Argument 2 passed to intlcal_is_equivalent_to() must be an instance of IntlCalendar, integer given +error: 2, intlcal_is_equivalent_to() expects parameter 2 to be IntlCalendar, integer given +error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_is_equivalent_to() must be an instance of IntlCalendar, integer given +error: 2, intlcal_is_equivalent_to() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments +bool(false) diff --git a/ext/intl/tests/calendar_isLenient_error.phpt b/ext/intl/tests/calendar_isLenient_error.phpt new file mode 100644 index 0000000000000..7ddde1ae02c5b --- /dev/null +++ b/ext/intl/tests/calendar_isLenient_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::isLenient(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +isLenient(1)); + +var_dump(intlcal_is_lenient($c, 1)); +var_dump(intlcal_is_lenient(1)); + +--EXPECTF-- + +Warning: IntlCalendar::isLenient() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::isLenient(): intlcal_is_lenient: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_is_lenient() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_is_lenient(): intlcal_is_lenient: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_is_lenient() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_isSet_basic.phpt b/ext/intl/tests/calendar_isSet_basic.phpt new file mode 100644 index 0000000000000..8ef01448d5d02 --- /dev/null +++ b/ext/intl/tests/calendar_isSet_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlCalendar::isSet() basic test +--SKIPIF-- +isSet(IntlCalendar::FIELD_MINUTE)); +$intlcal->clear(IntlCalendar::FIELD_MINUTE); +var_dump($intlcal->isSet(IntlCalendar::FIELD_MINUTE)); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 0); +var_dump(intlcal_is_set($intlcal, IntlCalendar::FIELD_MINUTE)); +?> +==DONE== +--EXPECT-- +bool(true) +bool(false) +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_isSet_error.phpt b/ext/intl/tests/calendar_isSet_error.phpt new file mode 100644 index 0000000000000..f238d776b2852 --- /dev/null +++ b/ext/intl/tests/calendar_isSet_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlCalendar::isSet(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +isSet()); +var_dump($c->isSet(1, 2)); +var_dump($c->isSet(-1)); + +var_dump(intlcal_is_set($c)); +var_dump(intlcal_is_set(1, 2)); + +--EXPECTF-- + +Warning: IntlCalendar::isSet() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::isSet(): intlcal_is_set: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::isSet() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::isSet(): intlcal_is_set: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::isSet(): intlcal_is_set: invalid field in %s on line %d +bool(false) + +Warning: intlcal_is_set() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlcal_is_set(): intlcal_is_set: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_is_set() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_isWeekend_basic.phpt b/ext/intl/tests/calendar_isWeekend_basic.phpt new file mode 100644 index 0000000000000..d6452c71f76d3 --- /dev/null +++ b/ext/intl/tests/calendar_isWeekend_basic.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlCalendar::isWeekend basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +isWeekend(strtotime('2012-02-29 12:00:00 +0000') * 1000)); +var_dump(intlcal_is_weekend($intlcal, strtotime('2012-02-29 12:00:00 +0000') * 1000)); +var_dump($intlcal->isWeekend(strtotime('2012-03-11 12:00:00 +0000') * 1000)); +?> +==DONE== +--EXPECT-- +bool(false) +bool(false) +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_isWeekend_error.phpt b/ext/intl/tests/calendar_isWeekend_error.phpt new file mode 100644 index 0000000000000..7939a66a1456a --- /dev/null +++ b/ext/intl/tests/calendar_isWeekend_error.phpt @@ -0,0 +1,38 @@ +--TEST-- +IntlCalendar::isWeekend(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +isWeekend(1, 2)); +var_dump($c->isWeekend("jhhk")); + +var_dump(intlcal_is_weekend($c, "jj")); +var_dump(intlcal_is_weekend(1)); + +--EXPECTF-- + +Warning: IntlCalendar::isWeekend(): intlcal_is_weekend: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::isWeekend() expects parameter 1 to be double, string given in %s on line %d + +Warning: IntlCalendar::isWeekend(): intlcal_is_weekend: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_is_weekend() expects parameter 2 to be double, string given in %s on line %d + +Warning: intlcal_is_weekend(): intlcal_is_weekend: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_is_weekend() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_is_set_lenient_basic.phpt b/ext/intl/tests/calendar_is_set_lenient_basic.phpt new file mode 100644 index 0000000000000..64f537f9bc41b --- /dev/null +++ b/ext/intl/tests/calendar_is_set_lenient_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlCalendar::isLenient(), ::setLenient() basic test +--SKIPIF-- +isLenient()); +var_dump(intlcal_is_lenient($intlcal1)); +var_dump($intlcal1->setLenient(false)); +var_dump($intlcal1->isLenient()); +var_dump(intlcal_set_lenient($intlcal1, true)); +var_dump($intlcal1->isLenient()); +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_roll_basic.phpt b/ext/intl/tests/calendar_roll_basic.phpt new file mode 100644 index 0000000000000..971c36217bd22 --- /dev/null +++ b/ext/intl/tests/calendar_roll_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlCalendar::roll() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +roll(IntlCalendar::FIELD_DAY_OF_MONTH, 2)); +var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb) +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //1 + +$intlcal = new IntlGregorianCalendar(2012, 1, 28); +var_dump(intlcal_roll($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, 2)); +var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb) +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //1 + + +?> +==DONE== +--EXPECT-- +bool(true) +int(1) +int(1) +bool(true) +int(1) +int(1) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_roll_error.phpt b/ext/intl/tests/calendar_roll_error.phpt new file mode 100644 index 0000000000000..a56739469905a --- /dev/null +++ b/ext/intl/tests/calendar_roll_error.phpt @@ -0,0 +1,37 @@ +--TEST-- +IntlCalendar::roll(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +roll(1, 2, 3)); +var_dump($c->roll(-1, 2)); +var_dump($c->roll(1)); + +var_dump(intlcal_roll($c, 1, 2, 3)); +var_dump(intlcal_roll(1, 2, 3)); +--EXPECTF-- + +Warning: IntlCalendar::roll(): intlcal_set: too many arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::roll(): intlcal_roll: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::roll() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::roll(): intlcal_roll: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_roll(): intlcal_set: too many arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_roll() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_roll_variation1.phpt b/ext/intl/tests/calendar_roll_variation1.phpt new file mode 100644 index 0000000000000..9fb8d75e5abaa --- /dev/null +++ b/ext/intl/tests/calendar_roll_variation1.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::roll() bool argument variation +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +roll(IntlCalendar::FIELD_DAY_OF_MONTH, true)); +var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb) +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //29 + +var_dump(intlcal_roll($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, false)); +var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb) +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //28 + +?> +==DONE== +--EXPECT-- +bool(true) +int(1) +int(29) +bool(true) +int(1) +int(28) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt b/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt new file mode 100644 index 0000000000000..79b38104e4cf3 --- /dev/null +++ b/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlCalendar::setFirstDayOfWeek() basic test +--SKIPIF-- +setFirstDayOfWeek(IntlCalendar::DOW_TUESDAY), + $intlcal->getFirstDayOfWeek(), + intlcal_set_first_day_of_week($intlcal, IntlCalendar::DOW_WEDNESDAY), + $intlcal->getFirstDayOfWeek() +); +?> +==DONE== +--EXPECT-- +int(3) +bool(true) +int(3) +bool(true) +int(4) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt b/ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt new file mode 100644 index 0000000000000..98237e56fa2c4 --- /dev/null +++ b/ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt @@ -0,0 +1,40 @@ +--TEST-- +IntlCalendar::setFirstDayOfWeek(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setFirstDayOfWeek()); +var_dump($c->setFirstDayOfWeek(1, 2)); +var_dump($c->setFirstDayOfWeek(0)); + +var_dump(intlcal_set_first_day_of_week($c, 0)); +var_dump(intlcal_set_first_day_of_week(1, 2)); + +--EXPECTF-- + +Warning: IntlCalendar::setFirstDayOfWeek() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setFirstDayOfWeek() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: invalid day of week in %s on line %d +bool(false) + +Warning: intlcal_set_first_day_of_week(): intlcal_set_first_day_of_week: invalid day of week in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_set_first_day_of_week() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_setLenient_error.phpt b/ext/intl/tests/calendar_setLenient_error.phpt new file mode 100644 index 0000000000000..2b1d7b016d70b --- /dev/null +++ b/ext/intl/tests/calendar_setLenient_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +IntlCalendar::setLenient(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setLenient()); +var_dump($c->setLenient(array())); +var_dump($c->setLenient(1, 2)); + +var_dump(intlcal_set_lenient($c, array())); +var_dump(intlcal_set_lenient(1, false)); + +--EXPECTF-- + +Warning: IntlCalendar::setLenient() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setLenient() expects parameter 1 to be boolean, array given in %s on line %d + +Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setLenient() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_set_lenient() expects parameter 2 to be boolean, array given in %s on line %d + +Warning: intlcal_set_lenient(): intlcal_set_lenient: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_set_lenient() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_setSkipped_RepeatedWallTimeOption_error.phpt b/ext/intl/tests/calendar_setSkipped_RepeatedWallTimeOption_error.phpt new file mode 100644 index 0000000000000..dab55d2b29e9b --- /dev/null +++ b/ext/intl/tests/calendar_setSkipped_RepeatedWallTimeOption_error.phpt @@ -0,0 +1,82 @@ +--TEST-- +IntlCalendar::setSkipped/RepeatedWallTimeOption(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setSkippedWallTimeOption()); +var_dump($c->setRepeatedWallTimeOption()); + +var_dump($c->setSkippedWallTimeOption(1, 2)); +var_dump($c->setRepeatedWallTimeOption(1, 2)); + +var_dump($c->setSkippedWallTimeOption(array())); +var_dump($c->setRepeatedWallTimeOption(array())); + +var_dump($c->setSkippedWallTimeOption(3)); +var_dump($c->setRepeatedWallTimeOption(2)); + +var_dump(intlcal_set_skipped_wall_time_option($c)); +var_dump(intlcal_set_repeated_wall_time_option($c)); + +var_dump(intlcal_set_repeated_wall_time_option(1, 1)); + +--EXPECTF-- + +Warning: IntlCalendar::setSkippedWallTimeOption() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setRepeatedWallTimeOption() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setSkippedWallTimeOption() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setRepeatedWallTimeOption() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setSkippedWallTimeOption() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setRepeatedWallTimeOption() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: invalid option in %s on line %d +bool(false) + +Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: invalid option in %s on line %d +bool(false) + +Warning: intlcal_set_skipped_wall_time_option() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlcal_set_skipped_wall_time_option(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_set_repeated_wall_time_option() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlcal_set_repeated_wall_time_option(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_set_repeated_wall_time_option() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_setTimeZone_basic.phpt b/ext/intl/tests/calendar_setTimeZone_basic.phpt new file mode 100644 index 0000000000000..525840ddd6539 --- /dev/null +++ b/ext/intl/tests/calendar_setTimeZone_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +IntlCalendar::setTimeZone() basic test +--SKIPIF-- +getTimeZone()->getID()); +echo "\n"; +var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); + +$intlcal->setTimeZone(IntlTimeZone::getGMT()); +print_r($intlcal->getTimeZone()->getID()); +echo "\n"; +var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); + +intlcal_set_time_zone($intlcal, + IntlTimeZone::createTimeZone('GMT+05:30')); +print_r($intlcal->getTimeZone()->getID()); +echo "\n"; +var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); + +?> +==DONE== +--EXPECT-- +Europe/Amsterdam +int(3600000) +GMT +int(0) +GMT+05:30 +int(19800000) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_setTimeZone_error.phpt b/ext/intl/tests/calendar_setTimeZone_error.phpt new file mode 100644 index 0000000000000..ebe4d119ea0bd --- /dev/null +++ b/ext/intl/tests/calendar_setTimeZone_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlCalendar::setTimeZone(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setTimeZone($gmt, 2)); +var_dump($c->setTimeZone()); + +var_dump(intlcal_set_time_zone($c, 1, 2)); +var_dump(intlcal_set_time_zone(1, $gmt)); + +--EXPECT-- +error: 2, IntlCalendar::setTimeZone() expects exactly 1 parameter, 2 given +error: 2, IntlCalendar::setTimeZone(): intlcal_set_time_zone: bad arguments +bool(false) +error: 2, IntlCalendar::setTimeZone() expects exactly 1 parameter, 0 given +error: 2, IntlCalendar::setTimeZone(): intlcal_set_time_zone: bad arguments +bool(false) +error: 2, intlcal_set_time_zone() expects exactly 2 parameters, 3 given +error: 2, intlcal_set_time_zone(): intlcal_set_time_zone: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_set_time_zone() must be an instance of IntlCalendar, integer given +error: 2, intlcal_set_time_zone() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_set_time_zone(): intlcal_set_time_zone: bad arguments +bool(false) diff --git a/ext/intl/tests/calendar_setTimeZone_error2.phpt b/ext/intl/tests/calendar_setTimeZone_error2.phpt new file mode 100644 index 0000000000000..aa1eaba209e9f --- /dev/null +++ b/ext/intl/tests/calendar_setTimeZone_error2.phpt @@ -0,0 +1,29 @@ +--TEST-- +IntlCalendar::setTimeZone(): valid time zones for DateTime but not ICU +--SKIPIF-- +setTimeZone($pstdate->getTimeZone()); +var_dump($intlcal->getTimeZone()->getID()); + +$pstdate = new DateTime('2012-01-01 00:00:00 +24:00'); +$intlcal->setTimeZone($pstdate->getTimeZone()); +var_dump($intlcal->getTimeZone()->getID()); + +--EXPECTF-- + +Warning: IntlCalendar::setTimeZone(): intlcal_set_time_zone: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d +string(16) "Europe/Amsterdam" + +Warning: IntlCalendar::setTimeZone(): intlcal_set_time_zone: object has an time zone offset that's too large in %s on line %d +string(16) "Europe/Amsterdam" diff --git a/ext/intl/tests/calendar_setTimeZone_variation1.phpt b/ext/intl/tests/calendar_setTimeZone_variation1.phpt new file mode 100644 index 0000000000000..b1cbb74edf305 --- /dev/null +++ b/ext/intl/tests/calendar_setTimeZone_variation1.phpt @@ -0,0 +1,30 @@ +--TEST-- +IntlCalendar::setTimeZone() variation with NULL arg +--SKIPIF-- +getTimeZone()->getID()); +echo "\n"; +var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); + +/* passing NULL has no effect */ +$intlcal->setTimeZone(null); +print_r($intlcal->getTimeZone()->getID()); +echo "\n"; +var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); + +?> +==DONE== +--EXPECT-- +Europe/Amsterdam +int(3600000) +Europe/Amsterdam +int(3600000) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_setTimeZone_variation2.phpt b/ext/intl/tests/calendar_setTimeZone_variation2.phpt new file mode 100644 index 0000000000000..7f4a7ffa371fa --- /dev/null +++ b/ext/intl/tests/calendar_setTimeZone_variation2.phpt @@ -0,0 +1,30 @@ +--TEST-- +IntlCalendar::setTimeZone(): different ways to specify time zone +--SKIPIF-- +setTimeZone('Europe/Paris'); +var_dump($intlcal->getTimeZone()->getID()); +$intlcal->setTimeZone(new DateTimeZone('Europe/Madrid')); +var_dump($intlcal->getTimeZone()->getID()); + +$pstdate = new DateTime('2012-01-01 00:00:00 PST'); +$intlcal->setTimeZone($pstdate->getTimeZone()); +var_dump($intlcal->getTimeZone()->getID()); + +$offsetdate = new DateTime('2012-01-01 00:00:00 -02:30'); +$intlcal->setTimeZone($offsetdate->getTimeZone()); +var_dump($intlcal->getTimeZone()->getID()); +--EXPECTF-- +string(12) "Europe/Paris" +string(13) "Europe/Madrid" +string(3) "PST" +string(%d) "GMT-02%S30" diff --git a/ext/intl/tests/calendar_setTime_basic.phpt b/ext/intl/tests/calendar_setTime_basic.phpt new file mode 100644 index 0000000000000..f7f213c0d8409 --- /dev/null +++ b/ext/intl/tests/calendar_setTime_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlCalendar::setTime() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setTime($time * 1000); + +var_dump( + (float)$time*1000, + $intlcal->getTime()); + +$intlcal = IntlCalendar::createInstance('UTC'); +intlcal_set_time($intlcal,$time * 1000); +var_dump(intlcal_get_time($intlcal)); + +?> +==DONE== +--EXPECT-- +float(1330473600000) +float(1330473600000) +float(1330473600000) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_setTime_error.phpt b/ext/intl/tests/calendar_setTime_error.phpt new file mode 100644 index 0000000000000..71c5b0a1bd48d --- /dev/null +++ b/ext/intl/tests/calendar_setTime_error.phpt @@ -0,0 +1,37 @@ +--TEST-- +IntlCalendar::setTime(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setTime(1, 2)); +var_dump($c->setTime("jjj")); + +var_dump(intlcal_set_time($c, 1, 2)); +var_dump(intlcal_set_time(1)); +--EXPECTF-- + +Warning: IntlCalendar::setTime() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::setTime(): intlcal_set_time: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setTime() expects parameter 1 to be double, string given in %s on line %d + +Warning: IntlCalendar::setTime(): intlcal_set_time: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_set_time() expects exactly 2 parameters, 3 given in %s on line %d + +Warning: intlcal_set_time(): intlcal_set_time: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_set_time() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_set_basic.phpt b/ext/intl/tests/calendar_set_basic.phpt new file mode 100644 index 0000000000000..8eccb32da65df --- /dev/null +++ b/ext/intl/tests/calendar_set_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +IntlCalendar::set() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +set(IntlCalendar::FIELD_DAY_OF_MONTH, 2)); +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); +var_dump(intlcal_set($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, 3)); +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); + +?> +==DONE== +--EXPECT-- +bool(true) +int(2) +bool(true) +int(3) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_set_error.phpt b/ext/intl/tests/calendar_set_error.phpt new file mode 100644 index 0000000000000..669b1888e02d3 --- /dev/null +++ b/ext/intl/tests/calendar_set_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlCalendar::set(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +set(1)); +var_dump($c->set(1, 2, 3, 4)); +var_dump($c->set(1, 2, 3, 4, 5, 6, 7)); +var_dump($c->set(-1, 2)); + +var_dump(intlcal_set($c, -1, 2)); +var_dump(intlcal_set(1, 2, 3)); +--EXPECTF-- + +Warning: IntlCalendar::set() expects at least 2 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::set(): intlcal_set: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::set(): intlcal_set: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::set(): intlcal_set: too many arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::set(): intlcal_set: invalid field in %s on line %d +bool(false) + +Warning: intlcal_set(): intlcal_set: invalid field in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_set() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_set_variation1.phpt b/ext/intl/tests/calendar_set_variation1.phpt new file mode 100644 index 0000000000000..8ea016ed61dd2 --- /dev/null +++ b/ext/intl/tests/calendar_set_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlCalendar::set() argument variations +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +clear(); +var_dump($intlcal->set(2012, 1, 29)); +var_dump($intlcal->getTime(), + strtotime('2012-02-29 00:00:00 +0000') * 1000.); + +//two minutes to midnight! +var_dump($intlcal->set(2012, 1, 29, 23, 58)); +var_dump($intlcal->getTime(), + strtotime('2012-02-29 23:58:00 +0000') * 1000.); + +var_dump($intlcal->set(2012, 1, 29, 23, 58, 31)); +var_dump($intlcal->getTime(), + strtotime('2012-02-29 23:58:31 +0000') * 1000.); + +?> +==DONE== +--EXPECT-- +bool(true) +float(1330473600000) +float(1330473600000) +bool(true) +float(1330559880000) +float(1330559880000) +bool(true) +float(1330559911000) +float(1330559911000) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_toDateTime_basic.phpt b/ext/intl/tests/calendar_toDateTime_basic.phpt new file mode 100644 index 0000000000000..d38487dabf40a --- /dev/null +++ b/ext/intl/tests/calendar_toDateTime_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlCalendar::toDateTime(): basic test +--SKIPIF-- +toDateTime(); + +var_dump($dt->format("c"), $dt->getTimeZone()->getName()); +?> +==DONE== +--EXPECT-- +string(25) "2012-05-17T17:35:36+01:00" +string(13) "Europe/Lisbon" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/calendar_toDateTime_error.phpt b/ext/intl/tests/calendar_toDateTime_error.phpt new file mode 100644 index 0000000000000..961a9c86a6a1d --- /dev/null +++ b/ext/intl/tests/calendar_toDateTime_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlCalendar::toDateTime(): bad arguments +--SKIPIF-- +toDateTime(3)); + +var_dump(intlcal_to_date_time($cal, 3)); + +$cal = new IntlGregorianCalendar("Etc/Unknown"); +try { +var_dump($cal->toDateTime()); +} catch (Exception $e) { +var_dump("exception: {$e->getMessage()}"); +} + +var_dump(intlcal_to_date_time(3)); + +--EXPECTF-- + +Warning: IntlCalendar::toDateTime() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_to_date_time() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_to_date_time(): intlcal_to_date_time: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d +string(77) "exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)" + +Catchable fatal error: Argument 1 passed to intlcal_to_date_time() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/cpbi_clone_equality.phpt b/ext/intl/tests/cpbi_clone_equality.phpt new file mode 100644 index 0000000000000..c62b45274737f --- /dev/null +++ b/ext/intl/tests/cpbi_clone_equality.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlCodePointBreakIterator: clone and equality +--SKIPIF-- +setText($text); + +$it_clone = clone $it; +var_dump($it == $it_clone); + +$it->setText($text2 ); +var_dump($it == $it_clone); + +$it_clone->setText($text2); +var_dump($it == $it_clone); + +?> +==DONE== +--EXPECT-- +bool(true) +bool(false) +bool(true) +==DONE== diff --git a/ext/intl/tests/cpbi_getLastCodePoint_basic.phpt b/ext/intl/tests/cpbi_getLastCodePoint_basic.phpt new file mode 100644 index 0000000000000..74a07a6292272 --- /dev/null +++ b/ext/intl/tests/cpbi_getLastCodePoint_basic.phpt @@ -0,0 +1,82 @@ +--TEST-- +IntlCodepointBreakIterator::getLastCodePoint(): basic test +--SKIPIF-- +setText($text); + +var_dump($codepoint_it->getLastCodePoint()); +//first() and last() don't read codepoint and set the last code point var to -1 +//The pointer is after the last read codepoint if moving forward and +//before the last read codepoint is moving backwards +$p = $codepoint_it->first(); +while ($p != IntlBreakIterator::DONE) { + $c = $codepoint_it->getLastCodePoint(); + if ($c > 0) + var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint())); + else + var_dump($c); + //it's a post-increment operation as to the codepoint, i.e., it gives the codepoint + //starting at the initial position and only then moves the pointer forward + $p = $codepoint_it->next(); +} + +echo "Now backwards\n"; +$p = $codepoint_it->last(); +while ($p != IntlBreakIterator::DONE) { + $c = $codepoint_it->getLastCodePoint(); + if ($c > 0) + var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint())); + else + var_dump($c); + $p = $codepoint_it->previous(); +} + + +?> +==DONE== +--EXPECT-- +int(-1) +int(-1) +string(6) "U+0E15" +string(6) "U+0E31" +string(6) "U+0E27" +string(6) "U+0E2D" +string(6) "U+0E22" +string(6) "U+0E48" +string(6) "U+0E32" +string(6) "U+0E07" +string(6) "U+0E02" +string(6) "U+0E49" +string(6) "U+0E2D" +string(6) "U+0E04" +string(6) "U+0E27" +string(6) "U+0E32" +string(6) "U+0E21" +Now backwards +int(-1) +string(6) "U+0E21" +string(6) "U+0E32" +string(6) "U+0E27" +string(6) "U+0E04" +string(6) "U+0E2D" +string(6) "U+0E49" +string(6) "U+0E02" +string(6) "U+0E07" +string(6) "U+0E32" +string(6) "U+0E48" +string(6) "U+0E22" +string(6) "U+0E2D" +string(6) "U+0E27" +string(6) "U+0E31" +string(6) "U+0E15" +==DONE== diff --git a/ext/intl/tests/cpbi_getLastCodePoint_error.phpt b/ext/intl/tests/cpbi_getLastCodePoint_error.phpt new file mode 100644 index 0000000000000..78bd216629b7a --- /dev/null +++ b/ext/intl/tests/cpbi_getLastCodePoint_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlBreakIterator::getLastCodePoint(): bad args +--SKIPIF-- +getLastCodePoint(array())); +--EXPECTF-- + +Warning: IntlCodePointBreakIterator::getLastCodePoint() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCodePointBreakIterator::getLastCodePoint(): cpbi_get_last_code_point: bad arguments in %s on line %d +bool(false) + diff --git a/ext/intl/tests/cpbi_parts_iterator.phpt b/ext/intl/tests/cpbi_parts_iterator.phpt new file mode 100644 index 0000000000000..4754c12371095 --- /dev/null +++ b/ext/intl/tests/cpbi_parts_iterator.phpt @@ -0,0 +1,40 @@ +--TEST-- +IntlCodepointBreakIterator's part iterator +--SKIPIF-- +getPartsIterator(); +$it->getBreakIterator()->setText($text); + +foreach ($it as $k => $v) { + echo "$k. $v (" . sprintf("U+%04X", $it->getBreakIterator()->getLastCodePoint()) . + ") at {$it->getBreakIterator()->current()}\r\n"; +} + +?> +==DONE== +--EXPECT-- +0. ต (U+0E15) at 3 +1. ั (U+0E31) at 6 +2. ว (U+0E27) at 9 +3. อ (U+0E2D) at 12 +4. ย (U+0E22) at 15 +5. ่ (U+0E48) at 18 +6. า (U+0E32) at 21 +7. ง (U+0E07) at 24 +8. ข (U+0E02) at 27 +9. ้ (U+0E49) at 30 +10. อ (U+0E2D) at 33 +11. ค (U+0E04) at 36 +12. ว (U+0E27) at 39 +13. า (U+0E32) at 42 +14. ม (U+0E21) at 45 +==DONE== diff --git a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt new file mode 100644 index 0000000000000..cfd9338717365 --- /dev/null +++ b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlDateFormatter::__construct(): bad timezone or calendar +--SKIPIF-- + +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::__construct(): datefmt_create: no such time zone: 'bad timezone' in %s on line %d +NULL + +Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d +NULL + +Warning: IntlDateFormatter::__construct(): datefmt_create: Invalid calendar argument; should be an integer or an IntlCalendar instance in %s on line %d +NULL +==DONE== diff --git a/ext/intl/tests/dateformat_calendars.phpt b/ext/intl/tests/dateformat_calendars.phpt index 27f380c718457..6af02e51c14e6 100644 --- a/ext/intl/tests/dateformat_calendars.phpt +++ b/ext/intl/tests/dateformat_calendars.phpt @@ -41,5 +41,5 @@ string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12" string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12" string(42) "Sunday, Tevet 6, 5772 5:12:00 AM GMT+05:12" -Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN in %s on line %d +Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d ==DONE== diff --git a/ext/intl/tests/dateformat_create_cal_arg.phpt b/ext/intl/tests/dateformat_create_cal_arg.phpt new file mode 100644 index 0000000000000..53fb084af95e6 --- /dev/null +++ b/ext/intl/tests/dateformat_create_cal_arg.phpt @@ -0,0 +1,53 @@ +--TEST-- +IntlDateFormatter: several forms of the calendar arg +--SKIPIF-- +format($ts), "\n"; + +$cal = IntlCalendar::createInstance('UTC', 'en@calendar=islamic'); +$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal); +echo $df->format($ts), "\n"; + +//override calendar's timezone +$cal = new IntlGregorianCalendar('UTC', NULL); +$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Madrid', $cal); +echo $df->format($ts), "\n"; + +//default calendar is gregorian +$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0); +echo $df->format($ts), "\n"; + +//try now with traditional +$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, NULL, IntlDateFormatter::TRADITIONAL); +echo $df->format($ts), "\n"; + +//the timezone can be overridden when not specifying a calendar +$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, 'UTC', IntlDateFormatter::TRADITIONAL); +echo $df->format($ts), "\n"; + +$df = new IntlDateFormatter('es_ES', 0, 0, 'UTC', 0); +echo $df->format($ts), "\n"; + +?> +==DONE== +--EXPECTF-- +domingo%S 1 de enero de 2012 00:00:00 GMT +domingo%S 8 de Safar de 1433 00:00:00 GMT +domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central +sábado%S 31 de diciembre de 2011 d.C. 23:00:00 Hora %Sde las Azores +sábado%S 7 de Safar de 1433 AH 23:00:00 Hora %Sde las Azores +domingo%S 8 de Safar de 1433 AH 00:00:00 GMT +domingo%S 1 de enero de 2012 00:00:00 GMT +==DONE== diff --git a/ext/intl/tests/dateformat_format.phpt b/ext/intl/tests/dateformat_format.phpt index e5548196d1031..8664eea319888 100644 --- a/ext/intl/tests/dateformat_format.phpt +++ b/ext/intl/tests/dateformat_format.phpt @@ -5,6 +5,8 @@ datefmt_format_code() --FILE-- setTime(strtotime('2012-01-01 00:00:00')*1000.); +echo IntlDateFormatter::formatObject($cal), "\n"; +echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n"; + +?> +==DONE== + +--EXPECTF-- +01/01/2012 00:00:00 +Domingo, 1 de Janeiro de 2012 0:00:00 Hora %Sda Europa Ocidental +Jan 1, 2012 12:00:00 AM +1/1/12 12:00:00 AM Western European %STime +Sun 2012-01-1 00,00,00.000 Portugal Time (Lisbon) +Domingo, 1 de Janeiro de 2012 5:00:00 GMT+03:00 +06/02/1433 00:00:00 +Sunday, Safar 6, 1433 12:00:00 AM Western European %STime +==DONE== + diff --git a/ext/intl/tests/dateformat_formatObject_datetime.phpt b/ext/intl/tests/dateformat_formatObject_datetime.phpt new file mode 100644 index 0000000000000..6427ad5a988c6 --- /dev/null +++ b/ext/intl/tests/dateformat_formatObject_datetime.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlDateFormatter::formatObject(): DateTime tests +--SKIPIF-- + +==DONE== + +--EXPECTF-- +01/01/2012 00:00:00 +Domingo, 1 de Janeiro de 2012 0:00:00 Hora %Sda Europa Ocidental +Jan 1, 2012 12:00:00 AM +1/1/12 12:00:00 AM Western European %STime +Sun 2012-01-1 00,00,00.000 Portugal Time (Lisbon) +Domingo, 1 de Janeiro de 2012 5:00:00 GMT+03:00 +==DONE== + diff --git a/ext/intl/tests/dateformat_formatObject_error.phpt b/ext/intl/tests/dateformat_formatObject_error.phpt new file mode 100644 index 0000000000000..7aaf69e54e644 --- /dev/null +++ b/ext/intl/tests/dateformat_formatObject_error.phpt @@ -0,0 +1,74 @@ +--TEST-- +IntlDateFormatter::formatObject(): error conditions +--SKIPIF-- + +==DONE== + +--EXPECTF-- + +Warning: IntlDateFormatter::formatObject() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject() expects parameter 1 to be object, integer given in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the passed object must be an instance of either IntlCalendar or DateTime in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad IntlCalendar instance: not initialized properly in %s on line %d +bool(false) + +Warning: DateTime::getTimestamp(): The DateTime object has not been correctly initialized by its constructor in %s on line %d + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: error calling ::getTimeStamp() on the object in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the date/time format type is invalid in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; if array, it must have two elements in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; if array, it must have two elements in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; the date format (first element of the array) is not valid in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; the time format (second element of the array) is not valid in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the format is empty in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject() expects parameter 3 to be string, array given in %s on line %d +bool(false) +==DONE== + diff --git a/ext/intl/tests/dateformat_format_parse.phpt b/ext/intl/tests/dateformat_format_parse.phpt index bd41d715b9e63..6bd3d8a8ff9ef 100644 --- a/ext/intl/tests/dateformat_format_parse.phpt +++ b/ext/intl/tests/dateformat_format_parse.phpt @@ -12,7 +12,7 @@ datefmt_format_code() and datefmt_parse_code() function ut_main() { - $timezone = 'GMT+5'; + $timezone = 'GMT+05:00'; $locale_arr = array ( 'en_US' diff --git a/ext/intl/tests/dateformat_getCalendarObject_error.phpt b/ext/intl/tests/dateformat_getCalendarObject_error.phpt new file mode 100644 index 0000000000000..d2ad66c829f91 --- /dev/null +++ b/ext/intl/tests/dateformat_getCalendarObject_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlDateFormatter::getCalendarObject(): bad args +--SKIPIF-- +getCalendarObject(9)); +var_dump(datefmt_get_calendar_object($df, 9)); +var_dump(datefmt_get_calendar_object($df, 9)); +var_dump(datefmt_get_calendar_object(new stdclass)); + +?> +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::getCalendarObject() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlDateFormatter::getCalendarObject(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_calendar_object() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_calendar_object() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_calendar_object() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d + +Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) +==DONE== diff --git a/ext/intl/tests/dateformat_getTimeZone_error.phpt b/ext/intl/tests/dateformat_getTimeZone_error.phpt new file mode 100644 index 0000000000000..4ac5555d88a39 --- /dev/null +++ b/ext/intl/tests/dateformat_getTimeZone_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlDateFormatter::getTimeZone(): bad args +--SKIPIF-- +getTimeZone(9)); +var_dump(datefmt_get_timezone($df, 9)); +var_dump(datefmt_get_timezone($df, 9)); +var_dump(datefmt_get_timezone(new stdclass)); + +?> +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::getTimeZone() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlDateFormatter::getTimeZone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_timezone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_timezone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_timezone() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d + +Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) +==DONE== diff --git a/ext/intl/tests/dateformat_get_set_calendar.phpt b/ext/intl/tests/dateformat_get_set_calendar.phpt index bfd4e578e1ca5..dbb3e6cd2391c 100644 --- a/ext/intl/tests/dateformat_get_set_calendar.phpt +++ b/ext/intl/tests/dateformat_get_set_calendar.phpt @@ -1,60 +1,55 @@ --TEST-- -datefmt_get_calendar_code() datefmt_set_calendar_code() +IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject() --SKIPIF-- - +format($ts), "\n"; +var_dump($df->getCalendar(), +$df->getCalendarObject()->getType(), +$df->getCalendarObject()->getTimeZone()->getId()); +echo "\n"; +} -/* - * Test for the datefmt_get_calendar and datefmt_set_calendar functions - */ - - -function ut_main() -{ - $calendar_arr = array ( - IntlDateFormatter::GREGORIAN, - IntlDateFormatter::TRADITIONAL, - 3 - ); - - $res_str = ''; - - $start_calendar = IntlDateFormatter::GREGORIAN; - $res_str .= "\nCreating IntlDateFormatter with calendar = $start_calendar"; - $fmt = ut_datefmt_create( "de-DE", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT ,'America/Los_Angeles', IntlDateFormatter::GREGORIAN); - $calendar = ut_datefmt_get_calendar( $fmt); - $res_str .= "\nAfter call to get_calendar : calendar= $calendar"; - $res_str .= "\n-------------------"; - - foreach( $calendar_arr as $calendar_entry ) - { - $res_str .= "\nSetting IntlDateFormatter with calendar = $calendar_entry"; - ut_datefmt_set_calendar( $fmt, $calendar_entry); - $calendar = ut_datefmt_get_calendar( $fmt); - $res_str .= "\nAfter call to get_calendar : calendar= $calendar"; - $res_str .= "\n-------------------"; - } - - return $res_str; +$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk'); +d($df); -} -include_once( 'ut_common.inc' ); +//changing the calendar with a cal type should not change tz +$df->setCalendar(IntlDateFormatter::TRADITIONAL); +d($df); + +//but changing with an actual calendar should +$cal = IntlCalendar::createInstance("UTC"); +$df->setCalendar($cal); +d($df); -// Run the test -ut_run(); ?> +==DONE== --EXPECT-- -Creating IntlDateFormatter with calendar = 1 -After call to get_calendar : calendar= 1 -------------------- -Setting IntlDateFormatter with calendar = 1 -After call to get_calendar : calendar= 1 -------------------- -Setting IntlDateFormatter with calendar = 0 -After call to get_calendar : calendar= 0 -------------------- -Setting IntlDateFormatter with calendar = 3 -After call to get_calendar : calendar= 0 -------------------- \ No newline at end of file +dimanche 1 janvier 2012 ap. J.-C. 03:00:00 UTC+03:00 +int(1) +string(9) "gregorian" +string(12) "Europe/Minsk" + +dimanche 8 Safar 1433 AH 03:00:00 UTC+03:00 +int(0) +string(7) "islamic" +string(12) "Europe/Minsk" + +dimanche 1 janvier 2012 ap. J.-C. 00:00:00 UTC +bool(false) +string(9) "gregorian" +string(3) "UTC" + +==DONE== diff --git a/ext/intl/tests/dateformat_get_set_timezone.phpt b/ext/intl/tests/dateformat_get_set_timezone.phpt new file mode 100644 index 0000000000000..41aa35b9cf3c6 --- /dev/null +++ b/ext/intl/tests/dateformat_get_set_timezone.phpt @@ -0,0 +1,62 @@ +--TEST-- +IntlDateFormatter: get/setTimeZone() +--SKIPIF-- +format($ts), "\n"; +var_dump( +$df->getTimeZoneID(), +$df->getTimeZone()->getID()); +echo "\n"; +} + +$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk'); +d($df); + +$df->setTimeZone(NULL); +d($df); + +$df->setTimeZone('Europe/Madrid'); +d($df); + +$df->setTimeZone(IntlTimeZone::createTimeZone('Europe/Paris')); +d($df); + +$df->setTimeZone(new DateTimeZone('Europe/Amsterdam')); +d($df); + +?> +==DONE== +--EXPECTF-- +Domingo, 1 de Janeiro de 2012 3:00:00 GMT+03:00 +string(12) "Europe/Minsk" +string(12) "Europe/Minsk" + +Sábado, 31 de Dezembro de 2011 23:00:00 Hor%s %Sdos Açores +string(15) "Atlantic/Azores" +string(15) "Atlantic/Azores" + +Domingo, 1 de Janeiro de 2012 1:00:00 Hor%s %Sda Europa Central +string(13) "Europe/Madrid" +string(13) "Europe/Madrid" + +Domingo, 1 de Janeiro de 2012 1:00:00 Hor%s %Sda Europa Central +string(12) "Europe/Paris" +string(12) "Europe/Paris" + +Domingo, 1 de Janeiro de 2012 1:00:00 Hor%s %Sda Europa Central +string(16) "Europe/Amsterdam" +string(16) "Europe/Amsterdam" + +==DONE== diff --git a/ext/intl/tests/dateformat_get_timezone_id.phpt b/ext/intl/tests/dateformat_get_timezone_id.phpt index 80cbdbbf0fc1a..a9701c38687ea 100644 --- a/ext/intl/tests/dateformat_get_timezone_id.phpt +++ b/ext/intl/tests/dateformat_get_timezone_id.phpt @@ -1,5 +1,8 @@ --TEST-- datefmt_get_timezone_id_code() +--INI-- +date.timezone=Atlantic/Azores +intl.error_level=E_WARNING --SKIPIF-- --FILE-- @@ -14,8 +17,8 @@ function ut_main() { $timezone_id_arr = array ( 'America/New_York', - 'America/Los_Angeles', - 'America/Dallas' + 'US/Pacific', + 'US/Central' ); $res_str = ''; @@ -42,8 +45,8 @@ ut_run(); Creating IntlDateFormatter with timezone_id = America/New_York After call to get_timezone_id : timezone_id= America/New_York -Creating IntlDateFormatter with timezone_id = America/Los_Angeles -After call to get_timezone_id : timezone_id= America/Los_Angeles +Creating IntlDateFormatter with timezone_id = US/Pacific +After call to get_timezone_id : timezone_id= US/Pacific -Creating IntlDateFormatter with timezone_id = America/Dallas -After call to get_timezone_id : timezone_id= America/Dallas +Creating IntlDateFormatter with timezone_id = US/Central +After call to get_timezone_id : timezone_id= US/Central diff --git a/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt b/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt new file mode 100644 index 0000000000000..5ee5b94d244e3 --- /dev/null +++ b/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlDateFormatter: setTimeZoneID() deprecation +--SKIPIF-- +setTimeZoneId('Europe/Madrid'); + +?> +==DONE== +--EXPECTF-- + +Deprecated: IntlDateFormatter::setTimeZoneId(): Use datefmt_set_timezone() instead, which also accepts a plain time zone identifier and for which this function is now an alias in %s on line %d +==DONE== diff --git a/ext/intl/tests/dateformat_setTimeZone_error.phpt b/ext/intl/tests/dateformat_setTimeZone_error.phpt new file mode 100644 index 0000000000000..bd37031325d86 --- /dev/null +++ b/ext/intl/tests/dateformat_setTimeZone_error.phpt @@ -0,0 +1,53 @@ +--TEST-- +IntlDateFormatter::setTimeZone() bad args +--SKIPIF-- +setTimeZone()); +var_dump(datefmt_set_timezone()); +var_dump($df->setTimeZone(array())); +var_dump($df->setTimeZone(1, 2)); +var_dump($df->setTimeZone('non existing timezone')); +var_dump(datefmt_set_timezone(new stdclass, 'UTC')); + +?> +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::setTimeZone() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_set_timezone() expects exactly 2 parameters, 0 given in %s on line %d + +Warning: datefmt_set_timezone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) + +Notice: Array to string conversion in %s on line %d + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: no such time zone: 'Array' in %s on line %d +bool(false) + +Warning: IntlDateFormatter::setTimeZone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: no such time zone: 'non existing timezone' in %s on line %d +bool(false) + +Warning: datefmt_set_timezone() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d + +Warning: datefmt_set_timezone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) +==DONE== diff --git a/ext/intl/tests/dateformat_set_timezone_id2.phpt b/ext/intl/tests/dateformat_set_timezone_id2.phpt index 23aacda90aeb2..ce9b89d1fdbbf 100644 --- a/ext/intl/tests/dateformat_set_timezone_id2.phpt +++ b/ext/intl/tests/dateformat_set_timezone_id2.phpt @@ -1,11 +1,16 @@ --TEST-- datefmt_set_timezone_id_code() icu >= 4.8 +--INI-- +date.timezone=Atlantic/Azores --SKIPIF-- --FILE-- ---EXPECT-- -After creation of the dateformatter : timezone_id= America/San_Francisco +--EXPECTF-- + +Warning: IntlDateFormatter::setTimeZoneId(): datefmt_set_timezone: no such time zone: 'CN' in %s on line %d + +Warning: datefmt_set_timezone_id(): datefmt_set_timezone: no such time zone: 'CN' in %s on line %d + +After creation of the dateformatter : timezone_id= US/Pacific ----------- Trying to set timezone_id= America/New_York After call to set_timezone_id : timezone_id= America/New_York @@ -71,6 +81,6 @@ Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Cent Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time ----------- Trying to set timezone_id= CN -After call to set_timezone_id : timezone_id= CN -Formatting timestamp=0 resulted in Thursday, January 1, 1970 12:00:00 AM GMT -Formatting timestamp=3600 resulted in Thursday, January 1, 1970 1:00:00 AM GMT +After call to set_timezone_id : timezone_id= America/Chicago +Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Central Standard Time +Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time diff --git a/ext/intl/tests/dateformat_timezone_arg_variations.phpt b/ext/intl/tests/dateformat_timezone_arg_variations.phpt new file mode 100644 index 0000000000000..ccfb5e19646a6 --- /dev/null +++ b/ext/intl/tests/dateformat_timezone_arg_variations.phpt @@ -0,0 +1,45 @@ +--TEST-- +IntlDateFormatter: several forms of the timezone arg +--SKIPIF-- +format($ts), "\n"; + +$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam'); +echo $df->format($ts), "\n"; + +$df = new IntlDateFormatter('es_ES', 0, 0, new DateTimeZone('Europe/Lisbon')); +echo $df->format($ts), "\n"; + +$df = new IntlDateFormatter('es_ES', 0, 0, IntlTimeZone::createTimeZone('America/New_York')); +echo $df->format($ts), "\n"; + +//time zone has priority +$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', new IntlGregorianCalendar('Europe/Lisbon')); +echo $df->format($ts), "\n"; + +//calendar has priority +$df = new IntlDateFormatter('es_ES', 0, 0, NULL, new IntlGregorianCalendar('Europe/Lisbon')); +echo $df->format($ts), "\n"; + +$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', 0); +echo $df->format($ts), "\n"; + +--EXPECTF-- +sábado%S 31 de diciembre de 2011 23:00:00 Hora%S de las Azores +domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central +domingo%S 1 de enero de 2012 00:00:00 Hora%S de Europa Occidental +sábado%S 31 de diciembre de 2011 19:00:00 Hora estándar oriental +domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central +domingo%S 1 de enero de 2012 00:00:00 Hora%S de Europa Occidental +domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central diff --git a/ext/intl/tests/gregoriancalendar___construct_basic.phpt b/ext/intl/tests/gregoriancalendar___construct_basic.phpt new file mode 100644 index 0000000000000..bdbef6725bf32 --- /dev/null +++ b/ext/intl/tests/gregoriancalendar___construct_basic.phpt @@ -0,0 +1,51 @@ +--TEST-- +IntlGregorianCalendar::__construct(): basic +--SKIPIF-- +getTimeZone()->getId()); +var_dump($intlcal->getLocale(1)); + +$intlcal = new IntlGregorianCalendar('Europe/Lisbon', NULL); +var_dump($intlcal->getTimeZone()->getId()); +var_dump($intlcal->getLocale(1)); + +$intlcal = new IntlGregorianCalendar(NULL, 'pt_PT'); +var_dump($intlcal->getTimeZone()->getId()); +var_dump($intlcal->getLocale(1)); + +$intlcal = new IntlGregorianCalendar('Europe/Lisbon', 'pt_PT'); +var_dump($intlcal->getTimeZone()->getId()); +var_dump($intlcal->getLocale(1)); + +$intlcal = new IntlGregorianCalendar('Europe/Paris', 'fr_CA', NULL, NULL, NULL, NULL); +var_dump($intlcal->getTimeZone()->getId()); +var_dump($intlcal->getLocale(1)); + +var_dump($intlcal->getType()); +?> +==DONE== +--EXPECT-- +string(16) "Europe/Amsterdam" +string(5) "nl_NL" +string(13) "Europe/Lisbon" +string(5) "nl_NL" +string(16) "Europe/Amsterdam" +string(5) "pt_PT" +string(13) "Europe/Lisbon" +string(5) "pt_PT" +string(12) "Europe/Paris" +string(5) "fr_CA" +string(9) "gregorian" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/gregoriancalendar___construct_error.phpt b/ext/intl/tests/gregoriancalendar___construct_error.phpt new file mode 100644 index 0000000000000..0e85394a4881b --- /dev/null +++ b/ext/intl/tests/gregoriancalendar___construct_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +IntlGregorianCalendar::__construct(): bad arguments +--SKIPIF-- +getTimeZone()->getId()); +var_dump($intlcal->getTime(), (float)strtotime('2012-02-29 16:00:00') * 1000); + +$intlcal = new IntlGregorianCalendar(2012, 1, 29, 16, 7, 8); +var_dump($intlcal->getTime(), (float)strtotime('2012-02-29 16:07:08') * 1000); + +var_dump($intlcal->getType()); +?> +==DONE== +--EXPECT-- +string(16) "Europe/Amsterdam" +float(1330527600000) +float(1330527600000) +float(1330528028000) +float(1330528028000) +string(9) "gregorian" +==DONE== diff --git a/ext/intl/tests/gregoriancalendar_getGregorianChange_error.phpt b/ext/intl/tests/gregoriancalendar_getGregorianChange_error.phpt new file mode 100644 index 0000000000000..58d566223b685 --- /dev/null +++ b/ext/intl/tests/gregoriancalendar_getGregorianChange_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +IntlGregorianCalendar::getGregorianChange(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getGregorianChange(1)); + +var_dump(intlgregcal_get_gregorian_change($c, 1)); +var_dump(intlgregcal_get_gregorian_change(1)); +--EXPECTF-- + +Warning: IntlGregorianCalendar::getGregorianChange() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlGregorianCalendar::getGregorianChange(): intlgregcal_get_gregorian_change: bad arguments in %s on line %d +bool(false) + +Warning: intlgregcal_get_gregorian_change() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlgregcal_get_gregorian_change(): intlgregcal_get_gregorian_change: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlgregcal_get_gregorian_change() must be an instance of IntlGregorianCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/gregoriancalendar_get_setGregorianChange_basic.phpt b/ext/intl/tests/gregoriancalendar_get_setGregorianChange_basic.phpt new file mode 100644 index 0000000000000..b08ad7981f0fb --- /dev/null +++ b/ext/intl/tests/gregoriancalendar_get_setGregorianChange_basic.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlGregorianCalendar::get/setGregorianChange(): basic test +--SKIPIF-- +getGregorianChange()); + +var_dump($intlcal->setGregorianChange(0)); +var_dump(intlgregcal_get_gregorian_change($intlcal)); + +var_dump(intlgregcal_set_gregorian_change($intlcal, 1)); +var_dump($intlcal->getGregorianChange()); + +?> +==DONE== +--EXPECT-- +float(-12219292800000) +bool(true) +float(0) +bool(true) +float(1) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt b/ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt new file mode 100644 index 0000000000000..b37452fcba896 --- /dev/null +++ b/ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlGregorianCalendar::isLeapYear(): basic test +--SKIPIF-- +isLeapYear(2012)); +var_dump($intlcal->isLeapYear(1900)); + +var_dump(intlgregcal_is_leap_year($intlcal, 2012)); +var_dump(intlgregcal_is_leap_year($intlcal, 1900)); +?> +==DONE== +--EXPECT-- +bool(true) +bool(false) +bool(true) +bool(false) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt b/ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt new file mode 100644 index 0000000000000..40a6c853965e2 --- /dev/null +++ b/ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt @@ -0,0 +1,48 @@ +--TEST-- +IntlGregorianCalendar::isLeapYear(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +isLeapYear(2000, 2011)); +var_dump($c->isLeapYear()); +var_dump($c->isLeapYear("fgdf")); + +var_dump(intlgregcal_is_leap_year($c, 1, 2)); +var_dump(intlgregcal_is_leap_year($c)); +var_dump(intlgregcal_is_leap_year(1, 2)); +--EXPECTF-- + +Warning: IntlGregorianCalendar::isLeapYear() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d +bool(false) + +Warning: IntlGregorianCalendar::isLeapYear() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d +bool(false) + +Warning: IntlGregorianCalendar::isLeapYear() expects parameter 1 to be long, string given in %s on line %d + +Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d +bool(false) + +Warning: intlgregcal_is_leap_year() expects exactly 2 parameters, 3 given in %s on line %d + +Warning: intlgregcal_is_leap_year(): intlgregcal_is_leap_year: bad arguments in %s on line %d +bool(false) + +Warning: intlgregcal_is_leap_year() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlgregcal_is_leap_year(): intlgregcal_is_leap_year: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlgregcal_is_leap_year() must be an instance of IntlGregorianCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/gregoriancalendar_setGregorianChange_error.phpt b/ext/intl/tests/gregoriancalendar_setGregorianChange_error.phpt new file mode 100644 index 0000000000000..eac8deb61b0b1 --- /dev/null +++ b/ext/intl/tests/gregoriancalendar_setGregorianChange_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlGregorianCalendar::setGregorianChange(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +setGregorianChange()); +var_dump($c->setGregorianChange(1, 2)); +var_dump($c->setGregorianChange("sdfds")); + +var_dump(intlgregcal_set_gregorian_change($c)); +var_dump(intlgregcal_set_gregorian_change(1, 4.)); +--EXPECTF-- + +Warning: IntlGregorianCalendar::setGregorianChange() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d +bool(false) + +Warning: IntlGregorianCalendar::setGregorianChange() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d +bool(false) + +Warning: IntlGregorianCalendar::setGregorianChange() expects parameter 1 to be double, string given in %s on line %d + +Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d +bool(false) + +Warning: intlgregcal_set_gregorian_change() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlgregcal_set_gregorian_change(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlgregcal_set_gregorian_change() must be an instance of IntlGregorianCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/ini_use_exceptions_basic.phpt b/ext/intl/tests/ini_use_exceptions_basic.phpt new file mode 100644 index 0000000000000..36ccbcb8a0c56 --- /dev/null +++ b/ext/intl/tests/ini_use_exceptions_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +intl.use_exceptions INI setting +--SKIPIF-- + +--FILE-- +transliterate('a', 3)); +} catch (IntlException $intlE) { + var_dump($intlE->getMessage()); +} +ini_set("intl.use_exceptions", false); +ini_set("intl.error_level", E_NOTICE); +var_dump($t->transliterate('a', 3)); +--EXPECTF-- +string(130) "transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)" + +Notice: Transliterator::transliterate(): transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_datetime.phpt b/ext/intl/tests/msgfmt_format_datetime.phpt new file mode 100644 index 0000000000000..07e7d68f144cd --- /dev/null +++ b/ext/intl/tests/msgfmt_format_datetime.phpt @@ -0,0 +1,28 @@ +--TEST-- +MessageFormatter::format(): DateTime accepted to format dates and times +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +format(array($dt))); + +?> +==DONE== +--EXPECTF-- +string(%s) "May %d, 2012 %d:%d:42 %s" +==DONE== diff --git a/ext/intl/tests/msgfmt_format_error1.phpt b/ext/intl/tests/msgfmt_format_error1.phpt new file mode 100644 index 0000000000000..684b05970a462 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error1.phpt @@ -0,0 +1,19 @@ +--TEST-- +MessageFormatter::format() insufficient numeric arguments +--SKIPIF-- +format(array(7))); + +--EXPECTF-- +string(5) "7 {1}" diff --git a/ext/intl/tests/msgfmt_format_error2.phpt b/ext/intl/tests/msgfmt_format_error2.phpt new file mode 100644 index 0000000000000..85d1b1c83d3df --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error2.phpt @@ -0,0 +1,23 @@ +--TEST-- +MessageFormatter::format() inconsistent types in named argument +--SKIPIF-- +format(array(7))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): Inconsistent types declared for an argument in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error3.phpt b/ext/intl/tests/msgfmt_format_error3.phpt new file mode 100644 index 0000000000000..6dfbee3c908ce --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error3.phpt @@ -0,0 +1,23 @@ +--TEST-- +MessageFormatter::format() given negative arg key +--SKIPIF-- +format(array("foo" => 7, -1 => "bar"))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): Found negative or too large array key in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error4.phpt b/ext/intl/tests/msgfmt_format_error4.phpt new file mode 100644 index 0000000000000..3b92b48b8b037 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error4.phpt @@ -0,0 +1,28 @@ +--TEST-- +MessageFormatter::format() invalid UTF-8 for arg key or value +--SKIPIF-- +format(array("foo" => 7, "\x80" => "bar"))); + +var_dump($mf->format(array("foo" => "\x80"))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): Invalid UTF-8 data in argument key: '' in %s on line %d +bool(false) + +Warning: MessageFormatter::format(): Invalid UTF-8 data in string argument: '' in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error5.phpt b/ext/intl/tests/msgfmt_format_error5.phpt new file mode 100644 index 0000000000000..ebbd4550e8f46 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error5.phpt @@ -0,0 +1,26 @@ +--TEST-- +MessageFormatter::format() invalid date/time argument +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +format(array("foo" => new stdclass()))); + +--EXPECTF-- +Warning: MessageFormatter::format(): msgfmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted) in %s on line %d + +Warning: MessageFormatter::format(): The argument for key 'foo' cannot be used as a date or time in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error6.phpt b/ext/intl/tests/msgfmt_format_error6.phpt new file mode 100644 index 0000000000000..b07d2ab774843 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error6.phpt @@ -0,0 +1,23 @@ +--TEST-- +MessageFormatter::format() invalid type for key not in pattern +--SKIPIF-- +format(array("foo" => 'bar', 7 => fopen('php://memory', 'r+')))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): No strategy to convert the value given for the argument with key '7' is available in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_intlcalendar.phpt b/ext/intl/tests/msgfmt_format_intlcalendar.phpt new file mode 100644 index 0000000000000..6ae78a91400c0 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_intlcalendar.phpt @@ -0,0 +1,30 @@ +--TEST-- +MessageFormat accepts IntlCalendar args +--SKIPIF-- +format(array($cal)), "\n"; + +//NOT FIXED: +/*$msgf = new MessageFormatter('en_US', +'{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); + +echo "msgf2: ", $msgf->format(array($time, 'date')), " ", + $msgf->format(array($time, 'time')), "\n"; +*/ + +?> +==DONE== +--EXPECT-- +Quinta-feira, 17 de Maio de 2012 5:35:36 p.m. WEST +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/msgfmt_format_mixed_params.phpt b/ext/intl/tests/msgfmt_format_mixed_params.phpt new file mode 100644 index 0000000000000..93412f49e22a1 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_mixed_params.phpt @@ -0,0 +1,25 @@ +--TEST-- +MessageFormatter::format(): mixed named and numeric parameters +--SKIPIF-- +format(array(2.3, "foo" => 1.3))); +var_dump($mf->format(array("foo" => 1.3, 0 => 2.3))); + +?> +==DONE== +--EXPECT-- +string(10) "2.3 -- 1st" +string(10) "2.3 -- 1st" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt b/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt new file mode 100644 index 0000000000000..299ae483a49b4 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt @@ -0,0 +1,58 @@ +--TEST-- +MessageFormatter::format(): simple types handling with numeric strings +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +format(array( +'a' => $ex, +'b' => $ex, +'c' => $ex, +'d' => $ex, +'e' => $ex, +'f' => " 1336317965.5", +'g' => " 1336317965.5", +'h' => $ex, +'i' => $ex, +'j' => $ex, +))); + +?> +==DONE== +--EXPECTF-- +string(%d) " + none 1336317965.5 str + number 1,336,317,965.5 + number integer 1,336,317,965 + number currency $1,336,317,965.50 + number percent 133,631,796,550% + date May %d, 2012 + time %d:%d:05 PM + spellout one billion three hundred thirty-six million three hundred seventeen thousand nine hundred sixty-five point five + ordinal 1,336,317,966th + duration 371,199:26:06 + " +==DONE== diff --git a/ext/intl/tests/msgfmt_format_subpatterns.phpt b/ext/intl/tests/msgfmt_format_subpatterns.phpt new file mode 100644 index 0000000000000..9f11e3e255443 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_subpatterns.phpt @@ -0,0 +1,75 @@ +--TEST-- +msgfmt_format() with subpatterns +--SKIPIF-- + +--EXPECT-- +'Alice does not give a party.' +'Alice does not give a party.' +'Alice invites Bob to his party.' +'Alice invites Bob to his party.' +'Alice invites Bob and one other person to their party.' +'Alice invites Bob and one other person to their party.' +'Alice invites Bob as one of the 26 people invited to her party.' +'Alice invites Bob as one of the 26 people invited to her party.' diff --git a/ext/intl/tests/msgfmt_format_subpatterns_named.phpt b/ext/intl/tests/msgfmt_format_subpatterns_named.phpt new file mode 100644 index 0000000000000..f6af02561bc99 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_subpatterns_named.phpt @@ -0,0 +1,75 @@ +--TEST-- +msgfmt_format() with named subpatterns +--SKIPIF-- + 'female', 'num_guests' => 0, 'host' => 'Alice', 'guest' => 'Bob'), + array('gender_of_host' => 'male', 'num_guests' => 1, 'host' => 'Alice', 'guest' => 'Bob'), + array('gender_of_host' => 'none', 'num_guests' => 2, 'host' => 'Alice', 'guest' => 'Bob'), + array('gender_of_host' => 'female', 'num_guests' => 27, 'host' => 'Alice', 'guest' => 'Bob'), +); + +$str_res = ''; + + $fmt = ut_msgfmt_create( 'en_US', $pattern ); + if(!$fmt) { + $str_res .= dump(intl_get_error_message())."\n"; + return $str_res; + } + foreach ($args as $arg) { + $str_res .= dump( ut_msgfmt_format($fmt, $arg) ). "\n"; + $str_res .= dump( ut_msgfmt_format_message('en_US', $pattern, $arg) ) . "\n"; + } + return $str_res; +} + +include_once( 'ut_common.inc' ); + +// Run the test +ut_run(); + +?> +--EXPECT-- +'Alice does not give a party.' +'Alice does not give a party.' +'Alice invites Bob to his party.' +'Alice invites Bob to his party.' +'Alice invites Bob and one other person to their party.' +'Alice invites Bob and one other person to their party.' +'Alice invites Bob as one of the 26 people invited to her party.' +'Alice invites Bob as one of the 26 people invited to her party.' diff --git a/ext/intl/tests/msgfmt_get_error.phpt b/ext/intl/tests/msgfmt_get_error.phpt deleted file mode 100644 index 015c50d465952..0000000000000 --- a/ext/intl/tests/msgfmt_get_error.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -msgmfmt_get_error_message/code() ---SKIPIF-- - ---FILE-- -getErrorMessage() . " (" . $fmt->getErrorCode() . ")\n"; - else - return "Ooops, an error should have occured."; -} - -include_once( 'ut_common.inc' ); - -// Run the test -ut_run(); -?> ---EXPECT-- -msgfmt_format: not enough parameters: U_ILLEGAL_ARGUMENT_ERROR (1) diff --git a/ext/intl/tests/msgfmt_millisecond_dates.phpt b/ext/intl/tests/msgfmt_millisecond_dates.phpt new file mode 100644 index 0000000000000..7dd051426b272 --- /dev/null +++ b/ext/intl/tests/msgfmt_millisecond_dates.phpt @@ -0,0 +1,29 @@ +--TEST-- +MessageFrormatter parses and formats dates with millisecond precision +--SKIPIF-- +format(array(1336310569.123))); + +$p = 'On 2012-05-06 AD at 15:22:49.123 GMT+02:00 something odd happened'; +var_dump($mf->parse($p)); + +?> +==DONE== +--EXPECTF-- +string(%d) "On 2012-05-0%d AD at %d:%d:49.123 %s something odd happened" +array(1) { + [0]=> + float(1336310569.123) +} +==DONE== diff --git a/ext/intl/tests/msgfmt_setPattern_cache.phpt b/ext/intl/tests/msgfmt_setPattern_cache.phpt new file mode 100644 index 0000000000000..35ec463c2a7a7 --- /dev/null +++ b/ext/intl/tests/msgfmt_setPattern_cache.phpt @@ -0,0 +1,26 @@ +--TEST-- +MessageFormatter::setPattern() invalidates arg types cache +--SKIPIF-- +format(array(1.3, 1.3))); +var_dump($mf->format(array(1.3, 1.3))); +$mf->setPattern("{0,ordinal} -- {1,number}"); +var_dump($mf->format(array(1.3, 1.3))); + +?> +==DONE== +--EXPECT-- +string(10) "1.3 -- 1st" +string(10) "1.3 -- 1st" +string(10) "1st -- 1.3" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/rbbiter___construct_basic.phpt b/ext/intl/tests/rbbiter___construct_basic.phpt new file mode 100644 index 0000000000000..6fb584fdee5b8 --- /dev/null +++ b/ext/intl/tests/rbbiter___construct_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +IntlRuleBasedBreakIterator::__construct: basic test +--SKIPIF-- + +==DONE== +--EXPECT-- +string(26) "IntlRuleBasedBreakIterator" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt b/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt new file mode 100644 index 0000000000000..dce0714d4dd4f --- /dev/null +++ b/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +IntlRuleBasedBreakIterator::getBinaryRules(): basic test +--SKIPIF-- + += 4.8 only'; ?> +--FILE-- +setText('sdfkjsdf88á.... ,;');; + +$br = $rbbi->getBinaryRules(); + +$rbbi2 = new IntlRuleBasedBreakIterator($br, true); + +var_dump($rbbi->getRules(), $rbbi2->getRules()); +var_dump($rbbi->getRules() == $rbbi2->getRules()); +?> +==DONE== +--EXPECT-- +string(128) "$LN = [[:letter:] [:number:]];$S = [.;,:];!!forward;$LN+ {1};$S+ {42};!!reverse;$LN+ {1};$S+ {42};!!safe_forward;!!safe_reverse;" +string(128) "$LN = [[:letter:] [:number:]];$S = [.;,:];!!forward;$LN+ {1};$S+ {42};!!reverse;$LN+ {1};$S+ {42};!!safe_forward;!!safe_reverse;" +bool(true) +==DONE== diff --git a/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt b/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt new file mode 100644 index 0000000000000..a56f6bc48867b --- /dev/null +++ b/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt @@ -0,0 +1,59 @@ +--TEST-- +IntlRuleBasedBreakIterator::getRuleStatusVec(): basic test +--SKIPIF-- +setText('sdfkjsdf88á.... ,;');; + +do { + var_dump($rbbi->current(), $rbbi->getRuleStatusVec()); +} while ($rbbi->next() != IntlBreakIterator::DONE); + +?> +==DONE== +--EXPECT-- +int(0) +array(1) { + [0]=> + int(0) +} +int(12) +array(2) { + [0]=> + int(1) + [1]=> + int(4) +} +int(16) +array(1) { + [0]=> + int(42) +} +int(19) +array(1) { + [0]=> + int(4) +} +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/rbbiter_getRuleStatus_basic.phpt b/ext/intl/tests/rbbiter_getRuleStatus_basic.phpt new file mode 100644 index 0000000000000..80eedbfba5f0c --- /dev/null +++ b/ext/intl/tests/rbbiter_getRuleStatus_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +IntlRuleBasedBreakIterator::getRuleStatus(): basic test +--SKIPIF-- +setText('sdfkjsdf88á.... ,;'); + +do { + echo "pos : {$rbbi->current()}\n", + "rule status: {$rbbi->getRuleStatus()}\n"; +} while ($rbbi->next() != IntlBreakIterator::DONE); + +?> +==DONE== +--EXPECT-- +pos : 0 +rule status: 0 +pos : 12 +rule status: 1 +pos : 16 +rule status: 42 +pos : 17 +rule status: 0 +pos : 19 +rule status: 42 +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/rbbiter_getRules_basic.phpt b/ext/intl/tests/rbbiter_getRules_basic.phpt new file mode 100644 index 0000000000000..2f7a40eb716b6 --- /dev/null +++ b/ext/intl/tests/rbbiter_getRules_basic.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlRuleBasedBreakIterator::getRules(): basic test +--SKIPIF-- +getRules()); + +?> +==DONE== +--EXPECT-- +string(128) "$LN = [[:letter:] [:number:]];$S = [.;,:];!!forward;$LN+ {1};$S+ {42};!!reverse;$LN+ {1};$S+ {42};!!safe_forward;!!safe_reverse;" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_clone_basic.phpt b/ext/intl/tests/timezone_clone_basic.phpt new file mode 100644 index 0000000000000..a8ef83f864142 --- /dev/null +++ b/ext/intl/tests/timezone_clone_basic.phpt @@ -0,0 +1,51 @@ +--TEST-- +IntlTimeZone clone handler: basic test +--SKIPIF-- + +==DONE== +--EXPECTF-- +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Amsterdam + [rawOffset] => 3600000 + [currentOffset] => %d +) +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Amsterdam + [rawOffset] => 3600000 + [currentOffset] => %d +) +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT + [rawOffset] => 0 + [currentOffset] => 0 +) +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT + [rawOffset] => 0 + [currentOffset] => 0 +) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_clone_error.phpt b/ext/intl/tests/timezone_clone_error.phpt new file mode 100644 index 0000000000000..df501be3b4c11 --- /dev/null +++ b/ext/intl/tests/timezone_clone_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlTimeZone clone handler: error test +--SKIPIF-- +getMessage()); +} + +?> +==DONE== +--EXPECT-- +object(A)#1 (1) { + ["valid"]=> + bool(false) +} +string(9) "Exception" +string(39) "Cannot clone unconstructed IntlTimeZone" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_countEquivalentIDs_basic.phpt b/ext/intl/tests/timezone_countEquivalentIDs_basic.phpt new file mode 100644 index 0000000000000..ec3e4050ab5cc --- /dev/null +++ b/ext/intl/tests/timezone_countEquivalentIDs_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +IntlTimeZone::countEquivalentIDs(): basic test +--SKIPIF-- += 2); + +$count2 = intltz_count_equivalent_ids('Europe/Lisbon'); +var_dump($count2 == $count); +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_countEquivalentIDs_error.phpt b/ext/intl/tests/timezone_countEquivalentIDs_error.phpt new file mode 100644 index 0000000000000..4d8f4bc3e3b50 --- /dev/null +++ b/ext/intl/tests/timezone_countEquivalentIDs_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +IntlTimeZone::countEquivalentIDs(): errors +--SKIPIF-- + +==DONE== +--EXPECTF-- +IntlTimeZone Object +( + [valid] => 1 + [id] => %s + [rawOffset] => %i + [currentOffset] => %i +) +IntlTimeZone Object +( + [valid] => 1 + [id] => %s + [rawOffset] => %i + [currentOffset] => %i +) +==DONE== diff --git a/ext/intl/tests/timezone_createDefault_error.phpt b/ext/intl/tests/timezone_createDefault_error.phpt new file mode 100644 index 0000000000000..07248982193c7 --- /dev/null +++ b/ext/intl/tests/timezone_createDefault_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlTimeZone::createDefault(): errors +--SKIPIF-- + 300); + +$tz = intltz_create_enumeration(); +var_dump(get_class($tz)); +$count2 = count(iterator_to_array($tz)); +var_dump($count == $count2); +?> +==DONE== +--EXPECT-- +string(12) "IntlIterator" +bool(true) +string(12) "IntlIterator" +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_createEnumeration_error.phpt b/ext/intl/tests/timezone_createEnumeration_error.phpt new file mode 100644 index 0000000000000..e1e7cb9333a98 --- /dev/null +++ b/ext/intl/tests/timezone_createEnumeration_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlTimeZone::createEnumeration(): errors +--SKIPIF-- + 20); + +$tz->rewind(); +var_dump(in_array('Europe/Amsterdam', iterator_to_array($tz))); + +?> +==DONE== +--EXPECT-- +string(12) "IntlIterator" +bool(true) +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_createEnumeration_variation2.phpt b/ext/intl/tests/timezone_createEnumeration_variation2.phpt new file mode 100644 index 0000000000000..ddf1a6ece1b39 --- /dev/null +++ b/ext/intl/tests/timezone_createEnumeration_variation2.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlTimeZone::createEnumeration(): variant with country +--SKIPIF-- += 1); + +$tz->rewind(); +var_dump(in_array('Europe/Amsterdam', iterator_to_array($tz))); + +?> +==DONE== +--EXPECT-- +string(12) "IntlIterator" +bool(true) +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt new file mode 100644 index 0000000000000..9ceffc5289bbd --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlTimeZone::createTimeZoneIDEnumeration(): basic test +--SKIPIF-- + +==DONE== +--EXPECT-- +Array +( + [0] => Atlantic/Azores +) +Array +( + [0] => Atlantic/Azores +) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt new file mode 100644 index 0000000000000..2cc2ac48e7053 --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlTimeZone::createTimeZoneIDEnumeration(): errors +--SKIPIF-- + +==DONE== +--EXPECT-- +bool(true) +bool(true) +bool(true) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt new file mode 100644 index 0000000000000..2afe171c580fd --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt @@ -0,0 +1,52 @@ +--TEST-- +IntlTimeZone::createTimeZoneIDEnumeration(): variant without region +--SKIPIF-- + $countCanonical); +var_dump($countCanonical > $countCanonicalLocation); + +$enum = IntlTimeZone::createTimeZoneIDEnumeration( + IntlTimeZone::TYPE_ANY, null, null); +$countAny2 = count(iterator_to_array($enum)); +var_dump($countAny == $countAny2); + +$enum = IntlTimeZone::createTimeZoneIDEnumeration( + IntlTimeZone::TYPE_ANY, null, -3600000); +$values = iterator_to_array($enum); + +print_r( +array_values( +array_intersect($values, +array('Etc/GMT+1', 'Atlantic/Azores')) +)); + + +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +bool(true) +Array +( + [0] => Atlantic/Azores + [1] => Etc/GMT+1 +) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_createTimeZone_basic.phpt b/ext/intl/tests/timezone_createTimeZone_basic.phpt new file mode 100644 index 0000000000000..e79f5b58ee2a1 --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZone_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlTimeZone::createTimeZone(): basic test +--SKIPIF-- + +==DONE== +--EXPECT-- +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT+01:00 + [rawOffset] => 3600000 + [currentOffset] => 3600000 +) +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT+01:00 + [rawOffset] => 3600000 + [currentOffset] => 3600000 +) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_createTimeZone_error.phpt b/ext/intl/tests/timezone_createTimeZone_error.phpt new file mode 100644 index 0000000000000..2be821a67eecd --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZone_error.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlTimeZone::createTimeZone(): errors +--SKIPIF-- + +==DONE== +--EXPECT-- +Comparison to self: +bool(true) +Comparison to equal instance: +bool(true) +Comparison to equivalent instance: +bool(false) +Comparison to GMT: +bool(false) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_equals_error.phpt b/ext/intl/tests/timezone_equals_error.phpt new file mode 100644 index 0000000000000..d8d027a761a8e --- /dev/null +++ b/ext/intl/tests/timezone_equals_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlTimeZone equals handler: error test +--SKIPIF-- +getMessage()); +} + +?> +==DONE== +--EXPECT-- +object(A)#1 (1) { + ["valid"]=> + bool(false) +} +object(IntlTimeZone)#2 (4) { + ["valid"]=> + bool(true) + ["id"]=> + string(3) "GMT" + ["rawOffset"]=> + int(0) + ["currentOffset"]=> + int(0) +} +string(9) "Exception" +string(63) "Comparison with at least one unconstructed IntlTimeZone operand" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_fromDateTimeZone_basic.phpt b/ext/intl/tests/timezone_fromDateTimeZone_basic.phpt new file mode 100644 index 0000000000000..10e2621ae4a21 --- /dev/null +++ b/ext/intl/tests/timezone_fromDateTimeZone_basic.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlTimeZone::fromDateTimeZone(): basic test +--SKIPIF-- +getID(), $tz->getRawOffset()); + + +$dt = new DateTime('2012-01-01 00:00:00 CET'); +$dtz = $dt->getTimeZone(); +/* this is different from new DateTimeZone('CET'), + * which gives a Europe/Berlin timezone */ +var_dump($dtz->getName()); +$tz = IntlTimeZone::fromDateTimeZone($dtz); +var_dump($tz->getID(), $tz->getRawOffset()); + + +$dt = new DateTime('2012-01-01 00:00:00 +0340'); +$dtz = $dt->getTimeZone(); +/* I don't think this timezone can be generated without a DateTime object */ +var_dump($dtz->getName()); +$tz = IntlTimeZone::fromDateTimeZone($dtz); +var_dump($tz->getID(), $tz->getRawOffset() /* (3*60+40)*60000 */); + +--EXPECTF-- +string(16) "Europe/Amsterdam" +int(3600000) +string(3) "CET" +string(3) "CET" +int(3600000) +string(6) "+03:40" +string(%d) "GMT+03%s0" +int(13200000) diff --git a/ext/intl/tests/timezone_fromDateTimeZone_error.phpt b/ext/intl/tests/timezone_fromDateTimeZone_error.phpt new file mode 100644 index 0000000000000..031882277e6d3 --- /dev/null +++ b/ext/intl/tests/timezone_fromDateTimeZone_error.phpt @@ -0,0 +1,50 @@ +--TEST-- +IntlTimeZone::fromDateTimeZone(): argument errors +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getTimeZone())); + +var_dump(intltz_from_date_time_zone()); + +--EXPECTF-- + +Warning: IntlTimeZone::fromDateTimeZone() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d +NULL + +Warning: IntlTimeZone::fromDateTimeZone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d +NULL + +Warning: IntlTimeZone::fromDateTimeZone() expects parameter 1 to be DateTimeZone, string given in %s on line %d + +Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d +NULL + +Warning: IntlTimeZone::fromDateTimeZone() expects parameter 1 to be DateTimeZone, object given in %s on line %d + +Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d +NULL + +Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d +NULL + +Warning: intltz_from_date_time_zone() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: intltz_from_date_time_zone(): intltz_from_date_time_zone: bad arguments in %s on line %d +NULL diff --git a/ext/intl/tests/timezone_getCanonicalID_basic.phpt b/ext/intl/tests/timezone_getCanonicalID_basic.phpt new file mode 100644 index 0000000000000..897e9a9edc9f1 --- /dev/null +++ b/ext/intl/tests/timezone_getCanonicalID_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlTimeZone::getCanonicalID: basic test +--SKIPIF-- + +==DONE== +--EXPECT-- +Europe/Lisbon +Europe/Lisbon +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getCanonicalID_error.phpt b/ext/intl/tests/timezone_getCanonicalID_error.phpt new file mode 100644 index 0000000000000..c7ffb45b77728 --- /dev/null +++ b/ext/intl/tests/timezone_getCanonicalID_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlTimeZone::getCanonicalID(): errors +--SKIPIF-- + +==DONE== +--EXPECT-- +string(13) "Europe/Lisbon" +bool(true) +string(0) "" +bool(false) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getDSTSavings_basic.phpt b/ext/intl/tests/timezone_getDSTSavings_basic.phpt new file mode 100644 index 0000000000000..8dee5b8e9405a --- /dev/null +++ b/ext/intl/tests/timezone_getDSTSavings_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +IntlTimeZone::getDSTSavings(): basic test +--SKIPIF-- +getDSTSavings()); + +var_dump(intltz_get_dst_savings($lsb)); + +?> +==DONE== +--EXPECT-- +int(3600000) +int(3600000) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getDSTSavings_error.phpt b/ext/intl/tests/timezone_getDSTSavings_error.phpt new file mode 100644 index 0000000000000..e1469f4ac6d65 --- /dev/null +++ b/ext/intl/tests/timezone_getDSTSavings_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlTimeZone::getDSTSavings(): errors +--SKIPIF-- +getDSTSavings(array())); + +var_dump(intltz_get_dst_savings(null)); + +--EXPECTF-- + +Warning: IntlTimeZone::getDSTSavings() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getDSTSavings(): intltz_get_dst_savings: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_dst_savings() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getDisplayName_basic.phpt b/ext/intl/tests/timezone_getDisplayName_basic.phpt new file mode 100644 index 0000000000000..e4fc2f37cea10 --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlTimeZone::getDisplayName(): basic test +--SKIPIF-- +getDisplayName()); + +ini_set('intl.default_locale', 'pt_PT'); +var_dump($lsb->getDisplayName()); + +?> +==DONE== +--EXPECTF-- +string(%d) "Western European%sTime" +string(%d) "Hora%sda Europa Ocidental" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getDisplayName_error.phpt b/ext/intl/tests/timezone_getDisplayName_error.phpt new file mode 100644 index 0000000000000..a12f85c8552db --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_error.phpt @@ -0,0 +1,45 @@ +--TEST-- +IntlTimeZone::getDisplayName(): errors +--SKIPIF-- +getDisplayName(array())); +var_dump($tz->getDisplayName(false, array())); +var_dump($tz->getDisplayName(false, -1)); +var_dump($tz->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT, array())); +var_dump($tz->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT, NULL, NULL)); + +var_dump(intltz_get_display_name(null, IntlTimeZone::DISPLAY_SHORT, false, 'pt_PT')); + +--EXPECTF-- + +Warning: IntlTimeZone::getDisplayName() expects parameter 1 to be boolean, array given in %s on line %d + +Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getDisplayName() expects parameter 2 to be long, array given in %s on line %d + +Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: wrong display type in %s on line %d +bool(false) + +Warning: IntlTimeZone::getDisplayName() expects parameter 3 to be string, array given in %s on line %d + +Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getDisplayName() expects at most 3 parameters, 4 given in %s on line %d + +Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_display_name() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getDisplayName_variant1.phpt b/ext/intl/tests/timezone_getDisplayName_variant1.phpt new file mode 100644 index 0000000000000..83922dd1706c4 --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_variant1.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlTimeZone::getDisplayName(): daylight parameter effect +--SKIPIF-- +getDisplayName()); +var_dump($lsb->getDisplayName(false)); +var_dump($lsb->getDisplayName(true)); + +?> +==DONE== +--EXPECTF-- +string(%d) "Western European%sTime" +string(%d) "Western European%sTime" +string(28) "Western European Summer Time" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt b/ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt new file mode 100644 index 0000000000000..4ee30aee12642 --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt @@ -0,0 +1,38 @@ +--TEST-- +IntlTimeZone::getDisplayName(): type parameter (ICU >= 49) +--SKIPIF-- +getDisplayName(false, IntlTimeZone::DISPLAY_SHORT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_GENERIC)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG_GENERIC)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_GMT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG_GMT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_COMMONLY_USED)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_GENERIC_LOCATION)); + +?> +==DONE== +--EXPECT-- +string(3) "GMT" +string(30) "Western European Standard Time" +string(22) "Portugal Time (Lisbon)" +string(21) "Western European Time" +string(5) "+0000" +string(3) "GMT" +string(3) "GMT" +string(22) "Portugal Time (Lisbon)" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getDisplayName_variant2.phpt b/ext/intl/tests/timezone_getDisplayName_variant2.phpt new file mode 100644 index 0000000000000..1ccf68767fef5 --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_variant2.phpt @@ -0,0 +1,40 @@ +--TEST-- +IntlTimeZone::getDisplayName(): type parameter (ICU < 49) +--SKIPIF-- += 0) + die('skip for ICU < 49'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +getDisplayName(false, IntlTimeZone::DISPLAY_SHORT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_GENERIC)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG_GENERIC)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_GMT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG_GMT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_COMMONLY_USED)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_GENERIC_LOCATION)); + +?> +==DONE== +--EXPECT-- +string(3) "WET" +string(21) "Western European Time" +string(22) "Portugal Time (Lisbon)" +string(22) "Portugal Time (Lisbon)" +string(5) "+0000" +string(3) "GMT" +string(3) "GMT" +string(22) "Portugal Time (Lisbon)" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getDisplayName_variant3-49+.phpt b/ext/intl/tests/timezone_getDisplayName_variant3-49+.phpt new file mode 100644 index 0000000000000..e90cc4748c9b9 --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_variant3-49+.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlTimeZone::getDisplayName(): locale parameter +--SKIPIF-- +getDisplayName(false, IntlTimeZone::DISPLAY_LONG)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG, NULL)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG, 'pt_PT')); + +?> +==DONE== +--EXPECT-- +string(30) "Western European Standard Time" +string(30) "Western European Standard Time" +string(32) "Hora Padrão da Europa Ocidental" +==DONE== diff --git a/ext/intl/tests/timezone_getDisplayName_variant3.phpt b/ext/intl/tests/timezone_getDisplayName_variant3.phpt new file mode 100644 index 0000000000000..c160777583632 --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_variant3.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlTimeZone::getDisplayName(): locale parameter +--SKIPIF-- += 0) + die('skip for ICU <= 4.8'); +--FILE-- +getDisplayName(false, IntlTimeZone::DISPLAY_LONG)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG, NULL)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG, 'pt_PT')); + +?> +==DONE== +--EXPECT-- +string(21) "Western European Time" +string(21) "Western European Time" +string(24) "Hora da Europa Ocidental" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getEquivalentID_basic.phpt b/ext/intl/tests/timezone_getEquivalentID_basic.phpt new file mode 100644 index 0000000000000..8af1e20897d68 --- /dev/null +++ b/ext/intl/tests/timezone_getEquivalentID_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlTimeZone::getEquivalentID(): basic test +--SKIPIF-- + +==DONE== +--EXPECT-- +Portugal +Portugal +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getEquivalentID_error.phpt b/ext/intl/tests/timezone_getEquivalentID_error.phpt new file mode 100644 index 0000000000000..b3f344b54d747 --- /dev/null +++ b/ext/intl/tests/timezone_getEquivalentID_error.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlTimeZone::getEquivalentID(): errors +--SKIPIF-- +getErrorCode()); +var_dump($lsb->getErrorMessage()); + +var_dump($lsb->getOffset(INF, 1, $a, $b)); + +var_dump($lsb->getErrorCode()); +var_dump($lsb->getErrorMessage()); + +?> +==DONE== +--EXPECTF-- +int(0) +string(12) "U_ZERO_ERROR" + +Warning: IntlTimeZone::getOffset(): intltz_get_offset: error obtaining offset in %s on line %d +bool(false) +int(1) +string(67) "intltz_get_offset: error obtaining offset: U_ILLEGAL_ARGUMENT_ERROR" +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getErrorCode_error.phpt b/ext/intl/tests/timezone_getErrorCode_error.phpt new file mode 100644 index 0000000000000..b56d3b0a48a02 --- /dev/null +++ b/ext/intl/tests/timezone_getErrorCode_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlTimeZone::getErrorCode(): errors +--SKIPIF-- +getErrorCode(array())); + +var_dump(intltz_get_error_code(null)); + +--EXPECTF-- + +Warning: IntlTimeZone::getErrorCode() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getErrorCode(): intltz_get_error_code: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_error_code() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getErrorMessage_error.phpt b/ext/intl/tests/timezone_getErrorMessage_error.phpt new file mode 100644 index 0000000000000..067dcdc13b808 --- /dev/null +++ b/ext/intl/tests/timezone_getErrorMessage_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlTimeZone::getErrorMessage(): errors +--SKIPIF-- +getErrorMessage(array())); + +var_dump(intltz_get_error_message(null)); + +--EXPECTF-- + +Warning: IntlTimeZone::getErrorMessage() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getErrorMessage(): intltz_get_error_message: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_error_message() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getGMT_basic.phpt b/ext/intl/tests/timezone_getGMT_basic.phpt new file mode 100644 index 0000000000000..99b3fa22ca2b1 --- /dev/null +++ b/ext/intl/tests/timezone_getGMT_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +IntlTimeZone::getGMT(): basic test +--SKIPIF-- + +==DONE== +--EXPECT-- +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT + [rawOffset] => 0 + [currentOffset] => 0 +) +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT + [rawOffset] => 0 + [currentOffset] => 0 +) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getGMT_error.phpt b/ext/intl/tests/timezone_getGMT_error.phpt new file mode 100644 index 0000000000000..15afb765e4ad7 --- /dev/null +++ b/ext/intl/tests/timezone_getGMT_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlTimeZone::getGMT(): errors +--SKIPIF-- +getID('foo')); +intltz_get_id(null); + + +--EXPECTF-- + +Warning: IntlTimeZone::getID() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getID(): intltz_get_id: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_id() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getOffset_basic.phpt b/ext/intl/tests/timezone_getOffset_basic.phpt new file mode 100644 index 0000000000000..582d45cad9168 --- /dev/null +++ b/ext/intl/tests/timezone_getOffset_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlTimeZone::getOffset(): basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +getOffset($date *1000., true, $rawOffset, $dstOffset), + $rawOffset, $dstOffset); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); + +var_dump(intltz_get_offset($lsb, $date *1000., true, $rawOffset, $dstOffset), + $rawOffset, $dstOffset); + +?> +==DONE== +--EXPECT-- +bool(true) +int(3600000) +int(3600000) +bool(true) +int(0) +int(3600000) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getOffset_error.phpt b/ext/intl/tests/timezone_getOffset_error.phpt new file mode 100644 index 0000000000000..73555002c02e9 --- /dev/null +++ b/ext/intl/tests/timezone_getOffset_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlTimeZone::getOffset(): errors +--SKIPIF-- +getOffset(INF, true, $a, $a)); +var_dump($tz->getOffset(time()*1000, true, $a)); +var_dump($tz->getOffset(time()*1000, true, $a, $a, $a)); + +intltz_get_offset(null, time()*1000, false, $a, $a); + +--EXPECTF-- + +Warning: IntlTimeZone::getOffset(): intltz_get_offset: error obtaining offset in %s on line %d +bool(false) + +Warning: IntlTimeZone::getOffset() expects exactly 4 parameters, 3 given in %s on line %d + +Warning: IntlTimeZone::getOffset(): intltz_get_offset: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getOffset() expects exactly 4 parameters, 5 given in %s on line %d + +Warning: IntlTimeZone::getOffset(): intltz_get_offset: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_offset() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getRawOffset_basic.phpt b/ext/intl/tests/timezone_getRawOffset_basic.phpt new file mode 100644 index 0000000000000..a2b4debf2b0c8 --- /dev/null +++ b/ext/intl/tests/timezone_getRawOffset_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +IntlTimeZone::getRawOffset(): basic test +--SKIPIF-- +getRawOffset()); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump(intltz_get_raw_offset($lsb)); + +?> +==DONE== +--EXPECT-- +int(3600000) +int(0) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getRawOffset_error.phpt b/ext/intl/tests/timezone_getRawOffset_error.phpt new file mode 100644 index 0000000000000..eb6aac02cd0dd --- /dev/null +++ b/ext/intl/tests/timezone_getRawOffset_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlTimeZone::getRawOffset(): errors +--SKIPIF-- +getRawOffset('foo')); + +intltz_get_raw_offset(null); + +--EXPECTF-- + +Warning: IntlTimeZone::getRawOffset() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getRawOffset(): intltz_get_raw_offset: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_raw_offset() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getRegion_basic.phpt b/ext/intl/tests/timezone_getRegion_basic.phpt new file mode 100644 index 0000000000000..1a41ae8d583bc --- /dev/null +++ b/ext/intl/tests/timezone_getRegion_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +IntlTimeZone::getRegion(): basic test +--SKIPIF-- + +==DONE== +--EXPECT-- +NL +NL +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getRegion_error.phpt b/ext/intl/tests/timezone_getRegion_error.phpt new file mode 100644 index 0000000000000..34911d9abc687 --- /dev/null +++ b/ext/intl/tests/timezone_getRegion_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlTimeZone::getRegion(): errors +--SKIPIF-- + +==DONE== +--EXPECTF-- +20%d%s +20%d%s +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getUnknown_basic.phpt b/ext/intl/tests/timezone_getUnknown_basic.phpt new file mode 100644 index 0000000000000..aef1a54561c96 --- /dev/null +++ b/ext/intl/tests/timezone_getUnknown_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +IntlCalendar::getUnknown(): basic test +--SKIPIF-- + +==DONE== +--EXPECT-- +IntlTimeZone Object +( + [valid] => 1 + [id] => Etc/Unknown + [rawOffset] => 0 + [currentOffset] => 0 +) +IntlTimeZone Object +( + [valid] => 1 + [id] => Etc/Unknown + [rawOffset] => 0 + [currentOffset] => 0 +) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_getUnknown_error.phpt b/ext/intl/tests/timezone_getUnknown_error.phpt new file mode 100644 index 0000000000000..704b1b096ffa6 --- /dev/null +++ b/ext/intl/tests/timezone_getUnknown_error.phpt @@ -0,0 +1,29 @@ +--TEST-- +IntlCalendar::getUnknown(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +hasSameRules($lsb)); + +echo "\nEurope/Lisbon has same rules as Portugal:\n"; +var_dump($lsb->hasSameRules($prt)); + +echo "\nEurope/Lisbon has same rules as Atlantic/Azores:\n"; +var_dump(intltz_has_same_rules($lsb, $azo)); + +?> +==DONE== +--EXPECT-- +Europe/Lisbon has same rules as itself: +bool(true) + +Europe/Lisbon has same rules as Portugal: +bool(true) + +Europe/Lisbon has same rules as Atlantic/Azores: +bool(false) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_hasSameRules_error.phpt b/ext/intl/tests/timezone_hasSameRules_error.phpt new file mode 100644 index 0000000000000..35a29be5db6c0 --- /dev/null +++ b/ext/intl/tests/timezone_hasSameRules_error.phpt @@ -0,0 +1,37 @@ +--TEST-- +IntlTimeZone::hasSameRules(): errors +--SKIPIF-- +hasSameRules('foo')); + +var_dump(intltz_has_same_rules(null, $tz)); + +--EXPECT-- +int(4096) +string(99) "Argument 1 passed to IntlTimeZone::hasSameRules() must be an instance of IntlTimeZone, string given" +int(2) +string(81) "IntlTimeZone::hasSameRules() expects parameter 1 to be IntlTimeZone, string given" +int(2) +string(66) "IntlTimeZone::hasSameRules(): intltz_has_same_rules: bad arguments" +bool(false) +int(4096) +string(92) "Argument 1 passed to intltz_has_same_rules() must be an instance of IntlTimeZone, null given" +int(2) +string(74) "intltz_has_same_rules() expects parameter 1 to be IntlTimeZone, null given" +int(2) +string(61) "intltz_has_same_rules(): intltz_has_same_rules: bad arguments" +bool(false) diff --git a/ext/intl/tests/timezone_toDateTimeZone_basic.phpt b/ext/intl/tests/timezone_toDateTimeZone_basic.phpt new file mode 100644 index 0000000000000..d22aa689dc9f8 --- /dev/null +++ b/ext/intl/tests/timezone_toDateTimeZone_basic.phpt @@ -0,0 +1,38 @@ +--TEST-- +IntlTimeZone::toDateTimeZone(): basic test +--SKIPIF-- +getID(), $tz->getRawOffset()); + if (!$proc) + $dtz = $tz->toDateTimeZone(); + else + $dtz = intltz_to_date_time_zone($tz); + var_dump($dtz->getName(), $dtz->getOffset(new DateTime('2012-01-01 00:00:00'))); +} + +do_test(IntlTimeZone::createTimeZone('CET')); +do_test(IntlTimeZone::createTimeZone('Europe/Amsterdam')); +do_test(IntlTimeZone::createTimeZone('GMT+0405'), true); + +--EXPECTF-- +string(3) "CET" +int(3600000) +string(13) "Europe/Berlin" +int(3600) +string(16) "Europe/Amsterdam" +int(3600000) +string(16) "Europe/Amsterdam" +int(3600) +string(%s) "GMT+04%s5" +int(14700000) +string(6) "+04:05" +int(14700) diff --git a/ext/intl/tests/timezone_toDateTimeZone_error.phpt b/ext/intl/tests/timezone_toDateTimeZone_error.phpt new file mode 100644 index 0000000000000..e48d7aca92135 --- /dev/null +++ b/ext/intl/tests/timezone_toDateTimeZone_error.phpt @@ -0,0 +1,38 @@ +--TEST-- +IntlTimeZone::toDateTimeZone(): errors +--SKIPIF-- +toDateTimeZone('')); +try { + var_dump($tz->toDateTimeZone()); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +var_dump(intltz_to_date_time_zone()); +var_dump(intltz_to_date_time_zone(1)); + +--EXPECTF-- + +Warning: IntlTimeZone::toDateTimeZone() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::toDateTimeZone(): intltz_to_date_time_zone: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::toDateTimeZone(): intltz_to_date_time_zone: DateTimeZone constructor threw exception in %s on line %d +string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)" + +Warning: intltz_to_date_time_zone() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: intltz_to_date_time_zone(): intltz_to_date_time_zone: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_to_date_time_zone() must be an instance of IntlTimeZone, integer given in %s on line %d diff --git a/ext/intl/tests/timezone_useDaylightTime_basic.phpt b/ext/intl/tests/timezone_useDaylightTime_basic.phpt new file mode 100644 index 0000000000000..15baf108b3d41 --- /dev/null +++ b/ext/intl/tests/timezone_useDaylightTime_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +IntlTimeZone::useDaylightTime: basic test +--SKIPIF-- +useDaylightTime()); +var_dump($gmt->useDaylightTime()); + +var_dump(intltz_use_daylight_time($lsb)); +var_dump(intltz_use_daylight_time($gmt)); +?> +==DONE== +--EXPECT-- +bool(true) +bool(false) +bool(true) +bool(false) +==DONE== \ No newline at end of file diff --git a/ext/intl/tests/timezone_useDaylightTime_error.phpt b/ext/intl/tests/timezone_useDaylightTime_error.phpt new file mode 100644 index 0000000000000..aa5ca6cfca02e --- /dev/null +++ b/ext/intl/tests/timezone_useDaylightTime_error.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlTimeZone::useDaylightTime(): errors +--SKIPIF-- +useDaylightTime('foo')); +intltz_use_daylight_time(null); + +--EXPECTF-- + +Warning: IntlTimeZone::useDaylightTime() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::useDaylightTime(): intltz_use_daylight_time: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_use_daylight_time() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/uconverter___construct_error.phpt b/ext/intl/tests/uconverter___construct_error.phpt new file mode 100644 index 0000000000000..1b2480818b864 --- /dev/null +++ b/ext/intl/tests/uconverter___construct_error.phpt @@ -0,0 +1,14 @@ +--TEST-- +Basic UConverter::convert() usage +--INI-- +intl.error_level = E_WARNING +--SKIPIF-- + +--FILE-- + +--FILE-- + 100); +var_dump(in_array('UTF-7', $avail)); +var_dump(in_array('CESU-8', $avail)); +var_dump(in_array('ISO-8859-1', $avail)); + +$latin1 = UConverter::getAliases('latin1'); +var_dump(in_array('ISO-8859-1', $latin1)); + +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/intl/tests/uconverter_func_basic.phpt b/ext/intl/tests/uconverter_func_basic.phpt new file mode 100644 index 0000000000000..da8956beae128 --- /dev/null +++ b/ext/intl/tests/uconverter_func_basic.phpt @@ -0,0 +1,17 @@ +--TEST-- +Basic UConverter::transcode() usage +--SKIPIF-- + +--FILE-- + +--INI-- +intl.use_exceptions=false +--FILE-- + $subst); + $ret = UConverter::transcode("This is an ascii string", 'ascii', 'utf-8', $opts); + if ($ret === FALSE) { + echo "Error: ", intl_get_error_message(), "\n"; + } else { + var_dump($ret); + } + $ret = UConverter::transcode("Snowman: (\xE2\x98\x83)", 'ascii', 'utf-8', $opts); + if ($ret === FALSE) { + echo "Error: ", intl_get_error_message(), "\n"; + } else { + var_dump($ret); + } +} + +--EXPECTF-- +string(23) "This is an ascii string" +string(12) "Snowman: (?)" +Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR +Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR +Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR +Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR diff --git a/ext/intl/tests/uconverter_oop_algo.phpt b/ext/intl/tests/uconverter_oop_algo.phpt new file mode 100644 index 0000000000000..349182ce32c0f --- /dev/null +++ b/ext/intl/tests/uconverter_oop_algo.phpt @@ -0,0 +1,18 @@ +--TEST-- +UConverter Algorithmic converters +--SKIPIF-- + +--FILE-- +getSourceType()); +var_dump(UConverter::UTF8 === $c->getDestinationType()); + +$c = new UConverter('koi8-r', 'utf-32be'); +var_dump(UConverter::UTF32_BigEndian === $c->getSourceType()); +var_dump(UConverter::SBCS === $c->getDestinationType()); +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/intl/tests/uconverter_oop_basic.phpt b/ext/intl/tests/uconverter_oop_basic.phpt new file mode 100644 index 0000000000000..2b8909ff31e71 --- /dev/null +++ b/ext/intl/tests/uconverter_oop_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +Basic UConverter::convert() usage +--SKIPIF-- + +--FILE-- +convert("This is an ascii string")); +// urlencode so that non-ascii shows up parsable in phpt file +var_dump(urlencode($c->convert("Espa\xF1ol"))); // U+00F1 LATIN SMALL LETTER N WITH TILDE +var_dump(urlencode($c->convert("Stra\xDFa"))); // U+00DF LATIN SMALL LETTER SHARP S +var_dump(urlencode($c->convert("Stra\xC3\x9Fa", true))); // Reverse prior op + +$k = new UConverter('utf-8', 'koi8-r'); +var_dump(bin2hex($k->convert("\xE4"))); // U+0414 CYRILLIC CAPITAL LETTER DE +--EXPECT-- +string(23) "This is an ascii string" +string(12) "Espa%C3%B1ol" +string(11) "Stra%C3%9Fa" +string(8) "Stra%DFa" +string(4) "d094" diff --git a/ext/intl/tests/uconverter_oop_callback.phpt b/ext/intl/tests/uconverter_oop_callback.phpt new file mode 100644 index 0000000000000..47daf4330586c --- /dev/null +++ b/ext/intl/tests/uconverter_oop_callback.phpt @@ -0,0 +1,52 @@ +--TEST-- +UConverter::convert() w/ Callback Reasons +--SKIPIF-- + +--FILE-- +convert($word); +} +--EXPECT-- +toUCallback(REASON_RESET, ...) +toUCallback(REASON_RESET, ...) +fromUCallback(REASON_RESET, ...) +fromUCallback(REASON_RESET, ...) +toUCallback(REASON_RESET, ...) +toUCallback(REASON_ILLEGAL, ...) +toUCallback(REASON_RESET, ...) +toUCallback(REASON_ILLEGAL, ...) +fromUCallback(REASON_RESET, ...) +fromUCallback(REASON_UNASSIGNED, ...) +fromUCallback(REASON_RESET, ...) +fromUCallback(REASON_UNASSIGNED, ...) +toUCallback(REASON_RESET, ...) +toUCallback(REASON_RESET, ...) +fromUCallback(REASON_RESET, ...) +fromUCallback(REASON_UNASSIGNED, ...) +fromUCallback(REASON_RESET, ...) +fromUCallback(REASON_UNASSIGNED, ...) +toUCallback(REASON_CLOSE, ...) +fromUCallback(REASON_CLOSE, ...) +toUCallback(REASON_CLOSE, ...) +fromUCallback(REASON_CLOSE, ...) diff --git a/ext/intl/tests/uconverter_oop_callback_return.phpt b/ext/intl/tests/uconverter_oop_callback_return.phpt new file mode 100644 index 0000000000000..cd7e7a5834fd5 --- /dev/null +++ b/ext/intl/tests/uconverter_oop_callback_return.phpt @@ -0,0 +1,40 @@ +--TEST-- +UConverter::convert() w/ Callback Return Values +--SKIPIF-- + +--FILE-- +convert("\x80\x81\x82\x83")); +// This line will trigger fromUCallback +var_dump($c->convert("\xC3\xB1\xC3\xB2\xC3\xB3\xC3\xB4")); +--EXPECT-- +string(3) "abc" +string(3) "ABC" diff --git a/ext/intl/tests/uconverter_oop_subst.phpt b/ext/intl/tests/uconverter_oop_subst.phpt new file mode 100644 index 0000000000000..d21d95f8d0a12 --- /dev/null +++ b/ext/intl/tests/uconverter_oop_subst.phpt @@ -0,0 +1,24 @@ +--TEST-- +Basic UConverter::convert() w/ Subsitution +--SKIPIF-- + +--INI-- +intl.use_exceptions=false +--FILE-- +') as $subst) { + if (!$c->setSubstChars($subst)) { + echo "**Disallowed\n"; + continue; + } + var_dump($c->convert("This is an ascii string")); + var_dump($c->convert("Snowman: (\xE2\x98\x83)")); +} + +--EXPECT-- +string(23) "This is an ascii string" +string(12) "Snowman: (?)" +**Disallowed +**Disallowed diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp new file mode 100644 index 0000000000000..374b1638512d3 --- /dev/null +++ b/ext/intl/timezone/timezone_class.cpp @@ -0,0 +1,540 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "../intl_cppshims.h" + +#include +#include +#include "../intl_convertcpp.h" + +#include "../common/common_date.h" + +extern "C" { +#include "../intl_convert.h" +#define USE_TIMEZONE_POINTER 1 +#include "timezone_class.h" +#include "timezone_methods.h" +#include +#include +#include +} + +/* {{{ Global variables */ +U_CDECL_BEGIN +zend_class_entry *TimeZone_ce_ptr = NULL; +zend_object_handlers TimeZone_handlers; +U_CDECL_END +/* }}} */ + +/* {{{ timezone_object_construct */ +U_CFUNC void timezone_object_construct(const TimeZone *zone, zval *object, int owned TSRMLS_DC) +{ + TimeZone_object *to; + + object_init_ex(object, TimeZone_ce_ptr); + TIMEZONE_METHOD_FETCH_OBJECT_NO_CHECK; /* fetch zend object from zval "object" into "to" */ + to->utimezone = zone; + to->should_delete = owned; +} +/* }}} */ + +/* {{{ timezone_convert_to_datetimezone + * Convert from TimeZone to DateTimeZone object */ +U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, + intl_error *outside_error, + const char *func TSRMLS_DC) +{ + zval *ret = NULL; + UnicodeString id; + char *message = NULL; + php_timezone_obj *tzobj; + zval arg = zval_used_for_init; + + timeZone->getID(id); + if (id.isBogus()) { + spprintf(&message, 0, "%s: could not obtain TimeZone id", func); + intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, + message, 1 TSRMLS_CC); + goto error; + } + + MAKE_STD_ZVAL(ret); + object_init_ex(ret, php_date_get_timezone_ce()); + tzobj = (php_timezone_obj *)zend_objects_get_address(ret TSRMLS_CC); + + if (id.compare(0, 3, UnicodeString("GMT", sizeof("GMT")-1, US_INV)) == 0) { + /* The DateTimeZone constructor doesn't support offset time zones, + * so we must mess with DateTimeZone structure ourselves */ + tzobj->initialized = 1; + tzobj->type = TIMELIB_ZONETYPE_OFFSET; + //convert offset from milliseconds to minutes + tzobj->tzi.utc_offset = -1 * timeZone->getRawOffset() / (60 * 1000); + } else { + /* Call the constructor! */ + Z_TYPE(arg) = IS_STRING; + if (intl_charFromString(id, &Z_STRVAL(arg), &Z_STRLEN(arg), + &INTL_ERROR_CODE(*outside_error)) == FAILURE) { + spprintf(&message, 0, "%s: could not convert id to UTF-8", func); + intl_errors_set(outside_error, INTL_ERROR_CODE(*outside_error), + message, 1 TSRMLS_CC); + goto error; + } + zend_call_method_with_1_params(&ret, NULL, NULL, "__construct", + NULL, &arg); + if (EG(exception)) { + spprintf(&message, 0, + "%s: DateTimeZone constructor threw exception", func); + intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, + message, 1 TSRMLS_CC); + zend_object_store_ctor_failed(ret TSRMLS_CC); + goto error; + } + } + + if (0) { +error: + if (ret) { + zval_ptr_dtor(&ret); + } + ret = NULL; + } + + if (message) { + efree(message); + } + if (Z_TYPE(arg) == IS_STRING) { + zval_dtor(&arg); + } + return ret; +} +/* }}} */ + +/* {{{ timezone_process_timezone_argument + * TimeZone argument processor. outside_error may be NULL (for static functions/constructors) */ +U_CFUNC TimeZone *timezone_process_timezone_argument(zval **zv_timezone, + intl_error *outside_error, + const char *func TSRMLS_DC) +{ + zval local_zv_tz = zval_used_for_init, + *local_zv_tz_p = &local_zv_tz; + char *message = NULL; + TimeZone *timeZone; + + if (zv_timezone == NULL || Z_TYPE_PP(zv_timezone) == IS_NULL) { + timelib_tzinfo *tzinfo = get_timezone_info(TSRMLS_C); + ZVAL_STRING(&local_zv_tz, tzinfo->name, 0); + zv_timezone = &local_zv_tz_p; + } + + if (Z_TYPE_PP(zv_timezone) == IS_OBJECT && + instanceof_function(Z_OBJCE_PP(zv_timezone), TimeZone_ce_ptr TSRMLS_CC)) { + TimeZone_object *to = (TimeZone_object*)zend_objects_get_address( + *zv_timezone TSRMLS_CC); + if (to->utimezone == NULL) { + spprintf(&message, 0, "%s: passed IntlTimeZone is not " + "properly constructed", func); + if (message) { + intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); + efree(message); + } + return NULL; + } + timeZone = to->utimezone->clone(); + if (timeZone == NULL) { + spprintf(&message, 0, "%s: could not clone TimeZone", func); + if (message) { + intl_errors_set(outside_error, U_MEMORY_ALLOCATION_ERROR, message, 1 TSRMLS_CC); + efree(message); + } + return NULL; + } + } else if (Z_TYPE_PP(zv_timezone) == IS_OBJECT && + instanceof_function(Z_OBJCE_PP(zv_timezone), php_date_get_timezone_ce() TSRMLS_CC)) { + + php_timezone_obj *tzobj = (php_timezone_obj *)zend_objects_get_address( + *zv_timezone TSRMLS_CC); + + return timezone_convert_datetimezone(tzobj->type, tzobj, 0, + outside_error, func TSRMLS_CC); + } else { + UnicodeString id, + gottenId; + UErrorCode status = U_ZERO_ERROR; /* outside_error may be NULL */ + convert_to_string_ex(zv_timezone); + if (intl_stringFromChar(id, Z_STRVAL_PP(zv_timezone), Z_STRLEN_PP(zv_timezone), + &status) == FAILURE) { + spprintf(&message, 0, "%s: Time zone identifier given is not a " + "valid UTF-8 string", func); + if (message) { + intl_errors_set(outside_error, status, message, 1 TSRMLS_CC); + efree(message); + } + return NULL; + } + timeZone = TimeZone::createTimeZone(id); + if (timeZone == NULL) { + spprintf(&message, 0, "%s: could not create time zone", func); + if (message) { + intl_errors_set(outside_error, U_MEMORY_ALLOCATION_ERROR, message, 1 TSRMLS_CC); + efree(message); + } + return NULL; + } + if (timeZone->getID(gottenId) != id) { + spprintf(&message, 0, "%s: no such time zone: '%s'", + func, Z_STRVAL_PP(zv_timezone)); + if (message) { + intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC); + efree(message); + } + delete timeZone; + return NULL; + } + } + + return timeZone; +} +/* }}} */ + +/* {{{ clone handler for TimeZone */ +static zend_object_value TimeZone_clone_obj(zval *object TSRMLS_DC) +{ + TimeZone_object *to_orig, + *to_new; + zend_object_value ret_val; + intl_error_reset(NULL TSRMLS_CC); + + to_orig = (TimeZone_object*)zend_object_store_get_object(object TSRMLS_CC); + intl_error_reset(TIMEZONE_ERROR_P(to_orig) TSRMLS_CC); + + ret_val = TimeZone_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC); + to_new = (TimeZone_object*)zend_object_store_get_object_by_handle( + ret_val.handle TSRMLS_CC); + + zend_objects_clone_members(&to_new->zo, ret_val, + &to_orig->zo, Z_OBJ_HANDLE_P(object) TSRMLS_CC); + + if (to_orig->utimezone != NULL) { + TimeZone *newTimeZone; + + newTimeZone = to_orig->utimezone->clone(); + to_new->should_delete = 1; + if (!newTimeZone) { + char *err_msg; + intl_errors_set_code(TIMEZONE_ERROR_P(to_orig), + U_MEMORY_ALLOCATION_ERROR TSRMLS_CC); + intl_errors_set_custom_msg(TIMEZONE_ERROR_P(to_orig), + "Could not clone IntlTimeZone", 0 TSRMLS_CC); + err_msg = intl_error_get_message(TIMEZONE_ERROR_P(to_orig) TSRMLS_CC); + zend_throw_exception(NULL, err_msg, 0 TSRMLS_CC); + efree(err_msg); + } else { + to_new->utimezone = newTimeZone; + } + } else { + zend_throw_exception(NULL, "Cannot clone unconstructed IntlTimeZone", 0 TSRMLS_CC); + } + + return ret_val; +} +/* }}} */ + +/* {{{ compare_objects handler for TimeZone + * Can't be used for >, >=, <, <= comparisons */ +static int TimeZone_compare_objects(zval *object1, zval *object2 TSRMLS_DC) +{ + TimeZone_object *to1, + *to2; + to1 = (TimeZone_object*)zend_object_store_get_object(object1 TSRMLS_CC); + to2 = (TimeZone_object*)zend_object_store_get_object(object2 TSRMLS_CC); + + if (to1->utimezone == NULL || to2->utimezone == NULL) { + zend_throw_exception(NULL, "Comparison with at least one unconstructed " + "IntlTimeZone operand", 0 TSRMLS_CC); + /* intentionally not returning */ + } else { + if (*to1->utimezone == *to2->utimezone) { + return 0; + } + } + + return 1; +} +/* }}} */ + +/* {{{ get_debug_info handler for TimeZone */ +static HashTable *TimeZone_get_debug_info(zval *object, int *is_temp TSRMLS_DC) +{ + zval zv = zval_used_for_init; + TimeZone_object *to; + const TimeZone *tz; + UnicodeString ustr; + char *str; + int str_len; + UErrorCode uec = U_ZERO_ERROR; + + *is_temp = 1; + + array_init_size(&zv, 4); + + to = (TimeZone_object*)zend_object_store_get_object(object TSRMLS_CC); + tz = to->utimezone; + + if (tz == NULL) { + add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 0); + return Z_ARRVAL(zv); + } + + add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 1); + + tz->getID(ustr); + intl_convert_utf16_to_utf8(&str, &str_len, + ustr.getBuffer(), ustr.length(), &uec); + if (U_FAILURE(uec)) { + return Z_ARRVAL(zv); + } + add_assoc_stringl_ex(&zv, "id", sizeof("id"), str, str_len, 0); + + int32_t rawOffset, dstOffset; + UDate now = Calendar::getNow(); + tz->getOffset(now, FALSE, rawOffset, dstOffset, uec); + if (U_FAILURE(uec)) { + return Z_ARRVAL(zv); + } + + add_assoc_long_ex(&zv, "rawOffset", sizeof("rawOffset"), (long)rawOffset); + add_assoc_long_ex(&zv, "currentOffset", sizeof("currentOffset"), + (long)(rawOffset + dstOffset)); + + return Z_ARRVAL(zv); +} +/* }}} */ + +/* {{{ void TimeZone_object_init(TimeZone_object* to) + * Initialize internals of TImeZone_object not specific to zend standard objects. + */ +static void TimeZone_object_init(TimeZone_object *to TSRMLS_DC) +{ + intl_error_init(TIMEZONE_ERROR_P(to) TSRMLS_CC); + to->utimezone = NULL; + to->should_delete = 0; +} +/* }}} */ + +/* {{{ TimeZone_objects_dtor */ +static void TimeZone_objects_dtor(zend_object *object, + zend_object_handle handle TSRMLS_DC) +{ + zend_objects_destroy_object(object, handle TSRMLS_CC); +} +/* }}} */ + +/* {{{ TimeZone_objects_free */ +static void TimeZone_objects_free(zend_object *object TSRMLS_DC) +{ + TimeZone_object* to = (TimeZone_object*) object; + + if (to->utimezone && to->should_delete) { + delete to->utimezone; + to->utimezone = NULL; + } + intl_error_reset(TIMEZONE_ERROR_P(to) TSRMLS_CC); + + zend_object_std_dtor(&to->zo TSRMLS_CC); + + efree(to); +} +/* }}} */ + +/* {{{ TimeZone_object_create */ +static zend_object_value TimeZone_object_create(zend_class_entry *ce TSRMLS_DC) +{ + zend_object_value retval; + TimeZone_object* intern; + + intern = (TimeZone_object*)ecalloc(1, sizeof(TimeZone_object)); + + zend_object_std_init(&intern->zo, ce TSRMLS_CC); +#if PHP_VERSION_ID < 50399 + zend_hash_copy(intern->zo.properties, &(ce->default_properties), + (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*)); +#else + object_properties_init((zend_object*) intern, ce); +#endif + TimeZone_object_init(intern TSRMLS_CC); + + retval.handle = zend_objects_store_put( + intern, + (zend_objects_store_dtor_t) TimeZone_objects_dtor, + (zend_objects_free_object_storage_t) TimeZone_objects_free, + NULL TSRMLS_CC); + + retval.handlers = &TimeZone_handlers; + + return retval; +} +/* }}} */ + +/* {{{ TimeZone methods arguments info */ + +ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_idarg, 0, 0, 1) + ZEND_ARG_INFO(0, zoneId) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_fromDateTimeZone, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, otherTimeZone, IntlTimeZone, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_createEnumeration, 0, 0, 0) + ZEND_ARG_INFO(0, countryOrRawOffset) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_countEquivalentIDs, 0, 0, 1) + ZEND_ARG_INFO(0, zoneId) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_createTimeZoneIDEnumeration, 0, 0, 1) + ZEND_ARG_INFO(0, zoneType) + ZEND_ARG_INFO(0, region) + ZEND_ARG_INFO(0, rawOffset) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getCanonicalID, 0, 0, 1) + ZEND_ARG_INFO(0, zoneId) + ZEND_ARG_INFO(1, isSystemID) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getEquivalentID, 0, 0, 2) + ZEND_ARG_INFO(0, zoneId) + ZEND_ARG_INFO(0, index) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getOffset, 0, 0, 4) + ZEND_ARG_INFO(0, date) + ZEND_ARG_INFO(0, local) + ZEND_ARG_INFO(1, rawOffset) + ZEND_ARG_INFO(1, dstOffset) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_hasSameRules, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, otherTimeZone, IntlTimeZone, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getDisplayName, 0, 0, 0) + ZEND_ARG_INFO(0, isDaylight) + ZEND_ARG_INFO(0, style) + ZEND_ARG_INFO(0, locale) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_void, 0, 0, 0) +ZEND_END_ARG_INFO() + +/* }}} */ + +/* {{{ TimeZone_class_functions + * Every 'IntlTimeZone' class method has an entry in this table + */ +static zend_function_entry TimeZone_class_functions[] = { + PHP_ME(IntlTimeZone, __construct, ainfo_tz_void, ZEND_ACC_PRIVATE) + PHP_ME_MAPPING(createTimeZone, intltz_create_time_zone, ainfo_tz_idarg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME_MAPPING(fromDateTimeZone, intltz_from_date_time_zone, ainfo_tz_idarg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME_MAPPING(createDefault, intltz_create_default, ainfo_tz_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME_MAPPING(getGMT, intltz_get_gmt, ainfo_tz_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +#if U_ICU_VERSION_MAJOR_NUM >= 49 + PHP_ME_MAPPING(getUnknown, intltz_get_unknown, ainfo_tz_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +#endif + PHP_ME_MAPPING(createEnumeration, intltz_create_enumeration, ainfo_tz_createEnumeration, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME_MAPPING(countEquivalentIDs, intltz_count_equivalent_ids, ainfo_tz_idarg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 + PHP_ME_MAPPING(createTimeZoneIDEnumeration, intltz_create_time_zone_id_enumeration, ainfo_tz_createTimeZoneIDEnumeration, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +#endif + PHP_ME_MAPPING(getCanonicalID, intltz_get_canonical_id, ainfo_tz_getCanonicalID, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 + PHP_ME_MAPPING(getRegion, intltz_get_region, ainfo_tz_idarg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +#endif + PHP_ME_MAPPING(getTZDataVersion, intltz_get_tz_data_version, ainfo_tz_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME_MAPPING(getEquivalentID, intltz_get_equivalent_id, ainfo_tz_getEquivalentID, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + + PHP_ME_MAPPING(getID, intltz_get_id, ainfo_tz_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(useDaylightTime, intltz_use_daylight_time, ainfo_tz_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getOffset, intltz_get_offset, ainfo_tz_getOffset, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getRawOffset, intltz_get_raw_offset, ainfo_tz_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(hasSameRules, intltz_has_same_rules, ainfo_tz_hasSameRules, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getDisplayName, intltz_get_display_name, ainfo_tz_getDisplayName, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getDSTSavings, intltz_get_dst_savings, ainfo_tz_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(toDateTimeZone, intltz_to_date_time_zone, ainfo_tz_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getErrorCode, intltz_get_error_code, ainfo_tz_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getErrorMessage, intltz_get_error_message, ainfo_tz_void, ZEND_ACC_PUBLIC) + PHP_FE_END +}; +/* }}} */ + +/* {{{ timezone_register_IntlTimeZone_class + * Initialize 'IntlTimeZone' class + */ +U_CFUNC void timezone_register_IntlTimeZone_class(TSRMLS_D) +{ + zend_class_entry ce; + + /* Create and register 'IntlTimeZone' class. */ + INIT_CLASS_ENTRY(ce, "IntlTimeZone", TimeZone_class_functions); + ce.create_object = TimeZone_object_create; + TimeZone_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC); + if (!TimeZone_ce_ptr) { + //can't happen now without bigger problems before + php_error_docref0(NULL TSRMLS_CC, E_ERROR, + "IntlTimeZone: class registration has failed."); + return; + } + + memcpy(&TimeZone_handlers, zend_get_std_object_handlers(), + sizeof TimeZone_handlers); + TimeZone_handlers.clone_obj = TimeZone_clone_obj; + TimeZone_handlers.compare_objects = TimeZone_compare_objects; + TimeZone_handlers.get_debug_info = TimeZone_get_debug_info; + + /* Declare 'IntlTimeZone' class constants */ +#define TIMEZONE_DECL_LONG_CONST(name, val) \ + zend_declare_class_constant_long(TimeZone_ce_ptr, name, sizeof(name) - 1, \ + val TSRMLS_CC) + + TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT", TimeZone::SHORT); + TIMEZONE_DECL_LONG_CONST("DISPLAY_LONG", TimeZone::LONG); + +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 + TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT_GENERIC", TimeZone::SHORT_GENERIC); + TIMEZONE_DECL_LONG_CONST("DISPLAY_LONG_GENERIC", TimeZone::LONG_GENERIC); + TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT_GMT", TimeZone::SHORT_GMT); + TIMEZONE_DECL_LONG_CONST("DISPLAY_LONG_GMT", TimeZone::LONG_GMT); + TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT_COMMONLY_USED", TimeZone::SHORT_COMMONLY_USED); + TIMEZONE_DECL_LONG_CONST("DISPLAY_GENERIC_LOCATION", TimeZone::GENERIC_LOCATION); +#endif + +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 + TIMEZONE_DECL_LONG_CONST("TYPE_ANY", UCAL_ZONE_TYPE_ANY); + TIMEZONE_DECL_LONG_CONST("TYPE_CANONICAL", UCAL_ZONE_TYPE_CANONICAL); + TIMEZONE_DECL_LONG_CONST("TYPE_CANONICAL_LOCATION", UCAL_ZONE_TYPE_CANONICAL_LOCATION); +#endif + + /* Declare 'IntlTimeZone' class properties */ + +} +/* }}} */ diff --git a/ext/intl/timezone/timezone_class.h b/ext/intl/timezone/timezone_class.h new file mode 100644 index 0000000000000..a638f6dbf49ef --- /dev/null +++ b/ext/intl/timezone/timezone_class.h @@ -0,0 +1,72 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#ifndef TIMEZONE_CLASS_H +#define TIMEZONE_CLASS_H + +//redefinition of inline in PHP headers causes problems, so include this before +#include + +//fixes the build on windows for old versions of ICU +#include + +#include +#include "intl_error.h" +#include "intl_data.h" + +#ifndef USE_TIMEZONE_POINTER +typedef void TimeZone; +#endif + +typedef struct { + zend_object zo; + + // error handling + intl_error err; + + // ICU TimeZone + const TimeZone *utimezone; + + //whether to delete the timezone on object free + zend_bool should_delete; +} TimeZone_object; + +#define TIMEZONE_ERROR(to) (to)->err +#define TIMEZONE_ERROR_P(to) &(TIMEZONE_ERROR(to)) + +#define TIMEZONE_ERROR_CODE(co) INTL_ERROR_CODE(TIMEZONE_ERROR(to)) +#define TIMEZONE_ERROR_CODE_P(co) &(INTL_ERROR_CODE(TIMEZONE_ERROR(to))) + +#define TIMEZONE_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(TimeZone, to) +#define TIMEZONE_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(TimeZone, to) +#define TIMEZONE_METHOD_FETCH_OBJECT\ + TIMEZONE_METHOD_FETCH_OBJECT_NO_CHECK; \ + if (to->utimezone == NULL) { \ + intl_errors_set(&to->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlTimeZone", 0 TSRMLS_CC); \ + RETURN_FALSE; \ + } + +zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, intl_error *outside_error, const char *func TSRMLS_DC); +TimeZone *timezone_process_timezone_argument(zval **zv_timezone, intl_error *error, const char *func TSRMLS_DC); + +void timezone_object_construct(const TimeZone *zone, zval *object, int owned TSRMLS_DC); + +void timezone_register_IntlTimeZone_class(TSRMLS_D); + +extern zend_class_entry *TimeZone_ce_ptr; +extern zend_object_handlers TimeZone_handlers; + +#endif /* #ifndef TIMEZONE_CLASS_H */ diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp new file mode 100644 index 0000000000000..9ca6b44c896d7 --- /dev/null +++ b/ext/intl/timezone/timezone_methods.cpp @@ -0,0 +1,659 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "../intl_cppshims.h" + +#include +#include +#include +#include "intl_convertcpp.h" + +#include "../common/common_date.h" + +extern "C" { +#include "../php_intl.h" +#define USE_TIMEZONE_POINTER 1 +#include "timezone_class.h" +#include "intl_convert.h" +#include +#include +} +#include "common/common_enum.h" + +U_CFUNC PHP_METHOD(IntlTimeZone, __construct) +{ + zend_throw_exception( NULL, + "An object of this type cannot be created with the new operator", + 0 TSRMLS_CC ); +} + +U_CFUNC PHP_FUNCTION(intltz_create_time_zone) +{ + char *str_id; + int str_id_len; + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", + &str_id, &str_id_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_create_time_zone: bad arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + + UErrorCode status = UErrorCode(); + UnicodeString id = UnicodeString(); + if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { + intl_error_set(NULL, status, + "intltz_create_time_zone: could not convert time zone id to UTF-16", 0 TSRMLS_CC); + RETURN_NULL(); + } + + //guaranteed non-null; GMT if timezone cannot be understood + TimeZone *tz = TimeZone::createTimeZone(id); + timezone_object_construct(tz, return_value, 1 TSRMLS_CC); +} + +U_CFUNC PHP_FUNCTION(intltz_from_date_time_zone) +{ + zval *zv_timezone; + TimeZone *tz; + php_timezone_obj *tzobj; + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", + &zv_timezone, php_date_get_timezone_ce()) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_from_date_time_zone: bad arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + + tzobj = (php_timezone_obj *)zend_objects_get_address(zv_timezone TSRMLS_CC); + if (!tzobj->initialized) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_from_date_time_zone: DateTimeZone object is unconstructed", + 0 TSRMLS_CC); + RETURN_NULL(); + } + + tz = timezone_convert_datetimezone(tzobj->type, tzobj, FALSE, NULL, + "intltz_from_date_time_zone" TSRMLS_CC); + if (tz == NULL) { + RETURN_NULL(); + } + + timezone_object_construct(tz, return_value, 1 TSRMLS_CC); +} + +U_CFUNC PHP_FUNCTION(intltz_create_default) +{ + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_create_default: bad arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + + TimeZone *tz = TimeZone::createDefault(); + timezone_object_construct(tz, return_value, 1 TSRMLS_CC); +} + +U_CFUNC PHP_FUNCTION(intltz_get_gmt) +{ + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_gmt: bad arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + + timezone_object_construct(TimeZone::getGMT(), return_value, 0 TSRMLS_CC); +} + +#if U_ICU_VERSION_MAJOR_NUM >= 49 +U_CFUNC PHP_FUNCTION(intltz_get_unknown) +{ + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_unknown: bad arguments", 0 TSRMLS_CC); + RETURN_NULL(); + } + + timezone_object_construct(&TimeZone::getUnknown(), return_value, 0 TSRMLS_CC); +} +#endif + +U_CFUNC PHP_FUNCTION(intltz_create_enumeration) +{ + zval **arg = NULL; + StringEnumeration *se = NULL; + intl_error_reset(NULL TSRMLS_CC); + + /* double indirection to have the zend engine destroy the new zval that + * results from separation */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Z", &arg) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_create_enumeration: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (arg == NULL || Z_TYPE_PP(arg) == IS_NULL) { + se = TimeZone::createEnumeration(); + } else if (Z_TYPE_PP(arg) == IS_LONG) { +int_offset: + if (Z_LVAL_PP(arg) < (long)INT32_MIN || + Z_LVAL_PP(arg) > (long)INT32_MAX) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_create_enumeration: value is out of range", 0 TSRMLS_CC); + RETURN_FALSE; + } else { + se = TimeZone::createEnumeration((int32_t) Z_LVAL_PP(arg)); + } + } else if (Z_TYPE_PP(arg) == IS_DOUBLE) { +double_offset: + convert_to_long_ex(arg); + goto int_offset; + } else if (Z_TYPE_PP(arg) == IS_OBJECT || Z_TYPE_PP(arg) == IS_STRING) { + long lval; + double dval; + convert_to_string_ex(arg); + switch (is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &lval, &dval, 0)) { + case IS_DOUBLE: + SEPARATE_ZVAL(arg); + zval_dtor(*arg); + Z_TYPE_PP(arg) = IS_DOUBLE; + Z_DVAL_PP(arg) = dval; + goto double_offset; + case IS_LONG: + SEPARATE_ZVAL(arg); + zval_dtor(*arg); + Z_TYPE_PP(arg) = IS_LONG; + Z_LVAL_PP(arg) = lval; + goto int_offset; + } + /* else call string version */ + se = TimeZone::createEnumeration(Z_STRVAL_PP(arg)); + } else { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_create_enumeration: invalid argument type", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (se) { + IntlIterator_from_StringEnumeration(se, return_value TSRMLS_CC); + } else { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_create_enumeration: error obtaining enumeration", 0 TSRMLS_CC); + RETVAL_FALSE; + } +} + +U_CFUNC PHP_FUNCTION(intltz_count_equivalent_ids) +{ + char *str_id; + int str_id_len; + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", + &str_id, &str_id_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_count_equivalent_ids: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + UErrorCode status = UErrorCode(); + UnicodeString id = UnicodeString(); + if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { + intl_error_set(NULL, status, + "intltz_count_equivalent_ids: could not convert time zone id to UTF-16", 0 TSRMLS_CC); + RETURN_FALSE; + } + + int32_t result = TimeZone::countEquivalentIDs(id); + RETURN_LONG((long)result); +} + +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 +U_CFUNC PHP_FUNCTION(intltz_create_time_zone_id_enumeration) +{ + long zoneType, + offset_arg; + char *region = NULL; + int region_len = 0; + int32_t offset, + *offsetp = NULL; + int arg3isnull = 0; + intl_error_reset(NULL TSRMLS_CC); + + /* must come before zpp because zpp would convert the arg in the stack to 0 */ + if (ZEND_NUM_ARGS() == 3) { + zval **dummy, **zvoffset; + arg3isnull = zend_get_parameters_ex(3, &dummy, &dummy, &zvoffset) + != FAILURE && Z_TYPE_PP(zvoffset) == IS_NULL; + } + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|s!l", + &zoneType, ®ion, ®ion_len, &offset_arg) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_create_time_zone_id_enumeration: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (zoneType != UCAL_ZONE_TYPE_ANY && zoneType != UCAL_ZONE_TYPE_CANONICAL + && zoneType != UCAL_ZONE_TYPE_CANONICAL_LOCATION) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_create_time_zone_id_enumeration: bad zone type", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (ZEND_NUM_ARGS() == 3) { + if (offset_arg < (long)INT32_MIN || offset_arg > (long)INT32_MAX) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_create_time_zone_id_enumeration: offset out of bounds", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (!arg3isnull) { + offset = (int32_t)offset_arg; + offsetp = &offset; + } //else leave offsetp NULL + } + + StringEnumeration *se; + UErrorCode uec = UErrorCode(); + se = TimeZone::createTimeZoneIDEnumeration((USystemTimeZoneType)zoneType, + region, offsetp, uec); + INTL_CHECK_STATUS(uec, "intltz_create_time_zone_id_enumeration: " + "Error obtaining time zone id enumeration") + + IntlIterator_from_StringEnumeration(se, return_value TSRMLS_CC); +} +#endif + +U_CFUNC PHP_FUNCTION(intltz_get_canonical_id) +{ + char *str_id; + int str_id_len; + zval *is_systemid = NULL; + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", + &str_id, &str_id_len, &is_systemid) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_canonical_id: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + UErrorCode status = UErrorCode(); + UnicodeString id; + if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { + intl_error_set(NULL, status, + "intltz_get_canonical_id: could not convert time zone id to UTF-16", 0 TSRMLS_CC); + RETURN_FALSE; + } + + UnicodeString result; + UBool isSystemID; + TimeZone::getCanonicalID(id, result, isSystemID, status); + INTL_CHECK_STATUS(status, "intltz_get_canonical_id: error obtaining canonical ID"); + + intl_convert_utf16_to_utf8(&Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), + result.getBuffer(), result.length(), &status); + INTL_CHECK_STATUS(status, + "intltz_get_canonical_id: could not convert time zone id to UTF-16"); + Z_TYPE_P(return_value) = IS_STRING; + + if (is_systemid) { /* by-ref argument passed */ + zval_dtor(is_systemid); + ZVAL_BOOL(is_systemid, isSystemID); + } +} + +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 +U_CFUNC PHP_FUNCTION(intltz_get_region) +{ + char *str_id; + int str_id_len; + char outbuf[3]; + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", + &str_id, &str_id_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_region: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + UErrorCode status = UErrorCode(); + UnicodeString id; + if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { + intl_error_set(NULL, status, + "intltz_get_region: could not convert time zone id to UTF-16", 0 TSRMLS_CC); + RETURN_FALSE; + } + + int32_t region_len = TimeZone::getRegion(id, outbuf, sizeof(outbuf), status); + INTL_CHECK_STATUS(status, "intltz_get_region: Error obtaining region"); + + RETURN_STRINGL(outbuf, region_len, 1); +} +#endif + +U_CFUNC PHP_FUNCTION(intltz_get_tz_data_version) +{ + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters_none() == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_tz_data_version: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + UErrorCode status = UErrorCode(); + const char *res = TimeZone::getTZDataVersion(status); + INTL_CHECK_STATUS(status, "intltz_get_tz_data_version: " + "Error obtaining time zone data version"); + + RETURN_STRING(res, 1); +} + +U_CFUNC PHP_FUNCTION(intltz_get_equivalent_id) +{ + char *str_id; + int str_id_len; + long index; + intl_error_reset(NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", + &str_id, &str_id_len, &index) == FAILURE || + index < (long)INT32_MIN || index > (long)INT32_MAX) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_equivalent_id: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + UErrorCode status = UErrorCode(); + UnicodeString id; + if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { + intl_error_set(NULL, status, + "intltz_get_equivalent_id: could not convert time zone id to UTF-16", 0 TSRMLS_CC); + RETURN_FALSE; + } + + const UnicodeString result = TimeZone::getEquivalentID(id, (int32_t)index); + intl_convert_utf16_to_utf8(&Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), + result.getBuffer(), result.length(), &status); + INTL_CHECK_STATUS(status, "intltz_get_equivalent_id: " + "could not convert resulting time zone id to UTF-16"); + Z_TYPE_P(return_value) = IS_STRING; +} + +U_CFUNC PHP_FUNCTION(intltz_get_id) +{ + TIMEZONE_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, TimeZone_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_id: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + TIMEZONE_METHOD_FETCH_OBJECT; + + UnicodeString id_us; + to->utimezone->getID(id_us); + + char *id = NULL; + int id_len = 0; + + intl_convert_utf16_to_utf8(&id, &id_len, + id_us.getBuffer(), id_us.length(), TIMEZONE_ERROR_CODE_P(to)); + INTL_METHOD_CHECK_STATUS(to, "intltz_get_id: Could not convert id to UTF-8"); + + RETURN_STRINGL(id, id_len, 0); +} + +U_CFUNC PHP_FUNCTION(intltz_use_daylight_time) +{ + TIMEZONE_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, TimeZone_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_use_daylight_time: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + TIMEZONE_METHOD_FETCH_OBJECT; + + RETURN_BOOL(to->utimezone->useDaylightTime()); +} + +U_CFUNC PHP_FUNCTION(intltz_get_offset) +{ + UDate date; + zend_bool local; + zval *rawOffsetArg, + *dstOffsetArg; + int32_t rawOffset, + dstOffset; + TIMEZONE_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "Odbzz", &object, TimeZone_ce_ptr, &date, &local, &rawOffsetArg, + &dstOffsetArg) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_offset: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + TIMEZONE_METHOD_FETCH_OBJECT; + + to->utimezone->getOffset(date, (UBool) local, rawOffset, dstOffset, + TIMEZONE_ERROR_CODE(to)); + + INTL_METHOD_CHECK_STATUS(to, "intltz_get_offset: error obtaining offset"); + + zval_dtor(rawOffsetArg); + ZVAL_LONG(rawOffsetArg, rawOffset); + zval_dtor(dstOffsetArg); + ZVAL_LONG(dstOffsetArg, dstOffset); + + RETURN_TRUE; +} + +U_CFUNC PHP_FUNCTION(intltz_get_raw_offset) +{ + TIMEZONE_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, TimeZone_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_raw_offset: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + TIMEZONE_METHOD_FETCH_OBJECT; + + RETURN_LONG(to->utimezone->getRawOffset()); +} + +U_CFUNC PHP_FUNCTION(intltz_has_same_rules) +{ + zval *other_object; + TimeZone_object *other_to; + TIMEZONE_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "OO", &object, TimeZone_ce_ptr, &other_object, TimeZone_ce_ptr) + == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_has_same_rules: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + TIMEZONE_METHOD_FETCH_OBJECT; + other_to = (TimeZone_object *) zend_object_store_get_object(other_object TSRMLS_CC); + if (other_to->utimezone == NULL) { + intl_errors_set(&to->err, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_has_same_rules: The second IntlTimeZone is unconstructed", 0 TSRMLS_CC); + RETURN_FALSE; + } + + RETURN_BOOL(to->utimezone->hasSameRules(*other_to->utimezone)); +} + +static const TimeZone::EDisplayType display_types[] = { + TimeZone::SHORT, TimeZone::LONG, +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44 + TimeZone::SHORT_GENERIC, TimeZone::LONG_GENERIC, + TimeZone::SHORT_GMT, TimeZone::LONG_GMT, + TimeZone::SHORT_COMMONLY_USED, TimeZone::GENERIC_LOCATION +#endif +}; + +U_CFUNC PHP_FUNCTION(intltz_get_display_name) +{ + zend_bool daylight = 0; + long display_type = TimeZone::LONG; + const char *locale_str = NULL; + int dummy = 0; + TIMEZONE_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O|bls!", &object, TimeZone_ce_ptr, &daylight, &display_type, + &locale_str, &dummy) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_display_name: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + bool found = false; + for (int i = 0; !found && i < sizeof(display_types)/sizeof(*display_types); i++) { + if (display_types[i] == display_type) + found = true; + } + if (!found) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_display_name: wrong display type", 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (!locale_str) { + locale_str = intl_locale_get_default(TSRMLS_C); + } + + TIMEZONE_METHOD_FETCH_OBJECT; + + UnicodeString result; + to->utimezone->getDisplayName((UBool)daylight, (TimeZone::EDisplayType)display_type, + Locale::createFromName(locale_str), result); + + intl_convert_utf16_to_utf8(&Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), + result.getBuffer(), result.length(), TIMEZONE_ERROR_CODE_P(to)); + INTL_METHOD_CHECK_STATUS(to, "intltz_get_display_name: " + "could not convert resulting time zone id to UTF-16"); + + Z_TYPE_P(return_value) = IS_STRING; +} + +U_CFUNC PHP_FUNCTION(intltz_get_dst_savings) +{ + TIMEZONE_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, TimeZone_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_dst_savings: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + TIMEZONE_METHOD_FETCH_OBJECT; + + RETURN_LONG((long)to->utimezone->getDSTSavings()); +} + +U_CFUNC PHP_FUNCTION(intltz_to_date_time_zone) +{ + TIMEZONE_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + "O", &object, TimeZone_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_to_date_time_zone: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + TIMEZONE_METHOD_FETCH_OBJECT; + + zval *ret = timezone_convert_to_datetimezone(to->utimezone, + &TIMEZONE_ERROR(to), "intltz_to_date_time_zone" TSRMLS_CC); + + if (ret) { + RETURN_ZVAL(ret, 1, 1); + } else { + RETURN_FALSE; + } +} + +U_CFUNC PHP_FUNCTION(intltz_get_error_code) +{ + TIMEZONE_METHOD_INIT_VARS + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, TimeZone_ce_ptr) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_error_code: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + /* Fetch the object (without resetting its last error code ). */ + to = (TimeZone_object*)zend_object_store_get_object(object TSRMLS_CC); + if (to == NULL) + RETURN_FALSE; + + RETURN_LONG((long)TIMEZONE_ERROR_CODE(to)); +} + +U_CFUNC PHP_FUNCTION(intltz_get_error_message) +{ + const char* message = NULL; + TIMEZONE_METHOD_INIT_VARS + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", + &object, TimeZone_ce_ptr) == FAILURE) { + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, + "intltz_get_error_message: bad arguments", 0 TSRMLS_CC ); + RETURN_FALSE; + } + + + /* Fetch the object (without resetting its last error code ). */ + to = (TimeZone_object*)zend_object_store_get_object(object TSRMLS_CC); + if (to == NULL) + RETURN_FALSE; + + /* Return last error message. */ + message = intl_error_get_message(TIMEZONE_ERROR_P(to) TSRMLS_CC); + RETURN_STRING(message, 0); +} diff --git a/ext/intl/timezone/timezone_methods.h b/ext/intl/timezone/timezone_methods.h new file mode 100644 index 0000000000000..28c39f4fd703b --- /dev/null +++ b/ext/intl/timezone/timezone_methods.h @@ -0,0 +1,68 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#ifndef TIMEZONE_METHODS_H +#define TIMEZONE_METHODS_H + +#include + +PHP_METHOD(IntlTimeZone, __construct); + +PHP_FUNCTION(intltz_create_time_zone); + +PHP_FUNCTION(intltz_from_date_time_zone); + +PHP_FUNCTION(intltz_create_default); + +PHP_FUNCTION(intltz_get_id); + +PHP_FUNCTION(intltz_get_gmt); + +PHP_FUNCTION(intltz_get_unknown); + +PHP_FUNCTION(intltz_create_enumeration); + +PHP_FUNCTION(intltz_count_equivalent_ids); + +PHP_FUNCTION(intltz_create_time_zone_id_enumeration); + +PHP_FUNCTION(intltz_get_canonical_id); + +PHP_FUNCTION(intltz_get_region); + +PHP_FUNCTION(intltz_get_tz_data_version); + +PHP_FUNCTION(intltz_get_equivalent_id); + +PHP_FUNCTION(intltz_use_daylight_time); + +PHP_FUNCTION(intltz_get_offset); + +PHP_FUNCTION(intltz_get_raw_offset); + +PHP_FUNCTION(intltz_has_same_rules); + +PHP_FUNCTION(intltz_get_display_name); + +PHP_FUNCTION(intltz_get_dst_savings); + +PHP_FUNCTION(intltz_to_date_time_zone); + +PHP_FUNCTION(intltz_get_error_code); + +PHP_FUNCTION(intltz_get_error_message); + +#endif /* #ifndef TIMEZONE_METHODS_H */ diff --git a/ext/intl/transliterator/transliterator.c b/ext/intl/transliterator/transliterator.c index 75c9eaabdaa50..8ee49e1e51bbd 100644 --- a/ext/intl/transliterator/transliterator.c +++ b/ext/intl/transliterator/transliterator.c @@ -49,85 +49,6 @@ void transliterator_register_constants( INIT_FUNC_ARGS ) } /* }}} */ -/* {{{ transliterator_parse_error_to_string - * Transforms parse errors in strings. - */ -smart_str transliterator_parse_error_to_string( UParseError* pe ) -{ - smart_str ret = {0}; - char *buf; - int u8len; - UErrorCode status; - int any = 0; - - assert( pe != NULL ); - - smart_str_appends( &ret, "parse error " ); - if( pe->line > 0 ) - { - smart_str_appends( &ret, "on line " ); - smart_str_append_long( &ret, (long ) pe->line ); - any = 1; - } - if( pe->offset >= 0 ) { - if( any ) - smart_str_appends( &ret, ", " ); - else - smart_str_appends( &ret, "at " ); - - smart_str_appends( &ret, "offset " ); - smart_str_append_long( &ret, (long ) pe->offset ); - any = 1; - } - - if (pe->preContext[0] != 0 ) { - if( any ) - smart_str_appends( &ret, ", " ); - - smart_str_appends( &ret, "after \"" ); - intl_convert_utf16_to_utf8( &buf, &u8len, pe->preContext, -1, &status ); - if( U_FAILURE( status ) ) - { - smart_str_appends( &ret, "(could not convert parser error pre-context to UTF-8)" ); - } - else { - smart_str_appendl( &ret, buf, u8len ); - efree( buf ); - } - smart_str_appends( &ret, "\"" ); - any = 1; - } - - if( pe->postContext[0] != 0 ) - { - if( any ) - smart_str_appends( &ret, ", " ); - - smart_str_appends( &ret, "before or at \"" ); - intl_convert_utf16_to_utf8( &buf, &u8len, pe->postContext, -1, &status ); - if( U_FAILURE( status ) ) - { - smart_str_appends( &ret, "(could not convert parser error post-context to UTF-8)" ); - } - else - { - smart_str_appendl( &ret, buf, u8len ); - efree( buf ); - } - smart_str_appends( &ret, "\"" ); - any = 1; - } - - if( !any ) - { - smart_str_free( &ret ); - smart_str_appends( &ret, "no parse error" ); - } - - smart_str_0( &ret ); - return ret; -} - /* * Local variables: * tab-width: 4 diff --git a/ext/intl/transliterator/transliterator_methods.c b/ext/intl/transliterator/transliterator_methods.c index d0cfb9790d957..1aa39c54b980a 100644 --- a/ext/intl/transliterator/transliterator_methods.c +++ b/ext/intl/transliterator/transliterator_methods.c @@ -183,7 +183,7 @@ PHP_FUNCTION( transliterator_create_from_rules ) { char *msg = NULL; smart_str parse_error_str; - parse_error_str = transliterator_parse_error_to_string( &parse_error ); + parse_error_str = intl_parse_error_to_string( &parse_error ); spprintf( &msg, 0, "transliterator_create_from_rules: unable to " "create ICU transliterator from rules (%s)", parse_error_str.c ); smart_str_free( &parse_error_str ); diff --git a/ext/json/JSON_parser.h b/ext/json/JSON_parser.h index 541664b8c6f65..8671765b4d983 100644 --- a/ext/json/JSON_parser.h +++ b/ext/json/JSON_parser.h @@ -25,7 +25,10 @@ enum error_codes { PHP_JSON_ERROR_STATE_MISMATCH, PHP_JSON_ERROR_CTRL_CHAR, PHP_JSON_ERROR_SYNTAX, - PHP_JSON_ERROR_UTF8 + PHP_JSON_ERROR_UTF8, + PHP_JSON_ERROR_RECURSION, + PHP_JSON_ERROR_INF_OR_NAN, + PHP_JSON_ERROR_UNSUPPORTED_TYPE }; extern JSON_parser new_JSON_parser(int depth); diff --git a/ext/json/json.c b/ext/json/json.c index 8c8963db8cc5b..53608412f5a16 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -35,6 +35,7 @@ static PHP_MINFO_FUNCTION(json); static PHP_FUNCTION(json_encode); static PHP_FUNCTION(json_decode); static PHP_FUNCTION(json_last_error); +static PHP_FUNCTION(json_last_error_msg); static const char digits[] = "0123456789abcdef"; @@ -46,6 +47,7 @@ ZEND_DECLARE_MODULE_GLOBALS(json) ZEND_BEGIN_ARG_INFO_EX(arginfo_json_encode, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_ARG_INFO(0, options) + ZEND_ARG_INFO(0, depth) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_json_decode, 0, 0, 1) @@ -57,6 +59,9 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_json_last_error, 0) ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_json_last_error_msg, 0) +ZEND_END_ARG_INFO() /* }}} */ /* {{{ json_functions[] */ @@ -64,6 +69,7 @@ static const zend_function_entry json_functions[] = { PHP_FE(json_encode, arginfo_json_encode) PHP_FE(json_decode, arginfo_json_decode) PHP_FE(json_last_error, arginfo_json_last_error) + PHP_FE(json_last_error_msg, arginfo_json_last_error_msg) PHP_FE_END }; /* }}} */ @@ -96,6 +102,7 @@ static PHP_MINIT_FUNCTION(json) REGISTER_LONG_CONSTANT("JSON_UNESCAPED_SLASHES", PHP_JSON_UNESCAPED_SLASHES, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_PRETTY_PRINT", PHP_JSON_PRETTY_PRINT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_UNESCAPED_UNICODE", PHP_JSON_UNESCAPED_UNICODE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("JSON_PARTIAL_OUTPUT_ON_ERROR", PHP_JSON_PARTIAL_OUTPUT_ON_ERROR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_ERROR_NONE", PHP_JSON_ERROR_NONE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_ERROR_DEPTH", PHP_JSON_ERROR_DEPTH, CONST_CS | CONST_PERSISTENT); @@ -103,6 +110,9 @@ static PHP_MINIT_FUNCTION(json) REGISTER_LONG_CONSTANT("JSON_ERROR_CTRL_CHAR", PHP_JSON_ERROR_CTRL_CHAR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_ERROR_SYNTAX", PHP_JSON_ERROR_SYNTAX, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_ERROR_UTF8", PHP_JSON_ERROR_UTF8, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("JSON_ERROR_RECURSION", PHP_JSON_ERROR_RECURSION, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("JSON_ERROR_INF_OR_NAN", PHP_JSON_ERROR_INF_OR_NAN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("JSON_ERROR_UNSUPPORTED_TYPE", PHP_JSON_ERROR_UNSUPPORTED_TYPE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_OBJECT_AS_ARRAY", PHP_JSON_OBJECT_AS_ARRAY, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_BIGINT_AS_STRING", PHP_JSON_BIGINT_AS_STRING, CONST_CS | CONST_PERSISTENT); @@ -117,6 +127,7 @@ static PHP_GINIT_FUNCTION(json) { json_globals->encoder_depth = 0; json_globals->error_code = 0; + json_globals->encode_max_depth = 0; } /* }}} */ @@ -231,7 +242,7 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) } if (myht && myht->nApplyCount > 1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected"); + JSON_G(error_code) = PHP_JSON_ERROR_RECURSION; smart_str_appendl(buf, "null", 4); return; } @@ -332,6 +343,9 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) } } + if (JSON_G(encoder_depth) > JSON_G(encode_max_depth)) { + JSON_G(error_code) = PHP_JSON_ERROR_DEPTH; + } --JSON_G(encoder_depth); json_pretty_print_char(buf, options, '\n' TSRMLS_CC); json_pretty_print_indent(buf, options TSRMLS_CC); @@ -409,7 +423,7 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR smart_str_appendl(buf, tmp, l); efree(tmp); } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "double %.9g does not conform to the JSON spec, encoded as 0", d); + JSON_G(error_code) = PHP_JSON_ERROR_INF_OR_NAN; smart_str_appendc(buf, '0'); } } @@ -426,9 +440,6 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR } if (ulen < 0) { JSON_G(error_code) = PHP_JSON_ERROR_UTF8; - if (!PG(display_errors)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid UTF-8 sequence in argument"); - } smart_str_appendl(buf, "null", 4); } else { smart_str_appendl(buf, "\"\"", 2); @@ -556,7 +567,7 @@ static void json_encode_serializable_object(smart_str *buf, zval *val, int optio } if (myht && myht->nApplyCount > 1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected"); + JSON_G(error_code) = PHP_JSON_ERROR_RECURSION; smart_str_appendl(buf, "null", 4); return; } @@ -620,7 +631,7 @@ PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_ smart_str_appendl(buf, d, len); efree(d); } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "double %.9g does not conform to the JSON spec, encoded as 0", dbl); + JSON_G(error_code) = PHP_JSON_ERROR_INF_OR_NAN; smart_str_appendc(buf, '0'); } } @@ -641,7 +652,7 @@ PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_ break; default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "type is unsupported, encoded as null"); + JSON_G(error_code) = PHP_JSON_ERROR_UNSUPPORTED_TYPE; smart_str_appendl(buf, "null", 4); break; } @@ -745,23 +756,30 @@ PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, int str_len, /* }}} */ -/* {{{ proto string json_encode(mixed data [, int options]) +/* {{{ proto string json_encode(mixed data [, int options[, int depth]]) Returns the JSON representation of a value */ static PHP_FUNCTION(json_encode) { zval *parameter; smart_str buf = {0}; long options = 0; + long depth = JSON_PARSER_DEFAULT_DEPTH; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", ¶meter, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ll", ¶meter, &options, &depth) == FAILURE) { return; } JSON_G(error_code) = PHP_JSON_ERROR_NONE; + JSON_G(encode_max_depth) = depth; + php_json_encode(&buf, parameter, options TSRMLS_CC); - ZVAL_STRINGL(return_value, buf.c, buf.len, 1); + if (JSON_G(error_code) != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) { + ZVAL_FALSE(return_value); + } else { + ZVAL_STRINGL(return_value, buf.c, buf.len, 1); + } smart_str_free(&buf); } @@ -799,7 +817,7 @@ static PHP_FUNCTION(json_decode) /* }}} */ /* {{{ proto int json_last_error() - Returns the error code of the last json_decode(). */ + Returns the error code of the last json_encode() or json_decode() call. */ static PHP_FUNCTION(json_last_error) { if (zend_parse_parameters_none() == FAILURE) { @@ -810,6 +828,40 @@ static PHP_FUNCTION(json_last_error) } /* }}} */ +/* {{{ proto string json_last_error_msg() + Returns the error string of the last json_encode() or json_decode() call. */ +static PHP_FUNCTION(json_last_error_msg) +{ + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + switch(JSON_G(error_code)) { + case PHP_JSON_ERROR_NONE: + RETURN_STRING("No error", 1); + case PHP_JSON_ERROR_DEPTH: + RETURN_STRING("Maximum stack depth exceeded", 1); + case PHP_JSON_ERROR_STATE_MISMATCH: + RETURN_STRING("State mismatch (invalid or malformed JSON)", 1); + case PHP_JSON_ERROR_CTRL_CHAR: + RETURN_STRING("Control character error, possibly incorrectly encoded", 1); + case PHP_JSON_ERROR_SYNTAX: + RETURN_STRING("Syntax error", 1); + case PHP_JSON_ERROR_UTF8: + RETURN_STRING("Malformed UTF-8 characters, possibly incorrectly encoded", 1); + case PHP_JSON_ERROR_RECURSION: + RETURN_STRING("Recursion detected", 1); + case PHP_JSON_ERROR_INF_OR_NAN: + RETURN_STRING("Inf and NaN cannot be JSON encoded", 1); + case PHP_JSON_ERROR_UNSUPPORTED_TYPE: + RETURN_STRING("Type is not supported", 1); + default: + RETURN_STRING("Unknown error", 1); + } + +} +/* }}} */ + /* * Local variables: * tab-width: 4 diff --git a/ext/json/php_json.h b/ext/json/php_json.h index 08c07c2edc702..ec707ce3465a9 100644 --- a/ext/json/php_json.h +++ b/ext/json/php_json.h @@ -40,6 +40,7 @@ extern zend_module_entry json_module_entry; ZEND_BEGIN_MODULE_GLOBALS(json) int encoder_depth; int error_code; + int encode_max_depth; ZEND_END_MODULE_GLOBALS(json) #ifdef ZTS @@ -63,6 +64,7 @@ extern zend_class_entry *php_json_serializable_ce; #define PHP_JSON_UNESCAPED_SLASHES (1<<6) #define PHP_JSON_PRETTY_PRINT (1<<7) #define PHP_JSON_UNESCAPED_UNICODE (1<<8) +#define PHP_JSON_PARTIAL_OUTPUT_ON_ERROR (1<<9) /* Internal flags */ #define PHP_JSON_OUTPUT_ARRAY 0 diff --git a/ext/json/tests/003.phpt b/ext/json/tests/003.phpt index 3b52fb0884172..4ce5b0fde9d0c 100644 --- a/ext/json/tests/003.phpt +++ b/ext/json/tests/003.phpt @@ -9,10 +9,16 @@ $a = array(); $a[] = &$a; var_dump($a); + +echo "\n"; + var_dump(json_encode($a)); +var_dump(json_last_error(), json_last_error_msg()); -/* Break circular data structure to prevent memory leaks */ -unset($a[0]); +echo "\n"; + +var_dump(json_encode($a, JSON_PARTIAL_OUTPUT_ON_ERROR)); +var_dump(json_last_error(), json_last_error_msg()); echo "Done\n"; ?> @@ -25,6 +31,11 @@ array(1) { } } -Warning: json_encode(): recursion detected in %s on line %d +bool(false) +int(6) +string(%d) "Recursion detected" + string(8) "[[null]]" +int(6) +string(%d) "Recursion detected" Done diff --git a/ext/json/tests/004.phpt b/ext/json/tests/004.phpt index 1d282f9a96115..70ef3ffd1b80f 100644 --- a/ext/json/tests/004.phpt +++ b/ext/json/tests/004.phpt @@ -9,7 +9,16 @@ $a = new stdclass; $a->prop = $a; var_dump($a); + +echo "\n"; + var_dump(json_encode($a)); +var_dump(json_last_error(), json_last_error_msg()); + +echo "\n"; + +var_dump(json_encode($a, JSON_PARTIAL_OUTPUT_ON_ERROR)); +var_dump(json_last_error(), json_last_error_msg()); echo "Done\n"; ?> @@ -19,6 +28,11 @@ object(stdClass)#%d (1) { *RECURSION* } -Warning: json_encode(): recursion detected in %s on line %d +bool(false) +int(6) +string(%d) "Recursion detected" + string(22) "{"prop":{"prop":null}}" +int(6) +string(%d) "Recursion detected" Done diff --git a/ext/json/tests/007.phpt b/ext/json/tests/007.phpt index 9ee190a24cdc9..7557ac9ed7497 100644 --- a/ext/json/tests/007.phpt +++ b/ext/json/tests/007.phpt @@ -5,15 +5,15 @@ json_last_error() tests --FILE-- --EXPECTF-- string(5) ""abc"" -string(4) "null" +bool(false) string(4) "null" string(17) "[null,null,"abc"]" Done - diff --git a/ext/json/tests/bug53946.phpt b/ext/json/tests/bug53946.phpt index abbb81238b83f..111438ddc48ab 100644 --- a/ext/json/tests/bug53946.phpt +++ b/ext/json/tests/bug53946.phpt @@ -9,8 +9,8 @@ var_dump(json_encode("latin 1234 -/ russian мама мыла раму speci var_dump(json_encode("ab\xE0")); var_dump(json_encode("ab\xE0", JSON_UNESCAPED_UNICODE)); ?> ---EXPECT-- +--EXPECTF-- string(156) ""latin 1234 -\/ russian \u043c\u0430\u043c\u0430 \u043c\u044b\u043b\u0430 \u0440\u0430\u043c\u0443 specialchars \u0002 \b \n U+1D11E >\ud834\udd1e<"" string(100) ""latin 1234 -\/ russian мама мыла раму specialchars \u0002 \b \n U+1D11E >𝄞<"" -string(4) "null" -string(4) "null" +bool(false) +bool(false) diff --git a/ext/json/tests/bug54058.phpt b/ext/json/tests/bug54058.phpt index 3b1136bdd95e7..df1b3130f8422 100644 --- a/ext/json/tests/bug54058.phpt +++ b/ext/json/tests/bug54058.phpt @@ -8,28 +8,33 @@ Bug #54058 (json_last_error() invalid UTF-8 produces wrong error) $bad_utf8 = quoted_printable_decode('=B0'); json_encode($bad_utf8); -var_dump(json_last_error()); +var_dump(json_last_error(), json_last_error_msg()); $a = new stdclass; $a->foo = quoted_printable_decode('=B0'); json_encode($a); -var_dump(json_last_error()); +var_dump(json_last_error(), json_last_error_msg()); $b = new stdclass; $b->foo = $bad_utf8; $b->bar = 1; json_encode($b); -var_dump(json_last_error()); +var_dump(json_last_error(), json_last_error_msg()); $c = array( 'foo' => $bad_utf8, 'bar' => 1 ); json_encode($c); -var_dump(json_last_error()); +var_dump(json_last_error(), json_last_error_msg()); + ?> --EXPECTF-- int(5) +string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" int(5) +string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" int(5) +string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" int(5) +string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" diff --git a/ext/json/tests/bug61537.phpt b/ext/json/tests/bug61537.phpt new file mode 100644 index 0000000000000..80ed051c9a6d5 --- /dev/null +++ b/ext/json/tests/bug61537.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bug #61537 (json_encode() incorrectly truncates/discards information) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(false) +int(5) +string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" +string(4) "null" +int(5) +string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" + +bool(false) +int(5) +string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" +string(4) "null" +int(5) +string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" diff --git a/ext/json/tests/bug61978.phpt b/ext/json/tests/bug61978.phpt index 2c732979ef496..c34b03f8f7351 100644 --- a/ext/json/tests/bug61978.phpt +++ b/ext/json/tests/bug61978.phpt @@ -29,19 +29,15 @@ class JsonTest2 implements JsonSerializable { $obj1 = new JsonTest1(); -var_dump(json_encode($obj1)); +var_dump(json_encode($obj1, JSON_PARTIAL_OUTPUT_ON_ERROR)); -echo "\n==\n"; +echo "==\n"; $obj2 = new JsonTest2(); -var_dump(json_encode($obj2)); +var_dump(json_encode($obj2, JSON_PARTIAL_OUTPUT_ON_ERROR)); ?> --EXPECTF-- -Warning: json_encode(): recursion detected in %s on line %d string(44) "{"test":"123","me":{"test":"123","me":null}}" - == - -Warning: json_encode(): recursion detected in %s on line %d string(44) "{"test":"123","me":{"test":"123","me":null}}" diff --git a/ext/json/tests/bug62369.phpt b/ext/json/tests/bug62369.phpt new file mode 100644 index 0000000000000..a5efd802c5ee6 --- /dev/null +++ b/ext/json/tests/bug62369.phpt @@ -0,0 +1,34 @@ +--TEST-- +FR #62369 (Segfault on json_encode(deeply_nested_array) +--SKIPIF-- + +--FILE-- + +--FILE-- + +--EXPECTF-- +float(INF) +bool(false) +int(7) +string(34) "Inf and NaN cannot be JSON encoded" +string(1) "0" +int(7) +string(34) "Inf and NaN cannot be JSON encoded" + +float(NAN) +bool(false) +int(7) +string(34) "Inf and NaN cannot be JSON encoded" +string(1) "0" +int(7) +string(34) "Inf and NaN cannot be JSON encoded" diff --git a/ext/json/tests/json_encode_basic.phpt b/ext/json/tests/json_encode_basic.phpt index 152e24444c008..fc348eed8112c 100644 --- a/ext/json/tests/json_encode_basic.phpt +++ b/ext/json/tests/json_encode_basic.phpt @@ -150,9 +150,7 @@ string(4) "null" -- Iteration 25 -- string(4) "null" -- Iteration 26 -- - -Warning: json_encode(): type is unsupported, encoded as null in %s on line %d -string(4) "null" +bool(false) -- Iteration 27 -- string(82) "{"MyInt":99,"MyFloat":123.45,"MyBool":true,"MyNull":null,"MyString":"Hello World"}" -===Done=== \ No newline at end of file +===Done=== diff --git a/ext/json/tests/json_encode_error.phpt b/ext/json/tests/json_encode_error.phpt index d130dd960c5b7..547c8bef17bf5 100644 --- a/ext/json/tests/json_encode_error.phpt +++ b/ext/json/tests/json_encode_error.phpt @@ -34,7 +34,5 @@ Warning: json_encode() expects at least 1 parameter, 0 given in %s on line %d NULL -- Testing json_encode() function with more than expected no. of arguments -- - -Warning: json_encode() expects at most 2 parameters, 3 given in %s on line %d -NULL +string(5) ""abc"" ===Done=== diff --git a/ext/json/tests/pass001.1.phpt b/ext/json/tests/pass001.1.phpt index 7e15a7622ac61..a51f885780d74 100644 --- a/ext/json/tests/pass001.1.phpt +++ b/ext/json/tests/pass001.1.phpt @@ -90,10 +90,10 @@ $arr = json_decode($test, true); var_dump($arr); echo "ENCODE: FROM OBJECT\n"; -$obj_enc = json_encode($obj); +$obj_enc = json_encode($obj, JSON_PARTIAL_OUTPUT_ON_ERROR); echo $obj_enc . "\n"; echo "ENCODE: FROM ARRAY\n"; -$arr_enc = json_encode($arr); +$arr_enc = json_encode($arr, JSON_PARTIAL_OUTPUT_ON_ERROR); echo $arr_enc . "\n"; echo "DECODE AGAIN: AS OBJECT\n"; diff --git a/ext/json/tests/pass001.1_64bit.phpt b/ext/json/tests/pass001.1_64bit.phpt index 9c3e669952899..ff2714436d056 100644 --- a/ext/json/tests/pass001.1_64bit.phpt +++ b/ext/json/tests/pass001.1_64bit.phpt @@ -90,10 +90,10 @@ $arr = json_decode($test, true); var_dump($arr); echo "ENCODE: FROM OBJECT\n"; -$obj_enc = json_encode($obj); +$obj_enc = json_encode($obj, JSON_PARTIAL_OUTPUT_ON_ERROR); echo $obj_enc . "\n"; echo "ENCODE: FROM ARRAY\n"; -$arr_enc = json_encode($arr); +$arr_enc = json_encode($arr, JSON_PARTIAL_OUTPUT_ON_ERROR); echo $arr_enc . "\n"; echo "DECODE AGAIN: AS OBJECT\n"; diff --git a/ext/json/tests/pass001.phpt b/ext/json/tests/pass001.phpt index 43be11e2b0fcf..1fd05fcdd8705 100644 --- a/ext/json/tests/pass001.phpt +++ b/ext/json/tests/pass001.phpt @@ -79,10 +79,10 @@ $arr = json_decode($test, true); var_dump($arr); echo "ENCODE: FROM OBJECT\n"; -$obj_enc = json_encode($obj); +$obj_enc = json_encode($obj, JSON_PARTIAL_OUTPUT_ON_ERROR); echo $obj_enc . "\n"; echo "ENCODE: FROM ARRAY\n"; -$arr_enc = json_encode($arr); +$arr_enc = json_encode($arr, JSON_PARTIAL_OUTPUT_ON_ERROR); echo $arr_enc . "\n"; echo "DECODE AGAIN: AS OBJECT\n"; diff --git a/ext/json/tests/unsupported_type_error.phpt b/ext/json/tests/unsupported_type_error.phpt new file mode 100644 index 0000000000000..45a167a5ac0b1 --- /dev/null +++ b/ext/json/tests/unsupported_type_error.phpt @@ -0,0 +1,26 @@ +--TEST-- +An error is thrown when an unsupported type is encoded +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +resource(5) of type (stream) +bool(false) +int(8) +string(21) "Type is not supported" +string(4) "null" +int(8) +string(21) "Type is not supported" diff --git a/ext/mbstring/config.w32 b/ext/mbstring/config.w32 index 7bc9518cb8c3b..6b7e05a3297f9 100644 --- a/ext/mbstring/config.w32 +++ b/ext/mbstring/config.w32 @@ -37,7 +37,7 @@ if (PHP_MBSTRING != "no") { mbfilter_uuencode.c mbfilter_armscii8.c mbfilter_cp850.c \ mbfilter_cp5022x.c mbfilter_sjis_open.c mbfilter_sjis_mobile.c \ mbfilter_sjis_mac.c \ - mbfilter_iso2022jp_2004.c mbfilter_iso2022jp_mobile.c \ + mbfilter_iso2022jp_2004.c mbfilter_iso2022jp_mobile.c \ mbfilter_tl_jisx0201_jisx0208.c", "mbstring"); ADD_SOURCES("ext/mbstring/libmbfl/mbfl", "mbfilter.c mbfilter_8bit.c \ diff --git a/ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c b/ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c index 2f84edff21995..c134e5d585846 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c @@ -424,7 +424,7 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter) } else if (c == 0xa0) { s1 = 0x00a0; } else if (c == 0xa5) { /* YEN SIGN */ - s1 = 0x216f; /* FULLWIDTH YEN SIGN */ + s1 = 0x216f; /* FULLWIDTH YEN SIGN */ } else if (c == 0xff3c) { /* FULLWIDTH REVERSE SOLIDUS */ s1 = 0x2140; } diff --git a/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.h b/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.h index ef5e6da7f927d..c127b184049e7 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.h +++ b/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.h @@ -49,6 +49,8 @@ extern const struct mbfl_convert_vtbl vtbl_wchar_utf8_kddi_b; extern const struct mbfl_convert_vtbl vtbl_utf8_sb_wchar; extern const struct mbfl_convert_vtbl vtbl_wchar_utf8_sb; + + int mbfl_filt_conv_utf8_mobile_wchar(int c, mbfl_convert_filter *filter); int mbfl_filt_conv_wchar_utf8_mobile(int c, mbfl_convert_filter *filter); diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index a42f2e8809f61..4e430b6ea2364 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -473,7 +473,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_ereg_replace_callback, 0, 0, 3) ZEND_ARG_INFO(0, string) ZEND_ARG_INFO(0, option) ZEND_END_ARG_INFO() - + ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_split, 0, 0, 2) ZEND_ARG_INFO(0, pattern) ZEND_ARG_INFO(0, string) @@ -1688,12 +1688,12 @@ PHP_MINFO_FUNCTION(mbstring) php_info_print_table_start(); php_info_print_table_row(2, "Multibyte Support", "enabled"); php_info_print_table_row(2, "Multibyte string engine", "libmbfl"); - php_info_print_table_row(2, "HTTP input encoding translation", MBSTRG(encoding_translation) ? "enabled": "disabled"); - { - char tmp[256]; - snprintf(tmp, sizeof(tmp), "%d.%d.%d", MBFL_VERSION_MAJOR, MBFL_VERSION_MINOR, MBFL_VERSION_TEENY); - php_info_print_table_row(2, "libmbfl version", tmp); - } + php_info_print_table_row(2, "HTTP input encoding translation", MBSTRG(encoding_translation) ? "enabled": "disabled"); + { + char tmp[256]; + snprintf(tmp, sizeof(tmp), "%d.%d.%d", MBFL_VERSION_MAJOR, MBFL_VERSION_MINOR, MBFL_VERSION_TEENY); + php_info_print_table_row(2, "libmbfl version", tmp); + } php_info_print_table_end(); php_info_print_table_start(); diff --git a/ext/mbstring/oniguruma/COPYING b/ext/mbstring/oniguruma/COPYING index 4d321bb93bb68..2cee0bbec8245 100644 --- a/ext/mbstring/oniguruma/COPYING +++ b/ext/mbstring/oniguruma/COPYING @@ -1,12 +1,8 @@ Oniguruma LICENSE ----------------- -When this software is partly used or it is distributed with Ruby, -this of Ruby follows the license of Ruby. -It follows the BSD license in the case of the one except for it. - /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/ext/mbstring/oniguruma/HISTORY b/ext/mbstring/oniguruma/HISTORY index a1debefa490b5..06f38c246a999 100644 --- a/ext/mbstring/oniguruma/HISTORY +++ b/ext/mbstring/oniguruma/HISTORY @@ -1,111 +1,316 @@ History -2007/08/16: Version 4.7.1 - -2007/08/16: [test] success in ruby 1.9.0 (2007-04-06) [i686-linux]. -2007/07/04: [spec] (thanks K.Takata) +2010/01/09: Version 5.9.2 + +2010/01/05: [bug] fix utf16be_code_to_mbc() and utf16le_code_to_mbc(). +2008/09/16: [bug] fix memory leaks in parse_exp(). +2008/08/01: [bug] fix memory leaks. +2008/06/17: [bug] invalid type of argument was used + in onig_st_lookup_strend(). +2008/06/16: [bug] invalid CaseFoldMap entry in ISO-8859-5. 0xdf -> 0xde +2008/02/19: [new] add: onig_reg_init(). +2008/02/19: [new] add: onig_free_body(). +2008/02/19: [new] add: onig_new_without_alloc(). +2008/02/19: [API] rename onig_alloc_init() to onig_reg_init(), + and argument type changed. +2008/01/31: [impl] move UTF16_IS_SURROGATE_XXX() to regenc.h. +2008/01/30: [bug] (thanks akr) + fix euctw_islead(). +2008/01/23: [bug] update enc/koi8.c. + +2007/12/22: Version 5.9.1 + +2007/12/21: [impl] add sprint_byte(). +2007/11/28: [bug] (thanks Andy Armstrong) + don't overwrite error code in fetch_name(). +2007/11/12: [bug] utf8 mbc length of code 0xfe, 0xff are not 1, +2007/10/23: [spec] onig_enc_len() takes three arguments. (not used) +2007/10/15: [impl] (thanks Rui Hirokawa) + add check HAVE_STDARG_H. +2007/09/07: [API] rename enc_len() to onig_enc_len() in oniguruma.h. +2007/09/04: [API] remove ONIGENC_ERR_XXXXX. +2007/09/03: [API] add error ONIGERR_INVALID_CODE_POINT_VALUE. +2007/09/03: [impl] change error message to "invaid code point value" + for ONIGERR_INVALID_WIDE_CHAR_VALUE. +2007/09/03: [bug] xxx_code_to_mbclen() should return + ONIGERR_INVALID_WIDE_CHAR_VALUE for invalid code point. + ex. /[\x{7fffffff}]/ for ASCII encoding. +2007/08/28: [impl] remove "warning: no previous declaration ...". +2007/08/21: [impl] remove warnings in enc/mktable.c. +2007/08/20: [impl] remove "warning: unused parameter" +2007/08/20: [impl] remove "warning: comparison between signed and unsigned". +2007/08/06: [impl] remove clear_not_flag_cclass(). +2007/08/03: [bug] fix the case of undefined USE_NAMED_GROUP. +2007/08/02: [spec] add backref by number. +2007/08/01: [API] add OnigCtype. +2007/07/27: [spec] add USE_CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS. +2007/07/24: [impl] define PLATFORM_UNALIGNED_WORD_ACCESS. +2007/07/23: [dist] fix doc/FAQ.ja. + +2007/07/14: Version 5.9.0 + +2007/07/13: [bug] add check into onig_reduce_nested_quantifier(). +2007/06/26: [spec] (thanks K.Takata) ONIG_OPTION_SINGLELINE: '$' -> '\Z' (as Perl) -2007/07/04: [dist] (thanks K.Takata) +2007/06/26: [dist] (thanks K.Takata) fix documents API and API.ja. - -2007/06/18: Version 4.7.0 - -2007/06/18: [test] success in ruby 1.9.0 (2007-04-06) [i686-linux]. +2007/06/19: [impl] remove IS_NOT_NULL() check before onig_node_free(). 2007/06/18: [bug] (thanks KUBO Takehiro) WORD_ALIGNMENT_SIZE must be sizeof(OnigCodePoint). -2007/06/05: [impl] add #ifndef vsnprintf in regint.h. -2007/06/05: [bug] should check USE_CRNL_AS_LINE_TERMINATOR case +2007/06/18: [impl] rename CClassNode flags. +2007/06/18: [bug] initialization miss. +2007/06/13: [impl] change node type reference NXXXX. +2007/06/11: [impl] add node type bit. +2007/06/11: [spec] allow anchor in enclosed repeater. /(\z)*/ +2007/06/11: [impl] rename node types. +2007/06/08: [impl] remove OP_SET_OPTION_PUSH and OP_SET_OPTION from match_at(). +2007/06/07: [impl] use xvsnprintf(). +2007/06/06: [tune] don't set qn->next_head_exact for string first byte is zero. +2007/06/06: [impl] remove unused variables. + +2007/06/04: Version 5.8.0 + +2007/06/04: [impl] add #ifndef vsnprintf into regint.h. +2007/05/31: [dist] add configure option '--enable-crnl-as-line-terminator'. +2007/05/30: [dist] add sample/crnl.c. +2007/05/30: [bug] should check USE_CRNL_AS_LINE_TERMINATOR case in onig_search(). +2007/05/29: [impl] move USE_CRNL_AS_LINE_TERMINATOR into regenc.h. +2007/05/29: [impl] should check USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE + in forward_search_range() and backward_search_range(). -2007/04/12: Version 4.6.2 +2007/04/27: Version 5.7.0 +2007/04/20: [spec] add config USE_MATCH_RANGE_IS_COMPLETE_RANGE. +2007/04/20: [impl] refactoring in match_at(). + +2007/04/12: Version 5.6.1 + +2007/04/12: [bug] must not use UChar in oniguruma.h. 2007/04/09: [impl] change STATE_CHECK_BUFF_MAX_SIZE value from 0x8000 - to 0x4000. + to 0x4000. [ruby-core:10883] + +2007/04/04: Version 5.6.0 (mourning for Hideo Takamatsu) + +2007/04/03: [spec] add new notation (?'name'), \k'name', \g'name'. +2007/04/03: [impl] remove unused variable. 2007/03/26: [impl] add 'void' to function declarations. -2007/03/06: Version 4.6.1 +2007/03/06: Version 5.5.3 -2007/03/06: [test] success in ruby 1.9.0 (2006-10-23) [i686-linux]. 2007/03/06: [bug] add #include for bcc32. (In bcc32, alloca() is declared in malloc.h.) -2007/03/06: [impl] remove including version.h of Ruby. 2007/03/02: [bug] invalid optimization for semi-end-buf in onig_search(). ex. /\n\Z/.match("aaaaaaaaaa\n") 2007/03/02: [impl] move range > start check position in end_buf process. -2007/02/08: Version 4.6.0 +2007/01/09: Version 5.5.2 -2007/02/08: [test] success in ruby 1.9.0 (2006-10-23) [i686-linux]. -2007/01/09: [tune] select_opt_exact_info() didn't work for empty info. +2007/01/09: [impl] rename USE_EXTERNAL_LOWER_CASE_CONV_TABLE. +2007/01/05: [tune] select_opt_exact_info() didn't work for empty info. ex. /.a/ make MAP info instead of EXACT info. -2006/12/29: [impl] add print_enc_string() for ONIG_DEBUG mode. -2006/12/22: [spec] should check too short multibyte char in parse_exp(). - add USE_PAD_TO_SHORT_BYTE_CHAR. - ex. /\x00/ in UTF16 should be error. +2006/12/28: [impl] add print_enc_string() for ONIG_DEBUG mode. + +2006/12/22: Version 5.5.1 -2006/11/17: Version 4.5.1 +2006/12/22: [impl] rename ADD_PAD_TO_SHORT_BYTE_STRING + . to USE_PAD_TO_SHORT_BYTE_CHAR. +2006/12/21: [spec] should check too short multibyte char in parse_exp(). + add ADD_PAD_TO_SHORT_BYTE_STRING. + ex. /\x00/ in UTF16 should be error. -2006/11/17: [test] success in ruby 1.9.0 (2006-10-23) [i686-linux]. -2006/11/15: [impl] remove CHECK_INTERRUPT. +2006/12/06: Version 5.5.0 + +2006/12/05: [bug] should add unfold-1 codes from folded code into + onigenc_unicode_get_case_fold_codes_by_str(). + (ex. "S" -> "s" -> 0x017f) +2006/12/05: [new] add flag ONIGENC_CASE_FOLD_TURKISH_AZERI and + USE_UNICODE_CASE_FOLD_TURKISH_AZERI. (disabled in default) +2006/12/04: [spec] remove ONIGENC_CASE_FOLD_FULL. +2006/11/30: [impl] remove unnecessary check in xxx_mbc_case_fold(). + +2006/11/29: Version 5.4.0 + +2006/11/28: [spec] INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR is enabled in + default case fold status. +2006/11/28: [spec] rename ONIGENC_CASE_FOLD_MULTI_CHAR to + INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR. +2006/11/28: [impl] remove USE_UNICODE_CASE_FOLD_MULTI_CHAR. +2006/11/28: [impl] remove Fold[123]Table and add FoldTable. +2006/11/27: [impl] change tool/unicode_fc.rb to see CaseFolding.txt. +2006/11/24: [bug] should call callback for to[j] <-> to[k] in + onigenc_unicode_apply_all_case_fold(). + +2006/11/22: Version 5.3.0 + +2006/11/22: [dist] add index_ja.html. +2006/11/22: [impl] undef ONIG_ESCAPE_UCHAR_COLLISION in regint.h and regenc.h. +2006/11/21: [bug] invalid array access. +2006/11/21: [impl] escape UChar collision from config.h. +2006/11/20: [new] add Hiragana/Katakana properties into Shift_JIS. +2006/11/20: [impl] fix CR_Katakana[] values in EUC-JP. +2006/11/17: [impl] declare strend hash table functions in regint.h. +2006/11/17: [impl] move property list functions to regenc.c. +2006/11/17: [new] add Hiragana/Katakana properties into EUC-JP. +2006/11/15: [impl] remove NOT_RUBY from AM_CFLAGS. + +2006/11/14: Version 5.2.0 + +2006/11/14: [impl] remove program codes for Ruby. +2006/11/14: [impl] reduce program codes for Ruby. 2006/11/10: [bug] 0x24, 0x2b, 0x3c, 0x3d, 0x3e, 0x5e, 0x60, 0x7c, 0x7e should be [:punct:]. +2006/11/09: [new] (thanks Byte) + add new character encoding CP1251. 2006/11/08: [impl] rename QUALIFIER -> QUANTIFIER. -2006/11/07: [bug] (thanks Byte) - add 0xa3 <=> 0xb3 to CaseFoldMap[] for KOI8-R. -2006/11/06: Version 4.5.0 +2006/11/07: Version 5.1.0 -2006/11/06: [test] success in ruby 1.9.0 (2006-10-23) [i686-linux]. -2006/11/06: [API] remove ONIGENC_AMBIGUOUS_MATCH_COMPOUND. +2006/11/07: [dist] remove test.rb, testconv.rb and testconvu.rb. +2006/11/07: [bug] get_case_fold_codes_by_str() should handle 'Ss' and 'sS' + combination for ess-tsett. +2006/11/07: [impl] apply_all_case_fold() doesn't need to return all + case character combination for multi-character folding. + (ONIGENC_CASE_FOLD_MULTI_CHAR) +2006/11/07: [bug] (thanks Byte) + add { 0xa3, 0xb3 } to CaseFoldMap[] for KOI8-R. 2006/11/06: [spec] change ONIG_OPTION_FIND_LONGEST to search all of the string range. add USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE. - -2006/10/30: Version 4.4.6 - -2006/10/30: [test] success in ruby 1.9.0 (2006-10-23) [i686-linux]. +2006/11/02: [impl] re-implement expand_case_fold_string() for + ONIGENC_CASE_FOLD_MULTI_CHAR. +2006/10/30: [impl] add NSTR_DONT_GET_OPTINFO flag. 2006/10/30: [impl] (thanks K.Takata) add THREAD_SYSTEM_INIT and THREAD_SYSTEM_END. 2006/10/30: [bug] (thanks Wolfgang Nadasi-Donner) invalid offset value was used in STATE_CHECK_BUFF_INIT(). - -2006/10/24: Version 4.4.5 - -2006/10/24: [test] success in ruby 1.9.0 (2006-10-23) [i686-linux]. -2006/10/24: [impl] escape -Wall warning. -2006/10/24: [tune] (thanks Kornelius Kalnbach) +2006/10/27: [tune] speed up ONIGENC_MBC_CASE_FOLD() for UTF-16, UTF-32. + (ASCII code check) +2006/10/27: [tune] (thanks Kornelius Kalnbach) String#scan for long string needs long time compare with old Ruby by initialization time for combination explosion check ex. ("test " * 100_000).scan(/\w*\s?/) change STATE_CHECK_BUFF_MAX_SIZE from 0x8000000 to 0x8000. reduce initialization area of state_check_buff. +2006/10/25: [impl] add DISABLE_CASE_FOLD_MULTI_CHAR(). + +2006/10/23: Version 5.0.1 + +2006/10/23: [bug] should fold string in expand_case_fold_string(). +2006/10/23: [bug] (thanks Km) + too many case fold/unfold expansion problem. + don't expand and set ambig flag to the string node. + (except ONIGENC_CASE_FOLD_MULTI_CHAR). +2006/10/23: [bug] (thanks K.Takata) + invalid \p{Alnum}, \p{ASCII}, [:alnum:], [:ascii:]. + fix OnigEncAsciiCtypeTable[] etc... +2006/10/23: [spec] (thanks K.Takata) + add [:word:] POSIX bracket. +2006/10/23: [bug] (thanks K.Takata) + \p{Word} doesn't work. +2006/10/20: [impl] don't expand for AMBIG_FLAG string in + expand_case_fold_string(). + +2006/10/19: Version 5.0.0 + +2006/10/18: [bug] ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM should be 13. +2006/10/18: [impl] remove unused functions. +2006/10/18: [dist] update documents. +2006/10/18: [API] move OnigMetaCharTableType to OnigSyntaxType. +2006/10/18: [dev] add too/unicode_fc.rb, unicode_pc.rb. +2006/10/18: [dist] remove MANIFEST-RUBY from distribution. +2006/10/18: [bug] return duplicated code in + onigenc_unicode_get_case_fold_codes_by_str(). +2006/10/18 [API] remove ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS. +2006/10/18: [dev] add tool/19. +2006/10/18: [dist] remove target 19 from Makefile.am. +2006/10/17: [dist] add enc/unicode.c to target 19 of win32/Makefile. +2006/10/17: [impl] change type for escape VC++ warning. +2006/10/17: [API] rename ONIGENC_CASE_FOLD_NONE to ONIGENC_CASE_FOLD_MIN. +2006/10/17: [dist] remove INSTALL-RUBY from distribution. +2006/10/17: [dist] update LTVERSION to "2:0:0". +2006/10/17: [impl] remove warnings for [make CFLAGS="-g -O2 -Wall"] + in the case USE_UNICODE_PROPERTIES and + USE_UNICODE_CASE_FOLD_MULTI_CHAR are undefined. +2006/10/17: [impl] remove warnings for [make CFLAGS="-g -O2 -Wall"]. +2006/10/17: [impl] re-implement onigenc_unicode_apply_all_case_fold(). + multi-char by case folded char-class is treated as + caseless-string (ambig flag on). + enable OP_EXACT1_IC and OP_EXACTN_IC. +2006/10/16: [bug] unfold expand for 1->2, 1->3 folding in + onigenc_unicode_apply_all_case_fold(). + add CaseFoldExpand_12[], CaseFoldExpand_13[]. 2006/10/16: [bug] (thanks Akinori Musha) first argument of rb_warn() should be format string. -2006/10/10: [impl] add msa.state_check_buff_size initialization +2006/10/16: [impl] add msa.state_check_buff_size initialization in onig_search(). +2006/10/16: [spec] re-implement Unicode Caseless Match codes. 2006/10/10: [bug] should call onig_st_free_table() in onig_free_shared_cclass_table(). +2006/10/10: [impl] remove OnigCompCaseFoldCodes. +2006/10/10: [impl] remove onigenc_ascii_is_mbc_ambiguous() and + onigenc_mbn_is_mbc_ambiguous(). +2006/10/10: [API] remove is_mbc_ambiguous() member from OnigEncodingType. +2006/10/10: [API] rename onig_set_default_ambig_flag() to + onig_set_default_case_fold_flag(), + onig_get_default_ambig_flag() to + onig_get_default_case_fold_flag(), + onig_get_ambig_flag() to onig_get_case_fold_flag(). +2006/10/10: [API] rename ambig_flag to case_fold_flag. +2006/10/10: [API] rename OnigAmbigType to OnigCaseFoldType. +2006/10/10: [impl] rename ONIGENC_IS_CODE_SB_WORD() to IS_CODE_SB_WORD() + and move to regint.h. 2006/10/10: [impl] remove OP_WORD_SB and OP_WORD_MB. +2006/10/10: [impl] remove OP_EXACT1_IC and OP_EXACTN_IC from match_at(). +2006/10/10: [impl] should free new_str in expand_case_fold_string(). +2006/10/06: [dist] add test entrys to sample/encode.c. +2006/10/06: [impl] re-implement caseless match (case-fold). +2006/10/06: [impl] expand string node by case fold variations. + add expand_case_fold_string(). +2006/10/05: [spec] rename OnigCompAmbigCodeItem to OnigCaseFoldCodeItem. +2006/10/05: [spec] add apply_all_case_fold() and get_case_fold_codes_by_str() + to OnigEncodingType. +2006/10/05: [spec] remove ambig_flag, get_all_pair_ambig_codes() and + get_all_comp_ambig_codes() member from OnigEncodingType. +2006/10/03: [impl] rename mbc_to_normalize() to mbc_case_fold(). +2006/10/03: [spec] rename ONIGENC_AMBIGUOUS_MATCH_XXX + to ONIGENC_CASE_FOLD_XXX. + rename ONIGENC_CASE_FOLD_COMPOUND + to ONIGENC_CASE_FOLD_MULTI_CHAR. +2006/10/02: [impl] remove all ONIG_RUBY_M17N part. 2006/09/29: [impl] initialize state_check_buff_size in STATE_CHECK_BUFF_INIT(). make valgrind happy. -2006/09/22: [impl] convert to ascii for parameter string in +2006/09/22: [impl] remove parse time ctype values (CTYPE_WORD etc...) +2006/09/22: [ruby] enable USE_BACKREF_AT_LEVEL for Ruby mode. +2006/09/22: [spec] (thanks Allan Odgaard) + allow upper case letter as the first character + of group name. + fetch_name() and fetch_name_with_level() +2006/09/21: [impl] convert to ascii for parameter string in onig_error_code_to_str(). add enc member into OnigErrorInfo. - -2006/09/19: Version 4.4.4 - -2006/09/19: [test] success in ruby 1.9.0 (2006-08-22) [i686-linux]. +2006/09/21: [dist] update documents for Unicode Property. +2006/09/21: [new] add Unicode Properties. (enc/unicode.c) + Any, Assigned, C, Cc, L, Lm, Arabic, Greek etc... +2006/09/21: [impl] add USE_UNICODE_PROPERTIES into regenc.h. +2006/09/21: [impl] remove USE_UNICODE_FULL_RANGE_CTYPE. +2006/09/20: [impl] change ONIGENC_CTYPE_XXXX to sequencial values. + add BIT_CTYPE_XXXX bit flags to regenc.h. + update XXXX_CtypeTable[] for BIT_CTYPE_ALNUM. +2006/09/19: [memo] move from CVS to Subversion (1.3.2). 2006/09/19: [impl] (thanks KOYAMA Tetsuji) HAVE_STDARG_PROTOTYPES was not defined in Mac OS X by Xcode 2.4(gcc 4.0.1) problem. [php-dev 1312] etc... - -2006/09/15: Version 4.4.3 - -2006/09/15: [test] success in ruby 1.9.0 (2006-08-22) [i686-linux]. 2006/09/15: [bug] (thanks Allan Odgaard) out of range access in bm_search_notrev(). (p < s) +2006/09/13: [impl] add ONIGENC_CTYPE_ENC_EXT flag. +2006/09/13: [spec] remove 'Is' prefix check for property name + from fetch_char_property_to_ctype(). +2006/09/13: [API] add property_name_to_ctype member to OnigEncodingType. +2006/09/12: [spec][ruby] add ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY and + ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT to OnigSyntaxRuby. 2006/09/08: Version 4.4.2 @@ -1808,8 +2013,17 @@ History [inst: changes for installation] [dist: distribution change] [test: test] +[dev: development] [memo: memo] -- + +svn copy file:///home/kosako/svnreps/svnrep_onig/trunk file:///home/kosako/svnreps/svnrep_onig/tags/5.0.0 -m "ADD TAG: 5.0.0" + + +svn propset svn:ignore -F .cvsignore . +svn commit -m "..." + + cvs history -T @@ -1820,7 +2034,7 @@ cvs rtag "VERSION_X_X_X" oniguruma * write Makefile.am and configure.in. > aclocal -> libtoolize +> libtoolize or glibtoolize > automake --foreign --add-missing > autoconf > configure --with-rubydir=... CFLAGS="-O2 -Wall" diff --git a/ext/mbstring/oniguruma/README b/ext/mbstring/oniguruma/README index dff7fba562251..8390afd0508f5 100644 --- a/ext/mbstring/oniguruma/README +++ b/ext/mbstring/oniguruma/README @@ -1,9 +1,8 @@ -README 2007/06/18 +README 2007/05/31 Oniguruma ---- (C) K.Kosako http://www.geocities.jp/kosako3/oniguruma/ -http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/oniguruma/ Oniguruma is a regular expressions library. The characteristics of this library is that different character encoding @@ -13,16 +12,20 @@ Supported character encodings: ASCII, UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE, EUC-JP, EUC-TW, EUC-KR, EUC-CN, - Shift_JIS, Big5, GB 18030, KOI8-R, KOI8, + Shift_JIS, Big5, GB18030, KOI8-R, CP1251, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10, ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16 -* GB 18030: contributed by KUBO Takehiro -* KOI8 is not included in library archive by default setup. - (need to edit Makefile if you want to use it.) +* GB18030: contributed by KUBO Takehiro +* CP1251: contributed by Byte ------------------------------------------------------------ +License + + BSD license. + + Install Case 1: Unix and Cygwin platform @@ -63,14 +66,6 @@ Install -License - - When this software is partly used or it is distributed with Ruby, - this of Ruby follows the license of Ruby. - It follows the BSD license in the case of the one except for it. - - - Regular Expressions See doc/RE (or doc/RE.ja for Japanese). @@ -108,7 +103,10 @@ Sample Programs sample/posix.c POSIX API sample. sample/sql.c example of the variable meta characters. (SQL-like pattern matching) + +Test Programs sample/syntax.c Perl, Java and ASIS syntax test. + sample/crnl.c --enable-crnl-as-line-terminator test Source Files @@ -145,9 +143,10 @@ Source Files enc/euc_kr.c EUC-KR, EUC-CN encoding. enc/sjis.c Shift_JIS encoding. enc/big5.c Big5 encoding. - enc/gb18030.c GB 18030 encoding (contributed by KUBO Takehiro) + enc/gb18030.c GB18030 encoding. enc/koi8.c KOI8 encoding. enc/koi8_r.c KOI8-R encoding. + enc/cp1251.c CP1251 encoding. enc/iso8859_1.c ISO-8859-1 encoding. (Latin-1) enc/iso8859_2.c ISO-8859-2 encoding. (Latin-2) enc/iso8859_3.c ISO-8859-3 encoding. (Latin-3) @@ -176,14 +175,15 @@ Source Files -API differences with Japanized GNU regex(version 0.12) of Ruby 1.8/1.6 - - + re_compile_fastmap() is removed. - + re_alloc_pattern() is added. - +ToDo + ? case fold flag: Katakana <-> Hiragana. + ? add ONIG_OPTION_NOTBOS/NOTEOS. (\A, \z, \Z) + ?? \X (== \PM\pM*) + ?? implement syntax behavior ONIG_SYN_CONTEXT_INDEP_ANCHORS. + ?? transmission stopper. (return ONIG_STOP from match_at()) -I'm thankful to Akinori MUSHA. +and I'm thankful to Akinori MUSHA. Mail Address: K.Kosako diff --git a/ext/mbstring/oniguruma/README.ja b/ext/mbstring/oniguruma/README.ja index 2dee793caed8f..b14822c9e6254 100644 --- a/ext/mbstring/oniguruma/README.ja +++ b/ext/mbstring/oniguruma/README.ja @@ -1,9 +1,8 @@ -README.ja 2007/06/18 +README.ja 2007/05/31 ---- (C) K.Kosako http://www.geocities.jp/kosako3/oniguruma/ -http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/oniguruma/ ֤ɽ饤֥Ǥ롣 Υ饤֥Ĺϡ줾ɽ֥ȤȤ @@ -13,16 +12,20 @@ http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/oniguruma/ ASCII, UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE, EUC-JP, EUC-TW, EUC-KR, EUC-CN, - Shift_JIS, Big5, GB 18030, KOI8-R, KOI8, + Shift_JIS, Big5, GB18030, KOI8-R, CP1251, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10, ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16 -* GB 18030: ݷλ -* KOI8ϥǥեȤΥåȥåפǤϥ饤֥˴ޤޤʤ - (ɬפǤMakefileԽ뤳) +* GB18030: ݷλ +* CP1251: Byte ------------------------------------------------------------ +饤 + + BSD饤󥹤˽ + + 󥹥ȡ : UnixCygwinĶ @@ -63,12 +66,6 @@ http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/oniguruma/ 5. nmake ctest -饤 - - ΥեȥRubyȰ˻Ѥޤۤˤϡ - RubyΥ饤󥹤˽ - ʳξˤϡBSD饤󥹤˽ - ɽ @@ -97,7 +94,7 @@ http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/oniguruma/ GNU libtoolѤƤΤǡץåȥեबͭ饤֥򥵥ݡȤ СѤǤ褦ˤʤäƤ롣 Ū饤֥ȶͭ饤֥ΤɤѤ뤫ꤹˡ¹ԻǤ - ĶˡˤĤƤϡʬĴ٤Ʋ + ĶˡˤĤƤϡʬĴ٤Ʋ Win32ǥƥå󥯥饤֥(onig_s.lib)󥯤ˤϡ @@ -112,7 +109,10 @@ http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/oniguruma/ sample/listcap.c ǽλ sample/posix.c POSIX API sample/sql.c ѥ᥿ʸǽ (SQL-like ѥ) + +ƥȥץ sample/syntax.c PerlJavaASISʸˡΥƥ + sample/crnl.c --enable-crnl-as-line-terminator ƥ ե @@ -149,9 +149,10 @@ http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/oniguruma/ enc/euc_kr.c EUC-KR, EUC-CN 󥳡ǥ enc/sjis.c Shift_JIS 󥳡ǥ enc/big5.c Big5 󥳡ǥ - enc/gb18030.c GB 18030 󥳡ǥ (ݷλ ) + enc/gb18030.c GB18030 󥳡ǥ enc/koi8.c KOI8 󥳡ǥ enc/koi8_r.c KOI8-R 󥳡ǥ + enc/cp1251.c CP1251 󥳡ǥ enc/iso8859_1.c ISO-8859-1 (Latin-1) enc/iso8859_2.c ISO-8859-2 (Latin-2) enc/iso8859_3.c ISO-8859-3 (Latin-3) @@ -180,13 +181,15 @@ http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/oniguruma/ -Ruby 1.8/1.6ܸ첽GNU regexȤAPIΰ㤤 - - + re_compile_fastmap() Ϻ줿 - + re_alloc_pattern() ɲä줿 +ķ + ? case fold flag: Katakana <-> Hiragana + ? ONIG_OPTION_NOTBOS/NOTEOSɲ (\A, \z, \Z) + ?? \X (== \PM\pM*) + ?? ʸˡ ONIG_SYN_CONTEXT_INDEP_ANCHORSμ + ?? ְư߱黻 (match_at()ONIG_STOP֤) -I'm thankful to Akinori MUSHA. +and I'm thankful to Akinori MUSHA. ɥ쥹: K.Kosako diff --git a/ext/mbstring/oniguruma/doc/API b/ext/mbstring/oniguruma/doc/API index 2f66287d499bc..f3b88756bc6a4 100644 --- a/ext/mbstring/oniguruma/doc/API +++ b/ext/mbstring/oniguruma/doc/API @@ -1,4 +1,4 @@ -Oniguruma API Version 4.7.1 2007/07/04 +Oniguruma API Version 5.9.2 2008/02/19 #include @@ -105,10 +105,10 @@ Oniguruma API Version 4.7.1 2007/07/04 ONIG_ENCODING_EUC_KR EUC-KR ONIG_ENCODING_EUC_CN EUC-CN ONIG_ENCODING_SJIS Shift_JIS - ONIG_ENCODING_KOI8 KOI8 ONIG_ENCODING_KOI8_R KOI8-R + ONIG_ENCODING_CP1251 CP1251 ONIG_ENCODING_BIG5 Big5 - ONIG_ENCODING_GB18030 GB 18030 + ONIG_ENCODING_GB18030 GB18030 or any OnigEncodingType data address defined by user. @@ -134,6 +134,18 @@ Oniguruma API Version 4.7.1 2007/07/04 +# int onig_new_without_alloc(regex_t* reg, const UChar* pattern, + const UChar* pattern_end, + OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, + OnigErrorInfo* err_info) + + Create a regex object. + reg object area is not allocated in this function. + + normal return: ONIG_NORMAL + + + # int onig_new_deluxe(regex_t** reg, const UChar* pattern, const UChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo) @@ -153,15 +165,12 @@ Oniguruma API Version 4.7.1 2007/07/04 ci->target_enc: target string character encoding. ci->syntax: address of pattern syntax definition. ci->option: compile time option. - ci->ambig_flag: character matching ambiguity bit flag for + ci->case_fold_flag: character matching case fold bit flag for ONIG_OPTION_IGNORECASE mode. - ONIGENC_AMBIGUOUS_MATCH_NONE: exact - ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE: ignore case for ASCII - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE: ignore case for non-ASCII - ONIGENC_AMBIGUOUS_MATCH_FULL: all ambiguity on - ONIGENC_AMBIGUOUS_MATCH_DEFAULT: (ASCII | NONASCII) - onig_set_default_ambig_flag() + ONIGENC_CASE_FOLD_MIN: minimum + ONIGENC_CASE_FOLD_DEFAULT: minimum + onig_set_default_case_fold_flag() 5 err_info: address for return optional error info. Use this value as 3rd argument of onig_error_code_to_str(). @@ -188,6 +197,14 @@ Oniguruma API Version 4.7.1 2007/07/04 1 reg: regex object. +# void onig_free_body(regex_t* reg) + + Free memory used by regex object. (Except reg oneself.) + + arguments + 1 reg: regex object. + + # int onig_search(regex_t* reg, const UChar* str, const UChar* end, const UChar* start, const UChar* range, OnigRegion* region, OnigOptionType option) @@ -202,8 +219,8 @@ Oniguruma API Version 4.7.1 2007/07/04 3 end: terminate address of target string 4 start: search start address of target string 5 range: search terminate address of target string - in forward search (start <= searched string head < range) - in backward search (range <= searched string head <= start) + in forward search (start <= searched string < range) + in backward search (range <= searched string <= start) 6 region: address for return group match range info (NULL is allowed) 7 option: search time option @@ -335,10 +352,10 @@ Oniguruma API Version 4.7.1 2007/07/04 1 reg: regex object. -# OnigEncoding onig_get_encoding(regex_t* reg) -# OnigOptionType onig_get_options(regex_t* reg) -# OnigAmbigType onig_get_ambig_flag(regex_t* reg) -# OnigSyntaxType* onig_get_syntax(regex_t* reg) +# OnigEncoding onig_get_encoding(regex_t* reg) +# OnigOptionType onig_get_options(regex_t* reg) +# OnigCaseFoldType onig_get_case_fold_flag(regex_t* reg) +# OnigSyntaxType* onig_get_syntax(regex_t* reg) Return a value of the regex object. @@ -518,7 +535,7 @@ Oniguruma API Version 4.7.1 2007/07/04 2 from: source address. -# int onig_set_meta_char(OnigEncoding enc, unsigned int what, +# int onig_set_meta_char(OnigSyntaxType* syntax, unsigned int what, OnigCodePoint code) Set a variable meta character to the code point value. @@ -529,8 +546,8 @@ Oniguruma API Version 4.7.1 2007/07/04 normal return: ONIG_NORMAL arguments - 1 enc: target encoding - 2 what: specifies which meta character it is. + 1 syntax: target syntax + 2 what: specifies which meta character it is. ONIG_META_CHAR_ESCAPE ONIG_META_CHAR_ANYCHAR @@ -542,16 +559,16 @@ Oniguruma API Version 4.7.1 2007/07/04 3 code: meta character or ONIG_INEFFECTIVE_META_CHAR. -# OnigAmbigType onig_get_default_ambig_flag() +# OnigCaseFoldType onig_get_default_case_fold_flag() - Get default ambig flag. + Get default case fold flag. -# int onig_set_default_ambig_flag(OnigAmbigType ambig_flag) +# int onig_set_default_case_fold_flag(OnigCaseFoldType case_fold_flag) - Set default ambig flag. + Set default case fold flag. - 1 ambig_flag: ambiguity flag + 1 case_fold_flag: case fold flag # unsigned int onig_get_match_stack_limit_size(void) @@ -580,6 +597,6 @@ Oniguruma API Version 4.7.1 2007/07/04 # const char* onig_version(void) - Return version string. (ex. "2.2.8") + Return version string. (ex. "5.0.3") // END diff --git a/ext/mbstring/oniguruma/doc/API.ja b/ext/mbstring/oniguruma/doc/API.ja index f2a8bd6f10d0c..f681fa5460891 100644 --- a/ext/mbstring/oniguruma/doc/API.ja +++ b/ext/mbstring/oniguruma/doc/API.ja @@ -1,4 +1,4 @@ -֥󥿡ե Version 4.7.1 2007/07/04 +֥󥿡ե Version 5.9.2 2008/02/19 #include @@ -106,10 +106,10 @@ ONIG_ENCODING_EUC_KR EUC-KR ONIG_ENCODING_EUC_CN EUC-CN ONIG_ENCODING_SJIS Shift_JIS - ONIG_ENCODING_KOI8 KOI8 ONIG_ENCODING_KOI8_R KOI8-R + ONIG_ENCODING_CP1251 CP1251 ONIG_ENCODING_BIG5 Big5 - ONIG_ENCODING_GB18030 GB 18030 + ONIG_ENCODING_GB18030 GB18030 ޤϡ桼OnigEncodingTypeǡΥɥ쥹 @@ -134,6 +134,19 @@ onig_error_code_to_str()λܤΰȤƻѤ + +# int onig_new_without_alloc(regex_t* reg, const UChar* pattern, + const UChar* pattern_end, + OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, + OnigErrorInfo* err_info) + + ɽ֥(regex)롣 + regΰdzƤʤ + + ェλ: ONIG_NORMAL + + + # int onig_new_deluxe(regex_t** reg, const UChar* pattern, const UChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo) @@ -153,15 +166,12 @@ ci->target_enc: оʸʸ󥳡ǥ ci->syntax: ɽѥʸˡ ci->option: ɽѥץ - ci->ambig_flag: ONIG_OPTION_IGNORECASE⡼ɤǤ + ci->case_fold_flag: ONIG_OPTION_IGNORECASE⡼ɤǤ ʸۣޥåӥåȥե饰 - ONIGENC_AMBIGUOUS_MATCH_NONE: ̵ۣ - ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE: ASCIIʸʸ - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE: ASCIIʳʸʸ - ONIGENC_AMBIGUOUS_MATCH_FULL: Ƥۣե饰ͭ - ONIGENC_AMBIGUOUS_MATCH_DEFAULT: (ASCII | NONASCII) - onig_set_default_ambig_flag() + ONIGENC_CASE_FOLD_MIN: Ǿ + ONIGENC_CASE_FOLD_DEFAULT: Ǿ + onig_set_default_case_fold_flag() 5 err_info: 顼֤Υɥ쥹 onig_error_code_to_str()λܤΰȤƻѤ @@ -187,6 +197,14 @@ 1 reg: ɽ֥ +# void onig_free_body(regex_t* reg) + + ɽ֥ȤΥ롣(regȤΰ) + + + 1 reg: ɽ֥ + + # int onig_search(regex_t* reg, const UChar* str, const UChar* end, const UChar* start, const UChar* range, OnigRegion* region, OnigOptionType option) @@ -200,10 +218,10 @@ 1 reg: ɽ֥ 2 str: оʸ 3 end: оʸνüɥ쥹 - 4 start: оʸθƬֳϥɥ쥹 - 5 range: оʸθƬֽüɥ쥹 - õ (start <= õʸƬ < range) - õ (range <= õʸƬ <= start) + 4 start: оʸθƬ֥ɥ쥹 + 5 range: оʸθλ֥ɥ쥹 + õ (start <= õʸ < range) + õ (range <= õʸ <= start) 6 region: ޥåΰ(region) (NULL) 7 option: ץ @@ -340,10 +358,10 @@ 1 reg: ɽ֥ -# OnigEncoding onig_get_encoding(regex_t* reg) -# OnigOptionType onig_get_options(regex_t* reg) -# OnigAmbigType onig_get_ambig_flag(regex_t* reg) -# OnigSyntaxType* onig_get_syntax(regex_t* reg) +# OnigEncoding onig_get_encoding(regex_t* reg) +# OnigOptionType onig_get_options(regex_t* reg) +# OnigCaseFoldType onig_get_case_fold_flag(regex_t* reg) +# OnigSyntaxType* onig_get_syntax(regex_t* reg) ɽ֥ȤФơб֤ͤ @@ -524,7 +542,7 @@ 2 from: -# int onig_set_meta_char(OnigEncoding enc, unsigned int what, +# int onig_set_meta_char(OnigSyntaxType* syntax, unsigned int what, OnigCodePoint code) ᥿ʸꤷɥݥͤ˥åȤ롣 @@ -535,8 +553,8 @@ ェλ: ONIG_NORMAL - 1 enc: оʸ󥳡ǥ - 2 what: ᥿ʸǽλ + 1 syntax: оʸˡ + 2 what: ᥿ʸǽλ ONIG_META_CHAR_ESCAPE ONIG_META_CHAR_ANYCHAR @@ -548,17 +566,17 @@ 3 code: ᥿ʸΥɥݥ ޤ ONIG_INEFFECTIVE_META_CHAR. -# OnigAmbigType onig_get_default_ambig_flag() +# OnigCaseFoldType onig_get_default_case_fold_flag() - ǥեȤۣޥåե饰롣 + ǥեȤcase foldե饰롣 -# int onig_set_default_ambig_flag(OnigAmbigType ambig_flag) +# int onig_set_default_case_fold_flag(OnigCaseFoldType case_fold_flag) - ǥեȤۣޥåե饰򥻥åȤ롣 + ǥեȤcase foldե饰򥻥åȤ롣 - 1 ambig_flag: ۣޥåե饰 + 1 case_fold_flag: case foldե饰 # unsigned int onig_get_match_stack_limit_size(void) @@ -587,6 +605,6 @@ # const char* onig_version(void) - Сʸ֤( "2.2.8") + Сʸ֤( "5.0.3") // END diff --git a/ext/mbstring/oniguruma/doc/FAQ b/ext/mbstring/oniguruma/doc/FAQ index dccf242c8d5b4..46a3e0e08b7d8 100644 --- a/ext/mbstring/oniguruma/doc/FAQ +++ b/ext/mbstring/oniguruma/doc/FAQ @@ -1,4 +1,4 @@ -FAQ 2006/10/30 +FAQ 2006/11/14 1. Lognest match @@ -12,7 +12,7 @@ FAQ 2006/10/30 (A) Oniguruma Layer - Define the macro below at NOT_RUBY case in oniguruma/regint.h. + Define the macro below in oniguruma/regint.h. USE_MULTI_THREAD_SYSTEM THREAD_ATOMIC_START diff --git a/ext/mbstring/oniguruma/doc/FAQ.ja b/ext/mbstring/oniguruma/doc/FAQ.ja index 5582765ee6db1..1d65f9fb62753 100644 --- a/ext/mbstring/oniguruma/doc/FAQ.ja +++ b/ext/mbstring/oniguruma/doc/FAQ.ja @@ -1,4 +1,4 @@ -FAQ 2006/10/30 +FAQ 2007/07/23 1. Ĺޥå @@ -13,7 +13,7 @@ FAQ 2006/10/30 (A) Oniguruma Layer - oniguruma/regint.hNOT_RUBYʬΰʲΥޥ롣 + oniguruma/regint.hΰʲΥޥ롣 USE_MULTI_THREAD_SYSTEM THREAD_ATOMIC_START @@ -35,7 +35,16 @@ FAQ 2006/10/30 "åɥդ˴ؤ­"˽񤤤Ƥ -3. ᡼󥰥ꥹ +3. CR + LF + + DOSβ(CR(0x0c) + LF(0x0a)Ϣ³) + + regenc.hΡʲʬͭˤ롣 + + /* #define USE_CRNL_AS_LINE_TERMINATOR */ + + +4. ᡼󥰥ꥹ ֤˴ؤ᡼󥰥ꥹȤ¸ߤʤ @@ -59,8 +68,7 @@ Oniguruma (A) Onigurumaб -oniguruma/regint.hNOT_RUBYǰϤޤƤʬ -ʲΥޥƺƥѥ뤷Ƥ +oniguruma/regint.hǰʲΥޥƺƥѥ뤷Ƥ USE_MULTI_THREAD_SYSTEM diff --git a/ext/mbstring/oniguruma/doc/RE b/ext/mbstring/oniguruma/doc/RE index 5a2783d167d22..21efe531a46c5 100644 --- a/ext/mbstring/oniguruma/doc/RE +++ b/ext/mbstring/oniguruma/doc/RE @@ -1,4 +1,4 @@ -Oniguruma Regular Expressions Version 4.3.0 2006/08/17 +Oniguruma Regular Expressions Version 5.9.1 2007/09/05 syntax: ONIG_SYNTAX_RUBY (default) @@ -70,6 +70,38 @@ syntax: ONIG_SYNTAX_RUBY (default) \H non hexadecimal digit char + Character Property + + * \p{property-name} + * \p{^property-name} (negative) + * \P{property-name} (negative) + + property-name: + + + works on all encodings + Alnum, Alpha, Blank, Cntrl, Digit, Graph, Lower, + Print, Punct, Space, Upper, XDigit, Word, ASCII, + + + works on EUC_JP, Shift_JIS + Hiragana, Katakana + + + works on UTF8, UTF16, UTF32 + Any, Assigned, C, Cc, Cf, Cn, Co, Cs, L, Ll, Lm, Lo, Lt, Lu, + M, Mc, Me, Mn, N, Nd, Nl, No, P, Pc, Pd, Pe, Pf, Pi, Po, Ps, + S, Sc, Sk, Sm, So, Z, Zl, Zp, Zs, + Arabic, Armenian, Bengali, Bopomofo, Braille, Buginese, + Buhid, Canadian_Aboriginal, Cherokee, Common, Coptic, + Cypriot, Cyrillic, Deseret, Devanagari, Ethiopic, Georgian, + Glagolitic, Gothic, Greek, Gujarati, Gurmukhi, Han, Hangul, + Hanunoo, Hebrew, Hiragana, Inherited, Kannada, Katakana, + Kharoshthi, Khmer, Lao, Latin, Limbu, Linear_B, Malayalam, + Mongolian, Myanmar, New_Tai_Lue, Ogham, Old_Italic, Old_Persian, + Oriya, Osmanya, Runic, Shavian, Sinhala, Syloti_Nagri, Syriac, + Tagalog, Tagbanwa, Tai_Le, Tamil, Telugu, Thaana, Thai, Tibetan, + Tifinagh, Ugaritic, Yi + + + 4. Quantifier greedy @@ -111,11 +143,7 @@ syntax: ONIG_SYNTAX_RUBY (default) \A beginning of string \Z end of string, or before newline at the end \z end of string - \G matching start position (*) - - * Ruby Regexp: - previous end-of-match position - (This specification is not related to this library.) + \G matching start position 6. Character class @@ -135,40 +163,43 @@ syntax: ONIG_SYNTAX_RUBY (default) Not Unicode Case: - alnum alphabet or digit char - alpha alphabet - ascii code value: [0 - 127] - blank \t, \x20 - cntrl - digit 0-9 - graph include all of multibyte encoded characters - lower - print include all of multibyte encoded characters - punct - space \t, \n, \v, \f, \r, \x20 - upper - xdigit 0-9, a-f, A-F + alnum alphabet or digit char + alpha alphabet + ascii code value: [0 - 127] + blank \t, \x20 + cntrl + digit 0-9 + graph include all of multibyte encoded characters + lower + print include all of multibyte encoded characters + punct + space \t, \n, \v, \f, \r, \x20 + upper + xdigit 0-9, a-f, A-F + word alphanumeric, "_" and multibyte characters Unicode Case: - alnum Letter | Mark | Decimal_Number - alpha Letter | Mark - ascii 0000 - 007F - blank Space_Separator | 0009 - cntrl Control | Format | Unassigned | Private_Use | Surrogate - digit Decimal_Number - graph [[:^space:]] && ^Control && ^Unassigned && ^Surrogate - lower Lowercase_Letter - print [[:graph:]] | [[:space:]] - punct Connector_Punctuation | Dash_Punctuation | Close_Punctuation | - Final_Punctuation | Initial_Punctuation | Other_Punctuation | - Open_Punctuation - space Space_Separator | Line_Separator | Paragraph_Separator | - 0009 | 000A | 000B | 000C | 000D | 0085 - upper Uppercase_Letter - xdigit 0030 - 0039 | 0041 - 0046 | 0061 - 0066 - (0-9, a-f, A-F) + alnum Letter | Mark | Decimal_Number + alpha Letter | Mark + ascii 0000 - 007F + blank Space_Separator | 0009 + cntrl Control | Format | Unassigned | Private_Use | Surrogate + digit Decimal_Number + graph [[:^space:]] && ^Control && ^Unassigned && ^Surrogate + lower Lowercase_Letter + print [[:graph:]] | [[:space:]] + punct Connector_Punctuation | Dash_Punctuation | Close_Punctuation | + Final_Punctuation | Initial_Punctuation | Other_Punctuation | + Open_Punctuation + space Space_Separator | Line_Separator | Paragraph_Separator | + 0009 | 000A | 000B | 000C | 000D | 0085 + upper Uppercase_Letter + xdigit 0030 - 0039 | 0041 - 0046 | 0061 - 0066 + (0-9, a-f, A-F) + word Letter | Mark | Decimal_Number | Connector_Punctuation + 7. Extended groups @@ -200,9 +231,9 @@ syntax: ONIG_SYNTAX_RUBY (default) (?>subexp) atomic group don't backtrack in subexp. - (?subexp) define named group - (All characters of the name must be a word character. - And first character must not be a digit or uppper case) + (?subexp), (?'name'subexp) + define named group + (All characters of the name must be a word character.) Not only a name but a number is assigned like a captured group. @@ -215,7 +246,12 @@ syntax: ONIG_SYNTAX_RUBY (default) 8. Back reference \n back reference by group number (n >= 1) + \k back reference by group number (n >= 1) + \k'n' back reference by group number (n >= 1) + \k<-n> back reference by relative group number (n >= 1) + \k'-n' back reference by relative group number (n >= 1) \k back reference by group name + \k'name' back reference by group name In the back reference by the multiplex definition name, a subexp with a large number is referred to preferentially. @@ -227,10 +263,17 @@ syntax: ONIG_SYNTAX_RUBY (default) back reference with nest level - (This function is disabled in Ruby 1.9.) + level: 0, 1, 2, ... - \k n: 0, 1, 2, ... - \k n: 0, 1, 2, ... + \k (n >= 1) + \k (n >= 1) + \k'n+level' (n >= 1) + \k'n-level' (n >= 1) + + \k + \k + \k'name+level' + \k'name-level' Destinate relative nest level from back reference position. @@ -256,7 +299,11 @@ syntax: ONIG_SYNTAX_RUBY (default) 9. Subexp call ("Tanaka Akira special") \g call by group name + \g'name' call by group name \g call by group number (n >= 1) + \g'n' call by group number (n >= 1) + \g<-n> call by relative group number (n >= 1) + \g'-n' call by relative group number (n >= 1) * left-most recursive call is not allowed. ex. (?a|\gb) => error @@ -300,7 +347,6 @@ syntax: ONIG_SYNTAX_RUBY (default) ('g' and 'G' options are argued in ruby-dev ML) - These options are not implemented in Ruby level. ----------------------------- @@ -317,14 +363,13 @@ A-1. Syntax depend options A-2. Original extensions + hexadecimal digit char type \h, \H - + named group (?...) + + named group (?...), (?'name'...) + named backref \k + subexp call \g, \g A-3. Lacked features compare with perl 5.8.0 - + [:word:] + \N{name} + \l,\u,\L,\U, \X, \C + (?{code}) @@ -334,20 +379,10 @@ A-3. Lacked features compare with perl 5.8.0 * \Q...\E This is effective on ONIG_SYNTAX_PERL and ONIG_SYNTAX_JAVA. - * \p{property}, \P{property} - This is effective on ONIG_SYNTAX_PERL and ONIG_SYNTAX_JAVA. - Alnum, Alpha, Blank, Cntrl, Digit, Graph, Lower, - Print, Punct, Space, Upper, XDigit, ASCII are supported. - - Prefix 'Is' of property name is allowed in ONIG_SYNTAX_PERL only. - ex. \p{IsXDigit}. - - Negation operator of property is supported in ONIG_SYNTAX_PERL only. - \p{^...}, \P{^...} +A-4. Differences with Japanized GNU regex(version 0.12) of Ruby 1.8 -A-4. Differences with Japanized GNU regex(version 0.12) of Ruby - + + add character property (\p{property}, \P{property}) + add hexadecimal digit char type (\h, \H) + add look-behind (?<=fixed-char-length-pattern), (?) Ū Τ̲ᤷȤǤθƻԤԤʤʤ - (?) ̾դͼ + (?), (?'name') + ̾դͼ ̾Ƥ() - (̾ñ칽ʸǤʤФʤʤǽʸ - ʸǤäƤϤʤ) + (̾ñ칽ʸǤʤФʤʤ) ̾ǤʤͼƱֹͤƤ롣 ֹ꤬ػߤƤʤ (10. ͼ 򻲾) @@ -215,8 +244,13 @@ 8. - \n ֹ껲 (n >= 1) + \n ֹ껲 (n >= 1) + \k ֹ껲 (n >= 1) + \k'n' ֹ껲 (n >= 1) + \k<-n> ֹ껲 (n >= 1) + \k'-n' ֹ껲 (n >= 1) \k ̾껲 + \k'name' ̾껲 ̾껲Ȥǡ̾ʣμ¿Ƥˤϡ ֹ礭礫ͥŪ˻Ȥ롣 @@ -229,10 +263,17 @@ ͥȥ٥դ - εǽϸߡRuby 1.9Ǥ̵ˤƤ롣 + level: 0, 1, 2, ... + + \k (n >= 1) + \k (n >= 1) + \k'n+level' (n >= 1) + \k'n-level' (n >= 1) - \k n: 0, 1, 2, ... - \k n: 0, 1, 2, ... + \k + \k + \k'name+level' + \k'name-level' Ȥΰ֤ŪʬƽФͥȥ٥ꤷơΥ٥Ǥ ͤ򻲾Ȥ롣 @@ -259,7 +300,11 @@ 9. ʬƽФ ("ůڥ") \g ̾ƽФ - \g ֹƽФ (n >= 1) + \g'name' ̾ƽФ + \g ֹƽФ (n >= 1) + \g'n' ֹƽФ (n >= 1) + \g<-n> ֹƽФ (n >= 1) + \g'-n' ֹƽФ (n >= 1) Ǻ֤ǤκƵƽФ϶ػߤ롣 . (?a|\gb) => error @@ -306,7 +351,6 @@ οΰ̣ϡ ̾դ̵ͤ̾ͤƱ˻ѤɬΤ̤ϾʤǤ Ȥͳͤ줿ΤǤ롣 - ΥץˤĤƤϡRubyǤϸ߼Ƥʤ ----------------------------- @@ -323,14 +367,13 @@ 䵭 2. ȼĥǽ + 16ʿ16ʿ \h, \H - + ̾դͼ (?...) + + ̾դͼ (?...), (?'name'...) + ̾ \k + ʬƽФ \g, \g 䵭 3. Perl 5.8.0Ӥ¸ߤʤǽ - + [:word:] + \N{name} + \l,\u,\L,\U, \X, \C + (?{code}) @@ -340,21 +383,10 @@ * \Q...\E âONIG_SYNTAX_PERLONIG_SYNTAX_JAVAǤͭ - * \p{property}, \P{property} - âONIG_SYNTAX_PERLONIG_SYNTAX_JAVAǤͭ - Alnum, Alpha, Blank, Cntrl, Digit, Graph, Lower, - Print, Punct, Space, Upper, XDigit, ASCIIǤ롣 - - ̾ 'Is'ֻѤ뤳ȤϡONIG_SYNTAX_PERLǤΤ - Ƥ롣 - ex. \p{IsXDigit}. - 黻ҤϡONIG_SYNTAX_PERLǤΤߵƤ롣 - \p{^...}, \P{^...} - - -䵭 4. Rubyܸ첽 GNU regex(version 0.12)Ȥΰ㤤 +䵭 4. Ruby 1.8 ܸ첽 GNU regex(version 0.12)Ȥΰ㤤 + + ʸPropertyǽɲ (\p{property}, \P{Property}) + 16ʿɲ (\h, \H) + ɤߵǽɲ + ߤʷ֤Ҥɲ (?+, *+, ++) @@ -411,14 +443,18 @@ 䵭 6. - + UTF-8ǡХͤŬʲɤΥåϹԤʤäƤʤ + + 󥳡ǥ󥰥ХͤŬʲɤΥåϹԤʤäƤʤ + + : UTF-8 * ƬХȤȤʥХȤʸȤߤʤ /./u =~ "\xa3" * ԴʥХȥ󥹤Υå򤷤ʤ - /\w+/ =~ "a\xf3\x8ec" + /\w+/u =~ "a\xf3\x8ec" Ĵ٤뤳ȤϲǽǤϤ뤬٤ʤΤǹԤʤʤ + ʸȤơΤ褦ʥХꤷưݾڤʤ + diff --git a/ext/mbstring/oniguruma/enc/ascii.c b/ext/mbstring/oniguruma/enc/ascii.c index 64be21d7fff98..c2715f4e0d258 100644 --- a/ext/mbstring/oniguruma/enc/ascii.c +++ b/ext/mbstring/oniguruma/enc/ascii.c @@ -2,7 +2,7 @@ ascii.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2004 K.Kosako + * Copyright (c) 2002-2006 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,23 +43,14 @@ OnigEncodingType OnigEncodingASCII = { "US-ASCII", /* name */ 1, /* max byte length */ 1, /* min byte length */ - ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE, - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - onigenc_ascii_mbc_to_normalize, - onigenc_ascii_is_mbc_ambiguous, - onigenc_ascii_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, + onigenc_ascii_mbc_case_fold, + onigenc_ascii_apply_all_case_fold, + onigenc_ascii_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, ascii_is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, diff --git a/ext/mbstring/oniguruma/enc/big5.c b/ext/mbstring/oniguruma/enc/big5.c index 86792666a4b07..ca1e01b463083 100644 --- a/ext/mbstring/oniguruma/enc/big5.c +++ b/ext/mbstring/oniguruma/enc/big5.c @@ -2,7 +2,7 @@ big5.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2005 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,18 +67,21 @@ big5_code_to_mbc(OnigCodePoint code, UChar *buf) } static int -big5_mbc_to_normalize(OnigAmbigType flag, const UChar** pp, const UChar* end, - UChar* lower) +big5_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end, + UChar* lower) { - return onigenc_mbn_mbc_to_normalize(ONIG_ENCODING_BIG5, flag, - pp, end, lower); + return onigenc_mbn_mbc_case_fold(ONIG_ENCODING_BIG5, flag, + pp, end, lower); } +#if 0 static int -big5_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +big5_is_mbc_ambiguous(OnigCaseFoldType flag, + const UChar** pp, const UChar* end) { return onigenc_mbn_is_mbc_ambiguous(ONIG_ENCODING_BIG5, flag, pp, end); } +#endif static int big5_is_code_ctype(OnigCodePoint code, unsigned int ctype) @@ -125,14 +128,14 @@ big5_left_adjust_char_head(const UChar* start, const UChar* s) } } } - len = enc_len(ONIG_ENCODING_BIG5, p); + len = enclen(ONIG_ENCODING_BIG5, p); if (p + len > s) return (UChar* )p; p += len; return (UChar* )(p + ((s - p) & ~1)); } static int -big5_is_allowed_reverse_match(const UChar* s, const UChar* end) +big5_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED) { const UChar c = *s; @@ -144,23 +147,14 @@ OnigEncodingType OnigEncodingBIG5 = { "Big5", /* name */ 2, /* max enc length */ 1, /* min enc length */ - ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE, - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, big5_mbc_to_code, onigenc_mb2_code_to_mbclen, big5_code_to_mbc, - big5_mbc_to_normalize, - big5_is_mbc_ambiguous, - onigenc_ascii_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, + big5_mbc_case_fold, + onigenc_ascii_apply_all_case_fold, + onigenc_ascii_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, big5_is_code_ctype, onigenc_not_support_get_ctype_code_range, big5_left_adjust_char_head, diff --git a/ext/mbstring/oniguruma/enc/cp1251.c b/ext/mbstring/oniguruma/enc/cp1251.c new file mode 100644 index 0000000000000..63e58d2cd820d --- /dev/null +++ b/ext/mbstring/oniguruma/enc/cp1251.c @@ -0,0 +1,200 @@ +/********************************************************************** + cp1251.c - Oniguruma (regular expression library) +**********************************************************************/ +/*- + * Copyright (c) 2006-2007 Byte + * K.Kosako + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "regenc.h" + +#define ENC_CP1251_TO_LOWER_CASE(c) EncCP1251_ToLowerCaseTable[c] +#define ENC_IS_CP1251_CTYPE(code,ctype) \ + ((EncCP1251_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) + +static const UChar EncCP1251_ToLowerCaseTable[256] = { + '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', + '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', + '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', + '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', + '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', + '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', + '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', + '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', + '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', + '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', + '\220', '\203', '\202', '\203', '\204', '\205', '\206', '\207', + '\210', '\211', '\232', '\213', '\234', '\235', '\236', '\237', + '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', + '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', + '\240', '\242', '\242', '\274', '\244', '\264', '\246', '\247', + '\270', '\251', '\272', '\253', '\254', '\255', '\256', '\277', + '\260', '\261', '\263', '\263', '\264', '\265', '\266', '\267', + '\270', '\271', '\272', '\273', '\274', '\276', '\276', '\277', + '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', + '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377' +}; + +static const unsigned short EncCP1251_CtypeTable[256] = { + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x428c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, + 0x34a2, 0x34a2, 0x01a0, 0x30e2, 0x01a0, 0x01a0, 0x01a0, 0x01a0, + 0x0000, 0x01a0, 0x34a2, 0x01a0, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x30e2, 0x01a0, 0x01a0, 0x01a0, 0x01a0, 0x01a0, 0x01a0, 0x01a0, + 0x0008, 0x0000, 0x30e2, 0x01a0, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x0280, 0x34a2, 0x30e2, 0x34a2, 0x01a0, 0x34a2, 0x01a0, 0x01a0, + 0x34a2, 0x01a0, 0x34a2, 0x01a0, 0x01a0, 0x01a0, 0x01a0, 0x34a2, + 0x01a0, 0x01a0, 0x34a2, 0x30e2, 0x30e2, 0x31e2, 0x01a0, 0x01a0, + 0x30e2, 0x0000, 0x30e2, 0x01a0, 0x30e2, 0x34a2, 0x30e2, 0x30e2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2 +}; + +static int +cp1251_mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) +{ + const UChar* p = *pp; + + *lower = ENC_CP1251_TO_LOWER_CASE(*p); + (*pp)++; + return 1; +} + +static int +cp1251_is_code_ctype(OnigCodePoint code, unsigned int ctype) +{ + if (code < 256) + return ENC_IS_CP1251_CTYPE(code, ctype); + else + return FALSE; +} + +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xb8, 0xa8 }, + + { 0xe0, 0xc0 }, + { 0xe1, 0xc1 }, + { 0xe2, 0xc2 }, + { 0xe3, 0xc3 }, + { 0xe4, 0xc4 }, + { 0xe5, 0xc5 }, + { 0xe6, 0xc6 }, + { 0xe7, 0xc7 }, + { 0xe8, 0xc8 }, + { 0xe9, 0xc9 }, + { 0xea, 0xca }, + { 0xeb, 0xcb }, + { 0xec, 0xcc }, + { 0xed, 0xcd }, + { 0xee, 0xce }, + { 0xef, 0xcf }, + + { 0xf0, 0xd0 }, + { 0xf1, 0xd1 }, + { 0xf2, 0xd2 }, + { 0xf3, 0xd3 }, + { 0xf4, 0xd4 }, + { 0xf5, 0xd5 }, + { 0xf6, 0xd6 }, + { 0xf7, 0xd7 }, + { 0xf8, 0xd8 }, + { 0xf9, 0xd9 }, + { 0xfa, 0xda }, + { 0xfb, 0xdb }, + { 0xfc, 0xdc }, + { 0xfd, 0xdd }, + { 0xfe, 0xde }, + { 0xff, 0xdf } +}; + +static int +cp1251_apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) +{ + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0, + flag, f, arg); +} + +static int +cp1251_get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0, + flag, p, end, items); +} + +OnigEncodingType OnigEncodingCP1251 = { + onigenc_single_byte_mbc_enc_len, + "CP1251", /* name */ + 1, /* max enc length */ + 1, /* min enc length */ + onigenc_is_mbc_newline_0x0a, + onigenc_single_byte_mbc_to_code, + onigenc_single_byte_code_to_mbclen, + onigenc_single_byte_code_to_mbc, + cp1251_mbc_case_fold, + cp1251_apply_all_case_fold, + cp1251_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + cp1251_is_code_ctype, + onigenc_not_support_get_ctype_code_range, + onigenc_single_byte_left_adjust_char_head, + onigenc_always_true_is_allowed_reverse_match +}; diff --git a/ext/mbstring/oniguruma/enc/euc_jp.c b/ext/mbstring/oniguruma/enc/euc_jp.c index 71c81ee9fe833..f605297cc38e3 100644 --- a/ext/mbstring/oniguruma/enc/euc_jp.c +++ b/ext/mbstring/oniguruma/enc/euc_jp.c @@ -2,7 +2,7 @@ euc_jp.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2005 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ -#include "regenc.h" +#include "regint.h" #define eucjp_islead(c) ((UChar )((c) - 0xa1) > 0xfe - 0xa1) @@ -51,18 +51,18 @@ static const int EncLen_EUCJP[] = { }; static int -eucjp_mbc_enc_len(const UChar* p) +mbc_enc_len(const UChar* p) { return EncLen_EUCJP[*p]; } static OnigCodePoint -eucjp_mbc_to_code(const UChar* p, const UChar* end) +mbc_to_code(const UChar* p, const UChar* end) { int c, i, len; OnigCodePoint n; - len = enc_len(ONIG_ENCODING_EUC_JP, p); + len = enclen(ONIG_ENCODING_EUC_JP, p); n = (OnigCodePoint )*p++; if (len == 1) return n; @@ -75,17 +75,18 @@ eucjp_mbc_to_code(const UChar* p, const UChar* end) } static int -eucjp_code_to_mbclen(OnigCodePoint code) +code_to_mbclen(OnigCodePoint code) { if (ONIGENC_IS_CODE_ASCII(code)) return 1; else if ((code & 0xff0000) != 0) return 3; else if ((code & 0xff00) != 0) return 2; - else return 0; + else + return ONIGERR_INVALID_CODE_POINT_VALUE; } #if 0 static int -eucjp_code_to_mbc_first(OnigCodePoint code) +code_to_mbc_first(OnigCodePoint code) { int first; @@ -103,7 +104,7 @@ eucjp_code_to_mbc_first(OnigCodePoint code) #endif static int -eucjp_code_to_mbc(OnigCodePoint code, UChar *buf) +code_to_mbc(OnigCodePoint code, UChar *buf) { UChar *p = buf; @@ -112,66 +113,38 @@ eucjp_code_to_mbc(OnigCodePoint code, UChar *buf) *p++ = (UChar )(code & 0xff); #if 1 - if (enc_len(ONIG_ENCODING_EUC_JP, buf) != (p - buf)) - return ONIGENCERR_INVALID_WIDE_CHAR_VALUE; + if (enclen(ONIG_ENCODING_EUC_JP, buf) != (p - buf)) + return ONIGERR_INVALID_CODE_POINT_VALUE; #endif return p - buf; } static int -eucjp_mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { int len; const UChar* p = *pp; if (ONIGENC_IS_MBC_ASCII(p)) { - if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { - *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); - } - else { - *lower = *p; - } - + *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); (*pp)++; return 1; } else { - len = enc_len(ONIG_ENCODING_EUC_JP, p); - if (lower != p) { - int i; - for (i = 0; i < len; i++) { - *lower++ = *p++; - } + int i; + + len = enclen(ONIG_ENCODING_EUC_JP, p); + for (i = 0; i < len; i++) { + *lower++ = *p++; } (*pp) += len; return len; /* return byte length of converted char to lower */ } } -static int -eucjp_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) -{ - return onigenc_mbn_is_mbc_ambiguous(ONIG_ENCODING_EUC_JP, flag, pp, end); -} - -static int -eucjp_is_code_ctype(OnigCodePoint code, unsigned int ctype) -{ - if (code < 128) - return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype); - else { - if ((ctype & (ONIGENC_CTYPE_WORD | - ONIGENC_CTYPE_GRAPH | ONIGENC_CTYPE_PRINT)) != 0) { - return (eucjp_code_to_mbclen(code) > 1 ? TRUE : FALSE); - } - } - - return FALSE; -} - static UChar* -eucjp_left_adjust_char_head(const UChar* start, const UChar* s) +left_adjust_char_head(const UChar* start, const UChar* s) { /* In this encoding mb-trail bytes doesn't mix with single bytes. @@ -183,14 +156,14 @@ eucjp_left_adjust_char_head(const UChar* start, const UChar* s) p = s; while (!eucjp_islead(*p) && p > start) p--; - len = enc_len(ONIG_ENCODING_EUC_JP, p); + len = enclen(ONIG_ENCODING_EUC_JP, p); if (p + len > s) return (UChar* )p; p += len; return (UChar* )(p + ((s - p) & ~1)); } static int -eucjp_is_allowed_reverse_match(const UChar* s, const UChar* end) +is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED) { const UChar c = *s; if (c <= 0x7e || c == 0x8e || c == 0x8f) @@ -199,30 +172,114 @@ eucjp_is_allowed_reverse_match(const UChar* s, const UChar* end) return FALSE; } + +static int PropertyInited = 0; +static const OnigCodePoint** PropertyList; +static int PropertyListNum; +static int PropertyListSize; +static hash_table_type* PropertyNameTable; + +static const OnigCodePoint CR_Hiragana[] = { + 1, + 0xa4a1, 0xa4f3 +}; /* CR_Hiragana */ + +static const OnigCodePoint CR_Katakana[] = { + 3, + 0xa5a1, 0xa5f6, + 0xaaa6, 0xaaaf, + 0xaab1, 0xaadd +}; /* CR_Katakana */ + +static int +init_property_list(void) +{ + int r; + + PROPERTY_LIST_ADD_PROP("Hiragana", CR_Hiragana); + PROPERTY_LIST_ADD_PROP("Katakana", CR_Katakana); + PropertyInited = 1; + + end: + return r; +} + +static int +property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end) +{ + hash_data_type ctype; + + PROPERTY_LIST_INIT_CHECK; + + if (onig_st_lookup_strend(PropertyNameTable, p, end, &ctype) == 0) { + return onigenc_minimum_property_name_to_ctype(enc, p, end); + } + + return (int )ctype; +} + +static int +is_code_ctype(OnigCodePoint code, unsigned int ctype) +{ + if (ctype <= ONIGENC_MAX_STD_CTYPE) { + if (code < 128) + return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype); + else { + if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) { + return (code_to_mbclen(code) > 1 ? TRUE : FALSE); + } + } + } + else { + PROPERTY_LIST_INIT_CHECK; + + ctype -= (ONIGENC_MAX_STD_CTYPE + 1); + if (ctype >= (unsigned int )PropertyListNum) + return ONIGERR_TYPE_BUG; + + return onig_is_in_code_range((UChar* )PropertyList[ctype], code); + } + + return FALSE; +} + +static int +get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out, + const OnigCodePoint* ranges[]) +{ + if (ctype <= ONIGENC_MAX_STD_CTYPE) { + return ONIG_NO_SUPPORT_CONFIG; + } + else { + *sb_out = 0x80; + + PROPERTY_LIST_INIT_CHECK; + + ctype -= (ONIGENC_MAX_STD_CTYPE + 1); + if (ctype >= (OnigCtype )PropertyListNum) + return ONIGERR_TYPE_BUG; + + *ranges = PropertyList[ctype]; + return 0; + } +} + + OnigEncodingType OnigEncodingEUC_JP = { - eucjp_mbc_enc_len, + mbc_enc_len, "EUC-JP", /* name */ 3, /* max enc length */ 1, /* min enc length */ - ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE, - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, - eucjp_mbc_to_code, - eucjp_code_to_mbclen, - eucjp_code_to_mbc, - eucjp_mbc_to_normalize, - eucjp_is_mbc_ambiguous, - onigenc_ascii_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, - eucjp_is_code_ctype, - onigenc_not_support_get_ctype_code_range, - eucjp_left_adjust_char_head, - eucjp_is_allowed_reverse_match + mbc_to_code, + code_to_mbclen, + code_to_mbc, + mbc_case_fold, + onigenc_ascii_apply_all_case_fold, + onigenc_ascii_get_case_fold_codes_by_str, + property_name_to_ctype, + is_code_ctype, + get_ctype_code_range, + left_adjust_char_head, + is_allowed_reverse_match }; diff --git a/ext/mbstring/oniguruma/enc/euc_kr.c b/ext/mbstring/oniguruma/enc/euc_kr.c index 57bf801536cb1..1beef09001c03 100644 --- a/ext/mbstring/oniguruma/enc/euc_kr.c +++ b/ext/mbstring/oniguruma/enc/euc_kr.c @@ -2,7 +2,7 @@ euc_kr.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2005 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,18 +67,21 @@ euckr_code_to_mbc(OnigCodePoint code, UChar *buf) } static int -euckr_mbc_to_normalize(OnigAmbigType flag, const UChar** pp, const UChar* end, - UChar* lower) +euckr_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end, + UChar* lower) { - return onigenc_mbn_mbc_to_normalize(ONIG_ENCODING_EUC_KR, flag, - pp, end, lower); + return onigenc_mbn_mbc_case_fold(ONIG_ENCODING_EUC_KR, flag, + pp, end, lower); } +#if 0 static int -euckr_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +euckr_is_mbc_ambiguous(OnigCaseFoldType flag, + const UChar** pp, const UChar* end) { return onigenc_mbn_is_mbc_ambiguous(ONIG_ENCODING_EUC_KR, flag, pp, end); } +#endif static int euckr_is_code_ctype(OnigCodePoint code, unsigned int ctype) @@ -101,14 +104,14 @@ euckr_left_adjust_char_head(const UChar* start, const UChar* s) p = s; while (!euckr_islead(*p) && p > start) p--; - len = enc_len(ONIG_ENCODING_EUC_KR, p); + len = enclen(ONIG_ENCODING_EUC_KR, p); if (p + len > s) return (UChar* )p; p += len; return (UChar* )(p + ((s - p) & ~1)); } static int -euckr_is_allowed_reverse_match(const UChar* s, const UChar* end) +euckr_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED) { const UChar c = *s; if (c <= 0x7e) return TRUE; @@ -120,23 +123,14 @@ OnigEncodingType OnigEncodingEUC_KR = { "EUC-KR", /* name */ 2, /* max enc length */ 1, /* min enc length */ - ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE, - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, euckr_mbc_to_code, onigenc_mb2_code_to_mbclen, euckr_code_to_mbc, - euckr_mbc_to_normalize, - euckr_is_mbc_ambiguous, - onigenc_ascii_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, + euckr_mbc_case_fold, + onigenc_ascii_apply_all_case_fold, + onigenc_ascii_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, euckr_is_code_ctype, onigenc_not_support_get_ctype_code_range, euckr_left_adjust_char_head, @@ -149,23 +143,14 @@ OnigEncodingType OnigEncodingEUC_CN = { "EUC-CN", /* name */ 2, /* max enc length */ 1, /* min enc length */ - ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE, - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, euckr_mbc_to_code, onigenc_mb2_code_to_mbclen, euckr_code_to_mbc, - euckr_mbc_to_normalize, - euckr_is_mbc_ambiguous, - onigenc_ascii_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, + euckr_mbc_case_fold, + onigenc_ascii_apply_all_case_fold, + onigenc_ascii_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, euckr_is_code_ctype, onigenc_not_support_get_ctype_code_range, euckr_left_adjust_char_head, diff --git a/ext/mbstring/oniguruma/enc/euc_tw.c b/ext/mbstring/oniguruma/enc/euc_tw.c index 6f396e75e6a58..2ddeb9318af09 100644 --- a/ext/mbstring/oniguruma/enc/euc_tw.c +++ b/ext/mbstring/oniguruma/enc/euc_tw.c @@ -2,7 +2,7 @@ euc_tw.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2005 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,17 +67,11 @@ euctw_code_to_mbc(OnigCodePoint code, UChar *buf) } static int -euctw_mbc_to_normalize(OnigAmbigType flag, const UChar** pp, const UChar* end, - UChar* lower) +euctw_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end, + UChar* lower) { - return onigenc_mbn_mbc_to_normalize(ONIG_ENCODING_EUC_TW, flag, - pp, end, lower); -} - -static int -euctw_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) -{ - return onigenc_mbn_is_mbc_ambiguous(ONIG_ENCODING_EUC_TW, flag, pp, end); + return onigenc_mbn_mbc_case_fold(ONIG_ENCODING_EUC_TW, flag, + pp, end, lower); } static int @@ -86,7 +80,7 @@ euctw_is_code_ctype(OnigCodePoint code, unsigned int ctype) return onigenc_mb4_is_code_ctype(ONIG_ENCODING_EUC_TW, code, ctype); } -#define euctw_islead(c) (((c) < 0xa1 && (c) != 0x8e) || (c) == 0xff) +#define euctw_islead(c) ((UChar )((c) - 0xa1) > 0xfe - 0xa1) static UChar* euctw_left_adjust_char_head(const UChar* start, const UChar* s) @@ -101,14 +95,14 @@ euctw_left_adjust_char_head(const UChar* start, const UChar* s) p = s; while (!euctw_islead(*p) && p > start) p--; - len = enc_len(ONIG_ENCODING_EUC_TW, p); + len = enclen(ONIG_ENCODING_EUC_TW, p); if (p + len > s) return (UChar* )p; p += len; return (UChar* )(p + ((s - p) & ~1)); } static int -euctw_is_allowed_reverse_match(const UChar* s, const UChar* end) +euctw_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED) { const UChar c = *s; if (c <= 0x7e) return TRUE; @@ -120,23 +114,14 @@ OnigEncodingType OnigEncodingEUC_TW = { "EUC-TW", /* name */ 4, /* max enc length */ 1, /* min enc length */ - ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE, - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, euctw_mbc_to_code, onigenc_mb4_code_to_mbclen, euctw_code_to_mbc, - euctw_mbc_to_normalize, - euctw_is_mbc_ambiguous, - onigenc_ascii_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, + euctw_mbc_case_fold, + onigenc_ascii_apply_all_case_fold, + onigenc_ascii_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, euctw_is_code_ctype, onigenc_not_support_get_ctype_code_range, euctw_left_adjust_char_head, diff --git a/ext/mbstring/oniguruma/enc/gb18030.c b/ext/mbstring/oniguruma/enc/gb18030.c index 01995ea094d5e..6bbd109eab814 100644 --- a/ext/mbstring/oniguruma/enc/gb18030.c +++ b/ext/mbstring/oniguruma/enc/gb18030.c @@ -2,8 +2,8 @@ gb18030.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2005 KUBO Takehiro - * K.Kosako + * Copyright (c) 2005-2007 KUBO Takehiro + * K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -88,18 +88,21 @@ gb18030_code_to_mbc(OnigCodePoint code, UChar *buf) } static int -gb18030_mbc_to_normalize(OnigAmbigType flag, const UChar** pp, const UChar* end, - UChar* lower) +gb18030_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end, + UChar* lower) { - return onigenc_mbn_mbc_to_normalize(ONIG_ENCODING_GB18030, flag, - pp, end, lower); + return onigenc_mbn_mbc_case_fold(ONIG_ENCODING_GB18030, flag, + pp, end, lower); } +#if 0 static int -gb18030_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +gb18030_is_mbc_ambiguous(OnigCaseFoldType flag, + const UChar** pp, const UChar* end) { return onigenc_mbn_is_mbc_ambiguous(ONIG_ENCODING_GB18030, flag, pp, end); } +#endif static int gb18030_is_code_ctype(OnigCodePoint code, unsigned int ctype) @@ -467,7 +470,7 @@ gb18030_left_adjust_char_head(const UChar* start, const UChar* s) } static int -gb18030_is_allowed_reverse_match(const UChar* s, const UChar* end) +gb18030_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED) { return GB18030_MAP[*s] == C1 ? TRUE : FALSE; } @@ -477,23 +480,14 @@ OnigEncodingType OnigEncodingGB18030 = { "GB18030", /* name */ 4, /* max enc length */ 1, /* min enc length */ - ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE, - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, gb18030_mbc_to_code, onigenc_mb4_code_to_mbclen, gb18030_code_to_mbc, - gb18030_mbc_to_normalize, - gb18030_is_mbc_ambiguous, - onigenc_ascii_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, + gb18030_mbc_case_fold, + onigenc_ascii_apply_all_case_fold, + onigenc_ascii_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, gb18030_is_code_ctype, onigenc_not_support_get_ctype_code_range, gb18030_left_adjust_char_head, diff --git a/ext/mbstring/oniguruma/enc/iso8859_1.c b/ext/mbstring/oniguruma/enc/iso8859_1.c index 5646f26c10263..174b97f0267d4 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_1.c +++ b/ext/mbstring/oniguruma/enc/iso8859_1.c @@ -2,7 +2,7 @@ iso8859_1.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,90 +30,221 @@ #include "regenc.h" #define ENC_IS_ISO_8859_1_CTYPE(code,ctype) \ - ((EncISO_8859_1_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_1_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const unsigned short EncISO_8859_1_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, - 0x00a0, 0x00a0, 0x10e2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0, - 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x10e2, 0x00a0, 0x01a0, - 0x00a0, 0x10a0, 0x10e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2 + 0x00a0, 0x00a0, 0x30e2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0, + 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x00a0, 0x01a0, + 0x00a0, 0x10a0, 0x30e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2 +}; + +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe } }; static int -iso_8859_1_mbc_to_normalize(OnigAmbigType flag, const UChar** pp, const UChar* end, UChar* lower) +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - const UChar* p = *pp; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, f, arg); +} - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ONIGENC_ISO_8859_1_TO_LOWER_CASE(*p); +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag ARG_UNUSED, + const OnigUChar* p, const OnigUChar* end, + OnigCaseFoldCodeItem items[]) +{ + if (0x41 <= *p && *p <= 0x5a) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = (OnigCodePoint )(*p + 0x20); + if (*p == 0x53 && end > p + 1 + && (*(p+1) == 0x53 || *(p+1) == 0x73)) { /* SS */ + items[1].byte_len = 2; + items[1].code_len = 1; + items[1].code[0] = (OnigCodePoint )0xdf; + return 2; + } + else + return 1; } - else { - *lower = *p; + else if (0x61 <= *p && *p <= 0x7a) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = (OnigCodePoint )(*p - 0x20); + if (*p == 0x73 && end > p + 1 + && (*(p+1) == 0x73 || *(p+1) == 0x53)) { /* ss */ + items[1].byte_len = 2; + items[1].code_len = 1; + items[1].code[0] = (OnigCodePoint )0xdf; + return 2; + } + else + return 1; } - (*pp)++; - return 1; /* return byte length of converted char to lower */ + else if (0xc0 <= *p && *p <= 0xcf) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = (OnigCodePoint )(*p + 0x20); + return 1; + } + else if (0xd0 <= *p && *p <= 0xdf) { + if (*p == 0xdf) { + items[0].byte_len = 1; + items[0].code_len = 2; + items[0].code[0] = (OnigCodePoint )'s'; + items[0].code[1] = (OnigCodePoint )'s'; + + items[1].byte_len = 1; + items[1].code_len = 2; + items[1].code[0] = (OnigCodePoint )'S'; + items[1].code[1] = (OnigCodePoint )'S'; + + items[2].byte_len = 1; + items[2].code_len = 2; + items[2].code[0] = (OnigCodePoint )'s'; + items[2].code[1] = (OnigCodePoint )'S'; + + items[3].byte_len = 1; + items[3].code_len = 2; + items[3].code[0] = (OnigCodePoint )'S'; + items[3].code[1] = (OnigCodePoint )'s'; + + return 4; + } + else if (*p != 0xd7) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = (OnigCodePoint )(*p + 0x20); + return 1; + } + } + else if (0xe0 <= *p && *p <= 0xef) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = (OnigCodePoint )(*p - 0x20); + return 1; + } + else if (0xf0 <= *p && *p <= 0xfe) { + if (*p != 0xf7) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = (OnigCodePoint )(*p - 0x20); + return 1; + } + } + + return 0; } static int -iso_8859_1_is_mbc_ambiguous(OnigAmbigType flag, - const UChar** pp, const UChar* end) +mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, + const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + *lower++ = 's'; + *lower = 's'; + (*pp)++; + return 2; + } + + *lower = ONIGENC_ISO_8859_1_TO_LOWER_CASE(*p); (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_1_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xdf, 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ - if (*p == 0xdf || (*p >= 0xaa && *p <= 0xba)) - return FALSE; - else - return TRUE; - } + return 1; +} + +#if 0 +static int +is_mbc_ambiguous(OnigCaseFoldType flag, + const UChar** pp, const UChar* end) +{ + int v; + const UChar* p = *pp; - return (v != 0 ? TRUE : FALSE); + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + (*pp)++; + return TRUE; } - return FALSE; + + (*pp)++; + v = (EncISO_8859_1_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + /* 0xdf, 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ + if (*p >= 0xaa && *p <= 0xba) + return FALSE; + else + return TRUE; + } + + return (v != 0 ? TRUE : FALSE); } +#endif static int -iso_8859_1_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 256) return ENC_IS_ISO_8859_1_CTYPE(code, ctype); @@ -126,25 +257,15 @@ OnigEncodingType OnigEncodingISO_8859_1 = { "ISO-8859-1", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - iso_8859_1_mbc_to_normalize, - iso_8859_1_is_mbc_ambiguous, - onigenc_iso_8859_1_get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, - iso_8859_1_is_code_ctype, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match diff --git a/ext/mbstring/oniguruma/enc/iso8859_10.c b/ext/mbstring/oniguruma/enc/iso8859_10.c index 8081ef8010f98..e35c19d78f830 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_10.c +++ b/ext/mbstring/oniguruma/enc/iso8859_10.c @@ -2,7 +2,7 @@ iso8859_10.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ #define ENC_ISO_8859_10_TO_LOWER_CASE(c) EncISO_8859_10_ToLowerCaseTable[c] #define ENC_IS_ISO_8859_10_CTYPE(code,ctype) \ - ((EncISO_8859_10_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_10_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncISO_8859_10_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,88 +69,82 @@ static const UChar EncISO_8859_10_ToLowerCaseTable[256] = { }; static const unsigned short EncISO_8859_10_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0284, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x01a0, 0x14a2, 0x14a2, - 0x00a0, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x01a0, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x01a0, 0x10e2, 0x10e2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2 + 0x0284, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x34a2, 0x34a2, + 0x00a0, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x01a0, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x01a0, 0x30e2, 0x30e2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2 }; static int -iso_8859_10_mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_ISO_8859_10_TO_LOWER_CASE(*p); - } - else { - *lower = *p; + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + *lower++ = 's'; + *lower = 's'; + (*pp)++; + return 2; } + + *lower = ENC_ISO_8859_10_TO_LOWER_CASE(*p); (*pp)++; - return 1; /* return byte length of converted char to lower */ + return 1; } +#if 0 static int -iso_8859_10_is_mbc_ambiguous(OnigAmbigType flag, - const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; - (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_10_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xdf is lower case letter, but can't convert. */ - if (*p == 0xdf) - return FALSE; - else - return TRUE; - } + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + (*pp)++; + return TRUE; + } - return (v != 0 ? TRUE : FALSE); + (*pp)++; + v = (EncISO_8859_10_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + return TRUE; } - return FALSE; + + return (v != 0 ? TRUE : FALSE); } +#endif static int -iso_8859_10_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 256) return ENC_IS_ISO_8859_10_CTYPE(code, ctype); @@ -158,116 +152,71 @@ iso_8859_10_is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xa1, 0xb1 }, + { 0xa2, 0xb2 }, + { 0xa3, 0xb3 }, + { 0xa4, 0xb4 }, + { 0xa5, 0xb5 }, + { 0xa6, 0xb6 }, + { 0xa8, 0xb8 }, + { 0xa9, 0xb9 }, + { 0xaa, 0xba }, + { 0xab, 0xbb }, + { 0xac, 0xbc }, + { 0xae, 0xbe }, + { 0xaf, 0xbf }, + + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd7, 0xf7 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe } +}; + static int -iso_8859_10_get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xa1, 0xb1 }, - { 0xa2, 0xb2 }, - { 0xa3, 0xb3 }, - { 0xa4, 0xb4 }, - { 0xa5, 0xb5 }, - { 0xa6, 0xb6 }, - { 0xa8, 0xb8 }, - { 0xa9, 0xb9 }, - { 0xaa, 0xba }, - { 0xab, 0xbb }, - { 0xac, 0xbc }, - { 0xae, 0xbe }, - { 0xaf, 0xbf }, - - { 0xb1, 0xa1 }, - { 0xb2, 0xa2 }, - { 0xb3, 0xa3 }, - { 0xb4, 0xa4 }, - { 0xb5, 0xa5 }, - { 0xb6, 0xa6 }, - { 0xb8, 0xa8 }, - { 0xb9, 0xa9 }, - { 0xba, 0xaa }, - { 0xbb, 0xab }, - { 0xbc, 0xac }, - { 0xbe, 0xae }, - { 0xbf, 0xaf }, - - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd7, 0xf7 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf7, 0xd7 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfd, 0xdd }, - { 0xfe, 0xde } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, p, end, items); } OnigEncodingType OnigEncodingISO_8859_10 = { @@ -275,25 +224,15 @@ OnigEncodingType OnigEncodingISO_8859_10 = { "ISO-8859-10", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - iso_8859_10_mbc_to_normalize, - iso_8859_10_is_mbc_ambiguous, - iso_8859_10_get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, - iso_8859_10_is_code_ctype, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match diff --git a/ext/mbstring/oniguruma/enc/iso8859_11.c b/ext/mbstring/oniguruma/enc/iso8859_11.c index de9bb3b825716..8a460a30475fc 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_11.c +++ b/ext/mbstring/oniguruma/enc/iso8859_11.c @@ -2,7 +2,7 @@ iso8859_11.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2004 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,45 +30,45 @@ #include "regenc.h" #define ENC_IS_ISO_8859_11_CTYPE(code,ctype) \ - ((EncISO_8859_11_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_11_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const unsigned short EncISO_8859_11_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0284, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x0000, 0x0000, 0x0000, 0x0000 + 0x0284, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000 }; static int -iso_8859_11_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 256) return ENC_IS_ISO_8859_11_CTYPE(code, ctype); @@ -81,24 +81,15 @@ OnigEncodingType OnigEncodingISO_8859_11 = { "ISO-8859-11", /* name */ 1, /* max enc length */ 1, /* min enc length */ - ( ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - onigenc_ascii_mbc_to_normalize, - onigenc_ascii_is_mbc_ambiguous, - onigenc_ascii_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, - iso_8859_11_is_code_ctype, + onigenc_ascii_mbc_case_fold, + onigenc_ascii_apply_all_case_fold, + onigenc_ascii_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match diff --git a/ext/mbstring/oniguruma/enc/iso8859_13.c b/ext/mbstring/oniguruma/enc/iso8859_13.c index 69316edfc351b..3670d92ea5560 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_13.c +++ b/ext/mbstring/oniguruma/enc/iso8859_13.c @@ -31,7 +31,7 @@ #define ENC_ISO_8859_13_TO_LOWER_CASE(c) EncISO_8859_13_ToLowerCaseTable[c] #define ENC_IS_ISO_8859_13_CTYPE(code,ctype) \ - ((EncISO_8859_13_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_13_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncISO_8859_13_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,84 +69,83 @@ static const UChar EncISO_8859_13_ToLowerCaseTable[256] = { }; static const unsigned short EncISO_8859_13_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0, - 0x14a2, 0x00a0, 0x14a2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x14a2, - 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x01a0, 0x10e2, 0x00a0, 0x01a0, - 0x10e2, 0x10a0, 0x10e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x10e2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x01a0 + 0x34a2, 0x00a0, 0x34a2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x34a2, + 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x01a0, 0x30e2, 0x00a0, 0x01a0, + 0x30e2, 0x10a0, 0x30e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x30e2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x01a0 }; static int -mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_ISO_8859_13_TO_LOWER_CASE(*p); - } - else { - *lower = *p; + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + *lower++ = 's'; + *lower = 's'; + (*pp)++; + return 2; } + + *lower = ENC_ISO_8859_13_TO_LOWER_CASE(*p); (*pp)++; - return 1; /* return byte length of converted char to lower */ + return 1; } +#if 0 static int -is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; - (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_13_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xdf, 0xb5 are lower case letter, but can't convert. */ - if (*p == 0xdf || *p == 0xb5) - return FALSE; - else - return TRUE; - } + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + (*pp)++; + return TRUE; + } - return (v != 0 ? TRUE : FALSE); + (*pp)++; + v = (EncISO_8859_13_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + /* 0xdf, 0xb5 are lower case letter, but can't convert. */ + if (*p == 0xb5) + return FALSE; + else + return TRUE; } - return FALSE; + + return (v != 0 ? TRUE : FALSE); } +#endif static int is_code_ctype(OnigCodePoint code, unsigned int ctype) @@ -157,85 +156,56 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe } +}; + static int -get_all_pair_ambig_codes(OnigAmbigType flag, const OnigPairAmbigCodes** ccs) +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfd, 0xdd }, - { 0xfe, 0xde } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, p, end, items); } OnigEncodingType OnigEncodingISO_8859_13 = { @@ -243,24 +213,14 @@ OnigEncodingType OnigEncodingISO_8859_13 = { "ISO-8859-13", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - mbc_to_normalize, - is_mbc_ambiguous, - get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, diff --git a/ext/mbstring/oniguruma/enc/iso8859_14.c b/ext/mbstring/oniguruma/enc/iso8859_14.c index 44638cf13a50f..3596d4479aa7f 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_14.c +++ b/ext/mbstring/oniguruma/enc/iso8859_14.c @@ -31,7 +31,7 @@ #define ENC_ISO_8859_14_TO_LOWER_CASE(c) EncISO_8859_14_ToLowerCaseTable[c] #define ENC_IS_ISO_8859_14_CTYPE(code,ctype) \ - ((EncISO_8859_14_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_14_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncISO_8859_14_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,84 +69,80 @@ static const UChar EncISO_8859_14_ToLowerCaseTable[256] = { }; static const unsigned short EncISO_8859_14_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0284, 0x14a2, 0x10e2, 0x00a0, 0x14a2, 0x10e2, 0x14a2, 0x00a0, - 0x14a2, 0x00a0, 0x14a2, 0x10e2, 0x14a2, 0x01a0, 0x00a0, 0x14a2, - 0x14a2, 0x10e2, 0x14a2, 0x10e2, 0x14a2, 0x10e2, 0x00a0, 0x14a2, - 0x10e2, 0x10e2, 0x10e2, 0x14a2, 0x10e2, 0x14a2, 0x10e2, 0x10e2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2 + 0x0284, 0x34a2, 0x30e2, 0x00a0, 0x34a2, 0x30e2, 0x34a2, 0x00a0, + 0x34a2, 0x00a0, 0x34a2, 0x30e2, 0x34a2, 0x01a0, 0x00a0, 0x34a2, + 0x34a2, 0x30e2, 0x34a2, 0x30e2, 0x34a2, 0x30e2, 0x00a0, 0x34a2, + 0x30e2, 0x30e2, 0x30e2, 0x34a2, 0x30e2, 0x34a2, 0x30e2, 0x30e2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2 }; static int -mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_ISO_8859_14_TO_LOWER_CASE(*p); - } - else { - *lower = *p; + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + *lower++ = 's'; + *lower = 's'; + (*pp)++; + return 2; } + + *lower = ENC_ISO_8859_14_TO_LOWER_CASE(*p); (*pp)++; return 1; /* return byte length of converted char to lower */ } +#if 0 static int -is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, + const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; - (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_14_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xdf is lower case letter, but can't convert. */ - if (*p == 0xdf) - return FALSE; - else - return TRUE; - } + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + (*pp)++; + return TRUE; + } - return (v != 0 ? TRUE : FALSE); + (*pp)++; + v = (EncISO_8859_14_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + return TRUE; } - return FALSE; + + return (v != 0 ? TRUE : FALSE); } +#endif static int is_code_ctype(OnigCodePoint code, unsigned int ctype) @@ -157,115 +153,72 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xa1, 0xa2 }, + { 0xa4, 0xa5 }, + { 0xa6, 0xab }, + { 0xa8, 0xb8 }, + { 0xaa, 0xba }, + { 0xac, 0xbc }, + { 0xaf, 0xff }, + + { 0xb0, 0xb1 }, + { 0xb2, 0xb3 }, + { 0xb4, 0xb5 }, + { 0xb7, 0xb9 }, + { 0xbb, 0xbf }, + { 0xbd, 0xbe }, + + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd7, 0xf7 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe } +}; + static int -get_all_pair_ambig_codes(OnigAmbigType flag, const OnigPairAmbigCodes** ccs) +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xa1, 0xa2 }, - { 0xa2, 0xa1 }, - { 0xa4, 0xa5 }, - { 0xa5, 0xa4 }, - { 0xa6, 0xab }, - { 0xa8, 0xb8 }, - { 0xaa, 0xba }, - { 0xab, 0xa6 }, - { 0xac, 0xbc }, - { 0xaf, 0xff }, - - { 0xb0, 0xb1 }, - { 0xb1, 0xb0 }, - { 0xb2, 0xb3 }, - { 0xb3, 0xb2 }, - { 0xb4, 0xb5 }, - { 0xb5, 0xb4 }, - { 0xb7, 0xb9 }, - { 0xb8, 0xa8 }, - { 0xb9, 0xb7 }, - { 0xba, 0xaa }, - { 0xbb, 0xbf }, - { 0xbc, 0xac }, - { 0xbd, 0xbe }, - { 0xbe, 0xbd }, - { 0xbf, 0xbb }, - - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd7, 0xf7 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf7, 0xd7 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfd, 0xdd }, - { 0xfe, 0xde }, - { 0xff, 0xaf } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, p, end, items); } OnigEncodingType OnigEncodingISO_8859_14 = { @@ -273,24 +226,14 @@ OnigEncodingType OnigEncodingISO_8859_14 = { "ISO-8859-14", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - mbc_to_normalize, - is_mbc_ambiguous, - get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, diff --git a/ext/mbstring/oniguruma/enc/iso8859_15.c b/ext/mbstring/oniguruma/enc/iso8859_15.c index f643b895df2d0..08492fb4d9e99 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_15.c +++ b/ext/mbstring/oniguruma/enc/iso8859_15.c @@ -31,7 +31,7 @@ #define ENC_ISO_8859_15_TO_LOWER_CASE(c) EncISO_8859_15_ToLowerCaseTable[c] #define ENC_IS_ISO_8859_15_CTYPE(code,ctype) \ - ((EncISO_8859_15_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_15_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncISO_8859_15_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,84 +69,84 @@ static const UChar EncISO_8859_15_ToLowerCaseTable[256] = { }; static const unsigned short EncISO_8859_15_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x14a2, 0x00a0, - 0x10e2, 0x00a0, 0x10e2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0, - 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x14a2, 0x10e2, 0x00a0, 0x01a0, - 0x10e2, 0x10a0, 0x10e2, 0x01a0, 0x14a2, 0x10e2, 0x14a2, 0x01a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2 + 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x34a2, 0x00a0, + 0x30e2, 0x00a0, 0x30e2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0, + 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x34a2, 0x30e2, 0x00a0, 0x01a0, + 0x30e2, 0x10a0, 0x30e2, 0x01a0, 0x34a2, 0x30e2, 0x34a2, 0x01a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2 }; static int -mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_ISO_8859_15_TO_LOWER_CASE(*p); - } - else { - *lower = *p; + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + *lower++ = 's'; + *lower = 's'; + (*pp)++; + return 2; } + + *lower = ENC_ISO_8859_15_TO_LOWER_CASE(*p); (*pp)++; return 1; /* return byte length of converted char to lower */ } +#if 0 static int -is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, + const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; - (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_15_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xdf etc.. are lower case letter, but can't convert. */ - if (*p == 0xdf || *p == 0xaa || *p == 0xb5 || *p == 0xba) - return FALSE; - else - return TRUE; - } + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + (*pp)++; + return TRUE; + } - return (v != 0 ? TRUE : FALSE); + (*pp)++; + v = (EncISO_8859_15_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + /* 0xdf etc.. are lower case letter, but can't convert. */ + if (*p == 0xaa || *p == 0xb5 || *p == 0xba) + return FALSE; + else + return TRUE; } - return FALSE; + + return (v != 0 ? TRUE : FALSE); } +#endif static int is_code_ctype(OnigCodePoint code, unsigned int ctype) @@ -157,96 +157,62 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xa6, 0xa8 }, + + { 0xb4, 0xb8 }, + { 0xbc, 0xbd }, + { 0xbe, 0xff }, + + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe } +}; + static int -get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xa6, 0xa8 }, - { 0xa8, 0xa6 }, - - { 0xb4, 0xb8 }, - { 0xb8, 0xb4 }, - { 0xbc, 0xbd }, - { 0xbd, 0xbc }, - { 0xbe, 0xff }, - - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfd, 0xdd }, - { 0xfe, 0xde }, - { 0xff, 0xbe } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, p, end, items); } OnigEncodingType OnigEncodingISO_8859_15 = { @@ -254,24 +220,14 @@ OnigEncodingType OnigEncodingISO_8859_15 = { "ISO-8859-15", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - mbc_to_normalize, - is_mbc_ambiguous, - get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, diff --git a/ext/mbstring/oniguruma/enc/iso8859_16.c b/ext/mbstring/oniguruma/enc/iso8859_16.c index 921ae36d9d22a..8b39c58a6b438 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_16.c +++ b/ext/mbstring/oniguruma/enc/iso8859_16.c @@ -31,7 +31,7 @@ #define ENC_ISO_8859_16_TO_LOWER_CASE(c) EncISO_8859_16_ToLowerCaseTable[c] #define ENC_IS_ISO_8859_16_CTYPE(code,ctype) \ - ((EncISO_8859_16_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_16_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncISO_8859_16_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,84 +69,79 @@ static const UChar EncISO_8859_16_ToLowerCaseTable[256] = { }; static const unsigned short EncISO_8859_16_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0284, 0x14a2, 0x10e2, 0x14a2, 0x00a0, 0x01a0, 0x14a2, 0x00a0, - 0x10e2, 0x00a0, 0x14a2, 0x01a0, 0x14a2, 0x01a0, 0x10e2, 0x14a2, - 0x00a0, 0x00a0, 0x14a2, 0x10e2, 0x14a2, 0x01a0, 0x00a0, 0x01a0, - 0x10e2, 0x10e2, 0x10e2, 0x01a0, 0x14a2, 0x10e2, 0x14a2, 0x10e2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2 + 0x0284, 0x34a2, 0x30e2, 0x34a2, 0x00a0, 0x01a0, 0x34a2, 0x00a0, + 0x30e2, 0x00a0, 0x34a2, 0x01a0, 0x34a2, 0x01a0, 0x30e2, 0x34a2, + 0x00a0, 0x00a0, 0x34a2, 0x30e2, 0x34a2, 0x01a0, 0x00a0, 0x01a0, + 0x30e2, 0x30e2, 0x30e2, 0x01a0, 0x34a2, 0x30e2, 0x34a2, 0x30e2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2 }; static int -mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_ISO_8859_16_TO_LOWER_CASE(*p); - } - else { - *lower = *p; + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + *lower++ = 's'; + *lower = 's'; + (*pp)++; + return 2; } + + *lower = ENC_ISO_8859_16_TO_LOWER_CASE(*p); (*pp)++; return 1; /* return byte length of converted char to lower */ } +#if 0 static int -is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; - (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_16_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xdf is lower case letter, but can't convert. */ - if (*p == 0xdf) - return FALSE; - else - return TRUE; - } + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + (*pp)++; + return TRUE; + } - return (v != 0 ? TRUE : FALSE); + (*pp)++; + v = (EncISO_8859_16_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + return TRUE; } - return FALSE; + + return (v != 0 ? TRUE : FALSE); } +#endif static int is_code_ctype(OnigCodePoint code, unsigned int ctype) @@ -157,109 +152,69 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xa1, 0xa2 }, + { 0xa3, 0xb3 }, + { 0xa6, 0xa8 }, + { 0xaa, 0xba }, + { 0xac, 0xae }, + { 0xaf, 0xbf }, + + { 0xb2, 0xb9 }, + { 0xb4, 0xb8 }, + { 0xbc, 0xbd }, + { 0xbe, 0xff }, + + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd7, 0xf7 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe } +}; + static int -get_all_pair_ambig_codes(OnigAmbigType flag, const OnigPairAmbigCodes** ccs) +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xa1, 0xa2 }, - { 0xa2, 0xa1 }, - { 0xa3, 0xb3 }, - { 0xa6, 0xa8 }, - { 0xa8, 0xa6 }, - { 0xaa, 0xba }, - { 0xac, 0xae }, - { 0xae, 0xac }, - { 0xaf, 0xbf }, - - { 0xb2, 0xb9 }, - { 0xb3, 0xa3 }, - { 0xb4, 0xb8 }, - { 0xb8, 0xb4 }, - { 0xb9, 0xb2 }, - { 0xba, 0xaa }, - { 0xbc, 0xbd }, - { 0xbd, 0xbc }, - { 0xbe, 0xff }, - { 0xbf, 0xaf }, - - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd7, 0xf7 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf7, 0xd7 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfd, 0xdd }, - { 0xfe, 0xde }, - { 0xff, 0xbe } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, p, end, items); } OnigEncodingType OnigEncodingISO_8859_16 = { @@ -267,24 +222,14 @@ OnigEncodingType OnigEncodingISO_8859_16 = { "ISO-8859-16", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - mbc_to_normalize, - is_mbc_ambiguous, - get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, diff --git a/ext/mbstring/oniguruma/enc/iso8859_2.c b/ext/mbstring/oniguruma/enc/iso8859_2.c index f8cb3756f2849..80b93ba1ba3e1 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_2.c +++ b/ext/mbstring/oniguruma/enc/iso8859_2.c @@ -2,7 +2,7 @@ iso8859_2.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ #define ENC_ISO_8859_2_TO_LOWER_CASE(c) EncISO_8859_2_ToLowerCaseTable[c] #define ENC_IS_ISO_8859_2_CTYPE(code,ctype) \ - ((EncISO_8859_2_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_2_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncISO_8859_2_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,192 +69,145 @@ static const UChar EncISO_8859_2_ToLowerCaseTable[256] = { }; static const unsigned short EncISO_8859_2_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0284, 0x14a2, 0x00a0, 0x14a2, 0x00a0, 0x14a2, 0x14a2, 0x00a0, - 0x00a0, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x01a0, 0x14a2, 0x14a2, - 0x00a0, 0x10e2, 0x00a0, 0x10e2, 0x00a0, 0x10e2, 0x10e2, 0x00a0, - 0x00a0, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0, 0x10e2, 0x10e2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0 + 0x0284, 0x34a2, 0x00a0, 0x34a2, 0x00a0, 0x34a2, 0x34a2, 0x00a0, + 0x00a0, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x34a2, 0x34a2, + 0x00a0, 0x30e2, 0x00a0, 0x30e2, 0x00a0, 0x30e2, 0x30e2, 0x00a0, + 0x00a0, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, 0x30e2, 0x30e2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0 }; static int -iso_8859_2_mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_ISO_8859_2_TO_LOWER_CASE(*p); - } - else { - *lower = *p; + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + *lower++ = 's'; + *lower = 's'; + (*pp)++; + return 2; } + + *lower = ENC_ISO_8859_2_TO_LOWER_CASE(*p); (*pp)++; return 1; /* return byte length of converted char to lower */ } +#if 0 static int -iso_8859_2_is_mbc_ambiguous(OnigAmbigType flag, - const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; - (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_2_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xdf is lower case letter, but can't convert. */ - if (*p == 0xdf) - return FALSE; - else - return TRUE; - } + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + (*pp)++; + return TRUE; + } - return (v != 0 ? TRUE : FALSE); + (*pp)++; + v = (EncISO_8859_2_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + return TRUE; } - return FALSE; + + return (v != 0 ? TRUE : FALSE); } +#endif + +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xa1, 0xb1 }, + { 0xa3, 0xb3 }, + { 0xa5, 0xb5 }, + { 0xa6, 0xb6 }, + { 0xa9, 0xb9 }, + { 0xaa, 0xba }, + { 0xab, 0xbb }, + { 0xac, 0xbc }, + { 0xae, 0xbe }, + { 0xaf, 0xbf }, + + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe } +}; static int -iso_8859_2_get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xa1, 0xb1 }, - { 0xa3, 0xb3 }, - { 0xa5, 0xb5 }, - { 0xa6, 0xb6 }, - { 0xa9, 0xb9 }, - { 0xaa, 0xba }, - { 0xab, 0xbb }, - { 0xac, 0xbc }, - { 0xae, 0xbe }, - { 0xaf, 0xbf }, - - { 0xb1, 0xa1 }, - { 0xb3, 0xa3 }, - { 0xb5, 0xa5 }, - { 0xb6, 0xa6 }, - { 0xb9, 0xa9 }, - { 0xba, 0xaa }, - { 0xbb, 0xab }, - { 0xbc, 0xac }, - { 0xbe, 0xae }, - { 0xbf, 0xaf }, - - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfd, 0xdd }, - { 0xfe, 0xde } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, p, end, items); } static int -iso_8859_2_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 256) return ENC_IS_ISO_8859_2_CTYPE(code, ctype); @@ -267,25 +220,15 @@ OnigEncodingType OnigEncodingISO_8859_2 = { "ISO-8859-2", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - iso_8859_2_mbc_to_normalize, - iso_8859_2_is_mbc_ambiguous, - iso_8859_2_get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, - iso_8859_2_is_code_ctype, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match diff --git a/ext/mbstring/oniguruma/enc/iso8859_3.c b/ext/mbstring/oniguruma/enc/iso8859_3.c index e62d20de7b14a..fd1168c3816b8 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_3.c +++ b/ext/mbstring/oniguruma/enc/iso8859_3.c @@ -2,7 +2,7 @@ iso8859_3.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ #define ENC_ISO_8859_3_TO_LOWER_CASE(c) EncISO_8859_3_ToLowerCaseTable[c] #define ENC_IS_ISO_8859_3_CTYPE(code,ctype) \ - ((EncISO_8859_3_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_3_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncISO_8859_3_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,88 +69,86 @@ static const UChar EncISO_8859_3_ToLowerCaseTable[256] = { }; static const unsigned short EncISO_8859_3_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0284, 0x14a2, 0x00a0, 0x00a0, 0x00a0, 0x0000, 0x14a2, 0x00a0, - 0x00a0, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x01a0, 0x0000, 0x14a2, - 0x00a0, 0x10e2, 0x10a0, 0x10a0, 0x00a0, 0x10e2, 0x10e2, 0x01a0, - 0x00a0, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x11a0, 0x0000, 0x10e2, - 0x14a2, 0x14a2, 0x14a2, 0x0000, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x0000, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x0000, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x0000, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0 + 0x0284, 0x34a2, 0x00a0, 0x00a0, 0x00a0, 0x0000, 0x34a2, 0x00a0, + 0x00a0, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x0000, 0x34a2, + 0x00a0, 0x30e2, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x30e2, 0x01a0, + 0x00a0, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x11a0, 0x0000, 0x30e2, + 0x34a2, 0x34a2, 0x34a2, 0x0000, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x0000, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x0000, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x0000, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0 }; static int -iso_8859_3_mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, + const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_ISO_8859_3_TO_LOWER_CASE(*p); - } - else { - *lower = *p; + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + *lower++ = 's'; + *lower = 's'; + (*pp)++; + return 2; } + + *lower = ENC_ISO_8859_3_TO_LOWER_CASE(*p); (*pp)++; - return 1; /* return byte length of converted char to lower */ + return 1; } +#if 0 static int -iso_8859_3_is_mbc_ambiguous(OnigAmbigType flag, - const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; - (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_3_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xdf, 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ - if (*p == 0xdf || *p == 0xb5) - return FALSE; - else - return TRUE; - } + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + (*pp)++; + return TRUE; + } - return (v != 0 ? TRUE : FALSE); + (*pp)++; + v = (EncISO_8859_3_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ + if (*p == 0xb5) + return FALSE; + else + return TRUE; } - return FALSE; + + return (v != 0 ? TRUE : FALSE); } +#endif static int -iso_8859_3_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 256) return ENC_IS_ISO_8859_3_CTYPE(code, ctype); @@ -158,97 +156,63 @@ iso_8859_3_is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } -static int -iso_8859_3_get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) -{ - static const OnigPairAmbigCodes cc[] = { - { 0xa1, 0xb1 }, - { 0xa6, 0xb6 }, - { 0xa9, 0xb9 }, - { 0xaa, 0xba }, - { 0xab, 0xbb }, - { 0xac, 0xbc }, - { 0xaf, 0xbf }, - { 0xb1, 0xa1 }, - { 0xb6, 0xa6 }, - { 0xb9, 0xa9 }, - { 0xba, 0xaa }, - { 0xbb, 0xab }, - { 0xbc, 0xac }, - { 0xbf, 0xaf }, - - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xa1, 0xb1 }, + { 0xa6, 0xb6 }, + { 0xa9, 0xb9 }, + { 0xaa, 0xba }, + { 0xab, 0xbb }, + { 0xac, 0xbc }, + { 0xaf, 0xbf }, + + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe } +}; - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfd, 0xdd }, - { 0xfe, 0xde } - }; +static int +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) +{ + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, p, end, items); } OnigEncodingType OnigEncodingISO_8859_3 = { @@ -256,25 +220,15 @@ OnigEncodingType OnigEncodingISO_8859_3 = { "ISO-8859-3", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - iso_8859_3_mbc_to_normalize, - iso_8859_3_is_mbc_ambiguous, - iso_8859_3_get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, - iso_8859_3_is_code_ctype, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match diff --git a/ext/mbstring/oniguruma/enc/iso8859_4.c b/ext/mbstring/oniguruma/enc/iso8859_4.c index dd6bd7dfe3515..c124f5653d7a9 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_4.c +++ b/ext/mbstring/oniguruma/enc/iso8859_4.c @@ -2,7 +2,7 @@ iso8859_4.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ #define ENC_ISO_8859_4_TO_LOWER_CASE(c) EncISO_8859_4_ToLowerCaseTable[c] #define ENC_IS_ISO_8859_4_CTYPE(code,ctype) \ - ((EncISO_8859_4_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_4_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncISO_8859_4_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,88 +69,85 @@ static const UChar EncISO_8859_4_ToLowerCaseTable[256] = { }; static const unsigned short EncISO_8859_4_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0284, 0x14a2, 0x10e2, 0x14a2, 0x00a0, 0x14a2, 0x14a2, 0x00a0, - 0x00a0, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x01a0, 0x14a2, 0x00a0, - 0x00a0, 0x10e2, 0x00a0, 0x10e2, 0x00a0, 0x10e2, 0x10e2, 0x00a0, - 0x00a0, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x14a2, 0x10e2, 0x10e2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0 + 0x0284, 0x34a2, 0x30e2, 0x34a2, 0x00a0, 0x34a2, 0x34a2, 0x00a0, + 0x00a0, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x34a2, 0x00a0, + 0x00a0, 0x30e2, 0x00a0, 0x30e2, 0x00a0, 0x30e2, 0x30e2, 0x00a0, + 0x00a0, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x34a2, 0x30e2, 0x30e2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0 }; static int -iso_8859_4_mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_ISO_8859_4_TO_LOWER_CASE(*p); - } - else { - *lower = *p; + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + *lower++ = 's'; + *lower = 's'; + (*pp)++; + return 2; } + + *lower = ENC_ISO_8859_4_TO_LOWER_CASE(*p); (*pp)++; return 1; /* return byte length of converted char to lower */ } +#if 0 static int -iso_8859_4_is_mbc_ambiguous(OnigAmbigType flag, - const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; - (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_4_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xdf, 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ - if (*p == 0xdf || *p == 0xa2) - return FALSE; - else - return TRUE; - } + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + (*pp)++; + return TRUE; + } - return (v != 0 ? TRUE : FALSE); + (*pp)++; + v = (EncISO_8859_4_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + if (*p == 0xa2) + return FALSE; + else + return TRUE; } - return FALSE; + + return (v != 0 ? TRUE : FALSE); } +#endif static int -iso_8859_4_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 256) return ENC_IS_ISO_8859_4_CTYPE(code, ctype); @@ -158,106 +155,66 @@ iso_8859_4_is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xa1, 0xb1 }, + { 0xa3, 0xb3 }, + { 0xa5, 0xb5 }, + { 0xa6, 0xb6 }, + { 0xa9, 0xb9 }, + { 0xaa, 0xba }, + { 0xab, 0xbb }, + { 0xac, 0xbc }, + { 0xae, 0xbe }, + + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe } +}; + static int -iso_8859_4_get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xa1, 0xb1 }, - { 0xa3, 0xb3 }, - { 0xa5, 0xb5 }, - { 0xa6, 0xb6 }, - { 0xa9, 0xb9 }, - { 0xaa, 0xba }, - { 0xab, 0xbb }, - { 0xac, 0xbc }, - { 0xae, 0xbe }, - - { 0xb1, 0xa1 }, - { 0xb3, 0xa3 }, - { 0xb5, 0xa5 }, - { 0xb6, 0xa6 }, - { 0xb9, 0xa9 }, - { 0xba, 0xaa }, - { 0xbb, 0xab }, - { 0xbc, 0xac }, - { 0xbe, 0xae }, - - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfd, 0xdd }, - { 0xfe, 0xde } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, p, end, items); } OnigEncodingType OnigEncodingISO_8859_4 = { @@ -265,25 +222,15 @@ OnigEncodingType OnigEncodingISO_8859_4 = { "ISO-8859-4", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - iso_8859_4_mbc_to_normalize, - iso_8859_4_is_mbc_ambiguous, - iso_8859_4_get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, - iso_8859_4_is_code_ctype, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match diff --git a/ext/mbstring/oniguruma/enc/iso8859_5.c b/ext/mbstring/oniguruma/enc/iso8859_5.c index 87b7fb8a29de6..1ca67e735f197 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_5.c +++ b/ext/mbstring/oniguruma/enc/iso8859_5.c @@ -2,7 +2,7 @@ iso8859_5.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2005 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ #define ENC_ISO_8859_5_TO_LOWER_CASE(c) EncISO_8859_5_ToLowerCaseTable[c] #define ENC_IS_ISO_8859_5_CTYPE(code,ctype) \ - ((EncISO_8859_5_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_5_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncISO_8859_5_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,80 +69,66 @@ static const UChar EncISO_8859_5_ToLowerCaseTable[256] = { }; static const unsigned short EncISO_8859_5_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0284, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x01a0, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x00a0, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0, 0x10e2, 0x10e2 + 0x0284, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x00a0, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, 0x30e2, 0x30e2 }; static int -iso_8859_5_mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_ISO_8859_5_TO_LOWER_CASE(*p); - } - else { - *lower = *p; - } - + *lower = ENC_ISO_8859_5_TO_LOWER_CASE(*p); (*pp)++; - return 1; /* return byte length of converted char to lower */ + return 1; } +#if 0 static int -iso_8859_5_is_mbc_ambiguous(OnigAmbigType flag, - const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_5_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - return (v != 0 ? TRUE : FALSE); - } - return FALSE; + v = (EncISO_8859_5_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + return (v != 0 ? TRUE : FALSE); } +#endif static int -iso_8859_5_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 256) return ENC_IS_ISO_8859_5_CTYPE(code, ctype); @@ -150,120 +136,74 @@ iso_8859_5_is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xa1, 0xf1 }, + { 0xa2, 0xf2 }, + { 0xa3, 0xf3 }, + { 0xa4, 0xf4 }, + { 0xa5, 0xf5 }, + { 0xa6, 0xf6 }, + { 0xa7, 0xf7 }, + { 0xa8, 0xf8 }, + { 0xa9, 0xf9 }, + { 0xaa, 0xfa }, + { 0xab, 0xfb }, + { 0xac, 0xfc }, + { 0xae, 0xfe }, + { 0xaf, 0xff }, + + { 0xb0, 0xd0 }, + { 0xb1, 0xd1 }, + { 0xb2, 0xd2 }, + { 0xb3, 0xd3 }, + { 0xb4, 0xd4 }, + { 0xb5, 0xd5 }, + { 0xb6, 0xd6 }, + { 0xb7, 0xd7 }, + { 0xb8, 0xd8 }, + { 0xb9, 0xd9 }, + { 0xba, 0xda }, + { 0xbb, 0xdb }, + { 0xbc, 0xdc }, + { 0xbd, 0xdd }, + { 0xbe, 0xde }, + { 0xbf, 0xdf }, + + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef } +}; + static int -iso_8859_5_get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xa1, 0xf1 }, - { 0xa2, 0xf2 }, - { 0xa3, 0xf3 }, - { 0xa4, 0xf4 }, - { 0xa5, 0xf5 }, - { 0xa6, 0xf6 }, - { 0xa7, 0xf7 }, - { 0xa8, 0xf8 }, - { 0xa9, 0xf9 }, - { 0xaa, 0xfa }, - { 0xab, 0xfb }, - { 0xac, 0xfc }, - { 0xae, 0xfe }, - { 0xaf, 0xff }, - - { 0xb0, 0xd0 }, - { 0xb1, 0xd1 }, - { 0xb2, 0xd2 }, - { 0xb3, 0xd3 }, - { 0xb4, 0xd4 }, - { 0xb5, 0xd5 }, - { 0xb6, 0xd6 }, - { 0xb7, 0xd7 }, - { 0xb8, 0xd8 }, - { 0xb9, 0xd9 }, - { 0xba, 0xda }, - { 0xbb, 0xdb }, - { 0xbc, 0xdc }, - { 0xbd, 0xdd }, - { 0xbe, 0xdf }, - { 0xbf, 0xdf }, - - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xb0 }, - { 0xd1, 0xb1 }, - { 0xd2, 0xb2 }, - { 0xd3, 0xb3 }, - { 0xd4, 0xb4 }, - { 0xd5, 0xb5 }, - { 0xd6, 0xb6 }, - { 0xd7, 0xb7 }, - { 0xd8, 0xb8 }, - { 0xd9, 0xb9 }, - { 0xda, 0xba }, - { 0xdb, 0xbb }, - { 0xdc, 0xbc }, - { 0xdd, 0xbd }, - { 0xde, 0xbe }, - { 0xdf, 0xbf }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf1, 0xa1 }, - { 0xf2, 0xa2 }, - { 0xf3, 0xa3 }, - { 0xf4, 0xa4 }, - { 0xf5, 0xa5 }, - { 0xf6, 0xa6 }, - { 0xf7, 0xa7 }, - { 0xf8, 0xa8 }, - { 0xf9, 0xa9 }, - { 0xfa, 0xaa }, - { 0xfb, 0xab }, - { 0xfc, 0xac }, - { 0xfe, 0xae }, - { 0xff, 0xaf } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, + OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0, + flag, p, end, items); } OnigEncodingType OnigEncodingISO_8859_5 = { @@ -271,25 +211,15 @@ OnigEncodingType OnigEncodingISO_8859_5 = { "ISO-8859-5", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - iso_8859_5_mbc_to_normalize, - iso_8859_5_is_mbc_ambiguous, - iso_8859_5_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, - iso_8859_5_is_code_ctype, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match diff --git a/ext/mbstring/oniguruma/enc/iso8859_6.c b/ext/mbstring/oniguruma/enc/iso8859_6.c index fffcd0e7d19d1..ab42eeed3191b 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_6.c +++ b/ext/mbstring/oniguruma/enc/iso8859_6.c @@ -2,7 +2,7 @@ iso8859_6.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2005 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,25 +30,25 @@ #include "regenc.h" #define ENC_IS_ISO_8859_6_CTYPE(code,ctype) \ - ((EncISO_8859_6_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_6_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const unsigned short EncISO_8859_6_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, @@ -57,18 +57,18 @@ static const unsigned short EncISO_8859_6_CtypeTable[256] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x01a0, 0x01a0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x01a0, 0x0000, 0x0000, 0x0000, 0x01a0, - 0x0000, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }; static int -iso_8859_6_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 256) return ENC_IS_ISO_8859_6_CTYPE(code, ctype); @@ -81,24 +81,15 @@ OnigEncodingType OnigEncodingISO_8859_6 = { "ISO-8859-6", /* name */ 1, /* max enc length */ 1, /* min enc length */ - ( ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - onigenc_ascii_mbc_to_normalize, - onigenc_ascii_is_mbc_ambiguous, - onigenc_ascii_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, - iso_8859_6_is_code_ctype, + onigenc_ascii_mbc_case_fold, + onigenc_ascii_apply_all_case_fold, + onigenc_ascii_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match diff --git a/ext/mbstring/oniguruma/enc/iso8859_7.c b/ext/mbstring/oniguruma/enc/iso8859_7.c index e87661d84bb5e..1090064d74383 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_7.c +++ b/ext/mbstring/oniguruma/enc/iso8859_7.c @@ -2,7 +2,7 @@ iso8859_7.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2005 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ #define ENC_ISO_8859_7_TO_LOWER_CASE(c) EncISO_8859_7_ToLowerCaseTable[c] #define ENC_IS_ISO_8859_7_CTYPE(code,ctype) \ - ((EncISO_8859_7_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_7_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncISO_8859_7_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,87 +69,74 @@ static const UChar EncISO_8859_7_ToLowerCaseTable[256] = { }; static const unsigned short EncISO_8859_7_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0284, 0x01a0, 0x01a0, 0x00a0, 0x0000, 0x0000, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x0000, 0x01a0, 0x00a0, 0x01a0, 0x0000, 0x01a0, - 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x00a0, 0x14a2, 0x01a0, - 0x14a2, 0x14a2, 0x14a2, 0x01a0, 0x14a2, 0x10a0, 0x14a2, 0x14a2, - 0x10e2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x0000, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x0000 + 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x00a0, 0x34a2, 0x01a0, + 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x34a2, 0x10a0, 0x34a2, 0x34a2, + 0x30e2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x0000, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x0000 }; static int -iso_8859_7_mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_ISO_8859_7_TO_LOWER_CASE(*p); - } - else { - *lower = *p; - } + *lower = ENC_ISO_8859_7_TO_LOWER_CASE(*p); (*pp)++; - return 1; /* return byte length of converted char to lower */ + return 1; } +#if 0 static int -iso_8859_7_is_mbc_ambiguous(OnigAmbigType flag, - const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, + const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_7_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - if (*p == 0xc0 || *p == 0xe0) - return FALSE; - else - return TRUE; - } - - return (v != 0 ? TRUE : FALSE); + v = (EncISO_8859_7_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + if (*p == 0xc0 || *p == 0xe0) + return FALSE; + else + return TRUE; } - return FALSE; + + return (v != 0 ? TRUE : FALSE); } +#endif static int -iso_8859_7_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 256) return ENC_IS_ISO_8859_7_CTYPE(code, ctype); @@ -157,121 +144,78 @@ iso_8859_7_is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xb6, 0xdc }, + { 0xb8, 0xdd }, + { 0xb9, 0xde }, + { 0xba, 0xdf }, + { 0xbc, 0xfc }, + { 0xbe, 0xfd }, + { 0xbf, 0xfe }, + + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd7, 0xf7 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb } +}; + static int -iso_8859_7_get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xb6, 0xdc }, - { 0xb8, 0xdd }, - { 0xb9, 0xde }, - { 0xba, 0xdf }, - { 0xbc, 0xfc }, - { 0xbe, 0xfd }, - { 0xbf, 0xfe }, - - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd7, 0xf7 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xb6 }, - { 0xdd, 0xb8 }, - { 0xde, 0xb9 }, - { 0xdf, 0xba }, - - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf7, 0xd7 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xbc }, - { 0xfd, 0xbe }, - { 0xfe, 0xbf } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0, + flag, p, end, items); } + OnigEncodingType OnigEncodingISO_8859_7 = { onigenc_single_byte_mbc_enc_len, "ISO-8859-7", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - iso_8859_7_mbc_to_normalize, - iso_8859_7_is_mbc_ambiguous, - iso_8859_7_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, - iso_8859_7_is_code_ctype, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match diff --git a/ext/mbstring/oniguruma/enc/iso8859_8.c b/ext/mbstring/oniguruma/enc/iso8859_8.c index e76966c667f63..fb9846f25f484 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_8.c +++ b/ext/mbstring/oniguruma/enc/iso8859_8.c @@ -2,7 +2,7 @@ iso8859_8.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2004 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,45 +30,45 @@ #include "regenc.h" #define ENC_IS_ISO_8859_8_CTYPE(code,ctype) \ - ((EncISO_8859_8_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_8_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const unsigned short EncISO_8859_8_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0284, 0x0000, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0, - 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x10e2, 0x00a0, 0x01a0, + 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x00a0, 0x01a0, 0x00a0, 0x10a0, 0x00a0, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x01a0, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, 0x10a2, - 0x10a2, 0x10a2, 0x10a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, + 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }; static int -iso_8859_8_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 256) return ENC_IS_ISO_8859_8_CTYPE(code, ctype); @@ -81,24 +81,15 @@ OnigEncodingType OnigEncodingISO_8859_8 = { "ISO-8859-8", /* name */ 1, /* max enc length */ 1, /* min enc length */ - ( ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - onigenc_ascii_mbc_to_normalize, - onigenc_ascii_is_mbc_ambiguous, - onigenc_ascii_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, - iso_8859_8_is_code_ctype, + onigenc_ascii_mbc_case_fold, + onigenc_ascii_apply_all_case_fold, + onigenc_ascii_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match diff --git a/ext/mbstring/oniguruma/enc/iso8859_9.c b/ext/mbstring/oniguruma/enc/iso8859_9.c index 16a30c5f2479d..079d681c21c9d 100644 --- a/ext/mbstring/oniguruma/enc/iso8859_9.c +++ b/ext/mbstring/oniguruma/enc/iso8859_9.c @@ -2,7 +2,7 @@ iso8859_9.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ #define ENC_ISO_8859_9_TO_LOWER_CASE(c) EncISO_8859_9_ToLowerCaseTable[c] #define ENC_IS_ISO_8859_9_CTYPE(code,ctype) \ - ((EncISO_8859_9_CtypeTable[code] & ctype) != 0) + ((EncISO_8859_9_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncISO_8859_9_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,88 +69,86 @@ static const UChar EncISO_8859_9_ToLowerCaseTable[256] = { }; static const unsigned short EncISO_8859_9_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, - 0x00a0, 0x00a0, 0x10e2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0, - 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x10e2, 0x00a0, 0x01a0, - 0x00a0, 0x10a0, 0x10e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2 + 0x00a0, 0x00a0, 0x30e2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0, + 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x00a0, 0x01a0, + 0x00a0, 0x10a0, 0x30e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2 }; static int -iso_8859_9_mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_ISO_8859_9_TO_LOWER_CASE(*p); - } - else { - *lower = *p; + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + *lower++ = 's'; + *lower = 's'; + (*pp)++; + return 2; } + + *lower = ENC_ISO_8859_9_TO_LOWER_CASE(*p); (*pp)++; - return 1; /* return byte length of converted char to lower */ + return 1; } +#if 0 static int -iso_8859_9_is_mbc_ambiguous(OnigAmbigType flag, - const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; - (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncISO_8859_9_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xdf etc.. are lower case letter, but can't convert. */ - if (*p == 0xdf || (*p >= 0xaa && *p <= 0xba)) - return FALSE; - else - return TRUE; - } + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + (*pp)++; + return TRUE; + } - return (v != 0 ? TRUE : FALSE); + (*pp)++; + v = (EncISO_8859_9_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + /* 0xdf etc.. are lower case letter, but can't convert. */ + if (*p >= 0xaa && *p <= 0xba) + return FALSE; + else + return TRUE; } - return FALSE; + + return (v != 0 ? TRUE : FALSE); } +#endif static int -iso_8859_9_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 256) return ENC_IS_ISO_8859_9_CTYPE(code, ctype); @@ -158,86 +156,56 @@ iso_8859_9_is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe } +}; + static int -iso_8859_9_get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) +apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfd, 0xdd }, - { 0xfe, 0xde } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1, + flag, p, end, items); } OnigEncodingType OnigEncodingISO_8859_9 = { @@ -245,25 +213,15 @@ OnigEncodingType OnigEncodingISO_8859_9 = { "ISO-8859-9", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - iso_8859_9_mbc_to_normalize, - iso_8859_9_is_mbc_ambiguous, - iso_8859_9_get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, - iso_8859_9_is_code_ctype, + mbc_case_fold, + apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, + is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match diff --git a/ext/mbstring/oniguruma/enc/koi8.c b/ext/mbstring/oniguruma/enc/koi8.c index d7277e862e978..c6649572f5ae8 100644 --- a/ext/mbstring/oniguruma/enc/koi8.c +++ b/ext/mbstring/oniguruma/enc/koi8.c @@ -2,7 +2,7 @@ koi8.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2004 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ #define ENC_KOI8_TO_LOWER_CASE(c) EncKOI8_ToLowerCaseTable[c] #define ENC_IS_KOI8_CTYPE(code,ctype) \ - ((EncKOI8_CtypeTable[code] & ctype) != 0) + ((EncKOI8_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncKOI8_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,22 +69,22 @@ static const UChar EncKOI8_ToLowerCaseTable[256] = { }; static const unsigned short EncKOI8_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, @@ -93,52 +93,46 @@ static const unsigned short EncKOI8_CtypeTable[256] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2 + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2 }; + static int -koi8_mbc_to_normalize(OnigAmbigType flag, - const OnigUChar** pp, const OnigUChar* end, OnigUChar* lower) +koi8_mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { - const OnigUChar* p = *pp; + const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_KOI8_TO_LOWER_CASE(*p); - } - else { - *lower = *p; - } + *lower = ENC_KOI8_TO_LOWER_CASE(*p); (*pp)++; - return 1; /* return byte length of converted char to lower */ + return 1; } +#if 0 static int koi8_is_mbc_ambiguous(OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end) { const OnigUChar* p = *pp; (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && + if (((flag & ONIGENC_CASE_FOLD_ASCII_CASE) != 0 && ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && + ((flag & ONIGENC_CASE_FOLD_NONASCII_CASE) != 0 && !ONIGENC_IS_MBC_ASCII(p))) { int v = (EncKOI8_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); + (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); return (v != 0 ? TRUE : FALSE); } return FALSE; } - +#endif static int koi8_is_code_ctype(OnigCodePoint code, unsigned int ctype) @@ -149,89 +143,91 @@ koi8_is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd7, 0xf7 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe }, + { 0xdf, 0xff }, + + { 0xe0, 0xc0 }, + { 0xe1, 0xc1 }, + { 0xe2, 0xc2 }, + { 0xe3, 0xc3 }, + { 0xe4, 0xc4 }, + { 0xe5, 0xc5 }, + { 0xe6, 0xc6 }, + { 0xe7, 0xc7 }, + { 0xe8, 0xc8 }, + { 0xe9, 0xc9 }, + { 0xea, 0xca }, + { 0xeb, 0xcb }, + { 0xec, 0xcc }, + { 0xed, 0xcd }, + { 0xee, 0xce }, + { 0xef, 0xcf }, + + { 0xf0, 0xd0 }, + { 0xf1, 0xd1 }, + { 0xf2, 0xd2 }, + { 0xf3, 0xd3 }, + { 0xf4, 0xd4 }, + { 0xf5, 0xd5 }, + { 0xf6, 0xd6 }, + { 0xf7, 0xd7 }, + { 0xf8, 0xd8 }, + { 0xf9, 0xd9 }, + { 0xfa, 0xda }, + { 0xfb, 0xdb }, + { 0xfc, 0xdc }, + { 0xfe, 0xde }, + { 0xff, 0xdf } +}; + static int -koi8_get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) +koi8_apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd7, 0xf7 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, - { 0xdf, 0xff }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf7, 0xd7 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfe, 0xde }, - { 0xff, 0xdf } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +koi8_get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0, + flag, p, end, items); } OnigEncodingType OnigEncodingKOI8 = { @@ -239,24 +235,14 @@ OnigEncodingType OnigEncodingKOI8 = { "KOI8", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - koi8_mbc_to_normalize, - koi8_is_mbc_ambiguous, - koi8_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, + koi8_mbc_case_fold, + koi8_apply_all_case_fold, + koi8_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, koi8_is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, diff --git a/ext/mbstring/oniguruma/enc/koi8_r.c b/ext/mbstring/oniguruma/enc/koi8_r.c index 1010f5ff938e6..364dda15163b7 100644 --- a/ext/mbstring/oniguruma/enc/koi8_r.c +++ b/ext/mbstring/oniguruma/enc/koi8_r.c @@ -2,7 +2,7 @@ koi8_r.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ #define ENC_KOI8_R_TO_LOWER_CASE(c) EncKOI8_R_ToLowerCaseTable[c] #define ENC_IS_KOI8_R_CTYPE(code,ctype) \ - ((EncKOI8_R_CtypeTable[code] & ctype) != 0) + ((EncKOI8_R_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) static const UChar EncKOI8_R_ToLowerCaseTable[256] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', @@ -69,75 +69,63 @@ static const UChar EncKOI8_R_ToLowerCaseTable[256] = { }; static const unsigned short EncKOI8_R_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x0284, 0x00a0, 0x00a0, 0x10a0, 0x01a0, 0x00a0, - 0x00a0, 0x00a0, 0x00a0, 0x10e2, 0x00a0, 0x00a0, 0x00a0, 0x00a0, + 0x00a0, 0x00a0, 0x00a0, 0x30e2, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, - 0x00a0, 0x00a0, 0x00a0, 0x14a2, 0x00a0, 0x00a0, 0x00a0, 0x00a0, + 0x00a0, 0x00a0, 0x00a0, 0x34a2, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2 + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2 }; static int -koi8_r_mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +koi8_r_mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ENC_KOI8_R_TO_LOWER_CASE(*p); - } - else { - *lower = *p; - } + *lower = ENC_KOI8_R_TO_LOWER_CASE(*p); (*pp)++; - return 1; /* return byte length of converted char to lower */ + return 1; } +#if 0 static int -koi8_r_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +koi8_r_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { + int v; const UChar* p = *pp; (*pp)++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - int v = (EncKOI8_R_CtypeTable[*p] & - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - return (v != 0 ? TRUE : FALSE); - } - return FALSE; + v = (EncKOI8_R_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + return (v != 0 ? TRUE : FALSE); } +#endif static int koi8_r_is_code_ctype(OnigCodePoint code, unsigned int ctype) @@ -148,92 +136,60 @@ koi8_r_is_code_ctype(OnigCodePoint code, unsigned int ctype) return FALSE; } +static const OnigPairCaseFoldCodes CaseFoldMap[] = { + { 0xa3, 0xb3 }, + + { 0xc0, 0xe0 }, + { 0xc1, 0xe1 }, + { 0xc2, 0xe2 }, + { 0xc3, 0xe3 }, + { 0xc4, 0xe4 }, + { 0xc5, 0xe5 }, + { 0xc6, 0xe6 }, + { 0xc7, 0xe7 }, + { 0xc8, 0xe8 }, + { 0xc9, 0xe9 }, + { 0xca, 0xea }, + { 0xcb, 0xeb }, + { 0xcc, 0xec }, + { 0xcd, 0xed }, + { 0xce, 0xee }, + { 0xcf, 0xef }, + + { 0xd0, 0xf0 }, + { 0xd1, 0xf1 }, + { 0xd2, 0xf2 }, + { 0xd3, 0xf3 }, + { 0xd4, 0xf4 }, + { 0xd5, 0xf5 }, + { 0xd6, 0xf6 }, + { 0xd7, 0xf7 }, + { 0xd8, 0xf8 }, + { 0xd9, 0xf9 }, + { 0xda, 0xfa }, + { 0xdb, 0xfb }, + { 0xdc, 0xfc }, + { 0xdd, 0xfd }, + { 0xde, 0xfe }, + { 0xdf, 0xff } +}; + static int -koi8_r_get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) +koi8_r_apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigPairAmbigCodes cc[] = { - { 0xa3, 0xb3 }, - { 0xb3, 0xa3 }, - - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd7, 0xf7 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, - { 0xdf, 0xff }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf7, 0xd7 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfe, 0xde }, - { 0xff, 0xdf } - }; + return onigenc_apply_all_case_fold_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0, + flag, f, arg); +} - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return 52; - } - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); - } - else - return 0; +static int +koi8_r_get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_get_case_fold_codes_by_str_with_map( + sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0, + flag, p, end, items); } OnigEncodingType OnigEncodingKOI8_R = { @@ -241,24 +197,14 @@ OnigEncodingType OnigEncodingKOI8_R = { "KOI8-R", /* name */ 1, /* max enc length */ 1, /* min enc length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, onigenc_single_byte_mbc_to_code, onigenc_single_byte_code_to_mbclen, onigenc_single_byte_code_to_mbc, - koi8_r_mbc_to_normalize, - koi8_r_is_mbc_ambiguous, - koi8_r_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, + koi8_r_mbc_case_fold, + koi8_r_apply_all_case_fold, + koi8_r_get_case_fold_codes_by_str, + onigenc_minimum_property_name_to_ctype, koi8_r_is_code_ctype, onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, diff --git a/ext/mbstring/oniguruma/enc/mktable.c b/ext/mbstring/oniguruma/enc/mktable.c index fcf057423cfc5..285216ebdac1f 100644 --- a/ext/mbstring/oniguruma/enc/mktable.c +++ b/ext/mbstring/oniguruma/enc/mktable.c @@ -2,7 +2,7 @@ mktable.c **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,28 +29,32 @@ #include #include +#include + +#define __USE_ISOC99 +#include -#define NOT_RUBY #include "regenc.h" -#define UNICODE_ISO_8859_1 0 -#define ISO_8859_1 1 -#define ISO_8859_2 2 -#define ISO_8859_3 3 -#define ISO_8859_4 4 -#define ISO_8859_5 5 -#define ISO_8859_6 6 -#define ISO_8859_7 7 -#define ISO_8859_8 8 -#define ISO_8859_9 9 -#define ISO_8859_10 10 -#define ISO_8859_11 11 -#define ISO_8859_13 12 -#define ISO_8859_14 13 -#define ISO_8859_15 14 -#define ISO_8859_16 15 -#define KOI8 16 -#define KOI8_R 17 +#define ASCII 0 +#define UNICODE_ISO_8859_1 1 +#define ISO_8859_1 2 +#define ISO_8859_2 3 +#define ISO_8859_3 4 +#define ISO_8859_4 5 +#define ISO_8859_5 6 +#define ISO_8859_6 7 +#define ISO_8859_7 8 +#define ISO_8859_8 9 +#define ISO_8859_9 10 +#define ISO_8859_10 11 +#define ISO_8859_11 12 +#define ISO_8859_13 13 +#define ISO_8859_14 14 +#define ISO_8859_15 15 +#define ISO_8859_16 16 +#define KOI8 17 +#define KOI8_R 18 typedef struct { int num; @@ -58,6 +62,7 @@ typedef struct { } ENC_INFO; static ENC_INFO Info[] = { + { ASCII, "ASCII" }, { UNICODE_ISO_8859_1, "UNICODE_ISO_8859_1" }, { ISO_8859_1, "ISO_8859_1" }, { ISO_8859_2, "ISO_8859_2" }, @@ -81,6 +86,9 @@ static ENC_INFO Info[] = { static int IsAlpha(int enc, int c) { + if (enc == ASCII) + return isalpha(c); + if (c >= 0x41 && c <= 0x5a) return 1; if (c >= 0x61 && c <= 0x7a) return 1; @@ -255,6 +263,9 @@ static int IsAlpha(int enc, int c) static int IsBlank(int enc, int c) { + if (enc == ASCII) + return isblank(c); + if (c == 0x09 || c == 0x20) return 1; switch (enc) { @@ -291,6 +302,9 @@ static int IsBlank(int enc, int c) static int IsCntrl(int enc, int c) { + if (enc == ASCII) + return iscntrl(c); + if (c >= 0x00 && c <= 0x1F) return 1; switch (enc) { @@ -328,7 +342,7 @@ static int IsCntrl(int enc, int c) return 0; } -static int IsDigit(int enc, int c) +static int IsDigit(int enc ARG_UNUSED, int c) { if (c >= 0x30 && c <= 0x39) return 1; return 0; @@ -336,6 +350,9 @@ static int IsDigit(int enc, int c) static int IsGraph(int enc, int c) { + if (enc == ASCII) + return isgraph(c); + if (c >= 0x21 && c <= 0x7e) return 1; switch (enc) { @@ -405,6 +422,9 @@ static int IsGraph(int enc, int c) static int IsLower(int enc, int c) { + if (enc == ASCII) + return islower(c); + if (c >= 0x61 && c <= 0x7a) return 1; switch (enc) { @@ -534,6 +554,9 @@ static int IsLower(int enc, int c) static int IsPrint(int enc, int c) { + if (enc == ASCII) + return isprint(c); + if (c >= 0x20 && c <= 0x7e) return 1; switch (enc) { @@ -609,6 +632,9 @@ static int IsPrint(int enc, int c) static int IsPunct(int enc, int c) { + if (enc == ASCII) + return ispunct(c); + if (enc == UNICODE_ISO_8859_1) { if (c == 0x24 || c == 0x2b || c == 0x5e || c == 0x60 || c == 0x7c || c == 0x7e) return 1; @@ -705,6 +731,9 @@ static int IsPunct(int enc, int c) static int IsSpace(int enc, int c) { + if (enc == ASCII) + return isspace(c); + if (c >= 0x09 && c <= 0x0d) return 1; if (c == 0x20) return 1; @@ -744,6 +773,9 @@ static int IsSpace(int enc, int c) static int IsUpper(int enc, int c) { + if (enc == ASCII) + return isupper(c); + if (c >= 0x41 && c <= 0x5a) return 1; switch (enc) { @@ -868,6 +900,9 @@ static int IsUpper(int enc, int c) static int IsXDigit(int enc, int c) { + if (enc == ASCII) + return isxdigit(c); + if (c >= 0x30 && c <= 0x39) return 1; if (c >= 0x41 && c <= 0x46) return 1; if (c >= 0x61 && c <= 0x66) return 1; @@ -876,6 +911,10 @@ static int IsXDigit(int enc, int c) static int IsWord(int enc, int c) { + if (enc == ASCII) { + return (isalpha(c) || isdigit(c) || c == 0x5f); + } + if (c >= 0x30 && c <= 0x39) return 1; if (c >= 0x41 && c <= 0x5a) return 1; if (c == 0x5f) return 1; @@ -1052,13 +1091,13 @@ static int IsWord(int enc, int c) return 0; } -static int IsAscii(int enc, int c) +static int IsAscii(int enc ARG_UNUSED, int c) { if (c >= 0x00 && c <= 0x7f) return 1; return 0; } -static int IsNewline(int enc, int c) +static int IsNewline(int enc ARG_UNUSED, int c) { if (c == 0x0a) return 1; return 0; @@ -1072,25 +1111,25 @@ static int exec(FILE* fp, ENC_INFO* einfo) enc = einfo->num; - fprintf(fp, "static unsigned short Enc%s_CtypeTable[256] = {\n", + fprintf(fp, "static const unsigned short Enc%s_CtypeTable[256] = {\n", einfo->name); for (c = 0; c < 256; c++) { val = 0; - if (IsNewline(enc, c)) val |= ONIGENC_CTYPE_NEWLINE; - if (IsAlpha (enc, c)) val |= ONIGENC_CTYPE_ALPHA; - if (IsBlank (enc, c)) val |= ONIGENC_CTYPE_BLANK; - if (IsCntrl (enc, c)) val |= ONIGENC_CTYPE_CNTRL; - if (IsDigit (enc, c)) val |= ONIGENC_CTYPE_DIGIT; - if (IsGraph (enc, c)) val |= ONIGENC_CTYPE_GRAPH; - if (IsLower (enc, c)) val |= ONIGENC_CTYPE_LOWER; - if (IsPrint (enc, c)) val |= ONIGENC_CTYPE_PRINT; - if (IsPunct (enc, c)) val |= ONIGENC_CTYPE_PUNCT; - if (IsSpace (enc, c)) val |= ONIGENC_CTYPE_SPACE; - if (IsUpper (enc, c)) val |= ONIGENC_CTYPE_UPPER; - if (IsXDigit(enc, c)) val |= ONIGENC_CTYPE_XDIGIT; - if (IsWord (enc, c)) val |= ONIGENC_CTYPE_WORD; - if (IsAscii (enc, c)) val |= ONIGENC_CTYPE_ASCII; + if (IsNewline(enc, c)) val |= BIT_CTYPE_NEWLINE; + if (IsAlpha (enc, c)) val |= (BIT_CTYPE_ALPHA | BIT_CTYPE_ALNUM); + if (IsBlank (enc, c)) val |= BIT_CTYPE_BLANK; + if (IsCntrl (enc, c)) val |= BIT_CTYPE_CNTRL; + if (IsDigit (enc, c)) val |= (BIT_CTYPE_DIGIT | BIT_CTYPE_ALNUM); + if (IsGraph (enc, c)) val |= BIT_CTYPE_GRAPH; + if (IsLower (enc, c)) val |= BIT_CTYPE_LOWER; + if (IsPrint (enc, c)) val |= BIT_CTYPE_PRINT; + if (IsPunct (enc, c)) val |= BIT_CTYPE_PUNCT; + if (IsSpace (enc, c)) val |= BIT_CTYPE_SPACE; + if (IsUpper (enc, c)) val |= BIT_CTYPE_UPPER; + if (IsXDigit(enc, c)) val |= BIT_CTYPE_XDIGIT; + if (IsWord (enc, c)) val |= BIT_CTYPE_WORD; + if (IsAscii (enc, c)) val |= BIT_CTYPE_ASCII; if (c % NCOL == 0) fputs(" ", fp); fprintf(fp, "0x%04x", val); @@ -1104,12 +1143,20 @@ static int exec(FILE* fp, ENC_INFO* einfo) return 0; } -extern int main(int argc, char* argv[]) +extern int main(int argc ARG_UNUSED, char* argv[] ARG_UNUSED) { int i; FILE* fp = stdout; - for (i = 0; i < sizeof(Info)/sizeof(ENC_INFO); i++) { + setlocale(LC_ALL, "C"); + /* setlocale(LC_ALL, "POSIX"); */ + /* setlocale(LC_ALL, "en_GB.iso88591"); */ + /* setlocale(LC_ALL, "de_BE.iso88591"); */ + /* setlocale(LC_ALL, "fr_FR.iso88591"); */ + + for (i = 0; i < (int )(sizeof(Info)/sizeof(ENC_INFO)); i++) { exec(fp, &Info[i]); } + + return 0; } diff --git a/ext/mbstring/oniguruma/enc/sjis.c b/ext/mbstring/oniguruma/enc/sjis.c index f7d7d52265540..7a54c9fb3a521 100644 --- a/ext/mbstring/oniguruma/enc/sjis.c +++ b/ext/mbstring/oniguruma/enc/sjis.c @@ -2,7 +2,7 @@ sjis.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2005 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ -#include "regenc.h" +#include "regint.h" static const int EncLen_SJIS[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -71,13 +71,13 @@ static const char SJIS_CAN_BE_TRAIL_TABLE[256] = { #define SJIS_ISMB_TRAIL(byte) SJIS_CAN_BE_TRAIL_TABLE[(byte)] static int -sjis_mbc_enc_len(const UChar* p) +mbc_enc_len(const UChar* p) { return EncLen_SJIS[*p]; } static int -sjis_code_to_mbclen(OnigCodePoint code) +code_to_mbclen(OnigCodePoint code) { if (code < 256) { if (EncLen_SJIS[(int )code] == 1) @@ -89,16 +89,16 @@ sjis_code_to_mbclen(OnigCodePoint code) return 2; } else - return 0; + return ONIGERR_INVALID_CODE_POINT_VALUE; } static OnigCodePoint -sjis_mbc_to_code(const UChar* p, const UChar* end) +mbc_to_code(const UChar* p, const UChar* end) { int c, i, len; OnigCodePoint n; - len = enc_len(ONIG_ENCODING_SJIS, p); + len = enclen(ONIG_ENCODING_SJIS, p); c = *p++; n = c; if (len == 1) return n; @@ -112,7 +112,7 @@ sjis_mbc_to_code(const UChar* p, const UChar* end) } static int -sjis_code_to_mbc(OnigCodePoint code, UChar *buf) +code_to_mbc(OnigCodePoint code, UChar *buf) { UChar *p = buf; @@ -120,67 +120,63 @@ sjis_code_to_mbc(OnigCodePoint code, UChar *buf) *p++ = (UChar )(code & 0xff); #if 0 - if (enc_len(ONIG_ENCODING_SJIS, buf) != (p - buf)) - return REGERR_INVALID_WIDE_CHAR_VALUE; + if (enclen(ONIG_ENCODING_SJIS, buf) != (p - buf)) + return REGERR_INVALID_CODE_POINT_VALUE; #endif return p - buf; } static int -sjis_mbc_to_normalize(OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, + const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower) { const UChar* p = *pp; if (ONIGENC_IS_MBC_ASCII(p)) { - if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { - *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); - } - else { - *lower = *p; - } - + *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); (*pp)++; return 1; } else { - int len = enc_len(ONIG_ENCODING_SJIS, p); + int i; + int len = enclen(ONIG_ENCODING_SJIS, p); - if (lower != p) { - int i; - for (i = 0; i < len; i++) { - *lower++ = *p++; - } + for (i = 0; i < len; i++) { + *lower++ = *p++; } (*pp) += len; return len; /* return byte length of converted char to lower */ } } +#if 0 static int -sjis_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, + const UChar** pp, const UChar* end) { return onigenc_mbn_is_mbc_ambiguous(ONIG_ENCODING_SJIS, flag, pp, end); } +#endif +#if 0 static int -sjis_is_code_ctype(OnigCodePoint code, unsigned int ctype) +is_code_ctype(OnigCodePoint code, unsigned int ctype) { if (code < 128) return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype); else { - if ((ctype & (ONIGENC_CTYPE_WORD | - ONIGENC_CTYPE_GRAPH | ONIGENC_CTYPE_PRINT)) != 0) { - return (sjis_code_to_mbclen(code) > 1 ? TRUE : FALSE); + if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) { + return (code_to_mbclen(code) > 1 ? TRUE : FALSE); } } return FALSE; } +#endif static UChar* -sjis_left_adjust_char_head(const UChar* start, const UChar* s) +left_adjust_char_head(const UChar* start, const UChar* s) { const UChar *p; int len; @@ -196,43 +192,127 @@ sjis_left_adjust_char_head(const UChar* start, const UChar* s) } } } - len = enc_len(ONIG_ENCODING_SJIS, p); + len = enclen(ONIG_ENCODING_SJIS, p); if (p + len > s) return (UChar* )p; p += len; return (UChar* )(p + ((s - p) & ~1)); } static int -sjis_is_allowed_reverse_match(const UChar* s, const UChar* end) +is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED) { const UChar c = *s; return (SJIS_ISMB_TRAIL(c) ? FALSE : TRUE); } + +static int PropertyInited = 0; +static const OnigCodePoint** PropertyList; +static int PropertyListNum; +static int PropertyListSize; +static hash_table_type* PropertyNameTable; + +static const OnigCodePoint CR_Hiragana[] = { + 1, + 0x829f, 0x82f1 +}; /* CR_Hiragana */ + +static const OnigCodePoint CR_Katakana[] = { + 4, + 0x00a6, 0x00af, + 0x00b1, 0x00dd, + 0x8340, 0x837e, + 0x8380, 0x8396, +}; /* CR_Katakana */ + +static int +init_property_list(void) +{ + int r; + + PROPERTY_LIST_ADD_PROP("Hiragana", CR_Hiragana); + PROPERTY_LIST_ADD_PROP("Katakana", CR_Katakana); + PropertyInited = 1; + + end: + return r; +} + +static int +property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end) +{ + hash_data_type ctype; + + PROPERTY_LIST_INIT_CHECK; + + if (onig_st_lookup_strend(PropertyNameTable, p, end, &ctype) == 0) { + return onigenc_minimum_property_name_to_ctype(enc, p, end); + } + + return (int )ctype; +} + +static int +is_code_ctype(OnigCodePoint code, unsigned int ctype) +{ + if (ctype <= ONIGENC_MAX_STD_CTYPE) { + if (code < 128) + return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype); + else { + if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) { + return (code_to_mbclen(code) > 1 ? TRUE : FALSE); + } + } + } + else { + PROPERTY_LIST_INIT_CHECK; + + ctype -= (ONIGENC_MAX_STD_CTYPE + 1); + if (ctype >= (unsigned int )PropertyListNum) + return ONIGERR_TYPE_BUG; + + return onig_is_in_code_range((UChar* )PropertyList[ctype], code); + } + + return FALSE; +} + +static int +get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out, + const OnigCodePoint* ranges[]) +{ + if (ctype <= ONIGENC_MAX_STD_CTYPE) { + return ONIG_NO_SUPPORT_CONFIG; + } + else { + *sb_out = 0x80; + + PROPERTY_LIST_INIT_CHECK; + + ctype -= (ONIGENC_MAX_STD_CTYPE + 1); + if (ctype >= (OnigCtype )PropertyListNum) + return ONIGERR_TYPE_BUG; + + *ranges = PropertyList[ctype]; + return 0; + } +} + OnigEncodingType OnigEncodingSJIS = { - sjis_mbc_enc_len, + mbc_enc_len, "Shift_JIS", /* name */ 2, /* max byte length */ 1, /* min byte length */ - ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE, - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, onigenc_is_mbc_newline_0x0a, - sjis_mbc_to_code, - sjis_code_to_mbclen, - sjis_code_to_mbc, - sjis_mbc_to_normalize, - sjis_is_mbc_ambiguous, - onigenc_ascii_get_all_pair_ambig_codes, - onigenc_nothing_get_all_comp_ambig_codes, - sjis_is_code_ctype, - onigenc_not_support_get_ctype_code_range, - sjis_left_adjust_char_head, - sjis_is_allowed_reverse_match + mbc_to_code, + code_to_mbclen, + code_to_mbc, + mbc_case_fold, + onigenc_ascii_apply_all_case_fold, + onigenc_ascii_get_case_fold_codes_by_str, + property_name_to_ctype, + is_code_ctype, + get_ctype_code_range, + left_adjust_char_head, + is_allowed_reverse_match }; diff --git a/ext/mbstring/oniguruma/enc/unicode.c b/ext/mbstring/oniguruma/enc/unicode.c index a8cf539014ca0..af7a86e088203 100644 --- a/ext/mbstring/oniguruma/enc/unicode.c +++ b/ext/mbstring/oniguruma/enc/unicode.c @@ -2,7 +2,7 @@ unicode.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2004 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,51 +27,59 @@ * SUCH DAMAGE. */ -#include "regenc.h" +#include "regint.h" +#define ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(code,ctype) \ + ((EncUNICODE_ISO_8859_1_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) +#if 0 +#define ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(code,cbit) \ + ((EncUNICODE_ISO_8859_1_CtypeTable[code] & (cbit)) != 0) +#endif -const unsigned short OnigEnc_Unicode_ISO_8859_1_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x228c, 0x2289, 0x2288, 0x2288, 0x2288, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, +static const unsigned short EncUNICODE_ISO_8859_1_CtypeTable[256] = { + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x428c, 0x4289, 0x4288, 0x4288, 0x4288, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0288, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, - 0x00a0, 0x00a0, 0x10e2, 0x01a0, 0x00a0, 0x00a8, 0x00a0, 0x00a0, - 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x10e2, 0x00a0, 0x01a0, - 0x00a0, 0x10a0, 0x10e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2 + 0x00a0, 0x00a0, 0x30e2, 0x01a0, 0x00a0, 0x00a8, 0x00a0, 0x00a0, + 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x00a0, 0x01a0, + 0x00a0, 0x10a0, 0x30e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0, + 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, + 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2 }; -static const OnigCodePoint CRAlnum[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 414, -#else - 9, -#endif - 0x0030, 0x0039, +/* 'NEWLINE' */ +static const OnigCodePoint CR_NEWLINE[] = { + 1, + 0x000a, 0x000a +}; /* CR_NEWLINE */ + +/* 'Alpha': [[:Alpha:]] */ +static const OnigCodePoint CR_Alpha[] = { + 418, 0x0041, 0x005a, 0x0061, 0x007a, 0x00aa, 0x00aa, @@ -79,15 +87,12 @@ static const OnigCodePoint CRAlnum[] = { 0x00ba, 0x00ba, 0x00c0, 0x00d6, 0x00d8, 0x00f6, - 0x00f8, 0x0236 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , + 0x00f8, 0x0241, 0x0250, 0x02c1, 0x02c6, 0x02d1, 0x02e0, 0x02e4, 0x02ee, 0x02ee, - 0x0300, 0x0357, - 0x035d, 0x036f, + 0x0300, 0x036f, 0x037a, 0x037a, 0x0386, 0x0386, 0x0388, 0x038a, @@ -95,41 +100,39 @@ static const OnigCodePoint CRAlnum[] = { 0x038e, 0x03a1, 0x03a3, 0x03ce, 0x03d0, 0x03f5, - 0x03f7, 0x03fb, - 0x0400, 0x0481, + 0x03f7, 0x0481, 0x0483, 0x0486, 0x0488, 0x04ce, - 0x04d0, 0x04f5, - 0x04f8, 0x04f9, + 0x04d0, 0x04f9, 0x0500, 0x050f, 0x0531, 0x0556, 0x0559, 0x0559, 0x0561, 0x0587, - 0x0591, 0x05a1, - 0x05a3, 0x05b9, + 0x0591, 0x05b9, 0x05bb, 0x05bd, 0x05bf, 0x05bf, 0x05c1, 0x05c2, - 0x05c4, 0x05c4, + 0x05c4, 0x05c5, + 0x05c7, 0x05c7, 0x05d0, 0x05ea, 0x05f0, 0x05f2, 0x0610, 0x0615, 0x0621, 0x063a, - 0x0640, 0x0658, - 0x0660, 0x0669, + 0x0640, 0x065e, 0x066e, 0x06d3, 0x06d5, 0x06dc, 0x06de, 0x06e8, - 0x06ea, 0x06fc, + 0x06ea, 0x06ef, + 0x06fa, 0x06fc, 0x06ff, 0x06ff, 0x0710, 0x074a, - 0x074d, 0x074f, + 0x074d, 0x076d, 0x0780, 0x07b1, 0x0901, 0x0939, 0x093c, 0x094d, 0x0950, 0x0954, 0x0958, 0x0963, - 0x0966, 0x096f, + 0x097d, 0x097d, 0x0981, 0x0983, 0x0985, 0x098c, 0x098f, 0x0990, @@ -139,11 +142,11 @@ static const OnigCodePoint CRAlnum[] = { 0x09b6, 0x09b9, 0x09bc, 0x09c4, 0x09c7, 0x09c8, - 0x09cb, 0x09cd, + 0x09cb, 0x09ce, 0x09d7, 0x09d7, 0x09dc, 0x09dd, 0x09df, 0x09e3, - 0x09e6, 0x09f1, + 0x09f0, 0x09f1, 0x0a01, 0x0a03, 0x0a05, 0x0a0a, 0x0a0f, 0x0a10, @@ -158,7 +161,7 @@ static const OnigCodePoint CRAlnum[] = { 0x0a4b, 0x0a4d, 0x0a59, 0x0a5c, 0x0a5e, 0x0a5e, - 0x0a66, 0x0a74, + 0x0a70, 0x0a74, 0x0a81, 0x0a83, 0x0a85, 0x0a8d, 0x0a8f, 0x0a91, @@ -171,7 +174,6 @@ static const OnigCodePoint CRAlnum[] = { 0x0acb, 0x0acd, 0x0ad0, 0x0ad0, 0x0ae0, 0x0ae3, - 0x0ae6, 0x0aef, 0x0b01, 0x0b03, 0x0b05, 0x0b0c, 0x0b0f, 0x0b10, @@ -185,7 +187,6 @@ static const OnigCodePoint CRAlnum[] = { 0x0b56, 0x0b57, 0x0b5c, 0x0b5d, 0x0b5f, 0x0b61, - 0x0b66, 0x0b6f, 0x0b71, 0x0b71, 0x0b82, 0x0b83, 0x0b85, 0x0b8a, @@ -196,13 +197,11 @@ static const OnigCodePoint CRAlnum[] = { 0x0b9e, 0x0b9f, 0x0ba3, 0x0ba4, 0x0ba8, 0x0baa, - 0x0bae, 0x0bb5, - 0x0bb7, 0x0bb9, + 0x0bae, 0x0bb9, 0x0bbe, 0x0bc2, 0x0bc6, 0x0bc8, 0x0bca, 0x0bcd, 0x0bd7, 0x0bd7, - 0x0be7, 0x0bef, 0x0c01, 0x0c03, 0x0c05, 0x0c0c, 0x0c0e, 0x0c10, @@ -214,7 +213,6 @@ static const OnigCodePoint CRAlnum[] = { 0x0c4a, 0x0c4d, 0x0c55, 0x0c56, 0x0c60, 0x0c61, - 0x0c66, 0x0c6f, 0x0c82, 0x0c83, 0x0c85, 0x0c8c, 0x0c8e, 0x0c90, @@ -227,7 +225,6 @@ static const OnigCodePoint CRAlnum[] = { 0x0cd5, 0x0cd6, 0x0cde, 0x0cde, 0x0ce0, 0x0ce1, - 0x0ce6, 0x0cef, 0x0d02, 0x0d03, 0x0d05, 0x0d0c, 0x0d0e, 0x0d10, @@ -238,7 +235,6 @@ static const OnigCodePoint CRAlnum[] = { 0x0d4a, 0x0d4d, 0x0d57, 0x0d57, 0x0d60, 0x0d61, - 0x0d66, 0x0d6f, 0x0d82, 0x0d83, 0x0d85, 0x0d96, 0x0d9a, 0x0db1, @@ -252,7 +248,6 @@ static const OnigCodePoint CRAlnum[] = { 0x0df2, 0x0df3, 0x0e01, 0x0e3a, 0x0e40, 0x0e4e, - 0x0e50, 0x0e59, 0x0e81, 0x0e82, 0x0e84, 0x0e84, 0x0e87, 0x0e88, @@ -269,11 +264,9 @@ static const OnigCodePoint CRAlnum[] = { 0x0ec0, 0x0ec4, 0x0ec6, 0x0ec6, 0x0ec8, 0x0ecd, - 0x0ed0, 0x0ed9, 0x0edc, 0x0edd, 0x0f00, 0x0f00, 0x0f18, 0x0f19, - 0x0f20, 0x0f29, 0x0f35, 0x0f35, 0x0f37, 0x0f37, 0x0f39, 0x0f39, @@ -289,39 +282,31 @@ static const OnigCodePoint CRAlnum[] = { 0x1029, 0x102a, 0x102c, 0x1032, 0x1036, 0x1039, - 0x1040, 0x1049, 0x1050, 0x1059, 0x10a0, 0x10c5, - 0x10d0, 0x10f8, + 0x10d0, 0x10fa, + 0x10fc, 0x10fc, 0x1100, 0x1159, 0x115f, 0x11a2, 0x11a8, 0x11f9, - 0x1200, 0x1206, - 0x1208, 0x1246, - 0x1248, 0x1248, + 0x1200, 0x1248, 0x124a, 0x124d, 0x1250, 0x1256, 0x1258, 0x1258, 0x125a, 0x125d, - 0x1260, 0x1286, - 0x1288, 0x1288, + 0x1260, 0x1288, 0x128a, 0x128d, - 0x1290, 0x12ae, - 0x12b0, 0x12b0, + 0x1290, 0x12b0, 0x12b2, 0x12b5, 0x12b8, 0x12be, 0x12c0, 0x12c0, 0x12c2, 0x12c5, - 0x12c8, 0x12ce, - 0x12d0, 0x12d6, - 0x12d8, 0x12ee, - 0x12f0, 0x130e, - 0x1310, 0x1310, + 0x12c8, 0x12d6, + 0x12d8, 0x1310, 0x1312, 0x1315, - 0x1318, 0x131e, - 0x1320, 0x1346, - 0x1348, 0x135a, - 0x1369, 0x1371, + 0x1318, 0x135a, + 0x135f, 0x135f, + 0x1380, 0x138f, 0x13a0, 0x13f4, 0x1401, 0x166c, 0x166f, 0x1676, @@ -338,17 +323,18 @@ static const OnigCodePoint CRAlnum[] = { 0x17b6, 0x17d3, 0x17d7, 0x17d7, 0x17dc, 0x17dd, - 0x17e0, 0x17e9, 0x180b, 0x180d, - 0x1810, 0x1819, 0x1820, 0x1877, 0x1880, 0x18a9, 0x1900, 0x191c, 0x1920, 0x192b, 0x1930, 0x193b, - 0x1946, 0x196d, + 0x1950, 0x196d, 0x1970, 0x1974, - 0x1d00, 0x1d6b, + 0x1980, 0x19a9, + 0x19b0, 0x19c9, + 0x1a00, 0x1a1b, + 0x1d00, 0x1dc3, 0x1e00, 0x1e9b, 0x1ea0, 0x1ef9, 0x1f00, 0x1f15, @@ -372,7 +358,8 @@ static const OnigCodePoint CRAlnum[] = { 0x1ff6, 0x1ffc, 0x2071, 0x2071, 0x207f, 0x207f, - 0x20d0, 0x20ea, + 0x2090, 0x2094, + 0x20d0, 0x20eb, 0x2102, 0x2102, 0x2107, 0x2107, 0x210a, 0x2113, @@ -384,8 +371,23 @@ static const OnigCodePoint CRAlnum[] = { 0x212a, 0x212d, 0x212f, 0x2131, 0x2133, 0x2139, - 0x213d, 0x213f, + 0x213c, 0x213f, 0x2145, 0x2149, + 0x2c00, 0x2c2e, + 0x2c30, 0x2c5e, + 0x2c80, 0x2ce4, + 0x2d00, 0x2d25, + 0x2d30, 0x2d65, + 0x2d6f, 0x2d6f, + 0x2d80, 0x2d96, + 0x2da0, 0x2da6, + 0x2da8, 0x2dae, + 0x2db0, 0x2db6, + 0x2db8, 0x2dbe, + 0x2dc0, 0x2dc6, + 0x2dc8, 0x2dce, + 0x2dd0, 0x2dd6, + 0x2dd8, 0x2dde, 0x3005, 0x3006, 0x302a, 0x302f, 0x3031, 0x3035, @@ -400,11 +402,13 @@ static const OnigCodePoint CRAlnum[] = { 0x31a0, 0x31b7, 0x31f0, 0x31ff, 0x3400, 0x4db5, - 0x4e00, 0x9fa5, + 0x4e00, 0x9fbb, 0xa000, 0xa48c, + 0xa800, 0xa827, 0xac00, 0xd7a3, 0xf900, 0xfa2d, 0xfa30, 0xfa6a, + 0xfa70, 0xfad9, 0xfb00, 0xfb06, 0xfb13, 0xfb17, 0xfb1d, 0xfb28, @@ -422,7 +426,6 @@ static const OnigCodePoint CRAlnum[] = { 0xfe20, 0xfe23, 0xfe70, 0xfe74, 0xfe76, 0xfefc, - 0xff10, 0xff19, 0xff21, 0xff3a, 0xff41, 0xff5a, 0xff66, 0xffbe, @@ -440,19 +443,28 @@ static const OnigCodePoint CRAlnum[] = { 0x10300, 0x1031e, 0x10330, 0x10349, 0x10380, 0x1039d, + 0x103a0, 0x103c3, + 0x103c8, 0x103cf, 0x10400, 0x1049d, - 0x104a0, 0x104a9, 0x10800, 0x10805, 0x10808, 0x10808, 0x1080a, 0x10835, 0x10837, 0x10838, 0x1083c, 0x1083c, 0x1083f, 0x1083f, + 0x10a00, 0x10a03, + 0x10a05, 0x10a06, + 0x10a0c, 0x10a13, + 0x10a15, 0x10a17, + 0x10a19, 0x10a33, + 0x10a38, 0x10a3a, + 0x10a3f, 0x10a3f, 0x1d165, 0x1d169, 0x1d16d, 0x1d172, 0x1d17b, 0x1d182, 0x1d185, 0x1d18b, 0x1d1aa, 0x1d1ad, + 0x1d242, 0x1d244, 0x1d400, 0x1d454, 0x1d456, 0x1d49c, 0x1d49e, 0x1d49f, @@ -471,7 +483,7 @@ static const OnigCodePoint CRAlnum[] = { 0x1d540, 0x1d544, 0x1d546, 0x1d546, 0x1d54a, 0x1d550, - 0x1d552, 0x1d6a3, + 0x1d552, 0x1d6a5, 0x1d6a8, 0x1d6c0, 0x1d6c2, 0x1d6da, 0x1d6dc, 0x1d6fa, @@ -483,76 +495,117 @@ static const OnigCodePoint CRAlnum[] = { 0x1d78a, 0x1d7a8, 0x1d7aa, 0x1d7c2, 0x1d7c4, 0x1d7c9, - 0x1d7ce, 0x1d7ff, 0x20000, 0x2a6d6, 0x2f800, 0x2fa1d, 0xe0100, 0xe01ef -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRAlnum */ +}; /* CR_Alpha */ -static const OnigCodePoint CRAlpha[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 396, -#else - 8, -#endif - 0x0041, 0x005a, - 0x0061, 0x007a, - 0x00aa, 0x00aa, - 0x00b5, 0x00b5, - 0x00ba, 0x00ba, - 0x00c0, 0x00d6, - 0x00d8, 0x00f6, - 0x00f8, 0x0236 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0250, 0x02c1, - 0x02c6, 0x02d1, - 0x02e0, 0x02e4, - 0x02ee, 0x02ee, - 0x0300, 0x0357, - 0x035d, 0x036f, +/* 'Blank': [[:Blank:]] */ +static const OnigCodePoint CR_Blank[] = { + 9, + 0x0009, 0x0009, + 0x0020, 0x0020, + 0x00a0, 0x00a0, + 0x1680, 0x1680, + 0x180e, 0x180e, + 0x2000, 0x200a, + 0x202f, 0x202f, + 0x205f, 0x205f, + 0x3000, 0x3000 +}; /* CR_Blank */ + +/* 'Cntrl': [[:Cntrl:]] */ +static const OnigCodePoint CR_Cntrl[] = { + 19, + 0x0000, 0x001f, + 0x007f, 0x009f, + 0x00ad, 0x00ad, + 0x0600, 0x0603, + 0x06dd, 0x06dd, + 0x070f, 0x070f, + 0x17b4, 0x17b5, + 0x200b, 0x200f, + 0x202a, 0x202e, + 0x2060, 0x2063, + 0x206a, 0x206f, + 0xd800, 0xf8ff, + 0xfeff, 0xfeff, + 0xfff9, 0xfffb, + 0x1d173, 0x1d17a, + 0xe0001, 0xe0001, + 0xe0020, 0xe007f, + 0xf0000, 0xffffd, + 0x100000, 0x10fffd +}; /* CR_Cntrl */ + +/* 'Digit': [[:Digit:]] */ +static const OnigCodePoint CR_Digit[] = { + 23, + 0x0030, 0x0039, + 0x0660, 0x0669, + 0x06f0, 0x06f9, + 0x0966, 0x096f, + 0x09e6, 0x09ef, + 0x0a66, 0x0a6f, + 0x0ae6, 0x0aef, + 0x0b66, 0x0b6f, + 0x0be6, 0x0bef, + 0x0c66, 0x0c6f, + 0x0ce6, 0x0cef, + 0x0d66, 0x0d6f, + 0x0e50, 0x0e59, + 0x0ed0, 0x0ed9, + 0x0f20, 0x0f29, + 0x1040, 0x1049, + 0x17e0, 0x17e9, + 0x1810, 0x1819, + 0x1946, 0x194f, + 0x19d0, 0x19d9, + 0xff10, 0xff19, + 0x104a0, 0x104a9, + 0x1d7ce, 0x1d7ff +}; /* CR_Digit */ + +/* 'Graph': [[:Graph:]] */ +static const OnigCodePoint CR_Graph[] = { + 424, + 0x0021, 0x007e, + 0x00a1, 0x0241, + 0x0250, 0x036f, + 0x0374, 0x0375, 0x037a, 0x037a, - 0x0386, 0x0386, - 0x0388, 0x038a, + 0x037e, 0x037e, + 0x0384, 0x038a, 0x038c, 0x038c, 0x038e, 0x03a1, 0x03a3, 0x03ce, - 0x03d0, 0x03f5, - 0x03f7, 0x03fb, - 0x0400, 0x0481, - 0x0483, 0x0486, + 0x03d0, 0x0486, 0x0488, 0x04ce, - 0x04d0, 0x04f5, - 0x04f8, 0x04f9, + 0x04d0, 0x04f9, 0x0500, 0x050f, 0x0531, 0x0556, - 0x0559, 0x0559, + 0x0559, 0x055f, 0x0561, 0x0587, - 0x0591, 0x05a1, - 0x05a3, 0x05b9, - 0x05bb, 0x05bd, - 0x05bf, 0x05bf, - 0x05c1, 0x05c2, - 0x05c4, 0x05c4, + 0x0589, 0x058a, + 0x0591, 0x05b9, + 0x05bb, 0x05c7, 0x05d0, 0x05ea, - 0x05f0, 0x05f2, - 0x0610, 0x0615, + 0x05f0, 0x05f4, + 0x0600, 0x0603, + 0x060b, 0x0615, + 0x061b, 0x061b, + 0x061e, 0x061f, 0x0621, 0x063a, - 0x0640, 0x0658, - 0x066e, 0x06d3, - 0x06d5, 0x06dc, - 0x06de, 0x06e8, - 0x06ea, 0x06ef, - 0x06fa, 0x06fc, - 0x06ff, 0x06ff, - 0x0710, 0x074a, - 0x074d, 0x074f, + 0x0640, 0x065e, + 0x0660, 0x070d, + 0x070f, 0x074a, + 0x074d, 0x076d, 0x0780, 0x07b1, 0x0901, 0x0939, 0x093c, 0x094d, 0x0950, 0x0954, - 0x0958, 0x0963, + 0x0958, 0x0970, + 0x097d, 0x097d, 0x0981, 0x0983, 0x0985, 0x098c, 0x098f, 0x0990, @@ -562,11 +615,11 @@ static const OnigCodePoint CRAlpha[] = { 0x09b6, 0x09b9, 0x09bc, 0x09c4, 0x09c7, 0x09c8, - 0x09cb, 0x09cd, + 0x09cb, 0x09ce, 0x09d7, 0x09d7, 0x09dc, 0x09dd, 0x09df, 0x09e3, - 0x09f0, 0x09f1, + 0x09e6, 0x09fa, 0x0a01, 0x0a03, 0x0a05, 0x0a0a, 0x0a0f, 0x0a10, @@ -581,7 +634,7 @@ static const OnigCodePoint CRAlpha[] = { 0x0a4b, 0x0a4d, 0x0a59, 0x0a5c, 0x0a5e, 0x0a5e, - 0x0a70, 0x0a74, + 0x0a66, 0x0a74, 0x0a81, 0x0a83, 0x0a85, 0x0a8d, 0x0a8f, 0x0a91, @@ -594,6 +647,8 @@ static const OnigCodePoint CRAlpha[] = { 0x0acb, 0x0acd, 0x0ad0, 0x0ad0, 0x0ae0, 0x0ae3, + 0x0ae6, 0x0aef, + 0x0af1, 0x0af1, 0x0b01, 0x0b03, 0x0b05, 0x0b0c, 0x0b0f, 0x0b10, @@ -607,7 +662,7 @@ static const OnigCodePoint CRAlpha[] = { 0x0b56, 0x0b57, 0x0b5c, 0x0b5d, 0x0b5f, 0x0b61, - 0x0b71, 0x0b71, + 0x0b66, 0x0b71, 0x0b82, 0x0b83, 0x0b85, 0x0b8a, 0x0b8e, 0x0b90, @@ -617,12 +672,12 @@ static const OnigCodePoint CRAlpha[] = { 0x0b9e, 0x0b9f, 0x0ba3, 0x0ba4, 0x0ba8, 0x0baa, - 0x0bae, 0x0bb5, - 0x0bb7, 0x0bb9, + 0x0bae, 0x0bb9, 0x0bbe, 0x0bc2, 0x0bc6, 0x0bc8, 0x0bca, 0x0bcd, 0x0bd7, 0x0bd7, + 0x0be6, 0x0bfa, 0x0c01, 0x0c03, 0x0c05, 0x0c0c, 0x0c0e, 0x0c10, @@ -634,6 +689,7 @@ static const OnigCodePoint CRAlpha[] = { 0x0c4a, 0x0c4d, 0x0c55, 0x0c56, 0x0c60, 0x0c61, + 0x0c66, 0x0c6f, 0x0c82, 0x0c83, 0x0c85, 0x0c8c, 0x0c8e, 0x0c90, @@ -646,6 +702,7 @@ static const OnigCodePoint CRAlpha[] = { 0x0cd5, 0x0cd6, 0x0cde, 0x0cde, 0x0ce0, 0x0ce1, + 0x0ce6, 0x0cef, 0x0d02, 0x0d03, 0x0d05, 0x0d0c, 0x0d0e, 0x0d10, @@ -656,6 +713,7 @@ static const OnigCodePoint CRAlpha[] = { 0x0d4a, 0x0d4d, 0x0d57, 0x0d57, 0x0d60, 0x0d61, + 0x0d66, 0x0d6f, 0x0d82, 0x0d83, 0x0d85, 0x0d96, 0x0d9a, 0x0db1, @@ -666,9 +724,9 @@ static const OnigCodePoint CRAlpha[] = { 0x0dcf, 0x0dd4, 0x0dd6, 0x0dd6, 0x0dd8, 0x0ddf, - 0x0df2, 0x0df3, + 0x0df2, 0x0df4, 0x0e01, 0x0e3a, - 0x0e40, 0x0e4e, + 0x0e3f, 0x0e5b, 0x0e81, 0x0e82, 0x0e84, 0x0e84, 0x0e87, 0x0e88, @@ -685,80 +743,74 @@ static const OnigCodePoint CRAlpha[] = { 0x0ec0, 0x0ec4, 0x0ec6, 0x0ec6, 0x0ec8, 0x0ecd, + 0x0ed0, 0x0ed9, 0x0edc, 0x0edd, - 0x0f00, 0x0f00, - 0x0f18, 0x0f19, - 0x0f35, 0x0f35, - 0x0f37, 0x0f37, - 0x0f39, 0x0f39, - 0x0f3e, 0x0f47, + 0x0f00, 0x0f47, 0x0f49, 0x0f6a, - 0x0f71, 0x0f84, - 0x0f86, 0x0f8b, + 0x0f71, 0x0f8b, 0x0f90, 0x0f97, 0x0f99, 0x0fbc, - 0x0fc6, 0x0fc6, + 0x0fbe, 0x0fcc, + 0x0fcf, 0x0fd1, 0x1000, 0x1021, 0x1023, 0x1027, 0x1029, 0x102a, 0x102c, 0x1032, 0x1036, 0x1039, - 0x1050, 0x1059, + 0x1040, 0x1059, 0x10a0, 0x10c5, - 0x10d0, 0x10f8, + 0x10d0, 0x10fc, 0x1100, 0x1159, 0x115f, 0x11a2, 0x11a8, 0x11f9, - 0x1200, 0x1206, - 0x1208, 0x1246, - 0x1248, 0x1248, + 0x1200, 0x1248, 0x124a, 0x124d, 0x1250, 0x1256, 0x1258, 0x1258, 0x125a, 0x125d, - 0x1260, 0x1286, - 0x1288, 0x1288, + 0x1260, 0x1288, 0x128a, 0x128d, - 0x1290, 0x12ae, - 0x12b0, 0x12b0, + 0x1290, 0x12b0, 0x12b2, 0x12b5, 0x12b8, 0x12be, 0x12c0, 0x12c0, 0x12c2, 0x12c5, - 0x12c8, 0x12ce, - 0x12d0, 0x12d6, - 0x12d8, 0x12ee, - 0x12f0, 0x130e, - 0x1310, 0x1310, + 0x12c8, 0x12d6, + 0x12d8, 0x1310, 0x1312, 0x1315, - 0x1318, 0x131e, - 0x1320, 0x1346, - 0x1348, 0x135a, + 0x1318, 0x135a, + 0x135f, 0x137c, + 0x1380, 0x1399, 0x13a0, 0x13f4, - 0x1401, 0x166c, - 0x166f, 0x1676, - 0x1681, 0x169a, - 0x16a0, 0x16ea, + 0x1401, 0x1676, + 0x1681, 0x169c, + 0x16a0, 0x16f0, 0x1700, 0x170c, 0x170e, 0x1714, - 0x1720, 0x1734, + 0x1720, 0x1736, 0x1740, 0x1753, 0x1760, 0x176c, 0x176e, 0x1770, 0x1772, 0x1773, - 0x1780, 0x17b3, - 0x17b6, 0x17d3, - 0x17d7, 0x17d7, - 0x17dc, 0x17dd, - 0x180b, 0x180d, + 0x1780, 0x17dd, + 0x17e0, 0x17e9, + 0x17f0, 0x17f9, + 0x1800, 0x180d, + 0x1810, 0x1819, 0x1820, 0x1877, 0x1880, 0x18a9, 0x1900, 0x191c, 0x1920, 0x192b, 0x1930, 0x193b, - 0x1950, 0x196d, + 0x1940, 0x1940, + 0x1944, 0x196d, 0x1970, 0x1974, - 0x1d00, 0x1d6b, + 0x1980, 0x19a9, + 0x19b0, 0x19c9, + 0x19d0, 0x19d9, + 0x19de, 0x1a1b, + 0x1a1e, 0x1a1f, + 0x1d00, 0x1dc3, 0x1e00, 0x1e9b, 0x1ea0, 0x1ef9, 0x1f00, 0x1f15, @@ -771,74 +823,111 @@ static const OnigCodePoint CRAlpha[] = { 0x1f5d, 0x1f5d, 0x1f5f, 0x1f7d, 0x1f80, 0x1fb4, - 0x1fb6, 0x1fbc, - 0x1fbe, 0x1fbe, - 0x1fc2, 0x1fc4, - 0x1fc6, 0x1fcc, - 0x1fd0, 0x1fd3, + 0x1fb6, 0x1fc4, + 0x1fc6, 0x1fd3, 0x1fd6, 0x1fdb, - 0x1fe0, 0x1fec, + 0x1fdd, 0x1fef, 0x1ff2, 0x1ff4, - 0x1ff6, 0x1ffc, - 0x2071, 0x2071, - 0x207f, 0x207f, - 0x20d0, 0x20ea, - 0x2102, 0x2102, - 0x2107, 0x2107, - 0x210a, 0x2113, - 0x2115, 0x2115, - 0x2119, 0x211d, - 0x2124, 0x2124, - 0x2126, 0x2126, - 0x2128, 0x2128, - 0x212a, 0x212d, - 0x212f, 0x2131, - 0x2133, 0x2139, - 0x213d, 0x213f, - 0x2145, 0x2149, - 0x3005, 0x3006, - 0x302a, 0x302f, - 0x3031, 0x3035, - 0x303b, 0x303c, + 0x1ff6, 0x1ffe, + 0x200b, 0x2027, + 0x202a, 0x202e, + 0x2030, 0x205e, + 0x2060, 0x2063, + 0x206a, 0x2071, + 0x2074, 0x208e, + 0x2090, 0x2094, + 0x20a0, 0x20b5, + 0x20d0, 0x20eb, + 0x2100, 0x214c, + 0x2153, 0x2183, + 0x2190, 0x23db, + 0x2400, 0x2426, + 0x2440, 0x244a, + 0x2460, 0x269c, + 0x26a0, 0x26b1, + 0x2701, 0x2704, + 0x2706, 0x2709, + 0x270c, 0x2727, + 0x2729, 0x274b, + 0x274d, 0x274d, + 0x274f, 0x2752, + 0x2756, 0x2756, + 0x2758, 0x275e, + 0x2761, 0x2794, + 0x2798, 0x27af, + 0x27b1, 0x27be, + 0x27c0, 0x27c6, + 0x27d0, 0x27eb, + 0x27f0, 0x2b13, + 0x2c00, 0x2c2e, + 0x2c30, 0x2c5e, + 0x2c80, 0x2cea, + 0x2cf9, 0x2d25, + 0x2d30, 0x2d65, + 0x2d6f, 0x2d6f, + 0x2d80, 0x2d96, + 0x2da0, 0x2da6, + 0x2da8, 0x2dae, + 0x2db0, 0x2db6, + 0x2db8, 0x2dbe, + 0x2dc0, 0x2dc6, + 0x2dc8, 0x2dce, + 0x2dd0, 0x2dd6, + 0x2dd8, 0x2dde, + 0x2e00, 0x2e17, + 0x2e1c, 0x2e1d, + 0x2e80, 0x2e99, + 0x2e9b, 0x2ef3, + 0x2f00, 0x2fd5, + 0x2ff0, 0x2ffb, + 0x3001, 0x303f, 0x3041, 0x3096, - 0x3099, 0x309a, - 0x309d, 0x309f, - 0x30a1, 0x30fa, - 0x30fc, 0x30ff, + 0x3099, 0x30ff, 0x3105, 0x312c, 0x3131, 0x318e, - 0x31a0, 0x31b7, - 0x31f0, 0x31ff, - 0x3400, 0x4db5, - 0x4e00, 0x9fa5, - 0xa000, 0xa48c, - 0xac00, 0xd7a3, - 0xf900, 0xfa2d, + 0x3190, 0x31b7, + 0x31c0, 0x31cf, + 0x31f0, 0x321e, + 0x3220, 0x3243, + 0x3250, 0x32fe, + 0x3300, 0x4db5, + 0x4dc0, 0x9fbb, + 0xa000, 0xa48c, + 0xa490, 0xa4c6, + 0xa700, 0xa716, + 0xa800, 0xa82b, + 0xac00, 0xd7a3, + 0xe000, 0xfa2d, 0xfa30, 0xfa6a, + 0xfa70, 0xfad9, 0xfb00, 0xfb06, 0xfb13, 0xfb17, - 0xfb1d, 0xfb28, - 0xfb2a, 0xfb36, + 0xfb1d, 0xfb36, 0xfb38, 0xfb3c, 0xfb3e, 0xfb3e, 0xfb40, 0xfb41, 0xfb43, 0xfb44, 0xfb46, 0xfbb1, - 0xfbd3, 0xfd3d, + 0xfbd3, 0xfd3f, 0xfd50, 0xfd8f, 0xfd92, 0xfdc7, - 0xfdf0, 0xfdfb, - 0xfe00, 0xfe0f, + 0xfdf0, 0xfdfd, + 0xfe00, 0xfe19, 0xfe20, 0xfe23, + 0xfe30, 0xfe52, + 0xfe54, 0xfe66, + 0xfe68, 0xfe6b, 0xfe70, 0xfe74, 0xfe76, 0xfefc, - 0xff21, 0xff3a, - 0xff41, 0xff5a, - 0xff66, 0xffbe, + 0xfeff, 0xfeff, + 0xff01, 0xffbe, 0xffc2, 0xffc7, 0xffca, 0xffcf, 0xffd2, 0xffd7, 0xffda, 0xffdc, + 0xffe0, 0xffe6, + 0xffe8, 0xffee, + 0xfff9, 0xfffd, 0x10000, 0x1000b, 0x1000d, 0x10026, 0x10028, 0x1003a, @@ -846,21 +935,36 @@ static const OnigCodePoint CRAlpha[] = { 0x1003f, 0x1004d, 0x10050, 0x1005d, 0x10080, 0x100fa, + 0x10100, 0x10102, + 0x10107, 0x10133, + 0x10137, 0x1018a, 0x10300, 0x1031e, - 0x10330, 0x10349, + 0x10320, 0x10323, + 0x10330, 0x1034a, 0x10380, 0x1039d, + 0x1039f, 0x103c3, + 0x103c8, 0x103d5, 0x10400, 0x1049d, + 0x104a0, 0x104a9, 0x10800, 0x10805, 0x10808, 0x10808, 0x1080a, 0x10835, 0x10837, 0x10838, 0x1083c, 0x1083c, 0x1083f, 0x1083f, - 0x1d165, 0x1d169, - 0x1d16d, 0x1d172, - 0x1d17b, 0x1d182, - 0x1d185, 0x1d18b, - 0x1d1aa, 0x1d1ad, + 0x10a00, 0x10a03, + 0x10a05, 0x10a06, + 0x10a0c, 0x10a13, + 0x10a15, 0x10a17, + 0x10a19, 0x10a33, + 0x10a38, 0x10a3a, + 0x10a3f, 0x10a47, + 0x10a50, 0x10a58, + 0x1d000, 0x1d0f5, + 0x1d100, 0x1d126, + 0x1d12a, 0x1d1dd, + 0x1d200, 0x1d245, + 0x1d300, 0x1d356, 0x1d400, 0x1d454, 0x1d456, 0x1d49c, 0x1d49e, 0x1d49f, @@ -879,538 +983,27 @@ static const OnigCodePoint CRAlpha[] = { 0x1d540, 0x1d544, 0x1d546, 0x1d546, 0x1d54a, 0x1d550, - 0x1d552, 0x1d6a3, - 0x1d6a8, 0x1d6c0, - 0x1d6c2, 0x1d6da, - 0x1d6dc, 0x1d6fa, - 0x1d6fc, 0x1d714, - 0x1d716, 0x1d734, - 0x1d736, 0x1d74e, - 0x1d750, 0x1d76e, - 0x1d770, 0x1d788, - 0x1d78a, 0x1d7a8, - 0x1d7aa, 0x1d7c2, - 0x1d7c4, 0x1d7c9, + 0x1d552, 0x1d6a5, + 0x1d6a8, 0x1d7c9, + 0x1d7ce, 0x1d7ff, 0x20000, 0x2a6d6, 0x2f800, 0x2fa1d, - 0xe0100, 0xe01ef -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRAlpha */ - -static const OnigCodePoint CRBlank[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 9, -#else - 3, -#endif - 0x0009, 0x0009, - 0x0020, 0x0020, - 0x00a0, 0x00a0 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x1680, 0x1680, - 0x180e, 0x180e, - 0x2000, 0x200a, - 0x202f, 0x202f, - 0x205f, 0x205f, - 0x3000, 0x3000 -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRBlank */ - -static const OnigCodePoint CRCntrl[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 19, -#else - 3, -#endif - 0x0000, 0x001f, - 0x007f, 0x009f, - 0x00ad, 0x00ad -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0600, 0x0603, - 0x06dd, 0x06dd, - 0x070f, 0x070f, - 0x17b4, 0x17b5, - 0x200b, 0x200f, - 0x202a, 0x202e, - 0x2060, 0x2063, - 0x206a, 0x206f, - 0xd800, 0xf8ff, - 0xfeff, 0xfeff, - 0xfff9, 0xfffb, - 0x1d173, 0x1d17a, 0xe0001, 0xe0001, 0xe0020, 0xe007f, + 0xe0100, 0xe01ef, 0xf0000, 0xffffd, 0x100000, 0x10fffd -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRCntrl */ - -static const OnigCodePoint CRDigit[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 23, -#else - 1, -#endif - 0x0030, 0x0039 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0660, 0x0669, - 0x06f0, 0x06f9, - 0x0966, 0x096f, - 0x09e6, 0x09ef, - 0x0a66, 0x0a6f, - 0x0ae6, 0x0aef, - 0x0b66, 0x0b6f, - 0x0be7, 0x0bef, - 0x0c66, 0x0c6f, - 0x0ce6, 0x0cef, - 0x0d66, 0x0d6f, - 0x0e50, 0x0e59, - 0x0ed0, 0x0ed9, - 0x0f20, 0x0f29, - 0x1040, 0x1049, - 0x1369, 0x1371, - 0x17e0, 0x17e9, - 0x1810, 0x1819, - 0x1946, 0x194f, - 0xff10, 0xff19, - 0x104a0, 0x104a9, - 0x1d7ce, 0x1d7ff -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRDigit */ +}; /* CR_Graph */ -static const OnigCodePoint CRGraph[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 405, -#else - 2, -#endif - 0x0021, 0x007e, - 0x00a1, 0x0236 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0250, 0x0357, - 0x035d, 0x036f, - 0x0374, 0x0375, - 0x037a, 0x037a, - 0x037e, 0x037e, - 0x0384, 0x038a, - 0x038c, 0x038c, - 0x038e, 0x03a1, - 0x03a3, 0x03ce, - 0x03d0, 0x03fb, - 0x0400, 0x0486, - 0x0488, 0x04ce, - 0x04d0, 0x04f5, - 0x04f8, 0x04f9, - 0x0500, 0x050f, - 0x0531, 0x0556, - 0x0559, 0x055f, - 0x0561, 0x0587, - 0x0589, 0x058a, - 0x0591, 0x05a1, - 0x05a3, 0x05b9, - 0x05bb, 0x05c4, - 0x05d0, 0x05ea, - 0x05f0, 0x05f4, - 0x0600, 0x0603, - 0x060c, 0x0615, - 0x061b, 0x061b, - 0x061f, 0x061f, - 0x0621, 0x063a, - 0x0640, 0x0658, - 0x0660, 0x070d, - 0x070f, 0x074a, - 0x074d, 0x074f, - 0x0780, 0x07b1, - 0x0901, 0x0939, - 0x093c, 0x094d, - 0x0950, 0x0954, - 0x0958, 0x0970, - 0x0981, 0x0983, - 0x0985, 0x098c, - 0x098f, 0x0990, - 0x0993, 0x09a8, - 0x09aa, 0x09b0, - 0x09b2, 0x09b2, - 0x09b6, 0x09b9, - 0x09bc, 0x09c4, - 0x09c7, 0x09c8, - 0x09cb, 0x09cd, - 0x09d7, 0x09d7, - 0x09dc, 0x09dd, - 0x09df, 0x09e3, - 0x09e6, 0x09fa, - 0x0a01, 0x0a03, - 0x0a05, 0x0a0a, - 0x0a0f, 0x0a10, - 0x0a13, 0x0a28, - 0x0a2a, 0x0a30, - 0x0a32, 0x0a33, - 0x0a35, 0x0a36, - 0x0a38, 0x0a39, - 0x0a3c, 0x0a3c, - 0x0a3e, 0x0a42, - 0x0a47, 0x0a48, - 0x0a4b, 0x0a4d, - 0x0a59, 0x0a5c, - 0x0a5e, 0x0a5e, - 0x0a66, 0x0a74, - 0x0a81, 0x0a83, - 0x0a85, 0x0a8d, - 0x0a8f, 0x0a91, - 0x0a93, 0x0aa8, - 0x0aaa, 0x0ab0, - 0x0ab2, 0x0ab3, - 0x0ab5, 0x0ab9, - 0x0abc, 0x0ac5, - 0x0ac7, 0x0ac9, - 0x0acb, 0x0acd, - 0x0ad0, 0x0ad0, - 0x0ae0, 0x0ae3, - 0x0ae6, 0x0aef, - 0x0af1, 0x0af1, - 0x0b01, 0x0b03, - 0x0b05, 0x0b0c, - 0x0b0f, 0x0b10, - 0x0b13, 0x0b28, - 0x0b2a, 0x0b30, - 0x0b32, 0x0b33, - 0x0b35, 0x0b39, - 0x0b3c, 0x0b43, - 0x0b47, 0x0b48, - 0x0b4b, 0x0b4d, - 0x0b56, 0x0b57, - 0x0b5c, 0x0b5d, - 0x0b5f, 0x0b61, - 0x0b66, 0x0b71, - 0x0b82, 0x0b83, - 0x0b85, 0x0b8a, - 0x0b8e, 0x0b90, - 0x0b92, 0x0b95, - 0x0b99, 0x0b9a, - 0x0b9c, 0x0b9c, - 0x0b9e, 0x0b9f, - 0x0ba3, 0x0ba4, - 0x0ba8, 0x0baa, - 0x0bae, 0x0bb5, - 0x0bb7, 0x0bb9, - 0x0bbe, 0x0bc2, - 0x0bc6, 0x0bc8, - 0x0bca, 0x0bcd, - 0x0bd7, 0x0bd7, - 0x0be7, 0x0bfa, - 0x0c01, 0x0c03, - 0x0c05, 0x0c0c, - 0x0c0e, 0x0c10, - 0x0c12, 0x0c28, - 0x0c2a, 0x0c33, - 0x0c35, 0x0c39, - 0x0c3e, 0x0c44, - 0x0c46, 0x0c48, - 0x0c4a, 0x0c4d, - 0x0c55, 0x0c56, - 0x0c60, 0x0c61, - 0x0c66, 0x0c6f, - 0x0c82, 0x0c83, - 0x0c85, 0x0c8c, - 0x0c8e, 0x0c90, - 0x0c92, 0x0ca8, - 0x0caa, 0x0cb3, - 0x0cb5, 0x0cb9, - 0x0cbc, 0x0cc4, - 0x0cc6, 0x0cc8, - 0x0cca, 0x0ccd, - 0x0cd5, 0x0cd6, - 0x0cde, 0x0cde, - 0x0ce0, 0x0ce1, - 0x0ce6, 0x0cef, - 0x0d02, 0x0d03, - 0x0d05, 0x0d0c, - 0x0d0e, 0x0d10, - 0x0d12, 0x0d28, - 0x0d2a, 0x0d39, - 0x0d3e, 0x0d43, - 0x0d46, 0x0d48, - 0x0d4a, 0x0d4d, - 0x0d57, 0x0d57, - 0x0d60, 0x0d61, - 0x0d66, 0x0d6f, - 0x0d82, 0x0d83, - 0x0d85, 0x0d96, - 0x0d9a, 0x0db1, - 0x0db3, 0x0dbb, - 0x0dbd, 0x0dbd, - 0x0dc0, 0x0dc6, - 0x0dca, 0x0dca, - 0x0dcf, 0x0dd4, - 0x0dd6, 0x0dd6, - 0x0dd8, 0x0ddf, - 0x0df2, 0x0df4, - 0x0e01, 0x0e3a, - 0x0e3f, 0x0e5b, - 0x0e81, 0x0e82, - 0x0e84, 0x0e84, - 0x0e87, 0x0e88, - 0x0e8a, 0x0e8a, - 0x0e8d, 0x0e8d, - 0x0e94, 0x0e97, - 0x0e99, 0x0e9f, - 0x0ea1, 0x0ea3, - 0x0ea5, 0x0ea5, - 0x0ea7, 0x0ea7, - 0x0eaa, 0x0eab, - 0x0ead, 0x0eb9, - 0x0ebb, 0x0ebd, - 0x0ec0, 0x0ec4, - 0x0ec6, 0x0ec6, - 0x0ec8, 0x0ecd, - 0x0ed0, 0x0ed9, - 0x0edc, 0x0edd, - 0x0f00, 0x0f47, - 0x0f49, 0x0f6a, - 0x0f71, 0x0f8b, - 0x0f90, 0x0f97, - 0x0f99, 0x0fbc, - 0x0fbe, 0x0fcc, - 0x0fcf, 0x0fcf, - 0x1000, 0x1021, - 0x1023, 0x1027, - 0x1029, 0x102a, - 0x102c, 0x1032, - 0x1036, 0x1039, - 0x1040, 0x1059, - 0x10a0, 0x10c5, - 0x10d0, 0x10f8, - 0x10fb, 0x10fb, - 0x1100, 0x1159, - 0x115f, 0x11a2, - 0x11a8, 0x11f9, - 0x1200, 0x1206, - 0x1208, 0x1246, - 0x1248, 0x1248, - 0x124a, 0x124d, - 0x1250, 0x1256, - 0x1258, 0x1258, - 0x125a, 0x125d, - 0x1260, 0x1286, - 0x1288, 0x1288, - 0x128a, 0x128d, - 0x1290, 0x12ae, - 0x12b0, 0x12b0, - 0x12b2, 0x12b5, - 0x12b8, 0x12be, - 0x12c0, 0x12c0, - 0x12c2, 0x12c5, - 0x12c8, 0x12ce, - 0x12d0, 0x12d6, - 0x12d8, 0x12ee, - 0x12f0, 0x130e, - 0x1310, 0x1310, - 0x1312, 0x1315, - 0x1318, 0x131e, - 0x1320, 0x1346, - 0x1348, 0x135a, - 0x1361, 0x137c, - 0x13a0, 0x13f4, - 0x1401, 0x1676, - 0x1681, 0x169c, - 0x16a0, 0x16f0, - 0x1700, 0x170c, - 0x170e, 0x1714, - 0x1720, 0x1736, - 0x1740, 0x1753, - 0x1760, 0x176c, - 0x176e, 0x1770, - 0x1772, 0x1773, - 0x1780, 0x17dd, - 0x17e0, 0x17e9, - 0x17f0, 0x17f9, - 0x1800, 0x180d, - 0x1810, 0x1819, - 0x1820, 0x1877, - 0x1880, 0x18a9, - 0x1900, 0x191c, - 0x1920, 0x192b, - 0x1930, 0x193b, - 0x1940, 0x1940, - 0x1944, 0x196d, - 0x1970, 0x1974, - 0x19e0, 0x19ff, - 0x1d00, 0x1d6b, - 0x1e00, 0x1e9b, - 0x1ea0, 0x1ef9, - 0x1f00, 0x1f15, - 0x1f18, 0x1f1d, - 0x1f20, 0x1f45, - 0x1f48, 0x1f4d, - 0x1f50, 0x1f57, - 0x1f59, 0x1f59, - 0x1f5b, 0x1f5b, - 0x1f5d, 0x1f5d, - 0x1f5f, 0x1f7d, - 0x1f80, 0x1fb4, - 0x1fb6, 0x1fc4, - 0x1fc6, 0x1fd3, - 0x1fd6, 0x1fdb, - 0x1fdd, 0x1fef, - 0x1ff2, 0x1ff4, - 0x1ff6, 0x1ffe, - 0x200b, 0x2027, - 0x202a, 0x202e, - 0x2030, 0x2054, - 0x2057, 0x2057, - 0x2060, 0x2063, - 0x206a, 0x2071, - 0x2074, 0x208e, - 0x20a0, 0x20b1, - 0x20d0, 0x20ea, - 0x2100, 0x213b, - 0x213d, 0x214b, - 0x2153, 0x2183, - 0x2190, 0x23d0, - 0x2400, 0x2426, - 0x2440, 0x244a, - 0x2460, 0x2617, - 0x2619, 0x267d, - 0x2680, 0x2691, - 0x26a0, 0x26a1, - 0x2701, 0x2704, - 0x2706, 0x2709, - 0x270c, 0x2727, - 0x2729, 0x274b, - 0x274d, 0x274d, - 0x274f, 0x2752, - 0x2756, 0x2756, - 0x2758, 0x275e, - 0x2761, 0x2794, - 0x2798, 0x27af, - 0x27b1, 0x27be, - 0x27d0, 0x27eb, - 0x27f0, 0x2b0d, - 0x2e80, 0x2e99, - 0x2e9b, 0x2ef3, - 0x2f00, 0x2fd5, - 0x2ff0, 0x2ffb, - 0x3001, 0x303f, - 0x3041, 0x3096, - 0x3099, 0x30ff, - 0x3105, 0x312c, - 0x3131, 0x318e, - 0x3190, 0x31b7, - 0x31f0, 0x321e, - 0x3220, 0x3243, - 0x3250, 0x327d, - 0x327f, 0x32fe, - 0x3300, 0x4db5, - 0x4dc0, 0x9fa5, - 0xa000, 0xa48c, - 0xa490, 0xa4c6, - 0xac00, 0xd7a3, - 0xe000, 0xfa2d, - 0xfa30, 0xfa6a, - 0xfb00, 0xfb06, - 0xfb13, 0xfb17, - 0xfb1d, 0xfb36, - 0xfb38, 0xfb3c, - 0xfb3e, 0xfb3e, - 0xfb40, 0xfb41, - 0xfb43, 0xfb44, - 0xfb46, 0xfbb1, - 0xfbd3, 0xfd3f, - 0xfd50, 0xfd8f, - 0xfd92, 0xfdc7, - 0xfdf0, 0xfdfd, - 0xfe00, 0xfe0f, - 0xfe20, 0xfe23, - 0xfe30, 0xfe52, - 0xfe54, 0xfe66, - 0xfe68, 0xfe6b, - 0xfe70, 0xfe74, - 0xfe76, 0xfefc, - 0xfeff, 0xfeff, - 0xff01, 0xffbe, - 0xffc2, 0xffc7, - 0xffca, 0xffcf, - 0xffd2, 0xffd7, - 0xffda, 0xffdc, - 0xffe0, 0xffe6, - 0xffe8, 0xffee, - 0xfff9, 0xfffd, - 0x10000, 0x1000b, - 0x1000d, 0x10026, - 0x10028, 0x1003a, - 0x1003c, 0x1003d, - 0x1003f, 0x1004d, - 0x10050, 0x1005d, - 0x10080, 0x100fa, - 0x10100, 0x10102, - 0x10107, 0x10133, - 0x10137, 0x1013f, - 0x10300, 0x1031e, - 0x10320, 0x10323, - 0x10330, 0x1034a, - 0x10380, 0x1039d, - 0x1039f, 0x1039f, - 0x10400, 0x1049d, - 0x104a0, 0x104a9, - 0x10800, 0x10805, - 0x10808, 0x10808, - 0x1080a, 0x10835, - 0x10837, 0x10838, - 0x1083c, 0x1083c, - 0x1083f, 0x1083f, - 0x1d000, 0x1d0f5, - 0x1d100, 0x1d126, - 0x1d12a, 0x1d1dd, - 0x1d300, 0x1d356, - 0x1d400, 0x1d454, - 0x1d456, 0x1d49c, - 0x1d49e, 0x1d49f, - 0x1d4a2, 0x1d4a2, - 0x1d4a5, 0x1d4a6, - 0x1d4a9, 0x1d4ac, - 0x1d4ae, 0x1d4b9, - 0x1d4bb, 0x1d4bb, - 0x1d4bd, 0x1d4c3, - 0x1d4c5, 0x1d505, - 0x1d507, 0x1d50a, - 0x1d50d, 0x1d514, - 0x1d516, 0x1d51c, - 0x1d51e, 0x1d539, - 0x1d53b, 0x1d53e, - 0x1d540, 0x1d544, - 0x1d546, 0x1d546, - 0x1d54a, 0x1d550, - 0x1d552, 0x1d6a3, - 0x1d6a8, 0x1d7c9, - 0x1d7ce, 0x1d7ff, - 0x20000, 0x2a6d6, - 0x2f800, 0x2fa1d, - 0xe0001, 0xe0001, - 0xe0020, 0xe007f, - 0xe0100, 0xe01ef, - 0xf0000, 0xffffd, - 0x100000, 0x10fffd -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRGraph */ - -static const OnigCodePoint CRLower[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 424, -#else - 6, -#endif +/* 'Lower': [[:Lower:]] */ +static const OnigCodePoint CR_Lower[] = { + 480, 0x0061, 0x007a, 0x00aa, 0x00aa, 0x00b5, 0x00b5, 0x00ba, 0x00ba, 0x00df, 0x00f6, - 0x00f8, 0x00ff -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , + 0x00f8, 0x00ff, 0x0101, 0x0101, 0x0103, 0x0103, 0x0105, 0x0105, @@ -1543,7 +1136,9 @@ static const OnigCodePoint CRLower[] = { 0x022d, 0x022d, 0x022f, 0x022f, 0x0231, 0x0231, - 0x0233, 0x0236, + 0x0233, 0x0239, + 0x023c, 0x023c, + 0x023f, 0x0240, 0x0250, 0x02af, 0x0390, 0x0390, 0x03ac, 0x03ce, @@ -1563,7 +1158,7 @@ static const OnigCodePoint CRLower[] = { 0x03ef, 0x03f3, 0x03f5, 0x03f5, 0x03f8, 0x03f8, - 0x03fb, 0x03fb, + 0x03fb, 0x03fc, 0x0430, 0x045f, 0x0461, 0x0461, 0x0463, 0x0463, @@ -1635,6 +1230,7 @@ static const OnigCodePoint CRLower[] = { 0x04f1, 0x04f1, 0x04f3, 0x04f3, 0x04f5, 0x04f5, + 0x04f7, 0x04f7, 0x04f9, 0x04f9, 0x0501, 0x0501, 0x0503, 0x0503, @@ -1646,7 +1242,8 @@ static const OnigCodePoint CRLower[] = { 0x050f, 0x050f, 0x0561, 0x0587, 0x1d00, 0x1d2b, - 0x1d62, 0x1d6b, + 0x1d62, 0x1d77, + 0x1d79, 0x1d9a, 0x1e01, 0x1e01, 0x1e03, 0x1e03, 0x1e05, 0x1e05, @@ -1796,8 +1393,60 @@ static const OnigCodePoint CRLower[] = { 0x212f, 0x212f, 0x2134, 0x2134, 0x2139, 0x2139, - 0x213d, 0x213d, + 0x213c, 0x213d, 0x2146, 0x2149, + 0x2c30, 0x2c5e, + 0x2c81, 0x2c81, + 0x2c83, 0x2c83, + 0x2c85, 0x2c85, + 0x2c87, 0x2c87, + 0x2c89, 0x2c89, + 0x2c8b, 0x2c8b, + 0x2c8d, 0x2c8d, + 0x2c8f, 0x2c8f, + 0x2c91, 0x2c91, + 0x2c93, 0x2c93, + 0x2c95, 0x2c95, + 0x2c97, 0x2c97, + 0x2c99, 0x2c99, + 0x2c9b, 0x2c9b, + 0x2c9d, 0x2c9d, + 0x2c9f, 0x2c9f, + 0x2ca1, 0x2ca1, + 0x2ca3, 0x2ca3, + 0x2ca5, 0x2ca5, + 0x2ca7, 0x2ca7, + 0x2ca9, 0x2ca9, + 0x2cab, 0x2cab, + 0x2cad, 0x2cad, + 0x2caf, 0x2caf, + 0x2cb1, 0x2cb1, + 0x2cb3, 0x2cb3, + 0x2cb5, 0x2cb5, + 0x2cb7, 0x2cb7, + 0x2cb9, 0x2cb9, + 0x2cbb, 0x2cbb, + 0x2cbd, 0x2cbd, + 0x2cbf, 0x2cbf, + 0x2cc1, 0x2cc1, + 0x2cc3, 0x2cc3, + 0x2cc5, 0x2cc5, + 0x2cc7, 0x2cc7, + 0x2cc9, 0x2cc9, + 0x2ccb, 0x2ccb, + 0x2ccd, 0x2ccd, + 0x2ccf, 0x2ccf, + 0x2cd1, 0x2cd1, + 0x2cd3, 0x2cd3, + 0x2cd5, 0x2cd5, + 0x2cd7, 0x2cd7, + 0x2cd9, 0x2cd9, + 0x2cdb, 0x2cdb, + 0x2cdd, 0x2cdd, + 0x2cdf, 0x2cdf, + 0x2ce1, 0x2ce1, + 0x2ce3, 0x2ce4, + 0x2d00, 0x2d25, 0xfb00, 0xfb06, 0xfb13, 0xfb17, 0xff41, 0xff5a, @@ -1818,7 +1467,7 @@ static const OnigCodePoint CRLower[] = { 0x1d5ee, 0x1d607, 0x1d622, 0x1d63b, 0x1d656, 0x1d66f, - 0x1d68a, 0x1d6a3, + 0x1d68a, 0x1d6a5, 0x1d6c2, 0x1d6da, 0x1d6dc, 0x1d6e1, 0x1d6fc, 0x1d714, @@ -1829,23 +1478,16 @@ static const OnigCodePoint CRLower[] = { 0x1d78a, 0x1d78f, 0x1d7aa, 0x1d7c2, 0x1d7c4, 0x1d7c9 -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRLower */ +}; /* CR_Lower */ -static const OnigCodePoint CRPrint[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 405, -#else - 4, -#endif +/* 'Print': [[:Print:]] */ +static const OnigCodePoint CR_Print[] = { + 423, 0x0009, 0x000d, 0x0020, 0x007e, 0x0085, 0x0085, - 0x00a0, 0x0236 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0250, 0x0357, - 0x035d, 0x036f, + 0x00a0, 0x0241, + 0x0250, 0x036f, 0x0374, 0x0375, 0x037a, 0x037a, 0x037e, 0x037e, @@ -1853,35 +1495,33 @@ static const OnigCodePoint CRPrint[] = { 0x038c, 0x038c, 0x038e, 0x03a1, 0x03a3, 0x03ce, - 0x03d0, 0x03fb, - 0x0400, 0x0486, + 0x03d0, 0x0486, 0x0488, 0x04ce, - 0x04d0, 0x04f5, - 0x04f8, 0x04f9, + 0x04d0, 0x04f9, 0x0500, 0x050f, 0x0531, 0x0556, 0x0559, 0x055f, 0x0561, 0x0587, 0x0589, 0x058a, - 0x0591, 0x05a1, - 0x05a3, 0x05b9, - 0x05bb, 0x05c4, + 0x0591, 0x05b9, + 0x05bb, 0x05c7, 0x05d0, 0x05ea, 0x05f0, 0x05f4, 0x0600, 0x0603, - 0x060c, 0x0615, + 0x060b, 0x0615, 0x061b, 0x061b, - 0x061f, 0x061f, + 0x061e, 0x061f, 0x0621, 0x063a, - 0x0640, 0x0658, + 0x0640, 0x065e, 0x0660, 0x070d, 0x070f, 0x074a, - 0x074d, 0x074f, + 0x074d, 0x076d, 0x0780, 0x07b1, 0x0901, 0x0939, 0x093c, 0x094d, 0x0950, 0x0954, 0x0958, 0x0970, + 0x097d, 0x097d, 0x0981, 0x0983, 0x0985, 0x098c, 0x098f, 0x0990, @@ -1891,7 +1531,7 @@ static const OnigCodePoint CRPrint[] = { 0x09b6, 0x09b9, 0x09bc, 0x09c4, 0x09c7, 0x09c8, - 0x09cb, 0x09cd, + 0x09cb, 0x09ce, 0x09d7, 0x09d7, 0x09dc, 0x09dd, 0x09df, 0x09e3, @@ -1948,13 +1588,12 @@ static const OnigCodePoint CRPrint[] = { 0x0b9e, 0x0b9f, 0x0ba3, 0x0ba4, 0x0ba8, 0x0baa, - 0x0bae, 0x0bb5, - 0x0bb7, 0x0bb9, + 0x0bae, 0x0bb9, 0x0bbe, 0x0bc2, 0x0bc6, 0x0bc8, 0x0bca, 0x0bcd, 0x0bd7, 0x0bd7, - 0x0be7, 0x0bfa, + 0x0be6, 0x0bfa, 0x0c01, 0x0c03, 0x0c05, 0x0c0c, 0x0c0e, 0x0c10, @@ -2028,7 +1667,7 @@ static const OnigCodePoint CRPrint[] = { 0x0f90, 0x0f97, 0x0f99, 0x0fbc, 0x0fbe, 0x0fcc, - 0x0fcf, 0x0fcf, + 0x0fcf, 0x0fd1, 0x1000, 0x1021, 0x1023, 0x1027, 0x1029, 0x102a, @@ -2036,37 +1675,28 @@ static const OnigCodePoint CRPrint[] = { 0x1036, 0x1039, 0x1040, 0x1059, 0x10a0, 0x10c5, - 0x10d0, 0x10f8, - 0x10fb, 0x10fb, + 0x10d0, 0x10fc, 0x1100, 0x1159, 0x115f, 0x11a2, 0x11a8, 0x11f9, - 0x1200, 0x1206, - 0x1208, 0x1246, - 0x1248, 0x1248, + 0x1200, 0x1248, 0x124a, 0x124d, 0x1250, 0x1256, 0x1258, 0x1258, 0x125a, 0x125d, - 0x1260, 0x1286, - 0x1288, 0x1288, + 0x1260, 0x1288, 0x128a, 0x128d, - 0x1290, 0x12ae, - 0x12b0, 0x12b0, + 0x1290, 0x12b0, 0x12b2, 0x12b5, 0x12b8, 0x12be, 0x12c0, 0x12c0, 0x12c2, 0x12c5, - 0x12c8, 0x12ce, - 0x12d0, 0x12d6, - 0x12d8, 0x12ee, - 0x12f0, 0x130e, - 0x1310, 0x1310, + 0x12c8, 0x12d6, + 0x12d8, 0x1310, 0x1312, 0x1315, - 0x1318, 0x131e, - 0x1320, 0x1346, - 0x1348, 0x135a, - 0x1361, 0x137c, + 0x1318, 0x135a, + 0x135f, 0x137c, + 0x1380, 0x1399, 0x13a0, 0x13f4, 0x1401, 0x1676, 0x1680, 0x169c, @@ -2091,8 +1721,12 @@ static const OnigCodePoint CRPrint[] = { 0x1940, 0x1940, 0x1944, 0x196d, 0x1970, 0x1974, - 0x19e0, 0x19ff, - 0x1d00, 0x1d6b, + 0x1980, 0x19a9, + 0x19b0, 0x19c9, + 0x19d0, 0x19d9, + 0x19de, 0x1a1b, + 0x1a1e, 0x1a1f, + 0x1d00, 0x1dc3, 0x1e00, 0x1e9b, 0x1ea0, 0x1ef9, 0x1f00, 0x1f15, @@ -2111,23 +1745,19 @@ static const OnigCodePoint CRPrint[] = { 0x1fdd, 0x1fef, 0x1ff2, 0x1ff4, 0x1ff6, 0x1ffe, - 0x2000, 0x2054, - 0x2057, 0x2057, - 0x205f, 0x2063, + 0x2000, 0x2063, 0x206a, 0x2071, 0x2074, 0x208e, - 0x20a0, 0x20b1, - 0x20d0, 0x20ea, - 0x2100, 0x213b, - 0x213d, 0x214b, + 0x2090, 0x2094, + 0x20a0, 0x20b5, + 0x20d0, 0x20eb, + 0x2100, 0x214c, 0x2153, 0x2183, - 0x2190, 0x23d0, + 0x2190, 0x23db, 0x2400, 0x2426, 0x2440, 0x244a, - 0x2460, 0x2617, - 0x2619, 0x267d, - 0x2680, 0x2691, - 0x26a0, 0x26a1, + 0x2460, 0x269c, + 0x26a0, 0x26b1, 0x2701, 0x2704, 0x2706, 0x2709, 0x270c, 0x2727, @@ -2139,8 +1769,26 @@ static const OnigCodePoint CRPrint[] = { 0x2761, 0x2794, 0x2798, 0x27af, 0x27b1, 0x27be, + 0x27c0, 0x27c6, 0x27d0, 0x27eb, - 0x27f0, 0x2b0d, + 0x27f0, 0x2b13, + 0x2c00, 0x2c2e, + 0x2c30, 0x2c5e, + 0x2c80, 0x2cea, + 0x2cf9, 0x2d25, + 0x2d30, 0x2d65, + 0x2d6f, 0x2d6f, + 0x2d80, 0x2d96, + 0x2da0, 0x2da6, + 0x2da8, 0x2dae, + 0x2db0, 0x2db6, + 0x2db8, 0x2dbe, + 0x2dc0, 0x2dc6, + 0x2dc8, 0x2dce, + 0x2dd0, 0x2dd6, + 0x2dd8, 0x2dde, + 0x2e00, 0x2e17, + 0x2e1c, 0x2e1d, 0x2e80, 0x2e99, 0x2e9b, 0x2ef3, 0x2f00, 0x2fd5, @@ -2151,17 +1799,20 @@ static const OnigCodePoint CRPrint[] = { 0x3105, 0x312c, 0x3131, 0x318e, 0x3190, 0x31b7, + 0x31c0, 0x31cf, 0x31f0, 0x321e, 0x3220, 0x3243, - 0x3250, 0x327d, - 0x327f, 0x32fe, + 0x3250, 0x32fe, 0x3300, 0x4db5, - 0x4dc0, 0x9fa5, + 0x4dc0, 0x9fbb, 0xa000, 0xa48c, 0xa490, 0xa4c6, + 0xa700, 0xa716, + 0xa800, 0xa82b, 0xac00, 0xd7a3, 0xe000, 0xfa2d, 0xfa30, 0xfa6a, + 0xfa70, 0xfad9, 0xfb00, 0xfb06, 0xfb13, 0xfb17, 0xfb1d, 0xfb36, @@ -2174,7 +1825,7 @@ static const OnigCodePoint CRPrint[] = { 0xfd50, 0xfd8f, 0xfd92, 0xfdc7, 0xfdf0, 0xfdfd, - 0xfe00, 0xfe0f, + 0xfe00, 0xfe19, 0xfe20, 0xfe23, 0xfe30, 0xfe52, 0xfe54, 0xfe66, @@ -2199,12 +1850,13 @@ static const OnigCodePoint CRPrint[] = { 0x10080, 0x100fa, 0x10100, 0x10102, 0x10107, 0x10133, - 0x10137, 0x1013f, + 0x10137, 0x1018a, 0x10300, 0x1031e, 0x10320, 0x10323, 0x10330, 0x1034a, 0x10380, 0x1039d, - 0x1039f, 0x1039f, + 0x1039f, 0x103c3, + 0x103c8, 0x103d5, 0x10400, 0x1049d, 0x104a0, 0x104a9, 0x10800, 0x10805, @@ -2213,9 +1865,18 @@ static const OnigCodePoint CRPrint[] = { 0x10837, 0x10838, 0x1083c, 0x1083c, 0x1083f, 0x1083f, + 0x10a00, 0x10a03, + 0x10a05, 0x10a06, + 0x10a0c, 0x10a13, + 0x10a15, 0x10a17, + 0x10a19, 0x10a33, + 0x10a38, 0x10a3a, + 0x10a3f, 0x10a47, + 0x10a50, 0x10a58, 0x1d000, 0x1d0f5, 0x1d100, 0x1d126, 0x1d12a, 0x1d1dd, + 0x1d200, 0x1d245, 0x1d300, 0x1d356, 0x1d400, 0x1d454, 0x1d456, 0x1d49c, @@ -2235,7 +1896,7 @@ static const OnigCodePoint CRPrint[] = { 0x1d540, 0x1d544, 0x1d546, 0x1d546, 0x1d54a, 0x1d550, - 0x1d552, 0x1d6a3, + 0x1d552, 0x1d6a5, 0x1d6a8, 0x1d7c9, 0x1d7ce, 0x1d7ff, 0x20000, 0x2a6d6, @@ -2245,15 +1906,11 @@ static const OnigCodePoint CRPrint[] = { 0xe0100, 0xe01ef, 0xf0000, 0xffffd, 0x100000, 0x10fffd -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRPrint */ +}; /* CR_Print */ -static const OnigCodePoint CRPunct[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 86, -#else - 14, -#endif +/* 'Punct': [[:Punct:]] */ +static const OnigCodePoint CR_Punct[] = { + 96, 0x0021, 0x0023, 0x0025, 0x002a, 0x002c, 0x002f, @@ -2267,9 +1924,7 @@ static const OnigCodePoint CRPunct[] = { 0x00ab, 0x00ab, 0x00b7, 0x00b7, 0x00bb, 0x00bb, - 0x00bf, 0x00bf -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , + 0x00bf, 0x00bf, 0x037e, 0x037e, 0x0387, 0x0387, 0x055a, 0x055f, @@ -2277,10 +1932,11 @@ static const OnigCodePoint CRPunct[] = { 0x05be, 0x05be, 0x05c0, 0x05c0, 0x05c3, 0x05c3, + 0x05c6, 0x05c6, 0x05f3, 0x05f4, 0x060c, 0x060d, 0x061b, 0x061b, - 0x061f, 0x061f, + 0x061e, 0x061f, 0x066a, 0x066d, 0x06d4, 0x06d4, 0x0700, 0x070d, @@ -2292,6 +1948,7 @@ static const OnigCodePoint CRPunct[] = { 0x0f04, 0x0f12, 0x0f3a, 0x0f3d, 0x0f85, 0x0f85, + 0x0fd0, 0x0fd1, 0x104a, 0x104f, 0x10fb, 0x10fb, 0x1361, 0x1368, @@ -2303,20 +1960,26 @@ static const OnigCodePoint CRPunct[] = { 0x17d8, 0x17da, 0x1800, 0x180a, 0x1944, 0x1945, + 0x19de, 0x19df, + 0x1a1e, 0x1a1f, 0x2010, 0x2027, 0x2030, 0x2043, 0x2045, 0x2051, - 0x2053, 0x2054, - 0x2057, 0x2057, + 0x2053, 0x205e, 0x207d, 0x207e, 0x208d, 0x208e, 0x2329, 0x232a, 0x23b4, 0x23b6, 0x2768, 0x2775, + 0x27c5, 0x27c6, 0x27e6, 0x27eb, 0x2983, 0x2998, 0x29d8, 0x29db, 0x29fc, 0x29fd, + 0x2cf9, 0x2cfc, + 0x2cfe, 0x2cff, + 0x2e00, 0x2e17, + 0x2e1c, 0x2e1d, 0x3001, 0x3003, 0x3008, 0x3011, 0x3014, 0x301f, @@ -2325,6 +1988,7 @@ static const OnigCodePoint CRPunct[] = { 0x30a0, 0x30a0, 0x30fb, 0x30fb, 0xfd3e, 0xfd3f, + 0xfe10, 0xfe19, 0xfe30, 0xfe52, 0xfe54, 0xfe61, 0xfe63, 0xfe63, @@ -2341,22 +2005,17 @@ static const OnigCodePoint CRPunct[] = { 0xff5d, 0xff5d, 0xff5f, 0xff65, 0x10100, 0x10101, - 0x1039f, 0x1039f -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRPunct */ + 0x1039f, 0x1039f, + 0x10a50, 0x10a58 +}; /* CR_Punct */ -static const OnigCodePoint CRSpace[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE +/* 'Space': [[:Space:]] */ +static const OnigCodePoint CR_Space[] = { 11, -#else - 4, -#endif 0x0009, 0x000d, 0x0020, 0x0020, 0x0085, 0x0085, - 0x00a0, 0x00a0 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , + 0x00a0, 0x00a0, 0x1680, 0x1680, 0x180e, 0x180e, 0x2000, 0x200a, @@ -2364,20 +2023,14 @@ static const OnigCodePoint CRSpace[] = { 0x202f, 0x202f, 0x205f, 0x205f, 0x3000, 0x3000 -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRSpace */ +}; /* CR_Space */ -static const OnigCodePoint CRUpper[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 421, -#else - 3, -#endif +/* 'Upper': [[:Upper:]] */ +static const OnigCodePoint CR_Upper[] = { + 476, 0x0041, 0x005a, 0x00c0, 0x00d6, - 0x00d8, 0x00de -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , + 0x00d8, 0x00de, 0x0100, 0x0100, 0x0102, 0x0102, 0x0104, 0x0104, @@ -2511,6 +2164,9 @@ static const OnigCodePoint CRUpper[] = { 0x022e, 0x022e, 0x0230, 0x0230, 0x0232, 0x0232, + 0x023a, 0x023b, + 0x023d, 0x023e, + 0x0241, 0x0241, 0x0386, 0x0386, 0x0388, 0x038a, 0x038c, 0x038c, @@ -2533,7 +2189,7 @@ static const OnigCodePoint CRUpper[] = { 0x03f4, 0x03f4, 0x03f7, 0x03f7, 0x03f9, 0x03fa, - 0x0400, 0x042f, + 0x03fd, 0x042f, 0x0460, 0x0460, 0x0462, 0x0462, 0x0464, 0x0464, @@ -2604,6 +2260,7 @@ static const OnigCodePoint CRUpper[] = { 0x04f0, 0x04f0, 0x04f2, 0x04f2, 0x04f4, 0x04f4, + 0x04f6, 0x04f6, 0x04f8, 0x04f8, 0x0500, 0x0500, 0x0502, 0x0502, @@ -2764,6 +2421,57 @@ static const OnigCodePoint CRUpper[] = { 0x2133, 0x2133, 0x213e, 0x213f, 0x2145, 0x2145, + 0x2c00, 0x2c2e, + 0x2c80, 0x2c80, + 0x2c82, 0x2c82, + 0x2c84, 0x2c84, + 0x2c86, 0x2c86, + 0x2c88, 0x2c88, + 0x2c8a, 0x2c8a, + 0x2c8c, 0x2c8c, + 0x2c8e, 0x2c8e, + 0x2c90, 0x2c90, + 0x2c92, 0x2c92, + 0x2c94, 0x2c94, + 0x2c96, 0x2c96, + 0x2c98, 0x2c98, + 0x2c9a, 0x2c9a, + 0x2c9c, 0x2c9c, + 0x2c9e, 0x2c9e, + 0x2ca0, 0x2ca0, + 0x2ca2, 0x2ca2, + 0x2ca4, 0x2ca4, + 0x2ca6, 0x2ca6, + 0x2ca8, 0x2ca8, + 0x2caa, 0x2caa, + 0x2cac, 0x2cac, + 0x2cae, 0x2cae, + 0x2cb0, 0x2cb0, + 0x2cb2, 0x2cb2, + 0x2cb4, 0x2cb4, + 0x2cb6, 0x2cb6, + 0x2cb8, 0x2cb8, + 0x2cba, 0x2cba, + 0x2cbc, 0x2cbc, + 0x2cbe, 0x2cbe, + 0x2cc0, 0x2cc0, + 0x2cc2, 0x2cc2, + 0x2cc4, 0x2cc4, + 0x2cc6, 0x2cc6, + 0x2cc8, 0x2cc8, + 0x2cca, 0x2cca, + 0x2ccc, 0x2ccc, + 0x2cce, 0x2cce, + 0x2cd0, 0x2cd0, + 0x2cd2, 0x2cd2, + 0x2cd4, 0x2cd4, + 0x2cd6, 0x2cd6, + 0x2cd8, 0x2cd8, + 0x2cda, 0x2cda, + 0x2cdc, 0x2cdc, + 0x2cde, 0x2cde, + 0x2ce0, 0x2ce0, + 0x2ce2, 0x2ce2, 0xff21, 0xff3a, 0x10400, 0x10427, 0x1d400, 0x1d419, @@ -2796,35 +2504,19 @@ static const OnigCodePoint CRUpper[] = { 0x1d71c, 0x1d734, 0x1d756, 0x1d76e, 0x1d790, 0x1d7a8 -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRUpper */ +}; /* CR_Upper */ -static const OnigCodePoint CRXDigit[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 3, -#else +/* 'XDigit': [[:XDigit:]] */ +static const OnigCodePoint CR_XDigit[] = { 3, -#endif 0x0030, 0x0039, 0x0041, 0x0046, 0x0061, 0x0066 -}; +}; /* CR_XDigit */ -static const OnigCodePoint CRASCII[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 1, -#else - 1, -#endif - 0x0000, 0x007f -}; - -static const OnigCodePoint CRWord[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 436, -#else - 12, -#endif +/* 'Word': [[:Word:]] */ +static const OnigCodePoint CR_Word[] = { + 464, 0x0030, 0x0039, 0x0041, 0x005a, 0x005f, 0x005f, @@ -2836,16 +2528,12 @@ static const OnigCodePoint CRWord[] = { 0x00bc, 0x00be, 0x00c0, 0x00d6, 0x00d8, 0x00f6, -#ifndef USE_UNICODE_FULL_RANGE_CTYPE - 0x00f8, 0x7fffffff -#else /* not USE_UNICODE_FULL_RANGE_CTYPE */ - 0x00f8, 0x0236, + 0x00f8, 0x0241, 0x0250, 0x02c1, 0x02c6, 0x02d1, 0x02e0, 0x02e4, 0x02ee, 0x02ee, - 0x0300, 0x0357, - 0x035d, 0x036f, + 0x0300, 0x036f, 0x037a, 0x037a, 0x0386, 0x0386, 0x0388, 0x038a, @@ -2853,27 +2541,25 @@ static const OnigCodePoint CRWord[] = { 0x038e, 0x03a1, 0x03a3, 0x03ce, 0x03d0, 0x03f5, - 0x03f7, 0x03fb, - 0x0400, 0x0481, + 0x03f7, 0x0481, 0x0483, 0x0486, 0x0488, 0x04ce, - 0x04d0, 0x04f5, - 0x04f8, 0x04f9, + 0x04d0, 0x04f9, 0x0500, 0x050f, 0x0531, 0x0556, 0x0559, 0x0559, 0x0561, 0x0587, - 0x0591, 0x05a1, - 0x05a3, 0x05b9, + 0x0591, 0x05b9, 0x05bb, 0x05bd, 0x05bf, 0x05bf, 0x05c1, 0x05c2, - 0x05c4, 0x05c4, + 0x05c4, 0x05c5, + 0x05c7, 0x05c7, 0x05d0, 0x05ea, 0x05f0, 0x05f2, 0x0610, 0x0615, 0x0621, 0x063a, - 0x0640, 0x0658, + 0x0640, 0x065e, 0x0660, 0x0669, 0x066e, 0x06d3, 0x06d5, 0x06dc, @@ -2881,13 +2567,14 @@ static const OnigCodePoint CRWord[] = { 0x06ea, 0x06fc, 0x06ff, 0x06ff, 0x0710, 0x074a, - 0x074d, 0x074f, + 0x074d, 0x076d, 0x0780, 0x07b1, 0x0901, 0x0939, 0x093c, 0x094d, 0x0950, 0x0954, 0x0958, 0x0963, 0x0966, 0x096f, + 0x097d, 0x097d, 0x0981, 0x0983, 0x0985, 0x098c, 0x098f, 0x0990, @@ -2897,7 +2584,7 @@ static const OnigCodePoint CRWord[] = { 0x09b6, 0x09b9, 0x09bc, 0x09c4, 0x09c7, 0x09c8, - 0x09cb, 0x09cd, + 0x09cb, 0x09ce, 0x09d7, 0x09d7, 0x09dc, 0x09dd, 0x09df, 0x09e3, @@ -2955,13 +2642,12 @@ static const OnigCodePoint CRWord[] = { 0x0b9e, 0x0b9f, 0x0ba3, 0x0ba4, 0x0ba8, 0x0baa, - 0x0bae, 0x0bb5, - 0x0bb7, 0x0bb9, + 0x0bae, 0x0bb9, 0x0bbe, 0x0bc2, 0x0bc6, 0x0bc8, 0x0bca, 0x0bcd, 0x0bd7, 0x0bd7, - 0x0be7, 0x0bf2, + 0x0be6, 0x0bf2, 0x0c01, 0x0c03, 0x0c05, 0x0c0c, 0x0c0e, 0x0c10, @@ -3051,36 +2737,30 @@ static const OnigCodePoint CRWord[] = { 0x1040, 0x1049, 0x1050, 0x1059, 0x10a0, 0x10c5, - 0x10d0, 0x10f8, + 0x10d0, 0x10fa, + 0x10fc, 0x10fc, 0x1100, 0x1159, 0x115f, 0x11a2, 0x11a8, 0x11f9, - 0x1200, 0x1206, - 0x1208, 0x1246, - 0x1248, 0x1248, + 0x1200, 0x1248, 0x124a, 0x124d, 0x1250, 0x1256, 0x1258, 0x1258, 0x125a, 0x125d, - 0x1260, 0x1286, - 0x1288, 0x1288, + 0x1260, 0x1288, 0x128a, 0x128d, - 0x1290, 0x12ae, - 0x12b0, 0x12b0, + 0x1290, 0x12b0, 0x12b2, 0x12b5, 0x12b8, 0x12be, 0x12c0, 0x12c0, 0x12c2, 0x12c5, - 0x12c8, 0x12ce, - 0x12d0, 0x12d6, - 0x12d8, 0x12ee, - 0x12f0, 0x130e, - 0x1310, 0x1310, + 0x12c8, 0x12d6, + 0x12d8, 0x1310, 0x1312, 0x1315, - 0x1318, 0x131e, - 0x1320, 0x1346, - 0x1348, 0x135a, + 0x1318, 0x135a, + 0x135f, 0x135f, 0x1369, 0x137c, + 0x1380, 0x138f, 0x13a0, 0x13f4, 0x1401, 0x166c, 0x166f, 0x1676, @@ -3109,7 +2789,11 @@ static const OnigCodePoint CRWord[] = { 0x1930, 0x193b, 0x1946, 0x196d, 0x1970, 0x1974, - 0x1d00, 0x1d6b, + 0x1980, 0x19a9, + 0x19b0, 0x19c9, + 0x19d0, 0x19d9, + 0x1a00, 0x1a1b, + 0x1d00, 0x1dc3, 0x1e00, 0x1e9b, 0x1ea0, 0x1ef9, 0x1f00, 0x1f15, @@ -3136,7 +2820,8 @@ static const OnigCodePoint CRWord[] = { 0x2070, 0x2071, 0x2074, 0x2079, 0x207f, 0x2089, - 0x20d0, 0x20ea, + 0x2090, 0x2094, + 0x20d0, 0x20eb, 0x2102, 0x2102, 0x2107, 0x2107, 0x210a, 0x2113, @@ -3148,12 +2833,28 @@ static const OnigCodePoint CRWord[] = { 0x212a, 0x212d, 0x212f, 0x2131, 0x2133, 0x2139, - 0x213d, 0x213f, + 0x213c, 0x213f, 0x2145, 0x2149, 0x2153, 0x2183, 0x2460, 0x249b, 0x24ea, 0x24ff, 0x2776, 0x2793, + 0x2c00, 0x2c2e, + 0x2c30, 0x2c5e, + 0x2c80, 0x2ce4, + 0x2cfd, 0x2cfd, + 0x2d00, 0x2d25, + 0x2d30, 0x2d65, + 0x2d6f, 0x2d6f, + 0x2d80, 0x2d96, + 0x2da0, 0x2da6, + 0x2da8, 0x2dae, + 0x2db0, 0x2db6, + 0x2db8, 0x2dbe, + 0x2dc0, 0x2dc6, + 0x2dc8, 0x2dce, + 0x2dd0, 0x2dd6, + 0x2dd8, 0x2dde, 0x3005, 0x3007, 0x3021, 0x302f, 0x3031, 0x3035, @@ -3161,7 +2862,8 @@ static const OnigCodePoint CRWord[] = { 0x3041, 0x3096, 0x3099, 0x309a, 0x309d, 0x309f, - 0x30a1, 0x30ff, + 0x30a1, 0x30fa, + 0x30fc, 0x30ff, 0x3105, 0x312c, 0x3131, 0x318e, 0x3192, 0x3195, @@ -3172,11 +2874,13 @@ static const OnigCodePoint CRWord[] = { 0x3280, 0x3289, 0x32b1, 0x32bf, 0x3400, 0x4db5, - 0x4e00, 0x9fa5, + 0x4e00, 0x9fbb, 0xa000, 0xa48c, + 0xa800, 0xa827, 0xac00, 0xd7a3, 0xf900, 0xfa2d, 0xfa30, 0xfa6a, + 0xfa70, 0xfad9, 0xfb00, 0xfb06, 0xfb13, 0xfb17, 0xfb1d, 0xfb28, @@ -3200,7 +2904,7 @@ static const OnigCodePoint CRWord[] = { 0xff21, 0xff3a, 0xff3f, 0xff3f, 0xff41, 0xff5a, - 0xff65, 0xffbe, + 0xff66, 0xffbe, 0xffc2, 0xffc7, 0xffca, 0xffcf, 0xffd2, 0xffd7, @@ -3213,10 +2917,15 @@ static const OnigCodePoint CRWord[] = { 0x10050, 0x1005d, 0x10080, 0x100fa, 0x10107, 0x10133, + 0x10140, 0x10178, + 0x1018a, 0x1018a, 0x10300, 0x1031e, 0x10320, 0x10323, 0x10330, 0x1034a, 0x10380, 0x1039d, + 0x103a0, 0x103c3, + 0x103c8, 0x103cf, + 0x103d1, 0x103d5, 0x10400, 0x1049d, 0x104a0, 0x104a9, 0x10800, 0x10805, @@ -3225,11 +2934,19 @@ static const OnigCodePoint CRWord[] = { 0x10837, 0x10838, 0x1083c, 0x1083c, 0x1083f, 0x1083f, + 0x10a00, 0x10a03, + 0x10a05, 0x10a06, + 0x10a0c, 0x10a13, + 0x10a15, 0x10a17, + 0x10a19, 0x10a33, + 0x10a38, 0x10a3a, + 0x10a3f, 0x10a47, 0x1d165, 0x1d169, 0x1d16d, 0x1d172, 0x1d17b, 0x1d182, 0x1d185, 0x1d18b, 0x1d1aa, 0x1d1ad, + 0x1d242, 0x1d244, 0x1d400, 0x1d454, 0x1d456, 0x1d49c, 0x1d49e, 0x1d49f, @@ -3248,7 +2965,7 @@ static const OnigCodePoint CRWord[] = { 0x1d540, 0x1d544, 0x1d546, 0x1d546, 0x1d54a, 0x1d550, - 0x1d552, 0x1d6a3, + 0x1d552, 0x1d6a5, 0x1d6a8, 0x1d6c0, 0x1d6c2, 0x1d6da, 0x1d6dc, 0x1d6fa, @@ -3264,140 +2981,8376 @@ static const OnigCodePoint CRWord[] = { 0x20000, 0x2a6d6, 0x2f800, 0x2fa1d, 0xe0100, 0xe01ef -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of CRWord */ - - -extern int -onigenc_unicode_is_code_ctype(OnigCodePoint code, unsigned int ctype) -{ - if (code < 256) { - return ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(code, ctype); - } - -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - - switch (ctype) { - case ONIGENC_CTYPE_ALPHA: - return onig_is_in_code_range((UChar* )CRAlpha, code); - break; - case ONIGENC_CTYPE_BLANK: - return onig_is_in_code_range((UChar* )CRBlank, code); - break; - case ONIGENC_CTYPE_CNTRL: - return onig_is_in_code_range((UChar* )CRCntrl, code); - break; - case ONIGENC_CTYPE_DIGIT: - return onig_is_in_code_range((UChar* )CRDigit, code); - break; - case ONIGENC_CTYPE_GRAPH: - return onig_is_in_code_range((UChar* )CRGraph, code); - break; - case ONIGENC_CTYPE_LOWER: - return onig_is_in_code_range((UChar* )CRLower, code); - break; - case ONIGENC_CTYPE_PRINT: - return onig_is_in_code_range((UChar* )CRPrint, code); - break; - case ONIGENC_CTYPE_PUNCT: - return onig_is_in_code_range((UChar* )CRPunct, code); - break; - case ONIGENC_CTYPE_SPACE: - return onig_is_in_code_range((UChar* )CRSpace, code); - break; - case ONIGENC_CTYPE_UPPER: - return onig_is_in_code_range((UChar* )CRUpper, code); - break; - case ONIGENC_CTYPE_XDIGIT: - return FALSE; - break; - case ONIGENC_CTYPE_WORD: - return onig_is_in_code_range((UChar* )CRWord, code); - break; - case ONIGENC_CTYPE_ASCII: - return FALSE; - break; - case ONIGENC_CTYPE_ALNUM: - return onig_is_in_code_range((UChar* )CRAlnum, code); - break; - case ONIGENC_CTYPE_NEWLINE: - return FALSE; - break; - - default: - return ONIGENCERR_TYPE_BUG; - break; - } - -#else - - if ((ctype & ONIGENC_CTYPE_WORD) != 0) { - return TRUE; - } - return FALSE; -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -} +}; /* CR_Word */ -extern int -onigenc_unicode_get_ctype_code_range(int ctype, - const OnigCodePoint* sbr[], const OnigCodePoint* mbr[]) -{ - static const OnigCodePoint EmptyRange[] = { 0 }; - -#define CR_SET(list) do { \ - *mbr = list; \ -} while (0) - - *sbr = EmptyRange; - - switch (ctype) { - case ONIGENC_CTYPE_ALPHA: - CR_SET(CRAlpha); - break; - case ONIGENC_CTYPE_BLANK: - CR_SET(CRBlank); - break; - case ONIGENC_CTYPE_CNTRL: - CR_SET(CRCntrl); - break; - case ONIGENC_CTYPE_DIGIT: - CR_SET(CRDigit); - break; - case ONIGENC_CTYPE_GRAPH: - CR_SET(CRGraph); - break; - case ONIGENC_CTYPE_LOWER: - CR_SET(CRLower); - break; - case ONIGENC_CTYPE_PRINT: - CR_SET(CRPrint); - break; - case ONIGENC_CTYPE_PUNCT: - CR_SET(CRPunct); - break; - case ONIGENC_CTYPE_SPACE: - CR_SET(CRSpace); - break; - case ONIGENC_CTYPE_UPPER: - CR_SET(CRUpper); - break; - case ONIGENC_CTYPE_XDIGIT: - CR_SET(CRXDigit); - break; - case ONIGENC_CTYPE_WORD: - CR_SET(CRWord); - break; - case ONIGENC_CTYPE_ASCII: - CR_SET(CRASCII); - break; - case ONIGENC_CTYPE_ALNUM: - CR_SET(CRAlnum); - break; - - default: - return ONIGENCERR_TYPE_BUG; - break; - } - - return 0; +/* 'Alnum': [[:Alnum:]] */ +static const OnigCodePoint CR_Alnum[] = { + 436, + 0x0030, 0x0039, + 0x0041, 0x005a, + 0x0061, 0x007a, + 0x00aa, 0x00aa, + 0x00b5, 0x00b5, + 0x00ba, 0x00ba, + 0x00c0, 0x00d6, + 0x00d8, 0x00f6, + 0x00f8, 0x0241, + 0x0250, 0x02c1, + 0x02c6, 0x02d1, + 0x02e0, 0x02e4, + 0x02ee, 0x02ee, + 0x0300, 0x036f, + 0x037a, 0x037a, + 0x0386, 0x0386, + 0x0388, 0x038a, + 0x038c, 0x038c, + 0x038e, 0x03a1, + 0x03a3, 0x03ce, + 0x03d0, 0x03f5, + 0x03f7, 0x0481, + 0x0483, 0x0486, + 0x0488, 0x04ce, + 0x04d0, 0x04f9, + 0x0500, 0x050f, + 0x0531, 0x0556, + 0x0559, 0x0559, + 0x0561, 0x0587, + 0x0591, 0x05b9, + 0x05bb, 0x05bd, + 0x05bf, 0x05bf, + 0x05c1, 0x05c2, + 0x05c4, 0x05c5, + 0x05c7, 0x05c7, + 0x05d0, 0x05ea, + 0x05f0, 0x05f2, + 0x0610, 0x0615, + 0x0621, 0x063a, + 0x0640, 0x065e, + 0x0660, 0x0669, + 0x066e, 0x06d3, + 0x06d5, 0x06dc, + 0x06de, 0x06e8, + 0x06ea, 0x06fc, + 0x06ff, 0x06ff, + 0x0710, 0x074a, + 0x074d, 0x076d, + 0x0780, 0x07b1, + 0x0901, 0x0939, + 0x093c, 0x094d, + 0x0950, 0x0954, + 0x0958, 0x0963, + 0x0966, 0x096f, + 0x097d, 0x097d, + 0x0981, 0x0983, + 0x0985, 0x098c, + 0x098f, 0x0990, + 0x0993, 0x09a8, + 0x09aa, 0x09b0, + 0x09b2, 0x09b2, + 0x09b6, 0x09b9, + 0x09bc, 0x09c4, + 0x09c7, 0x09c8, + 0x09cb, 0x09ce, + 0x09d7, 0x09d7, + 0x09dc, 0x09dd, + 0x09df, 0x09e3, + 0x09e6, 0x09f1, + 0x0a01, 0x0a03, + 0x0a05, 0x0a0a, + 0x0a0f, 0x0a10, + 0x0a13, 0x0a28, + 0x0a2a, 0x0a30, + 0x0a32, 0x0a33, + 0x0a35, 0x0a36, + 0x0a38, 0x0a39, + 0x0a3c, 0x0a3c, + 0x0a3e, 0x0a42, + 0x0a47, 0x0a48, + 0x0a4b, 0x0a4d, + 0x0a59, 0x0a5c, + 0x0a5e, 0x0a5e, + 0x0a66, 0x0a74, + 0x0a81, 0x0a83, + 0x0a85, 0x0a8d, + 0x0a8f, 0x0a91, + 0x0a93, 0x0aa8, + 0x0aaa, 0x0ab0, + 0x0ab2, 0x0ab3, + 0x0ab5, 0x0ab9, + 0x0abc, 0x0ac5, + 0x0ac7, 0x0ac9, + 0x0acb, 0x0acd, + 0x0ad0, 0x0ad0, + 0x0ae0, 0x0ae3, + 0x0ae6, 0x0aef, + 0x0b01, 0x0b03, + 0x0b05, 0x0b0c, + 0x0b0f, 0x0b10, + 0x0b13, 0x0b28, + 0x0b2a, 0x0b30, + 0x0b32, 0x0b33, + 0x0b35, 0x0b39, + 0x0b3c, 0x0b43, + 0x0b47, 0x0b48, + 0x0b4b, 0x0b4d, + 0x0b56, 0x0b57, + 0x0b5c, 0x0b5d, + 0x0b5f, 0x0b61, + 0x0b66, 0x0b6f, + 0x0b71, 0x0b71, + 0x0b82, 0x0b83, + 0x0b85, 0x0b8a, + 0x0b8e, 0x0b90, + 0x0b92, 0x0b95, + 0x0b99, 0x0b9a, + 0x0b9c, 0x0b9c, + 0x0b9e, 0x0b9f, + 0x0ba3, 0x0ba4, + 0x0ba8, 0x0baa, + 0x0bae, 0x0bb9, + 0x0bbe, 0x0bc2, + 0x0bc6, 0x0bc8, + 0x0bca, 0x0bcd, + 0x0bd7, 0x0bd7, + 0x0be6, 0x0bef, + 0x0c01, 0x0c03, + 0x0c05, 0x0c0c, + 0x0c0e, 0x0c10, + 0x0c12, 0x0c28, + 0x0c2a, 0x0c33, + 0x0c35, 0x0c39, + 0x0c3e, 0x0c44, + 0x0c46, 0x0c48, + 0x0c4a, 0x0c4d, + 0x0c55, 0x0c56, + 0x0c60, 0x0c61, + 0x0c66, 0x0c6f, + 0x0c82, 0x0c83, + 0x0c85, 0x0c8c, + 0x0c8e, 0x0c90, + 0x0c92, 0x0ca8, + 0x0caa, 0x0cb3, + 0x0cb5, 0x0cb9, + 0x0cbc, 0x0cc4, + 0x0cc6, 0x0cc8, + 0x0cca, 0x0ccd, + 0x0cd5, 0x0cd6, + 0x0cde, 0x0cde, + 0x0ce0, 0x0ce1, + 0x0ce6, 0x0cef, + 0x0d02, 0x0d03, + 0x0d05, 0x0d0c, + 0x0d0e, 0x0d10, + 0x0d12, 0x0d28, + 0x0d2a, 0x0d39, + 0x0d3e, 0x0d43, + 0x0d46, 0x0d48, + 0x0d4a, 0x0d4d, + 0x0d57, 0x0d57, + 0x0d60, 0x0d61, + 0x0d66, 0x0d6f, + 0x0d82, 0x0d83, + 0x0d85, 0x0d96, + 0x0d9a, 0x0db1, + 0x0db3, 0x0dbb, + 0x0dbd, 0x0dbd, + 0x0dc0, 0x0dc6, + 0x0dca, 0x0dca, + 0x0dcf, 0x0dd4, + 0x0dd6, 0x0dd6, + 0x0dd8, 0x0ddf, + 0x0df2, 0x0df3, + 0x0e01, 0x0e3a, + 0x0e40, 0x0e4e, + 0x0e50, 0x0e59, + 0x0e81, 0x0e82, + 0x0e84, 0x0e84, + 0x0e87, 0x0e88, + 0x0e8a, 0x0e8a, + 0x0e8d, 0x0e8d, + 0x0e94, 0x0e97, + 0x0e99, 0x0e9f, + 0x0ea1, 0x0ea3, + 0x0ea5, 0x0ea5, + 0x0ea7, 0x0ea7, + 0x0eaa, 0x0eab, + 0x0ead, 0x0eb9, + 0x0ebb, 0x0ebd, + 0x0ec0, 0x0ec4, + 0x0ec6, 0x0ec6, + 0x0ec8, 0x0ecd, + 0x0ed0, 0x0ed9, + 0x0edc, 0x0edd, + 0x0f00, 0x0f00, + 0x0f18, 0x0f19, + 0x0f20, 0x0f29, + 0x0f35, 0x0f35, + 0x0f37, 0x0f37, + 0x0f39, 0x0f39, + 0x0f3e, 0x0f47, + 0x0f49, 0x0f6a, + 0x0f71, 0x0f84, + 0x0f86, 0x0f8b, + 0x0f90, 0x0f97, + 0x0f99, 0x0fbc, + 0x0fc6, 0x0fc6, + 0x1000, 0x1021, + 0x1023, 0x1027, + 0x1029, 0x102a, + 0x102c, 0x1032, + 0x1036, 0x1039, + 0x1040, 0x1049, + 0x1050, 0x1059, + 0x10a0, 0x10c5, + 0x10d0, 0x10fa, + 0x10fc, 0x10fc, + 0x1100, 0x1159, + 0x115f, 0x11a2, + 0x11a8, 0x11f9, + 0x1200, 0x1248, + 0x124a, 0x124d, + 0x1250, 0x1256, + 0x1258, 0x1258, + 0x125a, 0x125d, + 0x1260, 0x1288, + 0x128a, 0x128d, + 0x1290, 0x12b0, + 0x12b2, 0x12b5, + 0x12b8, 0x12be, + 0x12c0, 0x12c0, + 0x12c2, 0x12c5, + 0x12c8, 0x12d6, + 0x12d8, 0x1310, + 0x1312, 0x1315, + 0x1318, 0x135a, + 0x135f, 0x135f, + 0x1380, 0x138f, + 0x13a0, 0x13f4, + 0x1401, 0x166c, + 0x166f, 0x1676, + 0x1681, 0x169a, + 0x16a0, 0x16ea, + 0x1700, 0x170c, + 0x170e, 0x1714, + 0x1720, 0x1734, + 0x1740, 0x1753, + 0x1760, 0x176c, + 0x176e, 0x1770, + 0x1772, 0x1773, + 0x1780, 0x17b3, + 0x17b6, 0x17d3, + 0x17d7, 0x17d7, + 0x17dc, 0x17dd, + 0x17e0, 0x17e9, + 0x180b, 0x180d, + 0x1810, 0x1819, + 0x1820, 0x1877, + 0x1880, 0x18a9, + 0x1900, 0x191c, + 0x1920, 0x192b, + 0x1930, 0x193b, + 0x1946, 0x196d, + 0x1970, 0x1974, + 0x1980, 0x19a9, + 0x19b0, 0x19c9, + 0x19d0, 0x19d9, + 0x1a00, 0x1a1b, + 0x1d00, 0x1dc3, + 0x1e00, 0x1e9b, + 0x1ea0, 0x1ef9, + 0x1f00, 0x1f15, + 0x1f18, 0x1f1d, + 0x1f20, 0x1f45, + 0x1f48, 0x1f4d, + 0x1f50, 0x1f57, + 0x1f59, 0x1f59, + 0x1f5b, 0x1f5b, + 0x1f5d, 0x1f5d, + 0x1f5f, 0x1f7d, + 0x1f80, 0x1fb4, + 0x1fb6, 0x1fbc, + 0x1fbe, 0x1fbe, + 0x1fc2, 0x1fc4, + 0x1fc6, 0x1fcc, + 0x1fd0, 0x1fd3, + 0x1fd6, 0x1fdb, + 0x1fe0, 0x1fec, + 0x1ff2, 0x1ff4, + 0x1ff6, 0x1ffc, + 0x2071, 0x2071, + 0x207f, 0x207f, + 0x2090, 0x2094, + 0x20d0, 0x20eb, + 0x2102, 0x2102, + 0x2107, 0x2107, + 0x210a, 0x2113, + 0x2115, 0x2115, + 0x2119, 0x211d, + 0x2124, 0x2124, + 0x2126, 0x2126, + 0x2128, 0x2128, + 0x212a, 0x212d, + 0x212f, 0x2131, + 0x2133, 0x2139, + 0x213c, 0x213f, + 0x2145, 0x2149, + 0x2c00, 0x2c2e, + 0x2c30, 0x2c5e, + 0x2c80, 0x2ce4, + 0x2d00, 0x2d25, + 0x2d30, 0x2d65, + 0x2d6f, 0x2d6f, + 0x2d80, 0x2d96, + 0x2da0, 0x2da6, + 0x2da8, 0x2dae, + 0x2db0, 0x2db6, + 0x2db8, 0x2dbe, + 0x2dc0, 0x2dc6, + 0x2dc8, 0x2dce, + 0x2dd0, 0x2dd6, + 0x2dd8, 0x2dde, + 0x3005, 0x3006, + 0x302a, 0x302f, + 0x3031, 0x3035, + 0x303b, 0x303c, + 0x3041, 0x3096, + 0x3099, 0x309a, + 0x309d, 0x309f, + 0x30a1, 0x30fa, + 0x30fc, 0x30ff, + 0x3105, 0x312c, + 0x3131, 0x318e, + 0x31a0, 0x31b7, + 0x31f0, 0x31ff, + 0x3400, 0x4db5, + 0x4e00, 0x9fbb, + 0xa000, 0xa48c, + 0xa800, 0xa827, + 0xac00, 0xd7a3, + 0xf900, 0xfa2d, + 0xfa30, 0xfa6a, + 0xfa70, 0xfad9, + 0xfb00, 0xfb06, + 0xfb13, 0xfb17, + 0xfb1d, 0xfb28, + 0xfb2a, 0xfb36, + 0xfb38, 0xfb3c, + 0xfb3e, 0xfb3e, + 0xfb40, 0xfb41, + 0xfb43, 0xfb44, + 0xfb46, 0xfbb1, + 0xfbd3, 0xfd3d, + 0xfd50, 0xfd8f, + 0xfd92, 0xfdc7, + 0xfdf0, 0xfdfb, + 0xfe00, 0xfe0f, + 0xfe20, 0xfe23, + 0xfe70, 0xfe74, + 0xfe76, 0xfefc, + 0xff10, 0xff19, + 0xff21, 0xff3a, + 0xff41, 0xff5a, + 0xff66, 0xffbe, + 0xffc2, 0xffc7, + 0xffca, 0xffcf, + 0xffd2, 0xffd7, + 0xffda, 0xffdc, + 0x10000, 0x1000b, + 0x1000d, 0x10026, + 0x10028, 0x1003a, + 0x1003c, 0x1003d, + 0x1003f, 0x1004d, + 0x10050, 0x1005d, + 0x10080, 0x100fa, + 0x10300, 0x1031e, + 0x10330, 0x10349, + 0x10380, 0x1039d, + 0x103a0, 0x103c3, + 0x103c8, 0x103cf, + 0x10400, 0x1049d, + 0x104a0, 0x104a9, + 0x10800, 0x10805, + 0x10808, 0x10808, + 0x1080a, 0x10835, + 0x10837, 0x10838, + 0x1083c, 0x1083c, + 0x1083f, 0x1083f, + 0x10a00, 0x10a03, + 0x10a05, 0x10a06, + 0x10a0c, 0x10a13, + 0x10a15, 0x10a17, + 0x10a19, 0x10a33, + 0x10a38, 0x10a3a, + 0x10a3f, 0x10a3f, + 0x1d165, 0x1d169, + 0x1d16d, 0x1d172, + 0x1d17b, 0x1d182, + 0x1d185, 0x1d18b, + 0x1d1aa, 0x1d1ad, + 0x1d242, 0x1d244, + 0x1d400, 0x1d454, + 0x1d456, 0x1d49c, + 0x1d49e, 0x1d49f, + 0x1d4a2, 0x1d4a2, + 0x1d4a5, 0x1d4a6, + 0x1d4a9, 0x1d4ac, + 0x1d4ae, 0x1d4b9, + 0x1d4bb, 0x1d4bb, + 0x1d4bd, 0x1d4c3, + 0x1d4c5, 0x1d505, + 0x1d507, 0x1d50a, + 0x1d50d, 0x1d514, + 0x1d516, 0x1d51c, + 0x1d51e, 0x1d539, + 0x1d53b, 0x1d53e, + 0x1d540, 0x1d544, + 0x1d546, 0x1d546, + 0x1d54a, 0x1d550, + 0x1d552, 0x1d6a5, + 0x1d6a8, 0x1d6c0, + 0x1d6c2, 0x1d6da, + 0x1d6dc, 0x1d6fa, + 0x1d6fc, 0x1d714, + 0x1d716, 0x1d734, + 0x1d736, 0x1d74e, + 0x1d750, 0x1d76e, + 0x1d770, 0x1d788, + 0x1d78a, 0x1d7a8, + 0x1d7aa, 0x1d7c2, + 0x1d7c4, 0x1d7c9, + 0x1d7ce, 0x1d7ff, + 0x20000, 0x2a6d6, + 0x2f800, 0x2fa1d, + 0xe0100, 0xe01ef +}; /* CR_Alnum */ + +/* 'ASCII': [[:ASCII:]] */ +static const OnigCodePoint CR_ASCII[] = { + 1, + 0x0000, 0x007f +}; /* CR_ASCII */ + +#ifdef USE_UNICODE_PROPERTIES + +/* 'Any': - */ +static const OnigCodePoint CR_Any[] = { + 1, + 0x0000, 0x10ffff +}; /* CR_Any */ + +/* 'Assigned': - */ +static const OnigCodePoint CR_Assigned[] = { + 420, + 0x0000, 0x0241, + 0x0250, 0x036f, + 0x0374, 0x0375, + 0x037a, 0x037a, + 0x037e, 0x037e, + 0x0384, 0x038a, + 0x038c, 0x038c, + 0x038e, 0x03a1, + 0x03a3, 0x03ce, + 0x03d0, 0x0486, + 0x0488, 0x04ce, + 0x04d0, 0x04f9, + 0x0500, 0x050f, + 0x0531, 0x0556, + 0x0559, 0x055f, + 0x0561, 0x0587, + 0x0589, 0x058a, + 0x0591, 0x05b9, + 0x05bb, 0x05c7, + 0x05d0, 0x05ea, + 0x05f0, 0x05f4, + 0x0600, 0x0603, + 0x060b, 0x0615, + 0x061b, 0x061b, + 0x061e, 0x061f, + 0x0621, 0x063a, + 0x0640, 0x065e, + 0x0660, 0x070d, + 0x070f, 0x074a, + 0x074d, 0x076d, + 0x0780, 0x07b1, + 0x0901, 0x0939, + 0x093c, 0x094d, + 0x0950, 0x0954, + 0x0958, 0x0970, + 0x097d, 0x097d, + 0x0981, 0x0983, + 0x0985, 0x098c, + 0x098f, 0x0990, + 0x0993, 0x09a8, + 0x09aa, 0x09b0, + 0x09b2, 0x09b2, + 0x09b6, 0x09b9, + 0x09bc, 0x09c4, + 0x09c7, 0x09c8, + 0x09cb, 0x09ce, + 0x09d7, 0x09d7, + 0x09dc, 0x09dd, + 0x09df, 0x09e3, + 0x09e6, 0x09fa, + 0x0a01, 0x0a03, + 0x0a05, 0x0a0a, + 0x0a0f, 0x0a10, + 0x0a13, 0x0a28, + 0x0a2a, 0x0a30, + 0x0a32, 0x0a33, + 0x0a35, 0x0a36, + 0x0a38, 0x0a39, + 0x0a3c, 0x0a3c, + 0x0a3e, 0x0a42, + 0x0a47, 0x0a48, + 0x0a4b, 0x0a4d, + 0x0a59, 0x0a5c, + 0x0a5e, 0x0a5e, + 0x0a66, 0x0a74, + 0x0a81, 0x0a83, + 0x0a85, 0x0a8d, + 0x0a8f, 0x0a91, + 0x0a93, 0x0aa8, + 0x0aaa, 0x0ab0, + 0x0ab2, 0x0ab3, + 0x0ab5, 0x0ab9, + 0x0abc, 0x0ac5, + 0x0ac7, 0x0ac9, + 0x0acb, 0x0acd, + 0x0ad0, 0x0ad0, + 0x0ae0, 0x0ae3, + 0x0ae6, 0x0aef, + 0x0af1, 0x0af1, + 0x0b01, 0x0b03, + 0x0b05, 0x0b0c, + 0x0b0f, 0x0b10, + 0x0b13, 0x0b28, + 0x0b2a, 0x0b30, + 0x0b32, 0x0b33, + 0x0b35, 0x0b39, + 0x0b3c, 0x0b43, + 0x0b47, 0x0b48, + 0x0b4b, 0x0b4d, + 0x0b56, 0x0b57, + 0x0b5c, 0x0b5d, + 0x0b5f, 0x0b61, + 0x0b66, 0x0b71, + 0x0b82, 0x0b83, + 0x0b85, 0x0b8a, + 0x0b8e, 0x0b90, + 0x0b92, 0x0b95, + 0x0b99, 0x0b9a, + 0x0b9c, 0x0b9c, + 0x0b9e, 0x0b9f, + 0x0ba3, 0x0ba4, + 0x0ba8, 0x0baa, + 0x0bae, 0x0bb9, + 0x0bbe, 0x0bc2, + 0x0bc6, 0x0bc8, + 0x0bca, 0x0bcd, + 0x0bd7, 0x0bd7, + 0x0be6, 0x0bfa, + 0x0c01, 0x0c03, + 0x0c05, 0x0c0c, + 0x0c0e, 0x0c10, + 0x0c12, 0x0c28, + 0x0c2a, 0x0c33, + 0x0c35, 0x0c39, + 0x0c3e, 0x0c44, + 0x0c46, 0x0c48, + 0x0c4a, 0x0c4d, + 0x0c55, 0x0c56, + 0x0c60, 0x0c61, + 0x0c66, 0x0c6f, + 0x0c82, 0x0c83, + 0x0c85, 0x0c8c, + 0x0c8e, 0x0c90, + 0x0c92, 0x0ca8, + 0x0caa, 0x0cb3, + 0x0cb5, 0x0cb9, + 0x0cbc, 0x0cc4, + 0x0cc6, 0x0cc8, + 0x0cca, 0x0ccd, + 0x0cd5, 0x0cd6, + 0x0cde, 0x0cde, + 0x0ce0, 0x0ce1, + 0x0ce6, 0x0cef, + 0x0d02, 0x0d03, + 0x0d05, 0x0d0c, + 0x0d0e, 0x0d10, + 0x0d12, 0x0d28, + 0x0d2a, 0x0d39, + 0x0d3e, 0x0d43, + 0x0d46, 0x0d48, + 0x0d4a, 0x0d4d, + 0x0d57, 0x0d57, + 0x0d60, 0x0d61, + 0x0d66, 0x0d6f, + 0x0d82, 0x0d83, + 0x0d85, 0x0d96, + 0x0d9a, 0x0db1, + 0x0db3, 0x0dbb, + 0x0dbd, 0x0dbd, + 0x0dc0, 0x0dc6, + 0x0dca, 0x0dca, + 0x0dcf, 0x0dd4, + 0x0dd6, 0x0dd6, + 0x0dd8, 0x0ddf, + 0x0df2, 0x0df4, + 0x0e01, 0x0e3a, + 0x0e3f, 0x0e5b, + 0x0e81, 0x0e82, + 0x0e84, 0x0e84, + 0x0e87, 0x0e88, + 0x0e8a, 0x0e8a, + 0x0e8d, 0x0e8d, + 0x0e94, 0x0e97, + 0x0e99, 0x0e9f, + 0x0ea1, 0x0ea3, + 0x0ea5, 0x0ea5, + 0x0ea7, 0x0ea7, + 0x0eaa, 0x0eab, + 0x0ead, 0x0eb9, + 0x0ebb, 0x0ebd, + 0x0ec0, 0x0ec4, + 0x0ec6, 0x0ec6, + 0x0ec8, 0x0ecd, + 0x0ed0, 0x0ed9, + 0x0edc, 0x0edd, + 0x0f00, 0x0f47, + 0x0f49, 0x0f6a, + 0x0f71, 0x0f8b, + 0x0f90, 0x0f97, + 0x0f99, 0x0fbc, + 0x0fbe, 0x0fcc, + 0x0fcf, 0x0fd1, + 0x1000, 0x1021, + 0x1023, 0x1027, + 0x1029, 0x102a, + 0x102c, 0x1032, + 0x1036, 0x1039, + 0x1040, 0x1059, + 0x10a0, 0x10c5, + 0x10d0, 0x10fc, + 0x1100, 0x1159, + 0x115f, 0x11a2, + 0x11a8, 0x11f9, + 0x1200, 0x1248, + 0x124a, 0x124d, + 0x1250, 0x1256, + 0x1258, 0x1258, + 0x125a, 0x125d, + 0x1260, 0x1288, + 0x128a, 0x128d, + 0x1290, 0x12b0, + 0x12b2, 0x12b5, + 0x12b8, 0x12be, + 0x12c0, 0x12c0, + 0x12c2, 0x12c5, + 0x12c8, 0x12d6, + 0x12d8, 0x1310, + 0x1312, 0x1315, + 0x1318, 0x135a, + 0x135f, 0x137c, + 0x1380, 0x1399, + 0x13a0, 0x13f4, + 0x1401, 0x1676, + 0x1680, 0x169c, + 0x16a0, 0x16f0, + 0x1700, 0x170c, + 0x170e, 0x1714, + 0x1720, 0x1736, + 0x1740, 0x1753, + 0x1760, 0x176c, + 0x176e, 0x1770, + 0x1772, 0x1773, + 0x1780, 0x17dd, + 0x17e0, 0x17e9, + 0x17f0, 0x17f9, + 0x1800, 0x180e, + 0x1810, 0x1819, + 0x1820, 0x1877, + 0x1880, 0x18a9, + 0x1900, 0x191c, + 0x1920, 0x192b, + 0x1930, 0x193b, + 0x1940, 0x1940, + 0x1944, 0x196d, + 0x1970, 0x1974, + 0x1980, 0x19a9, + 0x19b0, 0x19c9, + 0x19d0, 0x19d9, + 0x19de, 0x1a1b, + 0x1a1e, 0x1a1f, + 0x1d00, 0x1dc3, + 0x1e00, 0x1e9b, + 0x1ea0, 0x1ef9, + 0x1f00, 0x1f15, + 0x1f18, 0x1f1d, + 0x1f20, 0x1f45, + 0x1f48, 0x1f4d, + 0x1f50, 0x1f57, + 0x1f59, 0x1f59, + 0x1f5b, 0x1f5b, + 0x1f5d, 0x1f5d, + 0x1f5f, 0x1f7d, + 0x1f80, 0x1fb4, + 0x1fb6, 0x1fc4, + 0x1fc6, 0x1fd3, + 0x1fd6, 0x1fdb, + 0x1fdd, 0x1fef, + 0x1ff2, 0x1ff4, + 0x1ff6, 0x1ffe, + 0x2000, 0x2063, + 0x206a, 0x2071, + 0x2074, 0x208e, + 0x2090, 0x2094, + 0x20a0, 0x20b5, + 0x20d0, 0x20eb, + 0x2100, 0x214c, + 0x2153, 0x2183, + 0x2190, 0x23db, + 0x2400, 0x2426, + 0x2440, 0x244a, + 0x2460, 0x269c, + 0x26a0, 0x26b1, + 0x2701, 0x2704, + 0x2706, 0x2709, + 0x270c, 0x2727, + 0x2729, 0x274b, + 0x274d, 0x274d, + 0x274f, 0x2752, + 0x2756, 0x2756, + 0x2758, 0x275e, + 0x2761, 0x2794, + 0x2798, 0x27af, + 0x27b1, 0x27be, + 0x27c0, 0x27c6, + 0x27d0, 0x27eb, + 0x27f0, 0x2b13, + 0x2c00, 0x2c2e, + 0x2c30, 0x2c5e, + 0x2c80, 0x2cea, + 0x2cf9, 0x2d25, + 0x2d30, 0x2d65, + 0x2d6f, 0x2d6f, + 0x2d80, 0x2d96, + 0x2da0, 0x2da6, + 0x2da8, 0x2dae, + 0x2db0, 0x2db6, + 0x2db8, 0x2dbe, + 0x2dc0, 0x2dc6, + 0x2dc8, 0x2dce, + 0x2dd0, 0x2dd6, + 0x2dd8, 0x2dde, + 0x2e00, 0x2e17, + 0x2e1c, 0x2e1d, + 0x2e80, 0x2e99, + 0x2e9b, 0x2ef3, + 0x2f00, 0x2fd5, + 0x2ff0, 0x2ffb, + 0x3000, 0x303f, + 0x3041, 0x3096, + 0x3099, 0x30ff, + 0x3105, 0x312c, + 0x3131, 0x318e, + 0x3190, 0x31b7, + 0x31c0, 0x31cf, + 0x31f0, 0x321e, + 0x3220, 0x3243, + 0x3250, 0x32fe, + 0x3300, 0x4db5, + 0x4dc0, 0x9fbb, + 0xa000, 0xa48c, + 0xa490, 0xa4c6, + 0xa700, 0xa716, + 0xa800, 0xa82b, + 0xac00, 0xd7a3, + 0xd800, 0xfa2d, + 0xfa30, 0xfa6a, + 0xfa70, 0xfad9, + 0xfb00, 0xfb06, + 0xfb13, 0xfb17, + 0xfb1d, 0xfb36, + 0xfb38, 0xfb3c, + 0xfb3e, 0xfb3e, + 0xfb40, 0xfb41, + 0xfb43, 0xfb44, + 0xfb46, 0xfbb1, + 0xfbd3, 0xfd3f, + 0xfd50, 0xfd8f, + 0xfd92, 0xfdc7, + 0xfdf0, 0xfdfd, + 0xfe00, 0xfe19, + 0xfe20, 0xfe23, + 0xfe30, 0xfe52, + 0xfe54, 0xfe66, + 0xfe68, 0xfe6b, + 0xfe70, 0xfe74, + 0xfe76, 0xfefc, + 0xfeff, 0xfeff, + 0xff01, 0xffbe, + 0xffc2, 0xffc7, + 0xffca, 0xffcf, + 0xffd2, 0xffd7, + 0xffda, 0xffdc, + 0xffe0, 0xffe6, + 0xffe8, 0xffee, + 0xfff9, 0xfffd, + 0x10000, 0x1000b, + 0x1000d, 0x10026, + 0x10028, 0x1003a, + 0x1003c, 0x1003d, + 0x1003f, 0x1004d, + 0x10050, 0x1005d, + 0x10080, 0x100fa, + 0x10100, 0x10102, + 0x10107, 0x10133, + 0x10137, 0x1018a, + 0x10300, 0x1031e, + 0x10320, 0x10323, + 0x10330, 0x1034a, + 0x10380, 0x1039d, + 0x1039f, 0x103c3, + 0x103c8, 0x103d5, + 0x10400, 0x1049d, + 0x104a0, 0x104a9, + 0x10800, 0x10805, + 0x10808, 0x10808, + 0x1080a, 0x10835, + 0x10837, 0x10838, + 0x1083c, 0x1083c, + 0x1083f, 0x1083f, + 0x10a00, 0x10a03, + 0x10a05, 0x10a06, + 0x10a0c, 0x10a13, + 0x10a15, 0x10a17, + 0x10a19, 0x10a33, + 0x10a38, 0x10a3a, + 0x10a3f, 0x10a47, + 0x10a50, 0x10a58, + 0x1d000, 0x1d0f5, + 0x1d100, 0x1d126, + 0x1d12a, 0x1d1dd, + 0x1d200, 0x1d245, + 0x1d300, 0x1d356, + 0x1d400, 0x1d454, + 0x1d456, 0x1d49c, + 0x1d49e, 0x1d49f, + 0x1d4a2, 0x1d4a2, + 0x1d4a5, 0x1d4a6, + 0x1d4a9, 0x1d4ac, + 0x1d4ae, 0x1d4b9, + 0x1d4bb, 0x1d4bb, + 0x1d4bd, 0x1d4c3, + 0x1d4c5, 0x1d505, + 0x1d507, 0x1d50a, + 0x1d50d, 0x1d514, + 0x1d516, 0x1d51c, + 0x1d51e, 0x1d539, + 0x1d53b, 0x1d53e, + 0x1d540, 0x1d544, + 0x1d546, 0x1d546, + 0x1d54a, 0x1d550, + 0x1d552, 0x1d6a5, + 0x1d6a8, 0x1d7c9, + 0x1d7ce, 0x1d7ff, + 0x20000, 0x2a6d6, + 0x2f800, 0x2fa1d, + 0xe0001, 0xe0001, + 0xe0020, 0xe007f, + 0xe0100, 0xe01ef, + 0xf0000, 0xffffd, + 0x100000, 0x10fffd +}; /* CR_Assigned */ + +/* 'C': Major Category */ +static const OnigCodePoint CR_C[] = { + 422, + 0x0000, 0x001f, + 0x007f, 0x009f, + 0x00ad, 0x00ad, + 0x0242, 0x024f, + 0x0370, 0x0373, + 0x0376, 0x0379, + 0x037b, 0x037d, + 0x037f, 0x0383, + 0x038b, 0x038b, + 0x038d, 0x038d, + 0x03a2, 0x03a2, + 0x03cf, 0x03cf, + 0x0487, 0x0487, + 0x04cf, 0x04cf, + 0x04fa, 0x04ff, + 0x0510, 0x0530, + 0x0557, 0x0558, + 0x0560, 0x0560, + 0x0588, 0x0588, + 0x058b, 0x0590, + 0x05ba, 0x05ba, + 0x05c8, 0x05cf, + 0x05eb, 0x05ef, + 0x05f5, 0x060a, + 0x0616, 0x061a, + 0x061c, 0x061d, + 0x0620, 0x0620, + 0x063b, 0x063f, + 0x065f, 0x065f, + 0x06dd, 0x06dd, + 0x070e, 0x070f, + 0x074b, 0x074c, + 0x076e, 0x077f, + 0x07b2, 0x0900, + 0x093a, 0x093b, + 0x094e, 0x094f, + 0x0955, 0x0957, + 0x0971, 0x097c, + 0x097e, 0x0980, + 0x0984, 0x0984, + 0x098d, 0x098e, + 0x0991, 0x0992, + 0x09a9, 0x09a9, + 0x09b1, 0x09b1, + 0x09b3, 0x09b5, + 0x09ba, 0x09bb, + 0x09c5, 0x09c6, + 0x09c9, 0x09ca, + 0x09cf, 0x09d6, + 0x09d8, 0x09db, + 0x09de, 0x09de, + 0x09e4, 0x09e5, + 0x09fb, 0x0a00, + 0x0a04, 0x0a04, + 0x0a0b, 0x0a0e, + 0x0a11, 0x0a12, + 0x0a29, 0x0a29, + 0x0a31, 0x0a31, + 0x0a34, 0x0a34, + 0x0a37, 0x0a37, + 0x0a3a, 0x0a3b, + 0x0a3d, 0x0a3d, + 0x0a43, 0x0a46, + 0x0a49, 0x0a4a, + 0x0a4e, 0x0a58, + 0x0a5d, 0x0a5d, + 0x0a5f, 0x0a65, + 0x0a75, 0x0a80, + 0x0a84, 0x0a84, + 0x0a8e, 0x0a8e, + 0x0a92, 0x0a92, + 0x0aa9, 0x0aa9, + 0x0ab1, 0x0ab1, + 0x0ab4, 0x0ab4, + 0x0aba, 0x0abb, + 0x0ac6, 0x0ac6, + 0x0aca, 0x0aca, + 0x0ace, 0x0acf, + 0x0ad1, 0x0adf, + 0x0ae4, 0x0ae5, + 0x0af0, 0x0af0, + 0x0af2, 0x0b00, + 0x0b04, 0x0b04, + 0x0b0d, 0x0b0e, + 0x0b11, 0x0b12, + 0x0b29, 0x0b29, + 0x0b31, 0x0b31, + 0x0b34, 0x0b34, + 0x0b3a, 0x0b3b, + 0x0b44, 0x0b46, + 0x0b49, 0x0b4a, + 0x0b4e, 0x0b55, + 0x0b58, 0x0b5b, + 0x0b5e, 0x0b5e, + 0x0b62, 0x0b65, + 0x0b72, 0x0b81, + 0x0b84, 0x0b84, + 0x0b8b, 0x0b8d, + 0x0b91, 0x0b91, + 0x0b96, 0x0b98, + 0x0b9b, 0x0b9b, + 0x0b9d, 0x0b9d, + 0x0ba0, 0x0ba2, + 0x0ba5, 0x0ba7, + 0x0bab, 0x0bad, + 0x0bba, 0x0bbd, + 0x0bc3, 0x0bc5, + 0x0bc9, 0x0bc9, + 0x0bce, 0x0bd6, + 0x0bd8, 0x0be5, + 0x0bfb, 0x0c00, + 0x0c04, 0x0c04, + 0x0c0d, 0x0c0d, + 0x0c11, 0x0c11, + 0x0c29, 0x0c29, + 0x0c34, 0x0c34, + 0x0c3a, 0x0c3d, + 0x0c45, 0x0c45, + 0x0c49, 0x0c49, + 0x0c4e, 0x0c54, + 0x0c57, 0x0c5f, + 0x0c62, 0x0c65, + 0x0c70, 0x0c81, + 0x0c84, 0x0c84, + 0x0c8d, 0x0c8d, + 0x0c91, 0x0c91, + 0x0ca9, 0x0ca9, + 0x0cb4, 0x0cb4, + 0x0cba, 0x0cbb, + 0x0cc5, 0x0cc5, + 0x0cc9, 0x0cc9, + 0x0cce, 0x0cd4, + 0x0cd7, 0x0cdd, + 0x0cdf, 0x0cdf, + 0x0ce2, 0x0ce5, + 0x0cf0, 0x0d01, + 0x0d04, 0x0d04, + 0x0d0d, 0x0d0d, + 0x0d11, 0x0d11, + 0x0d29, 0x0d29, + 0x0d3a, 0x0d3d, + 0x0d44, 0x0d45, + 0x0d49, 0x0d49, + 0x0d4e, 0x0d56, + 0x0d58, 0x0d5f, + 0x0d62, 0x0d65, + 0x0d70, 0x0d81, + 0x0d84, 0x0d84, + 0x0d97, 0x0d99, + 0x0db2, 0x0db2, + 0x0dbc, 0x0dbc, + 0x0dbe, 0x0dbf, + 0x0dc7, 0x0dc9, + 0x0dcb, 0x0dce, + 0x0dd5, 0x0dd5, + 0x0dd7, 0x0dd7, + 0x0de0, 0x0df1, + 0x0df5, 0x0e00, + 0x0e3b, 0x0e3e, + 0x0e5c, 0x0e80, + 0x0e83, 0x0e83, + 0x0e85, 0x0e86, + 0x0e89, 0x0e89, + 0x0e8b, 0x0e8c, + 0x0e8e, 0x0e93, + 0x0e98, 0x0e98, + 0x0ea0, 0x0ea0, + 0x0ea4, 0x0ea4, + 0x0ea6, 0x0ea6, + 0x0ea8, 0x0ea9, + 0x0eac, 0x0eac, + 0x0eba, 0x0eba, + 0x0ebe, 0x0ebf, + 0x0ec5, 0x0ec5, + 0x0ec7, 0x0ec7, + 0x0ece, 0x0ecf, + 0x0eda, 0x0edb, + 0x0ede, 0x0eff, + 0x0f48, 0x0f48, + 0x0f6b, 0x0f70, + 0x0f8c, 0x0f8f, + 0x0f98, 0x0f98, + 0x0fbd, 0x0fbd, + 0x0fcd, 0x0fce, + 0x0fd2, 0x0fff, + 0x1022, 0x1022, + 0x1028, 0x1028, + 0x102b, 0x102b, + 0x1033, 0x1035, + 0x103a, 0x103f, + 0x105a, 0x109f, + 0x10c6, 0x10cf, + 0x10fd, 0x10ff, + 0x115a, 0x115e, + 0x11a3, 0x11a7, + 0x11fa, 0x11ff, + 0x1249, 0x1249, + 0x124e, 0x124f, + 0x1257, 0x1257, + 0x1259, 0x1259, + 0x125e, 0x125f, + 0x1289, 0x1289, + 0x128e, 0x128f, + 0x12b1, 0x12b1, + 0x12b6, 0x12b7, + 0x12bf, 0x12bf, + 0x12c1, 0x12c1, + 0x12c6, 0x12c7, + 0x12d7, 0x12d7, + 0x1311, 0x1311, + 0x1316, 0x1317, + 0x135b, 0x135e, + 0x137d, 0x137f, + 0x139a, 0x139f, + 0x13f5, 0x1400, + 0x1677, 0x167f, + 0x169d, 0x169f, + 0x16f1, 0x16ff, + 0x170d, 0x170d, + 0x1715, 0x171f, + 0x1737, 0x173f, + 0x1754, 0x175f, + 0x176d, 0x176d, + 0x1771, 0x1771, + 0x1774, 0x177f, + 0x17b4, 0x17b5, + 0x17de, 0x17df, + 0x17ea, 0x17ef, + 0x17fa, 0x17ff, + 0x180f, 0x180f, + 0x181a, 0x181f, + 0x1878, 0x187f, + 0x18aa, 0x18ff, + 0x191d, 0x191f, + 0x192c, 0x192f, + 0x193c, 0x193f, + 0x1941, 0x1943, + 0x196e, 0x196f, + 0x1975, 0x197f, + 0x19aa, 0x19af, + 0x19ca, 0x19cf, + 0x19da, 0x19dd, + 0x1a1c, 0x1a1d, + 0x1a20, 0x1cff, + 0x1dc4, 0x1dff, + 0x1e9c, 0x1e9f, + 0x1efa, 0x1eff, + 0x1f16, 0x1f17, + 0x1f1e, 0x1f1f, + 0x1f46, 0x1f47, + 0x1f4e, 0x1f4f, + 0x1f58, 0x1f58, + 0x1f5a, 0x1f5a, + 0x1f5c, 0x1f5c, + 0x1f5e, 0x1f5e, + 0x1f7e, 0x1f7f, + 0x1fb5, 0x1fb5, + 0x1fc5, 0x1fc5, + 0x1fd4, 0x1fd5, + 0x1fdc, 0x1fdc, + 0x1ff0, 0x1ff1, + 0x1ff5, 0x1ff5, + 0x1fff, 0x1fff, + 0x200b, 0x200f, + 0x202a, 0x202e, + 0x2060, 0x206f, + 0x2072, 0x2073, + 0x208f, 0x208f, + 0x2095, 0x209f, + 0x20b6, 0x20cf, + 0x20ec, 0x20ff, + 0x214d, 0x2152, + 0x2184, 0x218f, + 0x23dc, 0x23ff, + 0x2427, 0x243f, + 0x244b, 0x245f, + 0x269d, 0x269f, + 0x26b2, 0x2700, + 0x2705, 0x2705, + 0x270a, 0x270b, + 0x2728, 0x2728, + 0x274c, 0x274c, + 0x274e, 0x274e, + 0x2753, 0x2755, + 0x2757, 0x2757, + 0x275f, 0x2760, + 0x2795, 0x2797, + 0x27b0, 0x27b0, + 0x27bf, 0x27bf, + 0x27c7, 0x27cf, + 0x27ec, 0x27ef, + 0x2b14, 0x2bff, + 0x2c2f, 0x2c2f, + 0x2c5f, 0x2c7f, + 0x2ceb, 0x2cf8, + 0x2d26, 0x2d2f, + 0x2d66, 0x2d6e, + 0x2d70, 0x2d7f, + 0x2d97, 0x2d9f, + 0x2da7, 0x2da7, + 0x2daf, 0x2daf, + 0x2db7, 0x2db7, + 0x2dbf, 0x2dbf, + 0x2dc7, 0x2dc7, + 0x2dcf, 0x2dcf, + 0x2dd7, 0x2dd7, + 0x2ddf, 0x2dff, + 0x2e18, 0x2e1b, + 0x2e1e, 0x2e7f, + 0x2e9a, 0x2e9a, + 0x2ef4, 0x2eff, + 0x2fd6, 0x2fef, + 0x2ffc, 0x2fff, + 0x3040, 0x3040, + 0x3097, 0x3098, + 0x3100, 0x3104, + 0x312d, 0x3130, + 0x318f, 0x318f, + 0x31b8, 0x31bf, + 0x31d0, 0x31ef, + 0x321f, 0x321f, + 0x3244, 0x324f, + 0x32ff, 0x32ff, + 0x4db6, 0x4dbf, + 0x9fbc, 0x9fff, + 0xa48d, 0xa48f, + 0xa4c7, 0xa6ff, + 0xa717, 0xa7ff, + 0xa82c, 0xabff, + 0xd7a4, 0xf8ff, + 0xfa2e, 0xfa2f, + 0xfa6b, 0xfa6f, + 0xfada, 0xfaff, + 0xfb07, 0xfb12, + 0xfb18, 0xfb1c, + 0xfb37, 0xfb37, + 0xfb3d, 0xfb3d, + 0xfb3f, 0xfb3f, + 0xfb42, 0xfb42, + 0xfb45, 0xfb45, + 0xfbb2, 0xfbd2, + 0xfd40, 0xfd4f, + 0xfd90, 0xfd91, + 0xfdc8, 0xfdef, + 0xfdfe, 0xfdff, + 0xfe1a, 0xfe1f, + 0xfe24, 0xfe2f, + 0xfe53, 0xfe53, + 0xfe67, 0xfe67, + 0xfe6c, 0xfe6f, + 0xfe75, 0xfe75, + 0xfefd, 0xff00, + 0xffbf, 0xffc1, + 0xffc8, 0xffc9, + 0xffd0, 0xffd1, + 0xffd8, 0xffd9, + 0xffdd, 0xffdf, + 0xffe7, 0xffe7, + 0xffef, 0xfffb, + 0xfffe, 0xffff, + 0x1000c, 0x1000c, + 0x10027, 0x10027, + 0x1003b, 0x1003b, + 0x1003e, 0x1003e, + 0x1004e, 0x1004f, + 0x1005e, 0x1007f, + 0x100fb, 0x100ff, + 0x10103, 0x10106, + 0x10134, 0x10136, + 0x1018b, 0x102ff, + 0x1031f, 0x1031f, + 0x10324, 0x1032f, + 0x1034b, 0x1037f, + 0x1039e, 0x1039e, + 0x103c4, 0x103c7, + 0x103d6, 0x103ff, + 0x1049e, 0x1049f, + 0x104aa, 0x107ff, + 0x10806, 0x10807, + 0x10809, 0x10809, + 0x10836, 0x10836, + 0x10839, 0x1083b, + 0x1083d, 0x1083e, + 0x10840, 0x109ff, + 0x10a04, 0x10a04, + 0x10a07, 0x10a0b, + 0x10a14, 0x10a14, + 0x10a18, 0x10a18, + 0x10a34, 0x10a37, + 0x10a3b, 0x10a3e, + 0x10a48, 0x10a4f, + 0x10a59, 0x1cfff, + 0x1d0f6, 0x1d0ff, + 0x1d127, 0x1d129, + 0x1d173, 0x1d17a, + 0x1d1de, 0x1d1ff, + 0x1d246, 0x1d2ff, + 0x1d357, 0x1d3ff, + 0x1d455, 0x1d455, + 0x1d49d, 0x1d49d, + 0x1d4a0, 0x1d4a1, + 0x1d4a3, 0x1d4a4, + 0x1d4a7, 0x1d4a8, + 0x1d4ad, 0x1d4ad, + 0x1d4ba, 0x1d4ba, + 0x1d4bc, 0x1d4bc, + 0x1d4c4, 0x1d4c4, + 0x1d506, 0x1d506, + 0x1d50b, 0x1d50c, + 0x1d515, 0x1d515, + 0x1d51d, 0x1d51d, + 0x1d53a, 0x1d53a, + 0x1d53f, 0x1d53f, + 0x1d545, 0x1d545, + 0x1d547, 0x1d549, + 0x1d551, 0x1d551, + 0x1d6a6, 0x1d6a7, + 0x1d7ca, 0x1d7cd, + 0x1d800, 0x1ffff, + 0x2a6d7, 0x2f7ff, + 0x2fa1e, 0xe00ff, + 0xe01f0, 0x10ffff +}; /* CR_C */ + +/* 'Cc': General Category */ +static const OnigCodePoint CR_Cc[] = { + 2, + 0x0000, 0x001f, + 0x007f, 0x009f +}; /* CR_Cc */ + +/* 'Cf': General Category */ +static const OnigCodePoint CR_Cf[] = { + 14, + 0x00ad, 0x00ad, + 0x0600, 0x0603, + 0x06dd, 0x06dd, + 0x070f, 0x070f, + 0x17b4, 0x17b5, + 0x200b, 0x200f, + 0x202a, 0x202e, + 0x2060, 0x2063, + 0x206a, 0x206f, + 0xfeff, 0xfeff, + 0xfff9, 0xfffb, + 0x1d173, 0x1d17a, + 0xe0001, 0xe0001, + 0xe0020, 0xe007f +}; /* CR_Cf */ + +/* 'Cn': General Category */ +static const OnigCodePoint CR_Cn[] = { + 420, + 0x0242, 0x024f, + 0x0370, 0x0373, + 0x0376, 0x0379, + 0x037b, 0x037d, + 0x037f, 0x0383, + 0x038b, 0x038b, + 0x038d, 0x038d, + 0x03a2, 0x03a2, + 0x03cf, 0x03cf, + 0x0487, 0x0487, + 0x04cf, 0x04cf, + 0x04fa, 0x04ff, + 0x0510, 0x0530, + 0x0557, 0x0558, + 0x0560, 0x0560, + 0x0588, 0x0588, + 0x058b, 0x0590, + 0x05ba, 0x05ba, + 0x05c8, 0x05cf, + 0x05eb, 0x05ef, + 0x05f5, 0x05ff, + 0x0604, 0x060a, + 0x0616, 0x061a, + 0x061c, 0x061d, + 0x0620, 0x0620, + 0x063b, 0x063f, + 0x065f, 0x065f, + 0x070e, 0x070e, + 0x074b, 0x074c, + 0x076e, 0x077f, + 0x07b2, 0x0900, + 0x093a, 0x093b, + 0x094e, 0x094f, + 0x0955, 0x0957, + 0x0971, 0x097c, + 0x097e, 0x0980, + 0x0984, 0x0984, + 0x098d, 0x098e, + 0x0991, 0x0992, + 0x09a9, 0x09a9, + 0x09b1, 0x09b1, + 0x09b3, 0x09b5, + 0x09ba, 0x09bb, + 0x09c5, 0x09c6, + 0x09c9, 0x09ca, + 0x09cf, 0x09d6, + 0x09d8, 0x09db, + 0x09de, 0x09de, + 0x09e4, 0x09e5, + 0x09fb, 0x0a00, + 0x0a04, 0x0a04, + 0x0a0b, 0x0a0e, + 0x0a11, 0x0a12, + 0x0a29, 0x0a29, + 0x0a31, 0x0a31, + 0x0a34, 0x0a34, + 0x0a37, 0x0a37, + 0x0a3a, 0x0a3b, + 0x0a3d, 0x0a3d, + 0x0a43, 0x0a46, + 0x0a49, 0x0a4a, + 0x0a4e, 0x0a58, + 0x0a5d, 0x0a5d, + 0x0a5f, 0x0a65, + 0x0a75, 0x0a80, + 0x0a84, 0x0a84, + 0x0a8e, 0x0a8e, + 0x0a92, 0x0a92, + 0x0aa9, 0x0aa9, + 0x0ab1, 0x0ab1, + 0x0ab4, 0x0ab4, + 0x0aba, 0x0abb, + 0x0ac6, 0x0ac6, + 0x0aca, 0x0aca, + 0x0ace, 0x0acf, + 0x0ad1, 0x0adf, + 0x0ae4, 0x0ae5, + 0x0af0, 0x0af0, + 0x0af2, 0x0b00, + 0x0b04, 0x0b04, + 0x0b0d, 0x0b0e, + 0x0b11, 0x0b12, + 0x0b29, 0x0b29, + 0x0b31, 0x0b31, + 0x0b34, 0x0b34, + 0x0b3a, 0x0b3b, + 0x0b44, 0x0b46, + 0x0b49, 0x0b4a, + 0x0b4e, 0x0b55, + 0x0b58, 0x0b5b, + 0x0b5e, 0x0b5e, + 0x0b62, 0x0b65, + 0x0b72, 0x0b81, + 0x0b84, 0x0b84, + 0x0b8b, 0x0b8d, + 0x0b91, 0x0b91, + 0x0b96, 0x0b98, + 0x0b9b, 0x0b9b, + 0x0b9d, 0x0b9d, + 0x0ba0, 0x0ba2, + 0x0ba5, 0x0ba7, + 0x0bab, 0x0bad, + 0x0bba, 0x0bbd, + 0x0bc3, 0x0bc5, + 0x0bc9, 0x0bc9, + 0x0bce, 0x0bd6, + 0x0bd8, 0x0be5, + 0x0bfb, 0x0c00, + 0x0c04, 0x0c04, + 0x0c0d, 0x0c0d, + 0x0c11, 0x0c11, + 0x0c29, 0x0c29, + 0x0c34, 0x0c34, + 0x0c3a, 0x0c3d, + 0x0c45, 0x0c45, + 0x0c49, 0x0c49, + 0x0c4e, 0x0c54, + 0x0c57, 0x0c5f, + 0x0c62, 0x0c65, + 0x0c70, 0x0c81, + 0x0c84, 0x0c84, + 0x0c8d, 0x0c8d, + 0x0c91, 0x0c91, + 0x0ca9, 0x0ca9, + 0x0cb4, 0x0cb4, + 0x0cba, 0x0cbb, + 0x0cc5, 0x0cc5, + 0x0cc9, 0x0cc9, + 0x0cce, 0x0cd4, + 0x0cd7, 0x0cdd, + 0x0cdf, 0x0cdf, + 0x0ce2, 0x0ce5, + 0x0cf0, 0x0d01, + 0x0d04, 0x0d04, + 0x0d0d, 0x0d0d, + 0x0d11, 0x0d11, + 0x0d29, 0x0d29, + 0x0d3a, 0x0d3d, + 0x0d44, 0x0d45, + 0x0d49, 0x0d49, + 0x0d4e, 0x0d56, + 0x0d58, 0x0d5f, + 0x0d62, 0x0d65, + 0x0d70, 0x0d81, + 0x0d84, 0x0d84, + 0x0d97, 0x0d99, + 0x0db2, 0x0db2, + 0x0dbc, 0x0dbc, + 0x0dbe, 0x0dbf, + 0x0dc7, 0x0dc9, + 0x0dcb, 0x0dce, + 0x0dd5, 0x0dd5, + 0x0dd7, 0x0dd7, + 0x0de0, 0x0df1, + 0x0df5, 0x0e00, + 0x0e3b, 0x0e3e, + 0x0e5c, 0x0e80, + 0x0e83, 0x0e83, + 0x0e85, 0x0e86, + 0x0e89, 0x0e89, + 0x0e8b, 0x0e8c, + 0x0e8e, 0x0e93, + 0x0e98, 0x0e98, + 0x0ea0, 0x0ea0, + 0x0ea4, 0x0ea4, + 0x0ea6, 0x0ea6, + 0x0ea8, 0x0ea9, + 0x0eac, 0x0eac, + 0x0eba, 0x0eba, + 0x0ebe, 0x0ebf, + 0x0ec5, 0x0ec5, + 0x0ec7, 0x0ec7, + 0x0ece, 0x0ecf, + 0x0eda, 0x0edb, + 0x0ede, 0x0eff, + 0x0f48, 0x0f48, + 0x0f6b, 0x0f70, + 0x0f8c, 0x0f8f, + 0x0f98, 0x0f98, + 0x0fbd, 0x0fbd, + 0x0fcd, 0x0fce, + 0x0fd2, 0x0fff, + 0x1022, 0x1022, + 0x1028, 0x1028, + 0x102b, 0x102b, + 0x1033, 0x1035, + 0x103a, 0x103f, + 0x105a, 0x109f, + 0x10c6, 0x10cf, + 0x10fd, 0x10ff, + 0x115a, 0x115e, + 0x11a3, 0x11a7, + 0x11fa, 0x11ff, + 0x1249, 0x1249, + 0x124e, 0x124f, + 0x1257, 0x1257, + 0x1259, 0x1259, + 0x125e, 0x125f, + 0x1289, 0x1289, + 0x128e, 0x128f, + 0x12b1, 0x12b1, + 0x12b6, 0x12b7, + 0x12bf, 0x12bf, + 0x12c1, 0x12c1, + 0x12c6, 0x12c7, + 0x12d7, 0x12d7, + 0x1311, 0x1311, + 0x1316, 0x1317, + 0x135b, 0x135e, + 0x137d, 0x137f, + 0x139a, 0x139f, + 0x13f5, 0x1400, + 0x1677, 0x167f, + 0x169d, 0x169f, + 0x16f1, 0x16ff, + 0x170d, 0x170d, + 0x1715, 0x171f, + 0x1737, 0x173f, + 0x1754, 0x175f, + 0x176d, 0x176d, + 0x1771, 0x1771, + 0x1774, 0x177f, + 0x17de, 0x17df, + 0x17ea, 0x17ef, + 0x17fa, 0x17ff, + 0x180f, 0x180f, + 0x181a, 0x181f, + 0x1878, 0x187f, + 0x18aa, 0x18ff, + 0x191d, 0x191f, + 0x192c, 0x192f, + 0x193c, 0x193f, + 0x1941, 0x1943, + 0x196e, 0x196f, + 0x1975, 0x197f, + 0x19aa, 0x19af, + 0x19ca, 0x19cf, + 0x19da, 0x19dd, + 0x1a1c, 0x1a1d, + 0x1a20, 0x1cff, + 0x1dc4, 0x1dff, + 0x1e9c, 0x1e9f, + 0x1efa, 0x1eff, + 0x1f16, 0x1f17, + 0x1f1e, 0x1f1f, + 0x1f46, 0x1f47, + 0x1f4e, 0x1f4f, + 0x1f58, 0x1f58, + 0x1f5a, 0x1f5a, + 0x1f5c, 0x1f5c, + 0x1f5e, 0x1f5e, + 0x1f7e, 0x1f7f, + 0x1fb5, 0x1fb5, + 0x1fc5, 0x1fc5, + 0x1fd4, 0x1fd5, + 0x1fdc, 0x1fdc, + 0x1ff0, 0x1ff1, + 0x1ff5, 0x1ff5, + 0x1fff, 0x1fff, + 0x2064, 0x2069, + 0x2072, 0x2073, + 0x208f, 0x208f, + 0x2095, 0x209f, + 0x20b6, 0x20cf, + 0x20ec, 0x20ff, + 0x214d, 0x2152, + 0x2184, 0x218f, + 0x23dc, 0x23ff, + 0x2427, 0x243f, + 0x244b, 0x245f, + 0x269d, 0x269f, + 0x26b2, 0x2700, + 0x2705, 0x2705, + 0x270a, 0x270b, + 0x2728, 0x2728, + 0x274c, 0x274c, + 0x274e, 0x274e, + 0x2753, 0x2755, + 0x2757, 0x2757, + 0x275f, 0x2760, + 0x2795, 0x2797, + 0x27b0, 0x27b0, + 0x27bf, 0x27bf, + 0x27c7, 0x27cf, + 0x27ec, 0x27ef, + 0x2b14, 0x2bff, + 0x2c2f, 0x2c2f, + 0x2c5f, 0x2c7f, + 0x2ceb, 0x2cf8, + 0x2d26, 0x2d2f, + 0x2d66, 0x2d6e, + 0x2d70, 0x2d7f, + 0x2d97, 0x2d9f, + 0x2da7, 0x2da7, + 0x2daf, 0x2daf, + 0x2db7, 0x2db7, + 0x2dbf, 0x2dbf, + 0x2dc7, 0x2dc7, + 0x2dcf, 0x2dcf, + 0x2dd7, 0x2dd7, + 0x2ddf, 0x2dff, + 0x2e18, 0x2e1b, + 0x2e1e, 0x2e7f, + 0x2e9a, 0x2e9a, + 0x2ef4, 0x2eff, + 0x2fd6, 0x2fef, + 0x2ffc, 0x2fff, + 0x3040, 0x3040, + 0x3097, 0x3098, + 0x3100, 0x3104, + 0x312d, 0x3130, + 0x318f, 0x318f, + 0x31b8, 0x31bf, + 0x31d0, 0x31ef, + 0x321f, 0x321f, + 0x3244, 0x324f, + 0x32ff, 0x32ff, + 0x4db6, 0x4dbf, + 0x9fbc, 0x9fff, + 0xa48d, 0xa48f, + 0xa4c7, 0xa6ff, + 0xa717, 0xa7ff, + 0xa82c, 0xabff, + 0xd7a4, 0xd7ff, + 0xfa2e, 0xfa2f, + 0xfa6b, 0xfa6f, + 0xfada, 0xfaff, + 0xfb07, 0xfb12, + 0xfb18, 0xfb1c, + 0xfb37, 0xfb37, + 0xfb3d, 0xfb3d, + 0xfb3f, 0xfb3f, + 0xfb42, 0xfb42, + 0xfb45, 0xfb45, + 0xfbb2, 0xfbd2, + 0xfd40, 0xfd4f, + 0xfd90, 0xfd91, + 0xfdc8, 0xfdef, + 0xfdfe, 0xfdff, + 0xfe1a, 0xfe1f, + 0xfe24, 0xfe2f, + 0xfe53, 0xfe53, + 0xfe67, 0xfe67, + 0xfe6c, 0xfe6f, + 0xfe75, 0xfe75, + 0xfefd, 0xfefe, + 0xff00, 0xff00, + 0xffbf, 0xffc1, + 0xffc8, 0xffc9, + 0xffd0, 0xffd1, + 0xffd8, 0xffd9, + 0xffdd, 0xffdf, + 0xffe7, 0xffe7, + 0xffef, 0xfff8, + 0xfffe, 0xffff, + 0x1000c, 0x1000c, + 0x10027, 0x10027, + 0x1003b, 0x1003b, + 0x1003e, 0x1003e, + 0x1004e, 0x1004f, + 0x1005e, 0x1007f, + 0x100fb, 0x100ff, + 0x10103, 0x10106, + 0x10134, 0x10136, + 0x1018b, 0x102ff, + 0x1031f, 0x1031f, + 0x10324, 0x1032f, + 0x1034b, 0x1037f, + 0x1039e, 0x1039e, + 0x103c4, 0x103c7, + 0x103d6, 0x103ff, + 0x1049e, 0x1049f, + 0x104aa, 0x107ff, + 0x10806, 0x10807, + 0x10809, 0x10809, + 0x10836, 0x10836, + 0x10839, 0x1083b, + 0x1083d, 0x1083e, + 0x10840, 0x109ff, + 0x10a04, 0x10a04, + 0x10a07, 0x10a0b, + 0x10a14, 0x10a14, + 0x10a18, 0x10a18, + 0x10a34, 0x10a37, + 0x10a3b, 0x10a3e, + 0x10a48, 0x10a4f, + 0x10a59, 0x1cfff, + 0x1d0f6, 0x1d0ff, + 0x1d127, 0x1d129, + 0x1d1de, 0x1d1ff, + 0x1d246, 0x1d2ff, + 0x1d357, 0x1d3ff, + 0x1d455, 0x1d455, + 0x1d49d, 0x1d49d, + 0x1d4a0, 0x1d4a1, + 0x1d4a3, 0x1d4a4, + 0x1d4a7, 0x1d4a8, + 0x1d4ad, 0x1d4ad, + 0x1d4ba, 0x1d4ba, + 0x1d4bc, 0x1d4bc, + 0x1d4c4, 0x1d4c4, + 0x1d506, 0x1d506, + 0x1d50b, 0x1d50c, + 0x1d515, 0x1d515, + 0x1d51d, 0x1d51d, + 0x1d53a, 0x1d53a, + 0x1d53f, 0x1d53f, + 0x1d545, 0x1d545, + 0x1d547, 0x1d549, + 0x1d551, 0x1d551, + 0x1d6a6, 0x1d6a7, + 0x1d7ca, 0x1d7cd, + 0x1d800, 0x1ffff, + 0x2a6d7, 0x2f7ff, + 0x2fa1e, 0xe0000, + 0xe0002, 0xe001f, + 0xe0080, 0xe00ff, + 0xe01f0, 0xeffff, + 0xffffe, 0xfffff, + 0x10fffe, 0x10ffff +}; /* CR_Cn */ + +/* 'Co': General Category */ +static const OnigCodePoint CR_Co[] = { + 3, + 0xe000, 0xf8ff, + 0xf0000, 0xffffd, + 0x100000, 0x10fffd +}; /* CR_Co */ + +/* 'Cs': General Category */ +static const OnigCodePoint CR_Cs[] = { + 1, + 0xd800, 0xdfff +}; /* CR_Cs */ + +/* 'L': Major Category */ +static const OnigCodePoint CR_L[] = { + 347, + 0x0041, 0x005a, + 0x0061, 0x007a, + 0x00aa, 0x00aa, + 0x00b5, 0x00b5, + 0x00ba, 0x00ba, + 0x00c0, 0x00d6, + 0x00d8, 0x00f6, + 0x00f8, 0x0241, + 0x0250, 0x02c1, + 0x02c6, 0x02d1, + 0x02e0, 0x02e4, + 0x02ee, 0x02ee, + 0x037a, 0x037a, + 0x0386, 0x0386, + 0x0388, 0x038a, + 0x038c, 0x038c, + 0x038e, 0x03a1, + 0x03a3, 0x03ce, + 0x03d0, 0x03f5, + 0x03f7, 0x0481, + 0x048a, 0x04ce, + 0x04d0, 0x04f9, + 0x0500, 0x050f, + 0x0531, 0x0556, + 0x0559, 0x0559, + 0x0561, 0x0587, + 0x05d0, 0x05ea, + 0x05f0, 0x05f2, + 0x0621, 0x063a, + 0x0640, 0x064a, + 0x066e, 0x066f, + 0x0671, 0x06d3, + 0x06d5, 0x06d5, + 0x06e5, 0x06e6, + 0x06ee, 0x06ef, + 0x06fa, 0x06fc, + 0x06ff, 0x06ff, + 0x0710, 0x0710, + 0x0712, 0x072f, + 0x074d, 0x076d, + 0x0780, 0x07a5, + 0x07b1, 0x07b1, + 0x0904, 0x0939, + 0x093d, 0x093d, + 0x0950, 0x0950, + 0x0958, 0x0961, + 0x097d, 0x097d, + 0x0985, 0x098c, + 0x098f, 0x0990, + 0x0993, 0x09a8, + 0x09aa, 0x09b0, + 0x09b2, 0x09b2, + 0x09b6, 0x09b9, + 0x09bd, 0x09bd, + 0x09ce, 0x09ce, + 0x09dc, 0x09dd, + 0x09df, 0x09e1, + 0x09f0, 0x09f1, + 0x0a05, 0x0a0a, + 0x0a0f, 0x0a10, + 0x0a13, 0x0a28, + 0x0a2a, 0x0a30, + 0x0a32, 0x0a33, + 0x0a35, 0x0a36, + 0x0a38, 0x0a39, + 0x0a59, 0x0a5c, + 0x0a5e, 0x0a5e, + 0x0a72, 0x0a74, + 0x0a85, 0x0a8d, + 0x0a8f, 0x0a91, + 0x0a93, 0x0aa8, + 0x0aaa, 0x0ab0, + 0x0ab2, 0x0ab3, + 0x0ab5, 0x0ab9, + 0x0abd, 0x0abd, + 0x0ad0, 0x0ad0, + 0x0ae0, 0x0ae1, + 0x0b05, 0x0b0c, + 0x0b0f, 0x0b10, + 0x0b13, 0x0b28, + 0x0b2a, 0x0b30, + 0x0b32, 0x0b33, + 0x0b35, 0x0b39, + 0x0b3d, 0x0b3d, + 0x0b5c, 0x0b5d, + 0x0b5f, 0x0b61, + 0x0b71, 0x0b71, + 0x0b83, 0x0b83, + 0x0b85, 0x0b8a, + 0x0b8e, 0x0b90, + 0x0b92, 0x0b95, + 0x0b99, 0x0b9a, + 0x0b9c, 0x0b9c, + 0x0b9e, 0x0b9f, + 0x0ba3, 0x0ba4, + 0x0ba8, 0x0baa, + 0x0bae, 0x0bb9, + 0x0c05, 0x0c0c, + 0x0c0e, 0x0c10, + 0x0c12, 0x0c28, + 0x0c2a, 0x0c33, + 0x0c35, 0x0c39, + 0x0c60, 0x0c61, + 0x0c85, 0x0c8c, + 0x0c8e, 0x0c90, + 0x0c92, 0x0ca8, + 0x0caa, 0x0cb3, + 0x0cb5, 0x0cb9, + 0x0cbd, 0x0cbd, + 0x0cde, 0x0cde, + 0x0ce0, 0x0ce1, + 0x0d05, 0x0d0c, + 0x0d0e, 0x0d10, + 0x0d12, 0x0d28, + 0x0d2a, 0x0d39, + 0x0d60, 0x0d61, + 0x0d85, 0x0d96, + 0x0d9a, 0x0db1, + 0x0db3, 0x0dbb, + 0x0dbd, 0x0dbd, + 0x0dc0, 0x0dc6, + 0x0e01, 0x0e30, + 0x0e32, 0x0e33, + 0x0e40, 0x0e46, + 0x0e81, 0x0e82, + 0x0e84, 0x0e84, + 0x0e87, 0x0e88, + 0x0e8a, 0x0e8a, + 0x0e8d, 0x0e8d, + 0x0e94, 0x0e97, + 0x0e99, 0x0e9f, + 0x0ea1, 0x0ea3, + 0x0ea5, 0x0ea5, + 0x0ea7, 0x0ea7, + 0x0eaa, 0x0eab, + 0x0ead, 0x0eb0, + 0x0eb2, 0x0eb3, + 0x0ebd, 0x0ebd, + 0x0ec0, 0x0ec4, + 0x0ec6, 0x0ec6, + 0x0edc, 0x0edd, + 0x0f00, 0x0f00, + 0x0f40, 0x0f47, + 0x0f49, 0x0f6a, + 0x0f88, 0x0f8b, + 0x1000, 0x1021, + 0x1023, 0x1027, + 0x1029, 0x102a, + 0x1050, 0x1055, + 0x10a0, 0x10c5, + 0x10d0, 0x10fa, + 0x10fc, 0x10fc, + 0x1100, 0x1159, + 0x115f, 0x11a2, + 0x11a8, 0x11f9, + 0x1200, 0x1248, + 0x124a, 0x124d, + 0x1250, 0x1256, + 0x1258, 0x1258, + 0x125a, 0x125d, + 0x1260, 0x1288, + 0x128a, 0x128d, + 0x1290, 0x12b0, + 0x12b2, 0x12b5, + 0x12b8, 0x12be, + 0x12c0, 0x12c0, + 0x12c2, 0x12c5, + 0x12c8, 0x12d6, + 0x12d8, 0x1310, + 0x1312, 0x1315, + 0x1318, 0x135a, + 0x1380, 0x138f, + 0x13a0, 0x13f4, + 0x1401, 0x166c, + 0x166f, 0x1676, + 0x1681, 0x169a, + 0x16a0, 0x16ea, + 0x1700, 0x170c, + 0x170e, 0x1711, + 0x1720, 0x1731, + 0x1740, 0x1751, + 0x1760, 0x176c, + 0x176e, 0x1770, + 0x1780, 0x17b3, + 0x17d7, 0x17d7, + 0x17dc, 0x17dc, + 0x1820, 0x1877, + 0x1880, 0x18a8, + 0x1900, 0x191c, + 0x1950, 0x196d, + 0x1970, 0x1974, + 0x1980, 0x19a9, + 0x19c1, 0x19c7, + 0x1a00, 0x1a16, + 0x1d00, 0x1dbf, + 0x1e00, 0x1e9b, + 0x1ea0, 0x1ef9, + 0x1f00, 0x1f15, + 0x1f18, 0x1f1d, + 0x1f20, 0x1f45, + 0x1f48, 0x1f4d, + 0x1f50, 0x1f57, + 0x1f59, 0x1f59, + 0x1f5b, 0x1f5b, + 0x1f5d, 0x1f5d, + 0x1f5f, 0x1f7d, + 0x1f80, 0x1fb4, + 0x1fb6, 0x1fbc, + 0x1fbe, 0x1fbe, + 0x1fc2, 0x1fc4, + 0x1fc6, 0x1fcc, + 0x1fd0, 0x1fd3, + 0x1fd6, 0x1fdb, + 0x1fe0, 0x1fec, + 0x1ff2, 0x1ff4, + 0x1ff6, 0x1ffc, + 0x2071, 0x2071, + 0x207f, 0x207f, + 0x2090, 0x2094, + 0x2102, 0x2102, + 0x2107, 0x2107, + 0x210a, 0x2113, + 0x2115, 0x2115, + 0x2119, 0x211d, + 0x2124, 0x2124, + 0x2126, 0x2126, + 0x2128, 0x2128, + 0x212a, 0x212d, + 0x212f, 0x2131, + 0x2133, 0x2139, + 0x213c, 0x213f, + 0x2145, 0x2149, + 0x2c00, 0x2c2e, + 0x2c30, 0x2c5e, + 0x2c80, 0x2ce4, + 0x2d00, 0x2d25, + 0x2d30, 0x2d65, + 0x2d6f, 0x2d6f, + 0x2d80, 0x2d96, + 0x2da0, 0x2da6, + 0x2da8, 0x2dae, + 0x2db0, 0x2db6, + 0x2db8, 0x2dbe, + 0x2dc0, 0x2dc6, + 0x2dc8, 0x2dce, + 0x2dd0, 0x2dd6, + 0x2dd8, 0x2dde, + 0x3005, 0x3006, + 0x3031, 0x3035, + 0x303b, 0x303c, + 0x3041, 0x3096, + 0x309d, 0x309f, + 0x30a1, 0x30fa, + 0x30fc, 0x30ff, + 0x3105, 0x312c, + 0x3131, 0x318e, + 0x31a0, 0x31b7, + 0x31f0, 0x31ff, + 0x3400, 0x4db5, + 0x4e00, 0x9fbb, + 0xa000, 0xa48c, + 0xa800, 0xa801, + 0xa803, 0xa805, + 0xa807, 0xa80a, + 0xa80c, 0xa822, + 0xac00, 0xd7a3, + 0xf900, 0xfa2d, + 0xfa30, 0xfa6a, + 0xfa70, 0xfad9, + 0xfb00, 0xfb06, + 0xfb13, 0xfb17, + 0xfb1d, 0xfb1d, + 0xfb1f, 0xfb28, + 0xfb2a, 0xfb36, + 0xfb38, 0xfb3c, + 0xfb3e, 0xfb3e, + 0xfb40, 0xfb41, + 0xfb43, 0xfb44, + 0xfb46, 0xfbb1, + 0xfbd3, 0xfd3d, + 0xfd50, 0xfd8f, + 0xfd92, 0xfdc7, + 0xfdf0, 0xfdfb, + 0xfe70, 0xfe74, + 0xfe76, 0xfefc, + 0xff21, 0xff3a, + 0xff41, 0xff5a, + 0xff66, 0xffbe, + 0xffc2, 0xffc7, + 0xffca, 0xffcf, + 0xffd2, 0xffd7, + 0xffda, 0xffdc, + 0x10000, 0x1000b, + 0x1000d, 0x10026, + 0x10028, 0x1003a, + 0x1003c, 0x1003d, + 0x1003f, 0x1004d, + 0x10050, 0x1005d, + 0x10080, 0x100fa, + 0x10300, 0x1031e, + 0x10330, 0x10349, + 0x10380, 0x1039d, + 0x103a0, 0x103c3, + 0x103c8, 0x103cf, + 0x10400, 0x1049d, + 0x10800, 0x10805, + 0x10808, 0x10808, + 0x1080a, 0x10835, + 0x10837, 0x10838, + 0x1083c, 0x1083c, + 0x1083f, 0x1083f, + 0x10a00, 0x10a00, + 0x10a10, 0x10a13, + 0x10a15, 0x10a17, + 0x10a19, 0x10a33, + 0x1d400, 0x1d454, + 0x1d456, 0x1d49c, + 0x1d49e, 0x1d49f, + 0x1d4a2, 0x1d4a2, + 0x1d4a5, 0x1d4a6, + 0x1d4a9, 0x1d4ac, + 0x1d4ae, 0x1d4b9, + 0x1d4bb, 0x1d4bb, + 0x1d4bd, 0x1d4c3, + 0x1d4c5, 0x1d505, + 0x1d507, 0x1d50a, + 0x1d50d, 0x1d514, + 0x1d516, 0x1d51c, + 0x1d51e, 0x1d539, + 0x1d53b, 0x1d53e, + 0x1d540, 0x1d544, + 0x1d546, 0x1d546, + 0x1d54a, 0x1d550, + 0x1d552, 0x1d6a5, + 0x1d6a8, 0x1d6c0, + 0x1d6c2, 0x1d6da, + 0x1d6dc, 0x1d6fa, + 0x1d6fc, 0x1d714, + 0x1d716, 0x1d734, + 0x1d736, 0x1d74e, + 0x1d750, 0x1d76e, + 0x1d770, 0x1d788, + 0x1d78a, 0x1d7a8, + 0x1d7aa, 0x1d7c2, + 0x1d7c4, 0x1d7c9, + 0x20000, 0x2a6d6, + 0x2f800, 0x2fa1d +}; /* CR_L */ + +/* 'Ll': General Category */ +static const OnigCodePoint CR_Ll[] = { + 480, + 0x0061, 0x007a, + 0x00aa, 0x00aa, + 0x00b5, 0x00b5, + 0x00ba, 0x00ba, + 0x00df, 0x00f6, + 0x00f8, 0x00ff, + 0x0101, 0x0101, + 0x0103, 0x0103, + 0x0105, 0x0105, + 0x0107, 0x0107, + 0x0109, 0x0109, + 0x010b, 0x010b, + 0x010d, 0x010d, + 0x010f, 0x010f, + 0x0111, 0x0111, + 0x0113, 0x0113, + 0x0115, 0x0115, + 0x0117, 0x0117, + 0x0119, 0x0119, + 0x011b, 0x011b, + 0x011d, 0x011d, + 0x011f, 0x011f, + 0x0121, 0x0121, + 0x0123, 0x0123, + 0x0125, 0x0125, + 0x0127, 0x0127, + 0x0129, 0x0129, + 0x012b, 0x012b, + 0x012d, 0x012d, + 0x012f, 0x012f, + 0x0131, 0x0131, + 0x0133, 0x0133, + 0x0135, 0x0135, + 0x0137, 0x0138, + 0x013a, 0x013a, + 0x013c, 0x013c, + 0x013e, 0x013e, + 0x0140, 0x0140, + 0x0142, 0x0142, + 0x0144, 0x0144, + 0x0146, 0x0146, + 0x0148, 0x0149, + 0x014b, 0x014b, + 0x014d, 0x014d, + 0x014f, 0x014f, + 0x0151, 0x0151, + 0x0153, 0x0153, + 0x0155, 0x0155, + 0x0157, 0x0157, + 0x0159, 0x0159, + 0x015b, 0x015b, + 0x015d, 0x015d, + 0x015f, 0x015f, + 0x0161, 0x0161, + 0x0163, 0x0163, + 0x0165, 0x0165, + 0x0167, 0x0167, + 0x0169, 0x0169, + 0x016b, 0x016b, + 0x016d, 0x016d, + 0x016f, 0x016f, + 0x0171, 0x0171, + 0x0173, 0x0173, + 0x0175, 0x0175, + 0x0177, 0x0177, + 0x017a, 0x017a, + 0x017c, 0x017c, + 0x017e, 0x0180, + 0x0183, 0x0183, + 0x0185, 0x0185, + 0x0188, 0x0188, + 0x018c, 0x018d, + 0x0192, 0x0192, + 0x0195, 0x0195, + 0x0199, 0x019b, + 0x019e, 0x019e, + 0x01a1, 0x01a1, + 0x01a3, 0x01a3, + 0x01a5, 0x01a5, + 0x01a8, 0x01a8, + 0x01aa, 0x01ab, + 0x01ad, 0x01ad, + 0x01b0, 0x01b0, + 0x01b4, 0x01b4, + 0x01b6, 0x01b6, + 0x01b9, 0x01ba, + 0x01bd, 0x01bf, + 0x01c6, 0x01c6, + 0x01c9, 0x01c9, + 0x01cc, 0x01cc, + 0x01ce, 0x01ce, + 0x01d0, 0x01d0, + 0x01d2, 0x01d2, + 0x01d4, 0x01d4, + 0x01d6, 0x01d6, + 0x01d8, 0x01d8, + 0x01da, 0x01da, + 0x01dc, 0x01dd, + 0x01df, 0x01df, + 0x01e1, 0x01e1, + 0x01e3, 0x01e3, + 0x01e5, 0x01e5, + 0x01e7, 0x01e7, + 0x01e9, 0x01e9, + 0x01eb, 0x01eb, + 0x01ed, 0x01ed, + 0x01ef, 0x01f0, + 0x01f3, 0x01f3, + 0x01f5, 0x01f5, + 0x01f9, 0x01f9, + 0x01fb, 0x01fb, + 0x01fd, 0x01fd, + 0x01ff, 0x01ff, + 0x0201, 0x0201, + 0x0203, 0x0203, + 0x0205, 0x0205, + 0x0207, 0x0207, + 0x0209, 0x0209, + 0x020b, 0x020b, + 0x020d, 0x020d, + 0x020f, 0x020f, + 0x0211, 0x0211, + 0x0213, 0x0213, + 0x0215, 0x0215, + 0x0217, 0x0217, + 0x0219, 0x0219, + 0x021b, 0x021b, + 0x021d, 0x021d, + 0x021f, 0x021f, + 0x0221, 0x0221, + 0x0223, 0x0223, + 0x0225, 0x0225, + 0x0227, 0x0227, + 0x0229, 0x0229, + 0x022b, 0x022b, + 0x022d, 0x022d, + 0x022f, 0x022f, + 0x0231, 0x0231, + 0x0233, 0x0239, + 0x023c, 0x023c, + 0x023f, 0x0240, + 0x0250, 0x02af, + 0x0390, 0x0390, + 0x03ac, 0x03ce, + 0x03d0, 0x03d1, + 0x03d5, 0x03d7, + 0x03d9, 0x03d9, + 0x03db, 0x03db, + 0x03dd, 0x03dd, + 0x03df, 0x03df, + 0x03e1, 0x03e1, + 0x03e3, 0x03e3, + 0x03e5, 0x03e5, + 0x03e7, 0x03e7, + 0x03e9, 0x03e9, + 0x03eb, 0x03eb, + 0x03ed, 0x03ed, + 0x03ef, 0x03f3, + 0x03f5, 0x03f5, + 0x03f8, 0x03f8, + 0x03fb, 0x03fc, + 0x0430, 0x045f, + 0x0461, 0x0461, + 0x0463, 0x0463, + 0x0465, 0x0465, + 0x0467, 0x0467, + 0x0469, 0x0469, + 0x046b, 0x046b, + 0x046d, 0x046d, + 0x046f, 0x046f, + 0x0471, 0x0471, + 0x0473, 0x0473, + 0x0475, 0x0475, + 0x0477, 0x0477, + 0x0479, 0x0479, + 0x047b, 0x047b, + 0x047d, 0x047d, + 0x047f, 0x047f, + 0x0481, 0x0481, + 0x048b, 0x048b, + 0x048d, 0x048d, + 0x048f, 0x048f, + 0x0491, 0x0491, + 0x0493, 0x0493, + 0x0495, 0x0495, + 0x0497, 0x0497, + 0x0499, 0x0499, + 0x049b, 0x049b, + 0x049d, 0x049d, + 0x049f, 0x049f, + 0x04a1, 0x04a1, + 0x04a3, 0x04a3, + 0x04a5, 0x04a5, + 0x04a7, 0x04a7, + 0x04a9, 0x04a9, + 0x04ab, 0x04ab, + 0x04ad, 0x04ad, + 0x04af, 0x04af, + 0x04b1, 0x04b1, + 0x04b3, 0x04b3, + 0x04b5, 0x04b5, + 0x04b7, 0x04b7, + 0x04b9, 0x04b9, + 0x04bb, 0x04bb, + 0x04bd, 0x04bd, + 0x04bf, 0x04bf, + 0x04c2, 0x04c2, + 0x04c4, 0x04c4, + 0x04c6, 0x04c6, + 0x04c8, 0x04c8, + 0x04ca, 0x04ca, + 0x04cc, 0x04cc, + 0x04ce, 0x04ce, + 0x04d1, 0x04d1, + 0x04d3, 0x04d3, + 0x04d5, 0x04d5, + 0x04d7, 0x04d7, + 0x04d9, 0x04d9, + 0x04db, 0x04db, + 0x04dd, 0x04dd, + 0x04df, 0x04df, + 0x04e1, 0x04e1, + 0x04e3, 0x04e3, + 0x04e5, 0x04e5, + 0x04e7, 0x04e7, + 0x04e9, 0x04e9, + 0x04eb, 0x04eb, + 0x04ed, 0x04ed, + 0x04ef, 0x04ef, + 0x04f1, 0x04f1, + 0x04f3, 0x04f3, + 0x04f5, 0x04f5, + 0x04f7, 0x04f7, + 0x04f9, 0x04f9, + 0x0501, 0x0501, + 0x0503, 0x0503, + 0x0505, 0x0505, + 0x0507, 0x0507, + 0x0509, 0x0509, + 0x050b, 0x050b, + 0x050d, 0x050d, + 0x050f, 0x050f, + 0x0561, 0x0587, + 0x1d00, 0x1d2b, + 0x1d62, 0x1d77, + 0x1d79, 0x1d9a, + 0x1e01, 0x1e01, + 0x1e03, 0x1e03, + 0x1e05, 0x1e05, + 0x1e07, 0x1e07, + 0x1e09, 0x1e09, + 0x1e0b, 0x1e0b, + 0x1e0d, 0x1e0d, + 0x1e0f, 0x1e0f, + 0x1e11, 0x1e11, + 0x1e13, 0x1e13, + 0x1e15, 0x1e15, + 0x1e17, 0x1e17, + 0x1e19, 0x1e19, + 0x1e1b, 0x1e1b, + 0x1e1d, 0x1e1d, + 0x1e1f, 0x1e1f, + 0x1e21, 0x1e21, + 0x1e23, 0x1e23, + 0x1e25, 0x1e25, + 0x1e27, 0x1e27, + 0x1e29, 0x1e29, + 0x1e2b, 0x1e2b, + 0x1e2d, 0x1e2d, + 0x1e2f, 0x1e2f, + 0x1e31, 0x1e31, + 0x1e33, 0x1e33, + 0x1e35, 0x1e35, + 0x1e37, 0x1e37, + 0x1e39, 0x1e39, + 0x1e3b, 0x1e3b, + 0x1e3d, 0x1e3d, + 0x1e3f, 0x1e3f, + 0x1e41, 0x1e41, + 0x1e43, 0x1e43, + 0x1e45, 0x1e45, + 0x1e47, 0x1e47, + 0x1e49, 0x1e49, + 0x1e4b, 0x1e4b, + 0x1e4d, 0x1e4d, + 0x1e4f, 0x1e4f, + 0x1e51, 0x1e51, + 0x1e53, 0x1e53, + 0x1e55, 0x1e55, + 0x1e57, 0x1e57, + 0x1e59, 0x1e59, + 0x1e5b, 0x1e5b, + 0x1e5d, 0x1e5d, + 0x1e5f, 0x1e5f, + 0x1e61, 0x1e61, + 0x1e63, 0x1e63, + 0x1e65, 0x1e65, + 0x1e67, 0x1e67, + 0x1e69, 0x1e69, + 0x1e6b, 0x1e6b, + 0x1e6d, 0x1e6d, + 0x1e6f, 0x1e6f, + 0x1e71, 0x1e71, + 0x1e73, 0x1e73, + 0x1e75, 0x1e75, + 0x1e77, 0x1e77, + 0x1e79, 0x1e79, + 0x1e7b, 0x1e7b, + 0x1e7d, 0x1e7d, + 0x1e7f, 0x1e7f, + 0x1e81, 0x1e81, + 0x1e83, 0x1e83, + 0x1e85, 0x1e85, + 0x1e87, 0x1e87, + 0x1e89, 0x1e89, + 0x1e8b, 0x1e8b, + 0x1e8d, 0x1e8d, + 0x1e8f, 0x1e8f, + 0x1e91, 0x1e91, + 0x1e93, 0x1e93, + 0x1e95, 0x1e9b, + 0x1ea1, 0x1ea1, + 0x1ea3, 0x1ea3, + 0x1ea5, 0x1ea5, + 0x1ea7, 0x1ea7, + 0x1ea9, 0x1ea9, + 0x1eab, 0x1eab, + 0x1ead, 0x1ead, + 0x1eaf, 0x1eaf, + 0x1eb1, 0x1eb1, + 0x1eb3, 0x1eb3, + 0x1eb5, 0x1eb5, + 0x1eb7, 0x1eb7, + 0x1eb9, 0x1eb9, + 0x1ebb, 0x1ebb, + 0x1ebd, 0x1ebd, + 0x1ebf, 0x1ebf, + 0x1ec1, 0x1ec1, + 0x1ec3, 0x1ec3, + 0x1ec5, 0x1ec5, + 0x1ec7, 0x1ec7, + 0x1ec9, 0x1ec9, + 0x1ecb, 0x1ecb, + 0x1ecd, 0x1ecd, + 0x1ecf, 0x1ecf, + 0x1ed1, 0x1ed1, + 0x1ed3, 0x1ed3, + 0x1ed5, 0x1ed5, + 0x1ed7, 0x1ed7, + 0x1ed9, 0x1ed9, + 0x1edb, 0x1edb, + 0x1edd, 0x1edd, + 0x1edf, 0x1edf, + 0x1ee1, 0x1ee1, + 0x1ee3, 0x1ee3, + 0x1ee5, 0x1ee5, + 0x1ee7, 0x1ee7, + 0x1ee9, 0x1ee9, + 0x1eeb, 0x1eeb, + 0x1eed, 0x1eed, + 0x1eef, 0x1eef, + 0x1ef1, 0x1ef1, + 0x1ef3, 0x1ef3, + 0x1ef5, 0x1ef5, + 0x1ef7, 0x1ef7, + 0x1ef9, 0x1ef9, + 0x1f00, 0x1f07, + 0x1f10, 0x1f15, + 0x1f20, 0x1f27, + 0x1f30, 0x1f37, + 0x1f40, 0x1f45, + 0x1f50, 0x1f57, + 0x1f60, 0x1f67, + 0x1f70, 0x1f7d, + 0x1f80, 0x1f87, + 0x1f90, 0x1f97, + 0x1fa0, 0x1fa7, + 0x1fb0, 0x1fb4, + 0x1fb6, 0x1fb7, + 0x1fbe, 0x1fbe, + 0x1fc2, 0x1fc4, + 0x1fc6, 0x1fc7, + 0x1fd0, 0x1fd3, + 0x1fd6, 0x1fd7, + 0x1fe0, 0x1fe7, + 0x1ff2, 0x1ff4, + 0x1ff6, 0x1ff7, + 0x2071, 0x2071, + 0x207f, 0x207f, + 0x210a, 0x210a, + 0x210e, 0x210f, + 0x2113, 0x2113, + 0x212f, 0x212f, + 0x2134, 0x2134, + 0x2139, 0x2139, + 0x213c, 0x213d, + 0x2146, 0x2149, + 0x2c30, 0x2c5e, + 0x2c81, 0x2c81, + 0x2c83, 0x2c83, + 0x2c85, 0x2c85, + 0x2c87, 0x2c87, + 0x2c89, 0x2c89, + 0x2c8b, 0x2c8b, + 0x2c8d, 0x2c8d, + 0x2c8f, 0x2c8f, + 0x2c91, 0x2c91, + 0x2c93, 0x2c93, + 0x2c95, 0x2c95, + 0x2c97, 0x2c97, + 0x2c99, 0x2c99, + 0x2c9b, 0x2c9b, + 0x2c9d, 0x2c9d, + 0x2c9f, 0x2c9f, + 0x2ca1, 0x2ca1, + 0x2ca3, 0x2ca3, + 0x2ca5, 0x2ca5, + 0x2ca7, 0x2ca7, + 0x2ca9, 0x2ca9, + 0x2cab, 0x2cab, + 0x2cad, 0x2cad, + 0x2caf, 0x2caf, + 0x2cb1, 0x2cb1, + 0x2cb3, 0x2cb3, + 0x2cb5, 0x2cb5, + 0x2cb7, 0x2cb7, + 0x2cb9, 0x2cb9, + 0x2cbb, 0x2cbb, + 0x2cbd, 0x2cbd, + 0x2cbf, 0x2cbf, + 0x2cc1, 0x2cc1, + 0x2cc3, 0x2cc3, + 0x2cc5, 0x2cc5, + 0x2cc7, 0x2cc7, + 0x2cc9, 0x2cc9, + 0x2ccb, 0x2ccb, + 0x2ccd, 0x2ccd, + 0x2ccf, 0x2ccf, + 0x2cd1, 0x2cd1, + 0x2cd3, 0x2cd3, + 0x2cd5, 0x2cd5, + 0x2cd7, 0x2cd7, + 0x2cd9, 0x2cd9, + 0x2cdb, 0x2cdb, + 0x2cdd, 0x2cdd, + 0x2cdf, 0x2cdf, + 0x2ce1, 0x2ce1, + 0x2ce3, 0x2ce4, + 0x2d00, 0x2d25, + 0xfb00, 0xfb06, + 0xfb13, 0xfb17, + 0xff41, 0xff5a, + 0x10428, 0x1044f, + 0x1d41a, 0x1d433, + 0x1d44e, 0x1d454, + 0x1d456, 0x1d467, + 0x1d482, 0x1d49b, + 0x1d4b6, 0x1d4b9, + 0x1d4bb, 0x1d4bb, + 0x1d4bd, 0x1d4c3, + 0x1d4c5, 0x1d4cf, + 0x1d4ea, 0x1d503, + 0x1d51e, 0x1d537, + 0x1d552, 0x1d56b, + 0x1d586, 0x1d59f, + 0x1d5ba, 0x1d5d3, + 0x1d5ee, 0x1d607, + 0x1d622, 0x1d63b, + 0x1d656, 0x1d66f, + 0x1d68a, 0x1d6a5, + 0x1d6c2, 0x1d6da, + 0x1d6dc, 0x1d6e1, + 0x1d6fc, 0x1d714, + 0x1d716, 0x1d71b, + 0x1d736, 0x1d74e, + 0x1d750, 0x1d755, + 0x1d770, 0x1d788, + 0x1d78a, 0x1d78f, + 0x1d7aa, 0x1d7c2, + 0x1d7c4, 0x1d7c9 +}; /* CR_Ll */ + +/* 'Lm': General Category */ +static const OnigCodePoint CR_Lm[] = { + 26, + 0x02b0, 0x02c1, + 0x02c6, 0x02d1, + 0x02e0, 0x02e4, + 0x02ee, 0x02ee, + 0x037a, 0x037a, + 0x0559, 0x0559, + 0x0640, 0x0640, + 0x06e5, 0x06e6, + 0x0e46, 0x0e46, + 0x0ec6, 0x0ec6, + 0x10fc, 0x10fc, + 0x17d7, 0x17d7, + 0x1843, 0x1843, + 0x1d2c, 0x1d61, + 0x1d78, 0x1d78, + 0x1d9b, 0x1dbf, + 0x2090, 0x2094, + 0x2d6f, 0x2d6f, + 0x3005, 0x3005, + 0x3031, 0x3035, + 0x303b, 0x303b, + 0x309d, 0x309e, + 0x30fc, 0x30fe, + 0xa015, 0xa015, + 0xff70, 0xff70, + 0xff9e, 0xff9f +}; /* CR_Lm */ + +/* 'Lo': General Category */ +static const OnigCodePoint CR_Lo[] = { + 245, + 0x01bb, 0x01bb, + 0x01c0, 0x01c3, + 0x05d0, 0x05ea, + 0x05f0, 0x05f2, + 0x0621, 0x063a, + 0x0641, 0x064a, + 0x066e, 0x066f, + 0x0671, 0x06d3, + 0x06d5, 0x06d5, + 0x06ee, 0x06ef, + 0x06fa, 0x06fc, + 0x06ff, 0x06ff, + 0x0710, 0x0710, + 0x0712, 0x072f, + 0x074d, 0x076d, + 0x0780, 0x07a5, + 0x07b1, 0x07b1, + 0x0904, 0x0939, + 0x093d, 0x093d, + 0x0950, 0x0950, + 0x0958, 0x0961, + 0x097d, 0x097d, + 0x0985, 0x098c, + 0x098f, 0x0990, + 0x0993, 0x09a8, + 0x09aa, 0x09b0, + 0x09b2, 0x09b2, + 0x09b6, 0x09b9, + 0x09bd, 0x09bd, + 0x09ce, 0x09ce, + 0x09dc, 0x09dd, + 0x09df, 0x09e1, + 0x09f0, 0x09f1, + 0x0a05, 0x0a0a, + 0x0a0f, 0x0a10, + 0x0a13, 0x0a28, + 0x0a2a, 0x0a30, + 0x0a32, 0x0a33, + 0x0a35, 0x0a36, + 0x0a38, 0x0a39, + 0x0a59, 0x0a5c, + 0x0a5e, 0x0a5e, + 0x0a72, 0x0a74, + 0x0a85, 0x0a8d, + 0x0a8f, 0x0a91, + 0x0a93, 0x0aa8, + 0x0aaa, 0x0ab0, + 0x0ab2, 0x0ab3, + 0x0ab5, 0x0ab9, + 0x0abd, 0x0abd, + 0x0ad0, 0x0ad0, + 0x0ae0, 0x0ae1, + 0x0b05, 0x0b0c, + 0x0b0f, 0x0b10, + 0x0b13, 0x0b28, + 0x0b2a, 0x0b30, + 0x0b32, 0x0b33, + 0x0b35, 0x0b39, + 0x0b3d, 0x0b3d, + 0x0b5c, 0x0b5d, + 0x0b5f, 0x0b61, + 0x0b71, 0x0b71, + 0x0b83, 0x0b83, + 0x0b85, 0x0b8a, + 0x0b8e, 0x0b90, + 0x0b92, 0x0b95, + 0x0b99, 0x0b9a, + 0x0b9c, 0x0b9c, + 0x0b9e, 0x0b9f, + 0x0ba3, 0x0ba4, + 0x0ba8, 0x0baa, + 0x0bae, 0x0bb9, + 0x0c05, 0x0c0c, + 0x0c0e, 0x0c10, + 0x0c12, 0x0c28, + 0x0c2a, 0x0c33, + 0x0c35, 0x0c39, + 0x0c60, 0x0c61, + 0x0c85, 0x0c8c, + 0x0c8e, 0x0c90, + 0x0c92, 0x0ca8, + 0x0caa, 0x0cb3, + 0x0cb5, 0x0cb9, + 0x0cbd, 0x0cbd, + 0x0cde, 0x0cde, + 0x0ce0, 0x0ce1, + 0x0d05, 0x0d0c, + 0x0d0e, 0x0d10, + 0x0d12, 0x0d28, + 0x0d2a, 0x0d39, + 0x0d60, 0x0d61, + 0x0d85, 0x0d96, + 0x0d9a, 0x0db1, + 0x0db3, 0x0dbb, + 0x0dbd, 0x0dbd, + 0x0dc0, 0x0dc6, + 0x0e01, 0x0e30, + 0x0e32, 0x0e33, + 0x0e40, 0x0e45, + 0x0e81, 0x0e82, + 0x0e84, 0x0e84, + 0x0e87, 0x0e88, + 0x0e8a, 0x0e8a, + 0x0e8d, 0x0e8d, + 0x0e94, 0x0e97, + 0x0e99, 0x0e9f, + 0x0ea1, 0x0ea3, + 0x0ea5, 0x0ea5, + 0x0ea7, 0x0ea7, + 0x0eaa, 0x0eab, + 0x0ead, 0x0eb0, + 0x0eb2, 0x0eb3, + 0x0ebd, 0x0ebd, + 0x0ec0, 0x0ec4, + 0x0edc, 0x0edd, + 0x0f00, 0x0f00, + 0x0f40, 0x0f47, + 0x0f49, 0x0f6a, + 0x0f88, 0x0f8b, + 0x1000, 0x1021, + 0x1023, 0x1027, + 0x1029, 0x102a, + 0x1050, 0x1055, + 0x10d0, 0x10fa, + 0x1100, 0x1159, + 0x115f, 0x11a2, + 0x11a8, 0x11f9, + 0x1200, 0x1248, + 0x124a, 0x124d, + 0x1250, 0x1256, + 0x1258, 0x1258, + 0x125a, 0x125d, + 0x1260, 0x1288, + 0x128a, 0x128d, + 0x1290, 0x12b0, + 0x12b2, 0x12b5, + 0x12b8, 0x12be, + 0x12c0, 0x12c0, + 0x12c2, 0x12c5, + 0x12c8, 0x12d6, + 0x12d8, 0x1310, + 0x1312, 0x1315, + 0x1318, 0x135a, + 0x1380, 0x138f, + 0x13a0, 0x13f4, + 0x1401, 0x166c, + 0x166f, 0x1676, + 0x1681, 0x169a, + 0x16a0, 0x16ea, + 0x1700, 0x170c, + 0x170e, 0x1711, + 0x1720, 0x1731, + 0x1740, 0x1751, + 0x1760, 0x176c, + 0x176e, 0x1770, + 0x1780, 0x17b3, + 0x17dc, 0x17dc, + 0x1820, 0x1842, + 0x1844, 0x1877, + 0x1880, 0x18a8, + 0x1900, 0x191c, + 0x1950, 0x196d, + 0x1970, 0x1974, + 0x1980, 0x19a9, + 0x19c1, 0x19c7, + 0x1a00, 0x1a16, + 0x2135, 0x2138, + 0x2d30, 0x2d65, + 0x2d80, 0x2d96, + 0x2da0, 0x2da6, + 0x2da8, 0x2dae, + 0x2db0, 0x2db6, + 0x2db8, 0x2dbe, + 0x2dc0, 0x2dc6, + 0x2dc8, 0x2dce, + 0x2dd0, 0x2dd6, + 0x2dd8, 0x2dde, + 0x3006, 0x3006, + 0x303c, 0x303c, + 0x3041, 0x3096, + 0x309f, 0x309f, + 0x30a1, 0x30fa, + 0x30ff, 0x30ff, + 0x3105, 0x312c, + 0x3131, 0x318e, + 0x31a0, 0x31b7, + 0x31f0, 0x31ff, + 0x3400, 0x4db5, + 0x4e00, 0x9fbb, + 0xa000, 0xa014, + 0xa016, 0xa48c, + 0xa800, 0xa801, + 0xa803, 0xa805, + 0xa807, 0xa80a, + 0xa80c, 0xa822, + 0xac00, 0xd7a3, + 0xf900, 0xfa2d, + 0xfa30, 0xfa6a, + 0xfa70, 0xfad9, + 0xfb1d, 0xfb1d, + 0xfb1f, 0xfb28, + 0xfb2a, 0xfb36, + 0xfb38, 0xfb3c, + 0xfb3e, 0xfb3e, + 0xfb40, 0xfb41, + 0xfb43, 0xfb44, + 0xfb46, 0xfbb1, + 0xfbd3, 0xfd3d, + 0xfd50, 0xfd8f, + 0xfd92, 0xfdc7, + 0xfdf0, 0xfdfb, + 0xfe70, 0xfe74, + 0xfe76, 0xfefc, + 0xff66, 0xff6f, + 0xff71, 0xff9d, + 0xffa0, 0xffbe, + 0xffc2, 0xffc7, + 0xffca, 0xffcf, + 0xffd2, 0xffd7, + 0xffda, 0xffdc, + 0x10000, 0x1000b, + 0x1000d, 0x10026, + 0x10028, 0x1003a, + 0x1003c, 0x1003d, + 0x1003f, 0x1004d, + 0x10050, 0x1005d, + 0x10080, 0x100fa, + 0x10300, 0x1031e, + 0x10330, 0x10349, + 0x10380, 0x1039d, + 0x103a0, 0x103c3, + 0x103c8, 0x103cf, + 0x10450, 0x1049d, + 0x10800, 0x10805, + 0x10808, 0x10808, + 0x1080a, 0x10835, + 0x10837, 0x10838, + 0x1083c, 0x1083c, + 0x1083f, 0x1083f, + 0x10a00, 0x10a00, + 0x10a10, 0x10a13, + 0x10a15, 0x10a17, + 0x10a19, 0x10a33, + 0x20000, 0x2a6d6, + 0x2f800, 0x2fa1d +}; /* CR_Lo */ + +/* 'Lt': General Category */ +static const OnigCodePoint CR_Lt[] = { + 10, + 0x01c5, 0x01c5, + 0x01c8, 0x01c8, + 0x01cb, 0x01cb, + 0x01f2, 0x01f2, + 0x1f88, 0x1f8f, + 0x1f98, 0x1f9f, + 0x1fa8, 0x1faf, + 0x1fbc, 0x1fbc, + 0x1fcc, 0x1fcc, + 0x1ffc, 0x1ffc +}; /* CR_Lt */ + +/* 'Lu': General Category */ +static const OnigCodePoint CR_Lu[] = { + 476, + 0x0041, 0x005a, + 0x00c0, 0x00d6, + 0x00d8, 0x00de, + 0x0100, 0x0100, + 0x0102, 0x0102, + 0x0104, 0x0104, + 0x0106, 0x0106, + 0x0108, 0x0108, + 0x010a, 0x010a, + 0x010c, 0x010c, + 0x010e, 0x010e, + 0x0110, 0x0110, + 0x0112, 0x0112, + 0x0114, 0x0114, + 0x0116, 0x0116, + 0x0118, 0x0118, + 0x011a, 0x011a, + 0x011c, 0x011c, + 0x011e, 0x011e, + 0x0120, 0x0120, + 0x0122, 0x0122, + 0x0124, 0x0124, + 0x0126, 0x0126, + 0x0128, 0x0128, + 0x012a, 0x012a, + 0x012c, 0x012c, + 0x012e, 0x012e, + 0x0130, 0x0130, + 0x0132, 0x0132, + 0x0134, 0x0134, + 0x0136, 0x0136, + 0x0139, 0x0139, + 0x013b, 0x013b, + 0x013d, 0x013d, + 0x013f, 0x013f, + 0x0141, 0x0141, + 0x0143, 0x0143, + 0x0145, 0x0145, + 0x0147, 0x0147, + 0x014a, 0x014a, + 0x014c, 0x014c, + 0x014e, 0x014e, + 0x0150, 0x0150, + 0x0152, 0x0152, + 0x0154, 0x0154, + 0x0156, 0x0156, + 0x0158, 0x0158, + 0x015a, 0x015a, + 0x015c, 0x015c, + 0x015e, 0x015e, + 0x0160, 0x0160, + 0x0162, 0x0162, + 0x0164, 0x0164, + 0x0166, 0x0166, + 0x0168, 0x0168, + 0x016a, 0x016a, + 0x016c, 0x016c, + 0x016e, 0x016e, + 0x0170, 0x0170, + 0x0172, 0x0172, + 0x0174, 0x0174, + 0x0176, 0x0176, + 0x0178, 0x0179, + 0x017b, 0x017b, + 0x017d, 0x017d, + 0x0181, 0x0182, + 0x0184, 0x0184, + 0x0186, 0x0187, + 0x0189, 0x018b, + 0x018e, 0x0191, + 0x0193, 0x0194, + 0x0196, 0x0198, + 0x019c, 0x019d, + 0x019f, 0x01a0, + 0x01a2, 0x01a2, + 0x01a4, 0x01a4, + 0x01a6, 0x01a7, + 0x01a9, 0x01a9, + 0x01ac, 0x01ac, + 0x01ae, 0x01af, + 0x01b1, 0x01b3, + 0x01b5, 0x01b5, + 0x01b7, 0x01b8, + 0x01bc, 0x01bc, + 0x01c4, 0x01c4, + 0x01c7, 0x01c7, + 0x01ca, 0x01ca, + 0x01cd, 0x01cd, + 0x01cf, 0x01cf, + 0x01d1, 0x01d1, + 0x01d3, 0x01d3, + 0x01d5, 0x01d5, + 0x01d7, 0x01d7, + 0x01d9, 0x01d9, + 0x01db, 0x01db, + 0x01de, 0x01de, + 0x01e0, 0x01e0, + 0x01e2, 0x01e2, + 0x01e4, 0x01e4, + 0x01e6, 0x01e6, + 0x01e8, 0x01e8, + 0x01ea, 0x01ea, + 0x01ec, 0x01ec, + 0x01ee, 0x01ee, + 0x01f1, 0x01f1, + 0x01f4, 0x01f4, + 0x01f6, 0x01f8, + 0x01fa, 0x01fa, + 0x01fc, 0x01fc, + 0x01fe, 0x01fe, + 0x0200, 0x0200, + 0x0202, 0x0202, + 0x0204, 0x0204, + 0x0206, 0x0206, + 0x0208, 0x0208, + 0x020a, 0x020a, + 0x020c, 0x020c, + 0x020e, 0x020e, + 0x0210, 0x0210, + 0x0212, 0x0212, + 0x0214, 0x0214, + 0x0216, 0x0216, + 0x0218, 0x0218, + 0x021a, 0x021a, + 0x021c, 0x021c, + 0x021e, 0x021e, + 0x0220, 0x0220, + 0x0222, 0x0222, + 0x0224, 0x0224, + 0x0226, 0x0226, + 0x0228, 0x0228, + 0x022a, 0x022a, + 0x022c, 0x022c, + 0x022e, 0x022e, + 0x0230, 0x0230, + 0x0232, 0x0232, + 0x023a, 0x023b, + 0x023d, 0x023e, + 0x0241, 0x0241, + 0x0386, 0x0386, + 0x0388, 0x038a, + 0x038c, 0x038c, + 0x038e, 0x038f, + 0x0391, 0x03a1, + 0x03a3, 0x03ab, + 0x03d2, 0x03d4, + 0x03d8, 0x03d8, + 0x03da, 0x03da, + 0x03dc, 0x03dc, + 0x03de, 0x03de, + 0x03e0, 0x03e0, + 0x03e2, 0x03e2, + 0x03e4, 0x03e4, + 0x03e6, 0x03e6, + 0x03e8, 0x03e8, + 0x03ea, 0x03ea, + 0x03ec, 0x03ec, + 0x03ee, 0x03ee, + 0x03f4, 0x03f4, + 0x03f7, 0x03f7, + 0x03f9, 0x03fa, + 0x03fd, 0x042f, + 0x0460, 0x0460, + 0x0462, 0x0462, + 0x0464, 0x0464, + 0x0466, 0x0466, + 0x0468, 0x0468, + 0x046a, 0x046a, + 0x046c, 0x046c, + 0x046e, 0x046e, + 0x0470, 0x0470, + 0x0472, 0x0472, + 0x0474, 0x0474, + 0x0476, 0x0476, + 0x0478, 0x0478, + 0x047a, 0x047a, + 0x047c, 0x047c, + 0x047e, 0x047e, + 0x0480, 0x0480, + 0x048a, 0x048a, + 0x048c, 0x048c, + 0x048e, 0x048e, + 0x0490, 0x0490, + 0x0492, 0x0492, + 0x0494, 0x0494, + 0x0496, 0x0496, + 0x0498, 0x0498, + 0x049a, 0x049a, + 0x049c, 0x049c, + 0x049e, 0x049e, + 0x04a0, 0x04a0, + 0x04a2, 0x04a2, + 0x04a4, 0x04a4, + 0x04a6, 0x04a6, + 0x04a8, 0x04a8, + 0x04aa, 0x04aa, + 0x04ac, 0x04ac, + 0x04ae, 0x04ae, + 0x04b0, 0x04b0, + 0x04b2, 0x04b2, + 0x04b4, 0x04b4, + 0x04b6, 0x04b6, + 0x04b8, 0x04b8, + 0x04ba, 0x04ba, + 0x04bc, 0x04bc, + 0x04be, 0x04be, + 0x04c0, 0x04c1, + 0x04c3, 0x04c3, + 0x04c5, 0x04c5, + 0x04c7, 0x04c7, + 0x04c9, 0x04c9, + 0x04cb, 0x04cb, + 0x04cd, 0x04cd, + 0x04d0, 0x04d0, + 0x04d2, 0x04d2, + 0x04d4, 0x04d4, + 0x04d6, 0x04d6, + 0x04d8, 0x04d8, + 0x04da, 0x04da, + 0x04dc, 0x04dc, + 0x04de, 0x04de, + 0x04e0, 0x04e0, + 0x04e2, 0x04e2, + 0x04e4, 0x04e4, + 0x04e6, 0x04e6, + 0x04e8, 0x04e8, + 0x04ea, 0x04ea, + 0x04ec, 0x04ec, + 0x04ee, 0x04ee, + 0x04f0, 0x04f0, + 0x04f2, 0x04f2, + 0x04f4, 0x04f4, + 0x04f6, 0x04f6, + 0x04f8, 0x04f8, + 0x0500, 0x0500, + 0x0502, 0x0502, + 0x0504, 0x0504, + 0x0506, 0x0506, + 0x0508, 0x0508, + 0x050a, 0x050a, + 0x050c, 0x050c, + 0x050e, 0x050e, + 0x0531, 0x0556, + 0x10a0, 0x10c5, + 0x1e00, 0x1e00, + 0x1e02, 0x1e02, + 0x1e04, 0x1e04, + 0x1e06, 0x1e06, + 0x1e08, 0x1e08, + 0x1e0a, 0x1e0a, + 0x1e0c, 0x1e0c, + 0x1e0e, 0x1e0e, + 0x1e10, 0x1e10, + 0x1e12, 0x1e12, + 0x1e14, 0x1e14, + 0x1e16, 0x1e16, + 0x1e18, 0x1e18, + 0x1e1a, 0x1e1a, + 0x1e1c, 0x1e1c, + 0x1e1e, 0x1e1e, + 0x1e20, 0x1e20, + 0x1e22, 0x1e22, + 0x1e24, 0x1e24, + 0x1e26, 0x1e26, + 0x1e28, 0x1e28, + 0x1e2a, 0x1e2a, + 0x1e2c, 0x1e2c, + 0x1e2e, 0x1e2e, + 0x1e30, 0x1e30, + 0x1e32, 0x1e32, + 0x1e34, 0x1e34, + 0x1e36, 0x1e36, + 0x1e38, 0x1e38, + 0x1e3a, 0x1e3a, + 0x1e3c, 0x1e3c, + 0x1e3e, 0x1e3e, + 0x1e40, 0x1e40, + 0x1e42, 0x1e42, + 0x1e44, 0x1e44, + 0x1e46, 0x1e46, + 0x1e48, 0x1e48, + 0x1e4a, 0x1e4a, + 0x1e4c, 0x1e4c, + 0x1e4e, 0x1e4e, + 0x1e50, 0x1e50, + 0x1e52, 0x1e52, + 0x1e54, 0x1e54, + 0x1e56, 0x1e56, + 0x1e58, 0x1e58, + 0x1e5a, 0x1e5a, + 0x1e5c, 0x1e5c, + 0x1e5e, 0x1e5e, + 0x1e60, 0x1e60, + 0x1e62, 0x1e62, + 0x1e64, 0x1e64, + 0x1e66, 0x1e66, + 0x1e68, 0x1e68, + 0x1e6a, 0x1e6a, + 0x1e6c, 0x1e6c, + 0x1e6e, 0x1e6e, + 0x1e70, 0x1e70, + 0x1e72, 0x1e72, + 0x1e74, 0x1e74, + 0x1e76, 0x1e76, + 0x1e78, 0x1e78, + 0x1e7a, 0x1e7a, + 0x1e7c, 0x1e7c, + 0x1e7e, 0x1e7e, + 0x1e80, 0x1e80, + 0x1e82, 0x1e82, + 0x1e84, 0x1e84, + 0x1e86, 0x1e86, + 0x1e88, 0x1e88, + 0x1e8a, 0x1e8a, + 0x1e8c, 0x1e8c, + 0x1e8e, 0x1e8e, + 0x1e90, 0x1e90, + 0x1e92, 0x1e92, + 0x1e94, 0x1e94, + 0x1ea0, 0x1ea0, + 0x1ea2, 0x1ea2, + 0x1ea4, 0x1ea4, + 0x1ea6, 0x1ea6, + 0x1ea8, 0x1ea8, + 0x1eaa, 0x1eaa, + 0x1eac, 0x1eac, + 0x1eae, 0x1eae, + 0x1eb0, 0x1eb0, + 0x1eb2, 0x1eb2, + 0x1eb4, 0x1eb4, + 0x1eb6, 0x1eb6, + 0x1eb8, 0x1eb8, + 0x1eba, 0x1eba, + 0x1ebc, 0x1ebc, + 0x1ebe, 0x1ebe, + 0x1ec0, 0x1ec0, + 0x1ec2, 0x1ec2, + 0x1ec4, 0x1ec4, + 0x1ec6, 0x1ec6, + 0x1ec8, 0x1ec8, + 0x1eca, 0x1eca, + 0x1ecc, 0x1ecc, + 0x1ece, 0x1ece, + 0x1ed0, 0x1ed0, + 0x1ed2, 0x1ed2, + 0x1ed4, 0x1ed4, + 0x1ed6, 0x1ed6, + 0x1ed8, 0x1ed8, + 0x1eda, 0x1eda, + 0x1edc, 0x1edc, + 0x1ede, 0x1ede, + 0x1ee0, 0x1ee0, + 0x1ee2, 0x1ee2, + 0x1ee4, 0x1ee4, + 0x1ee6, 0x1ee6, + 0x1ee8, 0x1ee8, + 0x1eea, 0x1eea, + 0x1eec, 0x1eec, + 0x1eee, 0x1eee, + 0x1ef0, 0x1ef0, + 0x1ef2, 0x1ef2, + 0x1ef4, 0x1ef4, + 0x1ef6, 0x1ef6, + 0x1ef8, 0x1ef8, + 0x1f08, 0x1f0f, + 0x1f18, 0x1f1d, + 0x1f28, 0x1f2f, + 0x1f38, 0x1f3f, + 0x1f48, 0x1f4d, + 0x1f59, 0x1f59, + 0x1f5b, 0x1f5b, + 0x1f5d, 0x1f5d, + 0x1f5f, 0x1f5f, + 0x1f68, 0x1f6f, + 0x1fb8, 0x1fbb, + 0x1fc8, 0x1fcb, + 0x1fd8, 0x1fdb, + 0x1fe8, 0x1fec, + 0x1ff8, 0x1ffb, + 0x2102, 0x2102, + 0x2107, 0x2107, + 0x210b, 0x210d, + 0x2110, 0x2112, + 0x2115, 0x2115, + 0x2119, 0x211d, + 0x2124, 0x2124, + 0x2126, 0x2126, + 0x2128, 0x2128, + 0x212a, 0x212d, + 0x2130, 0x2131, + 0x2133, 0x2133, + 0x213e, 0x213f, + 0x2145, 0x2145, + 0x2c00, 0x2c2e, + 0x2c80, 0x2c80, + 0x2c82, 0x2c82, + 0x2c84, 0x2c84, + 0x2c86, 0x2c86, + 0x2c88, 0x2c88, + 0x2c8a, 0x2c8a, + 0x2c8c, 0x2c8c, + 0x2c8e, 0x2c8e, + 0x2c90, 0x2c90, + 0x2c92, 0x2c92, + 0x2c94, 0x2c94, + 0x2c96, 0x2c96, + 0x2c98, 0x2c98, + 0x2c9a, 0x2c9a, + 0x2c9c, 0x2c9c, + 0x2c9e, 0x2c9e, + 0x2ca0, 0x2ca0, + 0x2ca2, 0x2ca2, + 0x2ca4, 0x2ca4, + 0x2ca6, 0x2ca6, + 0x2ca8, 0x2ca8, + 0x2caa, 0x2caa, + 0x2cac, 0x2cac, + 0x2cae, 0x2cae, + 0x2cb0, 0x2cb0, + 0x2cb2, 0x2cb2, + 0x2cb4, 0x2cb4, + 0x2cb6, 0x2cb6, + 0x2cb8, 0x2cb8, + 0x2cba, 0x2cba, + 0x2cbc, 0x2cbc, + 0x2cbe, 0x2cbe, + 0x2cc0, 0x2cc0, + 0x2cc2, 0x2cc2, + 0x2cc4, 0x2cc4, + 0x2cc6, 0x2cc6, + 0x2cc8, 0x2cc8, + 0x2cca, 0x2cca, + 0x2ccc, 0x2ccc, + 0x2cce, 0x2cce, + 0x2cd0, 0x2cd0, + 0x2cd2, 0x2cd2, + 0x2cd4, 0x2cd4, + 0x2cd6, 0x2cd6, + 0x2cd8, 0x2cd8, + 0x2cda, 0x2cda, + 0x2cdc, 0x2cdc, + 0x2cde, 0x2cde, + 0x2ce0, 0x2ce0, + 0x2ce2, 0x2ce2, + 0xff21, 0xff3a, + 0x10400, 0x10427, + 0x1d400, 0x1d419, + 0x1d434, 0x1d44d, + 0x1d468, 0x1d481, + 0x1d49c, 0x1d49c, + 0x1d49e, 0x1d49f, + 0x1d4a2, 0x1d4a2, + 0x1d4a5, 0x1d4a6, + 0x1d4a9, 0x1d4ac, + 0x1d4ae, 0x1d4b5, + 0x1d4d0, 0x1d4e9, + 0x1d504, 0x1d505, + 0x1d507, 0x1d50a, + 0x1d50d, 0x1d514, + 0x1d516, 0x1d51c, + 0x1d538, 0x1d539, + 0x1d53b, 0x1d53e, + 0x1d540, 0x1d544, + 0x1d546, 0x1d546, + 0x1d54a, 0x1d550, + 0x1d56c, 0x1d585, + 0x1d5a0, 0x1d5b9, + 0x1d5d4, 0x1d5ed, + 0x1d608, 0x1d621, + 0x1d63c, 0x1d655, + 0x1d670, 0x1d689, + 0x1d6a8, 0x1d6c0, + 0x1d6e2, 0x1d6fa, + 0x1d71c, 0x1d734, + 0x1d756, 0x1d76e, + 0x1d790, 0x1d7a8 +}; /* CR_Lu */ + +/* 'M': Major Category */ +static const OnigCodePoint CR_M[] = { + 133, + 0x0300, 0x036f, + 0x0483, 0x0486, + 0x0488, 0x0489, + 0x0591, 0x05b9, + 0x05bb, 0x05bd, + 0x05bf, 0x05bf, + 0x05c1, 0x05c2, + 0x05c4, 0x05c5, + 0x05c7, 0x05c7, + 0x0610, 0x0615, + 0x064b, 0x065e, + 0x0670, 0x0670, + 0x06d6, 0x06dc, + 0x06de, 0x06e4, + 0x06e7, 0x06e8, + 0x06ea, 0x06ed, + 0x0711, 0x0711, + 0x0730, 0x074a, + 0x07a6, 0x07b0, + 0x0901, 0x0903, + 0x093c, 0x093c, + 0x093e, 0x094d, + 0x0951, 0x0954, + 0x0962, 0x0963, + 0x0981, 0x0983, + 0x09bc, 0x09bc, + 0x09be, 0x09c4, + 0x09c7, 0x09c8, + 0x09cb, 0x09cd, + 0x09d7, 0x09d7, + 0x09e2, 0x09e3, + 0x0a01, 0x0a03, + 0x0a3c, 0x0a3c, + 0x0a3e, 0x0a42, + 0x0a47, 0x0a48, + 0x0a4b, 0x0a4d, + 0x0a70, 0x0a71, + 0x0a81, 0x0a83, + 0x0abc, 0x0abc, + 0x0abe, 0x0ac5, + 0x0ac7, 0x0ac9, + 0x0acb, 0x0acd, + 0x0ae2, 0x0ae3, + 0x0b01, 0x0b03, + 0x0b3c, 0x0b3c, + 0x0b3e, 0x0b43, + 0x0b47, 0x0b48, + 0x0b4b, 0x0b4d, + 0x0b56, 0x0b57, + 0x0b82, 0x0b82, + 0x0bbe, 0x0bc2, + 0x0bc6, 0x0bc8, + 0x0bca, 0x0bcd, + 0x0bd7, 0x0bd7, + 0x0c01, 0x0c03, + 0x0c3e, 0x0c44, + 0x0c46, 0x0c48, + 0x0c4a, 0x0c4d, + 0x0c55, 0x0c56, + 0x0c82, 0x0c83, + 0x0cbc, 0x0cbc, + 0x0cbe, 0x0cc4, + 0x0cc6, 0x0cc8, + 0x0cca, 0x0ccd, + 0x0cd5, 0x0cd6, + 0x0d02, 0x0d03, + 0x0d3e, 0x0d43, + 0x0d46, 0x0d48, + 0x0d4a, 0x0d4d, + 0x0d57, 0x0d57, + 0x0d82, 0x0d83, + 0x0dca, 0x0dca, + 0x0dcf, 0x0dd4, + 0x0dd6, 0x0dd6, + 0x0dd8, 0x0ddf, + 0x0df2, 0x0df3, + 0x0e31, 0x0e31, + 0x0e34, 0x0e3a, + 0x0e47, 0x0e4e, + 0x0eb1, 0x0eb1, + 0x0eb4, 0x0eb9, + 0x0ebb, 0x0ebc, + 0x0ec8, 0x0ecd, + 0x0f18, 0x0f19, + 0x0f35, 0x0f35, + 0x0f37, 0x0f37, + 0x0f39, 0x0f39, + 0x0f3e, 0x0f3f, + 0x0f71, 0x0f84, + 0x0f86, 0x0f87, + 0x0f90, 0x0f97, + 0x0f99, 0x0fbc, + 0x0fc6, 0x0fc6, + 0x102c, 0x1032, + 0x1036, 0x1039, + 0x1056, 0x1059, + 0x135f, 0x135f, + 0x1712, 0x1714, + 0x1732, 0x1734, + 0x1752, 0x1753, + 0x1772, 0x1773, + 0x17b6, 0x17d3, + 0x17dd, 0x17dd, + 0x180b, 0x180d, + 0x18a9, 0x18a9, + 0x1920, 0x192b, + 0x1930, 0x193b, + 0x19b0, 0x19c0, + 0x19c8, 0x19c9, + 0x1a17, 0x1a1b, + 0x1dc0, 0x1dc3, + 0x20d0, 0x20eb, + 0x302a, 0x302f, + 0x3099, 0x309a, + 0xa802, 0xa802, + 0xa806, 0xa806, + 0xa80b, 0xa80b, + 0xa823, 0xa827, + 0xfb1e, 0xfb1e, + 0xfe00, 0xfe0f, + 0xfe20, 0xfe23, + 0x10a01, 0x10a03, + 0x10a05, 0x10a06, + 0x10a0c, 0x10a0f, + 0x10a38, 0x10a3a, + 0x10a3f, 0x10a3f, + 0x1d165, 0x1d169, + 0x1d16d, 0x1d172, + 0x1d17b, 0x1d182, + 0x1d185, 0x1d18b, + 0x1d1aa, 0x1d1ad, + 0x1d242, 0x1d244, + 0xe0100, 0xe01ef +}; /* CR_M */ + +/* 'Mc': General Category */ +static const OnigCodePoint CR_Mc[] = { + 63, + 0x0903, 0x0903, + 0x093e, 0x0940, + 0x0949, 0x094c, + 0x0982, 0x0983, + 0x09be, 0x09c0, + 0x09c7, 0x09c8, + 0x09cb, 0x09cc, + 0x09d7, 0x09d7, + 0x0a03, 0x0a03, + 0x0a3e, 0x0a40, + 0x0a83, 0x0a83, + 0x0abe, 0x0ac0, + 0x0ac9, 0x0ac9, + 0x0acb, 0x0acc, + 0x0b02, 0x0b03, + 0x0b3e, 0x0b3e, + 0x0b40, 0x0b40, + 0x0b47, 0x0b48, + 0x0b4b, 0x0b4c, + 0x0b57, 0x0b57, + 0x0bbe, 0x0bbf, + 0x0bc1, 0x0bc2, + 0x0bc6, 0x0bc8, + 0x0bca, 0x0bcc, + 0x0bd7, 0x0bd7, + 0x0c01, 0x0c03, + 0x0c41, 0x0c44, + 0x0c82, 0x0c83, + 0x0cbe, 0x0cbe, + 0x0cc0, 0x0cc4, + 0x0cc7, 0x0cc8, + 0x0cca, 0x0ccb, + 0x0cd5, 0x0cd6, + 0x0d02, 0x0d03, + 0x0d3e, 0x0d40, + 0x0d46, 0x0d48, + 0x0d4a, 0x0d4c, + 0x0d57, 0x0d57, + 0x0d82, 0x0d83, + 0x0dcf, 0x0dd1, + 0x0dd8, 0x0ddf, + 0x0df2, 0x0df3, + 0x0f3e, 0x0f3f, + 0x0f7f, 0x0f7f, + 0x102c, 0x102c, + 0x1031, 0x1031, + 0x1038, 0x1038, + 0x1056, 0x1057, + 0x17b6, 0x17b6, + 0x17be, 0x17c5, + 0x17c7, 0x17c8, + 0x1923, 0x1926, + 0x1929, 0x192b, + 0x1930, 0x1931, + 0x1933, 0x1938, + 0x19b0, 0x19c0, + 0x19c8, 0x19c9, + 0x1a19, 0x1a1b, + 0xa802, 0xa802, + 0xa823, 0xa824, + 0xa827, 0xa827, + 0x1d165, 0x1d166, + 0x1d16d, 0x1d172 +}; /* CR_Mc */ + +/* 'Me': General Category */ +static const OnigCodePoint CR_Me[] = { + 4, + 0x0488, 0x0489, + 0x06de, 0x06de, + 0x20dd, 0x20e0, + 0x20e2, 0x20e4 +}; /* CR_Me */ + +/* 'Mn': General Category */ +static const OnigCodePoint CR_Mn[] = { + 124, + 0x0300, 0x036f, + 0x0483, 0x0486, + 0x0591, 0x05b9, + 0x05bb, 0x05bd, + 0x05bf, 0x05bf, + 0x05c1, 0x05c2, + 0x05c4, 0x05c5, + 0x05c7, 0x05c7, + 0x0610, 0x0615, + 0x064b, 0x065e, + 0x0670, 0x0670, + 0x06d6, 0x06dc, + 0x06df, 0x06e4, + 0x06e7, 0x06e8, + 0x06ea, 0x06ed, + 0x0711, 0x0711, + 0x0730, 0x074a, + 0x07a6, 0x07b0, + 0x0901, 0x0902, + 0x093c, 0x093c, + 0x0941, 0x0948, + 0x094d, 0x094d, + 0x0951, 0x0954, + 0x0962, 0x0963, + 0x0981, 0x0981, + 0x09bc, 0x09bc, + 0x09c1, 0x09c4, + 0x09cd, 0x09cd, + 0x09e2, 0x09e3, + 0x0a01, 0x0a02, + 0x0a3c, 0x0a3c, + 0x0a41, 0x0a42, + 0x0a47, 0x0a48, + 0x0a4b, 0x0a4d, + 0x0a70, 0x0a71, + 0x0a81, 0x0a82, + 0x0abc, 0x0abc, + 0x0ac1, 0x0ac5, + 0x0ac7, 0x0ac8, + 0x0acd, 0x0acd, + 0x0ae2, 0x0ae3, + 0x0b01, 0x0b01, + 0x0b3c, 0x0b3c, + 0x0b3f, 0x0b3f, + 0x0b41, 0x0b43, + 0x0b4d, 0x0b4d, + 0x0b56, 0x0b56, + 0x0b82, 0x0b82, + 0x0bc0, 0x0bc0, + 0x0bcd, 0x0bcd, + 0x0c3e, 0x0c40, + 0x0c46, 0x0c48, + 0x0c4a, 0x0c4d, + 0x0c55, 0x0c56, + 0x0cbc, 0x0cbc, + 0x0cbf, 0x0cbf, + 0x0cc6, 0x0cc6, + 0x0ccc, 0x0ccd, + 0x0d41, 0x0d43, + 0x0d4d, 0x0d4d, + 0x0dca, 0x0dca, + 0x0dd2, 0x0dd4, + 0x0dd6, 0x0dd6, + 0x0e31, 0x0e31, + 0x0e34, 0x0e3a, + 0x0e47, 0x0e4e, + 0x0eb1, 0x0eb1, + 0x0eb4, 0x0eb9, + 0x0ebb, 0x0ebc, + 0x0ec8, 0x0ecd, + 0x0f18, 0x0f19, + 0x0f35, 0x0f35, + 0x0f37, 0x0f37, + 0x0f39, 0x0f39, + 0x0f71, 0x0f7e, + 0x0f80, 0x0f84, + 0x0f86, 0x0f87, + 0x0f90, 0x0f97, + 0x0f99, 0x0fbc, + 0x0fc6, 0x0fc6, + 0x102d, 0x1030, + 0x1032, 0x1032, + 0x1036, 0x1037, + 0x1039, 0x1039, + 0x1058, 0x1059, + 0x135f, 0x135f, + 0x1712, 0x1714, + 0x1732, 0x1734, + 0x1752, 0x1753, + 0x1772, 0x1773, + 0x17b7, 0x17bd, + 0x17c6, 0x17c6, + 0x17c9, 0x17d3, + 0x17dd, 0x17dd, + 0x180b, 0x180d, + 0x18a9, 0x18a9, + 0x1920, 0x1922, + 0x1927, 0x1928, + 0x1932, 0x1932, + 0x1939, 0x193b, + 0x1a17, 0x1a18, + 0x1dc0, 0x1dc3, + 0x20d0, 0x20dc, + 0x20e1, 0x20e1, + 0x20e5, 0x20eb, + 0x302a, 0x302f, + 0x3099, 0x309a, + 0xa806, 0xa806, + 0xa80b, 0xa80b, + 0xa825, 0xa826, + 0xfb1e, 0xfb1e, + 0xfe00, 0xfe0f, + 0xfe20, 0xfe23, + 0x10a01, 0x10a03, + 0x10a05, 0x10a06, + 0x10a0c, 0x10a0f, + 0x10a38, 0x10a3a, + 0x10a3f, 0x10a3f, + 0x1d167, 0x1d169, + 0x1d17b, 0x1d182, + 0x1d185, 0x1d18b, + 0x1d1aa, 0x1d1ad, + 0x1d242, 0x1d244, + 0xe0100, 0xe01ef +}; /* CR_Mn */ + +/* 'N': Major Category */ +static const OnigCodePoint CR_N[] = { + 53, + 0x0030, 0x0039, + 0x00b2, 0x00b3, + 0x00b9, 0x00b9, + 0x00bc, 0x00be, + 0x0660, 0x0669, + 0x06f0, 0x06f9, + 0x0966, 0x096f, + 0x09e6, 0x09ef, + 0x09f4, 0x09f9, + 0x0a66, 0x0a6f, + 0x0ae6, 0x0aef, + 0x0b66, 0x0b6f, + 0x0be6, 0x0bf2, + 0x0c66, 0x0c6f, + 0x0ce6, 0x0cef, + 0x0d66, 0x0d6f, + 0x0e50, 0x0e59, + 0x0ed0, 0x0ed9, + 0x0f20, 0x0f33, + 0x1040, 0x1049, + 0x1369, 0x137c, + 0x16ee, 0x16f0, + 0x17e0, 0x17e9, + 0x17f0, 0x17f9, + 0x1810, 0x1819, + 0x1946, 0x194f, + 0x19d0, 0x19d9, + 0x2070, 0x2070, + 0x2074, 0x2079, + 0x2080, 0x2089, + 0x2153, 0x2183, + 0x2460, 0x249b, + 0x24ea, 0x24ff, + 0x2776, 0x2793, + 0x2cfd, 0x2cfd, + 0x3007, 0x3007, + 0x3021, 0x3029, + 0x3038, 0x303a, + 0x3192, 0x3195, + 0x3220, 0x3229, + 0x3251, 0x325f, + 0x3280, 0x3289, + 0x32b1, 0x32bf, + 0xff10, 0xff19, + 0x10107, 0x10133, + 0x10140, 0x10178, + 0x1018a, 0x1018a, + 0x10320, 0x10323, + 0x1034a, 0x1034a, + 0x103d1, 0x103d5, + 0x104a0, 0x104a9, + 0x10a40, 0x10a47, + 0x1d7ce, 0x1d7ff +}; /* CR_N */ + +/* 'Nd': General Category */ +static const OnigCodePoint CR_Nd[] = { + 23, + 0x0030, 0x0039, + 0x0660, 0x0669, + 0x06f0, 0x06f9, + 0x0966, 0x096f, + 0x09e6, 0x09ef, + 0x0a66, 0x0a6f, + 0x0ae6, 0x0aef, + 0x0b66, 0x0b6f, + 0x0be6, 0x0bef, + 0x0c66, 0x0c6f, + 0x0ce6, 0x0cef, + 0x0d66, 0x0d6f, + 0x0e50, 0x0e59, + 0x0ed0, 0x0ed9, + 0x0f20, 0x0f29, + 0x1040, 0x1049, + 0x17e0, 0x17e9, + 0x1810, 0x1819, + 0x1946, 0x194f, + 0x19d0, 0x19d9, + 0xff10, 0xff19, + 0x104a0, 0x104a9, + 0x1d7ce, 0x1d7ff +}; /* CR_Nd */ + +/* 'Nl': General Category */ +static const OnigCodePoint CR_Nl[] = { + 8, + 0x16ee, 0x16f0, + 0x2160, 0x2183, + 0x3007, 0x3007, + 0x3021, 0x3029, + 0x3038, 0x303a, + 0x10140, 0x10174, + 0x1034a, 0x1034a, + 0x103d1, 0x103d5 +}; /* CR_Nl */ + +/* 'No': General Category */ +static const OnigCodePoint CR_No[] = { + 26, + 0x00b2, 0x00b3, + 0x00b9, 0x00b9, + 0x00bc, 0x00be, + 0x09f4, 0x09f9, + 0x0bf0, 0x0bf2, + 0x0f2a, 0x0f33, + 0x1369, 0x137c, + 0x17f0, 0x17f9, + 0x2070, 0x2070, + 0x2074, 0x2079, + 0x2080, 0x2089, + 0x2153, 0x215f, + 0x2460, 0x249b, + 0x24ea, 0x24ff, + 0x2776, 0x2793, + 0x2cfd, 0x2cfd, + 0x3192, 0x3195, + 0x3220, 0x3229, + 0x3251, 0x325f, + 0x3280, 0x3289, + 0x32b1, 0x32bf, + 0x10107, 0x10133, + 0x10175, 0x10178, + 0x1018a, 0x1018a, + 0x10320, 0x10323, + 0x10a40, 0x10a47 +}; /* CR_No */ + +/* 'P': Major Category */ +static const OnigCodePoint CR_P[] = { + 96, + 0x0021, 0x0023, + 0x0025, 0x002a, + 0x002c, 0x002f, + 0x003a, 0x003b, + 0x003f, 0x0040, + 0x005b, 0x005d, + 0x005f, 0x005f, + 0x007b, 0x007b, + 0x007d, 0x007d, + 0x00a1, 0x00a1, + 0x00ab, 0x00ab, + 0x00b7, 0x00b7, + 0x00bb, 0x00bb, + 0x00bf, 0x00bf, + 0x037e, 0x037e, + 0x0387, 0x0387, + 0x055a, 0x055f, + 0x0589, 0x058a, + 0x05be, 0x05be, + 0x05c0, 0x05c0, + 0x05c3, 0x05c3, + 0x05c6, 0x05c6, + 0x05f3, 0x05f4, + 0x060c, 0x060d, + 0x061b, 0x061b, + 0x061e, 0x061f, + 0x066a, 0x066d, + 0x06d4, 0x06d4, + 0x0700, 0x070d, + 0x0964, 0x0965, + 0x0970, 0x0970, + 0x0df4, 0x0df4, + 0x0e4f, 0x0e4f, + 0x0e5a, 0x0e5b, + 0x0f04, 0x0f12, + 0x0f3a, 0x0f3d, + 0x0f85, 0x0f85, + 0x0fd0, 0x0fd1, + 0x104a, 0x104f, + 0x10fb, 0x10fb, + 0x1361, 0x1368, + 0x166d, 0x166e, + 0x169b, 0x169c, + 0x16eb, 0x16ed, + 0x1735, 0x1736, + 0x17d4, 0x17d6, + 0x17d8, 0x17da, + 0x1800, 0x180a, + 0x1944, 0x1945, + 0x19de, 0x19df, + 0x1a1e, 0x1a1f, + 0x2010, 0x2027, + 0x2030, 0x2043, + 0x2045, 0x2051, + 0x2053, 0x205e, + 0x207d, 0x207e, + 0x208d, 0x208e, + 0x2329, 0x232a, + 0x23b4, 0x23b6, + 0x2768, 0x2775, + 0x27c5, 0x27c6, + 0x27e6, 0x27eb, + 0x2983, 0x2998, + 0x29d8, 0x29db, + 0x29fc, 0x29fd, + 0x2cf9, 0x2cfc, + 0x2cfe, 0x2cff, + 0x2e00, 0x2e17, + 0x2e1c, 0x2e1d, + 0x3001, 0x3003, + 0x3008, 0x3011, + 0x3014, 0x301f, + 0x3030, 0x3030, + 0x303d, 0x303d, + 0x30a0, 0x30a0, + 0x30fb, 0x30fb, + 0xfd3e, 0xfd3f, + 0xfe10, 0xfe19, + 0xfe30, 0xfe52, + 0xfe54, 0xfe61, + 0xfe63, 0xfe63, + 0xfe68, 0xfe68, + 0xfe6a, 0xfe6b, + 0xff01, 0xff03, + 0xff05, 0xff0a, + 0xff0c, 0xff0f, + 0xff1a, 0xff1b, + 0xff1f, 0xff20, + 0xff3b, 0xff3d, + 0xff3f, 0xff3f, + 0xff5b, 0xff5b, + 0xff5d, 0xff5d, + 0xff5f, 0xff65, + 0x10100, 0x10101, + 0x1039f, 0x1039f, + 0x10a50, 0x10a58 +}; /* CR_P */ + +/* 'Pc': General Category */ +static const OnigCodePoint CR_Pc[] = { + 6, + 0x005f, 0x005f, + 0x203f, 0x2040, + 0x2054, 0x2054, + 0xfe33, 0xfe34, + 0xfe4d, 0xfe4f, + 0xff3f, 0xff3f +}; /* CR_Pc */ + +/* 'Pd': General Category */ +static const OnigCodePoint CR_Pd[] = { + 12, + 0x002d, 0x002d, + 0x058a, 0x058a, + 0x1806, 0x1806, + 0x2010, 0x2015, + 0x2e17, 0x2e17, + 0x301c, 0x301c, + 0x3030, 0x3030, + 0x30a0, 0x30a0, + 0xfe31, 0xfe32, + 0xfe58, 0xfe58, + 0xfe63, 0xfe63, + 0xff0d, 0xff0d +}; /* CR_Pd */ + +/* 'Pe': General Category */ +static const OnigCodePoint CR_Pe[] = { + 65, + 0x0029, 0x0029, + 0x005d, 0x005d, + 0x007d, 0x007d, + 0x0f3b, 0x0f3b, + 0x0f3d, 0x0f3d, + 0x169c, 0x169c, + 0x2046, 0x2046, + 0x207e, 0x207e, + 0x208e, 0x208e, + 0x232a, 0x232a, + 0x23b5, 0x23b5, + 0x2769, 0x2769, + 0x276b, 0x276b, + 0x276d, 0x276d, + 0x276f, 0x276f, + 0x2771, 0x2771, + 0x2773, 0x2773, + 0x2775, 0x2775, + 0x27c6, 0x27c6, + 0x27e7, 0x27e7, + 0x27e9, 0x27e9, + 0x27eb, 0x27eb, + 0x2984, 0x2984, + 0x2986, 0x2986, + 0x2988, 0x2988, + 0x298a, 0x298a, + 0x298c, 0x298c, + 0x298e, 0x298e, + 0x2990, 0x2990, + 0x2992, 0x2992, + 0x2994, 0x2994, + 0x2996, 0x2996, + 0x2998, 0x2998, + 0x29d9, 0x29d9, + 0x29db, 0x29db, + 0x29fd, 0x29fd, + 0x3009, 0x3009, + 0x300b, 0x300b, + 0x300d, 0x300d, + 0x300f, 0x300f, + 0x3011, 0x3011, + 0x3015, 0x3015, + 0x3017, 0x3017, + 0x3019, 0x3019, + 0x301b, 0x301b, + 0x301e, 0x301f, + 0xfd3f, 0xfd3f, + 0xfe18, 0xfe18, + 0xfe36, 0xfe36, + 0xfe38, 0xfe38, + 0xfe3a, 0xfe3a, + 0xfe3c, 0xfe3c, + 0xfe3e, 0xfe3e, + 0xfe40, 0xfe40, + 0xfe42, 0xfe42, + 0xfe44, 0xfe44, + 0xfe48, 0xfe48, + 0xfe5a, 0xfe5a, + 0xfe5c, 0xfe5c, + 0xfe5e, 0xfe5e, + 0xff09, 0xff09, + 0xff3d, 0xff3d, + 0xff5d, 0xff5d, + 0xff60, 0xff60, + 0xff63, 0xff63 +}; /* CR_Pe */ + +/* 'Pf': General Category */ +static const OnigCodePoint CR_Pf[] = { + 9, + 0x00bb, 0x00bb, + 0x2019, 0x2019, + 0x201d, 0x201d, + 0x203a, 0x203a, + 0x2e03, 0x2e03, + 0x2e05, 0x2e05, + 0x2e0a, 0x2e0a, + 0x2e0d, 0x2e0d, + 0x2e1d, 0x2e1d +}; /* CR_Pf */ + +/* 'Pi': General Category */ +static const OnigCodePoint CR_Pi[] = { + 10, + 0x00ab, 0x00ab, + 0x2018, 0x2018, + 0x201b, 0x201c, + 0x201f, 0x201f, + 0x2039, 0x2039, + 0x2e02, 0x2e02, + 0x2e04, 0x2e04, + 0x2e09, 0x2e09, + 0x2e0c, 0x2e0c, + 0x2e1c, 0x2e1c +}; /* CR_Pi */ + +/* 'Po': General Category */ +static const OnigCodePoint CR_Po[] = { + 88, + 0x0021, 0x0023, + 0x0025, 0x0027, + 0x002a, 0x002a, + 0x002c, 0x002c, + 0x002e, 0x002f, + 0x003a, 0x003b, + 0x003f, 0x0040, + 0x005c, 0x005c, + 0x00a1, 0x00a1, + 0x00b7, 0x00b7, + 0x00bf, 0x00bf, + 0x037e, 0x037e, + 0x0387, 0x0387, + 0x055a, 0x055f, + 0x0589, 0x0589, + 0x05be, 0x05be, + 0x05c0, 0x05c0, + 0x05c3, 0x05c3, + 0x05c6, 0x05c6, + 0x05f3, 0x05f4, + 0x060c, 0x060d, + 0x061b, 0x061b, + 0x061e, 0x061f, + 0x066a, 0x066d, + 0x06d4, 0x06d4, + 0x0700, 0x070d, + 0x0964, 0x0965, + 0x0970, 0x0970, + 0x0df4, 0x0df4, + 0x0e4f, 0x0e4f, + 0x0e5a, 0x0e5b, + 0x0f04, 0x0f12, + 0x0f85, 0x0f85, + 0x0fd0, 0x0fd1, + 0x104a, 0x104f, + 0x10fb, 0x10fb, + 0x1361, 0x1368, + 0x166d, 0x166e, + 0x16eb, 0x16ed, + 0x1735, 0x1736, + 0x17d4, 0x17d6, + 0x17d8, 0x17da, + 0x1800, 0x1805, + 0x1807, 0x180a, + 0x1944, 0x1945, + 0x19de, 0x19df, + 0x1a1e, 0x1a1f, + 0x2016, 0x2017, + 0x2020, 0x2027, + 0x2030, 0x2038, + 0x203b, 0x203e, + 0x2041, 0x2043, + 0x2047, 0x2051, + 0x2053, 0x2053, + 0x2055, 0x205e, + 0x23b6, 0x23b6, + 0x2cf9, 0x2cfc, + 0x2cfe, 0x2cff, + 0x2e00, 0x2e01, + 0x2e06, 0x2e08, + 0x2e0b, 0x2e0b, + 0x2e0e, 0x2e16, + 0x3001, 0x3003, + 0x303d, 0x303d, + 0x30fb, 0x30fb, + 0xfe10, 0xfe16, + 0xfe19, 0xfe19, + 0xfe30, 0xfe30, + 0xfe45, 0xfe46, + 0xfe49, 0xfe4c, + 0xfe50, 0xfe52, + 0xfe54, 0xfe57, + 0xfe5f, 0xfe61, + 0xfe68, 0xfe68, + 0xfe6a, 0xfe6b, + 0xff01, 0xff03, + 0xff05, 0xff07, + 0xff0a, 0xff0a, + 0xff0c, 0xff0c, + 0xff0e, 0xff0f, + 0xff1a, 0xff1b, + 0xff1f, 0xff20, + 0xff3c, 0xff3c, + 0xff61, 0xff61, + 0xff64, 0xff65, + 0x10100, 0x10101, + 0x1039f, 0x1039f, + 0x10a50, 0x10a58 +}; /* CR_Po */ + +/* 'Ps': General Category */ +static const OnigCodePoint CR_Ps[] = { + 67, + 0x0028, 0x0028, + 0x005b, 0x005b, + 0x007b, 0x007b, + 0x0f3a, 0x0f3a, + 0x0f3c, 0x0f3c, + 0x169b, 0x169b, + 0x201a, 0x201a, + 0x201e, 0x201e, + 0x2045, 0x2045, + 0x207d, 0x207d, + 0x208d, 0x208d, + 0x2329, 0x2329, + 0x23b4, 0x23b4, + 0x2768, 0x2768, + 0x276a, 0x276a, + 0x276c, 0x276c, + 0x276e, 0x276e, + 0x2770, 0x2770, + 0x2772, 0x2772, + 0x2774, 0x2774, + 0x27c5, 0x27c5, + 0x27e6, 0x27e6, + 0x27e8, 0x27e8, + 0x27ea, 0x27ea, + 0x2983, 0x2983, + 0x2985, 0x2985, + 0x2987, 0x2987, + 0x2989, 0x2989, + 0x298b, 0x298b, + 0x298d, 0x298d, + 0x298f, 0x298f, + 0x2991, 0x2991, + 0x2993, 0x2993, + 0x2995, 0x2995, + 0x2997, 0x2997, + 0x29d8, 0x29d8, + 0x29da, 0x29da, + 0x29fc, 0x29fc, + 0x3008, 0x3008, + 0x300a, 0x300a, + 0x300c, 0x300c, + 0x300e, 0x300e, + 0x3010, 0x3010, + 0x3014, 0x3014, + 0x3016, 0x3016, + 0x3018, 0x3018, + 0x301a, 0x301a, + 0x301d, 0x301d, + 0xfd3e, 0xfd3e, + 0xfe17, 0xfe17, + 0xfe35, 0xfe35, + 0xfe37, 0xfe37, + 0xfe39, 0xfe39, + 0xfe3b, 0xfe3b, + 0xfe3d, 0xfe3d, + 0xfe3f, 0xfe3f, + 0xfe41, 0xfe41, + 0xfe43, 0xfe43, + 0xfe47, 0xfe47, + 0xfe59, 0xfe59, + 0xfe5b, 0xfe5b, + 0xfe5d, 0xfe5d, + 0xff08, 0xff08, + 0xff3b, 0xff3b, + 0xff5b, 0xff5b, + 0xff5f, 0xff5f, + 0xff62, 0xff62 +}; /* CR_Ps */ + +/* 'S': Major Category */ +static const OnigCodePoint CR_S[] = { + 162, + 0x0024, 0x0024, + 0x002b, 0x002b, + 0x003c, 0x003e, + 0x005e, 0x005e, + 0x0060, 0x0060, + 0x007c, 0x007c, + 0x007e, 0x007e, + 0x00a2, 0x00a9, + 0x00ac, 0x00ac, + 0x00ae, 0x00b1, + 0x00b4, 0x00b4, + 0x00b6, 0x00b6, + 0x00b8, 0x00b8, + 0x00d7, 0x00d7, + 0x00f7, 0x00f7, + 0x02c2, 0x02c5, + 0x02d2, 0x02df, + 0x02e5, 0x02ed, + 0x02ef, 0x02ff, + 0x0374, 0x0375, + 0x0384, 0x0385, + 0x03f6, 0x03f6, + 0x0482, 0x0482, + 0x060b, 0x060b, + 0x060e, 0x060f, + 0x06e9, 0x06e9, + 0x06fd, 0x06fe, + 0x09f2, 0x09f3, + 0x09fa, 0x09fa, + 0x0af1, 0x0af1, + 0x0b70, 0x0b70, + 0x0bf3, 0x0bfa, + 0x0e3f, 0x0e3f, + 0x0f01, 0x0f03, + 0x0f13, 0x0f17, + 0x0f1a, 0x0f1f, + 0x0f34, 0x0f34, + 0x0f36, 0x0f36, + 0x0f38, 0x0f38, + 0x0fbe, 0x0fc5, + 0x0fc7, 0x0fcc, + 0x0fcf, 0x0fcf, + 0x1360, 0x1360, + 0x1390, 0x1399, + 0x17db, 0x17db, + 0x1940, 0x1940, + 0x19e0, 0x19ff, + 0x1fbd, 0x1fbd, + 0x1fbf, 0x1fc1, + 0x1fcd, 0x1fcf, + 0x1fdd, 0x1fdf, + 0x1fed, 0x1fef, + 0x1ffd, 0x1ffe, + 0x2044, 0x2044, + 0x2052, 0x2052, + 0x207a, 0x207c, + 0x208a, 0x208c, + 0x20a0, 0x20b5, + 0x2100, 0x2101, + 0x2103, 0x2106, + 0x2108, 0x2109, + 0x2114, 0x2114, + 0x2116, 0x2118, + 0x211e, 0x2123, + 0x2125, 0x2125, + 0x2127, 0x2127, + 0x2129, 0x2129, + 0x212e, 0x212e, + 0x2132, 0x2132, + 0x213a, 0x213b, + 0x2140, 0x2144, + 0x214a, 0x214c, + 0x2190, 0x2328, + 0x232b, 0x23b3, + 0x23b7, 0x23db, + 0x2400, 0x2426, + 0x2440, 0x244a, + 0x249c, 0x24e9, + 0x2500, 0x269c, + 0x26a0, 0x26b1, + 0x2701, 0x2704, + 0x2706, 0x2709, + 0x270c, 0x2727, + 0x2729, 0x274b, + 0x274d, 0x274d, + 0x274f, 0x2752, + 0x2756, 0x2756, + 0x2758, 0x275e, + 0x2761, 0x2767, + 0x2794, 0x2794, + 0x2798, 0x27af, + 0x27b1, 0x27be, + 0x27c0, 0x27c4, + 0x27d0, 0x27e5, + 0x27f0, 0x2982, + 0x2999, 0x29d7, + 0x29dc, 0x29fb, + 0x29fe, 0x2b13, + 0x2ce5, 0x2cea, + 0x2e80, 0x2e99, + 0x2e9b, 0x2ef3, + 0x2f00, 0x2fd5, + 0x2ff0, 0x2ffb, + 0x3004, 0x3004, + 0x3012, 0x3013, + 0x3020, 0x3020, + 0x3036, 0x3037, + 0x303e, 0x303f, + 0x309b, 0x309c, + 0x3190, 0x3191, + 0x3196, 0x319f, + 0x31c0, 0x31cf, + 0x3200, 0x321e, + 0x322a, 0x3243, + 0x3250, 0x3250, + 0x3260, 0x327f, + 0x328a, 0x32b0, + 0x32c0, 0x32fe, + 0x3300, 0x33ff, + 0x4dc0, 0x4dff, + 0xa490, 0xa4c6, + 0xa700, 0xa716, + 0xa828, 0xa82b, + 0xfb29, 0xfb29, + 0xfdfc, 0xfdfd, + 0xfe62, 0xfe62, + 0xfe64, 0xfe66, + 0xfe69, 0xfe69, + 0xff04, 0xff04, + 0xff0b, 0xff0b, + 0xff1c, 0xff1e, + 0xff3e, 0xff3e, + 0xff40, 0xff40, + 0xff5c, 0xff5c, + 0xff5e, 0xff5e, + 0xffe0, 0xffe6, + 0xffe8, 0xffee, + 0xfffc, 0xfffd, + 0x10102, 0x10102, + 0x10137, 0x1013f, + 0x10179, 0x10189, + 0x103d0, 0x103d0, + 0x1d000, 0x1d0f5, + 0x1d100, 0x1d126, + 0x1d12a, 0x1d164, + 0x1d16a, 0x1d16c, + 0x1d183, 0x1d184, + 0x1d18c, 0x1d1a9, + 0x1d1ae, 0x1d1dd, + 0x1d200, 0x1d241, + 0x1d245, 0x1d245, + 0x1d300, 0x1d356, + 0x1d6c1, 0x1d6c1, + 0x1d6db, 0x1d6db, + 0x1d6fb, 0x1d6fb, + 0x1d715, 0x1d715, + 0x1d735, 0x1d735, + 0x1d74f, 0x1d74f, + 0x1d76f, 0x1d76f, + 0x1d789, 0x1d789, + 0x1d7a9, 0x1d7a9, + 0x1d7c3, 0x1d7c3 +}; /* CR_S */ + +/* 'Sc': General Category */ +static const OnigCodePoint CR_Sc[] = { + 14, + 0x0024, 0x0024, + 0x00a2, 0x00a5, + 0x060b, 0x060b, + 0x09f2, 0x09f3, + 0x0af1, 0x0af1, + 0x0bf9, 0x0bf9, + 0x0e3f, 0x0e3f, + 0x17db, 0x17db, + 0x20a0, 0x20b5, + 0xfdfc, 0xfdfc, + 0xfe69, 0xfe69, + 0xff04, 0xff04, + 0xffe0, 0xffe1, + 0xffe5, 0xffe6 +}; /* CR_Sc */ + +/* 'Sk': General Category */ +static const OnigCodePoint CR_Sk[] = { + 23, + 0x005e, 0x005e, + 0x0060, 0x0060, + 0x00a8, 0x00a8, + 0x00af, 0x00af, + 0x00b4, 0x00b4, + 0x00b8, 0x00b8, + 0x02c2, 0x02c5, + 0x02d2, 0x02df, + 0x02e5, 0x02ed, + 0x02ef, 0x02ff, + 0x0374, 0x0375, + 0x0384, 0x0385, + 0x1fbd, 0x1fbd, + 0x1fbf, 0x1fc1, + 0x1fcd, 0x1fcf, + 0x1fdd, 0x1fdf, + 0x1fed, 0x1fef, + 0x1ffd, 0x1ffe, + 0x309b, 0x309c, + 0xa700, 0xa716, + 0xff3e, 0xff3e, + 0xff40, 0xff40, + 0xffe3, 0xffe3 +}; /* CR_Sk */ + +/* 'Sm': General Category */ +static const OnigCodePoint CR_Sm[] = { + 59, + 0x002b, 0x002b, + 0x003c, 0x003e, + 0x007c, 0x007c, + 0x007e, 0x007e, + 0x00ac, 0x00ac, + 0x00b1, 0x00b1, + 0x00d7, 0x00d7, + 0x00f7, 0x00f7, + 0x03f6, 0x03f6, + 0x2044, 0x2044, + 0x2052, 0x2052, + 0x207a, 0x207c, + 0x208a, 0x208c, + 0x2140, 0x2144, + 0x214b, 0x214b, + 0x2190, 0x2194, + 0x219a, 0x219b, + 0x21a0, 0x21a0, + 0x21a3, 0x21a3, + 0x21a6, 0x21a6, + 0x21ae, 0x21ae, + 0x21ce, 0x21cf, + 0x21d2, 0x21d2, + 0x21d4, 0x21d4, + 0x21f4, 0x22ff, + 0x2308, 0x230b, + 0x2320, 0x2321, + 0x237c, 0x237c, + 0x239b, 0x23b3, + 0x25b7, 0x25b7, + 0x25c1, 0x25c1, + 0x25f8, 0x25ff, + 0x266f, 0x266f, + 0x27c0, 0x27c4, + 0x27d0, 0x27e5, + 0x27f0, 0x27ff, + 0x2900, 0x2982, + 0x2999, 0x29d7, + 0x29dc, 0x29fb, + 0x29fe, 0x2aff, + 0xfb29, 0xfb29, + 0xfe62, 0xfe62, + 0xfe64, 0xfe66, + 0xff0b, 0xff0b, + 0xff1c, 0xff1e, + 0xff5c, 0xff5c, + 0xff5e, 0xff5e, + 0xffe2, 0xffe2, + 0xffe9, 0xffec, + 0x1d6c1, 0x1d6c1, + 0x1d6db, 0x1d6db, + 0x1d6fb, 0x1d6fb, + 0x1d715, 0x1d715, + 0x1d735, 0x1d735, + 0x1d74f, 0x1d74f, + 0x1d76f, 0x1d76f, + 0x1d789, 0x1d789, + 0x1d7a9, 0x1d7a9, + 0x1d7c3, 0x1d7c3 +}; /* CR_Sm */ + +/* 'So': General Category */ +static const OnigCodePoint CR_So[] = { + 120, + 0x00a6, 0x00a7, + 0x00a9, 0x00a9, + 0x00ae, 0x00ae, + 0x00b0, 0x00b0, + 0x00b6, 0x00b6, + 0x0482, 0x0482, + 0x060e, 0x060f, + 0x06e9, 0x06e9, + 0x06fd, 0x06fe, + 0x09fa, 0x09fa, + 0x0b70, 0x0b70, + 0x0bf3, 0x0bf8, + 0x0bfa, 0x0bfa, + 0x0f01, 0x0f03, + 0x0f13, 0x0f17, + 0x0f1a, 0x0f1f, + 0x0f34, 0x0f34, + 0x0f36, 0x0f36, + 0x0f38, 0x0f38, + 0x0fbe, 0x0fc5, + 0x0fc7, 0x0fcc, + 0x0fcf, 0x0fcf, + 0x1360, 0x1360, + 0x1390, 0x1399, + 0x1940, 0x1940, + 0x19e0, 0x19ff, + 0x2100, 0x2101, + 0x2103, 0x2106, + 0x2108, 0x2109, + 0x2114, 0x2114, + 0x2116, 0x2118, + 0x211e, 0x2123, + 0x2125, 0x2125, + 0x2127, 0x2127, + 0x2129, 0x2129, + 0x212e, 0x212e, + 0x2132, 0x2132, + 0x213a, 0x213b, + 0x214a, 0x214a, + 0x214c, 0x214c, + 0x2195, 0x2199, + 0x219c, 0x219f, + 0x21a1, 0x21a2, + 0x21a4, 0x21a5, + 0x21a7, 0x21ad, + 0x21af, 0x21cd, + 0x21d0, 0x21d1, + 0x21d3, 0x21d3, + 0x21d5, 0x21f3, + 0x2300, 0x2307, + 0x230c, 0x231f, + 0x2322, 0x2328, + 0x232b, 0x237b, + 0x237d, 0x239a, + 0x23b7, 0x23db, + 0x2400, 0x2426, + 0x2440, 0x244a, + 0x249c, 0x24e9, + 0x2500, 0x25b6, + 0x25b8, 0x25c0, + 0x25c2, 0x25f7, + 0x2600, 0x266e, + 0x2670, 0x269c, + 0x26a0, 0x26b1, + 0x2701, 0x2704, + 0x2706, 0x2709, + 0x270c, 0x2727, + 0x2729, 0x274b, + 0x274d, 0x274d, + 0x274f, 0x2752, + 0x2756, 0x2756, + 0x2758, 0x275e, + 0x2761, 0x2767, + 0x2794, 0x2794, + 0x2798, 0x27af, + 0x27b1, 0x27be, + 0x2800, 0x28ff, + 0x2b00, 0x2b13, + 0x2ce5, 0x2cea, + 0x2e80, 0x2e99, + 0x2e9b, 0x2ef3, + 0x2f00, 0x2fd5, + 0x2ff0, 0x2ffb, + 0x3004, 0x3004, + 0x3012, 0x3013, + 0x3020, 0x3020, + 0x3036, 0x3037, + 0x303e, 0x303f, + 0x3190, 0x3191, + 0x3196, 0x319f, + 0x31c0, 0x31cf, + 0x3200, 0x321e, + 0x322a, 0x3243, + 0x3250, 0x3250, + 0x3260, 0x327f, + 0x328a, 0x32b0, + 0x32c0, 0x32fe, + 0x3300, 0x33ff, + 0x4dc0, 0x4dff, + 0xa490, 0xa4c6, + 0xa828, 0xa82b, + 0xfdfd, 0xfdfd, + 0xffe4, 0xffe4, + 0xffe8, 0xffe8, + 0xffed, 0xffee, + 0xfffc, 0xfffd, + 0x10102, 0x10102, + 0x10137, 0x1013f, + 0x10179, 0x10189, + 0x103d0, 0x103d0, + 0x1d000, 0x1d0f5, + 0x1d100, 0x1d126, + 0x1d12a, 0x1d164, + 0x1d16a, 0x1d16c, + 0x1d183, 0x1d184, + 0x1d18c, 0x1d1a9, + 0x1d1ae, 0x1d1dd, + 0x1d200, 0x1d241, + 0x1d245, 0x1d245, + 0x1d300, 0x1d356 +}; /* CR_So */ + +/* 'Z': Major Category */ +static const OnigCodePoint CR_Z[] = { + 9, + 0x0020, 0x0020, + 0x00a0, 0x00a0, + 0x1680, 0x1680, + 0x180e, 0x180e, + 0x2000, 0x200a, + 0x2028, 0x2029, + 0x202f, 0x202f, + 0x205f, 0x205f, + 0x3000, 0x3000 +}; /* CR_Z */ + +/* 'Zl': General Category */ +static const OnigCodePoint CR_Zl[] = { + 1, + 0x2028, 0x2028 +}; /* CR_Zl */ + +/* 'Zp': General Category */ +static const OnigCodePoint CR_Zp[] = { + 1, + 0x2029, 0x2029 +}; /* CR_Zp */ + +/* 'Zs': General Category */ +static const OnigCodePoint CR_Zs[] = { + 8, + 0x0020, 0x0020, + 0x00a0, 0x00a0, + 0x1680, 0x1680, + 0x180e, 0x180e, + 0x2000, 0x200a, + 0x202f, 0x202f, + 0x205f, 0x205f, + 0x3000, 0x3000 +}; /* CR_Zs */ + +/* 'Arabic': Script */ +static const OnigCodePoint CR_Arabic[] = { + 17, + 0x060b, 0x060b, + 0x060d, 0x0615, + 0x061e, 0x061e, + 0x0621, 0x063a, + 0x0641, 0x064a, + 0x0656, 0x065e, + 0x066a, 0x066f, + 0x0671, 0x06dc, + 0x06de, 0x06ff, + 0x0750, 0x076d, + 0xfb50, 0xfbb1, + 0xfbd3, 0xfd3d, + 0xfd50, 0xfd8f, + 0xfd92, 0xfdc7, + 0xfdf0, 0xfdfc, + 0xfe70, 0xfe74, + 0xfe76, 0xfefc +}; /* CR_Arabic */ + +/* 'Armenian': Script */ +static const OnigCodePoint CR_Armenian[] = { + 5, + 0x0531, 0x0556, + 0x0559, 0x055f, + 0x0561, 0x0587, + 0x058a, 0x058a, + 0xfb13, 0xfb17 +}; /* CR_Armenian */ + +/* 'Bengali': Script */ +static const OnigCodePoint CR_Bengali[] = { + 14, + 0x0981, 0x0983, + 0x0985, 0x098c, + 0x098f, 0x0990, + 0x0993, 0x09a8, + 0x09aa, 0x09b0, + 0x09b2, 0x09b2, + 0x09b6, 0x09b9, + 0x09bc, 0x09c4, + 0x09c7, 0x09c8, + 0x09cb, 0x09ce, + 0x09d7, 0x09d7, + 0x09dc, 0x09dd, + 0x09df, 0x09e3, + 0x09e6, 0x09fa +}; /* CR_Bengali */ + +/* 'Bopomofo': Script */ +static const OnigCodePoint CR_Bopomofo[] = { + 2, + 0x3105, 0x312c, + 0x31a0, 0x31b7 +}; /* CR_Bopomofo */ + +/* 'Braille': Script */ +static const OnigCodePoint CR_Braille[] = { + 1, + 0x2800, 0x28ff +}; /* CR_Braille */ + +/* 'Buginese': Script */ +static const OnigCodePoint CR_Buginese[] = { + 2, + 0x1a00, 0x1a1b, + 0x1a1e, 0x1a1f +}; /* CR_Buginese */ + +/* 'Buhid': Script */ +static const OnigCodePoint CR_Buhid[] = { + 1, + 0x1740, 0x1753 +}; /* CR_Buhid */ + +/* 'Canadian_Aboriginal': Script */ +static const OnigCodePoint CR_Canadian_Aboriginal[] = { + 1, + 0x1401, 0x1676 +}; /* CR_Canadian_Aboriginal */ + +/* 'Cherokee': Script */ +static const OnigCodePoint CR_Cherokee[] = { + 1, + 0x13a0, 0x13f4 +}; /* CR_Cherokee */ + +/* 'Common': Script */ +static const OnigCodePoint CR_Common[] = { + 126, + 0x0000, 0x0040, + 0x005b, 0x0060, + 0x007b, 0x00a9, + 0x00ab, 0x00b9, + 0x00bb, 0x00bf, + 0x00d7, 0x00d7, + 0x00f7, 0x00f7, + 0x02b9, 0x02df, + 0x02e5, 0x02ff, + 0x037e, 0x037e, + 0x0387, 0x0387, + 0x0589, 0x0589, + 0x0600, 0x0603, + 0x060c, 0x060c, + 0x061b, 0x061b, + 0x061f, 0x061f, + 0x0640, 0x0640, + 0x0660, 0x0669, + 0x06dd, 0x06dd, + 0x0964, 0x0965, + 0x0970, 0x0970, + 0x0e3f, 0x0e3f, + 0x10fb, 0x10fb, + 0x16eb, 0x16ed, + 0x1735, 0x1736, + 0x2000, 0x200b, + 0x200e, 0x2063, + 0x206a, 0x2070, + 0x2074, 0x207e, + 0x2080, 0x208e, + 0x20a0, 0x20b5, + 0x2100, 0x2125, + 0x2127, 0x2129, + 0x212c, 0x214c, + 0x2153, 0x2183, + 0x2190, 0x23db, + 0x2400, 0x2426, + 0x2440, 0x244a, + 0x2460, 0x269c, + 0x26a0, 0x26b1, + 0x2701, 0x2704, + 0x2706, 0x2709, + 0x270c, 0x2727, + 0x2729, 0x274b, + 0x274d, 0x274d, + 0x274f, 0x2752, + 0x2756, 0x2756, + 0x2758, 0x275e, + 0x2761, 0x2794, + 0x2798, 0x27af, + 0x27b1, 0x27be, + 0x27c0, 0x27c6, + 0x27d0, 0x27eb, + 0x27f0, 0x27ff, + 0x2900, 0x2b13, + 0x2e00, 0x2e17, + 0x2e1c, 0x2e1d, + 0x2ff0, 0x2ffb, + 0x3000, 0x3004, + 0x3006, 0x3006, + 0x3008, 0x3020, + 0x3030, 0x3037, + 0x303c, 0x303f, + 0x309b, 0x309c, + 0x30a0, 0x30a0, + 0x30fb, 0x30fc, + 0x3190, 0x319f, + 0x31c0, 0x31cf, + 0x3220, 0x3243, + 0x3250, 0x325f, + 0x327e, 0x32fe, + 0x3300, 0x33ff, + 0x4dc0, 0x4dff, + 0xa700, 0xa716, + 0xe000, 0xf8ff, + 0xfd3e, 0xfd3f, + 0xfdfd, 0xfdfd, + 0xfe10, 0xfe19, + 0xfe30, 0xfe52, + 0xfe54, 0xfe66, + 0xfe68, 0xfe6b, + 0xfeff, 0xfeff, + 0xff01, 0xff20, + 0xff3b, 0xff40, + 0xff5b, 0xff65, + 0xff70, 0xff70, + 0xff9e, 0xff9f, + 0xffe0, 0xffe6, + 0xffe8, 0xffee, + 0xfff9, 0xfffd, + 0x10100, 0x10102, + 0x10107, 0x10133, + 0x10137, 0x1013f, + 0x1d000, 0x1d0f5, + 0x1d100, 0x1d126, + 0x1d12a, 0x1d166, + 0x1d16a, 0x1d17a, + 0x1d183, 0x1d184, + 0x1d18c, 0x1d1a9, + 0x1d1ae, 0x1d1dd, + 0x1d300, 0x1d356, + 0x1d400, 0x1d454, + 0x1d456, 0x1d49c, + 0x1d49e, 0x1d49f, + 0x1d4a2, 0x1d4a2, + 0x1d4a5, 0x1d4a6, + 0x1d4a9, 0x1d4ac, + 0x1d4ae, 0x1d4b9, + 0x1d4bb, 0x1d4bb, + 0x1d4bd, 0x1d4c3, + 0x1d4c5, 0x1d505, + 0x1d507, 0x1d50a, + 0x1d50d, 0x1d514, + 0x1d516, 0x1d51c, + 0x1d51e, 0x1d539, + 0x1d53b, 0x1d53e, + 0x1d540, 0x1d544, + 0x1d546, 0x1d546, + 0x1d54a, 0x1d550, + 0x1d552, 0x1d6a5, + 0x1d6a8, 0x1d7c9, + 0x1d7ce, 0x1d7ff, + 0xe0001, 0xe0001, + 0xe0020, 0xe007f, + 0xf0000, 0xffffd, + 0x100000, 0x10fffd +}; /* CR_Common */ + +/* 'Coptic': Script */ +static const OnigCodePoint CR_Coptic[] = { + 3, + 0x03e2, 0x03ef, + 0x2c80, 0x2cea, + 0x2cf9, 0x2cff +}; /* CR_Coptic */ + +/* 'Cypriot': Script */ +static const OnigCodePoint CR_Cypriot[] = { + 6, + 0x10800, 0x10805, + 0x10808, 0x10808, + 0x1080a, 0x10835, + 0x10837, 0x10838, + 0x1083c, 0x1083c, + 0x1083f, 0x1083f +}; /* CR_Cypriot */ + +/* 'Cyrillic': Script */ +static const OnigCodePoint CR_Cyrillic[] = { + 6, + 0x0400, 0x0486, + 0x0488, 0x04ce, + 0x04d0, 0x04f9, + 0x0500, 0x050f, + 0x1d2b, 0x1d2b, + 0x1d78, 0x1d78 +}; /* CR_Cyrillic */ + +/* 'Deseret': Script */ +static const OnigCodePoint CR_Deseret[] = { + 1, + 0x10400, 0x1044f +}; /* CR_Deseret */ + +/* 'Devanagari': Script */ +static const OnigCodePoint CR_Devanagari[] = { + 6, + 0x0901, 0x0939, + 0x093c, 0x094d, + 0x0950, 0x0954, + 0x0958, 0x0963, + 0x0966, 0x096f, + 0x097d, 0x097d +}; /* CR_Devanagari */ + +/* 'Ethiopic': Script */ +static const OnigCodePoint CR_Ethiopic[] = { + 27, + 0x1200, 0x1248, + 0x124a, 0x124d, + 0x1250, 0x1256, + 0x1258, 0x1258, + 0x125a, 0x125d, + 0x1260, 0x1288, + 0x128a, 0x128d, + 0x1290, 0x12b0, + 0x12b2, 0x12b5, + 0x12b8, 0x12be, + 0x12c0, 0x12c0, + 0x12c2, 0x12c5, + 0x12c8, 0x12d6, + 0x12d8, 0x1310, + 0x1312, 0x1315, + 0x1318, 0x135a, + 0x135f, 0x137c, + 0x1380, 0x1399, + 0x2d80, 0x2d96, + 0x2da0, 0x2da6, + 0x2da8, 0x2dae, + 0x2db0, 0x2db6, + 0x2db8, 0x2dbe, + 0x2dc0, 0x2dc6, + 0x2dc8, 0x2dce, + 0x2dd0, 0x2dd6, + 0x2dd8, 0x2dde +}; /* CR_Ethiopic */ + +/* 'Georgian': Script */ +static const OnigCodePoint CR_Georgian[] = { + 4, + 0x10a0, 0x10c5, + 0x10d0, 0x10fa, + 0x10fc, 0x10fc, + 0x2d00, 0x2d25 +}; /* CR_Georgian */ + +/* 'Glagolitic': Script */ +static const OnigCodePoint CR_Glagolitic[] = { + 2, + 0x2c00, 0x2c2e, + 0x2c30, 0x2c5e +}; /* CR_Glagolitic */ + +/* 'Gothic': Script */ +static const OnigCodePoint CR_Gothic[] = { + 1, + 0x10330, 0x1034a +}; /* CR_Gothic */ + +/* 'Greek': Script */ +static const OnigCodePoint CR_Greek[] = { + 31, + 0x0374, 0x0375, + 0x037a, 0x037a, + 0x0384, 0x0386, + 0x0388, 0x038a, + 0x038c, 0x038c, + 0x038e, 0x03a1, + 0x03a3, 0x03ce, + 0x03d0, 0x03e1, + 0x03f0, 0x03ff, + 0x1d26, 0x1d2a, + 0x1d5d, 0x1d61, + 0x1d66, 0x1d6a, + 0x1f00, 0x1f15, + 0x1f18, 0x1f1d, + 0x1f20, 0x1f45, + 0x1f48, 0x1f4d, + 0x1f50, 0x1f57, + 0x1f59, 0x1f59, + 0x1f5b, 0x1f5b, + 0x1f5d, 0x1f5d, + 0x1f5f, 0x1f7d, + 0x1f80, 0x1fb4, + 0x1fb6, 0x1fc4, + 0x1fc6, 0x1fd3, + 0x1fd6, 0x1fdb, + 0x1fdd, 0x1fef, + 0x1ff2, 0x1ff4, + 0x1ff6, 0x1ffe, + 0x2126, 0x2126, + 0x10140, 0x1018a, + 0x1d200, 0x1d245 +}; /* CR_Greek */ + +/* 'Gujarati': Script */ +static const OnigCodePoint CR_Gujarati[] = { + 14, + 0x0a81, 0x0a83, + 0x0a85, 0x0a8d, + 0x0a8f, 0x0a91, + 0x0a93, 0x0aa8, + 0x0aaa, 0x0ab0, + 0x0ab2, 0x0ab3, + 0x0ab5, 0x0ab9, + 0x0abc, 0x0ac5, + 0x0ac7, 0x0ac9, + 0x0acb, 0x0acd, + 0x0ad0, 0x0ad0, + 0x0ae0, 0x0ae3, + 0x0ae6, 0x0aef, + 0x0af1, 0x0af1 +}; /* CR_Gujarati */ + +/* 'Gurmukhi': Script */ +static const OnigCodePoint CR_Gurmukhi[] = { + 15, + 0x0a01, 0x0a03, + 0x0a05, 0x0a0a, + 0x0a0f, 0x0a10, + 0x0a13, 0x0a28, + 0x0a2a, 0x0a30, + 0x0a32, 0x0a33, + 0x0a35, 0x0a36, + 0x0a38, 0x0a39, + 0x0a3c, 0x0a3c, + 0x0a3e, 0x0a42, + 0x0a47, 0x0a48, + 0x0a4b, 0x0a4d, + 0x0a59, 0x0a5c, + 0x0a5e, 0x0a5e, + 0x0a66, 0x0a74 +}; /* CR_Gurmukhi */ + +/* 'Han': Script */ +static const OnigCodePoint CR_Han[] = { + 14, + 0x2e80, 0x2e99, + 0x2e9b, 0x2ef3, + 0x2f00, 0x2fd5, + 0x3005, 0x3005, + 0x3007, 0x3007, + 0x3021, 0x3029, + 0x3038, 0x303b, + 0x3400, 0x4db5, + 0x4e00, 0x9fbb, + 0xf900, 0xfa2d, + 0xfa30, 0xfa6a, + 0xfa70, 0xfad9, + 0x20000, 0x2a6d6, + 0x2f800, 0x2fa1d +}; /* CR_Han */ + +/* 'Hangul': Script */ +static const OnigCodePoint CR_Hangul[] = { + 12, + 0x1100, 0x1159, + 0x115f, 0x11a2, + 0x11a8, 0x11f9, + 0x3131, 0x318e, + 0x3200, 0x321e, + 0x3260, 0x327d, + 0xac00, 0xd7a3, + 0xffa0, 0xffbe, + 0xffc2, 0xffc7, + 0xffca, 0xffcf, + 0xffd2, 0xffd7, + 0xffda, 0xffdc +}; /* CR_Hangul */ + +/* 'Hanunoo': Script */ +static const OnigCodePoint CR_Hanunoo[] = { + 1, + 0x1720, 0x1734 +}; /* CR_Hanunoo */ + +/* 'Hebrew': Script */ +static const OnigCodePoint CR_Hebrew[] = { + 10, + 0x0591, 0x05b9, + 0x05bb, 0x05c7, + 0x05d0, 0x05ea, + 0x05f0, 0x05f4, + 0xfb1d, 0xfb36, + 0xfb38, 0xfb3c, + 0xfb3e, 0xfb3e, + 0xfb40, 0xfb41, + 0xfb43, 0xfb44, + 0xfb46, 0xfb4f +}; /* CR_Hebrew */ + +/* 'Hiragana': Script */ +static const OnigCodePoint CR_Hiragana[] = { + 2, + 0x3041, 0x3096, + 0x309d, 0x309f +}; /* CR_Hiragana */ + +/* 'Inherited': Script */ +static const OnigCodePoint CR_Inherited[] = { + 15, + 0x0300, 0x036f, + 0x064b, 0x0655, + 0x0670, 0x0670, + 0x1dc0, 0x1dc3, + 0x200c, 0x200d, + 0x20d0, 0x20eb, + 0x302a, 0x302f, + 0x3099, 0x309a, + 0xfe00, 0xfe0f, + 0xfe20, 0xfe23, + 0x1d167, 0x1d169, + 0x1d17b, 0x1d182, + 0x1d185, 0x1d18b, + 0x1d1aa, 0x1d1ad, + 0xe0100, 0xe01ef +}; /* CR_Inherited */ + +/* 'Kannada': Script */ +static const OnigCodePoint CR_Kannada[] = { + 13, + 0x0c82, 0x0c83, + 0x0c85, 0x0c8c, + 0x0c8e, 0x0c90, + 0x0c92, 0x0ca8, + 0x0caa, 0x0cb3, + 0x0cb5, 0x0cb9, + 0x0cbc, 0x0cc4, + 0x0cc6, 0x0cc8, + 0x0cca, 0x0ccd, + 0x0cd5, 0x0cd6, + 0x0cde, 0x0cde, + 0x0ce0, 0x0ce1, + 0x0ce6, 0x0cef +}; /* CR_Kannada */ + +/* 'Katakana': Script */ +static const OnigCodePoint CR_Katakana[] = { + 5, + 0x30a1, 0x30fa, + 0x30fd, 0x30ff, + 0x31f0, 0x31ff, + 0xff66, 0xff6f, + 0xff71, 0xff9d +}; /* CR_Katakana */ + +/* 'Kharoshthi': Script */ +static const OnigCodePoint CR_Kharoshthi[] = { + 8, + 0x10a00, 0x10a03, + 0x10a05, 0x10a06, + 0x10a0c, 0x10a13, + 0x10a15, 0x10a17, + 0x10a19, 0x10a33, + 0x10a38, 0x10a3a, + 0x10a3f, 0x10a47, + 0x10a50, 0x10a58 +}; /* CR_Kharoshthi */ + +/* 'Khmer': Script */ +static const OnigCodePoint CR_Khmer[] = { + 4, + 0x1780, 0x17dd, + 0x17e0, 0x17e9, + 0x17f0, 0x17f9, + 0x19e0, 0x19ff +}; /* CR_Khmer */ + +/* 'Lao': Script */ +static const OnigCodePoint CR_Lao[] = { + 18, + 0x0e81, 0x0e82, + 0x0e84, 0x0e84, + 0x0e87, 0x0e88, + 0x0e8a, 0x0e8a, + 0x0e8d, 0x0e8d, + 0x0e94, 0x0e97, + 0x0e99, 0x0e9f, + 0x0ea1, 0x0ea3, + 0x0ea5, 0x0ea5, + 0x0ea7, 0x0ea7, + 0x0eaa, 0x0eab, + 0x0ead, 0x0eb9, + 0x0ebb, 0x0ebd, + 0x0ec0, 0x0ec4, + 0x0ec6, 0x0ec6, + 0x0ec8, 0x0ecd, + 0x0ed0, 0x0ed9, + 0x0edc, 0x0edd +}; /* CR_Lao */ + +/* 'Latin': Script */ +static const OnigCodePoint CR_Latin[] = { + 23, + 0x0041, 0x005a, + 0x0061, 0x007a, + 0x00aa, 0x00aa, + 0x00ba, 0x00ba, + 0x00c0, 0x00d6, + 0x00d8, 0x00f6, + 0x00f8, 0x0241, + 0x0250, 0x02b8, + 0x02e0, 0x02e4, + 0x1d00, 0x1d25, + 0x1d2c, 0x1d5c, + 0x1d62, 0x1d65, + 0x1d6b, 0x1d77, + 0x1d79, 0x1dbf, + 0x1e00, 0x1e9b, + 0x1ea0, 0x1ef9, + 0x2071, 0x2071, + 0x207f, 0x207f, + 0x2090, 0x2094, + 0x212a, 0x212b, + 0xfb00, 0xfb06, + 0xff21, 0xff3a, + 0xff41, 0xff5a +}; /* CR_Latin */ + +/* 'Limbu': Script */ +static const OnigCodePoint CR_Limbu[] = { + 5, + 0x1900, 0x191c, + 0x1920, 0x192b, + 0x1930, 0x193b, + 0x1940, 0x1940, + 0x1944, 0x194f +}; /* CR_Limbu */ + +/* 'Linear_B': Script */ +static const OnigCodePoint CR_Linear_B[] = { + 7, + 0x10000, 0x1000b, + 0x1000d, 0x10026, + 0x10028, 0x1003a, + 0x1003c, 0x1003d, + 0x1003f, 0x1004d, + 0x10050, 0x1005d, + 0x10080, 0x100fa +}; /* CR_Linear_B */ + +/* 'Malayalam': Script */ +static const OnigCodePoint CR_Malayalam[] = { + 11, + 0x0d02, 0x0d03, + 0x0d05, 0x0d0c, + 0x0d0e, 0x0d10, + 0x0d12, 0x0d28, + 0x0d2a, 0x0d39, + 0x0d3e, 0x0d43, + 0x0d46, 0x0d48, + 0x0d4a, 0x0d4d, + 0x0d57, 0x0d57, + 0x0d60, 0x0d61, + 0x0d66, 0x0d6f +}; /* CR_Malayalam */ + +/* 'Mongolian': Script */ +static const OnigCodePoint CR_Mongolian[] = { + 4, + 0x1800, 0x180e, + 0x1810, 0x1819, + 0x1820, 0x1877, + 0x1880, 0x18a9 +}; /* CR_Mongolian */ + +/* 'Myanmar': Script */ +static const OnigCodePoint CR_Myanmar[] = { + 6, + 0x1000, 0x1021, + 0x1023, 0x1027, + 0x1029, 0x102a, + 0x102c, 0x1032, + 0x1036, 0x1039, + 0x1040, 0x1059 +}; /* CR_Myanmar */ + +/* 'New_Tai_Lue': Script */ +static const OnigCodePoint CR_New_Tai_Lue[] = { + 4, + 0x1980, 0x19a9, + 0x19b0, 0x19c9, + 0x19d0, 0x19d9, + 0x19de, 0x19df +}; /* CR_New_Tai_Lue */ + +/* 'Ogham': Script */ +static const OnigCodePoint CR_Ogham[] = { + 1, + 0x1680, 0x169c +}; /* CR_Ogham */ + +/* 'Old_Italic': Script */ +static const OnigCodePoint CR_Old_Italic[] = { + 2, + 0x10300, 0x1031e, + 0x10320, 0x10323 +}; /* CR_Old_Italic */ + +/* 'Old_Persian': Script */ +static const OnigCodePoint CR_Old_Persian[] = { + 2, + 0x103a0, 0x103c3, + 0x103c8, 0x103d5 +}; /* CR_Old_Persian */ + +/* 'Oriya': Script */ +static const OnigCodePoint CR_Oriya[] = { + 14, + 0x0b01, 0x0b03, + 0x0b05, 0x0b0c, + 0x0b0f, 0x0b10, + 0x0b13, 0x0b28, + 0x0b2a, 0x0b30, + 0x0b32, 0x0b33, + 0x0b35, 0x0b39, + 0x0b3c, 0x0b43, + 0x0b47, 0x0b48, + 0x0b4b, 0x0b4d, + 0x0b56, 0x0b57, + 0x0b5c, 0x0b5d, + 0x0b5f, 0x0b61, + 0x0b66, 0x0b71 +}; /* CR_Oriya */ + +/* 'Osmanya': Script */ +static const OnigCodePoint CR_Osmanya[] = { + 2, + 0x10480, 0x1049d, + 0x104a0, 0x104a9 +}; /* CR_Osmanya */ + +/* 'Runic': Script */ +static const OnigCodePoint CR_Runic[] = { + 2, + 0x16a0, 0x16ea, + 0x16ee, 0x16f0 +}; /* CR_Runic */ + +/* 'Shavian': Script */ +static const OnigCodePoint CR_Shavian[] = { + 1, + 0x10450, 0x1047f +}; /* CR_Shavian */ + +/* 'Sinhala': Script */ +static const OnigCodePoint CR_Sinhala[] = { + 11, + 0x0d82, 0x0d83, + 0x0d85, 0x0d96, + 0x0d9a, 0x0db1, + 0x0db3, 0x0dbb, + 0x0dbd, 0x0dbd, + 0x0dc0, 0x0dc6, + 0x0dca, 0x0dca, + 0x0dcf, 0x0dd4, + 0x0dd6, 0x0dd6, + 0x0dd8, 0x0ddf, + 0x0df2, 0x0df4 +}; /* CR_Sinhala */ + +/* 'Syloti_Nagri': Script */ +static const OnigCodePoint CR_Syloti_Nagri[] = { + 1, + 0xa800, 0xa82b +}; /* CR_Syloti_Nagri */ + +/* 'Syriac': Script */ +static const OnigCodePoint CR_Syriac[] = { + 3, + 0x0700, 0x070d, + 0x070f, 0x074a, + 0x074d, 0x074f +}; /* CR_Syriac */ + +/* 'Tagalog': Script */ +static const OnigCodePoint CR_Tagalog[] = { + 2, + 0x1700, 0x170c, + 0x170e, 0x1714 +}; /* CR_Tagalog */ + +/* 'Tagbanwa': Script */ +static const OnigCodePoint CR_Tagbanwa[] = { + 3, + 0x1760, 0x176c, + 0x176e, 0x1770, + 0x1772, 0x1773 +}; /* CR_Tagbanwa */ + +/* 'Tai_Le': Script */ +static const OnigCodePoint CR_Tai_Le[] = { + 2, + 0x1950, 0x196d, + 0x1970, 0x1974 +}; /* CR_Tai_Le */ + +/* 'Tamil': Script */ +static const OnigCodePoint CR_Tamil[] = { + 15, + 0x0b82, 0x0b83, + 0x0b85, 0x0b8a, + 0x0b8e, 0x0b90, + 0x0b92, 0x0b95, + 0x0b99, 0x0b9a, + 0x0b9c, 0x0b9c, + 0x0b9e, 0x0b9f, + 0x0ba3, 0x0ba4, + 0x0ba8, 0x0baa, + 0x0bae, 0x0bb9, + 0x0bbe, 0x0bc2, + 0x0bc6, 0x0bc8, + 0x0bca, 0x0bcd, + 0x0bd7, 0x0bd7, + 0x0be6, 0x0bfa +}; /* CR_Tamil */ + +/* 'Telugu': Script */ +static const OnigCodePoint CR_Telugu[] = { + 12, + 0x0c01, 0x0c03, + 0x0c05, 0x0c0c, + 0x0c0e, 0x0c10, + 0x0c12, 0x0c28, + 0x0c2a, 0x0c33, + 0x0c35, 0x0c39, + 0x0c3e, 0x0c44, + 0x0c46, 0x0c48, + 0x0c4a, 0x0c4d, + 0x0c55, 0x0c56, + 0x0c60, 0x0c61, + 0x0c66, 0x0c6f +}; /* CR_Telugu */ + +/* 'Thaana': Script */ +static const OnigCodePoint CR_Thaana[] = { + 1, + 0x0780, 0x07b1 +}; /* CR_Thaana */ + +/* 'Thai': Script */ +static const OnigCodePoint CR_Thai[] = { + 2, + 0x0e01, 0x0e3a, + 0x0e40, 0x0e5b +}; /* CR_Thai */ + +/* 'Tibetan': Script */ +static const OnigCodePoint CR_Tibetan[] = { + 7, + 0x0f00, 0x0f47, + 0x0f49, 0x0f6a, + 0x0f71, 0x0f8b, + 0x0f90, 0x0f97, + 0x0f99, 0x0fbc, + 0x0fbe, 0x0fcc, + 0x0fcf, 0x0fd1 +}; /* CR_Tibetan */ + +/* 'Tifinagh': Script */ +static const OnigCodePoint CR_Tifinagh[] = { + 2, + 0x2d30, 0x2d65, + 0x2d6f, 0x2d6f +}; /* CR_Tifinagh */ + +/* 'Ugaritic': Script */ +static const OnigCodePoint CR_Ugaritic[] = { + 2, + 0x10380, 0x1039d, + 0x1039f, 0x1039f +}; /* CR_Ugaritic */ + +/* 'Yi': Script */ +static const OnigCodePoint CR_Yi[] = { + 2, + 0xa000, 0xa48c, + 0xa490, 0xa4c6 +}; /* CR_Yi */ + + +#endif /* USE_UNICODE_PROPERTIES */ + + +typedef struct { + int n; + OnigCodePoint code[3]; +} CodePointList3; + +typedef struct { + OnigCodePoint from; + CodePointList3 to; +} CaseFold_11_Type; + +typedef struct { + OnigCodePoint from; + CodePointList3 to; +} CaseUnfold_11_Type; + +typedef struct { + int n; + OnigCodePoint code[2]; +} CodePointList2; + +typedef struct { + OnigCodePoint from[2]; + CodePointList2 to; +} CaseUnfold_12_Type; + +typedef struct { + OnigCodePoint from[3]; + CodePointList2 to; +} CaseUnfold_13_Type; + +static const CaseFold_11_Type CaseFold[] = { + { 0x0041, {1, {0x0061}}}, + { 0x0042, {1, {0x0062}}}, + { 0x0043, {1, {0x0063}}}, + { 0x0044, {1, {0x0064}}}, + { 0x0045, {1, {0x0065}}}, + { 0x0046, {1, {0x0066}}}, + { 0x0047, {1, {0x0067}}}, + { 0x0048, {1, {0x0068}}}, + { 0x004a, {1, {0x006a}}}, + { 0x004b, {1, {0x006b}}}, + { 0x004c, {1, {0x006c}}}, + { 0x004d, {1, {0x006d}}}, + { 0x004e, {1, {0x006e}}}, + { 0x004f, {1, {0x006f}}}, + { 0x0050, {1, {0x0070}}}, + { 0x0051, {1, {0x0071}}}, + { 0x0052, {1, {0x0072}}}, + { 0x0053, {1, {0x0073}}}, + { 0x0054, {1, {0x0074}}}, + { 0x0055, {1, {0x0075}}}, + { 0x0056, {1, {0x0076}}}, + { 0x0057, {1, {0x0077}}}, + { 0x0058, {1, {0x0078}}}, + { 0x0059, {1, {0x0079}}}, + { 0x005a, {1, {0x007a}}}, + { 0x00b5, {1, {0x03bc}}}, + { 0x00c0, {1, {0x00e0}}}, + { 0x00c1, {1, {0x00e1}}}, + { 0x00c2, {1, {0x00e2}}}, + { 0x00c3, {1, {0x00e3}}}, + { 0x00c4, {1, {0x00e4}}}, + { 0x00c5, {1, {0x00e5}}}, + { 0x00c6, {1, {0x00e6}}}, + { 0x00c7, {1, {0x00e7}}}, + { 0x00c8, {1, {0x00e8}}}, + { 0x00c9, {1, {0x00e9}}}, + { 0x00ca, {1, {0x00ea}}}, + { 0x00cb, {1, {0x00eb}}}, + { 0x00cc, {1, {0x00ec}}}, + { 0x00cd, {1, {0x00ed}}}, + { 0x00ce, {1, {0x00ee}}}, + { 0x00cf, {1, {0x00ef}}}, + { 0x00d0, {1, {0x00f0}}}, + { 0x00d1, {1, {0x00f1}}}, + { 0x00d2, {1, {0x00f2}}}, + { 0x00d3, {1, {0x00f3}}}, + { 0x00d4, {1, {0x00f4}}}, + { 0x00d5, {1, {0x00f5}}}, + { 0x00d6, {1, {0x00f6}}}, + { 0x00d8, {1, {0x00f8}}}, + { 0x00d9, {1, {0x00f9}}}, + { 0x00da, {1, {0x00fa}}}, + { 0x00db, {1, {0x00fb}}}, + { 0x00dc, {1, {0x00fc}}}, + { 0x00dd, {1, {0x00fd}}}, + { 0x00de, {1, {0x00fe}}}, + { 0x00df, {2, {0x0073, 0x0073}}}, + { 0x0100, {1, {0x0101}}}, + { 0x0102, {1, {0x0103}}}, + { 0x0104, {1, {0x0105}}}, + { 0x0106, {1, {0x0107}}}, + { 0x0108, {1, {0x0109}}}, + { 0x010a, {1, {0x010b}}}, + { 0x010c, {1, {0x010d}}}, + { 0x010e, {1, {0x010f}}}, + { 0x0110, {1, {0x0111}}}, + { 0x0112, {1, {0x0113}}}, + { 0x0114, {1, {0x0115}}}, + { 0x0116, {1, {0x0117}}}, + { 0x0118, {1, {0x0119}}}, + { 0x011a, {1, {0x011b}}}, + { 0x011c, {1, {0x011d}}}, + { 0x011e, {1, {0x011f}}}, + { 0x0120, {1, {0x0121}}}, + { 0x0122, {1, {0x0123}}}, + { 0x0124, {1, {0x0125}}}, + { 0x0126, {1, {0x0127}}}, + { 0x0128, {1, {0x0129}}}, + { 0x012a, {1, {0x012b}}}, + { 0x012c, {1, {0x012d}}}, + { 0x012e, {1, {0x012f}}}, + { 0x0132, {1, {0x0133}}}, + { 0x0134, {1, {0x0135}}}, + { 0x0136, {1, {0x0137}}}, + { 0x0139, {1, {0x013a}}}, + { 0x013b, {1, {0x013c}}}, + { 0x013d, {1, {0x013e}}}, + { 0x013f, {1, {0x0140}}}, + { 0x0141, {1, {0x0142}}}, + { 0x0143, {1, {0x0144}}}, + { 0x0145, {1, {0x0146}}}, + { 0x0147, {1, {0x0148}}}, + { 0x0149, {2, {0x02bc, 0x006e}}}, + { 0x014a, {1, {0x014b}}}, + { 0x014c, {1, {0x014d}}}, + { 0x014e, {1, {0x014f}}}, + { 0x0150, {1, {0x0151}}}, + { 0x0152, {1, {0x0153}}}, + { 0x0154, {1, {0x0155}}}, + { 0x0156, {1, {0x0157}}}, + { 0x0158, {1, {0x0159}}}, + { 0x015a, {1, {0x015b}}}, + { 0x015c, {1, {0x015d}}}, + { 0x015e, {1, {0x015f}}}, + { 0x0160, {1, {0x0161}}}, + { 0x0162, {1, {0x0163}}}, + { 0x0164, {1, {0x0165}}}, + { 0x0166, {1, {0x0167}}}, + { 0x0168, {1, {0x0169}}}, + { 0x016a, {1, {0x016b}}}, + { 0x016c, {1, {0x016d}}}, + { 0x016e, {1, {0x016f}}}, + { 0x0170, {1, {0x0171}}}, + { 0x0172, {1, {0x0173}}}, + { 0x0174, {1, {0x0175}}}, + { 0x0176, {1, {0x0177}}}, + { 0x0178, {1, {0x00ff}}}, + { 0x0179, {1, {0x017a}}}, + { 0x017b, {1, {0x017c}}}, + { 0x017d, {1, {0x017e}}}, + { 0x017f, {1, {0x0073}}}, + { 0x0181, {1, {0x0253}}}, + { 0x0182, {1, {0x0183}}}, + { 0x0184, {1, {0x0185}}}, + { 0x0186, {1, {0x0254}}}, + { 0x0187, {1, {0x0188}}}, + { 0x0189, {1, {0x0256}}}, + { 0x018a, {1, {0x0257}}}, + { 0x018b, {1, {0x018c}}}, + { 0x018e, {1, {0x01dd}}}, + { 0x018f, {1, {0x0259}}}, + { 0x0190, {1, {0x025b}}}, + { 0x0191, {1, {0x0192}}}, + { 0x0193, {1, {0x0260}}}, + { 0x0194, {1, {0x0263}}}, + { 0x0196, {1, {0x0269}}}, + { 0x0197, {1, {0x0268}}}, + { 0x0198, {1, {0x0199}}}, + { 0x019c, {1, {0x026f}}}, + { 0x019d, {1, {0x0272}}}, + { 0x019f, {1, {0x0275}}}, + { 0x01a0, {1, {0x01a1}}}, + { 0x01a2, {1, {0x01a3}}}, + { 0x01a4, {1, {0x01a5}}}, + { 0x01a6, {1, {0x0280}}}, + { 0x01a7, {1, {0x01a8}}}, + { 0x01a9, {1, {0x0283}}}, + { 0x01ac, {1, {0x01ad}}}, + { 0x01ae, {1, {0x0288}}}, + { 0x01af, {1, {0x01b0}}}, + { 0x01b1, {1, {0x028a}}}, + { 0x01b2, {1, {0x028b}}}, + { 0x01b3, {1, {0x01b4}}}, + { 0x01b5, {1, {0x01b6}}}, + { 0x01b7, {1, {0x0292}}}, + { 0x01b8, {1, {0x01b9}}}, + { 0x01bc, {1, {0x01bd}}}, + { 0x01c4, {1, {0x01c6}}}, + { 0x01c5, {1, {0x01c6}}}, + { 0x01c7, {1, {0x01c9}}}, + { 0x01c8, {1, {0x01c9}}}, + { 0x01ca, {1, {0x01cc}}}, + { 0x01cb, {1, {0x01cc}}}, + { 0x01cd, {1, {0x01ce}}}, + { 0x01cf, {1, {0x01d0}}}, + { 0x01d1, {1, {0x01d2}}}, + { 0x01d3, {1, {0x01d4}}}, + { 0x01d5, {1, {0x01d6}}}, + { 0x01d7, {1, {0x01d8}}}, + { 0x01d9, {1, {0x01da}}}, + { 0x01db, {1, {0x01dc}}}, + { 0x01de, {1, {0x01df}}}, + { 0x01e0, {1, {0x01e1}}}, + { 0x01e2, {1, {0x01e3}}}, + { 0x01e4, {1, {0x01e5}}}, + { 0x01e6, {1, {0x01e7}}}, + { 0x01e8, {1, {0x01e9}}}, + { 0x01ea, {1, {0x01eb}}}, + { 0x01ec, {1, {0x01ed}}}, + { 0x01ee, {1, {0x01ef}}}, + { 0x01f0, {2, {0x006a, 0x030c}}}, + { 0x01f1, {1, {0x01f3}}}, + { 0x01f2, {1, {0x01f3}}}, + { 0x01f4, {1, {0x01f5}}}, + { 0x01f6, {1, {0x0195}}}, + { 0x01f7, {1, {0x01bf}}}, + { 0x01f8, {1, {0x01f9}}}, + { 0x01fa, {1, {0x01fb}}}, + { 0x01fc, {1, {0x01fd}}}, + { 0x01fe, {1, {0x01ff}}}, + { 0x0200, {1, {0x0201}}}, + { 0x0202, {1, {0x0203}}}, + { 0x0204, {1, {0x0205}}}, + { 0x0206, {1, {0x0207}}}, + { 0x0208, {1, {0x0209}}}, + { 0x020a, {1, {0x020b}}}, + { 0x020c, {1, {0x020d}}}, + { 0x020e, {1, {0x020f}}}, + { 0x0210, {1, {0x0211}}}, + { 0x0212, {1, {0x0213}}}, + { 0x0214, {1, {0x0215}}}, + { 0x0216, {1, {0x0217}}}, + { 0x0218, {1, {0x0219}}}, + { 0x021a, {1, {0x021b}}}, + { 0x021c, {1, {0x021d}}}, + { 0x021e, {1, {0x021f}}}, + { 0x0220, {1, {0x019e}}}, + { 0x0222, {1, {0x0223}}}, + { 0x0224, {1, {0x0225}}}, + { 0x0226, {1, {0x0227}}}, + { 0x0228, {1, {0x0229}}}, + { 0x022a, {1, {0x022b}}}, + { 0x022c, {1, {0x022d}}}, + { 0x022e, {1, {0x022f}}}, + { 0x0230, {1, {0x0231}}}, + { 0x0232, {1, {0x0233}}}, + { 0x023b, {1, {0x023c}}}, + { 0x023d, {1, {0x019a}}}, + { 0x0241, {1, {0x0294}}}, + { 0x0345, {1, {0x03b9}}}, + { 0x0386, {1, {0x03ac}}}, + { 0x0388, {1, {0x03ad}}}, + { 0x0389, {1, {0x03ae}}}, + { 0x038a, {1, {0x03af}}}, + { 0x038c, {1, {0x03cc}}}, + { 0x038e, {1, {0x03cd}}}, + { 0x038f, {1, {0x03ce}}}, + { 0x0390, {3, {0x03b9, 0x0308, 0x0301}}}, + { 0x0391, {1, {0x03b1}}}, + { 0x0392, {1, {0x03b2}}}, + { 0x0393, {1, {0x03b3}}}, + { 0x0394, {1, {0x03b4}}}, + { 0x0395, {1, {0x03b5}}}, + { 0x0396, {1, {0x03b6}}}, + { 0x0397, {1, {0x03b7}}}, + { 0x0398, {1, {0x03b8}}}, + { 0x0399, {1, {0x03b9}}}, + { 0x039a, {1, {0x03ba}}}, + { 0x039b, {1, {0x03bb}}}, + { 0x039c, {1, {0x03bc}}}, + { 0x039d, {1, {0x03bd}}}, + { 0x039e, {1, {0x03be}}}, + { 0x039f, {1, {0x03bf}}}, + { 0x03a0, {1, {0x03c0}}}, + { 0x03a1, {1, {0x03c1}}}, + { 0x03a3, {1, {0x03c3}}}, + { 0x03a4, {1, {0x03c4}}}, + { 0x03a5, {1, {0x03c5}}}, + { 0x03a6, {1, {0x03c6}}}, + { 0x03a7, {1, {0x03c7}}}, + { 0x03a8, {1, {0x03c8}}}, + { 0x03a9, {1, {0x03c9}}}, + { 0x03aa, {1, {0x03ca}}}, + { 0x03ab, {1, {0x03cb}}}, + { 0x03b0, {3, {0x03c5, 0x0308, 0x0301}}}, + { 0x03c2, {1, {0x03c3}}}, + { 0x03d0, {1, {0x03b2}}}, + { 0x03d1, {1, {0x03b8}}}, + { 0x03d5, {1, {0x03c6}}}, + { 0x03d6, {1, {0x03c0}}}, + { 0x03d8, {1, {0x03d9}}}, + { 0x03da, {1, {0x03db}}}, + { 0x03dc, {1, {0x03dd}}}, + { 0x03de, {1, {0x03df}}}, + { 0x03e0, {1, {0x03e1}}}, + { 0x03e2, {1, {0x03e3}}}, + { 0x03e4, {1, {0x03e5}}}, + { 0x03e6, {1, {0x03e7}}}, + { 0x03e8, {1, {0x03e9}}}, + { 0x03ea, {1, {0x03eb}}}, + { 0x03ec, {1, {0x03ed}}}, + { 0x03ee, {1, {0x03ef}}}, + { 0x03f0, {1, {0x03ba}}}, + { 0x03f1, {1, {0x03c1}}}, + { 0x03f4, {1, {0x03b8}}}, + { 0x03f5, {1, {0x03b5}}}, + { 0x03f7, {1, {0x03f8}}}, + { 0x03f9, {1, {0x03f2}}}, + { 0x03fa, {1, {0x03fb}}}, + { 0x0400, {1, {0x0450}}}, + { 0x0401, {1, {0x0451}}}, + { 0x0402, {1, {0x0452}}}, + { 0x0403, {1, {0x0453}}}, + { 0x0404, {1, {0x0454}}}, + { 0x0405, {1, {0x0455}}}, + { 0x0406, {1, {0x0456}}}, + { 0x0407, {1, {0x0457}}}, + { 0x0408, {1, {0x0458}}}, + { 0x0409, {1, {0x0459}}}, + { 0x040a, {1, {0x045a}}}, + { 0x040b, {1, {0x045b}}}, + { 0x040c, {1, {0x045c}}}, + { 0x040d, {1, {0x045d}}}, + { 0x040e, {1, {0x045e}}}, + { 0x040f, {1, {0x045f}}}, + { 0x0410, {1, {0x0430}}}, + { 0x0411, {1, {0x0431}}}, + { 0x0412, {1, {0x0432}}}, + { 0x0413, {1, {0x0433}}}, + { 0x0414, {1, {0x0434}}}, + { 0x0415, {1, {0x0435}}}, + { 0x0416, {1, {0x0436}}}, + { 0x0417, {1, {0x0437}}}, + { 0x0418, {1, {0x0438}}}, + { 0x0419, {1, {0x0439}}}, + { 0x041a, {1, {0x043a}}}, + { 0x041b, {1, {0x043b}}}, + { 0x041c, {1, {0x043c}}}, + { 0x041d, {1, {0x043d}}}, + { 0x041e, {1, {0x043e}}}, + { 0x041f, {1, {0x043f}}}, + { 0x0420, {1, {0x0440}}}, + { 0x0421, {1, {0x0441}}}, + { 0x0422, {1, {0x0442}}}, + { 0x0423, {1, {0x0443}}}, + { 0x0424, {1, {0x0444}}}, + { 0x0425, {1, {0x0445}}}, + { 0x0426, {1, {0x0446}}}, + { 0x0427, {1, {0x0447}}}, + { 0x0428, {1, {0x0448}}}, + { 0x0429, {1, {0x0449}}}, + { 0x042a, {1, {0x044a}}}, + { 0x042b, {1, {0x044b}}}, + { 0x042c, {1, {0x044c}}}, + { 0x042d, {1, {0x044d}}}, + { 0x042e, {1, {0x044e}}}, + { 0x042f, {1, {0x044f}}}, + { 0x0460, {1, {0x0461}}}, + { 0x0462, {1, {0x0463}}}, + { 0x0464, {1, {0x0465}}}, + { 0x0466, {1, {0x0467}}}, + { 0x0468, {1, {0x0469}}}, + { 0x046a, {1, {0x046b}}}, + { 0x046c, {1, {0x046d}}}, + { 0x046e, {1, {0x046f}}}, + { 0x0470, {1, {0x0471}}}, + { 0x0472, {1, {0x0473}}}, + { 0x0474, {1, {0x0475}}}, + { 0x0476, {1, {0x0477}}}, + { 0x0478, {1, {0x0479}}}, + { 0x047a, {1, {0x047b}}}, + { 0x047c, {1, {0x047d}}}, + { 0x047e, {1, {0x047f}}}, + { 0x0480, {1, {0x0481}}}, + { 0x048a, {1, {0x048b}}}, + { 0x048c, {1, {0x048d}}}, + { 0x048e, {1, {0x048f}}}, + { 0x0490, {1, {0x0491}}}, + { 0x0492, {1, {0x0493}}}, + { 0x0494, {1, {0x0495}}}, + { 0x0496, {1, {0x0497}}}, + { 0x0498, {1, {0x0499}}}, + { 0x049a, {1, {0x049b}}}, + { 0x049c, {1, {0x049d}}}, + { 0x049e, {1, {0x049f}}}, + { 0x04a0, {1, {0x04a1}}}, + { 0x04a2, {1, {0x04a3}}}, + { 0x04a4, {1, {0x04a5}}}, + { 0x04a6, {1, {0x04a7}}}, + { 0x04a8, {1, {0x04a9}}}, + { 0x04aa, {1, {0x04ab}}}, + { 0x04ac, {1, {0x04ad}}}, + { 0x04ae, {1, {0x04af}}}, + { 0x04b0, {1, {0x04b1}}}, + { 0x04b2, {1, {0x04b3}}}, + { 0x04b4, {1, {0x04b5}}}, + { 0x04b6, {1, {0x04b7}}}, + { 0x04b8, {1, {0x04b9}}}, + { 0x04ba, {1, {0x04bb}}}, + { 0x04bc, {1, {0x04bd}}}, + { 0x04be, {1, {0x04bf}}}, + { 0x04c1, {1, {0x04c2}}}, + { 0x04c3, {1, {0x04c4}}}, + { 0x04c5, {1, {0x04c6}}}, + { 0x04c7, {1, {0x04c8}}}, + { 0x04c9, {1, {0x04ca}}}, + { 0x04cb, {1, {0x04cc}}}, + { 0x04cd, {1, {0x04ce}}}, + { 0x04d0, {1, {0x04d1}}}, + { 0x04d2, {1, {0x04d3}}}, + { 0x04d4, {1, {0x04d5}}}, + { 0x04d6, {1, {0x04d7}}}, + { 0x04d8, {1, {0x04d9}}}, + { 0x04da, {1, {0x04db}}}, + { 0x04dc, {1, {0x04dd}}}, + { 0x04de, {1, {0x04df}}}, + { 0x04e0, {1, {0x04e1}}}, + { 0x04e2, {1, {0x04e3}}}, + { 0x04e4, {1, {0x04e5}}}, + { 0x04e6, {1, {0x04e7}}}, + { 0x04e8, {1, {0x04e9}}}, + { 0x04ea, {1, {0x04eb}}}, + { 0x04ec, {1, {0x04ed}}}, + { 0x04ee, {1, {0x04ef}}}, + { 0x04f0, {1, {0x04f1}}}, + { 0x04f2, {1, {0x04f3}}}, + { 0x04f4, {1, {0x04f5}}}, + { 0x04f6, {1, {0x04f7}}}, + { 0x04f8, {1, {0x04f9}}}, + { 0x0500, {1, {0x0501}}}, + { 0x0502, {1, {0x0503}}}, + { 0x0504, {1, {0x0505}}}, + { 0x0506, {1, {0x0507}}}, + { 0x0508, {1, {0x0509}}}, + { 0x050a, {1, {0x050b}}}, + { 0x050c, {1, {0x050d}}}, + { 0x050e, {1, {0x050f}}}, + { 0x0531, {1, {0x0561}}}, + { 0x0532, {1, {0x0562}}}, + { 0x0533, {1, {0x0563}}}, + { 0x0534, {1, {0x0564}}}, + { 0x0535, {1, {0x0565}}}, + { 0x0536, {1, {0x0566}}}, + { 0x0537, {1, {0x0567}}}, + { 0x0538, {1, {0x0568}}}, + { 0x0539, {1, {0x0569}}}, + { 0x053a, {1, {0x056a}}}, + { 0x053b, {1, {0x056b}}}, + { 0x053c, {1, {0x056c}}}, + { 0x053d, {1, {0x056d}}}, + { 0x053e, {1, {0x056e}}}, + { 0x053f, {1, {0x056f}}}, + { 0x0540, {1, {0x0570}}}, + { 0x0541, {1, {0x0571}}}, + { 0x0542, {1, {0x0572}}}, + { 0x0543, {1, {0x0573}}}, + { 0x0544, {1, {0x0574}}}, + { 0x0545, {1, {0x0575}}}, + { 0x0546, {1, {0x0576}}}, + { 0x0547, {1, {0x0577}}}, + { 0x0548, {1, {0x0578}}}, + { 0x0549, {1, {0x0579}}}, + { 0x054a, {1, {0x057a}}}, + { 0x054b, {1, {0x057b}}}, + { 0x054c, {1, {0x057c}}}, + { 0x054d, {1, {0x057d}}}, + { 0x054e, {1, {0x057e}}}, + { 0x054f, {1, {0x057f}}}, + { 0x0550, {1, {0x0580}}}, + { 0x0551, {1, {0x0581}}}, + { 0x0552, {1, {0x0582}}}, + { 0x0553, {1, {0x0583}}}, + { 0x0554, {1, {0x0584}}}, + { 0x0555, {1, {0x0585}}}, + { 0x0556, {1, {0x0586}}}, + { 0x0587, {2, {0x0565, 0x0582}}}, + { 0x10a0, {1, {0x2d00}}}, + { 0x10a1, {1, {0x2d01}}}, + { 0x10a2, {1, {0x2d02}}}, + { 0x10a3, {1, {0x2d03}}}, + { 0x10a4, {1, {0x2d04}}}, + { 0x10a5, {1, {0x2d05}}}, + { 0x10a6, {1, {0x2d06}}}, + { 0x10a7, {1, {0x2d07}}}, + { 0x10a8, {1, {0x2d08}}}, + { 0x10a9, {1, {0x2d09}}}, + { 0x10aa, {1, {0x2d0a}}}, + { 0x10ab, {1, {0x2d0b}}}, + { 0x10ac, {1, {0x2d0c}}}, + { 0x10ad, {1, {0x2d0d}}}, + { 0x10ae, {1, {0x2d0e}}}, + { 0x10af, {1, {0x2d0f}}}, + { 0x10b0, {1, {0x2d10}}}, + { 0x10b1, {1, {0x2d11}}}, + { 0x10b2, {1, {0x2d12}}}, + { 0x10b3, {1, {0x2d13}}}, + { 0x10b4, {1, {0x2d14}}}, + { 0x10b5, {1, {0x2d15}}}, + { 0x10b6, {1, {0x2d16}}}, + { 0x10b7, {1, {0x2d17}}}, + { 0x10b8, {1, {0x2d18}}}, + { 0x10b9, {1, {0x2d19}}}, + { 0x10ba, {1, {0x2d1a}}}, + { 0x10bb, {1, {0x2d1b}}}, + { 0x10bc, {1, {0x2d1c}}}, + { 0x10bd, {1, {0x2d1d}}}, + { 0x10be, {1, {0x2d1e}}}, + { 0x10bf, {1, {0x2d1f}}}, + { 0x10c0, {1, {0x2d20}}}, + { 0x10c1, {1, {0x2d21}}}, + { 0x10c2, {1, {0x2d22}}}, + { 0x10c3, {1, {0x2d23}}}, + { 0x10c4, {1, {0x2d24}}}, + { 0x10c5, {1, {0x2d25}}}, + { 0x1e00, {1, {0x1e01}}}, + { 0x1e02, {1, {0x1e03}}}, + { 0x1e04, {1, {0x1e05}}}, + { 0x1e06, {1, {0x1e07}}}, + { 0x1e08, {1, {0x1e09}}}, + { 0x1e0a, {1, {0x1e0b}}}, + { 0x1e0c, {1, {0x1e0d}}}, + { 0x1e0e, {1, {0x1e0f}}}, + { 0x1e10, {1, {0x1e11}}}, + { 0x1e12, {1, {0x1e13}}}, + { 0x1e14, {1, {0x1e15}}}, + { 0x1e16, {1, {0x1e17}}}, + { 0x1e18, {1, {0x1e19}}}, + { 0x1e1a, {1, {0x1e1b}}}, + { 0x1e1c, {1, {0x1e1d}}}, + { 0x1e1e, {1, {0x1e1f}}}, + { 0x1e20, {1, {0x1e21}}}, + { 0x1e22, {1, {0x1e23}}}, + { 0x1e24, {1, {0x1e25}}}, + { 0x1e26, {1, {0x1e27}}}, + { 0x1e28, {1, {0x1e29}}}, + { 0x1e2a, {1, {0x1e2b}}}, + { 0x1e2c, {1, {0x1e2d}}}, + { 0x1e2e, {1, {0x1e2f}}}, + { 0x1e30, {1, {0x1e31}}}, + { 0x1e32, {1, {0x1e33}}}, + { 0x1e34, {1, {0x1e35}}}, + { 0x1e36, {1, {0x1e37}}}, + { 0x1e38, {1, {0x1e39}}}, + { 0x1e3a, {1, {0x1e3b}}}, + { 0x1e3c, {1, {0x1e3d}}}, + { 0x1e3e, {1, {0x1e3f}}}, + { 0x1e40, {1, {0x1e41}}}, + { 0x1e42, {1, {0x1e43}}}, + { 0x1e44, {1, {0x1e45}}}, + { 0x1e46, {1, {0x1e47}}}, + { 0x1e48, {1, {0x1e49}}}, + { 0x1e4a, {1, {0x1e4b}}}, + { 0x1e4c, {1, {0x1e4d}}}, + { 0x1e4e, {1, {0x1e4f}}}, + { 0x1e50, {1, {0x1e51}}}, + { 0x1e52, {1, {0x1e53}}}, + { 0x1e54, {1, {0x1e55}}}, + { 0x1e56, {1, {0x1e57}}}, + { 0x1e58, {1, {0x1e59}}}, + { 0x1e5a, {1, {0x1e5b}}}, + { 0x1e5c, {1, {0x1e5d}}}, + { 0x1e5e, {1, {0x1e5f}}}, + { 0x1e60, {1, {0x1e61}}}, + { 0x1e62, {1, {0x1e63}}}, + { 0x1e64, {1, {0x1e65}}}, + { 0x1e66, {1, {0x1e67}}}, + { 0x1e68, {1, {0x1e69}}}, + { 0x1e6a, {1, {0x1e6b}}}, + { 0x1e6c, {1, {0x1e6d}}}, + { 0x1e6e, {1, {0x1e6f}}}, + { 0x1e70, {1, {0x1e71}}}, + { 0x1e72, {1, {0x1e73}}}, + { 0x1e74, {1, {0x1e75}}}, + { 0x1e76, {1, {0x1e77}}}, + { 0x1e78, {1, {0x1e79}}}, + { 0x1e7a, {1, {0x1e7b}}}, + { 0x1e7c, {1, {0x1e7d}}}, + { 0x1e7e, {1, {0x1e7f}}}, + { 0x1e80, {1, {0x1e81}}}, + { 0x1e82, {1, {0x1e83}}}, + { 0x1e84, {1, {0x1e85}}}, + { 0x1e86, {1, {0x1e87}}}, + { 0x1e88, {1, {0x1e89}}}, + { 0x1e8a, {1, {0x1e8b}}}, + { 0x1e8c, {1, {0x1e8d}}}, + { 0x1e8e, {1, {0x1e8f}}}, + { 0x1e90, {1, {0x1e91}}}, + { 0x1e92, {1, {0x1e93}}}, + { 0x1e94, {1, {0x1e95}}}, + { 0x1e96, {2, {0x0068, 0x0331}}}, + { 0x1e97, {2, {0x0074, 0x0308}}}, + { 0x1e98, {2, {0x0077, 0x030a}}}, + { 0x1e99, {2, {0x0079, 0x030a}}}, + { 0x1e9a, {2, {0x0061, 0x02be}}}, + { 0x1e9b, {1, {0x1e61}}}, + { 0x1ea0, {1, {0x1ea1}}}, + { 0x1ea2, {1, {0x1ea3}}}, + { 0x1ea4, {1, {0x1ea5}}}, + { 0x1ea6, {1, {0x1ea7}}}, + { 0x1ea8, {1, {0x1ea9}}}, + { 0x1eaa, {1, {0x1eab}}}, + { 0x1eac, {1, {0x1ead}}}, + { 0x1eae, {1, {0x1eaf}}}, + { 0x1eb0, {1, {0x1eb1}}}, + { 0x1eb2, {1, {0x1eb3}}}, + { 0x1eb4, {1, {0x1eb5}}}, + { 0x1eb6, {1, {0x1eb7}}}, + { 0x1eb8, {1, {0x1eb9}}}, + { 0x1eba, {1, {0x1ebb}}}, + { 0x1ebc, {1, {0x1ebd}}}, + { 0x1ebe, {1, {0x1ebf}}}, + { 0x1ec0, {1, {0x1ec1}}}, + { 0x1ec2, {1, {0x1ec3}}}, + { 0x1ec4, {1, {0x1ec5}}}, + { 0x1ec6, {1, {0x1ec7}}}, + { 0x1ec8, {1, {0x1ec9}}}, + { 0x1eca, {1, {0x1ecb}}}, + { 0x1ecc, {1, {0x1ecd}}}, + { 0x1ece, {1, {0x1ecf}}}, + { 0x1ed0, {1, {0x1ed1}}}, + { 0x1ed2, {1, {0x1ed3}}}, + { 0x1ed4, {1, {0x1ed5}}}, + { 0x1ed6, {1, {0x1ed7}}}, + { 0x1ed8, {1, {0x1ed9}}}, + { 0x1eda, {1, {0x1edb}}}, + { 0x1edc, {1, {0x1edd}}}, + { 0x1ede, {1, {0x1edf}}}, + { 0x1ee0, {1, {0x1ee1}}}, + { 0x1ee2, {1, {0x1ee3}}}, + { 0x1ee4, {1, {0x1ee5}}}, + { 0x1ee6, {1, {0x1ee7}}}, + { 0x1ee8, {1, {0x1ee9}}}, + { 0x1eea, {1, {0x1eeb}}}, + { 0x1eec, {1, {0x1eed}}}, + { 0x1eee, {1, {0x1eef}}}, + { 0x1ef0, {1, {0x1ef1}}}, + { 0x1ef2, {1, {0x1ef3}}}, + { 0x1ef4, {1, {0x1ef5}}}, + { 0x1ef6, {1, {0x1ef7}}}, + { 0x1ef8, {1, {0x1ef9}}}, + { 0x1f08, {1, {0x1f00}}}, + { 0x1f09, {1, {0x1f01}}}, + { 0x1f0a, {1, {0x1f02}}}, + { 0x1f0b, {1, {0x1f03}}}, + { 0x1f0c, {1, {0x1f04}}}, + { 0x1f0d, {1, {0x1f05}}}, + { 0x1f0e, {1, {0x1f06}}}, + { 0x1f0f, {1, {0x1f07}}}, + { 0x1f18, {1, {0x1f10}}}, + { 0x1f19, {1, {0x1f11}}}, + { 0x1f1a, {1, {0x1f12}}}, + { 0x1f1b, {1, {0x1f13}}}, + { 0x1f1c, {1, {0x1f14}}}, + { 0x1f1d, {1, {0x1f15}}}, + { 0x1f28, {1, {0x1f20}}}, + { 0x1f29, {1, {0x1f21}}}, + { 0x1f2a, {1, {0x1f22}}}, + { 0x1f2b, {1, {0x1f23}}}, + { 0x1f2c, {1, {0x1f24}}}, + { 0x1f2d, {1, {0x1f25}}}, + { 0x1f2e, {1, {0x1f26}}}, + { 0x1f2f, {1, {0x1f27}}}, + { 0x1f38, {1, {0x1f30}}}, + { 0x1f39, {1, {0x1f31}}}, + { 0x1f3a, {1, {0x1f32}}}, + { 0x1f3b, {1, {0x1f33}}}, + { 0x1f3c, {1, {0x1f34}}}, + { 0x1f3d, {1, {0x1f35}}}, + { 0x1f3e, {1, {0x1f36}}}, + { 0x1f3f, {1, {0x1f37}}}, + { 0x1f48, {1, {0x1f40}}}, + { 0x1f49, {1, {0x1f41}}}, + { 0x1f4a, {1, {0x1f42}}}, + { 0x1f4b, {1, {0x1f43}}}, + { 0x1f4c, {1, {0x1f44}}}, + { 0x1f4d, {1, {0x1f45}}}, + { 0x1f50, {2, {0x03c5, 0x0313}}}, + { 0x1f52, {3, {0x03c5, 0x0313, 0x0300}}}, + { 0x1f54, {3, {0x03c5, 0x0313, 0x0301}}}, + { 0x1f56, {3, {0x03c5, 0x0313, 0x0342}}}, + { 0x1f59, {1, {0x1f51}}}, + { 0x1f5b, {1, {0x1f53}}}, + { 0x1f5d, {1, {0x1f55}}}, + { 0x1f5f, {1, {0x1f57}}}, + { 0x1f68, {1, {0x1f60}}}, + { 0x1f69, {1, {0x1f61}}}, + { 0x1f6a, {1, {0x1f62}}}, + { 0x1f6b, {1, {0x1f63}}}, + { 0x1f6c, {1, {0x1f64}}}, + { 0x1f6d, {1, {0x1f65}}}, + { 0x1f6e, {1, {0x1f66}}}, + { 0x1f6f, {1, {0x1f67}}}, + { 0x1f80, {2, {0x1f00, 0x03b9}}}, + { 0x1f81, {2, {0x1f01, 0x03b9}}}, + { 0x1f82, {2, {0x1f02, 0x03b9}}}, + { 0x1f83, {2, {0x1f03, 0x03b9}}}, + { 0x1f84, {2, {0x1f04, 0x03b9}}}, + { 0x1f85, {2, {0x1f05, 0x03b9}}}, + { 0x1f86, {2, {0x1f06, 0x03b9}}}, + { 0x1f87, {2, {0x1f07, 0x03b9}}}, + { 0x1f88, {2, {0x1f00, 0x03b9}}}, + { 0x1f89, {2, {0x1f01, 0x03b9}}}, + { 0x1f8a, {2, {0x1f02, 0x03b9}}}, + { 0x1f8b, {2, {0x1f03, 0x03b9}}}, + { 0x1f8c, {2, {0x1f04, 0x03b9}}}, + { 0x1f8d, {2, {0x1f05, 0x03b9}}}, + { 0x1f8e, {2, {0x1f06, 0x03b9}}}, + { 0x1f8f, {2, {0x1f07, 0x03b9}}}, + { 0x1f90, {2, {0x1f20, 0x03b9}}}, + { 0x1f91, {2, {0x1f21, 0x03b9}}}, + { 0x1f92, {2, {0x1f22, 0x03b9}}}, + { 0x1f93, {2, {0x1f23, 0x03b9}}}, + { 0x1f94, {2, {0x1f24, 0x03b9}}}, + { 0x1f95, {2, {0x1f25, 0x03b9}}}, + { 0x1f96, {2, {0x1f26, 0x03b9}}}, + { 0x1f97, {2, {0x1f27, 0x03b9}}}, + { 0x1f98, {2, {0x1f20, 0x03b9}}}, + { 0x1f99, {2, {0x1f21, 0x03b9}}}, + { 0x1f9a, {2, {0x1f22, 0x03b9}}}, + { 0x1f9b, {2, {0x1f23, 0x03b9}}}, + { 0x1f9c, {2, {0x1f24, 0x03b9}}}, + { 0x1f9d, {2, {0x1f25, 0x03b9}}}, + { 0x1f9e, {2, {0x1f26, 0x03b9}}}, + { 0x1f9f, {2, {0x1f27, 0x03b9}}}, + { 0x1fa0, {2, {0x1f60, 0x03b9}}}, + { 0x1fa1, {2, {0x1f61, 0x03b9}}}, + { 0x1fa2, {2, {0x1f62, 0x03b9}}}, + { 0x1fa3, {2, {0x1f63, 0x03b9}}}, + { 0x1fa4, {2, {0x1f64, 0x03b9}}}, + { 0x1fa5, {2, {0x1f65, 0x03b9}}}, + { 0x1fa6, {2, {0x1f66, 0x03b9}}}, + { 0x1fa7, {2, {0x1f67, 0x03b9}}}, + { 0x1fa8, {2, {0x1f60, 0x03b9}}}, + { 0x1fa9, {2, {0x1f61, 0x03b9}}}, + { 0x1faa, {2, {0x1f62, 0x03b9}}}, + { 0x1fab, {2, {0x1f63, 0x03b9}}}, + { 0x1fac, {2, {0x1f64, 0x03b9}}}, + { 0x1fad, {2, {0x1f65, 0x03b9}}}, + { 0x1fae, {2, {0x1f66, 0x03b9}}}, + { 0x1faf, {2, {0x1f67, 0x03b9}}}, + { 0x1fb2, {2, {0x1f70, 0x03b9}}}, + { 0x1fb3, {2, {0x03b1, 0x03b9}}}, + { 0x1fb4, {2, {0x03ac, 0x03b9}}}, + { 0x1fb6, {2, {0x03b1, 0x0342}}}, + { 0x1fb7, {3, {0x03b1, 0x0342, 0x03b9}}}, + { 0x1fb8, {1, {0x1fb0}}}, + { 0x1fb9, {1, {0x1fb1}}}, + { 0x1fba, {1, {0x1f70}}}, + { 0x1fbb, {1, {0x1f71}}}, + { 0x1fbc, {2, {0x03b1, 0x03b9}}}, + { 0x1fbe, {1, {0x03b9}}}, + { 0x1fc2, {2, {0x1f74, 0x03b9}}}, + { 0x1fc3, {2, {0x03b7, 0x03b9}}}, + { 0x1fc4, {2, {0x03ae, 0x03b9}}}, + { 0x1fc6, {2, {0x03b7, 0x0342}}}, + { 0x1fc7, {3, {0x03b7, 0x0342, 0x03b9}}}, + { 0x1fc8, {1, {0x1f72}}}, + { 0x1fc9, {1, {0x1f73}}}, + { 0x1fca, {1, {0x1f74}}}, + { 0x1fcb, {1, {0x1f75}}}, + { 0x1fcc, {2, {0x03b7, 0x03b9}}}, + { 0x1fd2, {3, {0x03b9, 0x0308, 0x0300}}}, + { 0x1fd3, {3, {0x03b9, 0x0308, 0x0301}}}, + { 0x1fd6, {2, {0x03b9, 0x0342}}}, + { 0x1fd7, {3, {0x03b9, 0x0308, 0x0342}}}, + { 0x1fd8, {1, {0x1fd0}}}, + { 0x1fd9, {1, {0x1fd1}}}, + { 0x1fda, {1, {0x1f76}}}, + { 0x1fdb, {1, {0x1f77}}}, + { 0x1fe2, {3, {0x03c5, 0x0308, 0x0300}}}, + { 0x1fe3, {3, {0x03c5, 0x0308, 0x0301}}}, + { 0x1fe4, {2, {0x03c1, 0x0313}}}, + { 0x1fe6, {2, {0x03c5, 0x0342}}}, + { 0x1fe7, {3, {0x03c5, 0x0308, 0x0342}}}, + { 0x1fe8, {1, {0x1fe0}}}, + { 0x1fe9, {1, {0x1fe1}}}, + { 0x1fea, {1, {0x1f7a}}}, + { 0x1feb, {1, {0x1f7b}}}, + { 0x1fec, {1, {0x1fe5}}}, + { 0x1ff2, {2, {0x1f7c, 0x03b9}}}, + { 0x1ff3, {2, {0x03c9, 0x03b9}}}, + { 0x1ff4, {2, {0x03ce, 0x03b9}}}, + { 0x1ff6, {2, {0x03c9, 0x0342}}}, + { 0x1ff7, {3, {0x03c9, 0x0342, 0x03b9}}}, + { 0x1ff8, {1, {0x1f78}}}, + { 0x1ff9, {1, {0x1f79}}}, + { 0x1ffa, {1, {0x1f7c}}}, + { 0x1ffb, {1, {0x1f7d}}}, + { 0x1ffc, {2, {0x03c9, 0x03b9}}}, + { 0x2126, {1, {0x03c9}}}, + { 0x212a, {1, {0x006b}}}, + { 0x212b, {1, {0x00e5}}}, + { 0x2160, {1, {0x2170}}}, + { 0x2161, {1, {0x2171}}}, + { 0x2162, {1, {0x2172}}}, + { 0x2163, {1, {0x2173}}}, + { 0x2164, {1, {0x2174}}}, + { 0x2165, {1, {0x2175}}}, + { 0x2166, {1, {0x2176}}}, + { 0x2167, {1, {0x2177}}}, + { 0x2168, {1, {0x2178}}}, + { 0x2169, {1, {0x2179}}}, + { 0x216a, {1, {0x217a}}}, + { 0x216b, {1, {0x217b}}}, + { 0x216c, {1, {0x217c}}}, + { 0x216d, {1, {0x217d}}}, + { 0x216e, {1, {0x217e}}}, + { 0x216f, {1, {0x217f}}}, + { 0x24b6, {1, {0x24d0}}}, + { 0x24b7, {1, {0x24d1}}}, + { 0x24b8, {1, {0x24d2}}}, + { 0x24b9, {1, {0x24d3}}}, + { 0x24ba, {1, {0x24d4}}}, + { 0x24bb, {1, {0x24d5}}}, + { 0x24bc, {1, {0x24d6}}}, + { 0x24bd, {1, {0x24d7}}}, + { 0x24be, {1, {0x24d8}}}, + { 0x24bf, {1, {0x24d9}}}, + { 0x24c0, {1, {0x24da}}}, + { 0x24c1, {1, {0x24db}}}, + { 0x24c2, {1, {0x24dc}}}, + { 0x24c3, {1, {0x24dd}}}, + { 0x24c4, {1, {0x24de}}}, + { 0x24c5, {1, {0x24df}}}, + { 0x24c6, {1, {0x24e0}}}, + { 0x24c7, {1, {0x24e1}}}, + { 0x24c8, {1, {0x24e2}}}, + { 0x24c9, {1, {0x24e3}}}, + { 0x24ca, {1, {0x24e4}}}, + { 0x24cb, {1, {0x24e5}}}, + { 0x24cc, {1, {0x24e6}}}, + { 0x24cd, {1, {0x24e7}}}, + { 0x24ce, {1, {0x24e8}}}, + { 0x24cf, {1, {0x24e9}}}, + { 0x2c00, {1, {0x2c30}}}, + { 0x2c01, {1, {0x2c31}}}, + { 0x2c02, {1, {0x2c32}}}, + { 0x2c03, {1, {0x2c33}}}, + { 0x2c04, {1, {0x2c34}}}, + { 0x2c05, {1, {0x2c35}}}, + { 0x2c06, {1, {0x2c36}}}, + { 0x2c07, {1, {0x2c37}}}, + { 0x2c08, {1, {0x2c38}}}, + { 0x2c09, {1, {0x2c39}}}, + { 0x2c0a, {1, {0x2c3a}}}, + { 0x2c0b, {1, {0x2c3b}}}, + { 0x2c0c, {1, {0x2c3c}}}, + { 0x2c0d, {1, {0x2c3d}}}, + { 0x2c0e, {1, {0x2c3e}}}, + { 0x2c0f, {1, {0x2c3f}}}, + { 0x2c10, {1, {0x2c40}}}, + { 0x2c11, {1, {0x2c41}}}, + { 0x2c12, {1, {0x2c42}}}, + { 0x2c13, {1, {0x2c43}}}, + { 0x2c14, {1, {0x2c44}}}, + { 0x2c15, {1, {0x2c45}}}, + { 0x2c16, {1, {0x2c46}}}, + { 0x2c17, {1, {0x2c47}}}, + { 0x2c18, {1, {0x2c48}}}, + { 0x2c19, {1, {0x2c49}}}, + { 0x2c1a, {1, {0x2c4a}}}, + { 0x2c1b, {1, {0x2c4b}}}, + { 0x2c1c, {1, {0x2c4c}}}, + { 0x2c1d, {1, {0x2c4d}}}, + { 0x2c1e, {1, {0x2c4e}}}, + { 0x2c1f, {1, {0x2c4f}}}, + { 0x2c20, {1, {0x2c50}}}, + { 0x2c21, {1, {0x2c51}}}, + { 0x2c22, {1, {0x2c52}}}, + { 0x2c23, {1, {0x2c53}}}, + { 0x2c24, {1, {0x2c54}}}, + { 0x2c25, {1, {0x2c55}}}, + { 0x2c26, {1, {0x2c56}}}, + { 0x2c27, {1, {0x2c57}}}, + { 0x2c28, {1, {0x2c58}}}, + { 0x2c29, {1, {0x2c59}}}, + { 0x2c2a, {1, {0x2c5a}}}, + { 0x2c2b, {1, {0x2c5b}}}, + { 0x2c2c, {1, {0x2c5c}}}, + { 0x2c2d, {1, {0x2c5d}}}, + { 0x2c2e, {1, {0x2c5e}}}, + { 0x2c80, {1, {0x2c81}}}, + { 0x2c82, {1, {0x2c83}}}, + { 0x2c84, {1, {0x2c85}}}, + { 0x2c86, {1, {0x2c87}}}, + { 0x2c88, {1, {0x2c89}}}, + { 0x2c8a, {1, {0x2c8b}}}, + { 0x2c8c, {1, {0x2c8d}}}, + { 0x2c8e, {1, {0x2c8f}}}, + { 0x2c90, {1, {0x2c91}}}, + { 0x2c92, {1, {0x2c93}}}, + { 0x2c94, {1, {0x2c95}}}, + { 0x2c96, {1, {0x2c97}}}, + { 0x2c98, {1, {0x2c99}}}, + { 0x2c9a, {1, {0x2c9b}}}, + { 0x2c9c, {1, {0x2c9d}}}, + { 0x2c9e, {1, {0x2c9f}}}, + { 0x2ca0, {1, {0x2ca1}}}, + { 0x2ca2, {1, {0x2ca3}}}, + { 0x2ca4, {1, {0x2ca5}}}, + { 0x2ca6, {1, {0x2ca7}}}, + { 0x2ca8, {1, {0x2ca9}}}, + { 0x2caa, {1, {0x2cab}}}, + { 0x2cac, {1, {0x2cad}}}, + { 0x2cae, {1, {0x2caf}}}, + { 0x2cb0, {1, {0x2cb1}}}, + { 0x2cb2, {1, {0x2cb3}}}, + { 0x2cb4, {1, {0x2cb5}}}, + { 0x2cb6, {1, {0x2cb7}}}, + { 0x2cb8, {1, {0x2cb9}}}, + { 0x2cba, {1, {0x2cbb}}}, + { 0x2cbc, {1, {0x2cbd}}}, + { 0x2cbe, {1, {0x2cbf}}}, + { 0x2cc0, {1, {0x2cc1}}}, + { 0x2cc2, {1, {0x2cc3}}}, + { 0x2cc4, {1, {0x2cc5}}}, + { 0x2cc6, {1, {0x2cc7}}}, + { 0x2cc8, {1, {0x2cc9}}}, + { 0x2cca, {1, {0x2ccb}}}, + { 0x2ccc, {1, {0x2ccd}}}, + { 0x2cce, {1, {0x2ccf}}}, + { 0x2cd0, {1, {0x2cd1}}}, + { 0x2cd2, {1, {0x2cd3}}}, + { 0x2cd4, {1, {0x2cd5}}}, + { 0x2cd6, {1, {0x2cd7}}}, + { 0x2cd8, {1, {0x2cd9}}}, + { 0x2cda, {1, {0x2cdb}}}, + { 0x2cdc, {1, {0x2cdd}}}, + { 0x2cde, {1, {0x2cdf}}}, + { 0x2ce0, {1, {0x2ce1}}}, + { 0x2ce2, {1, {0x2ce3}}}, + { 0xfb00, {2, {0x0066, 0x0066}}}, + { 0xfb01, {2, {0x0066, 0x0069}}}, + { 0xfb02, {2, {0x0066, 0x006c}}}, + { 0xfb03, {3, {0x0066, 0x0066, 0x0069}}}, + { 0xfb04, {3, {0x0066, 0x0066, 0x006c}}}, + { 0xfb05, {2, {0x0073, 0x0074}}}, + { 0xfb06, {2, {0x0073, 0x0074}}}, + { 0xfb13, {2, {0x0574, 0x0576}}}, + { 0xfb14, {2, {0x0574, 0x0565}}}, + { 0xfb15, {2, {0x0574, 0x056b}}}, + { 0xfb16, {2, {0x057e, 0x0576}}}, + { 0xfb17, {2, {0x0574, 0x056d}}}, + { 0xff21, {1, {0xff41}}}, + { 0xff22, {1, {0xff42}}}, + { 0xff23, {1, {0xff43}}}, + { 0xff24, {1, {0xff44}}}, + { 0xff25, {1, {0xff45}}}, + { 0xff26, {1, {0xff46}}}, + { 0xff27, {1, {0xff47}}}, + { 0xff28, {1, {0xff48}}}, + { 0xff29, {1, {0xff49}}}, + { 0xff2a, {1, {0xff4a}}}, + { 0xff2b, {1, {0xff4b}}}, + { 0xff2c, {1, {0xff4c}}}, + { 0xff2d, {1, {0xff4d}}}, + { 0xff2e, {1, {0xff4e}}}, + { 0xff2f, {1, {0xff4f}}}, + { 0xff30, {1, {0xff50}}}, + { 0xff31, {1, {0xff51}}}, + { 0xff32, {1, {0xff52}}}, + { 0xff33, {1, {0xff53}}}, + { 0xff34, {1, {0xff54}}}, + { 0xff35, {1, {0xff55}}}, + { 0xff36, {1, {0xff56}}}, + { 0xff37, {1, {0xff57}}}, + { 0xff38, {1, {0xff58}}}, + { 0xff39, {1, {0xff59}}}, + { 0xff3a, {1, {0xff5a}}}, + { 0x10400, {1, {0x10428}}}, + { 0x10401, {1, {0x10429}}}, + { 0x10402, {1, {0x1042a}}}, + { 0x10403, {1, {0x1042b}}}, + { 0x10404, {1, {0x1042c}}}, + { 0x10405, {1, {0x1042d}}}, + { 0x10406, {1, {0x1042e}}}, + { 0x10407, {1, {0x1042f}}}, + { 0x10408, {1, {0x10430}}}, + { 0x10409, {1, {0x10431}}}, + { 0x1040a, {1, {0x10432}}}, + { 0x1040b, {1, {0x10433}}}, + { 0x1040c, {1, {0x10434}}}, + { 0x1040d, {1, {0x10435}}}, + { 0x1040e, {1, {0x10436}}}, + { 0x1040f, {1, {0x10437}}}, + { 0x10410, {1, {0x10438}}}, + { 0x10411, {1, {0x10439}}}, + { 0x10412, {1, {0x1043a}}}, + { 0x10413, {1, {0x1043b}}}, + { 0x10414, {1, {0x1043c}}}, + { 0x10415, {1, {0x1043d}}}, + { 0x10416, {1, {0x1043e}}}, + { 0x10417, {1, {0x1043f}}}, + { 0x10418, {1, {0x10440}}}, + { 0x10419, {1, {0x10441}}}, + { 0x1041a, {1, {0x10442}}}, + { 0x1041b, {1, {0x10443}}}, + { 0x1041c, {1, {0x10444}}}, + { 0x1041d, {1, {0x10445}}}, + { 0x1041e, {1, {0x10446}}}, + { 0x1041f, {1, {0x10447}}}, + { 0x10420, {1, {0x10448}}}, + { 0x10421, {1, {0x10449}}}, + { 0x10422, {1, {0x1044a}}}, + { 0x10423, {1, {0x1044b}}}, + { 0x10424, {1, {0x1044c}}}, + { 0x10425, {1, {0x1044d}}}, + { 0x10426, {1, {0x1044e}}}, + { 0x10427, {1, {0x1044f}}} +}; + +static const CaseFold_11_Type CaseFold_Locale[] = { + { 0x0049, {1, {0x0069}}}, + { 0x0130, {2, {0x0069, 0x0307}}} +}; + +static const CaseUnfold_11_Type CaseUnfold_11[] = { + { 0x0061, {1, {0x0041 }}}, + { 0x0062, {1, {0x0042 }}}, + { 0x0063, {1, {0x0043 }}}, + { 0x0064, {1, {0x0044 }}}, + { 0x0065, {1, {0x0045 }}}, + { 0x0066, {1, {0x0046 }}}, + { 0x0067, {1, {0x0047 }}}, + { 0x0068, {1, {0x0048 }}}, + { 0x006a, {1, {0x004a }}}, + { 0x006b, {2, {0x212a, 0x004b }}}, + { 0x006c, {1, {0x004c }}}, + { 0x006d, {1, {0x004d }}}, + { 0x006e, {1, {0x004e }}}, + { 0x006f, {1, {0x004f }}}, + { 0x0070, {1, {0x0050 }}}, + { 0x0071, {1, {0x0051 }}}, + { 0x0072, {1, {0x0052 }}}, + { 0x0073, {2, {0x0053, 0x017f }}}, + { 0x0074, {1, {0x0054 }}}, + { 0x0075, {1, {0x0055 }}}, + { 0x0076, {1, {0x0056 }}}, + { 0x0077, {1, {0x0057 }}}, + { 0x0078, {1, {0x0058 }}}, + { 0x0079, {1, {0x0059 }}}, + { 0x007a, {1, {0x005a }}}, + { 0x00e0, {1, {0x00c0 }}}, + { 0x00e1, {1, {0x00c1 }}}, + { 0x00e2, {1, {0x00c2 }}}, + { 0x00e3, {1, {0x00c3 }}}, + { 0x00e4, {1, {0x00c4 }}}, + { 0x00e5, {2, {0x212b, 0x00c5 }}}, + { 0x00e6, {1, {0x00c6 }}}, + { 0x00e7, {1, {0x00c7 }}}, + { 0x00e8, {1, {0x00c8 }}}, + { 0x00e9, {1, {0x00c9 }}}, + { 0x00ea, {1, {0x00ca }}}, + { 0x00eb, {1, {0x00cb }}}, + { 0x00ec, {1, {0x00cc }}}, + { 0x00ed, {1, {0x00cd }}}, + { 0x00ee, {1, {0x00ce }}}, + { 0x00ef, {1, {0x00cf }}}, + { 0x00f0, {1, {0x00d0 }}}, + { 0x00f1, {1, {0x00d1 }}}, + { 0x00f2, {1, {0x00d2 }}}, + { 0x00f3, {1, {0x00d3 }}}, + { 0x00f4, {1, {0x00d4 }}}, + { 0x00f5, {1, {0x00d5 }}}, + { 0x00f6, {1, {0x00d6 }}}, + { 0x00f8, {1, {0x00d8 }}}, + { 0x00f9, {1, {0x00d9 }}}, + { 0x00fa, {1, {0x00da }}}, + { 0x00fb, {1, {0x00db }}}, + { 0x00fc, {1, {0x00dc }}}, + { 0x00fd, {1, {0x00dd }}}, + { 0x00fe, {1, {0x00de }}}, + { 0x00ff, {1, {0x0178 }}}, + { 0x0101, {1, {0x0100 }}}, + { 0x0103, {1, {0x0102 }}}, + { 0x0105, {1, {0x0104 }}}, + { 0x0107, {1, {0x0106 }}}, + { 0x0109, {1, {0x0108 }}}, + { 0x010b, {1, {0x010a }}}, + { 0x010d, {1, {0x010c }}}, + { 0x010f, {1, {0x010e }}}, + { 0x0111, {1, {0x0110 }}}, + { 0x0113, {1, {0x0112 }}}, + { 0x0115, {1, {0x0114 }}}, + { 0x0117, {1, {0x0116 }}}, + { 0x0119, {1, {0x0118 }}}, + { 0x011b, {1, {0x011a }}}, + { 0x011d, {1, {0x011c }}}, + { 0x011f, {1, {0x011e }}}, + { 0x0121, {1, {0x0120 }}}, + { 0x0123, {1, {0x0122 }}}, + { 0x0125, {1, {0x0124 }}}, + { 0x0127, {1, {0x0126 }}}, + { 0x0129, {1, {0x0128 }}}, + { 0x012b, {1, {0x012a }}}, + { 0x012d, {1, {0x012c }}}, + { 0x012f, {1, {0x012e }}}, + { 0x0133, {1, {0x0132 }}}, + { 0x0135, {1, {0x0134 }}}, + { 0x0137, {1, {0x0136 }}}, + { 0x013a, {1, {0x0139 }}}, + { 0x013c, {1, {0x013b }}}, + { 0x013e, {1, {0x013d }}}, + { 0x0140, {1, {0x013f }}}, + { 0x0142, {1, {0x0141 }}}, + { 0x0144, {1, {0x0143 }}}, + { 0x0146, {1, {0x0145 }}}, + { 0x0148, {1, {0x0147 }}}, + { 0x014b, {1, {0x014a }}}, + { 0x014d, {1, {0x014c }}}, + { 0x014f, {1, {0x014e }}}, + { 0x0151, {1, {0x0150 }}}, + { 0x0153, {1, {0x0152 }}}, + { 0x0155, {1, {0x0154 }}}, + { 0x0157, {1, {0x0156 }}}, + { 0x0159, {1, {0x0158 }}}, + { 0x015b, {1, {0x015a }}}, + { 0x015d, {1, {0x015c }}}, + { 0x015f, {1, {0x015e }}}, + { 0x0161, {1, {0x0160 }}}, + { 0x0163, {1, {0x0162 }}}, + { 0x0165, {1, {0x0164 }}}, + { 0x0167, {1, {0x0166 }}}, + { 0x0169, {1, {0x0168 }}}, + { 0x016b, {1, {0x016a }}}, + { 0x016d, {1, {0x016c }}}, + { 0x016f, {1, {0x016e }}}, + { 0x0171, {1, {0x0170 }}}, + { 0x0173, {1, {0x0172 }}}, + { 0x0175, {1, {0x0174 }}}, + { 0x0177, {1, {0x0176 }}}, + { 0x017a, {1, {0x0179 }}}, + { 0x017c, {1, {0x017b }}}, + { 0x017e, {1, {0x017d }}}, + { 0x0183, {1, {0x0182 }}}, + { 0x0185, {1, {0x0184 }}}, + { 0x0188, {1, {0x0187 }}}, + { 0x018c, {1, {0x018b }}}, + { 0x0192, {1, {0x0191 }}}, + { 0x0195, {1, {0x01f6 }}}, + { 0x0199, {1, {0x0198 }}}, + { 0x019a, {1, {0x023d }}}, + { 0x019e, {1, {0x0220 }}}, + { 0x01a1, {1, {0x01a0 }}}, + { 0x01a3, {1, {0x01a2 }}}, + { 0x01a5, {1, {0x01a4 }}}, + { 0x01a8, {1, {0x01a7 }}}, + { 0x01ad, {1, {0x01ac }}}, + { 0x01b0, {1, {0x01af }}}, + { 0x01b4, {1, {0x01b3 }}}, + { 0x01b6, {1, {0x01b5 }}}, + { 0x01b9, {1, {0x01b8 }}}, + { 0x01bd, {1, {0x01bc }}}, + { 0x01bf, {1, {0x01f7 }}}, + { 0x01c6, {2, {0x01c4, 0x01c5 }}}, + { 0x01c9, {2, {0x01c7, 0x01c8 }}}, + { 0x01cc, {2, {0x01ca, 0x01cb }}}, + { 0x01ce, {1, {0x01cd }}}, + { 0x01d0, {1, {0x01cf }}}, + { 0x01d2, {1, {0x01d1 }}}, + { 0x01d4, {1, {0x01d3 }}}, + { 0x01d6, {1, {0x01d5 }}}, + { 0x01d8, {1, {0x01d7 }}}, + { 0x01da, {1, {0x01d9 }}}, + { 0x01dc, {1, {0x01db }}}, + { 0x01dd, {1, {0x018e }}}, + { 0x01df, {1, {0x01de }}}, + { 0x01e1, {1, {0x01e0 }}}, + { 0x01e3, {1, {0x01e2 }}}, + { 0x01e5, {1, {0x01e4 }}}, + { 0x01e7, {1, {0x01e6 }}}, + { 0x01e9, {1, {0x01e8 }}}, + { 0x01eb, {1, {0x01ea }}}, + { 0x01ed, {1, {0x01ec }}}, + { 0x01ef, {1, {0x01ee }}}, + { 0x01f3, {2, {0x01f1, 0x01f2 }}}, + { 0x01f5, {1, {0x01f4 }}}, + { 0x01f9, {1, {0x01f8 }}}, + { 0x01fb, {1, {0x01fa }}}, + { 0x01fd, {1, {0x01fc }}}, + { 0x01ff, {1, {0x01fe }}}, + { 0x0201, {1, {0x0200 }}}, + { 0x0203, {1, {0x0202 }}}, + { 0x0205, {1, {0x0204 }}}, + { 0x0207, {1, {0x0206 }}}, + { 0x0209, {1, {0x0208 }}}, + { 0x020b, {1, {0x020a }}}, + { 0x020d, {1, {0x020c }}}, + { 0x020f, {1, {0x020e }}}, + { 0x0211, {1, {0x0210 }}}, + { 0x0213, {1, {0x0212 }}}, + { 0x0215, {1, {0x0214 }}}, + { 0x0217, {1, {0x0216 }}}, + { 0x0219, {1, {0x0218 }}}, + { 0x021b, {1, {0x021a }}}, + { 0x021d, {1, {0x021c }}}, + { 0x021f, {1, {0x021e }}}, + { 0x0223, {1, {0x0222 }}}, + { 0x0225, {1, {0x0224 }}}, + { 0x0227, {1, {0x0226 }}}, + { 0x0229, {1, {0x0228 }}}, + { 0x022b, {1, {0x022a }}}, + { 0x022d, {1, {0x022c }}}, + { 0x022f, {1, {0x022e }}}, + { 0x0231, {1, {0x0230 }}}, + { 0x0233, {1, {0x0232 }}}, + { 0x023c, {1, {0x023b }}}, + { 0x0253, {1, {0x0181 }}}, + { 0x0254, {1, {0x0186 }}}, + { 0x0256, {1, {0x0189 }}}, + { 0x0257, {1, {0x018a }}}, + { 0x0259, {1, {0x018f }}}, + { 0x025b, {1, {0x0190 }}}, + { 0x0260, {1, {0x0193 }}}, + { 0x0263, {1, {0x0194 }}}, + { 0x0268, {1, {0x0197 }}}, + { 0x0269, {1, {0x0196 }}}, + { 0x026f, {1, {0x019c }}}, + { 0x0272, {1, {0x019d }}}, + { 0x0275, {1, {0x019f }}}, + { 0x0280, {1, {0x01a6 }}}, + { 0x0283, {1, {0x01a9 }}}, + { 0x0288, {1, {0x01ae }}}, + { 0x028a, {1, {0x01b1 }}}, + { 0x028b, {1, {0x01b2 }}}, + { 0x0292, {1, {0x01b7 }}}, + { 0x0294, {1, {0x0241 }}}, + { 0x03ac, {1, {0x0386 }}}, + { 0x03ad, {1, {0x0388 }}}, + { 0x03ae, {1, {0x0389 }}}, + { 0x03af, {1, {0x038a }}}, + { 0x03b1, {1, {0x0391 }}}, + { 0x03b2, {2, {0x0392, 0x03d0 }}}, + { 0x03b3, {1, {0x0393 }}}, + { 0x03b4, {1, {0x0394 }}}, + { 0x03b5, {2, {0x03f5, 0x0395 }}}, + { 0x03b6, {1, {0x0396 }}}, + { 0x03b7, {1, {0x0397 }}}, + { 0x03b8, {3, {0x03f4, 0x0398, 0x03d1 }}}, + { 0x03b9, {3, {0x1fbe, 0x0399, 0x0345 }}}, + { 0x03ba, {2, {0x03f0, 0x039a }}}, + { 0x03bb, {1, {0x039b }}}, + { 0x03bc, {2, {0x00b5, 0x039c }}}, + { 0x03bd, {1, {0x039d }}}, + { 0x03be, {1, {0x039e }}}, + { 0x03bf, {1, {0x039f }}}, + { 0x03c0, {2, {0x03a0, 0x03d6 }}}, + { 0x03c1, {2, {0x03f1, 0x03a1 }}}, + { 0x03c3, {2, {0x03a3, 0x03c2 }}}, + { 0x03c4, {1, {0x03a4 }}}, + { 0x03c5, {1, {0x03a5 }}}, + { 0x03c6, {2, {0x03a6, 0x03d5 }}}, + { 0x03c7, {1, {0x03a7 }}}, + { 0x03c8, {1, {0x03a8 }}}, + { 0x03c9, {2, {0x03a9, 0x2126 }}}, + { 0x03ca, {1, {0x03aa }}}, + { 0x03cb, {1, {0x03ab }}}, + { 0x03cc, {1, {0x038c }}}, + { 0x03cd, {1, {0x038e }}}, + { 0x03ce, {1, {0x038f }}}, + { 0x03d9, {1, {0x03d8 }}}, + { 0x03db, {1, {0x03da }}}, + { 0x03dd, {1, {0x03dc }}}, + { 0x03df, {1, {0x03de }}}, + { 0x03e1, {1, {0x03e0 }}}, + { 0x03e3, {1, {0x03e2 }}}, + { 0x03e5, {1, {0x03e4 }}}, + { 0x03e7, {1, {0x03e6 }}}, + { 0x03e9, {1, {0x03e8 }}}, + { 0x03eb, {1, {0x03ea }}}, + { 0x03ed, {1, {0x03ec }}}, + { 0x03ef, {1, {0x03ee }}}, + { 0x03f2, {1, {0x03f9 }}}, + { 0x03f8, {1, {0x03f7 }}}, + { 0x03fb, {1, {0x03fa }}}, + { 0x0430, {1, {0x0410 }}}, + { 0x0431, {1, {0x0411 }}}, + { 0x0432, {1, {0x0412 }}}, + { 0x0433, {1, {0x0413 }}}, + { 0x0434, {1, {0x0414 }}}, + { 0x0435, {1, {0x0415 }}}, + { 0x0436, {1, {0x0416 }}}, + { 0x0437, {1, {0x0417 }}}, + { 0x0438, {1, {0x0418 }}}, + { 0x0439, {1, {0x0419 }}}, + { 0x043a, {1, {0x041a }}}, + { 0x043b, {1, {0x041b }}}, + { 0x043c, {1, {0x041c }}}, + { 0x043d, {1, {0x041d }}}, + { 0x043e, {1, {0x041e }}}, + { 0x043f, {1, {0x041f }}}, + { 0x0440, {1, {0x0420 }}}, + { 0x0441, {1, {0x0421 }}}, + { 0x0442, {1, {0x0422 }}}, + { 0x0443, {1, {0x0423 }}}, + { 0x0444, {1, {0x0424 }}}, + { 0x0445, {1, {0x0425 }}}, + { 0x0446, {1, {0x0426 }}}, + { 0x0447, {1, {0x0427 }}}, + { 0x0448, {1, {0x0428 }}}, + { 0x0449, {1, {0x0429 }}}, + { 0x044a, {1, {0x042a }}}, + { 0x044b, {1, {0x042b }}}, + { 0x044c, {1, {0x042c }}}, + { 0x044d, {1, {0x042d }}}, + { 0x044e, {1, {0x042e }}}, + { 0x044f, {1, {0x042f }}}, + { 0x0450, {1, {0x0400 }}}, + { 0x0451, {1, {0x0401 }}}, + { 0x0452, {1, {0x0402 }}}, + { 0x0453, {1, {0x0403 }}}, + { 0x0454, {1, {0x0404 }}}, + { 0x0455, {1, {0x0405 }}}, + { 0x0456, {1, {0x0406 }}}, + { 0x0457, {1, {0x0407 }}}, + { 0x0458, {1, {0x0408 }}}, + { 0x0459, {1, {0x0409 }}}, + { 0x045a, {1, {0x040a }}}, + { 0x045b, {1, {0x040b }}}, + { 0x045c, {1, {0x040c }}}, + { 0x045d, {1, {0x040d }}}, + { 0x045e, {1, {0x040e }}}, + { 0x045f, {1, {0x040f }}}, + { 0x0461, {1, {0x0460 }}}, + { 0x0463, {1, {0x0462 }}}, + { 0x0465, {1, {0x0464 }}}, + { 0x0467, {1, {0x0466 }}}, + { 0x0469, {1, {0x0468 }}}, + { 0x046b, {1, {0x046a }}}, + { 0x046d, {1, {0x046c }}}, + { 0x046f, {1, {0x046e }}}, + { 0x0471, {1, {0x0470 }}}, + { 0x0473, {1, {0x0472 }}}, + { 0x0475, {1, {0x0474 }}}, + { 0x0477, {1, {0x0476 }}}, + { 0x0479, {1, {0x0478 }}}, + { 0x047b, {1, {0x047a }}}, + { 0x047d, {1, {0x047c }}}, + { 0x047f, {1, {0x047e }}}, + { 0x0481, {1, {0x0480 }}}, + { 0x048b, {1, {0x048a }}}, + { 0x048d, {1, {0x048c }}}, + { 0x048f, {1, {0x048e }}}, + { 0x0491, {1, {0x0490 }}}, + { 0x0493, {1, {0x0492 }}}, + { 0x0495, {1, {0x0494 }}}, + { 0x0497, {1, {0x0496 }}}, + { 0x0499, {1, {0x0498 }}}, + { 0x049b, {1, {0x049a }}}, + { 0x049d, {1, {0x049c }}}, + { 0x049f, {1, {0x049e }}}, + { 0x04a1, {1, {0x04a0 }}}, + { 0x04a3, {1, {0x04a2 }}}, + { 0x04a5, {1, {0x04a4 }}}, + { 0x04a7, {1, {0x04a6 }}}, + { 0x04a9, {1, {0x04a8 }}}, + { 0x04ab, {1, {0x04aa }}}, + { 0x04ad, {1, {0x04ac }}}, + { 0x04af, {1, {0x04ae }}}, + { 0x04b1, {1, {0x04b0 }}}, + { 0x04b3, {1, {0x04b2 }}}, + { 0x04b5, {1, {0x04b4 }}}, + { 0x04b7, {1, {0x04b6 }}}, + { 0x04b9, {1, {0x04b8 }}}, + { 0x04bb, {1, {0x04ba }}}, + { 0x04bd, {1, {0x04bc }}}, + { 0x04bf, {1, {0x04be }}}, + { 0x04c2, {1, {0x04c1 }}}, + { 0x04c4, {1, {0x04c3 }}}, + { 0x04c6, {1, {0x04c5 }}}, + { 0x04c8, {1, {0x04c7 }}}, + { 0x04ca, {1, {0x04c9 }}}, + { 0x04cc, {1, {0x04cb }}}, + { 0x04ce, {1, {0x04cd }}}, + { 0x04d1, {1, {0x04d0 }}}, + { 0x04d3, {1, {0x04d2 }}}, + { 0x04d5, {1, {0x04d4 }}}, + { 0x04d7, {1, {0x04d6 }}}, + { 0x04d9, {1, {0x04d8 }}}, + { 0x04db, {1, {0x04da }}}, + { 0x04dd, {1, {0x04dc }}}, + { 0x04df, {1, {0x04de }}}, + { 0x04e1, {1, {0x04e0 }}}, + { 0x04e3, {1, {0x04e2 }}}, + { 0x04e5, {1, {0x04e4 }}}, + { 0x04e7, {1, {0x04e6 }}}, + { 0x04e9, {1, {0x04e8 }}}, + { 0x04eb, {1, {0x04ea }}}, + { 0x04ed, {1, {0x04ec }}}, + { 0x04ef, {1, {0x04ee }}}, + { 0x04f1, {1, {0x04f0 }}}, + { 0x04f3, {1, {0x04f2 }}}, + { 0x04f5, {1, {0x04f4 }}}, + { 0x04f7, {1, {0x04f6 }}}, + { 0x04f9, {1, {0x04f8 }}}, + { 0x0501, {1, {0x0500 }}}, + { 0x0503, {1, {0x0502 }}}, + { 0x0505, {1, {0x0504 }}}, + { 0x0507, {1, {0x0506 }}}, + { 0x0509, {1, {0x0508 }}}, + { 0x050b, {1, {0x050a }}}, + { 0x050d, {1, {0x050c }}}, + { 0x050f, {1, {0x050e }}}, + { 0x0561, {1, {0x0531 }}}, + { 0x0562, {1, {0x0532 }}}, + { 0x0563, {1, {0x0533 }}}, + { 0x0564, {1, {0x0534 }}}, + { 0x0565, {1, {0x0535 }}}, + { 0x0566, {1, {0x0536 }}}, + { 0x0567, {1, {0x0537 }}}, + { 0x0568, {1, {0x0538 }}}, + { 0x0569, {1, {0x0539 }}}, + { 0x056a, {1, {0x053a }}}, + { 0x056b, {1, {0x053b }}}, + { 0x056c, {1, {0x053c }}}, + { 0x056d, {1, {0x053d }}}, + { 0x056e, {1, {0x053e }}}, + { 0x056f, {1, {0x053f }}}, + { 0x0570, {1, {0x0540 }}}, + { 0x0571, {1, {0x0541 }}}, + { 0x0572, {1, {0x0542 }}}, + { 0x0573, {1, {0x0543 }}}, + { 0x0574, {1, {0x0544 }}}, + { 0x0575, {1, {0x0545 }}}, + { 0x0576, {1, {0x0546 }}}, + { 0x0577, {1, {0x0547 }}}, + { 0x0578, {1, {0x0548 }}}, + { 0x0579, {1, {0x0549 }}}, + { 0x057a, {1, {0x054a }}}, + { 0x057b, {1, {0x054b }}}, + { 0x057c, {1, {0x054c }}}, + { 0x057d, {1, {0x054d }}}, + { 0x057e, {1, {0x054e }}}, + { 0x057f, {1, {0x054f }}}, + { 0x0580, {1, {0x0550 }}}, + { 0x0581, {1, {0x0551 }}}, + { 0x0582, {1, {0x0552 }}}, + { 0x0583, {1, {0x0553 }}}, + { 0x0584, {1, {0x0554 }}}, + { 0x0585, {1, {0x0555 }}}, + { 0x0586, {1, {0x0556 }}}, + { 0x1e01, {1, {0x1e00 }}}, + { 0x1e03, {1, {0x1e02 }}}, + { 0x1e05, {1, {0x1e04 }}}, + { 0x1e07, {1, {0x1e06 }}}, + { 0x1e09, {1, {0x1e08 }}}, + { 0x1e0b, {1, {0x1e0a }}}, + { 0x1e0d, {1, {0x1e0c }}}, + { 0x1e0f, {1, {0x1e0e }}}, + { 0x1e11, {1, {0x1e10 }}}, + { 0x1e13, {1, {0x1e12 }}}, + { 0x1e15, {1, {0x1e14 }}}, + { 0x1e17, {1, {0x1e16 }}}, + { 0x1e19, {1, {0x1e18 }}}, + { 0x1e1b, {1, {0x1e1a }}}, + { 0x1e1d, {1, {0x1e1c }}}, + { 0x1e1f, {1, {0x1e1e }}}, + { 0x1e21, {1, {0x1e20 }}}, + { 0x1e23, {1, {0x1e22 }}}, + { 0x1e25, {1, {0x1e24 }}}, + { 0x1e27, {1, {0x1e26 }}}, + { 0x1e29, {1, {0x1e28 }}}, + { 0x1e2b, {1, {0x1e2a }}}, + { 0x1e2d, {1, {0x1e2c }}}, + { 0x1e2f, {1, {0x1e2e }}}, + { 0x1e31, {1, {0x1e30 }}}, + { 0x1e33, {1, {0x1e32 }}}, + { 0x1e35, {1, {0x1e34 }}}, + { 0x1e37, {1, {0x1e36 }}}, + { 0x1e39, {1, {0x1e38 }}}, + { 0x1e3b, {1, {0x1e3a }}}, + { 0x1e3d, {1, {0x1e3c }}}, + { 0x1e3f, {1, {0x1e3e }}}, + { 0x1e41, {1, {0x1e40 }}}, + { 0x1e43, {1, {0x1e42 }}}, + { 0x1e45, {1, {0x1e44 }}}, + { 0x1e47, {1, {0x1e46 }}}, + { 0x1e49, {1, {0x1e48 }}}, + { 0x1e4b, {1, {0x1e4a }}}, + { 0x1e4d, {1, {0x1e4c }}}, + { 0x1e4f, {1, {0x1e4e }}}, + { 0x1e51, {1, {0x1e50 }}}, + { 0x1e53, {1, {0x1e52 }}}, + { 0x1e55, {1, {0x1e54 }}}, + { 0x1e57, {1, {0x1e56 }}}, + { 0x1e59, {1, {0x1e58 }}}, + { 0x1e5b, {1, {0x1e5a }}}, + { 0x1e5d, {1, {0x1e5c }}}, + { 0x1e5f, {1, {0x1e5e }}}, + { 0x1e61, {2, {0x1e9b, 0x1e60 }}}, + { 0x1e63, {1, {0x1e62 }}}, + { 0x1e65, {1, {0x1e64 }}}, + { 0x1e67, {1, {0x1e66 }}}, + { 0x1e69, {1, {0x1e68 }}}, + { 0x1e6b, {1, {0x1e6a }}}, + { 0x1e6d, {1, {0x1e6c }}}, + { 0x1e6f, {1, {0x1e6e }}}, + { 0x1e71, {1, {0x1e70 }}}, + { 0x1e73, {1, {0x1e72 }}}, + { 0x1e75, {1, {0x1e74 }}}, + { 0x1e77, {1, {0x1e76 }}}, + { 0x1e79, {1, {0x1e78 }}}, + { 0x1e7b, {1, {0x1e7a }}}, + { 0x1e7d, {1, {0x1e7c }}}, + { 0x1e7f, {1, {0x1e7e }}}, + { 0x1e81, {1, {0x1e80 }}}, + { 0x1e83, {1, {0x1e82 }}}, + { 0x1e85, {1, {0x1e84 }}}, + { 0x1e87, {1, {0x1e86 }}}, + { 0x1e89, {1, {0x1e88 }}}, + { 0x1e8b, {1, {0x1e8a }}}, + { 0x1e8d, {1, {0x1e8c }}}, + { 0x1e8f, {1, {0x1e8e }}}, + { 0x1e91, {1, {0x1e90 }}}, + { 0x1e93, {1, {0x1e92 }}}, + { 0x1e95, {1, {0x1e94 }}}, + { 0x1ea1, {1, {0x1ea0 }}}, + { 0x1ea3, {1, {0x1ea2 }}}, + { 0x1ea5, {1, {0x1ea4 }}}, + { 0x1ea7, {1, {0x1ea6 }}}, + { 0x1ea9, {1, {0x1ea8 }}}, + { 0x1eab, {1, {0x1eaa }}}, + { 0x1ead, {1, {0x1eac }}}, + { 0x1eaf, {1, {0x1eae }}}, + { 0x1eb1, {1, {0x1eb0 }}}, + { 0x1eb3, {1, {0x1eb2 }}}, + { 0x1eb5, {1, {0x1eb4 }}}, + { 0x1eb7, {1, {0x1eb6 }}}, + { 0x1eb9, {1, {0x1eb8 }}}, + { 0x1ebb, {1, {0x1eba }}}, + { 0x1ebd, {1, {0x1ebc }}}, + { 0x1ebf, {1, {0x1ebe }}}, + { 0x1ec1, {1, {0x1ec0 }}}, + { 0x1ec3, {1, {0x1ec2 }}}, + { 0x1ec5, {1, {0x1ec4 }}}, + { 0x1ec7, {1, {0x1ec6 }}}, + { 0x1ec9, {1, {0x1ec8 }}}, + { 0x1ecb, {1, {0x1eca }}}, + { 0x1ecd, {1, {0x1ecc }}}, + { 0x1ecf, {1, {0x1ece }}}, + { 0x1ed1, {1, {0x1ed0 }}}, + { 0x1ed3, {1, {0x1ed2 }}}, + { 0x1ed5, {1, {0x1ed4 }}}, + { 0x1ed7, {1, {0x1ed6 }}}, + { 0x1ed9, {1, {0x1ed8 }}}, + { 0x1edb, {1, {0x1eda }}}, + { 0x1edd, {1, {0x1edc }}}, + { 0x1edf, {1, {0x1ede }}}, + { 0x1ee1, {1, {0x1ee0 }}}, + { 0x1ee3, {1, {0x1ee2 }}}, + { 0x1ee5, {1, {0x1ee4 }}}, + { 0x1ee7, {1, {0x1ee6 }}}, + { 0x1ee9, {1, {0x1ee8 }}}, + { 0x1eeb, {1, {0x1eea }}}, + { 0x1eed, {1, {0x1eec }}}, + { 0x1eef, {1, {0x1eee }}}, + { 0x1ef1, {1, {0x1ef0 }}}, + { 0x1ef3, {1, {0x1ef2 }}}, + { 0x1ef5, {1, {0x1ef4 }}}, + { 0x1ef7, {1, {0x1ef6 }}}, + { 0x1ef9, {1, {0x1ef8 }}}, + { 0x1f00, {1, {0x1f08 }}}, + { 0x1f01, {1, {0x1f09 }}}, + { 0x1f02, {1, {0x1f0a }}}, + { 0x1f03, {1, {0x1f0b }}}, + { 0x1f04, {1, {0x1f0c }}}, + { 0x1f05, {1, {0x1f0d }}}, + { 0x1f06, {1, {0x1f0e }}}, + { 0x1f07, {1, {0x1f0f }}}, + { 0x1f10, {1, {0x1f18 }}}, + { 0x1f11, {1, {0x1f19 }}}, + { 0x1f12, {1, {0x1f1a }}}, + { 0x1f13, {1, {0x1f1b }}}, + { 0x1f14, {1, {0x1f1c }}}, + { 0x1f15, {1, {0x1f1d }}}, + { 0x1f20, {1, {0x1f28 }}}, + { 0x1f21, {1, {0x1f29 }}}, + { 0x1f22, {1, {0x1f2a }}}, + { 0x1f23, {1, {0x1f2b }}}, + { 0x1f24, {1, {0x1f2c }}}, + { 0x1f25, {1, {0x1f2d }}}, + { 0x1f26, {1, {0x1f2e }}}, + { 0x1f27, {1, {0x1f2f }}}, + { 0x1f30, {1, {0x1f38 }}}, + { 0x1f31, {1, {0x1f39 }}}, + { 0x1f32, {1, {0x1f3a }}}, + { 0x1f33, {1, {0x1f3b }}}, + { 0x1f34, {1, {0x1f3c }}}, + { 0x1f35, {1, {0x1f3d }}}, + { 0x1f36, {1, {0x1f3e }}}, + { 0x1f37, {1, {0x1f3f }}}, + { 0x1f40, {1, {0x1f48 }}}, + { 0x1f41, {1, {0x1f49 }}}, + { 0x1f42, {1, {0x1f4a }}}, + { 0x1f43, {1, {0x1f4b }}}, + { 0x1f44, {1, {0x1f4c }}}, + { 0x1f45, {1, {0x1f4d }}}, + { 0x1f51, {1, {0x1f59 }}}, + { 0x1f53, {1, {0x1f5b }}}, + { 0x1f55, {1, {0x1f5d }}}, + { 0x1f57, {1, {0x1f5f }}}, + { 0x1f60, {1, {0x1f68 }}}, + { 0x1f61, {1, {0x1f69 }}}, + { 0x1f62, {1, {0x1f6a }}}, + { 0x1f63, {1, {0x1f6b }}}, + { 0x1f64, {1, {0x1f6c }}}, + { 0x1f65, {1, {0x1f6d }}}, + { 0x1f66, {1, {0x1f6e }}}, + { 0x1f67, {1, {0x1f6f }}}, + { 0x1f70, {1, {0x1fba }}}, + { 0x1f71, {1, {0x1fbb }}}, + { 0x1f72, {1, {0x1fc8 }}}, + { 0x1f73, {1, {0x1fc9 }}}, + { 0x1f74, {1, {0x1fca }}}, + { 0x1f75, {1, {0x1fcb }}}, + { 0x1f76, {1, {0x1fda }}}, + { 0x1f77, {1, {0x1fdb }}}, + { 0x1f78, {1, {0x1ff8 }}}, + { 0x1f79, {1, {0x1ff9 }}}, + { 0x1f7a, {1, {0x1fea }}}, + { 0x1f7b, {1, {0x1feb }}}, + { 0x1f7c, {1, {0x1ffa }}}, + { 0x1f7d, {1, {0x1ffb }}}, + { 0x1fb0, {1, {0x1fb8 }}}, + { 0x1fb1, {1, {0x1fb9 }}}, + { 0x1fd0, {1, {0x1fd8 }}}, + { 0x1fd1, {1, {0x1fd9 }}}, + { 0x1fe0, {1, {0x1fe8 }}}, + { 0x1fe1, {1, {0x1fe9 }}}, + { 0x1fe5, {1, {0x1fec }}}, + { 0x2170, {1, {0x2160 }}}, + { 0x2171, {1, {0x2161 }}}, + { 0x2172, {1, {0x2162 }}}, + { 0x2173, {1, {0x2163 }}}, + { 0x2174, {1, {0x2164 }}}, + { 0x2175, {1, {0x2165 }}}, + { 0x2176, {1, {0x2166 }}}, + { 0x2177, {1, {0x2167 }}}, + { 0x2178, {1, {0x2168 }}}, + { 0x2179, {1, {0x2169 }}}, + { 0x217a, {1, {0x216a }}}, + { 0x217b, {1, {0x216b }}}, + { 0x217c, {1, {0x216c }}}, + { 0x217d, {1, {0x216d }}}, + { 0x217e, {1, {0x216e }}}, + { 0x217f, {1, {0x216f }}}, + { 0x24d0, {1, {0x24b6 }}}, + { 0x24d1, {1, {0x24b7 }}}, + { 0x24d2, {1, {0x24b8 }}}, + { 0x24d3, {1, {0x24b9 }}}, + { 0x24d4, {1, {0x24ba }}}, + { 0x24d5, {1, {0x24bb }}}, + { 0x24d6, {1, {0x24bc }}}, + { 0x24d7, {1, {0x24bd }}}, + { 0x24d8, {1, {0x24be }}}, + { 0x24d9, {1, {0x24bf }}}, + { 0x24da, {1, {0x24c0 }}}, + { 0x24db, {1, {0x24c1 }}}, + { 0x24dc, {1, {0x24c2 }}}, + { 0x24dd, {1, {0x24c3 }}}, + { 0x24de, {1, {0x24c4 }}}, + { 0x24df, {1, {0x24c5 }}}, + { 0x24e0, {1, {0x24c6 }}}, + { 0x24e1, {1, {0x24c7 }}}, + { 0x24e2, {1, {0x24c8 }}}, + { 0x24e3, {1, {0x24c9 }}}, + { 0x24e4, {1, {0x24ca }}}, + { 0x24e5, {1, {0x24cb }}}, + { 0x24e6, {1, {0x24cc }}}, + { 0x24e7, {1, {0x24cd }}}, + { 0x24e8, {1, {0x24ce }}}, + { 0x24e9, {1, {0x24cf }}}, + { 0x2c30, {1, {0x2c00 }}}, + { 0x2c31, {1, {0x2c01 }}}, + { 0x2c32, {1, {0x2c02 }}}, + { 0x2c33, {1, {0x2c03 }}}, + { 0x2c34, {1, {0x2c04 }}}, + { 0x2c35, {1, {0x2c05 }}}, + { 0x2c36, {1, {0x2c06 }}}, + { 0x2c37, {1, {0x2c07 }}}, + { 0x2c38, {1, {0x2c08 }}}, + { 0x2c39, {1, {0x2c09 }}}, + { 0x2c3a, {1, {0x2c0a }}}, + { 0x2c3b, {1, {0x2c0b }}}, + { 0x2c3c, {1, {0x2c0c }}}, + { 0x2c3d, {1, {0x2c0d }}}, + { 0x2c3e, {1, {0x2c0e }}}, + { 0x2c3f, {1, {0x2c0f }}}, + { 0x2c40, {1, {0x2c10 }}}, + { 0x2c41, {1, {0x2c11 }}}, + { 0x2c42, {1, {0x2c12 }}}, + { 0x2c43, {1, {0x2c13 }}}, + { 0x2c44, {1, {0x2c14 }}}, + { 0x2c45, {1, {0x2c15 }}}, + { 0x2c46, {1, {0x2c16 }}}, + { 0x2c47, {1, {0x2c17 }}}, + { 0x2c48, {1, {0x2c18 }}}, + { 0x2c49, {1, {0x2c19 }}}, + { 0x2c4a, {1, {0x2c1a }}}, + { 0x2c4b, {1, {0x2c1b }}}, + { 0x2c4c, {1, {0x2c1c }}}, + { 0x2c4d, {1, {0x2c1d }}}, + { 0x2c4e, {1, {0x2c1e }}}, + { 0x2c4f, {1, {0x2c1f }}}, + { 0x2c50, {1, {0x2c20 }}}, + { 0x2c51, {1, {0x2c21 }}}, + { 0x2c52, {1, {0x2c22 }}}, + { 0x2c53, {1, {0x2c23 }}}, + { 0x2c54, {1, {0x2c24 }}}, + { 0x2c55, {1, {0x2c25 }}}, + { 0x2c56, {1, {0x2c26 }}}, + { 0x2c57, {1, {0x2c27 }}}, + { 0x2c58, {1, {0x2c28 }}}, + { 0x2c59, {1, {0x2c29 }}}, + { 0x2c5a, {1, {0x2c2a }}}, + { 0x2c5b, {1, {0x2c2b }}}, + { 0x2c5c, {1, {0x2c2c }}}, + { 0x2c5d, {1, {0x2c2d }}}, + { 0x2c5e, {1, {0x2c2e }}}, + { 0x2c81, {1, {0x2c80 }}}, + { 0x2c83, {1, {0x2c82 }}}, + { 0x2c85, {1, {0x2c84 }}}, + { 0x2c87, {1, {0x2c86 }}}, + { 0x2c89, {1, {0x2c88 }}}, + { 0x2c8b, {1, {0x2c8a }}}, + { 0x2c8d, {1, {0x2c8c }}}, + { 0x2c8f, {1, {0x2c8e }}}, + { 0x2c91, {1, {0x2c90 }}}, + { 0x2c93, {1, {0x2c92 }}}, + { 0x2c95, {1, {0x2c94 }}}, + { 0x2c97, {1, {0x2c96 }}}, + { 0x2c99, {1, {0x2c98 }}}, + { 0x2c9b, {1, {0x2c9a }}}, + { 0x2c9d, {1, {0x2c9c }}}, + { 0x2c9f, {1, {0x2c9e }}}, + { 0x2ca1, {1, {0x2ca0 }}}, + { 0x2ca3, {1, {0x2ca2 }}}, + { 0x2ca5, {1, {0x2ca4 }}}, + { 0x2ca7, {1, {0x2ca6 }}}, + { 0x2ca9, {1, {0x2ca8 }}}, + { 0x2cab, {1, {0x2caa }}}, + { 0x2cad, {1, {0x2cac }}}, + { 0x2caf, {1, {0x2cae }}}, + { 0x2cb1, {1, {0x2cb0 }}}, + { 0x2cb3, {1, {0x2cb2 }}}, + { 0x2cb5, {1, {0x2cb4 }}}, + { 0x2cb7, {1, {0x2cb6 }}}, + { 0x2cb9, {1, {0x2cb8 }}}, + { 0x2cbb, {1, {0x2cba }}}, + { 0x2cbd, {1, {0x2cbc }}}, + { 0x2cbf, {1, {0x2cbe }}}, + { 0x2cc1, {1, {0x2cc0 }}}, + { 0x2cc3, {1, {0x2cc2 }}}, + { 0x2cc5, {1, {0x2cc4 }}}, + { 0x2cc7, {1, {0x2cc6 }}}, + { 0x2cc9, {1, {0x2cc8 }}}, + { 0x2ccb, {1, {0x2cca }}}, + { 0x2ccd, {1, {0x2ccc }}}, + { 0x2ccf, {1, {0x2cce }}}, + { 0x2cd1, {1, {0x2cd0 }}}, + { 0x2cd3, {1, {0x2cd2 }}}, + { 0x2cd5, {1, {0x2cd4 }}}, + { 0x2cd7, {1, {0x2cd6 }}}, + { 0x2cd9, {1, {0x2cd8 }}}, + { 0x2cdb, {1, {0x2cda }}}, + { 0x2cdd, {1, {0x2cdc }}}, + { 0x2cdf, {1, {0x2cde }}}, + { 0x2ce1, {1, {0x2ce0 }}}, + { 0x2ce3, {1, {0x2ce2 }}}, + { 0x2d00, {1, {0x10a0 }}}, + { 0x2d01, {1, {0x10a1 }}}, + { 0x2d02, {1, {0x10a2 }}}, + { 0x2d03, {1, {0x10a3 }}}, + { 0x2d04, {1, {0x10a4 }}}, + { 0x2d05, {1, {0x10a5 }}}, + { 0x2d06, {1, {0x10a6 }}}, + { 0x2d07, {1, {0x10a7 }}}, + { 0x2d08, {1, {0x10a8 }}}, + { 0x2d09, {1, {0x10a9 }}}, + { 0x2d0a, {1, {0x10aa }}}, + { 0x2d0b, {1, {0x10ab }}}, + { 0x2d0c, {1, {0x10ac }}}, + { 0x2d0d, {1, {0x10ad }}}, + { 0x2d0e, {1, {0x10ae }}}, + { 0x2d0f, {1, {0x10af }}}, + { 0x2d10, {1, {0x10b0 }}}, + { 0x2d11, {1, {0x10b1 }}}, + { 0x2d12, {1, {0x10b2 }}}, + { 0x2d13, {1, {0x10b3 }}}, + { 0x2d14, {1, {0x10b4 }}}, + { 0x2d15, {1, {0x10b5 }}}, + { 0x2d16, {1, {0x10b6 }}}, + { 0x2d17, {1, {0x10b7 }}}, + { 0x2d18, {1, {0x10b8 }}}, + { 0x2d19, {1, {0x10b9 }}}, + { 0x2d1a, {1, {0x10ba }}}, + { 0x2d1b, {1, {0x10bb }}}, + { 0x2d1c, {1, {0x10bc }}}, + { 0x2d1d, {1, {0x10bd }}}, + { 0x2d1e, {1, {0x10be }}}, + { 0x2d1f, {1, {0x10bf }}}, + { 0x2d20, {1, {0x10c0 }}}, + { 0x2d21, {1, {0x10c1 }}}, + { 0x2d22, {1, {0x10c2 }}}, + { 0x2d23, {1, {0x10c3 }}}, + { 0x2d24, {1, {0x10c4 }}}, + { 0x2d25, {1, {0x10c5 }}}, + { 0xff41, {1, {0xff21 }}}, + { 0xff42, {1, {0xff22 }}}, + { 0xff43, {1, {0xff23 }}}, + { 0xff44, {1, {0xff24 }}}, + { 0xff45, {1, {0xff25 }}}, + { 0xff46, {1, {0xff26 }}}, + { 0xff47, {1, {0xff27 }}}, + { 0xff48, {1, {0xff28 }}}, + { 0xff49, {1, {0xff29 }}}, + { 0xff4a, {1, {0xff2a }}}, + { 0xff4b, {1, {0xff2b }}}, + { 0xff4c, {1, {0xff2c }}}, + { 0xff4d, {1, {0xff2d }}}, + { 0xff4e, {1, {0xff2e }}}, + { 0xff4f, {1, {0xff2f }}}, + { 0xff50, {1, {0xff30 }}}, + { 0xff51, {1, {0xff31 }}}, + { 0xff52, {1, {0xff32 }}}, + { 0xff53, {1, {0xff33 }}}, + { 0xff54, {1, {0xff34 }}}, + { 0xff55, {1, {0xff35 }}}, + { 0xff56, {1, {0xff36 }}}, + { 0xff57, {1, {0xff37 }}}, + { 0xff58, {1, {0xff38 }}}, + { 0xff59, {1, {0xff39 }}}, + { 0xff5a, {1, {0xff3a }}}, + { 0x10428, {1, {0x10400 }}}, + { 0x10429, {1, {0x10401 }}}, + { 0x1042a, {1, {0x10402 }}}, + { 0x1042b, {1, {0x10403 }}}, + { 0x1042c, {1, {0x10404 }}}, + { 0x1042d, {1, {0x10405 }}}, + { 0x1042e, {1, {0x10406 }}}, + { 0x1042f, {1, {0x10407 }}}, + { 0x10430, {1, {0x10408 }}}, + { 0x10431, {1, {0x10409 }}}, + { 0x10432, {1, {0x1040a }}}, + { 0x10433, {1, {0x1040b }}}, + { 0x10434, {1, {0x1040c }}}, + { 0x10435, {1, {0x1040d }}}, + { 0x10436, {1, {0x1040e }}}, + { 0x10437, {1, {0x1040f }}}, + { 0x10438, {1, {0x10410 }}}, + { 0x10439, {1, {0x10411 }}}, + { 0x1043a, {1, {0x10412 }}}, + { 0x1043b, {1, {0x10413 }}}, + { 0x1043c, {1, {0x10414 }}}, + { 0x1043d, {1, {0x10415 }}}, + { 0x1043e, {1, {0x10416 }}}, + { 0x1043f, {1, {0x10417 }}}, + { 0x10440, {1, {0x10418 }}}, + { 0x10441, {1, {0x10419 }}}, + { 0x10442, {1, {0x1041a }}}, + { 0x10443, {1, {0x1041b }}}, + { 0x10444, {1, {0x1041c }}}, + { 0x10445, {1, {0x1041d }}}, + { 0x10446, {1, {0x1041e }}}, + { 0x10447, {1, {0x1041f }}}, + { 0x10448, {1, {0x10420 }}}, + { 0x10449, {1, {0x10421 }}}, + { 0x1044a, {1, {0x10422 }}}, + { 0x1044b, {1, {0x10423 }}}, + { 0x1044c, {1, {0x10424 }}}, + { 0x1044d, {1, {0x10425 }}}, + { 0x1044e, {1, {0x10426 }}}, + { 0x1044f, {1, {0x10427 }}} +}; + +static const CaseUnfold_11_Type CaseUnfold_11_Locale[] = { + { 0x0069, {1, {0x0049 }}} +}; + +static const CaseUnfold_12_Type CaseUnfold_12[] = { + { {0x0061, 0x02be}, {1, {0x1e9a }}}, + { {0x0066, 0x0066}, {1, {0xfb00 }}}, + { {0x0066, 0x0069}, {1, {0xfb01 }}}, + { {0x0066, 0x006c}, {1, {0xfb02 }}}, + { {0x0068, 0x0331}, {1, {0x1e96 }}}, + { {0x006a, 0x030c}, {1, {0x01f0 }}}, + { {0x0073, 0x0073}, {1, {0x00df }}}, + { {0x0073, 0x0074}, {2, {0xfb05, 0xfb06 }}}, + { {0x0074, 0x0308}, {1, {0x1e97 }}}, + { {0x0077, 0x030a}, {1, {0x1e98 }}}, + { {0x0079, 0x030a}, {1, {0x1e99 }}}, + { {0x02bc, 0x006e}, {1, {0x0149 }}}, + { {0x03ac, 0x03b9}, {1, {0x1fb4 }}}, + { {0x03ae, 0x03b9}, {1, {0x1fc4 }}}, + { {0x03b1, 0x0342}, {1, {0x1fb6 }}}, + { {0x03b1, 0x03b9}, {2, {0x1fb3, 0x1fbc }}}, + { {0x03b7, 0x0342}, {1, {0x1fc6 }}}, + { {0x03b7, 0x03b9}, {2, {0x1fc3, 0x1fcc }}}, + { {0x03b9, 0x0342}, {1, {0x1fd6 }}}, + { {0x03c1, 0x0313}, {1, {0x1fe4 }}}, + { {0x03c5, 0x0313}, {1, {0x1f50 }}}, + { {0x03c5, 0x0342}, {1, {0x1fe6 }}}, + { {0x03c9, 0x0342}, {1, {0x1ff6 }}}, + { {0x03c9, 0x03b9}, {2, {0x1ff3, 0x1ffc }}}, + { {0x03ce, 0x03b9}, {1, {0x1ff4 }}}, + { {0x0565, 0x0582}, {1, {0x0587 }}}, + { {0x0574, 0x0565}, {1, {0xfb14 }}}, + { {0x0574, 0x056b}, {1, {0xfb15 }}}, + { {0x0574, 0x056d}, {1, {0xfb17 }}}, + { {0x0574, 0x0576}, {1, {0xfb13 }}}, + { {0x057e, 0x0576}, {1, {0xfb16 }}}, + { {0x1f00, 0x03b9}, {2, {0x1f88, 0x1f80 }}}, + { {0x1f01, 0x03b9}, {2, {0x1f81, 0x1f89 }}}, + { {0x1f02, 0x03b9}, {2, {0x1f82, 0x1f8a }}}, + { {0x1f03, 0x03b9}, {2, {0x1f83, 0x1f8b }}}, + { {0x1f04, 0x03b9}, {2, {0x1f84, 0x1f8c }}}, + { {0x1f05, 0x03b9}, {2, {0x1f85, 0x1f8d }}}, + { {0x1f06, 0x03b9}, {2, {0x1f86, 0x1f8e }}}, + { {0x1f07, 0x03b9}, {2, {0x1f87, 0x1f8f }}}, + { {0x1f20, 0x03b9}, {2, {0x1f90, 0x1f98 }}}, + { {0x1f21, 0x03b9}, {2, {0x1f91, 0x1f99 }}}, + { {0x1f22, 0x03b9}, {2, {0x1f92, 0x1f9a }}}, + { {0x1f23, 0x03b9}, {2, {0x1f93, 0x1f9b }}}, + { {0x1f24, 0x03b9}, {2, {0x1f94, 0x1f9c }}}, + { {0x1f25, 0x03b9}, {2, {0x1f95, 0x1f9d }}}, + { {0x1f26, 0x03b9}, {2, {0x1f96, 0x1f9e }}}, + { {0x1f27, 0x03b9}, {2, {0x1f97, 0x1f9f }}}, + { {0x1f60, 0x03b9}, {2, {0x1fa0, 0x1fa8 }}}, + { {0x1f61, 0x03b9}, {2, {0x1fa1, 0x1fa9 }}}, + { {0x1f62, 0x03b9}, {2, {0x1fa2, 0x1faa }}}, + { {0x1f63, 0x03b9}, {2, {0x1fa3, 0x1fab }}}, + { {0x1f64, 0x03b9}, {2, {0x1fa4, 0x1fac }}}, + { {0x1f65, 0x03b9}, {2, {0x1fa5, 0x1fad }}}, + { {0x1f66, 0x03b9}, {2, {0x1fa6, 0x1fae }}}, + { {0x1f67, 0x03b9}, {2, {0x1fa7, 0x1faf }}}, + { {0x1f70, 0x03b9}, {1, {0x1fb2 }}}, + { {0x1f74, 0x03b9}, {1, {0x1fc2 }}}, + { {0x1f7c, 0x03b9}, {1, {0x1ff2 }}} +}; + +static const CaseUnfold_12_Type CaseUnfold_12_Locale[] = { + { {0x0069, 0x0307}, {1, {0x0130 }}} +}; + +static const CaseUnfold_13_Type CaseUnfold_13[] = { + { {0x0066, 0x0066, 0x0069}, {1, {0xfb03 }}}, + { {0x0066, 0x0066, 0x006c}, {1, {0xfb04 }}}, + { {0x03b1, 0x0342, 0x03b9}, {1, {0x1fb7 }}}, + { {0x03b7, 0x0342, 0x03b9}, {1, {0x1fc7 }}}, + { {0x03b9, 0x0308, 0x0300}, {1, {0x1fd2 }}}, + { {0x03b9, 0x0308, 0x0301}, {2, {0x0390, 0x1fd3 }}}, + { {0x03b9, 0x0308, 0x0342}, {1, {0x1fd7 }}}, + { {0x03c5, 0x0308, 0x0300}, {1, {0x1fe2 }}}, + { {0x03c5, 0x0308, 0x0301}, {2, {0x03b0, 0x1fe3 }}}, + { {0x03c5, 0x0308, 0x0342}, {1, {0x1fe7 }}}, + { {0x03c5, 0x0313, 0x0300}, {1, {0x1f52 }}}, + { {0x03c5, 0x0313, 0x0301}, {1, {0x1f54 }}}, + { {0x03c5, 0x0313, 0x0342}, {1, {0x1f56 }}}, + { {0x03c9, 0x0342, 0x03b9}, {1, {0x1ff7 }}} +}; + + +static PosixBracketEntryType HashEntryData[] = { + { (UChar* )"NEWLINE", 0, 7 }, + { (UChar* )"Alpha", 1, 5 }, + { (UChar* )"Blank", 2, 5 }, + { (UChar* )"Cntrl", 3, 5 }, + { (UChar* )"Digit", 4, 5 }, + { (UChar* )"Graph", 5, 5 }, + { (UChar* )"Lower", 6, 5 }, + { (UChar* )"Print", 7, 5 }, + { (UChar* )"Punct", 8, 5 }, + { (UChar* )"Space", 9, 5 }, + { (UChar* )"Upper", 10, 5 }, + { (UChar* )"XDigit", 11, 6 }, + { (UChar* )"Word", 12, 4 }, + { (UChar* )"Alnum", 13, 5 }, + { (UChar* )"ASCII", 14, 5 }, + +#ifdef USE_UNICODE_PROPERTIES + { (UChar* )"Any", 15, 3 }, + { (UChar* )"Assigned", 16, 8 }, + { (UChar* )"C", 17, 1 }, + { (UChar* )"Cc", 18, 2 }, + { (UChar* )"Cf", 19, 2 }, + { (UChar* )"Cn", 20, 2 }, + { (UChar* )"Co", 21, 2 }, + { (UChar* )"Cs", 22, 2 }, + { (UChar* )"L", 23, 1 }, + { (UChar* )"Ll", 24, 2 }, + { (UChar* )"Lm", 25, 2 }, + { (UChar* )"Lo", 26, 2 }, + { (UChar* )"Lt", 27, 2 }, + { (UChar* )"Lu", 28, 2 }, + { (UChar* )"M", 29, 1 }, + { (UChar* )"Mc", 30, 2 }, + { (UChar* )"Me", 31, 2 }, + { (UChar* )"Mn", 32, 2 }, + { (UChar* )"N", 33, 1 }, + { (UChar* )"Nd", 34, 2 }, + { (UChar* )"Nl", 35, 2 }, + { (UChar* )"No", 36, 2 }, + { (UChar* )"P", 37, 1 }, + { (UChar* )"Pc", 38, 2 }, + { (UChar* )"Pd", 39, 2 }, + { (UChar* )"Pe", 40, 2 }, + { (UChar* )"Pf", 41, 2 }, + { (UChar* )"Pi", 42, 2 }, + { (UChar* )"Po", 43, 2 }, + { (UChar* )"Ps", 44, 2 }, + { (UChar* )"S", 45, 1 }, + { (UChar* )"Sc", 46, 2 }, + { (UChar* )"Sk", 47, 2 }, + { (UChar* )"Sm", 48, 2 }, + { (UChar* )"So", 49, 2 }, + { (UChar* )"Z", 50, 1 }, + { (UChar* )"Zl", 51, 2 }, + { (UChar* )"Zp", 52, 2 }, + { (UChar* )"Zs", 53, 2 }, + { (UChar* )"Arabic", 54, 6 }, + { (UChar* )"Armenian", 55, 8 }, + { (UChar* )"Bengali", 56, 7 }, + { (UChar* )"Bopomofo", 57, 8 }, + { (UChar* )"Braille", 58, 7 }, + { (UChar* )"Buginese", 59, 8 }, + { (UChar* )"Buhid", 60, 5 }, + { (UChar* )"Canadian_Aboriginal", 61, 19 }, + { (UChar* )"Cherokee", 62, 8 }, + { (UChar* )"Common", 63, 6 }, + { (UChar* )"Coptic", 64, 6 }, + { (UChar* )"Cypriot", 65, 7 }, + { (UChar* )"Cyrillic", 66, 8 }, + { (UChar* )"Deseret", 67, 7 }, + { (UChar* )"Devanagari", 68, 10 }, + { (UChar* )"Ethiopic", 69, 8 }, + { (UChar* )"Georgian", 70, 8 }, + { (UChar* )"Glagolitic", 71, 10 }, + { (UChar* )"Gothic", 72, 6 }, + { (UChar* )"Greek", 73, 5 }, + { (UChar* )"Gujarati", 74, 8 }, + { (UChar* )"Gurmukhi", 75, 8 }, + { (UChar* )"Han", 76, 3 }, + { (UChar* )"Hangul", 77, 6 }, + { (UChar* )"Hanunoo", 78, 7 }, + { (UChar* )"Hebrew", 79, 6 }, + { (UChar* )"Hiragana", 80, 8 }, + { (UChar* )"Inherited", 81, 9 }, + { (UChar* )"Kannada", 82, 7 }, + { (UChar* )"Katakana", 83, 8 }, + { (UChar* )"Kharoshthi", 84, 10 }, + { (UChar* )"Khmer", 85, 5 }, + { (UChar* )"Lao", 86, 3 }, + { (UChar* )"Latin", 87, 5 }, + { (UChar* )"Limbu", 88, 5 }, + { (UChar* )"Linear_B", 89, 8 }, + { (UChar* )"Malayalam", 90, 9 }, + { (UChar* )"Mongolian", 91, 9 }, + { (UChar* )"Myanmar", 92, 7 }, + { (UChar* )"New_Tai_Lue", 93, 11 }, + { (UChar* )"Ogham", 94, 5 }, + { (UChar* )"Old_Italic", 95, 10 }, + { (UChar* )"Old_Persian", 96, 11 }, + { (UChar* )"Oriya", 97, 5 }, + { (UChar* )"Osmanya", 98, 7 }, + { (UChar* )"Runic", 99, 5 }, + { (UChar* )"Shavian", 100, 7 }, + { (UChar* )"Sinhala", 101, 7 }, + { (UChar* )"Syloti_Nagri", 102, 12 }, + { (UChar* )"Syriac", 103, 6 }, + { (UChar* )"Tagalog", 104, 7 }, + { (UChar* )"Tagbanwa", 105, 8 }, + { (UChar* )"Tai_Le", 106, 6 }, + { (UChar* )"Tamil", 107, 5 }, + { (UChar* )"Telugu", 108, 6 }, + { (UChar* )"Thaana", 109, 6 }, + { (UChar* )"Thai", 110, 4 }, + { (UChar* )"Tibetan", 111, 7 }, + { (UChar* )"Tifinagh", 112, 8 }, + { (UChar* )"Ugaritic", 113, 8 }, + { (UChar* )"Yi", 114, 2 }, +#endif /* USE_UNICODE_PROPERTIES */ + { (UChar* )NULL, -1, 0 } +}; + +#ifdef USE_UNICODE_PROPERTIES +#define CODE_RANGES_NUM 115 +#else +#define CODE_RANGES_NUM 15 +#endif + +static const OnigCodePoint* CodeRanges[CODE_RANGES_NUM]; +static int CodeRangeTableInited = 0; + +static void init_code_range_array(void) { + THREAD_ATOMIC_START; + + CodeRanges[0] = CR_NEWLINE; + CodeRanges[1] = CR_Alpha; + CodeRanges[2] = CR_Blank; + CodeRanges[3] = CR_Cntrl; + CodeRanges[4] = CR_Digit; + CodeRanges[5] = CR_Graph; + CodeRanges[6] = CR_Lower; + CodeRanges[7] = CR_Print; + CodeRanges[8] = CR_Punct; + CodeRanges[9] = CR_Space; + CodeRanges[10] = CR_Upper; + CodeRanges[11] = CR_XDigit; + CodeRanges[12] = CR_Word; + CodeRanges[13] = CR_Alnum; + CodeRanges[14] = CR_ASCII; + +#ifdef USE_UNICODE_PROPERTIES + CodeRanges[15] = CR_Any; + CodeRanges[16] = CR_Assigned; + CodeRanges[17] = CR_C; + CodeRanges[18] = CR_Cc; + CodeRanges[19] = CR_Cf; + CodeRanges[20] = CR_Cn; + CodeRanges[21] = CR_Co; + CodeRanges[22] = CR_Cs; + CodeRanges[23] = CR_L; + CodeRanges[24] = CR_Ll; + CodeRanges[25] = CR_Lm; + CodeRanges[26] = CR_Lo; + CodeRanges[27] = CR_Lt; + CodeRanges[28] = CR_Lu; + CodeRanges[29] = CR_M; + CodeRanges[30] = CR_Mc; + CodeRanges[31] = CR_Me; + CodeRanges[32] = CR_Mn; + CodeRanges[33] = CR_N; + CodeRanges[34] = CR_Nd; + CodeRanges[35] = CR_Nl; + CodeRanges[36] = CR_No; + CodeRanges[37] = CR_P; + CodeRanges[38] = CR_Pc; + CodeRanges[39] = CR_Pd; + CodeRanges[40] = CR_Pe; + CodeRanges[41] = CR_Pf; + CodeRanges[42] = CR_Pi; + CodeRanges[43] = CR_Po; + CodeRanges[44] = CR_Ps; + CodeRanges[45] = CR_S; + CodeRanges[46] = CR_Sc; + CodeRanges[47] = CR_Sk; + CodeRanges[48] = CR_Sm; + CodeRanges[49] = CR_So; + CodeRanges[50] = CR_Z; + CodeRanges[51] = CR_Zl; + CodeRanges[52] = CR_Zp; + CodeRanges[53] = CR_Zs; + CodeRanges[54] = CR_Arabic; + CodeRanges[55] = CR_Armenian; + CodeRanges[56] = CR_Bengali; + CodeRanges[57] = CR_Bopomofo; + CodeRanges[58] = CR_Braille; + CodeRanges[59] = CR_Buginese; + CodeRanges[60] = CR_Buhid; + CodeRanges[61] = CR_Canadian_Aboriginal; + CodeRanges[62] = CR_Cherokee; + CodeRanges[63] = CR_Common; + CodeRanges[64] = CR_Coptic; + CodeRanges[65] = CR_Cypriot; + CodeRanges[66] = CR_Cyrillic; + CodeRanges[67] = CR_Deseret; + CodeRanges[68] = CR_Devanagari; + CodeRanges[69] = CR_Ethiopic; + CodeRanges[70] = CR_Georgian; + CodeRanges[71] = CR_Glagolitic; + CodeRanges[72] = CR_Gothic; + CodeRanges[73] = CR_Greek; + CodeRanges[74] = CR_Gujarati; + CodeRanges[75] = CR_Gurmukhi; + CodeRanges[76] = CR_Han; + CodeRanges[77] = CR_Hangul; + CodeRanges[78] = CR_Hanunoo; + CodeRanges[79] = CR_Hebrew; + CodeRanges[80] = CR_Hiragana; + CodeRanges[81] = CR_Inherited; + CodeRanges[82] = CR_Kannada; + CodeRanges[83] = CR_Katakana; + CodeRanges[84] = CR_Kharoshthi; + CodeRanges[85] = CR_Khmer; + CodeRanges[86] = CR_Lao; + CodeRanges[87] = CR_Latin; + CodeRanges[88] = CR_Limbu; + CodeRanges[89] = CR_Linear_B; + CodeRanges[90] = CR_Malayalam; + CodeRanges[91] = CR_Mongolian; + CodeRanges[92] = CR_Myanmar; + CodeRanges[93] = CR_New_Tai_Lue; + CodeRanges[94] = CR_Ogham; + CodeRanges[95] = CR_Old_Italic; + CodeRanges[96] = CR_Old_Persian; + CodeRanges[97] = CR_Oriya; + CodeRanges[98] = CR_Osmanya; + CodeRanges[99] = CR_Runic; + CodeRanges[100] = CR_Shavian; + CodeRanges[101] = CR_Sinhala; + CodeRanges[102] = CR_Syloti_Nagri; + CodeRanges[103] = CR_Syriac; + CodeRanges[104] = CR_Tagalog; + CodeRanges[105] = CR_Tagbanwa; + CodeRanges[106] = CR_Tai_Le; + CodeRanges[107] = CR_Tamil; + CodeRanges[108] = CR_Telugu; + CodeRanges[109] = CR_Thaana; + CodeRanges[110] = CR_Thai; + CodeRanges[111] = CR_Tibetan; + CodeRanges[112] = CR_Tifinagh; + CodeRanges[113] = CR_Ugaritic; + CodeRanges[114] = CR_Yi; +#endif /* USE_UNICODE_PROPERTIES */ + + CodeRangeTableInited = 1; + THREAD_ATOMIC_END; +} + +extern int +onigenc_unicode_is_code_ctype(OnigCodePoint code, unsigned int ctype) +{ + if ( +#ifdef USE_UNICODE_PROPERTIES + ctype <= ONIGENC_MAX_STD_CTYPE && +#endif + code < 256) { + return ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(code, ctype); + } + + if (ctype >= CODE_RANGES_NUM) { + return ONIGERR_TYPE_BUG; + } + + if (CodeRangeTableInited == 0) init_code_range_array(); + + return onig_is_in_code_range((UChar* )CodeRanges[ctype], code); +} + + +extern int +onigenc_unicode_ctype_code_range(int ctype, const OnigCodePoint* ranges[]) +{ + if (ctype >= CODE_RANGES_NUM) { + return ONIGERR_TYPE_BUG; + } + + if (CodeRangeTableInited == 0) init_code_range_array(); + + *ranges = CodeRanges[ctype]; + + return 0; +} + +extern int +onigenc_utf16_32_get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out, + const OnigCodePoint* ranges[]) +{ + *sb_out = 0x00; + return onigenc_unicode_ctype_code_range(ctype, ranges); +} + +#include "st.h" + +#define PROPERTY_NAME_MAX_SIZE 20 + +static st_table* NameCtypeTable; +static int NameTableInited = 0; + +static int init_name_ctype_table(void) +{ + PosixBracketEntryType *pb; + + THREAD_ATOMIC_START; + + NameCtypeTable = onig_st_init_strend_table_with_size(100); + if (ONIG_IS_NULL(NameCtypeTable)) return ONIGERR_MEMORY; + + for (pb = HashEntryData; ONIG_IS_NOT_NULL(pb->name); pb++) { + onig_st_insert_strend(NameCtypeTable, pb->name, pb->name + pb->len, + (st_data_t )pb->ctype); + } + + NameTableInited = 1; + THREAD_ATOMIC_END; + return 0; +} + +extern int +onigenc_unicode_property_name_to_ctype(OnigEncoding enc, UChar* name, UChar* end) +{ + int len; + hash_data_type ctype; + UChar buf[PROPERTY_NAME_MAX_SIZE]; + UChar *p; + OnigCodePoint code; + + p = name; + len = 0; + while (p < end) { + code = ONIGENC_MBC_TO_CODE(enc, p, end); + if (code >= 0x80) + return ONIGERR_INVALID_CHAR_PROPERTY_NAME; + + buf[len++] = (UChar )code; + if (len >= PROPERTY_NAME_MAX_SIZE) + return ONIGERR_INVALID_CHAR_PROPERTY_NAME; + + p += enclen(enc, p); + } + + buf[len] = 0; + + if (NameTableInited == 0) init_name_ctype_table(); + + if (onig_st_lookup_strend(NameCtypeTable, buf, buf + len, &ctype) == 0) { + return ONIGERR_INVALID_CHAR_PROPERTY_NAME; + } + + return (int )ctype; +} + + +static int +code2_cmp(OnigCodePoint* x, OnigCodePoint* y) +{ + if (x[0] == y[0] && x[1] == y[1]) return 0; + return 1; +} + +static int +code2_hash(OnigCodePoint* x) +{ + return (int )(x[0] + x[1]); +} + +static struct st_hash_type type_code2_hash = { + code2_cmp, + code2_hash, +}; + +static int +code3_cmp(OnigCodePoint* x, OnigCodePoint* y) +{ + if (x[0] == y[0] && x[1] == y[1] && x[2] == y[2]) return 0; + return 1; +} + +static int +code3_hash(OnigCodePoint* x) +{ + return (int )(x[0] + x[1] + x[2]); +} + +static struct st_hash_type type_code3_hash = { + code3_cmp, + code3_hash, +}; + + +static st_table* FoldTable; /* fold-1, fold-2, fold-3 */ +static st_table* Unfold1Table; +static st_table* Unfold2Table; +static st_table* Unfold3Table; +static int CaseFoldInited = 0; + +static int init_case_fold_table(void) +{ + const CaseFold_11_Type *p; + const CaseUnfold_11_Type *p1; + const CaseUnfold_12_Type *p2; + const CaseUnfold_13_Type *p3; + int i; + + THREAD_ATOMIC_START; + + FoldTable = st_init_numtable_with_size(1200); + if (ONIG_IS_NULL(FoldTable)) return ONIGERR_MEMORY; + for (i = 0; i < (int )(sizeof(CaseFold)/sizeof(CaseFold_11_Type)); i++) { + p = &CaseFold[i]; + st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )&(p->to)); + } + for (i = 0; i < (int )(sizeof(CaseFold_Locale)/sizeof(CaseFold_11_Type)); + i++) { + p = &CaseFold_Locale[i]; + st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )&(p->to)); + } + + Unfold1Table = st_init_numtable_with_size(1000); + if (ONIG_IS_NULL(Unfold1Table)) return ONIGERR_MEMORY; + + for (i = 0; i < (int )(sizeof(CaseUnfold_11)/sizeof(CaseUnfold_11_Type)); + i++) { + p1 = &CaseUnfold_11[i]; + st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )&(p1->to)); + } + for (i = 0; + i < (int )(sizeof(CaseUnfold_11_Locale)/sizeof(CaseUnfold_11_Type)); + i++) { + p1 = &CaseUnfold_11_Locale[i]; + st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )&(p1->to)); + } + + Unfold2Table = st_init_table_with_size(&type_code2_hash, 200); + if (ONIG_IS_NULL(Unfold2Table)) return ONIGERR_MEMORY; + + for (i = 0; i < (int )(sizeof(CaseUnfold_12)/sizeof(CaseUnfold_12_Type)); + i++) { + p2 = &CaseUnfold_12[i]; + st_add_direct(Unfold2Table, (st_data_t )p2->from, (st_data_t )(&p2->to)); + } + for (i = 0; + i < (int )(sizeof(CaseUnfold_12_Locale)/sizeof(CaseUnfold_12_Type)); + i++) { + p2 = &CaseUnfold_12_Locale[i]; + st_add_direct(Unfold2Table, (st_data_t )p2->from, (st_data_t )(&p2->to)); + } + + Unfold3Table = st_init_table_with_size(&type_code3_hash, 30); + if (ONIG_IS_NULL(Unfold3Table)) return ONIGERR_MEMORY; + + for (i = 0; i < (int )(sizeof(CaseUnfold_13)/sizeof(CaseUnfold_13_Type)); + i++) { + p3 = &CaseUnfold_13[i]; + st_add_direct(Unfold3Table, (st_data_t )p3->from, (st_data_t )(&p3->to)); + } + + CaseFoldInited = 1; + THREAD_ATOMIC_END; + return 0; +} + +extern int +onigenc_unicode_mbc_case_fold(OnigEncoding enc, + OnigCaseFoldType flag ARG_UNUSED, const UChar** pp, const UChar* end, + UChar* fold) +{ + CodePointList3 *to; + OnigCodePoint code; + int i, len, rlen; + const UChar *p = *pp; + + if (CaseFoldInited == 0) init_case_fold_table(); + + code = ONIGENC_MBC_TO_CODE(enc, p, end); + len = enclen(enc, p); + *pp += len; + +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI + if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) { + if (code == 0x0049) { + return ONIGENC_CODE_TO_MBC(enc, 0x0131, fold); + } + else if (code == 0x0130) { + return ONIGENC_CODE_TO_MBC(enc, 0x0069, fold); + } + } +#endif + + if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0) { + if (to->n == 1) { + return ONIGENC_CODE_TO_MBC(enc, to->code[0], fold); + } +#if 0 + /* NO NEEDS TO CHECK */ + else if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { +#else + else { +#endif + rlen = 0; + for (i = 0; i < to->n; i++) { + len = ONIGENC_CODE_TO_MBC(enc, to->code[i], fold); + fold += len; + rlen += len; + } + return rlen; + } + } + + for (i = 0; i < len; i++) { + *fold++ = *p++; + } + return len; +} + +extern int +onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) +{ + const CaseUnfold_11_Type* p11; + OnigCodePoint code; + int i, j, k, r; + + /* if (CaseFoldInited == 0) init_case_fold_table(); */ + + for (i = 0; i < (int )(sizeof(CaseUnfold_11)/sizeof(CaseUnfold_11_Type)); + i++) { + p11 = &CaseUnfold_11[i]; + for (j = 0; j < p11->to.n; j++) { + code = p11->from; + r = (*f)(p11->to.code[j], &code, 1, arg); + if (r != 0) return r; + + code = p11->to.code[j]; + r = (*f)(p11->from, &code, 1, arg); + if (r != 0) return r; + + for (k = 0; k < j; k++) { + r = (*f)(p11->to.code[j], (OnigCodePoint* )(&p11->to.code[k]), 1, arg); + if (r != 0) return r; + + r = (*f)(p11->to.code[k], (OnigCodePoint* )(&p11->to.code[j]), 1, arg); + if (r != 0) return r; + } + } + } + +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI + if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) { + code = 0x0131; + r = (*f)(0x0049, &code, 1, arg); + if (r != 0) return r; + code = 0x0049; + r = (*f)(0x0131, &code, 1, arg); + if (r != 0) return r; + + code = 0x0130; + r = (*f)(0x0069, &code, 1, arg); + if (r != 0) return r; + code = 0x0069; + r = (*f)(0x0130, &code, 1, arg); + if (r != 0) return r; + } + else { +#endif + for (i = 0; + i < (int )(sizeof(CaseUnfold_11_Locale)/sizeof(CaseUnfold_11_Type)); + i++) { + p11 = &CaseUnfold_11_Locale[i]; + for (j = 0; j < p11->to.n; j++) { + code = p11->from; + r = (*f)(p11->to.code[j], &code, 1, arg); + if (r != 0) return r; + + code = p11->to.code[j]; + r = (*f)(p11->from, &code, 1, arg); + if (r != 0) return r; + + for (k = 0; k < j; k++) { + r = (*f)(p11->to.code[j], (OnigCodePoint* )(&p11->to.code[k]), + 1, arg); + if (r != 0) return r; + + r = (*f)(p11->to.code[k], (OnigCodePoint* )(&p11->to.code[j]), + 1, arg); + if (r != 0) return r; + } + } + } +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI + } +#endif + + if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + for (i = 0; i < (int )(sizeof(CaseUnfold_12)/sizeof(CaseUnfold_12_Type)); + i++) { + for (j = 0; j < CaseUnfold_12[i].to.n; j++) { + r = (*f)(CaseUnfold_12[i].to.code[j], + (OnigCodePoint* )CaseUnfold_12[i].from, 2, arg); + if (r != 0) return r; + + for (k = 0; k < CaseUnfold_12[i].to.n; k++) { + if (k == j) continue; + + r = (*f)(CaseUnfold_12[i].to.code[j], + (OnigCodePoint* )(&CaseUnfold_12[i].to.code[k]), 1, arg); + if (r != 0) return r; + } + } + } + +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI + if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) == 0) { +#endif + for (i = 0; + i < (int )(sizeof(CaseUnfold_12_Locale)/sizeof(CaseUnfold_12_Type)); + i++) { + for (j = 0; j < CaseUnfold_12_Locale[i].to.n; j++) { + r = (*f)(CaseUnfold_12_Locale[i].to.code[j], + (OnigCodePoint* )CaseUnfold_12_Locale[i].from, 2, arg); + if (r != 0) return r; + + for (k = 0; k < CaseUnfold_12_Locale[i].to.n; k++) { + if (k == j) continue; + + r = (*f)(CaseUnfold_12_Locale[i].to.code[j], + (OnigCodePoint* )(&CaseUnfold_12_Locale[i].to.code[k]), + 1, arg); + if (r != 0) return r; + } + } + } +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI + } +#endif + + for (i = 0; i < (int )(sizeof(CaseUnfold_13)/sizeof(CaseUnfold_13_Type)); + i++) { + for (j = 0; j < CaseUnfold_13[i].to.n; j++) { + r = (*f)(CaseUnfold_13[i].to.code[j], + (OnigCodePoint* )CaseUnfold_13[i].from, 3, arg); + if (r != 0) return r; + + for (k = 0; k < CaseUnfold_13[i].to.n; k++) { + if (k == j) continue; + + r = (*f)(CaseUnfold_13[i].to.code[j], + (OnigCodePoint* )(&CaseUnfold_13[i].to.code[k]), 1, arg); + if (r != 0) return r; + } + } + } + } + + return 0; +} + +extern int +onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc, + OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, + OnigCaseFoldCodeItem items[]) +{ + int n, i, j, k, len; + OnigCodePoint code, codes[3]; + CodePointList3 *to, *z3; + CodePointList2 *z2; + + if (CaseFoldInited == 0) init_case_fold_table(); + + n = 0; + + code = ONIGENC_MBC_TO_CODE(enc, p, end); + len = enclen(enc, p); + +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI + if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) { + if (code == 0x0049) { + items[0].byte_len = len; + items[0].code_len = 1; + items[0].code[0] = 0x0131; + return 1; + } + else if (code == 0x0130) { + items[0].byte_len = len; + items[0].code_len = 1; + items[0].code[0] = 0x0069; + return 1; + } + else if (code == 0x0131) { + items[0].byte_len = len; + items[0].code_len = 1; + items[0].code[0] = 0x0049; + return 1; + } + else if (code == 0x0069) { + items[0].byte_len = len; + items[0].code_len = 1; + items[0].code[0] = 0x0130; + return 1; + } + } +#endif + + if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0) { + if (to->n == 1) { + OnigCodePoint orig_code = code; + + items[0].byte_len = len; + items[0].code_len = 1; + items[0].code[0] = to->code[0]; + n++; + + code = to->code[0]; + if (onig_st_lookup(Unfold1Table, (st_data_t )code, (void* )&to) != 0) { + for (i = 0; i < to->n; i++) { + if (to->code[i] != orig_code) { + items[n].byte_len = len; + items[n].code_len = 1; + items[n].code[0] = to->code[i]; + n++; + } + } + } + } + else if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + OnigCodePoint cs[3][4]; + int fn, ncs[3]; + + for (fn = 0; fn < to->n; fn++) { + cs[fn][0] = to->code[fn]; + if (onig_st_lookup(Unfold1Table, (st_data_t )cs[fn][0], + (void* )&z3) != 0) { + for (i = 0; i < z3->n; i++) { + cs[fn][i+1] = z3->code[i]; + } + ncs[fn] = z3->n + 1; + } + else + ncs[fn] = 1; + } + + if (fn == 2) { + for (i = 0; i < ncs[0]; i++) { + for (j = 0; j < ncs[1]; j++) { + items[n].byte_len = len; + items[n].code_len = 2; + items[n].code[0] = cs[0][i]; + items[n].code[1] = cs[1][j]; + n++; + } + } + + if (onig_st_lookup(Unfold2Table, (st_data_t )to->code, + (void* )&z2) != 0) { + for (i = 0; i < z2->n; i++) { + if (z2->code[i] == code) continue; + + items[n].byte_len = len; + items[n].code_len = 1; + items[n].code[0] = z2->code[i]; + n++; + } + } + } + else { + for (i = 0; i < ncs[0]; i++) { + for (j = 0; j < ncs[1]; j++) { + for (k = 0; k < ncs[2]; k++) { + items[n].byte_len = len; + items[n].code_len = 3; + items[n].code[0] = cs[0][i]; + items[n].code[1] = cs[1][j]; + items[n].code[2] = cs[2][k]; + n++; + } + } + } + + if (onig_st_lookup(Unfold3Table, (st_data_t )to->code, + (void* )&z2) != 0) { + for (i = 0; i < z2->n; i++) { + if (z2->code[i] == code) continue; + + items[n].byte_len = len; + items[n].code_len = 1; + items[n].code[0] = z2->code[i]; + n++; + } + } + } + + /* multi char folded code is not head of another folded multi char */ + flag = 0; /* DISABLE_CASE_FOLD_MULTI_CHAR(flag); */ + } + } + else { + if (onig_st_lookup(Unfold1Table, (st_data_t )code, (void* )&to) != 0) { + for (i = 0; i < to->n; i++) { + items[n].byte_len = len; + items[n].code_len = 1; + items[n].code[0] = to->code[i]; + n++; + } + } + } + + + if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + p += len; + if (p < end) { + int clen; + + codes[0] = code; + code = ONIGENC_MBC_TO_CODE(enc, p, end); + if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0 + && to->n == 1) { + codes[1] = to->code[0]; + } + else + codes[1] = code; + + clen = enclen(enc, p); + len += clen; + if (onig_st_lookup(Unfold2Table, (st_data_t )codes, (void* )&z2) != 0) { + for (i = 0; i < z2->n; i++) { + items[n].byte_len = len; + items[n].code_len = 1; + items[n].code[0] = z2->code[i]; + n++; + } + } + + p += clen; + if (p < end) { + code = ONIGENC_MBC_TO_CODE(enc, p, end); + if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0 + && to->n == 1) { + codes[2] = to->code[0]; + } + else + codes[2] = code; + + clen = enclen(enc, p); + len += clen; + if (onig_st_lookup(Unfold3Table, (st_data_t )codes, + (void* )&z2) != 0) { + for (i = 0; i < z2->n; i++) { + items[n].byte_len = len; + items[n].code_len = 1; + items[n].code[0] = z2->code[i]; + n++; + } + } + } + } + } + + return n; } diff --git a/ext/mbstring/oniguruma/enc/utf16_be.c b/ext/mbstring/oniguruma/enc/utf16_be.c index 6ab80a6c1cea8..1e909ebbf2930 100644 --- a/ext/mbstring/oniguruma/enc/utf16_be.c +++ b/ext/mbstring/oniguruma/enc/utf16_be.c @@ -2,7 +2,7 @@ utf16_be.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,9 +29,6 @@ #include "regenc.h" -#define UTF16_IS_SURROGATE_FIRST(c) (c >= 0xd8 && c <= 0xdb) -#define UTF16_IS_SURROGATE_SECOND(c) (c >= 0xdc && c <= 0xdf) - static const int EncLen_UTF16[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -64,7 +61,11 @@ utf16be_is_mbc_newline(const UChar* p, const UChar* end) if (*(p+1) == 0x0a && *p == 0x00) return 1; #ifdef USE_UNICODE_ALL_LINE_TERMINATORS - if ((*(p+1) == 0x0d || *(p+1) == 0x85) && *p == 0x00) + if (( +#ifndef USE_CRNL_AS_LINE_TERMINATOR + *(p+1) == 0x0d || +#endif + *(p+1) == 0x85) && *p == 0x00) return 1; if (*p == 0x20 && (*(p+1) == 0x29 || *(p+1) == 0x28)) return 1; @@ -74,7 +75,7 @@ utf16be_is_mbc_newline(const UChar* p, const UChar* end) } static OnigCodePoint -utf16be_mbc_to_code(const UChar* p, const UChar* end) +utf16be_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED) { OnigCodePoint code; @@ -103,11 +104,11 @@ utf16be_code_to_mbc(OnigCodePoint code, UChar *buf) if (code > 0xffff) { unsigned int plane, high; - plane = code >> 16; + plane = (code >> 16) - 1; *p++ = (plane >> 2) + 0xd8; high = (code & 0xff00) >> 8; *p++ = ((plane & 0x03) << 6) + (high >> 2); - *p++ = (high & 0x02) + 0xdc; + *p++ = (high & 0x03) + 0xdc; *p = (UChar )(code & 0xff); return 4; } @@ -119,43 +120,37 @@ utf16be_code_to_mbc(OnigCodePoint code, UChar *buf) } static int -utf16be_mbc_to_normalize(OnigAmbigType flag, const UChar** pp, const UChar* end, - UChar* lower) +utf16be_mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end, UChar* fold) { const UChar* p = *pp; - if (*p == 0) { + if (ONIGENC_IS_ASCII_CODE(*(p+1)) && *p == 0) { p++; - *lower++ = '\0'; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ONIGENC_ISO_8859_1_TO_LOWER_CASE(*p); - } - else { - *lower = *p; - } - - (*pp) += 2; - return 2; /* return byte length of converted char to lower */ - } - else { - int len; - len = EncLen_UTF16[*p]; - if (lower != p) { - int i; - for (i = 0; i < len; i++) { - *lower++ = *p++; +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI + if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) { + if (*p == 0x49) { + *fold++ = 0x01; + *fold = 0x31; + (*pp) += 2; + return 2; } } - (*pp) += len; - return len; /* return byte length of converted char to lower */ +#endif + + *fold++ = 0; + *fold = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); + *pp += 2; + return 2; } + else + return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF16_BE, flag, + pp, end, fold); } +#if 0 static int -utf16be_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +utf16be_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { const UChar* p = *pp; @@ -165,27 +160,27 @@ utf16be_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) int c, v; p++; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - c = *p; - v = ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(c, - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ - if (c >= 0xaa && c <= 0xba) - return FALSE; - else - return TRUE; - } - return (v != 0 ? TRUE : FALSE); + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + return TRUE; + } + + c = *p; + v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c, + (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + + if ((v | BIT_CTYPE_LOWER) != 0) { + /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ + if (c >= 0xaa && c <= 0xba) + return FALSE; + else + return TRUE; } + return (v != 0 ? TRUE : FALSE); } return FALSE; } +#endif static UChar* utf16be_left_adjust_char_head(const UChar* start, const UChar* s) @@ -202,31 +197,29 @@ utf16be_left_adjust_char_head(const UChar* start, const UChar* s) return (UChar* )s; } +static int +utf16be_get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF16_BE, + flag, p, end, items); +} + OnigEncodingType OnigEncodingUTF16_BE = { utf16be_mbc_enc_len, "UTF-16BE", /* name */ 4, /* max byte length */ 2, /* min byte length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, utf16be_is_mbc_newline, utf16be_mbc_to_code, utf16be_code_to_mbclen, utf16be_code_to_mbc, - utf16be_mbc_to_normalize, - utf16be_is_mbc_ambiguous, - onigenc_iso_8859_1_get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, + utf16be_mbc_case_fold, + onigenc_unicode_apply_all_case_fold, + utf16be_get_case_fold_codes_by_str, + onigenc_unicode_property_name_to_ctype, onigenc_unicode_is_code_ctype, - onigenc_unicode_get_ctype_code_range, + onigenc_utf16_32_get_ctype_code_range, utf16be_left_adjust_char_head, onigenc_always_false_is_allowed_reverse_match }; diff --git a/ext/mbstring/oniguruma/enc/utf16_le.c b/ext/mbstring/oniguruma/enc/utf16_le.c index 2248e4910fd9e..5cc07591173a0 100644 --- a/ext/mbstring/oniguruma/enc/utf16_le.c +++ b/ext/mbstring/oniguruma/enc/utf16_le.c @@ -2,7 +2,7 @@ utf16_le.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,9 +29,6 @@ #include "regenc.h" -#define UTF16_IS_SURROGATE_FIRST(c) (c >= 0xd8 && c <= 0xdb) -#define UTF16_IS_SURROGATE_SECOND(c) (c >= 0xdc && c <= 0xdf) - static const int EncLen_UTF16[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -70,7 +67,11 @@ utf16le_is_mbc_newline(const UChar* p, const UChar* end) if (*p == 0x0a && *(p+1) == 0x00) return 1; #ifdef USE_UNICODE_ALL_LINE_TERMINATORS - if ((*p == 0x0d || *p == 0x85) && *(p+1) == 0x00) + if (( +#ifndef USE_CRNL_AS_LINE_TERMINATOR + *p == 0x0d || +#endif + *p == 0x85) && *(p+1) == 0x00) return 1; if (*(p+1) == 0x20 && (*p == 0x29 || *p == 0x28)) return 1; @@ -80,7 +81,7 @@ utf16le_is_mbc_newline(const UChar* p, const UChar* end) } static OnigCodePoint -utf16le_mbc_to_code(const UChar* p, const UChar* end) +utf16le_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED) { OnigCodePoint code; UChar c0 = *p; @@ -105,13 +106,13 @@ utf16le_code_to_mbc(OnigCodePoint code, UChar *buf) if (code > 0xffff) { unsigned int plane, high; - plane = code >> 16; + plane = (code >> 16) - 1; high = (code & 0xff00) >> 8; *p++ = ((plane & 0x03) << 6) + (high >> 2); *p++ = (plane >> 2) + 0xd8; *p++ = (UChar )(code & 0xff); - *p = (high & 0x02) + 0xdc; + *p = (high & 0x03) + 0xdc; return 4; } else { @@ -122,40 +123,37 @@ utf16le_code_to_mbc(OnigCodePoint code, UChar *buf) } static int -utf16le_mbc_to_normalize(OnigAmbigType flag, const UChar** pp, const UChar* end, - UChar* lower) +utf16le_mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end, UChar* fold) { const UChar* p = *pp; - if (*(p+1) == 0) { - *(lower+1) = '\0'; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ONIGENC_ISO_8859_1_TO_LOWER_CASE(*p); - } - else { - *lower = *p; - } - (*pp) += 2; - return 2; /* return byte length of converted char to lower */ - } - else { - int len = EncLen_UTF16[*(p+1)]; - if (lower != p) { - int i; - for (i = 0; i < len; i++) { - *lower++ = *p++; + if (ONIGENC_IS_ASCII_CODE(*p) && *(p+1) == 0) { +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI + if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) { + if (*p == 0x49) { + *fold++ = 0x31; + *fold = 0x01; + (*pp) += 2; + return 2; } } - (*pp) += len; - return len; /* return byte length of converted char to lower */ +#endif + + *fold++ = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); + *fold = 0; + *pp += 2; + return 2; } + else + return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF16_LE, flag, pp, end, + fold); } +#if 0 static int -utf16le_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +utf16le_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, + const UChar* end) { const UChar* p = *pp; @@ -164,26 +162,26 @@ utf16le_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) if (*(p+1) == 0) { int c, v; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - c = *p; - v = ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(c, - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ - if (c >= 0xaa && c <= 0xba) - return FALSE; - else - return TRUE; - } - return (v != 0 ? TRUE : FALSE); + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + return TRUE; } + + c = *p; + v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c, + (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ + if (c >= 0xaa && c <= 0xba) + return FALSE; + else + return TRUE; + } + return (v != 0 ? TRUE : FALSE); } return FALSE; } +#endif static UChar* utf16le_left_adjust_char_head(const UChar* start, const UChar* s) @@ -200,31 +198,29 @@ utf16le_left_adjust_char_head(const UChar* start, const UChar* s) return (UChar* )s; } +static int +utf16le_get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF16_LE, + flag, p, end, items); +} + OnigEncodingType OnigEncodingUTF16_LE = { utf16le_mbc_enc_len, "UTF-16LE", /* name */ 4, /* max byte length */ 2, /* min byte length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, utf16le_is_mbc_newline, utf16le_mbc_to_code, utf16le_code_to_mbclen, utf16le_code_to_mbc, - utf16le_mbc_to_normalize, - utf16le_is_mbc_ambiguous, - onigenc_iso_8859_1_get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, + utf16le_mbc_case_fold, + onigenc_unicode_apply_all_case_fold, + utf16le_get_case_fold_codes_by_str, + onigenc_unicode_property_name_to_ctype, onigenc_unicode_is_code_ctype, - onigenc_unicode_get_ctype_code_range, + onigenc_utf16_32_get_ctype_code_range, utf16le_left_adjust_char_head, onigenc_always_false_is_allowed_reverse_match }; diff --git a/ext/mbstring/oniguruma/enc/utf32_be.c b/ext/mbstring/oniguruma/enc/utf32_be.c index 75133ca2626e1..b4f822607c894 100644 --- a/ext/mbstring/oniguruma/enc/utf32_be.c +++ b/ext/mbstring/oniguruma/enc/utf32_be.c @@ -2,7 +2,7 @@ utf32_be.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,7 +30,7 @@ #include "regenc.h" static int -utf32be_mbc_enc_len(const UChar* p) +utf32be_mbc_enc_len(const UChar* p ARG_UNUSED) { return 4; } @@ -42,7 +42,11 @@ utf32be_is_mbc_newline(const UChar* p, const UChar* end) if (*(p+3) == 0x0a && *(p+2) == 0 && *(p+1) == 0 && *p == 0) return 1; #ifdef USE_UNICODE_ALL_LINE_TERMINATORS - if ((*(p+3) == 0x0d || *(p+3) == 0x85) + if (( +#ifndef USE_CRNL_AS_LINE_TERMINATOR + *(p+3) == 0x0d || +#endif + *(p+3) == 0x85) && *(p+2) == 0 && *(p+1) == 0 && *p == 0x00) return 1; if (*(p+2) == 0x20 && (*(p+3) == 0x29 || *(p+3) == 0x28) @@ -54,13 +58,13 @@ utf32be_is_mbc_newline(const UChar* p, const UChar* end) } static OnigCodePoint -utf32be_mbc_to_code(const UChar* p, const UChar* end) +utf32be_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED) { return (OnigCodePoint )(((p[0] * 256 + p[1]) * 256 + p[2]) * 256 + p[3]); } static int -utf32be_code_to_mbclen(OnigCodePoint code) +utf32be_code_to_mbclen(OnigCodePoint code ARG_UNUSED) { return 4; } @@ -78,44 +82,39 @@ utf32be_code_to_mbc(OnigCodePoint code, UChar *buf) } static int -utf32be_mbc_to_normalize(OnigAmbigType flag, const UChar** pp, const UChar* end, - UChar* lower) +utf32be_mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end, UChar* fold) { const UChar* p = *pp; - if (*(p+2) == 0 && *(p+1) == 0 && *p == 0) { - p += 3; - *lower++ = '\0'; - *lower++ = '\0'; - *lower++ = '\0'; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower = ONIGENC_ISO_8859_1_TO_LOWER_CASE(*p); - } - else { - *lower = *p; - } - - (*pp) += 4; - return 4; /* return byte length of converted char to lower */ - } - else { - int len = 4; - if (lower != p) { - int i; - for (i = 0; i < len; i++) { - *lower++ = *p++; + if (ONIGENC_IS_ASCII_CODE(*(p+3)) && *(p+2) == 0 && *(p+1) == 0 && *p == 0) { + *fold++ = 0; + *fold++ = 0; + +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI + if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) { + if (*(p+3) == 0x49) { + *fold++ = 0x01; + *fold = 0x31; + (*pp) += 4; + return 4; } } - (*pp) += len; - return len; /* return byte length of converted char to lower */ +#endif + + *fold++ = 0; + *fold = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*(p+3)); + *pp += 4; + return 4; } + else + return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF32_BE, flag, pp, end, + fold); } +#if 0 static int -utf32be_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +utf32be_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { const UChar* p = *pp; @@ -125,26 +124,26 @@ utf32be_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) int c, v; p += 3; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - c = *p; - v = ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(c, - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ - if (c >= 0xaa && c <= 0xba) - return FALSE; - else - return TRUE; - } - return (v != 0 ? TRUE : FALSE); + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + return TRUE; + } + + c = *p; + v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c, + (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ + if (c >= 0xaa && c <= 0xba) + return FALSE; + else + return TRUE; } + return (v != 0 ? TRUE : FALSE); } return FALSE; } +#endif static UChar* utf32be_left_adjust_char_head(const UChar* start, const UChar* s) @@ -157,31 +156,29 @@ utf32be_left_adjust_char_head(const UChar* start, const UChar* s) return (UChar* )(s - rem); } +static int +utf32be_get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF32_BE, + flag, p, end, items); +} + OnigEncodingType OnigEncodingUTF32_BE = { utf32be_mbc_enc_len, "UTF-32BE", /* name */ 4, /* max byte length */ 4, /* min byte length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, utf32be_is_mbc_newline, utf32be_mbc_to_code, utf32be_code_to_mbclen, utf32be_code_to_mbc, - utf32be_mbc_to_normalize, - utf32be_is_mbc_ambiguous, - onigenc_iso_8859_1_get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, + utf32be_mbc_case_fold, + onigenc_unicode_apply_all_case_fold, + utf32be_get_case_fold_codes_by_str, + onigenc_unicode_property_name_to_ctype, onigenc_unicode_is_code_ctype, - onigenc_unicode_get_ctype_code_range, + onigenc_utf16_32_get_ctype_code_range, utf32be_left_adjust_char_head, onigenc_always_false_is_allowed_reverse_match }; diff --git a/ext/mbstring/oniguruma/enc/utf32_le.c b/ext/mbstring/oniguruma/enc/utf32_le.c index 21dca10c115d2..8f413bfc74e12 100644 --- a/ext/mbstring/oniguruma/enc/utf32_le.c +++ b/ext/mbstring/oniguruma/enc/utf32_le.c @@ -2,7 +2,7 @@ utf32_le.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,7 +30,7 @@ #include "regenc.h" static int -utf32le_mbc_enc_len(const UChar* p) +utf32le_mbc_enc_len(const UChar* p ARG_UNUSED) { return 4; } @@ -42,8 +42,12 @@ utf32le_is_mbc_newline(const UChar* p, const UChar* end) if (*p == 0x0a && *(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0) return 1; #ifdef USE_UNICODE_ALL_LINE_TERMINATORS - if ((*p == 0x0d || *p == 0x85) && *(p+1) == 0x00 - && (p+2) == 0x00 && *(p+3) == 0x00) + if (( +#ifndef USE_CRNL_AS_LINE_TERMINATOR + *p == 0x0d || +#endif + *p == 0x85) + && *(p+1) == 0x00 && (p+2) == 0x00 && *(p+3) == 0x00) return 1; if (*(p+1) == 0x20 && (*p == 0x29 || *p == 0x28) && *(p+2) == 0x00 && *(p+3) == 0x00) @@ -54,13 +58,13 @@ utf32le_is_mbc_newline(const UChar* p, const UChar* end) } static OnigCodePoint -utf32le_mbc_to_code(const UChar* p, const UChar* end) +utf32le_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED) { return (OnigCodePoint )(((p[3] * 256 + p[2]) * 256 + p[1]) * 256 + p[0]); } static int -utf32le_code_to_mbclen(OnigCodePoint code) +utf32le_code_to_mbclen(OnigCodePoint code ARG_UNUSED) { return 4; } @@ -78,43 +82,40 @@ utf32le_code_to_mbc(OnigCodePoint code, UChar *buf) } static int -utf32le_mbc_to_normalize(OnigAmbigType flag, const UChar** pp, const UChar* end, - UChar* lower) +utf32le_mbc_case_fold(OnigCaseFoldType flag, + const UChar** pp, const UChar* end, UChar* fold) { const UChar* p = *pp; - if (*(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0) { - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - *lower++ = ONIGENC_ISO_8859_1_TO_LOWER_CASE(*p); + if (ONIGENC_IS_ASCII_CODE(*p) && *(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0) { +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI + if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) { + if (*p == 0x49) { + *fold++ = 0x31; + *fold++ = 0x01; + } } else { - *lower++ = *p; +#endif + *fold++ = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); + *fold++ = 0; +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI } - *lower++ = '\0'; - *lower++ = '\0'; - *lower = '\0'; +#endif - (*pp) += 4; - return 4; /* return byte length of converted char to lower */ - } - else { - int len = 4; - if (lower != p) { - int i; - for (i = 0; i < len; i++) { - *lower++ = *p++; - } - } - (*pp) += len; - return len; /* return byte length of converted char to lower */ + *fold++ = 0; + *fold = 0; + *pp += 4; + return 4; } + else + return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF32_LE, flag, pp, end, + fold); } +#if 0 static int -utf32le_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +utf32le_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { const UChar* p = *pp; @@ -123,26 +124,26 @@ utf32le_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) if (*(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0) { int c, v; - if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 && - ONIGENC_IS_MBC_ASCII(p)) || - ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 && - !ONIGENC_IS_MBC_ASCII(p))) { - c = *p; - v = ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(c, - (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)); - if ((v | ONIGENC_CTYPE_LOWER) != 0) { - /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ - if (c >= 0xaa && c <= 0xba) - return FALSE; - else - return TRUE; - } - return (v != 0 ? TRUE : FALSE); + if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + return TRUE; + } + + c = *p; + v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c, + (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER)); + if ((v | BIT_CTYPE_LOWER) != 0) { + /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */ + if (c >= 0xaa && c <= 0xba) + return FALSE; + else + return TRUE; } + return (v != 0 ? TRUE : FALSE); } return FALSE; } +#endif static UChar* utf32le_left_adjust_char_head(const UChar* start, const UChar* s) @@ -155,31 +156,29 @@ utf32le_left_adjust_char_head(const UChar* start, const UChar* s) return (UChar* )(s - rem); } +static int +utf32le_get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF32_LE, + flag, p, end, items); +} + OnigEncodingType OnigEncodingUTF32_LE = { utf32le_mbc_enc_len, "UTF-32LE", /* name */ 4, /* max byte length */ 4, /* min byte length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, utf32le_is_mbc_newline, utf32le_mbc_to_code, utf32le_code_to_mbclen, utf32le_code_to_mbc, - utf32le_mbc_to_normalize, - utf32le_is_mbc_ambiguous, - onigenc_iso_8859_1_get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, + utf32le_mbc_case_fold, + onigenc_unicode_apply_all_case_fold, + utf32le_get_case_fold_codes_by_str, + onigenc_unicode_property_name_to_ctype, onigenc_unicode_is_code_ctype, - onigenc_unicode_get_ctype_code_range, + onigenc_utf16_32_get_ctype_code_range, utf32le_left_adjust_char_head, onigenc_always_false_is_allowed_reverse_match }; diff --git a/ext/mbstring/oniguruma/enc/utf8.c b/ext/mbstring/oniguruma/enc/utf8.c index c7481d7050ae9..5e2c1721aa1cc 100644 --- a/ext/mbstring/oniguruma/enc/utf8.c +++ b/ext/mbstring/oniguruma/enc/utf8.c @@ -2,7 +2,7 @@ utf8.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -60,19 +60,21 @@ static const int EncLen_UTF8[] = { }; static int -utf8_mbc_enc_len(const UChar* p) +mbc_enc_len(const UChar* p) { return EncLen_UTF8[*p]; } static int -utf8_is_mbc_newline(const UChar* p, const UChar* end) +is_mbc_newline(const UChar* p, const UChar* end) { if (p < end) { if (*p == 0x0a) return 1; #ifdef USE_UNICODE_ALL_LINE_TERMINATORS +#ifndef USE_CRNL_AS_LINE_TERMINATOR if (*p == 0x0d) return 1; +#endif if (p + 1 < end) { if (*(p+1) == 0x85 && *p == 0xc2) /* U+0085 */ return 1; @@ -89,12 +91,12 @@ utf8_is_mbc_newline(const UChar* p, const UChar* end) } static OnigCodePoint -utf8_mbc_to_code(const UChar* p, const UChar* end) +mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED) { int c, len; OnigCodePoint n; - len = enc_len(ONIG_ENCODING_UTF8, p); + len = enclen(ONIG_ENCODING_UTF8, p); c = *p++; if (len > 1) { len--; @@ -116,14 +118,10 @@ utf8_mbc_to_code(const UChar* p, const UChar* end) } static int -utf8_code_to_mbclen(OnigCodePoint code) +code_to_mbclen(OnigCodePoint code) { if ((code & 0xffffff80) == 0) return 1; - else if ((code & 0xfffff800) == 0) { - if (code <= 0xff && code >= 0xfe) - return 1; - return 2; - } + else if ((code & 0xfffff800) == 0) return 2; else if ((code & 0xffff0000) == 0) return 3; else if ((code & 0xffe00000) == 0) return 4; else if ((code & 0xfc000000) == 0) return 5; @@ -133,35 +131,11 @@ utf8_code_to_mbclen(OnigCodePoint code) else if (code == INVALID_CODE_FF) return 1; #endif else - return ONIGENCERR_TOO_BIG_WIDE_CHAR_VALUE; -} - -#if 0 -static int -utf8_code_to_mbc_first(OnigCodePoint code) -{ - if ((code & 0xffffff80) == 0) - return code; - else { - if ((code & 0xfffff800) == 0) - return ((code>>6)& 0x1f) | 0xc0; - else if ((code & 0xffff0000) == 0) - return ((code>>12) & 0x0f) | 0xe0; - else if ((code & 0xffe00000) == 0) - return ((code>>18) & 0x07) | 0xf0; - else if ((code & 0xfc000000) == 0) - return ((code>>24) & 0x03) | 0xf8; - else if ((code & 0x80000000) == 0) - return ((code>>30) & 0x01) | 0xfc; - else { - return ONIGENCERR_TOO_BIG_WIDE_CHAR_VALUE; - } - } + return ONIGERR_INVALID_CODE_POINT_VALUE; } -#endif static int -utf8_code_to_mbc(OnigCodePoint code, UChar *buf) +code_to_mbc(OnigCodePoint code, UChar *buf) { #define UTF8_TRAILS(code, shift) (UChar )((((code) >> (shift)) & 0x3f) | 0x80) #define UTF8_TRAIL0(code) (UChar )(((code) & 0x3f) | 0x80) @@ -209,7 +183,7 @@ utf8_code_to_mbc(OnigCodePoint code, UChar *buf) } #endif else { - return ONIGENCERR_TOO_BIG_WIDE_CHAR_VALUE; + return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE; } *p++ = UTF8_TRAIL0(code); @@ -218,76 +192,60 @@ utf8_code_to_mbc(OnigCodePoint code, UChar *buf) } static int -utf8_mbc_to_normalize(OnigAmbigType flag, const UChar** pp, const UChar* end, UChar* lower) +mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, + const UChar* end, UChar* fold) { const UChar* p = *pp; if (ONIGENC_IS_MBC_ASCII(p)) { - if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { - *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); - } - else { - *lower = *p; +#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI + if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) { + if (*p == 0x49) { + *fold++ = 0xc4; + *fold = 0xb1; + (*pp)++; + return 2; + } } +#endif + + *fold = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); (*pp)++; return 1; /* return byte length of converted char to lower */ } else { - int len; - - if (*p == 195) { /* 195 == '\303' */ - int c = *(p + 1); - if (c >= 128) { - if (c <= (UChar )'\236' && /* upper */ - (flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0) { - if (c != (UChar )'\227') { - *lower++ = *p; - *lower = (UChar )(c + 32); - (*pp) += 2; - return 2; - } - } - } - } - - len = enc_len(ONIG_ENCODING_UTF8, p); - if (lower != p) { - int i; - for (i = 0; i < len; i++) { - *lower++ = *p++; - } - } - (*pp) += len; - return len; /* return byte length of converted char to lower */ + return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF8, flag, + pp, end, fold); } } +#if 0 static int -utf8_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) +is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { const UChar* p = *pp; if (ONIGENC_IS_MBC_ASCII(p)) { (*pp)++; - if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { - return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p); - } + return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p); } else { - (*pp) += enc_len(ONIG_ENCODING_UTF8, p); + (*pp) += enclen(ONIG_ENCODING_UTF8, p); - if (*p == 195) { /* 195 == '\303' */ + if (*p == 0xc3) { int c = *(p + 1); - if (c >= 128) { - if ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0) { - if (c <= (UChar )'\236') { /* upper */ - if (c == (UChar )'\227') return FALSE; - return TRUE; - } - else if (c >= (UChar )'\240' && c <= (UChar )'\276') { /* lower */ - if (c == (UChar )'\267') return FALSE; - return TRUE; - } + if (c >= 0x80) { + if (c <= (UChar )0x9e) { /* upper */ + if (c == (UChar )0x97) return FALSE; + return TRUE; + } + else if (c >= (UChar )0xa0 && c <= (UChar )0xbe) { /* lower */ + if (c == (UChar )'\267') return FALSE; + return TRUE; + } + else if (c == (UChar )0x9f && + (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) { + return TRUE; } } } @@ -295,3401 +253,20 @@ utf8_is_mbc_ambiguous(OnigAmbigType flag, const UChar** pp, const UChar* end) return FALSE; } - - -static const OnigCodePoint EmptyRange[] = { 0 }; - -static const OnigCodePoint SBAlnum[] = { - 3, - 0x0030, 0x0039, - 0x0041, 0x005a, - 0x0061, 0x007a -}; - -static const OnigCodePoint MBAlnum[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 411, -#else - 6, -#endif - 0x00aa, 0x00aa, - 0x00b5, 0x00b5, - 0x00ba, 0x00ba, - 0x00c0, 0x00d6, - 0x00d8, 0x00f6, - 0x00f8, 0x0236 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0250, 0x02c1, - 0x02c6, 0x02d1, - 0x02e0, 0x02e4, - 0x02ee, 0x02ee, - 0x0300, 0x0357, - 0x035d, 0x036f, - 0x037a, 0x037a, - 0x0386, 0x0386, - 0x0388, 0x038a, - 0x038c, 0x038c, - 0x038e, 0x03a1, - 0x03a3, 0x03ce, - 0x03d0, 0x03f5, - 0x03f7, 0x03fb, - 0x0400, 0x0481, - 0x0483, 0x0486, - 0x0488, 0x04ce, - 0x04d0, 0x04f5, - 0x04f8, 0x04f9, - 0x0500, 0x050f, - 0x0531, 0x0556, - 0x0559, 0x0559, - 0x0561, 0x0587, - 0x0591, 0x05a1, - 0x05a3, 0x05b9, - 0x05bb, 0x05bd, - 0x05bf, 0x05bf, - 0x05c1, 0x05c2, - 0x05c4, 0x05c4, - 0x05d0, 0x05ea, - 0x05f0, 0x05f2, - 0x0610, 0x0615, - 0x0621, 0x063a, - 0x0640, 0x0658, - 0x0660, 0x0669, - 0x066e, 0x06d3, - 0x06d5, 0x06dc, - 0x06de, 0x06e8, - 0x06ea, 0x06fc, - 0x06ff, 0x06ff, - 0x0710, 0x074a, - 0x074d, 0x074f, - 0x0780, 0x07b1, - 0x0901, 0x0939, - 0x093c, 0x094d, - 0x0950, 0x0954, - 0x0958, 0x0963, - 0x0966, 0x096f, - 0x0981, 0x0983, - 0x0985, 0x098c, - 0x098f, 0x0990, - 0x0993, 0x09a8, - 0x09aa, 0x09b0, - 0x09b2, 0x09b2, - 0x09b6, 0x09b9, - 0x09bc, 0x09c4, - 0x09c7, 0x09c8, - 0x09cb, 0x09cd, - 0x09d7, 0x09d7, - 0x09dc, 0x09dd, - 0x09df, 0x09e3, - 0x09e6, 0x09f1, - 0x0a01, 0x0a03, - 0x0a05, 0x0a0a, - 0x0a0f, 0x0a10, - 0x0a13, 0x0a28, - 0x0a2a, 0x0a30, - 0x0a32, 0x0a33, - 0x0a35, 0x0a36, - 0x0a38, 0x0a39, - 0x0a3c, 0x0a3c, - 0x0a3e, 0x0a42, - 0x0a47, 0x0a48, - 0x0a4b, 0x0a4d, - 0x0a59, 0x0a5c, - 0x0a5e, 0x0a5e, - 0x0a66, 0x0a74, - 0x0a81, 0x0a83, - 0x0a85, 0x0a8d, - 0x0a8f, 0x0a91, - 0x0a93, 0x0aa8, - 0x0aaa, 0x0ab0, - 0x0ab2, 0x0ab3, - 0x0ab5, 0x0ab9, - 0x0abc, 0x0ac5, - 0x0ac7, 0x0ac9, - 0x0acb, 0x0acd, - 0x0ad0, 0x0ad0, - 0x0ae0, 0x0ae3, - 0x0ae6, 0x0aef, - 0x0b01, 0x0b03, - 0x0b05, 0x0b0c, - 0x0b0f, 0x0b10, - 0x0b13, 0x0b28, - 0x0b2a, 0x0b30, - 0x0b32, 0x0b33, - 0x0b35, 0x0b39, - 0x0b3c, 0x0b43, - 0x0b47, 0x0b48, - 0x0b4b, 0x0b4d, - 0x0b56, 0x0b57, - 0x0b5c, 0x0b5d, - 0x0b5f, 0x0b61, - 0x0b66, 0x0b6f, - 0x0b71, 0x0b71, - 0x0b82, 0x0b83, - 0x0b85, 0x0b8a, - 0x0b8e, 0x0b90, - 0x0b92, 0x0b95, - 0x0b99, 0x0b9a, - 0x0b9c, 0x0b9c, - 0x0b9e, 0x0b9f, - 0x0ba3, 0x0ba4, - 0x0ba8, 0x0baa, - 0x0bae, 0x0bb5, - 0x0bb7, 0x0bb9, - 0x0bbe, 0x0bc2, - 0x0bc6, 0x0bc8, - 0x0bca, 0x0bcd, - 0x0bd7, 0x0bd7, - 0x0be7, 0x0bef, - 0x0c01, 0x0c03, - 0x0c05, 0x0c0c, - 0x0c0e, 0x0c10, - 0x0c12, 0x0c28, - 0x0c2a, 0x0c33, - 0x0c35, 0x0c39, - 0x0c3e, 0x0c44, - 0x0c46, 0x0c48, - 0x0c4a, 0x0c4d, - 0x0c55, 0x0c56, - 0x0c60, 0x0c61, - 0x0c66, 0x0c6f, - 0x0c82, 0x0c83, - 0x0c85, 0x0c8c, - 0x0c8e, 0x0c90, - 0x0c92, 0x0ca8, - 0x0caa, 0x0cb3, - 0x0cb5, 0x0cb9, - 0x0cbc, 0x0cc4, - 0x0cc6, 0x0cc8, - 0x0cca, 0x0ccd, - 0x0cd5, 0x0cd6, - 0x0cde, 0x0cde, - 0x0ce0, 0x0ce1, - 0x0ce6, 0x0cef, - 0x0d02, 0x0d03, - 0x0d05, 0x0d0c, - 0x0d0e, 0x0d10, - 0x0d12, 0x0d28, - 0x0d2a, 0x0d39, - 0x0d3e, 0x0d43, - 0x0d46, 0x0d48, - 0x0d4a, 0x0d4d, - 0x0d57, 0x0d57, - 0x0d60, 0x0d61, - 0x0d66, 0x0d6f, - 0x0d82, 0x0d83, - 0x0d85, 0x0d96, - 0x0d9a, 0x0db1, - 0x0db3, 0x0dbb, - 0x0dbd, 0x0dbd, - 0x0dc0, 0x0dc6, - 0x0dca, 0x0dca, - 0x0dcf, 0x0dd4, - 0x0dd6, 0x0dd6, - 0x0dd8, 0x0ddf, - 0x0df2, 0x0df3, - 0x0e01, 0x0e3a, - 0x0e40, 0x0e4e, - 0x0e50, 0x0e59, - 0x0e81, 0x0e82, - 0x0e84, 0x0e84, - 0x0e87, 0x0e88, - 0x0e8a, 0x0e8a, - 0x0e8d, 0x0e8d, - 0x0e94, 0x0e97, - 0x0e99, 0x0e9f, - 0x0ea1, 0x0ea3, - 0x0ea5, 0x0ea5, - 0x0ea7, 0x0ea7, - 0x0eaa, 0x0eab, - 0x0ead, 0x0eb9, - 0x0ebb, 0x0ebd, - 0x0ec0, 0x0ec4, - 0x0ec6, 0x0ec6, - 0x0ec8, 0x0ecd, - 0x0ed0, 0x0ed9, - 0x0edc, 0x0edd, - 0x0f00, 0x0f00, - 0x0f18, 0x0f19, - 0x0f20, 0x0f29, - 0x0f35, 0x0f35, - 0x0f37, 0x0f37, - 0x0f39, 0x0f39, - 0x0f3e, 0x0f47, - 0x0f49, 0x0f6a, - 0x0f71, 0x0f84, - 0x0f86, 0x0f8b, - 0x0f90, 0x0f97, - 0x0f99, 0x0fbc, - 0x0fc6, 0x0fc6, - 0x1000, 0x1021, - 0x1023, 0x1027, - 0x1029, 0x102a, - 0x102c, 0x1032, - 0x1036, 0x1039, - 0x1040, 0x1049, - 0x1050, 0x1059, - 0x10a0, 0x10c5, - 0x10d0, 0x10f8, - 0x1100, 0x1159, - 0x115f, 0x11a2, - 0x11a8, 0x11f9, - 0x1200, 0x1206, - 0x1208, 0x1246, - 0x1248, 0x1248, - 0x124a, 0x124d, - 0x1250, 0x1256, - 0x1258, 0x1258, - 0x125a, 0x125d, - 0x1260, 0x1286, - 0x1288, 0x1288, - 0x128a, 0x128d, - 0x1290, 0x12ae, - 0x12b0, 0x12b0, - 0x12b2, 0x12b5, - 0x12b8, 0x12be, - 0x12c0, 0x12c0, - 0x12c2, 0x12c5, - 0x12c8, 0x12ce, - 0x12d0, 0x12d6, - 0x12d8, 0x12ee, - 0x12f0, 0x130e, - 0x1310, 0x1310, - 0x1312, 0x1315, - 0x1318, 0x131e, - 0x1320, 0x1346, - 0x1348, 0x135a, - 0x1369, 0x1371, - 0x13a0, 0x13f4, - 0x1401, 0x166c, - 0x166f, 0x1676, - 0x1681, 0x169a, - 0x16a0, 0x16ea, - 0x1700, 0x170c, - 0x170e, 0x1714, - 0x1720, 0x1734, - 0x1740, 0x1753, - 0x1760, 0x176c, - 0x176e, 0x1770, - 0x1772, 0x1773, - 0x1780, 0x17b3, - 0x17b6, 0x17d3, - 0x17d7, 0x17d7, - 0x17dc, 0x17dd, - 0x17e0, 0x17e9, - 0x180b, 0x180d, - 0x1810, 0x1819, - 0x1820, 0x1877, - 0x1880, 0x18a9, - 0x1900, 0x191c, - 0x1920, 0x192b, - 0x1930, 0x193b, - 0x1946, 0x196d, - 0x1970, 0x1974, - 0x1d00, 0x1d6b, - 0x1e00, 0x1e9b, - 0x1ea0, 0x1ef9, - 0x1f00, 0x1f15, - 0x1f18, 0x1f1d, - 0x1f20, 0x1f45, - 0x1f48, 0x1f4d, - 0x1f50, 0x1f57, - 0x1f59, 0x1f59, - 0x1f5b, 0x1f5b, - 0x1f5d, 0x1f5d, - 0x1f5f, 0x1f7d, - 0x1f80, 0x1fb4, - 0x1fb6, 0x1fbc, - 0x1fbe, 0x1fbe, - 0x1fc2, 0x1fc4, - 0x1fc6, 0x1fcc, - 0x1fd0, 0x1fd3, - 0x1fd6, 0x1fdb, - 0x1fe0, 0x1fec, - 0x1ff2, 0x1ff4, - 0x1ff6, 0x1ffc, - 0x2071, 0x2071, - 0x207f, 0x207f, - 0x20d0, 0x20ea, - 0x2102, 0x2102, - 0x2107, 0x2107, - 0x210a, 0x2113, - 0x2115, 0x2115, - 0x2119, 0x211d, - 0x2124, 0x2124, - 0x2126, 0x2126, - 0x2128, 0x2128, - 0x212a, 0x212d, - 0x212f, 0x2131, - 0x2133, 0x2139, - 0x213d, 0x213f, - 0x2145, 0x2149, - 0x3005, 0x3006, - 0x302a, 0x302f, - 0x3031, 0x3035, - 0x303b, 0x303c, - 0x3041, 0x3096, - 0x3099, 0x309a, - 0x309d, 0x309f, - 0x30a1, 0x30fa, - 0x30fc, 0x30ff, - 0x3105, 0x312c, - 0x3131, 0x318e, - 0x31a0, 0x31b7, - 0x31f0, 0x31ff, - 0x3400, 0x4db5, - 0x4e00, 0x9fa5, - 0xa000, 0xa48c, - 0xac00, 0xd7a3, - 0xf900, 0xfa2d, - 0xfa30, 0xfa6a, - 0xfb00, 0xfb06, - 0xfb13, 0xfb17, - 0xfb1d, 0xfb28, - 0xfb2a, 0xfb36, - 0xfb38, 0xfb3c, - 0xfb3e, 0xfb3e, - 0xfb40, 0xfb41, - 0xfb43, 0xfb44, - 0xfb46, 0xfbb1, - 0xfbd3, 0xfd3d, - 0xfd50, 0xfd8f, - 0xfd92, 0xfdc7, - 0xfdf0, 0xfdfb, - 0xfe00, 0xfe0f, - 0xfe20, 0xfe23, - 0xfe70, 0xfe74, - 0xfe76, 0xfefc, - 0xff10, 0xff19, - 0xff21, 0xff3a, - 0xff41, 0xff5a, - 0xff66, 0xffbe, - 0xffc2, 0xffc7, - 0xffca, 0xffcf, - 0xffd2, 0xffd7, - 0xffda, 0xffdc, - 0x10000, 0x1000b, - 0x1000d, 0x10026, - 0x10028, 0x1003a, - 0x1003c, 0x1003d, - 0x1003f, 0x1004d, - 0x10050, 0x1005d, - 0x10080, 0x100fa, - 0x10300, 0x1031e, - 0x10330, 0x10349, - 0x10380, 0x1039d, - 0x10400, 0x1049d, - 0x104a0, 0x104a9, - 0x10800, 0x10805, - 0x10808, 0x10808, - 0x1080a, 0x10835, - 0x10837, 0x10838, - 0x1083c, 0x1083c, - 0x1083f, 0x1083f, - 0x1d165, 0x1d169, - 0x1d16d, 0x1d172, - 0x1d17b, 0x1d182, - 0x1d185, 0x1d18b, - 0x1d1aa, 0x1d1ad, - 0x1d400, 0x1d454, - 0x1d456, 0x1d49c, - 0x1d49e, 0x1d49f, - 0x1d4a2, 0x1d4a2, - 0x1d4a5, 0x1d4a6, - 0x1d4a9, 0x1d4ac, - 0x1d4ae, 0x1d4b9, - 0x1d4bb, 0x1d4bb, - 0x1d4bd, 0x1d4c3, - 0x1d4c5, 0x1d505, - 0x1d507, 0x1d50a, - 0x1d50d, 0x1d514, - 0x1d516, 0x1d51c, - 0x1d51e, 0x1d539, - 0x1d53b, 0x1d53e, - 0x1d540, 0x1d544, - 0x1d546, 0x1d546, - 0x1d54a, 0x1d550, - 0x1d552, 0x1d6a3, - 0x1d6a8, 0x1d6c0, - 0x1d6c2, 0x1d6da, - 0x1d6dc, 0x1d6fa, - 0x1d6fc, 0x1d714, - 0x1d716, 0x1d734, - 0x1d736, 0x1d74e, - 0x1d750, 0x1d76e, - 0x1d770, 0x1d788, - 0x1d78a, 0x1d7a8, - 0x1d7aa, 0x1d7c2, - 0x1d7c4, 0x1d7c9, - 0x1d7ce, 0x1d7ff, - 0x20000, 0x2a6d6, - 0x2f800, 0x2fa1d, - 0xe0100, 0xe01ef -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBAlnum */ - -static const OnigCodePoint SBAlpha[] = { - 2, - 0x0041, 0x005a, - 0x0061, 0x007a -}; - -static const OnigCodePoint MBAlpha[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 394, -#else - 6, -#endif - 0x00aa, 0x00aa, - 0x00b5, 0x00b5, - 0x00ba, 0x00ba, - 0x00c0, 0x00d6, - 0x00d8, 0x00f6, - 0x00f8, 0x0236 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0250, 0x02c1, - 0x02c6, 0x02d1, - 0x02e0, 0x02e4, - 0x02ee, 0x02ee, - 0x0300, 0x0357, - 0x035d, 0x036f, - 0x037a, 0x037a, - 0x0386, 0x0386, - 0x0388, 0x038a, - 0x038c, 0x038c, - 0x038e, 0x03a1, - 0x03a3, 0x03ce, - 0x03d0, 0x03f5, - 0x03f7, 0x03fb, - 0x0400, 0x0481, - 0x0483, 0x0486, - 0x0488, 0x04ce, - 0x04d0, 0x04f5, - 0x04f8, 0x04f9, - 0x0500, 0x050f, - 0x0531, 0x0556, - 0x0559, 0x0559, - 0x0561, 0x0587, - 0x0591, 0x05a1, - 0x05a3, 0x05b9, - 0x05bb, 0x05bd, - 0x05bf, 0x05bf, - 0x05c1, 0x05c2, - 0x05c4, 0x05c4, - 0x05d0, 0x05ea, - 0x05f0, 0x05f2, - 0x0610, 0x0615, - 0x0621, 0x063a, - 0x0640, 0x0658, - 0x066e, 0x06d3, - 0x06d5, 0x06dc, - 0x06de, 0x06e8, - 0x06ea, 0x06ef, - 0x06fa, 0x06fc, - 0x06ff, 0x06ff, - 0x0710, 0x074a, - 0x074d, 0x074f, - 0x0780, 0x07b1, - 0x0901, 0x0939, - 0x093c, 0x094d, - 0x0950, 0x0954, - 0x0958, 0x0963, - 0x0981, 0x0983, - 0x0985, 0x098c, - 0x098f, 0x0990, - 0x0993, 0x09a8, - 0x09aa, 0x09b0, - 0x09b2, 0x09b2, - 0x09b6, 0x09b9, - 0x09bc, 0x09c4, - 0x09c7, 0x09c8, - 0x09cb, 0x09cd, - 0x09d7, 0x09d7, - 0x09dc, 0x09dd, - 0x09df, 0x09e3, - 0x09f0, 0x09f1, - 0x0a01, 0x0a03, - 0x0a05, 0x0a0a, - 0x0a0f, 0x0a10, - 0x0a13, 0x0a28, - 0x0a2a, 0x0a30, - 0x0a32, 0x0a33, - 0x0a35, 0x0a36, - 0x0a38, 0x0a39, - 0x0a3c, 0x0a3c, - 0x0a3e, 0x0a42, - 0x0a47, 0x0a48, - 0x0a4b, 0x0a4d, - 0x0a59, 0x0a5c, - 0x0a5e, 0x0a5e, - 0x0a70, 0x0a74, - 0x0a81, 0x0a83, - 0x0a85, 0x0a8d, - 0x0a8f, 0x0a91, - 0x0a93, 0x0aa8, - 0x0aaa, 0x0ab0, - 0x0ab2, 0x0ab3, - 0x0ab5, 0x0ab9, - 0x0abc, 0x0ac5, - 0x0ac7, 0x0ac9, - 0x0acb, 0x0acd, - 0x0ad0, 0x0ad0, - 0x0ae0, 0x0ae3, - 0x0b01, 0x0b03, - 0x0b05, 0x0b0c, - 0x0b0f, 0x0b10, - 0x0b13, 0x0b28, - 0x0b2a, 0x0b30, - 0x0b32, 0x0b33, - 0x0b35, 0x0b39, - 0x0b3c, 0x0b43, - 0x0b47, 0x0b48, - 0x0b4b, 0x0b4d, - 0x0b56, 0x0b57, - 0x0b5c, 0x0b5d, - 0x0b5f, 0x0b61, - 0x0b71, 0x0b71, - 0x0b82, 0x0b83, - 0x0b85, 0x0b8a, - 0x0b8e, 0x0b90, - 0x0b92, 0x0b95, - 0x0b99, 0x0b9a, - 0x0b9c, 0x0b9c, - 0x0b9e, 0x0b9f, - 0x0ba3, 0x0ba4, - 0x0ba8, 0x0baa, - 0x0bae, 0x0bb5, - 0x0bb7, 0x0bb9, - 0x0bbe, 0x0bc2, - 0x0bc6, 0x0bc8, - 0x0bca, 0x0bcd, - 0x0bd7, 0x0bd7, - 0x0c01, 0x0c03, - 0x0c05, 0x0c0c, - 0x0c0e, 0x0c10, - 0x0c12, 0x0c28, - 0x0c2a, 0x0c33, - 0x0c35, 0x0c39, - 0x0c3e, 0x0c44, - 0x0c46, 0x0c48, - 0x0c4a, 0x0c4d, - 0x0c55, 0x0c56, - 0x0c60, 0x0c61, - 0x0c82, 0x0c83, - 0x0c85, 0x0c8c, - 0x0c8e, 0x0c90, - 0x0c92, 0x0ca8, - 0x0caa, 0x0cb3, - 0x0cb5, 0x0cb9, - 0x0cbc, 0x0cc4, - 0x0cc6, 0x0cc8, - 0x0cca, 0x0ccd, - 0x0cd5, 0x0cd6, - 0x0cde, 0x0cde, - 0x0ce0, 0x0ce1, - 0x0d02, 0x0d03, - 0x0d05, 0x0d0c, - 0x0d0e, 0x0d10, - 0x0d12, 0x0d28, - 0x0d2a, 0x0d39, - 0x0d3e, 0x0d43, - 0x0d46, 0x0d48, - 0x0d4a, 0x0d4d, - 0x0d57, 0x0d57, - 0x0d60, 0x0d61, - 0x0d82, 0x0d83, - 0x0d85, 0x0d96, - 0x0d9a, 0x0db1, - 0x0db3, 0x0dbb, - 0x0dbd, 0x0dbd, - 0x0dc0, 0x0dc6, - 0x0dca, 0x0dca, - 0x0dcf, 0x0dd4, - 0x0dd6, 0x0dd6, - 0x0dd8, 0x0ddf, - 0x0df2, 0x0df3, - 0x0e01, 0x0e3a, - 0x0e40, 0x0e4e, - 0x0e81, 0x0e82, - 0x0e84, 0x0e84, - 0x0e87, 0x0e88, - 0x0e8a, 0x0e8a, - 0x0e8d, 0x0e8d, - 0x0e94, 0x0e97, - 0x0e99, 0x0e9f, - 0x0ea1, 0x0ea3, - 0x0ea5, 0x0ea5, - 0x0ea7, 0x0ea7, - 0x0eaa, 0x0eab, - 0x0ead, 0x0eb9, - 0x0ebb, 0x0ebd, - 0x0ec0, 0x0ec4, - 0x0ec6, 0x0ec6, - 0x0ec8, 0x0ecd, - 0x0edc, 0x0edd, - 0x0f00, 0x0f00, - 0x0f18, 0x0f19, - 0x0f35, 0x0f35, - 0x0f37, 0x0f37, - 0x0f39, 0x0f39, - 0x0f3e, 0x0f47, - 0x0f49, 0x0f6a, - 0x0f71, 0x0f84, - 0x0f86, 0x0f8b, - 0x0f90, 0x0f97, - 0x0f99, 0x0fbc, - 0x0fc6, 0x0fc6, - 0x1000, 0x1021, - 0x1023, 0x1027, - 0x1029, 0x102a, - 0x102c, 0x1032, - 0x1036, 0x1039, - 0x1050, 0x1059, - 0x10a0, 0x10c5, - 0x10d0, 0x10f8, - 0x1100, 0x1159, - 0x115f, 0x11a2, - 0x11a8, 0x11f9, - 0x1200, 0x1206, - 0x1208, 0x1246, - 0x1248, 0x1248, - 0x124a, 0x124d, - 0x1250, 0x1256, - 0x1258, 0x1258, - 0x125a, 0x125d, - 0x1260, 0x1286, - 0x1288, 0x1288, - 0x128a, 0x128d, - 0x1290, 0x12ae, - 0x12b0, 0x12b0, - 0x12b2, 0x12b5, - 0x12b8, 0x12be, - 0x12c0, 0x12c0, - 0x12c2, 0x12c5, - 0x12c8, 0x12ce, - 0x12d0, 0x12d6, - 0x12d8, 0x12ee, - 0x12f0, 0x130e, - 0x1310, 0x1310, - 0x1312, 0x1315, - 0x1318, 0x131e, - 0x1320, 0x1346, - 0x1348, 0x135a, - 0x13a0, 0x13f4, - 0x1401, 0x166c, - 0x166f, 0x1676, - 0x1681, 0x169a, - 0x16a0, 0x16ea, - 0x1700, 0x170c, - 0x170e, 0x1714, - 0x1720, 0x1734, - 0x1740, 0x1753, - 0x1760, 0x176c, - 0x176e, 0x1770, - 0x1772, 0x1773, - 0x1780, 0x17b3, - 0x17b6, 0x17d3, - 0x17d7, 0x17d7, - 0x17dc, 0x17dd, - 0x180b, 0x180d, - 0x1820, 0x1877, - 0x1880, 0x18a9, - 0x1900, 0x191c, - 0x1920, 0x192b, - 0x1930, 0x193b, - 0x1950, 0x196d, - 0x1970, 0x1974, - 0x1d00, 0x1d6b, - 0x1e00, 0x1e9b, - 0x1ea0, 0x1ef9, - 0x1f00, 0x1f15, - 0x1f18, 0x1f1d, - 0x1f20, 0x1f45, - 0x1f48, 0x1f4d, - 0x1f50, 0x1f57, - 0x1f59, 0x1f59, - 0x1f5b, 0x1f5b, - 0x1f5d, 0x1f5d, - 0x1f5f, 0x1f7d, - 0x1f80, 0x1fb4, - 0x1fb6, 0x1fbc, - 0x1fbe, 0x1fbe, - 0x1fc2, 0x1fc4, - 0x1fc6, 0x1fcc, - 0x1fd0, 0x1fd3, - 0x1fd6, 0x1fdb, - 0x1fe0, 0x1fec, - 0x1ff2, 0x1ff4, - 0x1ff6, 0x1ffc, - 0x2071, 0x2071, - 0x207f, 0x207f, - 0x20d0, 0x20ea, - 0x2102, 0x2102, - 0x2107, 0x2107, - 0x210a, 0x2113, - 0x2115, 0x2115, - 0x2119, 0x211d, - 0x2124, 0x2124, - 0x2126, 0x2126, - 0x2128, 0x2128, - 0x212a, 0x212d, - 0x212f, 0x2131, - 0x2133, 0x2139, - 0x213d, 0x213f, - 0x2145, 0x2149, - 0x3005, 0x3006, - 0x302a, 0x302f, - 0x3031, 0x3035, - 0x303b, 0x303c, - 0x3041, 0x3096, - 0x3099, 0x309a, - 0x309d, 0x309f, - 0x30a1, 0x30fa, - 0x30fc, 0x30ff, - 0x3105, 0x312c, - 0x3131, 0x318e, - 0x31a0, 0x31b7, - 0x31f0, 0x31ff, - 0x3400, 0x4db5, - 0x4e00, 0x9fa5, - 0xa000, 0xa48c, - 0xac00, 0xd7a3, - 0xf900, 0xfa2d, - 0xfa30, 0xfa6a, - 0xfb00, 0xfb06, - 0xfb13, 0xfb17, - 0xfb1d, 0xfb28, - 0xfb2a, 0xfb36, - 0xfb38, 0xfb3c, - 0xfb3e, 0xfb3e, - 0xfb40, 0xfb41, - 0xfb43, 0xfb44, - 0xfb46, 0xfbb1, - 0xfbd3, 0xfd3d, - 0xfd50, 0xfd8f, - 0xfd92, 0xfdc7, - 0xfdf0, 0xfdfb, - 0xfe00, 0xfe0f, - 0xfe20, 0xfe23, - 0xfe70, 0xfe74, - 0xfe76, 0xfefc, - 0xff21, 0xff3a, - 0xff41, 0xff5a, - 0xff66, 0xffbe, - 0xffc2, 0xffc7, - 0xffca, 0xffcf, - 0xffd2, 0xffd7, - 0xffda, 0xffdc, - 0x10000, 0x1000b, - 0x1000d, 0x10026, - 0x10028, 0x1003a, - 0x1003c, 0x1003d, - 0x1003f, 0x1004d, - 0x10050, 0x1005d, - 0x10080, 0x100fa, - 0x10300, 0x1031e, - 0x10330, 0x10349, - 0x10380, 0x1039d, - 0x10400, 0x1049d, - 0x10800, 0x10805, - 0x10808, 0x10808, - 0x1080a, 0x10835, - 0x10837, 0x10838, - 0x1083c, 0x1083c, - 0x1083f, 0x1083f, - 0x1d165, 0x1d169, - 0x1d16d, 0x1d172, - 0x1d17b, 0x1d182, - 0x1d185, 0x1d18b, - 0x1d1aa, 0x1d1ad, - 0x1d400, 0x1d454, - 0x1d456, 0x1d49c, - 0x1d49e, 0x1d49f, - 0x1d4a2, 0x1d4a2, - 0x1d4a5, 0x1d4a6, - 0x1d4a9, 0x1d4ac, - 0x1d4ae, 0x1d4b9, - 0x1d4bb, 0x1d4bb, - 0x1d4bd, 0x1d4c3, - 0x1d4c5, 0x1d505, - 0x1d507, 0x1d50a, - 0x1d50d, 0x1d514, - 0x1d516, 0x1d51c, - 0x1d51e, 0x1d539, - 0x1d53b, 0x1d53e, - 0x1d540, 0x1d544, - 0x1d546, 0x1d546, - 0x1d54a, 0x1d550, - 0x1d552, 0x1d6a3, - 0x1d6a8, 0x1d6c0, - 0x1d6c2, 0x1d6da, - 0x1d6dc, 0x1d6fa, - 0x1d6fc, 0x1d714, - 0x1d716, 0x1d734, - 0x1d736, 0x1d74e, - 0x1d750, 0x1d76e, - 0x1d770, 0x1d788, - 0x1d78a, 0x1d7a8, - 0x1d7aa, 0x1d7c2, - 0x1d7c4, 0x1d7c9, - 0x20000, 0x2a6d6, - 0x2f800, 0x2fa1d, - 0xe0100, 0xe01ef -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBAlpha */ - -static const OnigCodePoint SBBlank[] = { - 2, - 0x0009, 0x0009, - 0x0020, 0x0020 -}; - -static const OnigCodePoint MBBlank[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 7, -#else - 1, -#endif - 0x00a0, 0x00a0 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x1680, 0x1680, - 0x180e, 0x180e, - 0x2000, 0x200a, - 0x202f, 0x202f, - 0x205f, 0x205f, - 0x3000, 0x3000 -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBBlank */ - -static const OnigCodePoint SBCntrl[] = { - 2, - 0x0000, 0x001f, - 0x007f, 0x007f -}; - -static const OnigCodePoint MBCntrl[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 18, -#else - 2, -#endif - 0x0080, 0x009f, - 0x00ad, 0x00ad -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0600, 0x0603, - 0x06dd, 0x06dd, - 0x070f, 0x070f, - 0x17b4, 0x17b5, - 0x200b, 0x200f, - 0x202a, 0x202e, - 0x2060, 0x2063, - 0x206a, 0x206f, - 0xd800, 0xf8ff, - 0xfeff, 0xfeff, - 0xfff9, 0xfffb, - 0x1d173, 0x1d17a, - 0xe0001, 0xe0001, - 0xe0020, 0xe007f, - 0xf0000, 0xffffd, - 0x100000, 0x10fffd -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBCntrl */ - -static const OnigCodePoint SBDigit[] = { - 1, - 0x0030, 0x0039 -}; - -static const OnigCodePoint MBDigit[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 22, -#else - 0 -#endif -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 0x0660, 0x0669, - 0x06f0, 0x06f9, - 0x0966, 0x096f, - 0x09e6, 0x09ef, - 0x0a66, 0x0a6f, - 0x0ae6, 0x0aef, - 0x0b66, 0x0b6f, - 0x0be7, 0x0bef, - 0x0c66, 0x0c6f, - 0x0ce6, 0x0cef, - 0x0d66, 0x0d6f, - 0x0e50, 0x0e59, - 0x0ed0, 0x0ed9, - 0x0f20, 0x0f29, - 0x1040, 0x1049, - 0x1369, 0x1371, - 0x17e0, 0x17e9, - 0x1810, 0x1819, - 0x1946, 0x194f, - 0xff10, 0xff19, - 0x104a0, 0x104a9, - 0x1d7ce, 0x1d7ff -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBDigit */ - -static const OnigCodePoint SBGraph[] = { - 1, - 0x0021, 0x007e -}; - -static const OnigCodePoint MBGraph[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 404, -#else - 1, -#endif - 0x00a1, 0x0236 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0250, 0x0357, - 0x035d, 0x036f, - 0x0374, 0x0375, - 0x037a, 0x037a, - 0x037e, 0x037e, - 0x0384, 0x038a, - 0x038c, 0x038c, - 0x038e, 0x03a1, - 0x03a3, 0x03ce, - 0x03d0, 0x03fb, - 0x0400, 0x0486, - 0x0488, 0x04ce, - 0x04d0, 0x04f5, - 0x04f8, 0x04f9, - 0x0500, 0x050f, - 0x0531, 0x0556, - 0x0559, 0x055f, - 0x0561, 0x0587, - 0x0589, 0x058a, - 0x0591, 0x05a1, - 0x05a3, 0x05b9, - 0x05bb, 0x05c4, - 0x05d0, 0x05ea, - 0x05f0, 0x05f4, - 0x0600, 0x0603, - 0x060c, 0x0615, - 0x061b, 0x061b, - 0x061f, 0x061f, - 0x0621, 0x063a, - 0x0640, 0x0658, - 0x0660, 0x070d, - 0x070f, 0x074a, - 0x074d, 0x074f, - 0x0780, 0x07b1, - 0x0901, 0x0939, - 0x093c, 0x094d, - 0x0950, 0x0954, - 0x0958, 0x0970, - 0x0981, 0x0983, - 0x0985, 0x098c, - 0x098f, 0x0990, - 0x0993, 0x09a8, - 0x09aa, 0x09b0, - 0x09b2, 0x09b2, - 0x09b6, 0x09b9, - 0x09bc, 0x09c4, - 0x09c7, 0x09c8, - 0x09cb, 0x09cd, - 0x09d7, 0x09d7, - 0x09dc, 0x09dd, - 0x09df, 0x09e3, - 0x09e6, 0x09fa, - 0x0a01, 0x0a03, - 0x0a05, 0x0a0a, - 0x0a0f, 0x0a10, - 0x0a13, 0x0a28, - 0x0a2a, 0x0a30, - 0x0a32, 0x0a33, - 0x0a35, 0x0a36, - 0x0a38, 0x0a39, - 0x0a3c, 0x0a3c, - 0x0a3e, 0x0a42, - 0x0a47, 0x0a48, - 0x0a4b, 0x0a4d, - 0x0a59, 0x0a5c, - 0x0a5e, 0x0a5e, - 0x0a66, 0x0a74, - 0x0a81, 0x0a83, - 0x0a85, 0x0a8d, - 0x0a8f, 0x0a91, - 0x0a93, 0x0aa8, - 0x0aaa, 0x0ab0, - 0x0ab2, 0x0ab3, - 0x0ab5, 0x0ab9, - 0x0abc, 0x0ac5, - 0x0ac7, 0x0ac9, - 0x0acb, 0x0acd, - 0x0ad0, 0x0ad0, - 0x0ae0, 0x0ae3, - 0x0ae6, 0x0aef, - 0x0af1, 0x0af1, - 0x0b01, 0x0b03, - 0x0b05, 0x0b0c, - 0x0b0f, 0x0b10, - 0x0b13, 0x0b28, - 0x0b2a, 0x0b30, - 0x0b32, 0x0b33, - 0x0b35, 0x0b39, - 0x0b3c, 0x0b43, - 0x0b47, 0x0b48, - 0x0b4b, 0x0b4d, - 0x0b56, 0x0b57, - 0x0b5c, 0x0b5d, - 0x0b5f, 0x0b61, - 0x0b66, 0x0b71, - 0x0b82, 0x0b83, - 0x0b85, 0x0b8a, - 0x0b8e, 0x0b90, - 0x0b92, 0x0b95, - 0x0b99, 0x0b9a, - 0x0b9c, 0x0b9c, - 0x0b9e, 0x0b9f, - 0x0ba3, 0x0ba4, - 0x0ba8, 0x0baa, - 0x0bae, 0x0bb5, - 0x0bb7, 0x0bb9, - 0x0bbe, 0x0bc2, - 0x0bc6, 0x0bc8, - 0x0bca, 0x0bcd, - 0x0bd7, 0x0bd7, - 0x0be7, 0x0bfa, - 0x0c01, 0x0c03, - 0x0c05, 0x0c0c, - 0x0c0e, 0x0c10, - 0x0c12, 0x0c28, - 0x0c2a, 0x0c33, - 0x0c35, 0x0c39, - 0x0c3e, 0x0c44, - 0x0c46, 0x0c48, - 0x0c4a, 0x0c4d, - 0x0c55, 0x0c56, - 0x0c60, 0x0c61, - 0x0c66, 0x0c6f, - 0x0c82, 0x0c83, - 0x0c85, 0x0c8c, - 0x0c8e, 0x0c90, - 0x0c92, 0x0ca8, - 0x0caa, 0x0cb3, - 0x0cb5, 0x0cb9, - 0x0cbc, 0x0cc4, - 0x0cc6, 0x0cc8, - 0x0cca, 0x0ccd, - 0x0cd5, 0x0cd6, - 0x0cde, 0x0cde, - 0x0ce0, 0x0ce1, - 0x0ce6, 0x0cef, - 0x0d02, 0x0d03, - 0x0d05, 0x0d0c, - 0x0d0e, 0x0d10, - 0x0d12, 0x0d28, - 0x0d2a, 0x0d39, - 0x0d3e, 0x0d43, - 0x0d46, 0x0d48, - 0x0d4a, 0x0d4d, - 0x0d57, 0x0d57, - 0x0d60, 0x0d61, - 0x0d66, 0x0d6f, - 0x0d82, 0x0d83, - 0x0d85, 0x0d96, - 0x0d9a, 0x0db1, - 0x0db3, 0x0dbb, - 0x0dbd, 0x0dbd, - 0x0dc0, 0x0dc6, - 0x0dca, 0x0dca, - 0x0dcf, 0x0dd4, - 0x0dd6, 0x0dd6, - 0x0dd8, 0x0ddf, - 0x0df2, 0x0df4, - 0x0e01, 0x0e3a, - 0x0e3f, 0x0e5b, - 0x0e81, 0x0e82, - 0x0e84, 0x0e84, - 0x0e87, 0x0e88, - 0x0e8a, 0x0e8a, - 0x0e8d, 0x0e8d, - 0x0e94, 0x0e97, - 0x0e99, 0x0e9f, - 0x0ea1, 0x0ea3, - 0x0ea5, 0x0ea5, - 0x0ea7, 0x0ea7, - 0x0eaa, 0x0eab, - 0x0ead, 0x0eb9, - 0x0ebb, 0x0ebd, - 0x0ec0, 0x0ec4, - 0x0ec6, 0x0ec6, - 0x0ec8, 0x0ecd, - 0x0ed0, 0x0ed9, - 0x0edc, 0x0edd, - 0x0f00, 0x0f47, - 0x0f49, 0x0f6a, - 0x0f71, 0x0f8b, - 0x0f90, 0x0f97, - 0x0f99, 0x0fbc, - 0x0fbe, 0x0fcc, - 0x0fcf, 0x0fcf, - 0x1000, 0x1021, - 0x1023, 0x1027, - 0x1029, 0x102a, - 0x102c, 0x1032, - 0x1036, 0x1039, - 0x1040, 0x1059, - 0x10a0, 0x10c5, - 0x10d0, 0x10f8, - 0x10fb, 0x10fb, - 0x1100, 0x1159, - 0x115f, 0x11a2, - 0x11a8, 0x11f9, - 0x1200, 0x1206, - 0x1208, 0x1246, - 0x1248, 0x1248, - 0x124a, 0x124d, - 0x1250, 0x1256, - 0x1258, 0x1258, - 0x125a, 0x125d, - 0x1260, 0x1286, - 0x1288, 0x1288, - 0x128a, 0x128d, - 0x1290, 0x12ae, - 0x12b0, 0x12b0, - 0x12b2, 0x12b5, - 0x12b8, 0x12be, - 0x12c0, 0x12c0, - 0x12c2, 0x12c5, - 0x12c8, 0x12ce, - 0x12d0, 0x12d6, - 0x12d8, 0x12ee, - 0x12f0, 0x130e, - 0x1310, 0x1310, - 0x1312, 0x1315, - 0x1318, 0x131e, - 0x1320, 0x1346, - 0x1348, 0x135a, - 0x1361, 0x137c, - 0x13a0, 0x13f4, - 0x1401, 0x1676, - 0x1681, 0x169c, - 0x16a0, 0x16f0, - 0x1700, 0x170c, - 0x170e, 0x1714, - 0x1720, 0x1736, - 0x1740, 0x1753, - 0x1760, 0x176c, - 0x176e, 0x1770, - 0x1772, 0x1773, - 0x1780, 0x17dd, - 0x17e0, 0x17e9, - 0x17f0, 0x17f9, - 0x1800, 0x180d, - 0x1810, 0x1819, - 0x1820, 0x1877, - 0x1880, 0x18a9, - 0x1900, 0x191c, - 0x1920, 0x192b, - 0x1930, 0x193b, - 0x1940, 0x1940, - 0x1944, 0x196d, - 0x1970, 0x1974, - 0x19e0, 0x19ff, - 0x1d00, 0x1d6b, - 0x1e00, 0x1e9b, - 0x1ea0, 0x1ef9, - 0x1f00, 0x1f15, - 0x1f18, 0x1f1d, - 0x1f20, 0x1f45, - 0x1f48, 0x1f4d, - 0x1f50, 0x1f57, - 0x1f59, 0x1f59, - 0x1f5b, 0x1f5b, - 0x1f5d, 0x1f5d, - 0x1f5f, 0x1f7d, - 0x1f80, 0x1fb4, - 0x1fb6, 0x1fc4, - 0x1fc6, 0x1fd3, - 0x1fd6, 0x1fdb, - 0x1fdd, 0x1fef, - 0x1ff2, 0x1ff4, - 0x1ff6, 0x1ffe, - 0x200b, 0x2027, - 0x202a, 0x202e, - 0x2030, 0x2054, - 0x2057, 0x2057, - 0x2060, 0x2063, - 0x206a, 0x2071, - 0x2074, 0x208e, - 0x20a0, 0x20b1, - 0x20d0, 0x20ea, - 0x2100, 0x213b, - 0x213d, 0x214b, - 0x2153, 0x2183, - 0x2190, 0x23d0, - 0x2400, 0x2426, - 0x2440, 0x244a, - 0x2460, 0x2617, - 0x2619, 0x267d, - 0x2680, 0x2691, - 0x26a0, 0x26a1, - 0x2701, 0x2704, - 0x2706, 0x2709, - 0x270c, 0x2727, - 0x2729, 0x274b, - 0x274d, 0x274d, - 0x274f, 0x2752, - 0x2756, 0x2756, - 0x2758, 0x275e, - 0x2761, 0x2794, - 0x2798, 0x27af, - 0x27b1, 0x27be, - 0x27d0, 0x27eb, - 0x27f0, 0x2b0d, - 0x2e80, 0x2e99, - 0x2e9b, 0x2ef3, - 0x2f00, 0x2fd5, - 0x2ff0, 0x2ffb, - 0x3001, 0x303f, - 0x3041, 0x3096, - 0x3099, 0x30ff, - 0x3105, 0x312c, - 0x3131, 0x318e, - 0x3190, 0x31b7, - 0x31f0, 0x321e, - 0x3220, 0x3243, - 0x3250, 0x327d, - 0x327f, 0x32fe, - 0x3300, 0x4db5, - 0x4dc0, 0x9fa5, - 0xa000, 0xa48c, - 0xa490, 0xa4c6, - 0xac00, 0xd7a3, - 0xe000, 0xfa2d, - 0xfa30, 0xfa6a, - 0xfb00, 0xfb06, - 0xfb13, 0xfb17, - 0xfb1d, 0xfb36, - 0xfb38, 0xfb3c, - 0xfb3e, 0xfb3e, - 0xfb40, 0xfb41, - 0xfb43, 0xfb44, - 0xfb46, 0xfbb1, - 0xfbd3, 0xfd3f, - 0xfd50, 0xfd8f, - 0xfd92, 0xfdc7, - 0xfdf0, 0xfdfd, - 0xfe00, 0xfe0f, - 0xfe20, 0xfe23, - 0xfe30, 0xfe52, - 0xfe54, 0xfe66, - 0xfe68, 0xfe6b, - 0xfe70, 0xfe74, - 0xfe76, 0xfefc, - 0xfeff, 0xfeff, - 0xff01, 0xffbe, - 0xffc2, 0xffc7, - 0xffca, 0xffcf, - 0xffd2, 0xffd7, - 0xffda, 0xffdc, - 0xffe0, 0xffe6, - 0xffe8, 0xffee, - 0xfff9, 0xfffd, - 0x10000, 0x1000b, - 0x1000d, 0x10026, - 0x10028, 0x1003a, - 0x1003c, 0x1003d, - 0x1003f, 0x1004d, - 0x10050, 0x1005d, - 0x10080, 0x100fa, - 0x10100, 0x10102, - 0x10107, 0x10133, - 0x10137, 0x1013f, - 0x10300, 0x1031e, - 0x10320, 0x10323, - 0x10330, 0x1034a, - 0x10380, 0x1039d, - 0x1039f, 0x1039f, - 0x10400, 0x1049d, - 0x104a0, 0x104a9, - 0x10800, 0x10805, - 0x10808, 0x10808, - 0x1080a, 0x10835, - 0x10837, 0x10838, - 0x1083c, 0x1083c, - 0x1083f, 0x1083f, - 0x1d000, 0x1d0f5, - 0x1d100, 0x1d126, - 0x1d12a, 0x1d1dd, - 0x1d300, 0x1d356, - 0x1d400, 0x1d454, - 0x1d456, 0x1d49c, - 0x1d49e, 0x1d49f, - 0x1d4a2, 0x1d4a2, - 0x1d4a5, 0x1d4a6, - 0x1d4a9, 0x1d4ac, - 0x1d4ae, 0x1d4b9, - 0x1d4bb, 0x1d4bb, - 0x1d4bd, 0x1d4c3, - 0x1d4c5, 0x1d505, - 0x1d507, 0x1d50a, - 0x1d50d, 0x1d514, - 0x1d516, 0x1d51c, - 0x1d51e, 0x1d539, - 0x1d53b, 0x1d53e, - 0x1d540, 0x1d544, - 0x1d546, 0x1d546, - 0x1d54a, 0x1d550, - 0x1d552, 0x1d6a3, - 0x1d6a8, 0x1d7c9, - 0x1d7ce, 0x1d7ff, - 0x20000, 0x2a6d6, - 0x2f800, 0x2fa1d, - 0xe0001, 0xe0001, - 0xe0020, 0xe007f, - 0xe0100, 0xe01ef, - 0xf0000, 0xffffd, - 0x100000, 0x10fffd -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBGraph */ - -static const OnigCodePoint SBLower[] = { - 1, - 0x0061, 0x007a -}; - -static const OnigCodePoint MBLower[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 423, -#else - 5, -#endif - 0x00aa, 0x00aa, - 0x00b5, 0x00b5, - 0x00ba, 0x00ba, - 0x00df, 0x00f6, - 0x00f8, 0x00ff -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0101, 0x0101, - 0x0103, 0x0103, - 0x0105, 0x0105, - 0x0107, 0x0107, - 0x0109, 0x0109, - 0x010b, 0x010b, - 0x010d, 0x010d, - 0x010f, 0x010f, - 0x0111, 0x0111, - 0x0113, 0x0113, - 0x0115, 0x0115, - 0x0117, 0x0117, - 0x0119, 0x0119, - 0x011b, 0x011b, - 0x011d, 0x011d, - 0x011f, 0x011f, - 0x0121, 0x0121, - 0x0123, 0x0123, - 0x0125, 0x0125, - 0x0127, 0x0127, - 0x0129, 0x0129, - 0x012b, 0x012b, - 0x012d, 0x012d, - 0x012f, 0x012f, - 0x0131, 0x0131, - 0x0133, 0x0133, - 0x0135, 0x0135, - 0x0137, 0x0138, - 0x013a, 0x013a, - 0x013c, 0x013c, - 0x013e, 0x013e, - 0x0140, 0x0140, - 0x0142, 0x0142, - 0x0144, 0x0144, - 0x0146, 0x0146, - 0x0148, 0x0149, - 0x014b, 0x014b, - 0x014d, 0x014d, - 0x014f, 0x014f, - 0x0151, 0x0151, - 0x0153, 0x0153, - 0x0155, 0x0155, - 0x0157, 0x0157, - 0x0159, 0x0159, - 0x015b, 0x015b, - 0x015d, 0x015d, - 0x015f, 0x015f, - 0x0161, 0x0161, - 0x0163, 0x0163, - 0x0165, 0x0165, - 0x0167, 0x0167, - 0x0169, 0x0169, - 0x016b, 0x016b, - 0x016d, 0x016d, - 0x016f, 0x016f, - 0x0171, 0x0171, - 0x0173, 0x0173, - 0x0175, 0x0175, - 0x0177, 0x0177, - 0x017a, 0x017a, - 0x017c, 0x017c, - 0x017e, 0x0180, - 0x0183, 0x0183, - 0x0185, 0x0185, - 0x0188, 0x0188, - 0x018c, 0x018d, - 0x0192, 0x0192, - 0x0195, 0x0195, - 0x0199, 0x019b, - 0x019e, 0x019e, - 0x01a1, 0x01a1, - 0x01a3, 0x01a3, - 0x01a5, 0x01a5, - 0x01a8, 0x01a8, - 0x01aa, 0x01ab, - 0x01ad, 0x01ad, - 0x01b0, 0x01b0, - 0x01b4, 0x01b4, - 0x01b6, 0x01b6, - 0x01b9, 0x01ba, - 0x01bd, 0x01bf, - 0x01c6, 0x01c6, - 0x01c9, 0x01c9, - 0x01cc, 0x01cc, - 0x01ce, 0x01ce, - 0x01d0, 0x01d0, - 0x01d2, 0x01d2, - 0x01d4, 0x01d4, - 0x01d6, 0x01d6, - 0x01d8, 0x01d8, - 0x01da, 0x01da, - 0x01dc, 0x01dd, - 0x01df, 0x01df, - 0x01e1, 0x01e1, - 0x01e3, 0x01e3, - 0x01e5, 0x01e5, - 0x01e7, 0x01e7, - 0x01e9, 0x01e9, - 0x01eb, 0x01eb, - 0x01ed, 0x01ed, - 0x01ef, 0x01f0, - 0x01f3, 0x01f3, - 0x01f5, 0x01f5, - 0x01f9, 0x01f9, - 0x01fb, 0x01fb, - 0x01fd, 0x01fd, - 0x01ff, 0x01ff, - 0x0201, 0x0201, - 0x0203, 0x0203, - 0x0205, 0x0205, - 0x0207, 0x0207, - 0x0209, 0x0209, - 0x020b, 0x020b, - 0x020d, 0x020d, - 0x020f, 0x020f, - 0x0211, 0x0211, - 0x0213, 0x0213, - 0x0215, 0x0215, - 0x0217, 0x0217, - 0x0219, 0x0219, - 0x021b, 0x021b, - 0x021d, 0x021d, - 0x021f, 0x021f, - 0x0221, 0x0221, - 0x0223, 0x0223, - 0x0225, 0x0225, - 0x0227, 0x0227, - 0x0229, 0x0229, - 0x022b, 0x022b, - 0x022d, 0x022d, - 0x022f, 0x022f, - 0x0231, 0x0231, - 0x0233, 0x0236, - 0x0250, 0x02af, - 0x0390, 0x0390, - 0x03ac, 0x03ce, - 0x03d0, 0x03d1, - 0x03d5, 0x03d7, - 0x03d9, 0x03d9, - 0x03db, 0x03db, - 0x03dd, 0x03dd, - 0x03df, 0x03df, - 0x03e1, 0x03e1, - 0x03e3, 0x03e3, - 0x03e5, 0x03e5, - 0x03e7, 0x03e7, - 0x03e9, 0x03e9, - 0x03eb, 0x03eb, - 0x03ed, 0x03ed, - 0x03ef, 0x03f3, - 0x03f5, 0x03f5, - 0x03f8, 0x03f8, - 0x03fb, 0x03fb, - 0x0430, 0x045f, - 0x0461, 0x0461, - 0x0463, 0x0463, - 0x0465, 0x0465, - 0x0467, 0x0467, - 0x0469, 0x0469, - 0x046b, 0x046b, - 0x046d, 0x046d, - 0x046f, 0x046f, - 0x0471, 0x0471, - 0x0473, 0x0473, - 0x0475, 0x0475, - 0x0477, 0x0477, - 0x0479, 0x0479, - 0x047b, 0x047b, - 0x047d, 0x047d, - 0x047f, 0x047f, - 0x0481, 0x0481, - 0x048b, 0x048b, - 0x048d, 0x048d, - 0x048f, 0x048f, - 0x0491, 0x0491, - 0x0493, 0x0493, - 0x0495, 0x0495, - 0x0497, 0x0497, - 0x0499, 0x0499, - 0x049b, 0x049b, - 0x049d, 0x049d, - 0x049f, 0x049f, - 0x04a1, 0x04a1, - 0x04a3, 0x04a3, - 0x04a5, 0x04a5, - 0x04a7, 0x04a7, - 0x04a9, 0x04a9, - 0x04ab, 0x04ab, - 0x04ad, 0x04ad, - 0x04af, 0x04af, - 0x04b1, 0x04b1, - 0x04b3, 0x04b3, - 0x04b5, 0x04b5, - 0x04b7, 0x04b7, - 0x04b9, 0x04b9, - 0x04bb, 0x04bb, - 0x04bd, 0x04bd, - 0x04bf, 0x04bf, - 0x04c2, 0x04c2, - 0x04c4, 0x04c4, - 0x04c6, 0x04c6, - 0x04c8, 0x04c8, - 0x04ca, 0x04ca, - 0x04cc, 0x04cc, - 0x04ce, 0x04ce, - 0x04d1, 0x04d1, - 0x04d3, 0x04d3, - 0x04d5, 0x04d5, - 0x04d7, 0x04d7, - 0x04d9, 0x04d9, - 0x04db, 0x04db, - 0x04dd, 0x04dd, - 0x04df, 0x04df, - 0x04e1, 0x04e1, - 0x04e3, 0x04e3, - 0x04e5, 0x04e5, - 0x04e7, 0x04e7, - 0x04e9, 0x04e9, - 0x04eb, 0x04eb, - 0x04ed, 0x04ed, - 0x04ef, 0x04ef, - 0x04f1, 0x04f1, - 0x04f3, 0x04f3, - 0x04f5, 0x04f5, - 0x04f9, 0x04f9, - 0x0501, 0x0501, - 0x0503, 0x0503, - 0x0505, 0x0505, - 0x0507, 0x0507, - 0x0509, 0x0509, - 0x050b, 0x050b, - 0x050d, 0x050d, - 0x050f, 0x050f, - 0x0561, 0x0587, - 0x1d00, 0x1d2b, - 0x1d62, 0x1d6b, - 0x1e01, 0x1e01, - 0x1e03, 0x1e03, - 0x1e05, 0x1e05, - 0x1e07, 0x1e07, - 0x1e09, 0x1e09, - 0x1e0b, 0x1e0b, - 0x1e0d, 0x1e0d, - 0x1e0f, 0x1e0f, - 0x1e11, 0x1e11, - 0x1e13, 0x1e13, - 0x1e15, 0x1e15, - 0x1e17, 0x1e17, - 0x1e19, 0x1e19, - 0x1e1b, 0x1e1b, - 0x1e1d, 0x1e1d, - 0x1e1f, 0x1e1f, - 0x1e21, 0x1e21, - 0x1e23, 0x1e23, - 0x1e25, 0x1e25, - 0x1e27, 0x1e27, - 0x1e29, 0x1e29, - 0x1e2b, 0x1e2b, - 0x1e2d, 0x1e2d, - 0x1e2f, 0x1e2f, - 0x1e31, 0x1e31, - 0x1e33, 0x1e33, - 0x1e35, 0x1e35, - 0x1e37, 0x1e37, - 0x1e39, 0x1e39, - 0x1e3b, 0x1e3b, - 0x1e3d, 0x1e3d, - 0x1e3f, 0x1e3f, - 0x1e41, 0x1e41, - 0x1e43, 0x1e43, - 0x1e45, 0x1e45, - 0x1e47, 0x1e47, - 0x1e49, 0x1e49, - 0x1e4b, 0x1e4b, - 0x1e4d, 0x1e4d, - 0x1e4f, 0x1e4f, - 0x1e51, 0x1e51, - 0x1e53, 0x1e53, - 0x1e55, 0x1e55, - 0x1e57, 0x1e57, - 0x1e59, 0x1e59, - 0x1e5b, 0x1e5b, - 0x1e5d, 0x1e5d, - 0x1e5f, 0x1e5f, - 0x1e61, 0x1e61, - 0x1e63, 0x1e63, - 0x1e65, 0x1e65, - 0x1e67, 0x1e67, - 0x1e69, 0x1e69, - 0x1e6b, 0x1e6b, - 0x1e6d, 0x1e6d, - 0x1e6f, 0x1e6f, - 0x1e71, 0x1e71, - 0x1e73, 0x1e73, - 0x1e75, 0x1e75, - 0x1e77, 0x1e77, - 0x1e79, 0x1e79, - 0x1e7b, 0x1e7b, - 0x1e7d, 0x1e7d, - 0x1e7f, 0x1e7f, - 0x1e81, 0x1e81, - 0x1e83, 0x1e83, - 0x1e85, 0x1e85, - 0x1e87, 0x1e87, - 0x1e89, 0x1e89, - 0x1e8b, 0x1e8b, - 0x1e8d, 0x1e8d, - 0x1e8f, 0x1e8f, - 0x1e91, 0x1e91, - 0x1e93, 0x1e93, - 0x1e95, 0x1e9b, - 0x1ea1, 0x1ea1, - 0x1ea3, 0x1ea3, - 0x1ea5, 0x1ea5, - 0x1ea7, 0x1ea7, - 0x1ea9, 0x1ea9, - 0x1eab, 0x1eab, - 0x1ead, 0x1ead, - 0x1eaf, 0x1eaf, - 0x1eb1, 0x1eb1, - 0x1eb3, 0x1eb3, - 0x1eb5, 0x1eb5, - 0x1eb7, 0x1eb7, - 0x1eb9, 0x1eb9, - 0x1ebb, 0x1ebb, - 0x1ebd, 0x1ebd, - 0x1ebf, 0x1ebf, - 0x1ec1, 0x1ec1, - 0x1ec3, 0x1ec3, - 0x1ec5, 0x1ec5, - 0x1ec7, 0x1ec7, - 0x1ec9, 0x1ec9, - 0x1ecb, 0x1ecb, - 0x1ecd, 0x1ecd, - 0x1ecf, 0x1ecf, - 0x1ed1, 0x1ed1, - 0x1ed3, 0x1ed3, - 0x1ed5, 0x1ed5, - 0x1ed7, 0x1ed7, - 0x1ed9, 0x1ed9, - 0x1edb, 0x1edb, - 0x1edd, 0x1edd, - 0x1edf, 0x1edf, - 0x1ee1, 0x1ee1, - 0x1ee3, 0x1ee3, - 0x1ee5, 0x1ee5, - 0x1ee7, 0x1ee7, - 0x1ee9, 0x1ee9, - 0x1eeb, 0x1eeb, - 0x1eed, 0x1eed, - 0x1eef, 0x1eef, - 0x1ef1, 0x1ef1, - 0x1ef3, 0x1ef3, - 0x1ef5, 0x1ef5, - 0x1ef7, 0x1ef7, - 0x1ef9, 0x1ef9, - 0x1f00, 0x1f07, - 0x1f10, 0x1f15, - 0x1f20, 0x1f27, - 0x1f30, 0x1f37, - 0x1f40, 0x1f45, - 0x1f50, 0x1f57, - 0x1f60, 0x1f67, - 0x1f70, 0x1f7d, - 0x1f80, 0x1f87, - 0x1f90, 0x1f97, - 0x1fa0, 0x1fa7, - 0x1fb0, 0x1fb4, - 0x1fb6, 0x1fb7, - 0x1fbe, 0x1fbe, - 0x1fc2, 0x1fc4, - 0x1fc6, 0x1fc7, - 0x1fd0, 0x1fd3, - 0x1fd6, 0x1fd7, - 0x1fe0, 0x1fe7, - 0x1ff2, 0x1ff4, - 0x1ff6, 0x1ff7, - 0x2071, 0x2071, - 0x207f, 0x207f, - 0x210a, 0x210a, - 0x210e, 0x210f, - 0x2113, 0x2113, - 0x212f, 0x212f, - 0x2134, 0x2134, - 0x2139, 0x2139, - 0x213d, 0x213d, - 0x2146, 0x2149, - 0xfb00, 0xfb06, - 0xfb13, 0xfb17, - 0xff41, 0xff5a, - 0x10428, 0x1044f, - 0x1d41a, 0x1d433, - 0x1d44e, 0x1d454, - 0x1d456, 0x1d467, - 0x1d482, 0x1d49b, - 0x1d4b6, 0x1d4b9, - 0x1d4bb, 0x1d4bb, - 0x1d4bd, 0x1d4c3, - 0x1d4c5, 0x1d4cf, - 0x1d4ea, 0x1d503, - 0x1d51e, 0x1d537, - 0x1d552, 0x1d56b, - 0x1d586, 0x1d59f, - 0x1d5ba, 0x1d5d3, - 0x1d5ee, 0x1d607, - 0x1d622, 0x1d63b, - 0x1d656, 0x1d66f, - 0x1d68a, 0x1d6a3, - 0x1d6c2, 0x1d6da, - 0x1d6dc, 0x1d6e1, - 0x1d6fc, 0x1d714, - 0x1d716, 0x1d71b, - 0x1d736, 0x1d74e, - 0x1d750, 0x1d755, - 0x1d770, 0x1d788, - 0x1d78a, 0x1d78f, - 0x1d7aa, 0x1d7c2, - 0x1d7c4, 0x1d7c9 -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBLower */ - -static const OnigCodePoint SBPrint[] = { - 2, - 0x0009, 0x000d, - 0x0020, 0x007e -}; - -static const OnigCodePoint MBPrint[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 403, -#else - 2, #endif - 0x0085, 0x0085, - 0x00a0, 0x0236 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0250, 0x0357, - 0x035d, 0x036f, - 0x0374, 0x0375, - 0x037a, 0x037a, - 0x037e, 0x037e, - 0x0384, 0x038a, - 0x038c, 0x038c, - 0x038e, 0x03a1, - 0x03a3, 0x03ce, - 0x03d0, 0x03fb, - 0x0400, 0x0486, - 0x0488, 0x04ce, - 0x04d0, 0x04f5, - 0x04f8, 0x04f9, - 0x0500, 0x050f, - 0x0531, 0x0556, - 0x0559, 0x055f, - 0x0561, 0x0587, - 0x0589, 0x058a, - 0x0591, 0x05a1, - 0x05a3, 0x05b9, - 0x05bb, 0x05c4, - 0x05d0, 0x05ea, - 0x05f0, 0x05f4, - 0x0600, 0x0603, - 0x060c, 0x0615, - 0x061b, 0x061b, - 0x061f, 0x061f, - 0x0621, 0x063a, - 0x0640, 0x0658, - 0x0660, 0x070d, - 0x070f, 0x074a, - 0x074d, 0x074f, - 0x0780, 0x07b1, - 0x0901, 0x0939, - 0x093c, 0x094d, - 0x0950, 0x0954, - 0x0958, 0x0970, - 0x0981, 0x0983, - 0x0985, 0x098c, - 0x098f, 0x0990, - 0x0993, 0x09a8, - 0x09aa, 0x09b0, - 0x09b2, 0x09b2, - 0x09b6, 0x09b9, - 0x09bc, 0x09c4, - 0x09c7, 0x09c8, - 0x09cb, 0x09cd, - 0x09d7, 0x09d7, - 0x09dc, 0x09dd, - 0x09df, 0x09e3, - 0x09e6, 0x09fa, - 0x0a01, 0x0a03, - 0x0a05, 0x0a0a, - 0x0a0f, 0x0a10, - 0x0a13, 0x0a28, - 0x0a2a, 0x0a30, - 0x0a32, 0x0a33, - 0x0a35, 0x0a36, - 0x0a38, 0x0a39, - 0x0a3c, 0x0a3c, - 0x0a3e, 0x0a42, - 0x0a47, 0x0a48, - 0x0a4b, 0x0a4d, - 0x0a59, 0x0a5c, - 0x0a5e, 0x0a5e, - 0x0a66, 0x0a74, - 0x0a81, 0x0a83, - 0x0a85, 0x0a8d, - 0x0a8f, 0x0a91, - 0x0a93, 0x0aa8, - 0x0aaa, 0x0ab0, - 0x0ab2, 0x0ab3, - 0x0ab5, 0x0ab9, - 0x0abc, 0x0ac5, - 0x0ac7, 0x0ac9, - 0x0acb, 0x0acd, - 0x0ad0, 0x0ad0, - 0x0ae0, 0x0ae3, - 0x0ae6, 0x0aef, - 0x0af1, 0x0af1, - 0x0b01, 0x0b03, - 0x0b05, 0x0b0c, - 0x0b0f, 0x0b10, - 0x0b13, 0x0b28, - 0x0b2a, 0x0b30, - 0x0b32, 0x0b33, - 0x0b35, 0x0b39, - 0x0b3c, 0x0b43, - 0x0b47, 0x0b48, - 0x0b4b, 0x0b4d, - 0x0b56, 0x0b57, - 0x0b5c, 0x0b5d, - 0x0b5f, 0x0b61, - 0x0b66, 0x0b71, - 0x0b82, 0x0b83, - 0x0b85, 0x0b8a, - 0x0b8e, 0x0b90, - 0x0b92, 0x0b95, - 0x0b99, 0x0b9a, - 0x0b9c, 0x0b9c, - 0x0b9e, 0x0b9f, - 0x0ba3, 0x0ba4, - 0x0ba8, 0x0baa, - 0x0bae, 0x0bb5, - 0x0bb7, 0x0bb9, - 0x0bbe, 0x0bc2, - 0x0bc6, 0x0bc8, - 0x0bca, 0x0bcd, - 0x0bd7, 0x0bd7, - 0x0be7, 0x0bfa, - 0x0c01, 0x0c03, - 0x0c05, 0x0c0c, - 0x0c0e, 0x0c10, - 0x0c12, 0x0c28, - 0x0c2a, 0x0c33, - 0x0c35, 0x0c39, - 0x0c3e, 0x0c44, - 0x0c46, 0x0c48, - 0x0c4a, 0x0c4d, - 0x0c55, 0x0c56, - 0x0c60, 0x0c61, - 0x0c66, 0x0c6f, - 0x0c82, 0x0c83, - 0x0c85, 0x0c8c, - 0x0c8e, 0x0c90, - 0x0c92, 0x0ca8, - 0x0caa, 0x0cb3, - 0x0cb5, 0x0cb9, - 0x0cbc, 0x0cc4, - 0x0cc6, 0x0cc8, - 0x0cca, 0x0ccd, - 0x0cd5, 0x0cd6, - 0x0cde, 0x0cde, - 0x0ce0, 0x0ce1, - 0x0ce6, 0x0cef, - 0x0d02, 0x0d03, - 0x0d05, 0x0d0c, - 0x0d0e, 0x0d10, - 0x0d12, 0x0d28, - 0x0d2a, 0x0d39, - 0x0d3e, 0x0d43, - 0x0d46, 0x0d48, - 0x0d4a, 0x0d4d, - 0x0d57, 0x0d57, - 0x0d60, 0x0d61, - 0x0d66, 0x0d6f, - 0x0d82, 0x0d83, - 0x0d85, 0x0d96, - 0x0d9a, 0x0db1, - 0x0db3, 0x0dbb, - 0x0dbd, 0x0dbd, - 0x0dc0, 0x0dc6, - 0x0dca, 0x0dca, - 0x0dcf, 0x0dd4, - 0x0dd6, 0x0dd6, - 0x0dd8, 0x0ddf, - 0x0df2, 0x0df4, - 0x0e01, 0x0e3a, - 0x0e3f, 0x0e5b, - 0x0e81, 0x0e82, - 0x0e84, 0x0e84, - 0x0e87, 0x0e88, - 0x0e8a, 0x0e8a, - 0x0e8d, 0x0e8d, - 0x0e94, 0x0e97, - 0x0e99, 0x0e9f, - 0x0ea1, 0x0ea3, - 0x0ea5, 0x0ea5, - 0x0ea7, 0x0ea7, - 0x0eaa, 0x0eab, - 0x0ead, 0x0eb9, - 0x0ebb, 0x0ebd, - 0x0ec0, 0x0ec4, - 0x0ec6, 0x0ec6, - 0x0ec8, 0x0ecd, - 0x0ed0, 0x0ed9, - 0x0edc, 0x0edd, - 0x0f00, 0x0f47, - 0x0f49, 0x0f6a, - 0x0f71, 0x0f8b, - 0x0f90, 0x0f97, - 0x0f99, 0x0fbc, - 0x0fbe, 0x0fcc, - 0x0fcf, 0x0fcf, - 0x1000, 0x1021, - 0x1023, 0x1027, - 0x1029, 0x102a, - 0x102c, 0x1032, - 0x1036, 0x1039, - 0x1040, 0x1059, - 0x10a0, 0x10c5, - 0x10d0, 0x10f8, - 0x10fb, 0x10fb, - 0x1100, 0x1159, - 0x115f, 0x11a2, - 0x11a8, 0x11f9, - 0x1200, 0x1206, - 0x1208, 0x1246, - 0x1248, 0x1248, - 0x124a, 0x124d, - 0x1250, 0x1256, - 0x1258, 0x1258, - 0x125a, 0x125d, - 0x1260, 0x1286, - 0x1288, 0x1288, - 0x128a, 0x128d, - 0x1290, 0x12ae, - 0x12b0, 0x12b0, - 0x12b2, 0x12b5, - 0x12b8, 0x12be, - 0x12c0, 0x12c0, - 0x12c2, 0x12c5, - 0x12c8, 0x12ce, - 0x12d0, 0x12d6, - 0x12d8, 0x12ee, - 0x12f0, 0x130e, - 0x1310, 0x1310, - 0x1312, 0x1315, - 0x1318, 0x131e, - 0x1320, 0x1346, - 0x1348, 0x135a, - 0x1361, 0x137c, - 0x13a0, 0x13f4, - 0x1401, 0x1676, - 0x1680, 0x169c, - 0x16a0, 0x16f0, - 0x1700, 0x170c, - 0x170e, 0x1714, - 0x1720, 0x1736, - 0x1740, 0x1753, - 0x1760, 0x176c, - 0x176e, 0x1770, - 0x1772, 0x1773, - 0x1780, 0x17dd, - 0x17e0, 0x17e9, - 0x17f0, 0x17f9, - 0x1800, 0x180e, - 0x1810, 0x1819, - 0x1820, 0x1877, - 0x1880, 0x18a9, - 0x1900, 0x191c, - 0x1920, 0x192b, - 0x1930, 0x193b, - 0x1940, 0x1940, - 0x1944, 0x196d, - 0x1970, 0x1974, - 0x19e0, 0x19ff, - 0x1d00, 0x1d6b, - 0x1e00, 0x1e9b, - 0x1ea0, 0x1ef9, - 0x1f00, 0x1f15, - 0x1f18, 0x1f1d, - 0x1f20, 0x1f45, - 0x1f48, 0x1f4d, - 0x1f50, 0x1f57, - 0x1f59, 0x1f59, - 0x1f5b, 0x1f5b, - 0x1f5d, 0x1f5d, - 0x1f5f, 0x1f7d, - 0x1f80, 0x1fb4, - 0x1fb6, 0x1fc4, - 0x1fc6, 0x1fd3, - 0x1fd6, 0x1fdb, - 0x1fdd, 0x1fef, - 0x1ff2, 0x1ff4, - 0x1ff6, 0x1ffe, - 0x2000, 0x2054, - 0x2057, 0x2057, - 0x205f, 0x2063, - 0x206a, 0x2071, - 0x2074, 0x208e, - 0x20a0, 0x20b1, - 0x20d0, 0x20ea, - 0x2100, 0x213b, - 0x213d, 0x214b, - 0x2153, 0x2183, - 0x2190, 0x23d0, - 0x2400, 0x2426, - 0x2440, 0x244a, - 0x2460, 0x2617, - 0x2619, 0x267d, - 0x2680, 0x2691, - 0x26a0, 0x26a1, - 0x2701, 0x2704, - 0x2706, 0x2709, - 0x270c, 0x2727, - 0x2729, 0x274b, - 0x274d, 0x274d, - 0x274f, 0x2752, - 0x2756, 0x2756, - 0x2758, 0x275e, - 0x2761, 0x2794, - 0x2798, 0x27af, - 0x27b1, 0x27be, - 0x27d0, 0x27eb, - 0x27f0, 0x2b0d, - 0x2e80, 0x2e99, - 0x2e9b, 0x2ef3, - 0x2f00, 0x2fd5, - 0x2ff0, 0x2ffb, - 0x3000, 0x303f, - 0x3041, 0x3096, - 0x3099, 0x30ff, - 0x3105, 0x312c, - 0x3131, 0x318e, - 0x3190, 0x31b7, - 0x31f0, 0x321e, - 0x3220, 0x3243, - 0x3250, 0x327d, - 0x327f, 0x32fe, - 0x3300, 0x4db5, - 0x4dc0, 0x9fa5, - 0xa000, 0xa48c, - 0xa490, 0xa4c6, - 0xac00, 0xd7a3, - 0xe000, 0xfa2d, - 0xfa30, 0xfa6a, - 0xfb00, 0xfb06, - 0xfb13, 0xfb17, - 0xfb1d, 0xfb36, - 0xfb38, 0xfb3c, - 0xfb3e, 0xfb3e, - 0xfb40, 0xfb41, - 0xfb43, 0xfb44, - 0xfb46, 0xfbb1, - 0xfbd3, 0xfd3f, - 0xfd50, 0xfd8f, - 0xfd92, 0xfdc7, - 0xfdf0, 0xfdfd, - 0xfe00, 0xfe0f, - 0xfe20, 0xfe23, - 0xfe30, 0xfe52, - 0xfe54, 0xfe66, - 0xfe68, 0xfe6b, - 0xfe70, 0xfe74, - 0xfe76, 0xfefc, - 0xfeff, 0xfeff, - 0xff01, 0xffbe, - 0xffc2, 0xffc7, - 0xffca, 0xffcf, - 0xffd2, 0xffd7, - 0xffda, 0xffdc, - 0xffe0, 0xffe6, - 0xffe8, 0xffee, - 0xfff9, 0xfffd, - 0x10000, 0x1000b, - 0x1000d, 0x10026, - 0x10028, 0x1003a, - 0x1003c, 0x1003d, - 0x1003f, 0x1004d, - 0x10050, 0x1005d, - 0x10080, 0x100fa, - 0x10100, 0x10102, - 0x10107, 0x10133, - 0x10137, 0x1013f, - 0x10300, 0x1031e, - 0x10320, 0x10323, - 0x10330, 0x1034a, - 0x10380, 0x1039d, - 0x1039f, 0x1039f, - 0x10400, 0x1049d, - 0x104a0, 0x104a9, - 0x10800, 0x10805, - 0x10808, 0x10808, - 0x1080a, 0x10835, - 0x10837, 0x10838, - 0x1083c, 0x1083c, - 0x1083f, 0x1083f, - 0x1d000, 0x1d0f5, - 0x1d100, 0x1d126, - 0x1d12a, 0x1d1dd, - 0x1d300, 0x1d356, - 0x1d400, 0x1d454, - 0x1d456, 0x1d49c, - 0x1d49e, 0x1d49f, - 0x1d4a2, 0x1d4a2, - 0x1d4a5, 0x1d4a6, - 0x1d4a9, 0x1d4ac, - 0x1d4ae, 0x1d4b9, - 0x1d4bb, 0x1d4bb, - 0x1d4bd, 0x1d4c3, - 0x1d4c5, 0x1d505, - 0x1d507, 0x1d50a, - 0x1d50d, 0x1d514, - 0x1d516, 0x1d51c, - 0x1d51e, 0x1d539, - 0x1d53b, 0x1d53e, - 0x1d540, 0x1d544, - 0x1d546, 0x1d546, - 0x1d54a, 0x1d550, - 0x1d552, 0x1d6a3, - 0x1d6a8, 0x1d7c9, - 0x1d7ce, 0x1d7ff, - 0x20000, 0x2a6d6, - 0x2f800, 0x2fa1d, - 0xe0001, 0xe0001, - 0xe0020, 0xe007f, - 0xe0100, 0xe01ef, - 0xf0000, 0xffffd, - 0x100000, 0x10fffd -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBPrint */ - -static const OnigCodePoint SBPunct[] = { - 9, - 0x0021, 0x0023, - 0x0025, 0x002a, - 0x002c, 0x002f, - 0x003a, 0x003b, - 0x003f, 0x0040, - 0x005b, 0x005d, - 0x005f, 0x005f, - 0x007b, 0x007b, - 0x007d, 0x007d -}; /* end of SBPunct */ - -static const OnigCodePoint MBPunct[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 77, -#else - 5, -#endif - 0x00a1, 0x00a1, - 0x00ab, 0x00ab, - 0x00b7, 0x00b7, - 0x00bb, 0x00bb, - 0x00bf, 0x00bf -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x037e, 0x037e, - 0x0387, 0x0387, - 0x055a, 0x055f, - 0x0589, 0x058a, - 0x05be, 0x05be, - 0x05c0, 0x05c0, - 0x05c3, 0x05c3, - 0x05f3, 0x05f4, - 0x060c, 0x060d, - 0x061b, 0x061b, - 0x061f, 0x061f, - 0x066a, 0x066d, - 0x06d4, 0x06d4, - 0x0700, 0x070d, - 0x0964, 0x0965, - 0x0970, 0x0970, - 0x0df4, 0x0df4, - 0x0e4f, 0x0e4f, - 0x0e5a, 0x0e5b, - 0x0f04, 0x0f12, - 0x0f3a, 0x0f3d, - 0x0f85, 0x0f85, - 0x104a, 0x104f, - 0x10fb, 0x10fb, - 0x1361, 0x1368, - 0x166d, 0x166e, - 0x169b, 0x169c, - 0x16eb, 0x16ed, - 0x1735, 0x1736, - 0x17d4, 0x17d6, - 0x17d8, 0x17da, - 0x1800, 0x180a, - 0x1944, 0x1945, - 0x2010, 0x2027, - 0x2030, 0x2043, - 0x2045, 0x2051, - 0x2053, 0x2054, - 0x2057, 0x2057, - 0x207d, 0x207e, - 0x208d, 0x208e, - 0x2329, 0x232a, - 0x23b4, 0x23b6, - 0x2768, 0x2775, - 0x27e6, 0x27eb, - 0x2983, 0x2998, - 0x29d8, 0x29db, - 0x29fc, 0x29fd, - 0x3001, 0x3003, - 0x3008, 0x3011, - 0x3014, 0x301f, - 0x3030, 0x3030, - 0x303d, 0x303d, - 0x30a0, 0x30a0, - 0x30fb, 0x30fb, - 0xfd3e, 0xfd3f, - 0xfe30, 0xfe52, - 0xfe54, 0xfe61, - 0xfe63, 0xfe63, - 0xfe68, 0xfe68, - 0xfe6a, 0xfe6b, - 0xff01, 0xff03, - 0xff05, 0xff0a, - 0xff0c, 0xff0f, - 0xff1a, 0xff1b, - 0xff1f, 0xff20, - 0xff3b, 0xff3d, - 0xff3f, 0xff3f, - 0xff5b, 0xff5b, - 0xff5d, 0xff5d, - 0xff5f, 0xff65, - 0x10100, 0x10101, - 0x1039f, 0x1039f -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBPunct */ - -static const OnigCodePoint SBSpace[] = { - 2, - 0x0009, 0x000d, - 0x0020, 0x0020 -}; - -static const OnigCodePoint MBSpace[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 9, -#else - 2, -#endif - 0x0085, 0x0085, - 0x00a0, 0x00a0 -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x1680, 0x1680, - 0x180e, 0x180e, - 0x2000, 0x200a, - 0x2028, 0x2029, - 0x202f, 0x202f, - 0x205f, 0x205f, - 0x3000, 0x3000 -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBSpace */ - -static const OnigCodePoint SBUpper[] = { - 1, - 0x0041, 0x005a -}; - -static const OnigCodePoint MBUpper[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 420, -#else - 2, -#endif - 0x00c0, 0x00d6, - 0x00d8, 0x00de -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - , - 0x0100, 0x0100, - 0x0102, 0x0102, - 0x0104, 0x0104, - 0x0106, 0x0106, - 0x0108, 0x0108, - 0x010a, 0x010a, - 0x010c, 0x010c, - 0x010e, 0x010e, - 0x0110, 0x0110, - 0x0112, 0x0112, - 0x0114, 0x0114, - 0x0116, 0x0116, - 0x0118, 0x0118, - 0x011a, 0x011a, - 0x011c, 0x011c, - 0x011e, 0x011e, - 0x0120, 0x0120, - 0x0122, 0x0122, - 0x0124, 0x0124, - 0x0126, 0x0126, - 0x0128, 0x0128, - 0x012a, 0x012a, - 0x012c, 0x012c, - 0x012e, 0x012e, - 0x0130, 0x0130, - 0x0132, 0x0132, - 0x0134, 0x0134, - 0x0136, 0x0136, - 0x0139, 0x0139, - 0x013b, 0x013b, - 0x013d, 0x013d, - 0x013f, 0x013f, - 0x0141, 0x0141, - 0x0143, 0x0143, - 0x0145, 0x0145, - 0x0147, 0x0147, - 0x014a, 0x014a, - 0x014c, 0x014c, - 0x014e, 0x014e, - 0x0150, 0x0150, - 0x0152, 0x0152, - 0x0154, 0x0154, - 0x0156, 0x0156, - 0x0158, 0x0158, - 0x015a, 0x015a, - 0x015c, 0x015c, - 0x015e, 0x015e, - 0x0160, 0x0160, - 0x0162, 0x0162, - 0x0164, 0x0164, - 0x0166, 0x0166, - 0x0168, 0x0168, - 0x016a, 0x016a, - 0x016c, 0x016c, - 0x016e, 0x016e, - 0x0170, 0x0170, - 0x0172, 0x0172, - 0x0174, 0x0174, - 0x0176, 0x0176, - 0x0178, 0x0179, - 0x017b, 0x017b, - 0x017d, 0x017d, - 0x0181, 0x0182, - 0x0184, 0x0184, - 0x0186, 0x0187, - 0x0189, 0x018b, - 0x018e, 0x0191, - 0x0193, 0x0194, - 0x0196, 0x0198, - 0x019c, 0x019d, - 0x019f, 0x01a0, - 0x01a2, 0x01a2, - 0x01a4, 0x01a4, - 0x01a6, 0x01a7, - 0x01a9, 0x01a9, - 0x01ac, 0x01ac, - 0x01ae, 0x01af, - 0x01b1, 0x01b3, - 0x01b5, 0x01b5, - 0x01b7, 0x01b8, - 0x01bc, 0x01bc, - 0x01c4, 0x01c4, - 0x01c7, 0x01c7, - 0x01ca, 0x01ca, - 0x01cd, 0x01cd, - 0x01cf, 0x01cf, - 0x01d1, 0x01d1, - 0x01d3, 0x01d3, - 0x01d5, 0x01d5, - 0x01d7, 0x01d7, - 0x01d9, 0x01d9, - 0x01db, 0x01db, - 0x01de, 0x01de, - 0x01e0, 0x01e0, - 0x01e2, 0x01e2, - 0x01e4, 0x01e4, - 0x01e6, 0x01e6, - 0x01e8, 0x01e8, - 0x01ea, 0x01ea, - 0x01ec, 0x01ec, - 0x01ee, 0x01ee, - 0x01f1, 0x01f1, - 0x01f4, 0x01f4, - 0x01f6, 0x01f8, - 0x01fa, 0x01fa, - 0x01fc, 0x01fc, - 0x01fe, 0x01fe, - 0x0200, 0x0200, - 0x0202, 0x0202, - 0x0204, 0x0204, - 0x0206, 0x0206, - 0x0208, 0x0208, - 0x020a, 0x020a, - 0x020c, 0x020c, - 0x020e, 0x020e, - 0x0210, 0x0210, - 0x0212, 0x0212, - 0x0214, 0x0214, - 0x0216, 0x0216, - 0x0218, 0x0218, - 0x021a, 0x021a, - 0x021c, 0x021c, - 0x021e, 0x021e, - 0x0220, 0x0220, - 0x0222, 0x0222, - 0x0224, 0x0224, - 0x0226, 0x0226, - 0x0228, 0x0228, - 0x022a, 0x022a, - 0x022c, 0x022c, - 0x022e, 0x022e, - 0x0230, 0x0230, - 0x0232, 0x0232, - 0x0386, 0x0386, - 0x0388, 0x038a, - 0x038c, 0x038c, - 0x038e, 0x038f, - 0x0391, 0x03a1, - 0x03a3, 0x03ab, - 0x03d2, 0x03d4, - 0x03d8, 0x03d8, - 0x03da, 0x03da, - 0x03dc, 0x03dc, - 0x03de, 0x03de, - 0x03e0, 0x03e0, - 0x03e2, 0x03e2, - 0x03e4, 0x03e4, - 0x03e6, 0x03e6, - 0x03e8, 0x03e8, - 0x03ea, 0x03ea, - 0x03ec, 0x03ec, - 0x03ee, 0x03ee, - 0x03f4, 0x03f4, - 0x03f7, 0x03f7, - 0x03f9, 0x03fa, - 0x0400, 0x042f, - 0x0460, 0x0460, - 0x0462, 0x0462, - 0x0464, 0x0464, - 0x0466, 0x0466, - 0x0468, 0x0468, - 0x046a, 0x046a, - 0x046c, 0x046c, - 0x046e, 0x046e, - 0x0470, 0x0470, - 0x0472, 0x0472, - 0x0474, 0x0474, - 0x0476, 0x0476, - 0x0478, 0x0478, - 0x047a, 0x047a, - 0x047c, 0x047c, - 0x047e, 0x047e, - 0x0480, 0x0480, - 0x048a, 0x048a, - 0x048c, 0x048c, - 0x048e, 0x048e, - 0x0490, 0x0490, - 0x0492, 0x0492, - 0x0494, 0x0494, - 0x0496, 0x0496, - 0x0498, 0x0498, - 0x049a, 0x049a, - 0x049c, 0x049c, - 0x049e, 0x049e, - 0x04a0, 0x04a0, - 0x04a2, 0x04a2, - 0x04a4, 0x04a4, - 0x04a6, 0x04a6, - 0x04a8, 0x04a8, - 0x04aa, 0x04aa, - 0x04ac, 0x04ac, - 0x04ae, 0x04ae, - 0x04b0, 0x04b0, - 0x04b2, 0x04b2, - 0x04b4, 0x04b4, - 0x04b6, 0x04b6, - 0x04b8, 0x04b8, - 0x04ba, 0x04ba, - 0x04bc, 0x04bc, - 0x04be, 0x04be, - 0x04c0, 0x04c1, - 0x04c3, 0x04c3, - 0x04c5, 0x04c5, - 0x04c7, 0x04c7, - 0x04c9, 0x04c9, - 0x04cb, 0x04cb, - 0x04cd, 0x04cd, - 0x04d0, 0x04d0, - 0x04d2, 0x04d2, - 0x04d4, 0x04d4, - 0x04d6, 0x04d6, - 0x04d8, 0x04d8, - 0x04da, 0x04da, - 0x04dc, 0x04dc, - 0x04de, 0x04de, - 0x04e0, 0x04e0, - 0x04e2, 0x04e2, - 0x04e4, 0x04e4, - 0x04e6, 0x04e6, - 0x04e8, 0x04e8, - 0x04ea, 0x04ea, - 0x04ec, 0x04ec, - 0x04ee, 0x04ee, - 0x04f0, 0x04f0, - 0x04f2, 0x04f2, - 0x04f4, 0x04f4, - 0x04f8, 0x04f8, - 0x0500, 0x0500, - 0x0502, 0x0502, - 0x0504, 0x0504, - 0x0506, 0x0506, - 0x0508, 0x0508, - 0x050a, 0x050a, - 0x050c, 0x050c, - 0x050e, 0x050e, - 0x0531, 0x0556, - 0x10a0, 0x10c5, - 0x1e00, 0x1e00, - 0x1e02, 0x1e02, - 0x1e04, 0x1e04, - 0x1e06, 0x1e06, - 0x1e08, 0x1e08, - 0x1e0a, 0x1e0a, - 0x1e0c, 0x1e0c, - 0x1e0e, 0x1e0e, - 0x1e10, 0x1e10, - 0x1e12, 0x1e12, - 0x1e14, 0x1e14, - 0x1e16, 0x1e16, - 0x1e18, 0x1e18, - 0x1e1a, 0x1e1a, - 0x1e1c, 0x1e1c, - 0x1e1e, 0x1e1e, - 0x1e20, 0x1e20, - 0x1e22, 0x1e22, - 0x1e24, 0x1e24, - 0x1e26, 0x1e26, - 0x1e28, 0x1e28, - 0x1e2a, 0x1e2a, - 0x1e2c, 0x1e2c, - 0x1e2e, 0x1e2e, - 0x1e30, 0x1e30, - 0x1e32, 0x1e32, - 0x1e34, 0x1e34, - 0x1e36, 0x1e36, - 0x1e38, 0x1e38, - 0x1e3a, 0x1e3a, - 0x1e3c, 0x1e3c, - 0x1e3e, 0x1e3e, - 0x1e40, 0x1e40, - 0x1e42, 0x1e42, - 0x1e44, 0x1e44, - 0x1e46, 0x1e46, - 0x1e48, 0x1e48, - 0x1e4a, 0x1e4a, - 0x1e4c, 0x1e4c, - 0x1e4e, 0x1e4e, - 0x1e50, 0x1e50, - 0x1e52, 0x1e52, - 0x1e54, 0x1e54, - 0x1e56, 0x1e56, - 0x1e58, 0x1e58, - 0x1e5a, 0x1e5a, - 0x1e5c, 0x1e5c, - 0x1e5e, 0x1e5e, - 0x1e60, 0x1e60, - 0x1e62, 0x1e62, - 0x1e64, 0x1e64, - 0x1e66, 0x1e66, - 0x1e68, 0x1e68, - 0x1e6a, 0x1e6a, - 0x1e6c, 0x1e6c, - 0x1e6e, 0x1e6e, - 0x1e70, 0x1e70, - 0x1e72, 0x1e72, - 0x1e74, 0x1e74, - 0x1e76, 0x1e76, - 0x1e78, 0x1e78, - 0x1e7a, 0x1e7a, - 0x1e7c, 0x1e7c, - 0x1e7e, 0x1e7e, - 0x1e80, 0x1e80, - 0x1e82, 0x1e82, - 0x1e84, 0x1e84, - 0x1e86, 0x1e86, - 0x1e88, 0x1e88, - 0x1e8a, 0x1e8a, - 0x1e8c, 0x1e8c, - 0x1e8e, 0x1e8e, - 0x1e90, 0x1e90, - 0x1e92, 0x1e92, - 0x1e94, 0x1e94, - 0x1ea0, 0x1ea0, - 0x1ea2, 0x1ea2, - 0x1ea4, 0x1ea4, - 0x1ea6, 0x1ea6, - 0x1ea8, 0x1ea8, - 0x1eaa, 0x1eaa, - 0x1eac, 0x1eac, - 0x1eae, 0x1eae, - 0x1eb0, 0x1eb0, - 0x1eb2, 0x1eb2, - 0x1eb4, 0x1eb4, - 0x1eb6, 0x1eb6, - 0x1eb8, 0x1eb8, - 0x1eba, 0x1eba, - 0x1ebc, 0x1ebc, - 0x1ebe, 0x1ebe, - 0x1ec0, 0x1ec0, - 0x1ec2, 0x1ec2, - 0x1ec4, 0x1ec4, - 0x1ec6, 0x1ec6, - 0x1ec8, 0x1ec8, - 0x1eca, 0x1eca, - 0x1ecc, 0x1ecc, - 0x1ece, 0x1ece, - 0x1ed0, 0x1ed0, - 0x1ed2, 0x1ed2, - 0x1ed4, 0x1ed4, - 0x1ed6, 0x1ed6, - 0x1ed8, 0x1ed8, - 0x1eda, 0x1eda, - 0x1edc, 0x1edc, - 0x1ede, 0x1ede, - 0x1ee0, 0x1ee0, - 0x1ee2, 0x1ee2, - 0x1ee4, 0x1ee4, - 0x1ee6, 0x1ee6, - 0x1ee8, 0x1ee8, - 0x1eea, 0x1eea, - 0x1eec, 0x1eec, - 0x1eee, 0x1eee, - 0x1ef0, 0x1ef0, - 0x1ef2, 0x1ef2, - 0x1ef4, 0x1ef4, - 0x1ef6, 0x1ef6, - 0x1ef8, 0x1ef8, - 0x1f08, 0x1f0f, - 0x1f18, 0x1f1d, - 0x1f28, 0x1f2f, - 0x1f38, 0x1f3f, - 0x1f48, 0x1f4d, - 0x1f59, 0x1f59, - 0x1f5b, 0x1f5b, - 0x1f5d, 0x1f5d, - 0x1f5f, 0x1f5f, - 0x1f68, 0x1f6f, - 0x1fb8, 0x1fbb, - 0x1fc8, 0x1fcb, - 0x1fd8, 0x1fdb, - 0x1fe8, 0x1fec, - 0x1ff8, 0x1ffb, - 0x2102, 0x2102, - 0x2107, 0x2107, - 0x210b, 0x210d, - 0x2110, 0x2112, - 0x2115, 0x2115, - 0x2119, 0x211d, - 0x2124, 0x2124, - 0x2126, 0x2126, - 0x2128, 0x2128, - 0x212a, 0x212d, - 0x2130, 0x2131, - 0x2133, 0x2133, - 0x213e, 0x213f, - 0x2145, 0x2145, - 0xff21, 0xff3a, - 0x10400, 0x10427, - 0x1d400, 0x1d419, - 0x1d434, 0x1d44d, - 0x1d468, 0x1d481, - 0x1d49c, 0x1d49c, - 0x1d49e, 0x1d49f, - 0x1d4a2, 0x1d4a2, - 0x1d4a5, 0x1d4a6, - 0x1d4a9, 0x1d4ac, - 0x1d4ae, 0x1d4b5, - 0x1d4d0, 0x1d4e9, - 0x1d504, 0x1d505, - 0x1d507, 0x1d50a, - 0x1d50d, 0x1d514, - 0x1d516, 0x1d51c, - 0x1d538, 0x1d539, - 0x1d53b, 0x1d53e, - 0x1d540, 0x1d544, - 0x1d546, 0x1d546, - 0x1d54a, 0x1d550, - 0x1d56c, 0x1d585, - 0x1d5a0, 0x1d5b9, - 0x1d5d4, 0x1d5ed, - 0x1d608, 0x1d621, - 0x1d63c, 0x1d655, - 0x1d670, 0x1d689, - 0x1d6a8, 0x1d6c0, - 0x1d6e2, 0x1d6fa, - 0x1d71c, 0x1d734, - 0x1d756, 0x1d76e, - 0x1d790, 0x1d7a8 -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBUpper */ - -static const OnigCodePoint SBXDigit[] = { - 3, - 0x0030, 0x0039, - 0x0041, 0x0046, - 0x0061, 0x0066 -}; - -static const OnigCodePoint SBASCII[] = { - 1, - 0x0000, 0x007f -}; - -static const OnigCodePoint SBWord[] = { - 4, - 0x0030, 0x0039, - 0x0041, 0x005a, - 0x005f, 0x005f, - 0x0061, 0x007a -}; - -static const OnigCodePoint MBWord[] = { -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - 432, -#else - 8, -#endif - 0x00aa, 0x00aa, - 0x00b2, 0x00b3, - 0x00b5, 0x00b5, - 0x00b9, 0x00ba, - 0x00bc, 0x00be, - 0x00c0, 0x00d6, - 0x00d8, 0x00f6, -#ifndef USE_UNICODE_FULL_RANGE_CTYPE - 0x00f8, 0x7fffffff -#else /* not USE_UNICODE_FULL_RANGE_CTYPE */ - 0x00f8, 0x0236, - 0x0250, 0x02c1, - 0x02c6, 0x02d1, - 0x02e0, 0x02e4, - 0x02ee, 0x02ee, - 0x0300, 0x0357, - 0x035d, 0x036f, - 0x037a, 0x037a, - 0x0386, 0x0386, - 0x0388, 0x038a, - 0x038c, 0x038c, - 0x038e, 0x03a1, - 0x03a3, 0x03ce, - 0x03d0, 0x03f5, - 0x03f7, 0x03fb, - 0x0400, 0x0481, - 0x0483, 0x0486, - 0x0488, 0x04ce, - 0x04d0, 0x04f5, - 0x04f8, 0x04f9, - 0x0500, 0x050f, - 0x0531, 0x0556, - 0x0559, 0x0559, - 0x0561, 0x0587, - 0x0591, 0x05a1, - 0x05a3, 0x05b9, - 0x05bb, 0x05bd, - 0x05bf, 0x05bf, - 0x05c1, 0x05c2, - 0x05c4, 0x05c4, - 0x05d0, 0x05ea, - 0x05f0, 0x05f2, - 0x0610, 0x0615, - 0x0621, 0x063a, - 0x0640, 0x0658, - 0x0660, 0x0669, - 0x066e, 0x06d3, - 0x06d5, 0x06dc, - 0x06de, 0x06e8, - 0x06ea, 0x06fc, - 0x06ff, 0x06ff, - 0x0710, 0x074a, - 0x074d, 0x074f, - 0x0780, 0x07b1, - 0x0901, 0x0939, - 0x093c, 0x094d, - 0x0950, 0x0954, - 0x0958, 0x0963, - 0x0966, 0x096f, - 0x0981, 0x0983, - 0x0985, 0x098c, - 0x098f, 0x0990, - 0x0993, 0x09a8, - 0x09aa, 0x09b0, - 0x09b2, 0x09b2, - 0x09b6, 0x09b9, - 0x09bc, 0x09c4, - 0x09c7, 0x09c8, - 0x09cb, 0x09cd, - 0x09d7, 0x09d7, - 0x09dc, 0x09dd, - 0x09df, 0x09e3, - 0x09e6, 0x09f1, - 0x09f4, 0x09f9, - 0x0a01, 0x0a03, - 0x0a05, 0x0a0a, - 0x0a0f, 0x0a10, - 0x0a13, 0x0a28, - 0x0a2a, 0x0a30, - 0x0a32, 0x0a33, - 0x0a35, 0x0a36, - 0x0a38, 0x0a39, - 0x0a3c, 0x0a3c, - 0x0a3e, 0x0a42, - 0x0a47, 0x0a48, - 0x0a4b, 0x0a4d, - 0x0a59, 0x0a5c, - 0x0a5e, 0x0a5e, - 0x0a66, 0x0a74, - 0x0a81, 0x0a83, - 0x0a85, 0x0a8d, - 0x0a8f, 0x0a91, - 0x0a93, 0x0aa8, - 0x0aaa, 0x0ab0, - 0x0ab2, 0x0ab3, - 0x0ab5, 0x0ab9, - 0x0abc, 0x0ac5, - 0x0ac7, 0x0ac9, - 0x0acb, 0x0acd, - 0x0ad0, 0x0ad0, - 0x0ae0, 0x0ae3, - 0x0ae6, 0x0aef, - 0x0b01, 0x0b03, - 0x0b05, 0x0b0c, - 0x0b0f, 0x0b10, - 0x0b13, 0x0b28, - 0x0b2a, 0x0b30, - 0x0b32, 0x0b33, - 0x0b35, 0x0b39, - 0x0b3c, 0x0b43, - 0x0b47, 0x0b48, - 0x0b4b, 0x0b4d, - 0x0b56, 0x0b57, - 0x0b5c, 0x0b5d, - 0x0b5f, 0x0b61, - 0x0b66, 0x0b6f, - 0x0b71, 0x0b71, - 0x0b82, 0x0b83, - 0x0b85, 0x0b8a, - 0x0b8e, 0x0b90, - 0x0b92, 0x0b95, - 0x0b99, 0x0b9a, - 0x0b9c, 0x0b9c, - 0x0b9e, 0x0b9f, - 0x0ba3, 0x0ba4, - 0x0ba8, 0x0baa, - 0x0bae, 0x0bb5, - 0x0bb7, 0x0bb9, - 0x0bbe, 0x0bc2, - 0x0bc6, 0x0bc8, - 0x0bca, 0x0bcd, - 0x0bd7, 0x0bd7, - 0x0be7, 0x0bf2, - 0x0c01, 0x0c03, - 0x0c05, 0x0c0c, - 0x0c0e, 0x0c10, - 0x0c12, 0x0c28, - 0x0c2a, 0x0c33, - 0x0c35, 0x0c39, - 0x0c3e, 0x0c44, - 0x0c46, 0x0c48, - 0x0c4a, 0x0c4d, - 0x0c55, 0x0c56, - 0x0c60, 0x0c61, - 0x0c66, 0x0c6f, - 0x0c82, 0x0c83, - 0x0c85, 0x0c8c, - 0x0c8e, 0x0c90, - 0x0c92, 0x0ca8, - 0x0caa, 0x0cb3, - 0x0cb5, 0x0cb9, - 0x0cbc, 0x0cc4, - 0x0cc6, 0x0cc8, - 0x0cca, 0x0ccd, - 0x0cd5, 0x0cd6, - 0x0cde, 0x0cde, - 0x0ce0, 0x0ce1, - 0x0ce6, 0x0cef, - 0x0d02, 0x0d03, - 0x0d05, 0x0d0c, - 0x0d0e, 0x0d10, - 0x0d12, 0x0d28, - 0x0d2a, 0x0d39, - 0x0d3e, 0x0d43, - 0x0d46, 0x0d48, - 0x0d4a, 0x0d4d, - 0x0d57, 0x0d57, - 0x0d60, 0x0d61, - 0x0d66, 0x0d6f, - 0x0d82, 0x0d83, - 0x0d85, 0x0d96, - 0x0d9a, 0x0db1, - 0x0db3, 0x0dbb, - 0x0dbd, 0x0dbd, - 0x0dc0, 0x0dc6, - 0x0dca, 0x0dca, - 0x0dcf, 0x0dd4, - 0x0dd6, 0x0dd6, - 0x0dd8, 0x0ddf, - 0x0df2, 0x0df3, - 0x0e01, 0x0e3a, - 0x0e40, 0x0e4e, - 0x0e50, 0x0e59, - 0x0e81, 0x0e82, - 0x0e84, 0x0e84, - 0x0e87, 0x0e88, - 0x0e8a, 0x0e8a, - 0x0e8d, 0x0e8d, - 0x0e94, 0x0e97, - 0x0e99, 0x0e9f, - 0x0ea1, 0x0ea3, - 0x0ea5, 0x0ea5, - 0x0ea7, 0x0ea7, - 0x0eaa, 0x0eab, - 0x0ead, 0x0eb9, - 0x0ebb, 0x0ebd, - 0x0ec0, 0x0ec4, - 0x0ec6, 0x0ec6, - 0x0ec8, 0x0ecd, - 0x0ed0, 0x0ed9, - 0x0edc, 0x0edd, - 0x0f00, 0x0f00, - 0x0f18, 0x0f19, - 0x0f20, 0x0f33, - 0x0f35, 0x0f35, - 0x0f37, 0x0f37, - 0x0f39, 0x0f39, - 0x0f3e, 0x0f47, - 0x0f49, 0x0f6a, - 0x0f71, 0x0f84, - 0x0f86, 0x0f8b, - 0x0f90, 0x0f97, - 0x0f99, 0x0fbc, - 0x0fc6, 0x0fc6, - 0x1000, 0x1021, - 0x1023, 0x1027, - 0x1029, 0x102a, - 0x102c, 0x1032, - 0x1036, 0x1039, - 0x1040, 0x1049, - 0x1050, 0x1059, - 0x10a0, 0x10c5, - 0x10d0, 0x10f8, - 0x1100, 0x1159, - 0x115f, 0x11a2, - 0x11a8, 0x11f9, - 0x1200, 0x1206, - 0x1208, 0x1246, - 0x1248, 0x1248, - 0x124a, 0x124d, - 0x1250, 0x1256, - 0x1258, 0x1258, - 0x125a, 0x125d, - 0x1260, 0x1286, - 0x1288, 0x1288, - 0x128a, 0x128d, - 0x1290, 0x12ae, - 0x12b0, 0x12b0, - 0x12b2, 0x12b5, - 0x12b8, 0x12be, - 0x12c0, 0x12c0, - 0x12c2, 0x12c5, - 0x12c8, 0x12ce, - 0x12d0, 0x12d6, - 0x12d8, 0x12ee, - 0x12f0, 0x130e, - 0x1310, 0x1310, - 0x1312, 0x1315, - 0x1318, 0x131e, - 0x1320, 0x1346, - 0x1348, 0x135a, - 0x1369, 0x137c, - 0x13a0, 0x13f4, - 0x1401, 0x166c, - 0x166f, 0x1676, - 0x1681, 0x169a, - 0x16a0, 0x16ea, - 0x16ee, 0x16f0, - 0x1700, 0x170c, - 0x170e, 0x1714, - 0x1720, 0x1734, - 0x1740, 0x1753, - 0x1760, 0x176c, - 0x176e, 0x1770, - 0x1772, 0x1773, - 0x1780, 0x17b3, - 0x17b6, 0x17d3, - 0x17d7, 0x17d7, - 0x17dc, 0x17dd, - 0x17e0, 0x17e9, - 0x17f0, 0x17f9, - 0x180b, 0x180d, - 0x1810, 0x1819, - 0x1820, 0x1877, - 0x1880, 0x18a9, - 0x1900, 0x191c, - 0x1920, 0x192b, - 0x1930, 0x193b, - 0x1946, 0x196d, - 0x1970, 0x1974, - 0x1d00, 0x1d6b, - 0x1e00, 0x1e9b, - 0x1ea0, 0x1ef9, - 0x1f00, 0x1f15, - 0x1f18, 0x1f1d, - 0x1f20, 0x1f45, - 0x1f48, 0x1f4d, - 0x1f50, 0x1f57, - 0x1f59, 0x1f59, - 0x1f5b, 0x1f5b, - 0x1f5d, 0x1f5d, - 0x1f5f, 0x1f7d, - 0x1f80, 0x1fb4, - 0x1fb6, 0x1fbc, - 0x1fbe, 0x1fbe, - 0x1fc2, 0x1fc4, - 0x1fc6, 0x1fcc, - 0x1fd0, 0x1fd3, - 0x1fd6, 0x1fdb, - 0x1fe0, 0x1fec, - 0x1ff2, 0x1ff4, - 0x1ff6, 0x1ffc, - 0x203f, 0x2040, - 0x2054, 0x2054, - 0x2070, 0x2071, - 0x2074, 0x2079, - 0x207f, 0x2089, - 0x20d0, 0x20ea, - 0x2102, 0x2102, - 0x2107, 0x2107, - 0x210a, 0x2113, - 0x2115, 0x2115, - 0x2119, 0x211d, - 0x2124, 0x2124, - 0x2126, 0x2126, - 0x2128, 0x2128, - 0x212a, 0x212d, - 0x212f, 0x2131, - 0x2133, 0x2139, - 0x213d, 0x213f, - 0x2145, 0x2149, - 0x2153, 0x2183, - 0x2460, 0x249b, - 0x24ea, 0x24ff, - 0x2776, 0x2793, - 0x3005, 0x3007, - 0x3021, 0x302f, - 0x3031, 0x3035, - 0x3038, 0x303c, - 0x3041, 0x3096, - 0x3099, 0x309a, - 0x309d, 0x309f, - 0x30a1, 0x30ff, - 0x3105, 0x312c, - 0x3131, 0x318e, - 0x3192, 0x3195, - 0x31a0, 0x31b7, - 0x31f0, 0x31ff, - 0x3220, 0x3229, - 0x3251, 0x325f, - 0x3280, 0x3289, - 0x32b1, 0x32bf, - 0x3400, 0x4db5, - 0x4e00, 0x9fa5, - 0xa000, 0xa48c, - 0xac00, 0xd7a3, - 0xf900, 0xfa2d, - 0xfa30, 0xfa6a, - 0xfb00, 0xfb06, - 0xfb13, 0xfb17, - 0xfb1d, 0xfb28, - 0xfb2a, 0xfb36, - 0xfb38, 0xfb3c, - 0xfb3e, 0xfb3e, - 0xfb40, 0xfb41, - 0xfb43, 0xfb44, - 0xfb46, 0xfbb1, - 0xfbd3, 0xfd3d, - 0xfd50, 0xfd8f, - 0xfd92, 0xfdc7, - 0xfdf0, 0xfdfb, - 0xfe00, 0xfe0f, - 0xfe20, 0xfe23, - 0xfe33, 0xfe34, - 0xfe4d, 0xfe4f, - 0xfe70, 0xfe74, - 0xfe76, 0xfefc, - 0xff10, 0xff19, - 0xff21, 0xff3a, - 0xff3f, 0xff3f, - 0xff41, 0xff5a, - 0xff65, 0xffbe, - 0xffc2, 0xffc7, - 0xffca, 0xffcf, - 0xffd2, 0xffd7, - 0xffda, 0xffdc, - 0x10000, 0x1000b, - 0x1000d, 0x10026, - 0x10028, 0x1003a, - 0x1003c, 0x1003d, - 0x1003f, 0x1004d, - 0x10050, 0x1005d, - 0x10080, 0x100fa, - 0x10107, 0x10133, - 0x10300, 0x1031e, - 0x10320, 0x10323, - 0x10330, 0x1034a, - 0x10380, 0x1039d, - 0x10400, 0x1049d, - 0x104a0, 0x104a9, - 0x10800, 0x10805, - 0x10808, 0x10808, - 0x1080a, 0x10835, - 0x10837, 0x10838, - 0x1083c, 0x1083c, - 0x1083f, 0x1083f, - 0x1d165, 0x1d169, - 0x1d16d, 0x1d172, - 0x1d17b, 0x1d182, - 0x1d185, 0x1d18b, - 0x1d1aa, 0x1d1ad, - 0x1d400, 0x1d454, - 0x1d456, 0x1d49c, - 0x1d49e, 0x1d49f, - 0x1d4a2, 0x1d4a2, - 0x1d4a5, 0x1d4a6, - 0x1d4a9, 0x1d4ac, - 0x1d4ae, 0x1d4b9, - 0x1d4bb, 0x1d4bb, - 0x1d4bd, 0x1d4c3, - 0x1d4c5, 0x1d505, - 0x1d507, 0x1d50a, - 0x1d50d, 0x1d514, - 0x1d516, 0x1d51c, - 0x1d51e, 0x1d539, - 0x1d53b, 0x1d53e, - 0x1d540, 0x1d544, - 0x1d546, 0x1d546, - 0x1d54a, 0x1d550, - 0x1d552, 0x1d6a3, - 0x1d6a8, 0x1d6c0, - 0x1d6c2, 0x1d6da, - 0x1d6dc, 0x1d6fa, - 0x1d6fc, 0x1d714, - 0x1d716, 0x1d734, - 0x1d736, 0x1d74e, - 0x1d750, 0x1d76e, - 0x1d770, 0x1d788, - 0x1d78a, 0x1d7a8, - 0x1d7aa, 0x1d7c2, - 0x1d7c4, 0x1d7c9, - 0x1d7ce, 0x1d7ff, - 0x20000, 0x2a6d6, - 0x2f800, 0x2fa1d, - 0xe0100, 0xe01ef -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ -}; /* end of MBWord */ static int -utf8_get_ctype_code_range(int ctype, - const OnigCodePoint* sbr[], const OnigCodePoint* mbr[]) +get_ctype_code_range(OnigCtype ctype, OnigCodePoint *sb_out, + const OnigCodePoint* ranges[]) { -#define CR_SET(sbl,mbl) do { \ - *sbr = sbl; \ - *mbr = mbl; \ -} while (0) - -#define CR_SB_SET(sbl) do { \ - *sbr = sbl; \ - *mbr = EmptyRange; \ -} while (0) - - switch (ctype) { - case ONIGENC_CTYPE_ALPHA: - CR_SET(SBAlpha, MBAlpha); - break; - case ONIGENC_CTYPE_BLANK: - CR_SET(SBBlank, MBBlank); - break; - case ONIGENC_CTYPE_CNTRL: - CR_SET(SBCntrl, MBCntrl); - break; - case ONIGENC_CTYPE_DIGIT: - CR_SET(SBDigit, MBDigit); - break; - case ONIGENC_CTYPE_GRAPH: - CR_SET(SBGraph, MBGraph); - break; - case ONIGENC_CTYPE_LOWER: - CR_SET(SBLower, MBLower); - break; - case ONIGENC_CTYPE_PRINT: - CR_SET(SBPrint, MBPrint); - break; - case ONIGENC_CTYPE_PUNCT: - CR_SET(SBPunct, MBPunct); - break; - case ONIGENC_CTYPE_SPACE: - CR_SET(SBSpace, MBSpace); - break; - case ONIGENC_CTYPE_UPPER: - CR_SET(SBUpper, MBUpper); - break; - case ONIGENC_CTYPE_XDIGIT: - CR_SB_SET(SBXDigit); - break; - case ONIGENC_CTYPE_WORD: - CR_SET(SBWord, MBWord); - break; - case ONIGENC_CTYPE_ASCII: - CR_SB_SET(SBASCII); - break; - case ONIGENC_CTYPE_ALNUM: - CR_SET(SBAlnum, MBAlnum); - break; - - default: - return ONIGENCERR_TYPE_BUG; - break; - } - - return 0; + *sb_out = 0x80; + return onigenc_unicode_ctype_code_range(ctype, ranges); } -static int -utf8_is_code_ctype(OnigCodePoint code, unsigned int ctype) -{ -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - const OnigCodePoint *range; -#endif - - if (code < 256) { - return ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(code, ctype); - } - -#ifdef USE_UNICODE_FULL_RANGE_CTYPE - - switch (ctype) { - case ONIGENC_CTYPE_ALPHA: - range = MBAlpha; - break; - case ONIGENC_CTYPE_BLANK: - range = MBBlank; - break; - case ONIGENC_CTYPE_CNTRL: - range = MBCntrl; - break; - case ONIGENC_CTYPE_DIGIT: - range = MBDigit; - break; - case ONIGENC_CTYPE_GRAPH: - range = MBGraph; - break; - case ONIGENC_CTYPE_LOWER: - range = MBLower; - break; - case ONIGENC_CTYPE_PRINT: - range = MBPrint; - break; - case ONIGENC_CTYPE_PUNCT: - range = MBPunct; - break; - case ONIGENC_CTYPE_SPACE: - range = MBSpace; - break; - case ONIGENC_CTYPE_UPPER: - range = MBUpper; - break; - case ONIGENC_CTYPE_XDIGIT: - return FALSE; - break; - case ONIGENC_CTYPE_WORD: - range = MBWord; - break; - case ONIGENC_CTYPE_ASCII: - return FALSE; - break; - case ONIGENC_CTYPE_ALNUM: - range = MBAlnum; - break; - case ONIGENC_CTYPE_NEWLINE: - return FALSE; - break; - - default: - return ONIGENCERR_TYPE_BUG; - break; - } - - return onig_is_in_code_range((UChar* )range, code); - -#else - - if ((ctype & ONIGENC_CTYPE_WORD) != 0) { -#ifdef USE_INVALID_CODE_SCHEME - if (code <= VALID_CODE_LIMIT) -#endif - return TRUE; - } -#endif /* USE_UNICODE_FULL_RANGE_CTYPE */ - - return FALSE; -} static UChar* -utf8_left_adjust_char_head(const UChar* start, const UChar* s) +left_adjust_char_head(const UChar* start, const UChar* s) { const UChar *p; @@ -3700,31 +277,29 @@ utf8_left_adjust_char_head(const UChar* start, const UChar* s) return (UChar* )p; } +static int +get_case_fold_codes_by_str(OnigCaseFoldType flag, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF8, + flag, p, end, items); +} + OnigEncodingType OnigEncodingUTF8 = { - utf8_mbc_enc_len, + mbc_enc_len, "UTF-8", /* name */ 6, /* max byte length */ 1, /* min byte length */ - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ), - { - (OnigCodePoint )'\\' /* esc */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ - , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ - }, - utf8_is_mbc_newline, - utf8_mbc_to_code, - utf8_code_to_mbclen, - utf8_code_to_mbc, - utf8_mbc_to_normalize, - utf8_is_mbc_ambiguous, - onigenc_iso_8859_1_get_all_pair_ambig_codes, - onigenc_ess_tsett_get_all_comp_ambig_codes, - utf8_is_code_ctype, - utf8_get_ctype_code_range, - utf8_left_adjust_char_head, + is_mbc_newline, + mbc_to_code, + code_to_mbclen, + code_to_mbc, + mbc_case_fold, + onigenc_unicode_apply_all_case_fold, + get_case_fold_codes_by_str, + onigenc_unicode_property_name_to_ctype, + onigenc_unicode_is_code_ctype, + get_ctype_code_range, + left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match }; diff --git a/ext/mbstring/oniguruma/index.html b/ext/mbstring/oniguruma/index.html index d55f1cc94f724..af3426ce32892 100755 --- a/ext/mbstring/oniguruma/index.html +++ b/ext/mbstring/oniguruma/index.html @@ -8,7 +8,7 @@

Oniguruma

(Japanese)

-(c) K.Kosako, updated at: 2007/08/16 +(c) K.Kosako, updated at: 2010/01/09

@@ -16,8 +16,8 @@

Oniguruma

(Japanese)
What's new
    +
  • 2010/01/09: Version 5.9.2 released.
  • 2007/08/16: Version 4.7.1 released.
  • -
  • 2007/07/14: Version 5.9.0 released.
  • 2007/06/20: Version 2.5.9 released.
  • 2007/06/20: Maintainer of 2.x was changed.
@@ -62,9 +62,8 @@

Oniguruma

(Japanese)
Download:
- -
-Back to Home diff --git a/ext/mbstring/oniguruma/index_ja.html b/ext/mbstring/oniguruma/index_ja.html new file mode 100644 index 0000000000000..e03b045b98778 --- /dev/null +++ b/ext/mbstring/oniguruma/index_ja.html @@ -0,0 +1,190 @@ + + + + 鬼車 + + + +

鬼車

+ +

+(c) K.Kosako, 最終更新: 2010/01/09 +

+ +
+ +
更新情報 + +
    +
  • 2010/01/09: Version 5.9.2 リリース
  • +
  • 2007/08/16: Version 4.7.1 リリース
  • +
  • 2007/06/20: Version 2.5.9 リリース
  • +
  • 2007/06/20: 2.xの保守担当者を変更
  • +
+
+
+ +

+鬼車は正規表現ライブラリである。
+このライブラリの特徴は、それぞれの正規表現オブジェクトごとに異なる文字エンコーディングを +指定できること。
+(API: GNU regex, POSIX and Oniguruma native) +

+ +
+
対応している文字エンコーディング:
+ASCII, UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE,
+EUC-JP, EUC-TW, EUC-KR, EUC-CN,
+Shift_JIS, Big5, GB18030, KOI8-R, CP1251,
+ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5,
+ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10,
+ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16
+ +(GB18030は、KUBO Takehiro氏提供)
+(CP1251は、Byte氏提供) +
+

+
+ +
+ +
ライセンス:BSDライセンス + +
+
プラットフォーム: +
    +
  • Unix (Mac OS Xを含む) +
  • Cygwin +
  • Win32 +
+ +
+ +
ダウンロード: + + +
+ +2.xの保守担当は、Hannes Wyss <hwyss AT ywesee.com>に交替しました。
+2.xについては、彼に連絡してください。
+
+* 5.xはUnicode Property/Scriptを提供
+* 2.xはRuby1.6/1.8組込みライブラリとして動作する。 (2006年末で保守を終了)
+ +
+
ドキュメント: (version 5.9.2) + + +
+
サンプルプログラム: + + +
+
サイト: + + +
+
リンク: + + +
+
参考資料: + + +
+
+

+and I'm thankful to Akinori MUSHA. +

+ +
+
+
他のライブラリ: + +
+ +
+ホームにもどる + + diff --git a/ext/mbstring/oniguruma/onigposix.h b/ext/mbstring/oniguruma/onigposix.h index cfeb88a2928e7..f1cb35fbd8783 100644 --- a/ext/mbstring/oniguruma/onigposix.h +++ b/ext/mbstring/oniguruma/onigposix.h @@ -97,7 +97,7 @@ typedef struct { #ifndef ONIG_EXTERN #if defined(_WIN32) && !defined(__GNUC__) -#if defined(EXPORT) || defined(RUBY_EXPORT) +#if defined(EXPORT) #define ONIG_EXTERN extern __declspec(dllexport) #else #define ONIG_EXTERN extern __declspec(dllimport) diff --git a/ext/mbstring/oniguruma/oniguruma.h b/ext/mbstring/oniguruma/oniguruma.h index 5196a3d585d8a..3b557639f1dae 100644 --- a/ext/mbstring/oniguruma/oniguruma.h +++ b/ext/mbstring/oniguruma/oniguruma.h @@ -4,7 +4,7 @@ oniguruma.h - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2007 K.Kosako + * Copyright (c) 2002-2009 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,16 +29,14 @@ * SUCH DAMAGE. */ -#include "../php_onig_compat.h" - #ifdef __cplusplus extern "C" { #endif #define ONIGURUMA -#define ONIGURUMA_VERSION_MAJOR 4 -#define ONIGURUMA_VERSION_MINOR 7 -#define ONIGURUMA_VERSION_TEENY 1 +#define ONIGURUMA_VERSION_MAJOR 5 +#define ONIGURUMA_VERSION_MINOR 9 +#define ONIGURUMA_VERSION_TEENY 2 #ifdef __cplusplus # ifndef HAVE_PROTOTYPES @@ -56,6 +54,12 @@ extern "C" { # endif #endif +#ifdef HAVE_STDARG_H +# ifndef HAVE_STDARG_PROTOTYPES +# define HAVE_STDARG_PROTOTYPES 1 +# endif +#endif + #ifndef P_ #if defined(__STDC__) || defined(_WIN32) # define P_(args) args @@ -94,28 +98,27 @@ extern "C" { typedef unsigned char OnigUChar; typedef unsigned long OnigCodePoint; +typedef unsigned int OnigCtype; typedef unsigned int OnigDistance; #define ONIG_INFINITE_DISTANCE ~((OnigDistance )0) -/* ambiguous match flag */ -typedef unsigned int OnigAmbigType; +typedef unsigned int OnigCaseFoldType; /* case fold flag */ -ONIG_EXTERN OnigAmbigType OnigDefaultAmbigFlag; +ONIG_EXTERN OnigCaseFoldType OnigDefaultCaseFoldFlag; -#define ONIGENC_AMBIGUOUS_MATCH_NONE 0 -#define ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE (1<<0) -#define ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE (1<<1) +/* #define ONIGENC_CASE_FOLD_HIRAGANA_KATAKANA (1<<1) */ +/* #define ONIGENC_CASE_FOLD_KATAKANA_WIDTH (1<<2) */ +#define ONIGENC_CASE_FOLD_TURKISH_AZERI (1<<20) +#define INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR (1<<30) -#define ONIGENC_AMBIGUOUS_MATCH_LIMIT (1<<1) +#define ONIGENC_CASE_FOLD_MIN INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR +#define ONIGENC_CASE_FOLD_DEFAULT OnigDefaultCaseFoldFlag -#define ONIGENC_AMBIGUOUS_MATCH_FULL \ - ( ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE ) -#define ONIGENC_AMBIGUOUS_MATCH_DEFAULT OnigDefaultAmbigFlag - -#define ONIGENC_MAX_COMP_AMBIG_CODE_LEN 3 -#define ONIGENC_MAX_COMP_AMBIG_CODE_ITEM_NUM 4 +#define ONIGENC_MAX_COMP_CASE_FOLD_CODE_LEN 3 +#define ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM 13 +/* 13 => Unicode:0x1ffc */ /* code range */ #define ONIGENC_CODE_RANGE_NUM(range) ((int )range[0]) @@ -123,20 +126,10 @@ ONIG_EXTERN OnigAmbigType OnigDefaultAmbigFlag; #define ONIGENC_CODE_RANGE_TO(range,i) range[((i)*2) + 2] typedef struct { - int len; - OnigCodePoint code[ONIGENC_MAX_COMP_AMBIG_CODE_LEN]; -} OnigCompAmbigCodeItem; - -typedef struct { - int n; - OnigCodePoint code; - OnigCompAmbigCodeItem items[ONIGENC_MAX_COMP_AMBIG_CODE_ITEM_NUM]; -} OnigCompAmbigCodes; - -typedef struct { - OnigCodePoint from; - OnigCodePoint to; -} OnigPairAmbigCodes; + int byte_len; /* argument(original) character(s) byte length */ + int code_len; /* number of code */ + OnigCodePoint code[ONIGENC_MAX_COMP_CASE_FOLD_CODE_LEN]; +} OnigCaseFoldCodeItem; typedef struct { OnigCodePoint esc; @@ -146,32 +139,24 @@ typedef struct { OnigCodePoint one_or_more_time; OnigCodePoint anychar_anytime; } OnigMetaCharTableType; + +typedef int (*OnigApplyAllCaseFoldFunc)(OnigCodePoint from, OnigCodePoint* to, int to_len, void* arg); - -#if defined(RUBY_PLATFORM) && defined(M17N_H) - -#define ONIG_RUBY_M17N -typedef m17n_encoding* OnigEncoding; - -#else - -typedef struct { +typedef struct OnigEncodingTypeST { int (*mbc_enc_len)(const OnigUChar* p); const char* name; int max_enc_len; int min_enc_len; - OnigAmbigType support_ambig_flag; - OnigMetaCharTableType meta_char_table; int (*is_mbc_newline)(const OnigUChar* p, const OnigUChar* end); OnigCodePoint (*mbc_to_code)(const OnigUChar* p, const OnigUChar* end); int (*code_to_mbclen)(OnigCodePoint code); int (*code_to_mbc)(OnigCodePoint code, OnigUChar *buf); - int (*mbc_to_normalize)(OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to); - int (*is_mbc_ambiguous)(OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end); - int (*get_all_pair_ambig_codes)(OnigAmbigType flag, const OnigPairAmbigCodes** acs); - int (*get_all_comp_ambig_codes)(OnigAmbigType flag, const OnigCompAmbigCodes** acs); - int (*is_code_ctype)(OnigCodePoint code, unsigned int ctype); - int (*get_ctype_code_range)(int ctype, const OnigCodePoint* sb_range[], const OnigCodePoint* mb_range[]); + int (*mbc_case_fold)(OnigCaseFoldType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to); + int (*apply_all_case_fold)(OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg); + int (*get_case_fold_codes_by_str)(OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem acs[]); + int (*property_name_to_ctype)(struct OnigEncodingTypeST* enc, OnigUChar* p, OnigUChar* end); + int (*is_code_ctype)(OnigCodePoint code, OnigCtype ctype); + int (*get_ctype_code_range)(OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[]); OnigUChar* (*left_adjust_char_head)(const OnigUChar* start, const OnigUChar* p); int (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end); } OnigEncodingType; @@ -206,6 +191,7 @@ ONIG_EXTERN OnigEncodingType OnigEncodingEUC_CN; ONIG_EXTERN OnigEncodingType OnigEncodingSJIS; ONIG_EXTERN OnigEncodingType OnigEncodingKOI8; ONIG_EXTERN OnigEncodingType OnigEncodingKOI8_R; +ONIG_EXTERN OnigEncodingType OnigEncodingCP1251; ONIG_EXTERN OnigEncodingType OnigEncodingBIG5; ONIG_EXTERN OnigEncodingType OnigEncodingGB18030; @@ -237,136 +223,60 @@ ONIG_EXTERN OnigEncodingType OnigEncodingGB18030; #define ONIG_ENCODING_SJIS (&OnigEncodingSJIS) #define ONIG_ENCODING_KOI8 (&OnigEncodingKOI8) #define ONIG_ENCODING_KOI8_R (&OnigEncodingKOI8_R) +#define ONIG_ENCODING_CP1251 (&OnigEncodingCP1251) #define ONIG_ENCODING_BIG5 (&OnigEncodingBIG5) #define ONIG_ENCODING_GB18030 (&OnigEncodingGB18030) -#endif /* else RUBY && M17N */ - #define ONIG_ENCODING_UNDEF ((OnigEncoding )0) /* work size */ -#define ONIGENC_CODE_TO_MBC_MAXLEN 7 -#define ONIGENC_MBC_NORMALIZE_MAXLEN ONIGENC_CODE_TO_MBC_MAXLEN +#define ONIGENC_CODE_TO_MBC_MAXLEN 7 +#define ONIGENC_MBC_CASE_FOLD_MAXLEN 18 +/* 18: 6(max-byte) * 3(case-fold chars) */ /* character types */ -#define ONIGENC_CTYPE_NEWLINE (1<< 0) -#define ONIGENC_CTYPE_ALPHA (1<< 1) -#define ONIGENC_CTYPE_BLANK (1<< 2) -#define ONIGENC_CTYPE_CNTRL (1<< 3) -#define ONIGENC_CTYPE_DIGIT (1<< 4) -#define ONIGENC_CTYPE_GRAPH (1<< 5) -#define ONIGENC_CTYPE_LOWER (1<< 6) -#define ONIGENC_CTYPE_PRINT (1<< 7) -#define ONIGENC_CTYPE_PUNCT (1<< 8) -#define ONIGENC_CTYPE_SPACE (1<< 9) -#define ONIGENC_CTYPE_UPPER (1<<10) -#define ONIGENC_CTYPE_XDIGIT (1<<11) -#define ONIGENC_CTYPE_WORD (1<<12) -#define ONIGENC_CTYPE_ASCII (1<<13) -#define ONIGENC_CTYPE_ALNUM (ONIGENC_CTYPE_ALPHA | ONIGENC_CTYPE_DIGIT) - -#define enc_len(enc,p) ONIGENC_MBC_ENC_LEN(enc, p) +#define ONIGENC_CTYPE_NEWLINE 0 +#define ONIGENC_CTYPE_ALPHA 1 +#define ONIGENC_CTYPE_BLANK 2 +#define ONIGENC_CTYPE_CNTRL 3 +#define ONIGENC_CTYPE_DIGIT 4 +#define ONIGENC_CTYPE_GRAPH 5 +#define ONIGENC_CTYPE_LOWER 6 +#define ONIGENC_CTYPE_PRINT 7 +#define ONIGENC_CTYPE_PUNCT 8 +#define ONIGENC_CTYPE_SPACE 9 +#define ONIGENC_CTYPE_UPPER 10 +#define ONIGENC_CTYPE_XDIGIT 11 +#define ONIGENC_CTYPE_WORD 12 +#define ONIGENC_CTYPE_ALNUM 13 /* alpha || digit */ +#define ONIGENC_CTYPE_ASCII 14 +#define ONIGENC_MAX_STD_CTYPE ONIGENC_CTYPE_ASCII + + +#define onig_enc_len(enc,p,end) ONIGENC_MBC_ENC_LEN(enc,p) #define ONIGENC_IS_UNDEF(enc) ((enc) == ONIG_ENCODING_UNDEF) #define ONIGENC_IS_SINGLEBYTE(enc) (ONIGENC_MBC_MAXLEN(enc) == 1) #define ONIGENC_IS_MBC_HEAD(enc,p) (ONIGENC_MBC_ENC_LEN(enc,p) != 1) #define ONIGENC_IS_MBC_ASCII(p) (*(p) < 128) #define ONIGENC_IS_CODE_ASCII(code) ((code) < 128) -#define ONIGENC_IS_CODE_SB_WORD(enc,code) \ - (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code)) #define ONIGENC_IS_MBC_WORD(enc,s,end) \ ONIGENC_IS_CODE_WORD(enc,ONIGENC_MBC_TO_CODE(enc,s,end)) -#ifdef ONIG_RUBY_M17N - -#include /* for isblank(), isgraph() */ - -#define ONIGENC_MBC_TO_NORMALIZE(enc,flag,pp,end,buf) \ - onigenc_mbc_to_normalize(enc,flag,pp,end,buf) -#define ONIGENC_IS_MBC_AMBIGUOUS(enc,flag,pp,end) \ - onigenc_is_mbc_ambiguous(enc,flag,pp,end) - -#define ONIGENC_SUPPORT_AMBIG_FLAG(enc) ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE -#define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc,s,end) \ - onigenc_is_allowed_reverse_match(enc, s, end) -#define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,start,s) \ - onigenc_get_left_adjust_char_head(enc, start, s) -#define ONIGENC_GET_ALL_PAIR_AMBIG_CODES(enc, ambig_flag, acs) 0 -#define ONIGENC_GET_ALL_COMP_AMBIG_CODES(enc, ambig_flag, acs) 0 -#define ONIGENC_GET_CTYPE_CODE_RANGE(enc,ctype,sbr,mbr) \ - ONIG_NO_SUPPORT_CONFIG -#define ONIGENC_MBC_ENC_LEN(enc,p) m17n_mbclen(enc,(int )(*p)) -#define ONIGENC_MBC_MAXLEN(enc) m17n_mbmaxlen(enc) -#define ONIGENC_MBC_MAXLEN_DIST(enc) \ - (ONIGENC_MBC_MAXLEN(enc) > 0 ? ONIGENC_MBC_MAXLEN(enc) \ - : ONIG_INFINITE_DISTANCE) -#define ONIGENC_MBC_MINLEN(enc) 1 -#define ONIGENC_MBC_TO_CODE(enc,p,e) m17n_codepoint((enc),(p),(e)) -#define ONIGENC_CODE_TO_MBCLEN(enc,code) m17n_codelen((enc),(code)) -#define ONIGENC_CODE_TO_MBC(enc,code,buf) onigenc_code_to_mbc(enc, code, buf) - -#if 0 /* !! not supported !! */ -#define ONIGENC_IS_MBC_NEWLINE(enc,p,end) -#define ONIGENC_STEP_BACK(enc,start,s,n) -#endif - -#define ONIGENC_IS_CODE_CTYPE(enc,code,ctype) \ - onigenc_is_code_ctype(enc,code,ctype) - -#ifdef isblank -# define ONIGENC_IS_CODE_BLANK(enc,code) isblank((int )code) -#else -# define ONIGENC_IS_CODE_BLANK(enc,code) ((code) == ' ' || (code) == '\t') -#endif -#ifdef isgraph -# define ONIGENC_IS_CODE_GRAPH(enc,code) isgraph((int )code) -#else -# define ONIGENC_IS_CODE_GRAPH(enc,code) \ - (isprint((int )code) && !isspace((int )code)) -#endif - -#define ONIGENC_IS_CODE_PRINT(enc,code) m17n_isprint(enc,code) -#define ONIGENC_IS_CODE_ALNUM(enc,code) m17n_isalnum(enc,code) -#define ONIGENC_IS_CODE_ALPHA(enc,code) m17n_isalpha(enc,code) -#define ONIGENC_IS_CODE_LOWER(enc,code) m17n_islower(enc,code) -#define ONIGENC_IS_CODE_UPPER(enc,code) m17n_isupper(enc,code) -#define ONIGENC_IS_CODE_CNTRL(enc,code) m17n_iscntrl(enc,code) -#define ONIGENC_IS_CODE_PUNCT(enc,code) m17n_ispunct(enc,code) -#define ONIGENC_IS_CODE_SPACE(enc,code) m17n_isspace(enc,code) -#define ONIGENC_IS_CODE_DIGIT(enc,code) m17n_isdigit(enc,code) -#define ONIGENC_IS_CODE_XDIGIT(enc,code) m17n_isxdigit(enc,code) -#define ONIGENC_IS_CODE_WORD(enc,code) m17n_iswchar(enc,code) - -ONIG_EXTERN -int onigenc_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, int ctype)); -ONIG_EXTERN -int onigenc_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, OnigUChar *buf)); -ONIG_EXTERN -int onigenc_mbc_to_normalize P_((OnigEncoding enc, OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* buf)); -ONIG_EXTERN -int onigenc_is_mbc_ambiguous P_((OnigEncoding enc, OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end)); -ONIG_EXTERN -int onigenc_is_allowed_reverse_match P_((OnigEncoding enc, const OnigUChar* s, const OnigUChar* end)); - -#else /* ONIG_RUBY_M17N */ - #define ONIGENC_NAME(enc) ((enc)->name) -#define ONIGENC_MBC_TO_NORMALIZE(enc,flag,pp,end,buf) \ - (enc)->mbc_to_normalize(flag,(const OnigUChar** )pp,end,buf) -#define ONIGENC_IS_MBC_AMBIGUOUS(enc,flag,pp,end) \ - (enc)->is_mbc_ambiguous(flag,(const OnigUChar** )pp,end) -#define ONIGENC_SUPPORT_AMBIG_FLAG(enc) ((enc)->support_ambig_flag) +#define ONIGENC_MBC_CASE_FOLD(enc,flag,pp,end,buf) \ + (enc)->mbc_case_fold(flag,(const OnigUChar** )pp,end,buf) #define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc,s,end) \ (enc)->is_allowed_reverse_match(s,end) #define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,start,s) \ (enc)->left_adjust_char_head(start, s) -#define ONIGENC_GET_ALL_PAIR_AMBIG_CODES(enc,ambig_flag,acs) \ - (enc)->get_all_pair_ambig_codes(ambig_flag,acs) -#define ONIGENC_GET_ALL_COMP_AMBIG_CODES(enc,ambig_flag,acs) \ - (enc)->get_all_comp_ambig_codes(ambig_flag,acs) +#define ONIGENC_APPLY_ALL_CASE_FOLD(enc,case_fold_flag,f,arg) \ + (enc)->apply_all_case_fold(case_fold_flag,f,arg) +#define ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc,case_fold_flag,p,end,acs) \ + (enc)->get_case_fold_codes_by_str(case_fold_flag,p,end,acs) #define ONIGENC_STEP_BACK(enc,start,s,n) \ onigenc_step_back((enc),(start),(s),(n)) @@ -378,6 +288,8 @@ int onigenc_is_allowed_reverse_match P_((OnigEncoding enc, const OnigUChar* s, c #define ONIGENC_MBC_TO_CODE(enc,p,end) (enc)->mbc_to_code((p),(end)) #define ONIGENC_CODE_TO_MBCLEN(enc,code) (enc)->code_to_mbclen(code) #define ONIGENC_CODE_TO_MBC(enc,code,buf) (enc)->code_to_mbc(code,buf) +#define ONIGENC_PROPERTY_NAME_TO_CTYPE(enc,p,end) \ + (enc)->property_name_to_ctype(enc,p,end) #define ONIGENC_IS_CODE_CTYPE(enc,code,ctype) (enc)->is_code_ctype(code,ctype) @@ -410,14 +322,12 @@ int onigenc_is_allowed_reverse_match P_((OnigEncoding enc, const OnigUChar* s, c #define ONIGENC_IS_CODE_WORD(enc,code) \ ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_WORD) -#define ONIGENC_GET_CTYPE_CODE_RANGE(enc,ctype,sbr,mbr) \ - (enc)->get_ctype_code_range(ctype,sbr,mbr) +#define ONIGENC_GET_CTYPE_CODE_RANGE(enc,ctype,sbout,ranges) \ + (enc)->get_ctype_code_range(ctype,sbout,ranges) ONIG_EXTERN OnigUChar* onigenc_step_back P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, int n)); -#endif /* is not ONIG_RUBY_M17N */ - /* encoding API */ ONIG_EXTERN @@ -482,10 +392,11 @@ typedef unsigned int OnigOptionType; /* syntax */ typedef struct { - unsigned int op; - unsigned int op2; - unsigned int behavior; - OnigOptionType options; /* default option */ + unsigned int op; + unsigned int op2; + unsigned int behavior; + OnigOptionType options; /* default option */ + OnigMetaCharTableType meta_char_table; } OnigSyntaxType; ONIG_EXTERN OnigSyntaxType OnigSyntaxASIS; @@ -566,7 +477,7 @@ ONIG_EXTERN OnigSyntaxType* OnigDefaultSyntax; #define ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR (1U<<15) /* \`, \' */ #define ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY (1U<<16) /* \p{...}, \P{...} */ #define ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT (1U<<17) /* \p{^..}, \P{^..} */ -#define ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS (1U<<18) /* \p{IsXDigit} */ +/* #define ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS (1U<<18) */ #define ONIG_SYN_OP2_ESC_H_XDIGIT (1U<<19) /* \h, \H */ #define ONIG_SYN_OP2_INEFFECTIVE_ESCAPE (1U<<20) /* \ */ @@ -666,6 +577,7 @@ ONIG_EXTERN OnigSyntaxType* OnigDefaultSyntax; #define ONIGERR_NEVER_ENDING_RECURSION -221 #define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY -222 #define ONIGERR_INVALID_CHAR_PROPERTY_NAME -223 +#define ONIGERR_INVALID_CODE_POINT_VALUE -400 #define ONIGERR_INVALID_WIDE_CHAR_VALUE -400 #define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE -401 #define ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION -402 @@ -755,10 +667,10 @@ typedef struct re_pattern_buffer { int repeat_range_alloc; OnigRepeatRange* repeat_range; - OnigEncoding enc; + OnigEncoding enc; OnigOptionType options; OnigSyntaxType* syntax; - OnigAmbigType ambig_flag; + OnigCaseFoldType case_fold_flag; void* name_table; /* optimization info (string search, char-map and anchors) */ @@ -793,7 +705,7 @@ typedef struct { OnigEncoding target_enc; OnigSyntaxType* syntax; OnigOptionType option; - OnigAmbigType ambig_flag; + OnigCaseFoldType case_fold_flag; } OnigCompileInfo; /* Oniguruma Native API */ @@ -808,10 +720,15 @@ void onig_set_verb_warn_func P_((OnigWarnFunc f)); ONIG_EXTERN int onig_new P_((OnigRegex*, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo)); ONIG_EXTERN +int onig_reg_init P_((regex_t* reg, OnigOptionType option, OnigCaseFoldType case_fold_flag, OnigEncoding enc, OnigSyntaxType* syntax)); +int onig_new_without_alloc P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo)); +ONIG_EXTERN int onig_new_deluxe P_((OnigRegex* reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo)); ONIG_EXTERN void onig_free P_((OnigRegex)); ONIG_EXTERN +void onig_free_body P_((OnigRegex)); +ONIG_EXTERN int onig_recompile P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo)); ONIG_EXTERN int onig_recompile_deluxe P_((OnigRegex reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo)); @@ -856,7 +773,7 @@ OnigEncoding onig_get_encoding P_((OnigRegex reg)); ONIG_EXTERN OnigOptionType onig_get_options P_((OnigRegex reg)); ONIG_EXTERN -OnigAmbigType onig_get_ambig_flag P_((OnigRegex reg)); +OnigCaseFoldType onig_get_case_fold_flag P_((OnigRegex reg)); ONIG_EXTERN OnigSyntaxType* onig_get_syntax P_((OnigRegex reg)); ONIG_EXTERN @@ -880,13 +797,13 @@ void onig_set_syntax_behavior P_((OnigSyntaxType* syntax, unsigned int behavior) ONIG_EXTERN void onig_set_syntax_options P_((OnigSyntaxType* syntax, OnigOptionType options)); ONIG_EXTERN -int onig_set_meta_char P_((OnigEncoding enc, unsigned int what, OnigCodePoint code)); +int onig_set_meta_char P_((OnigSyntaxType* syntax, unsigned int what, OnigCodePoint code)); ONIG_EXTERN void onig_copy_encoding P_((OnigEncoding to, OnigEncoding from)); ONIG_EXTERN -OnigAmbigType onig_get_default_ambig_flag P_((void)); +OnigCaseFoldType onig_get_default_case_fold_flag P_((void)); ONIG_EXTERN -int onig_set_default_ambig_flag P_((OnigAmbigType ambig_flag)); +int onig_set_default_case_fold_flag P_((OnigCaseFoldType case_fold_flag)); ONIG_EXTERN unsigned int onig_get_match_stack_limit_size P_((void)); ONIG_EXTERN diff --git a/ext/mbstring/oniguruma/regcomp.c b/ext/mbstring/oniguruma/regcomp.c index 6a0976dee225a..f9d99563b3897 100644 --- a/ext/mbstring/oniguruma/regcomp.c +++ b/ext/mbstring/oniguruma/regcomp.c @@ -2,7 +2,7 @@ regcomp.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2007 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,26 +29,28 @@ #include "regparse.h" -OnigAmbigType OnigDefaultAmbigFlag = - (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE | - ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE); +OnigCaseFoldType OnigDefaultCaseFoldFlag = ONIGENC_CASE_FOLD_MIN; -extern OnigAmbigType -onig_get_default_ambig_flag(void) +extern OnigCaseFoldType +onig_get_default_case_fold_flag(void) { - return OnigDefaultAmbigFlag; + return OnigDefaultCaseFoldFlag; } extern int -onig_set_default_ambig_flag(OnigAmbigType ambig_flag) +onig_set_default_case_fold_flag(OnigCaseFoldType case_fold_flag) { - OnigDefaultAmbigFlag = ambig_flag; + OnigDefaultCaseFoldFlag = case_fold_flag; return 0; } +#ifndef PLATFORM_UNALIGNED_WORD_ACCESS +static unsigned char PadBuf[WORD_ALIGNMENT_SIZE]; +#endif + static UChar* -k_strdup(UChar* s, UChar* end) +str_dup(UChar* s, UChar* end) { int len = end - s; @@ -62,15 +64,29 @@ k_strdup(UChar* s, UChar* end) else return NULL; } -/* - Caution: node should not be a string node. - (s and end member address break) -*/ static void swap_node(Node* a, Node* b) { Node c; c = *a; *a = *b; *b = c; + + if (NTYPE(a) == NT_STR) { + StrNode* sn = NSTR(a); + if (sn->capa == 0) { + int len = sn->end - sn->s; + sn->s = sn->buf; + sn->end = sn->s + len; + } + } + + if (NTYPE(b) == NT_STR) { + StrNode* sn = NSTR(b); + if (sn->capa == 0) { + int len = sn->end - sn->s; + sn->s = sn->buf; + sn->end = sn->s + len; + } + } } static OnigDistance @@ -99,7 +115,7 @@ static int bitset_is_empty(BitSetRef bs) { int i; - for (i = 0; i < BITSET_SIZE; i++) { + for (i = 0; i < (int )BITSET_SIZE; i++) { if (bs[i] != 0) return 0; } return 1; @@ -122,8 +138,14 @@ bitset_on_num(BitSetRef bs) extern int onig_bbuf_init(BBuf* buf, int size) { - buf->p = (UChar* )xmalloc(size); - if (IS_NULL(buf->p)) return(ONIGERR_MEMORY); + if (size <= 0) { + size = 0; + buf->p = NULL; + } + else { + buf->p = (UChar* )xmalloc(size); + if (IS_NULL(buf->p)) return(ONIGERR_MEMORY); + } buf->alloc = size; buf->used = 0; @@ -139,7 +161,7 @@ unset_addr_list_init(UnsetAddrList* uslist, int size) UnsetAddr* p; p = (UnsetAddr* )xmalloc(sizeof(UnsetAddr)* size); - CHECK_NULL_RETURN_VAL(p, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(p); uslist->num = 0; uslist->alloc = size; uslist->us = p; @@ -162,7 +184,7 @@ unset_addr_list_add(UnsetAddrList* uslist, int offset, struct _Node* node) if (uslist->num >= uslist->alloc) { size = uslist->alloc * 2; p = (UnsetAddr* )xrealloc(uslist->us, sizeof(UnsetAddr) * size); - CHECK_NULL_RETURN_VAL(p, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(p); uslist->alloc = size; uslist->us = p; } @@ -394,8 +416,8 @@ compile_tree_n_times(Node* node, int n, regex_t* reg) } static int -add_compile_string_length(UChar* s, int mb_len, int str_len, - regex_t* reg, int ignore_case) +add_compile_string_length(UChar* s ARG_UNUSED, int mb_len, int str_len, + regex_t* reg ARG_UNUSED, int ignore_case) { int len; int op = select_str_opcode(mb_len, str_len, ignore_case); @@ -440,20 +462,20 @@ compile_length_string_node(Node* node, regex_t* reg) UChar *p, *prev; StrNode* sn; - sn = &(NSTRING(node)); + sn = NSTR(node); if (sn->end <= sn->s) return 0; ambig = NSTRING_IS_AMBIG(node); p = prev = sn->s; - prev_len = enc_len(enc, p); + prev_len = enclen(enc, p); p += prev_len; slen = 1; rlen = 0; for (; p < sn->end; ) { - len = enc_len(enc, p); + len = enclen(enc, p); if (len == prev_len) { slen++; } @@ -488,7 +510,7 @@ compile_string_node(Node* node, regex_t* reg) UChar *p, *prev, *end; StrNode* sn; - sn = &(NSTRING(node)); + sn = NSTR(node); if (sn->end <= sn->s) return 0; @@ -496,12 +518,12 @@ compile_string_node(Node* node, regex_t* reg) ambig = NSTRING_IS_AMBIG(node); p = prev = sn->s; - prev_len = enc_len(enc, p); + prev_len = enclen(enc, p); p += prev_len; slen = 1; for (; p < end; ) { - len = enc_len(enc, p); + len = enclen(enc, p); if (len == prev_len) { slen++; } @@ -535,8 +557,6 @@ add_multi_byte_cclass(BBuf* mbuf, regex_t* reg) add_length(reg, mbuf->used); return add_bytes(reg, mbuf->p, mbuf->used); #else - static unsigned char PadBuf[WORD_ALIGNMENT_SIZE]; - int r, pad_size; UChar* p = BBUF_GET_ADD_ADDRESS(reg) + SIZE_LENGTH; @@ -558,7 +578,7 @@ compile_length_cclass_node(CClassNode* cc, regex_t* reg) { int len; - if (IS_CCLASS_SHARE(cc)) { + if (IS_NCCLASS_SHARE(cc)) { len = SIZE_OPCODE + SIZE_POINTER; return len; } @@ -588,14 +608,14 @@ compile_cclass_node(CClassNode* cc, regex_t* reg) { int r; - if (IS_CCLASS_SHARE(cc)) { + if (IS_NCCLASS_SHARE(cc)) { add_opcode(reg, OP_CCLASS_NODE); r = add_pointer(reg, cc); return r; } if (IS_NULL(cc->mbuf)) { - if (IS_CCLASS_NOT(cc)) + if (IS_NCCLASS_NOT(cc)) add_opcode(reg, OP_CCLASS_NOT); else add_opcode(reg, OP_CCLASS); @@ -604,7 +624,7 @@ compile_cclass_node(CClassNode* cc, regex_t* reg) } else { if (ONIGENC_MBC_MINLEN(reg->enc) > 1 || bitset_is_empty(cc->bs)) { - if (IS_CCLASS_NOT(cc)) + if (IS_NCCLASS_NOT(cc)) add_opcode(reg, OP_CCLASS_MB_NOT); else add_opcode(reg, OP_CCLASS_MB); @@ -612,7 +632,7 @@ compile_cclass_node(CClassNode* cc, regex_t* reg) r = add_multi_byte_cclass(cc->mbuf, reg); } else { - if (IS_CCLASS_NOT(cc)) + if (IS_NCCLASS_NOT(cc)) add_opcode(reg, OP_CCLASS_MIX_NOT); else add_opcode(reg, OP_CCLASS_MIX); @@ -635,7 +655,7 @@ entry_repeat_range(regex_t* reg, int id, int lower, int upper) if (reg->repeat_range_alloc == 0) { p = (OnigRepeatRange* )xmalloc(sizeof(OnigRepeatRange) * REPEAT_RANGE_ALLOC); - CHECK_NULL_RETURN_VAL(p, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(p); reg->repeat_range = p; reg->repeat_range_alloc = REPEAT_RANGE_ALLOC; } @@ -644,7 +664,7 @@ entry_repeat_range(regex_t* reg, int id, int lower, int upper) n = reg->repeat_range_alloc + REPEAT_RANGE_ALLOC; p = (OnigRepeatRange* )xrealloc(reg->repeat_range, sizeof(OnigRepeatRange) * n); - CHECK_NULL_RETURN_VAL(p, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(p); reg->repeat_range = p; reg->repeat_range_alloc = n; } @@ -658,7 +678,7 @@ entry_repeat_range(regex_t* reg, int id, int lower, int upper) } static int -compile_range_repeat_node(QuantifierNode* qn, int target_len, int empty_info, +compile_range_repeat_node(QtfrNode* qn, int target_len, int empty_info, regex_t* reg) { int r; @@ -694,10 +714,10 @@ compile_range_repeat_node(QuantifierNode* qn, int target_len, int empty_info, } static int -is_anychar_star_quantifier(QuantifierNode* qn) +is_anychar_star_quantifier(QtfrNode* qn) { if (qn->greedy && IS_REPEAT_INFINITE(qn->upper) && - NTYPE(qn->target) == N_ANYCHAR) + NTYPE(qn->target) == NT_CANY) return 1; else return 0; @@ -709,7 +729,7 @@ is_anychar_star_quantifier(QuantifierNode* qn) #ifdef USE_COMBINATION_EXPLOSION_CHECK static int -compile_length_quantifier_node(QuantifierNode* qn, regex_t* reg) +compile_length_quantifier_node(QtfrNode* qn, regex_t* reg) { int len, mod_tlen, cklen; int ckn; @@ -724,7 +744,7 @@ compile_length_quantifier_node(QuantifierNode* qn, regex_t* reg) cklen = (CKN_ON ? SIZE_STATE_CHECK_NUM: 0); /* anychar repeat */ - if (NTYPE(qn->target) == N_ANYCHAR) { + if (NTYPE(qn->target) == NT_CANY) { if (qn->greedy && infinite) { if (IS_NOT_NULL(qn->next_head_exact) && !CKN_ON) return SIZE_OP_ANYCHAR_STAR_PEEK_NEXT + tlen * qn->lower + cklen; @@ -789,7 +809,7 @@ compile_length_quantifier_node(QuantifierNode* qn, regex_t* reg) } static int -compile_quantifier_node(QuantifierNode* qn, regex_t* reg) +compile_quantifier_node(QtfrNode* qn, regex_t* reg) { int r, mod_tlen; int ckn; @@ -815,7 +835,7 @@ compile_quantifier_node(QuantifierNode* qn, regex_t* reg) if (r) return r; } - return add_bytes(reg, NSTRING(qn->next_head_exact).s, 1); + return add_bytes(reg, NSTR(qn->next_head_exact)->s, 1); } else { if (IS_MULTILINE(reg->options)) { @@ -943,7 +963,7 @@ compile_quantifier_node(QuantifierNode* qn, regex_t* reg) #else /* USE_COMBINATION_EXPLOSION_CHECK */ static int -compile_length_quantifier_node(QuantifierNode* qn, regex_t* reg) +compile_length_quantifier_node(QtfrNode* qn, regex_t* reg) { int len, mod_tlen; int infinite = IS_REPEAT_INFINITE(qn->upper); @@ -953,7 +973,7 @@ compile_length_quantifier_node(QuantifierNode* qn, regex_t* reg) if (tlen < 0) return tlen; /* anychar repeat */ - if (NTYPE(qn->target) == N_ANYCHAR) { + if (NTYPE(qn->target) == NT_CANY) { if (qn->greedy && infinite) { if (IS_NOT_NULL(qn->next_head_exact)) return SIZE_OP_ANYCHAR_STAR_PEEK_NEXT + tlen * qn->lower; @@ -1008,7 +1028,7 @@ compile_length_quantifier_node(QuantifierNode* qn, regex_t* reg) } static int -compile_quantifier_node(QuantifierNode* qn, regex_t* reg) +compile_quantifier_node(QtfrNode* qn, regex_t* reg) { int i, r, mod_tlen; int infinite = IS_REPEAT_INFINITE(qn->upper); @@ -1026,7 +1046,7 @@ compile_quantifier_node(QuantifierNode* qn, regex_t* reg) else r = add_opcode(reg, OP_ANYCHAR_STAR_PEEK_NEXT); if (r) return r; - return add_bytes(reg, NSTRING(qn->next_head_exact).s, 1); + return add_bytes(reg, NSTR(qn->next_head_exact)->s, 1); } else { if (IS_MULTILINE(reg->options)) @@ -1067,7 +1087,7 @@ compile_quantifier_node(QuantifierNode* qn, regex_t* reg) r = add_opcode_rel_addr(reg, OP_PUSH_OR_JUMP_EXACT1, mod_tlen + SIZE_OP_JUMP); if (r) return r; - add_bytes(reg, NSTRING(qn->head_exact).s, 1); + add_bytes(reg, NSTR(qn->head_exact)->s, 1); r = compile_tree_empty_check(qn->target, reg, empty_info); if (r) return r; r = add_opcode_rel_addr(reg, OP_JUMP, @@ -1077,7 +1097,7 @@ compile_quantifier_node(QuantifierNode* qn, regex_t* reg) r = add_opcode_rel_addr(reg, OP_PUSH_IF_PEEK_NEXT, mod_tlen + SIZE_OP_JUMP); if (r) return r; - add_bytes(reg, NSTRING(qn->next_head_exact).s, 1); + add_bytes(reg, NSTR(qn->next_head_exact)->s, 1); r = compile_tree_empty_check(qn->target, reg, empty_info); if (r) return r; r = add_opcode_rel_addr(reg, OP_JUMP, @@ -1136,7 +1156,7 @@ compile_quantifier_node(QuantifierNode* qn, regex_t* reg) #endif /* USE_COMBINATION_EXPLOSION_CHECK */ static int -compile_length_option_node(EffectNode* node, regex_t* reg) +compile_length_option_node(EncloseNode* node, regex_t* reg) { int tlen; OnigOptionType prev = reg->options; @@ -1156,7 +1176,7 @@ compile_length_option_node(EffectNode* node, regex_t* reg) } static int -compile_option_node(EffectNode* node, regex_t* reg) +compile_option_node(EncloseNode* node, regex_t* reg) { int r; OnigOptionType prev = reg->options; @@ -1182,12 +1202,12 @@ compile_option_node(EffectNode* node, regex_t* reg) } static int -compile_length_effect_node(EffectNode* node, regex_t* reg) +compile_length_enclose_node(EncloseNode* node, regex_t* reg) { int len; int tlen; - if (node->type == EFFECT_OPTION) + if (node->type == ENCLOSE_OPTION) return compile_length_option_node(node, reg); if (node->target) { @@ -1198,16 +1218,16 @@ compile_length_effect_node(EffectNode* node, regex_t* reg) tlen = 0; switch (node->type) { - case EFFECT_MEMORY: + case ENCLOSE_MEMORY: #ifdef USE_SUBEXP_CALL - if (IS_EFFECT_CALLED(node)) { + if (IS_ENCLOSE_CALLED(node)) { len = SIZE_OP_MEMORY_START_PUSH + tlen + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN; if (BIT_STATUS_AT(reg->bt_mem_end, node->regnum)) - len += (IS_EFFECT_RECURSION(node) + len += (IS_ENCLOSE_RECURSION(node) ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_PUSH); else - len += (IS_EFFECT_RECURSION(node) + len += (IS_ENCLOSE_RECURSION(node) ? SIZE_OP_MEMORY_END_REC : SIZE_OP_MEMORY_END); } else @@ -1223,9 +1243,9 @@ compile_length_effect_node(EffectNode* node, regex_t* reg) } break; - case EFFECT_STOP_BACKTRACK: - if (IS_EFFECT_STOP_BT_SIMPLE_REPEAT(node)) { - QuantifierNode* qn = &NQUANTIFIER(node->target); + case ENCLOSE_STOP_BACKTRACK: + if (IS_ENCLOSE_STOP_BT_SIMPLE_REPEAT(node)) { + QtfrNode* qn = NQTFR(node->target); tlen = compile_length_tree(qn->target, reg); if (tlen < 0) return tlen; @@ -1248,17 +1268,17 @@ compile_length_effect_node(EffectNode* node, regex_t* reg) static int get_char_length_tree(Node* node, regex_t* reg, int* len); static int -compile_effect_node(EffectNode* node, regex_t* reg) +compile_enclose_node(EncloseNode* node, regex_t* reg) { int r, len; - if (node->type == EFFECT_OPTION) + if (node->type == ENCLOSE_OPTION) return compile_option_node(node, reg); switch (node->type) { - case EFFECT_MEMORY: + case ENCLOSE_MEMORY: #ifdef USE_SUBEXP_CALL - if (IS_EFFECT_CALLED(node)) { + if (IS_ENCLOSE_CALLED(node)) { r = add_opcode(reg, OP_CALL); if (r) return r; node->call_addr = BBUF_GET_OFFSET_POS(reg) + SIZE_ABSADDR + SIZE_OP_JUMP; @@ -1268,10 +1288,10 @@ compile_effect_node(EffectNode* node, regex_t* reg) len = compile_length_tree(node->target, reg); len += (SIZE_OP_MEMORY_START_PUSH + SIZE_OP_RETURN); if (BIT_STATUS_AT(reg->bt_mem_end, node->regnum)) - len += (IS_EFFECT_RECURSION(node) + len += (IS_ENCLOSE_RECURSION(node) ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_PUSH); else - len += (IS_EFFECT_RECURSION(node) + len += (IS_ENCLOSE_RECURSION(node) ? SIZE_OP_MEMORY_END_REC : SIZE_OP_MEMORY_END); r = add_opcode_rel_addr(reg, OP_JUMP, len); @@ -1288,12 +1308,12 @@ compile_effect_node(EffectNode* node, regex_t* reg) r = compile_tree(node->target, reg); if (r) return r; #ifdef USE_SUBEXP_CALL - if (IS_EFFECT_CALLED(node)) { + if (IS_ENCLOSE_CALLED(node)) { if (BIT_STATUS_AT(reg->bt_mem_end, node->regnum)) - r = add_opcode(reg, (IS_EFFECT_RECURSION(node) + r = add_opcode(reg, (IS_ENCLOSE_RECURSION(node) ? OP_MEMORY_END_PUSH_REC : OP_MEMORY_END_PUSH)); else - r = add_opcode(reg, (IS_EFFECT_RECURSION(node) + r = add_opcode(reg, (IS_ENCLOSE_RECURSION(node) ? OP_MEMORY_END_REC : OP_MEMORY_END)); if (r) return r; @@ -1313,9 +1333,9 @@ compile_effect_node(EffectNode* node, regex_t* reg) } break; - case EFFECT_STOP_BACKTRACK: - if (IS_EFFECT_STOP_BT_SIMPLE_REPEAT(node)) { - QuantifierNode* qn = &NQUANTIFIER(node->target); + case ENCLOSE_STOP_BACKTRACK: + if (IS_ENCLOSE_STOP_BT_SIMPLE_REPEAT(node)) { + QtfrNode* qn = NQTFR(node->target); r = compile_tree_n_times(qn->target, qn->lower, reg); if (r) return r; @@ -1472,50 +1492,50 @@ compile_length_tree(Node* node, regex_t* reg) type = NTYPE(node); switch (type) { - case N_LIST: + case NT_LIST: len = 0; do { - r = compile_length_tree(NCONS(node).left, reg); + r = compile_length_tree(NCAR(node), reg); if (r < 0) return r; len += r; - } while (IS_NOT_NULL(node = NCONS(node).right)); + } while (IS_NOT_NULL(node = NCDR(node))); r = len; break; - case N_ALT: + case NT_ALT: { int n; n = r = 0; do { - r += compile_length_tree(NCONS(node).left, reg); + r += compile_length_tree(NCAR(node), reg); n++; - } while (IS_NOT_NULL(node = NCONS(node).right)); + } while (IS_NOT_NULL(node = NCDR(node))); r += (SIZE_OP_PUSH + SIZE_OP_JUMP) * (n - 1); } break; - case N_STRING: + case NT_STR: if (NSTRING_IS_RAW(node)) - r = compile_length_string_raw_node(&(NSTRING(node)), reg); + r = compile_length_string_raw_node(NSTR(node), reg); else r = compile_length_string_node(node, reg); break; - case N_CCLASS: - r = compile_length_cclass_node(&(NCCLASS(node)), reg); + case NT_CCLASS: + r = compile_length_cclass_node(NCCLASS(node), reg); break; - case N_CTYPE: - case N_ANYCHAR: + case NT_CTYPE: + case NT_CANY: r = SIZE_OPCODE; break; - case N_BACKREF: + case NT_BREF: { - BackrefNode* br = &(NBACKREF(node)); + BRefNode* br = NBREF(node); -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL if (IS_BACKREF_NEST_LEVEL(br)) { r = SIZE_OPCODE + SIZE_OPTION + SIZE_LENGTH + SIZE_LENGTH + (SIZE_MEMNUM * br->back_num); @@ -1533,21 +1553,21 @@ compile_length_tree(Node* node, regex_t* reg) break; #ifdef USE_SUBEXP_CALL - case N_CALL: + case NT_CALL: r = SIZE_OP_CALL; break; #endif - case N_QUANTIFIER: - r = compile_length_quantifier_node(&(NQUANTIFIER(node)), reg); + case NT_QTFR: + r = compile_length_quantifier_node(NQTFR(node), reg); break; - case N_EFFECT: - r = compile_length_effect_node(&NEFFECT(node), reg); + case NT_ENCLOSE: + r = compile_length_enclose_node(NENCLOSE(node), reg); break; - case N_ANCHOR: - r = compile_length_anchor_node(&(NANCHOR(node)), reg); + case NT_ANCHOR: + r = compile_length_anchor_node(NANCHOR(node), reg); break; default: @@ -1565,59 +1585,61 @@ compile_tree(Node* node, regex_t* reg) type = NTYPE(node); switch (type) { - case N_LIST: + case NT_LIST: do { - r = compile_tree(NCONS(node).left, reg); - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + r = compile_tree(NCAR(node), reg); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_ALT: + case NT_ALT: { Node* x = node; len = 0; do { - len += compile_length_tree(NCONS(x).left, reg); - if (NCONS(x).right != NULL) { + len += compile_length_tree(NCAR(x), reg); + if (NCDR(x) != NULL) { len += SIZE_OP_PUSH + SIZE_OP_JUMP; } - } while (IS_NOT_NULL(x = NCONS(x).right)); + } while (IS_NOT_NULL(x = NCDR(x))); pos = reg->used + len; /* goal position */ do { - len = compile_length_tree(NCONS(node).left, reg); - if (IS_NOT_NULL(NCONS(node).right)) { + len = compile_length_tree(NCAR(node), reg); + if (IS_NOT_NULL(NCDR(node))) { r = add_opcode_rel_addr(reg, OP_PUSH, len + SIZE_OP_JUMP); if (r) break; } - r = compile_tree(NCONS(node).left, reg); + r = compile_tree(NCAR(node), reg); if (r) break; - if (IS_NOT_NULL(NCONS(node).right)) { + if (IS_NOT_NULL(NCDR(node))) { len = pos - (reg->used + SIZE_OP_JUMP); r = add_opcode_rel_addr(reg, OP_JUMP, len); if (r) break; } - } while (IS_NOT_NULL(node = NCONS(node).right)); + } while (IS_NOT_NULL(node = NCDR(node))); } break; - case N_STRING: + case NT_STR: if (NSTRING_IS_RAW(node)) - r = compile_string_raw_node(&(NSTRING(node)), reg); + r = compile_string_raw_node(NSTR(node), reg); else r = compile_string_node(node, reg); break; - case N_CCLASS: - r = compile_cclass_node(&(NCCLASS(node)), reg); + case NT_CCLASS: + r = compile_cclass_node(NCCLASS(node), reg); break; - case N_CTYPE: + case NT_CTYPE: { int op; - switch (NCTYPE(node).type) { - case CTYPE_WORD: op = OP_WORD; break; - case CTYPE_NOT_WORD: op = OP_NOT_WORD; break; + switch (NCTYPE(node)->ctype) { + case ONIGENC_CTYPE_WORD: + if (NCTYPE(node)->not != 0) op = OP_NOT_WORD; + else op = OP_WORD; + break; default: return ONIGERR_TYPE_BUG; break; @@ -1626,20 +1648,20 @@ compile_tree(Node* node, regex_t* reg) } break; - case N_ANYCHAR: + case NT_CANY: if (IS_MULTILINE(reg->options)) r = add_opcode(reg, OP_ANYCHAR_ML); else r = add_opcode(reg, OP_ANYCHAR); break; - case N_BACKREF: + case NT_BREF: { - BackrefNode* br = &(NBACKREF(node)); + BRefNode* br = NBREF(node); -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL if (IS_BACKREF_NEST_LEVEL(br)) { - r = add_opcode(reg, OP_BACKREF_AT_LEVEL); + r = add_opcode(reg, OP_BACKREF_WITH_LEVEL); if (r) return r; r = add_option(reg, (reg->options & ONIG_OPTION_IGNORECASE)); if (r) return r; @@ -1681,7 +1703,7 @@ compile_tree(Node* node, regex_t* reg) } if (r) return r; -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL add_bacref_mems: #endif r = add_length(reg, br->back_num); @@ -1696,21 +1718,21 @@ compile_tree(Node* node, regex_t* reg) break; #ifdef USE_SUBEXP_CALL - case N_CALL: - r = compile_call(&(NCALL(node)), reg); + case NT_CALL: + r = compile_call(NCALL(node), reg); break; #endif - case N_QUANTIFIER: - r = compile_quantifier_node(&(NQUANTIFIER(node)), reg); + case NT_QTFR: + r = compile_quantifier_node(NQTFR(node), reg); break; - case N_EFFECT: - r = compile_effect_node(&NEFFECT(node), reg); + case NT_ENCLOSE: + r = compile_enclose_node(NENCLOSE(node), reg); break; - case N_ANCHOR: - r = compile_anchor_node(&(NANCHOR(node)), reg); + case NT_ANCHOR: + r = compile_anchor_node(NANCHOR(node), reg); break; default: @@ -1732,29 +1754,29 @@ noname_disable_map(Node** plink, GroupNumRemap* map, int* counter) Node* node = *plink; switch (NTYPE(node)) { - case N_LIST: - case N_ALT: + case NT_LIST: + case NT_ALT: do { - r = noname_disable_map(&(NCONS(node).left), map, counter); - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + r = noname_disable_map(&(NCAR(node)), map, counter); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_QUANTIFIER: + case NT_QTFR: { - Node** ptarget = &(NQUANTIFIER(node).target); + Node** ptarget = &(NQTFR(node)->target); Node* old = *ptarget; r = noname_disable_map(ptarget, map, counter); - if (*ptarget != old && NTYPE(*ptarget) == N_QUANTIFIER) { + if (*ptarget != old && NTYPE(*ptarget) == NT_QTFR) { onig_reduce_nested_quantifier(node, *ptarget); } } break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); - if (en->type == EFFECT_MEMORY) { - if (IS_EFFECT_NAMED_GROUP(en)) { + EncloseNode* en = NENCLOSE(node); + if (en->type == ENCLOSE_MEMORY) { + if (IS_ENCLOSE_NAMED_GROUP(en)) { (*counter)++; map[en->regnum].new_val = *counter; en->regnum = *counter; @@ -1784,7 +1806,7 @@ renumber_node_backref(Node* node, GroupNumRemap* map) { int i, pos, n, old_num; int *backs; - BackrefNode* bn = &(NBACKREF(node)); + BRefNode* bn = NBREF(node); if (! IS_BACKREF_NAME_REF(bn)) return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED; @@ -1813,20 +1835,20 @@ renumber_by_map(Node* node, GroupNumRemap* map) int r = 0; switch (NTYPE(node)) { - case N_LIST: - case N_ALT: + case NT_LIST: + case NT_ALT: do { - r = renumber_by_map(NCONS(node).left, map); - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + r = renumber_by_map(NCAR(node), map); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_QUANTIFIER: - r = renumber_by_map(NQUANTIFIER(node).target, map); + case NT_QTFR: + r = renumber_by_map(NQTFR(node)->target, map); break; - case N_EFFECT: - r = renumber_by_map(NEFFECT(node).target, map); + case NT_ENCLOSE: + r = renumber_by_map(NENCLOSE(node)->target, map); break; - case N_BACKREF: + case NT_BREF: r = renumber_node_backref(node, map); break; @@ -1843,21 +1865,21 @@ numbered_ref_check(Node* node) int r = 0; switch (NTYPE(node)) { - case N_LIST: - case N_ALT: + case NT_LIST: + case NT_ALT: do { - r = numbered_ref_check(NCONS(node).left); - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + r = numbered_ref_check(NCAR(node)); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_QUANTIFIER: - r = numbered_ref_check(NQUANTIFIER(node).target); + case NT_QTFR: + r = numbered_ref_check(NQTFR(node)->target); break; - case N_EFFECT: - r = numbered_ref_check(NEFFECT(node).target); + case NT_ENCLOSE: + r = numbered_ref_check(NENCLOSE(node)->target); break; - case N_BACKREF: - if (! IS_BACKREF_NAME_REF(&(NBACKREF(node)))) + case NT_BREF: + if (! IS_BACKREF_NAME_REF(NBREF(node))) return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED; break; @@ -1876,7 +1898,7 @@ disable_noname_group_capture(Node** root, regex_t* reg, ScanEnv* env) GroupNumRemap* map; map = (GroupNumRemap* )xalloca(sizeof(GroupNumRemap) * (env->num_mem + 1)); - CHECK_NULL_RETURN_VAL(map, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(map); for (i = 1; i <= env->num_mem; i++) { map[i].new_val = 0; } @@ -1914,12 +1936,12 @@ static int unset_addr_list_fix(UnsetAddrList* uslist, regex_t* reg) { int i, offset; - EffectNode* en; + EncloseNode* en; AbsAddrType addr; for (i = 0; i < uslist->num; i++) { - en = &(NEFFECT(uslist->us[i].target)); - if (! IS_EFFECT_ADDR_FIXED(en)) return ONIGERR_PARSER_BUG; + en = NENCLOSE(uslist->us[i].target); + if (! IS_ENCLOSE_ADDR_FIXED(en)) return ONIGERR_PARSER_BUG; addr = en->call_addr; offset = uslist->us[i].offset; @@ -1929,53 +1951,53 @@ unset_addr_list_fix(UnsetAddrList* uslist, regex_t* reg) } #endif -#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK +#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT static int quantifiers_memory_node_info(Node* node) { int r = 0; switch (NTYPE(node)) { - case N_LIST: - case N_ALT: + case NT_LIST: + case NT_ALT: { int v; do { - v = quantifiers_memory_node_info(NCONS(node).left); + v = quantifiers_memory_node_info(NCAR(node)); if (v > r) r = v; - } while (v >= 0 && IS_NOT_NULL(node = NCONS(node).right)); + } while (v >= 0 && IS_NOT_NULL(node = NCDR(node))); } break; #ifdef USE_SUBEXP_CALL - case N_CALL: - if (IS_CALL_RECURSION(&NCALL(node))) { + case NT_CALL: + if (IS_CALL_RECURSION(NCALL(node))) { return NQ_TARGET_IS_EMPTY_REC; /* tiny version */ } else - r = quantifiers_memory_node_info(NCALL(node).target); + r = quantifiers_memory_node_info(NCALL(node)->target); break; #endif - case N_QUANTIFIER: + case NT_QTFR: { - QuantifierNode* qn = &(NQUANTIFIER(node)); + QtfrNode* qn = NQTFR(node); if (qn->upper != 0) { r = quantifiers_memory_node_info(qn->target); } } break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); + EncloseNode* en = NENCLOSE(node); switch (en->type) { - case EFFECT_MEMORY: + case ENCLOSE_MEMORY: return NQ_TARGET_IS_EMPTY_MEM; break; - case EFFECT_OPTION: - case EFFECT_STOP_BACKTRACK: + case ENCLOSE_OPTION: + case ENCLOSE_STOP_BACKTRACK: r = quantifiers_memory_node_info(en->target); break; default: @@ -1984,19 +2006,19 @@ quantifiers_memory_node_info(Node* node) } break; - case N_BACKREF: - case N_STRING: - case N_CTYPE: - case N_CCLASS: - case N_ANYCHAR: - case N_ANCHOR: + case NT_BREF: + case NT_STR: + case NT_CTYPE: + case NT_CCLASS: + case NT_CANY: + case NT_ANCHOR: default: break; } return r; } -#endif /* USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK */ +#endif /* USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT */ static int get_min_match_length(Node* node, OnigDistance *min, ScanEnv* env) @@ -2006,12 +2028,12 @@ get_min_match_length(Node* node, OnigDistance *min, ScanEnv* env) *min = 0; switch (NTYPE(node)) { - case N_BACKREF: + case NT_BREF: { int i; int* backs; Node** nodes = SCANENV_MEM_NODES(env); - BackrefNode* br = &(NBACKREF(node)); + BRefNode* br = NBREF(node); if (br->state & NST_RECURSION) break; backs = BACKREFS_P(br); @@ -2028,62 +2050,57 @@ get_min_match_length(Node* node, OnigDistance *min, ScanEnv* env) break; #ifdef USE_SUBEXP_CALL - case N_CALL: - if (IS_CALL_RECURSION(&NCALL(node))) { - EffectNode* en = &(NEFFECT(NCALL(node).target)); - if (IS_EFFECT_MIN_FIXED(en)) + case NT_CALL: + if (IS_CALL_RECURSION(NCALL(node))) { + EncloseNode* en = NENCLOSE(NCALL(node)->target); + if (IS_ENCLOSE_MIN_FIXED(en)) *min = en->min_len; } else - r = get_min_match_length(NCALL(node).target, min, env); + r = get_min_match_length(NCALL(node)->target, min, env); break; #endif - case N_LIST: + case NT_LIST: do { - r = get_min_match_length(NCONS(node).left, &tmin, env); + r = get_min_match_length(NCAR(node), &tmin, env); if (r == 0) *min += tmin; - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_ALT: + case NT_ALT: { Node *x, *y; y = node; do { - x = NCONS(y).left; + x = NCAR(y); r = get_min_match_length(x, &tmin, env); if (r != 0) break; if (y == node) *min = tmin; else if (*min > tmin) *min = tmin; - } while (r == 0 && IS_NOT_NULL(y = NCONS(y).right)); + } while (r == 0 && IS_NOT_NULL(y = NCDR(y))); } break; - case N_STRING: + case NT_STR: { - StrNode* sn = &(NSTRING(node)); + StrNode* sn = NSTR(node); *min = sn->end - sn->s; } break; - case N_CTYPE: - switch (NCTYPE(node).type) { - case CTYPE_WORD: *min = 1; break; - case CTYPE_NOT_WORD: *min = 1; break; - default: - break; - } + case NT_CTYPE: + *min = 1; break; - case N_CCLASS: - case N_ANYCHAR: + case NT_CCLASS: + case NT_CANY: *min = 1; break; - case N_QUANTIFIER: + case NT_QTFR: { - QuantifierNode* qn = &(NQUANTIFIER(node)); + QtfrNode* qn = NQTFR(node); if (qn->lower > 0) { r = get_min_match_length(qn->target, min, env); @@ -2093,32 +2110,32 @@ get_min_match_length(Node* node, OnigDistance *min, ScanEnv* env) } break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); + EncloseNode* en = NENCLOSE(node); switch (en->type) { - case EFFECT_MEMORY: + case ENCLOSE_MEMORY: #ifdef USE_SUBEXP_CALL - if (IS_EFFECT_MIN_FIXED(en)) + if (IS_ENCLOSE_MIN_FIXED(en)) *min = en->min_len; else { r = get_min_match_length(en->target, min, env); if (r == 0) { en->min_len = *min; - SET_EFFECT_STATUS(node, NST_MIN_FIXED); + SET_ENCLOSE_STATUS(node, NST_MIN_FIXED); } } break; #endif - case EFFECT_OPTION: - case EFFECT_STOP_BACKTRACK: + case ENCLOSE_OPTION: + case ENCLOSE_STOP_BACKTRACK: r = get_min_match_length(en->target, min, env); break; } } break; - case N_ANCHOR: + case NT_ANCHOR: default: break; } @@ -2134,51 +2151,43 @@ get_max_match_length(Node* node, OnigDistance *max, ScanEnv* env) *max = 0; switch (NTYPE(node)) { - case N_LIST: + case NT_LIST: do { - r = get_max_match_length(NCONS(node).left, &tmax, env); + r = get_max_match_length(NCAR(node), &tmax, env); if (r == 0) *max = distance_add(*max, tmax); - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_ALT: + case NT_ALT: do { - r = get_max_match_length(NCONS(node).left, &tmax, env); + r = get_max_match_length(NCAR(node), &tmax, env); if (r == 0 && *max < tmax) *max = tmax; - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_STRING: + case NT_STR: { - StrNode* sn = &(NSTRING(node)); + StrNode* sn = NSTR(node); *max = sn->end - sn->s; } break; - case N_CTYPE: - switch (NCTYPE(node).type) { - case CTYPE_WORD: - case CTYPE_NOT_WORD: - *max = ONIGENC_MBC_MAXLEN_DIST(env->enc); - break; - - default: - break; - } + case NT_CTYPE: + *max = ONIGENC_MBC_MAXLEN_DIST(env->enc); break; - case N_CCLASS: - case N_ANYCHAR: + case NT_CCLASS: + case NT_CANY: *max = ONIGENC_MBC_MAXLEN_DIST(env->enc); break; - case N_BACKREF: + case NT_BREF: { int i; int* backs; Node** nodes = SCANENV_MEM_NODES(env); - BackrefNode* br = &(NBACKREF(node)); + BRefNode* br = NBREF(node); if (br->state & NST_RECURSION) { *max = ONIG_INFINITE_DISTANCE; break; @@ -2194,17 +2203,17 @@ get_max_match_length(Node* node, OnigDistance *max, ScanEnv* env) break; #ifdef USE_SUBEXP_CALL - case N_CALL: - if (! IS_CALL_RECURSION(&(NCALL(node)))) - r = get_max_match_length(NCALL(node).target, max, env); + case NT_CALL: + if (! IS_CALL_RECURSION(NCALL(node))) + r = get_max_match_length(NCALL(node)->target, max, env); else *max = ONIG_INFINITE_DISTANCE; break; #endif - case N_QUANTIFIER: + case NT_QTFR: { - QuantifierNode* qn = &(NQUANTIFIER(node)); + QtfrNode* qn = NQTFR(node); if (qn->upper != 0) { r = get_max_match_length(qn->target, max, env); @@ -2218,32 +2227,32 @@ get_max_match_length(Node* node, OnigDistance *max, ScanEnv* env) } break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); + EncloseNode* en = NENCLOSE(node); switch (en->type) { - case EFFECT_MEMORY: + case ENCLOSE_MEMORY: #ifdef USE_SUBEXP_CALL - if (IS_EFFECT_MAX_FIXED(en)) + if (IS_ENCLOSE_MAX_FIXED(en)) *max = en->max_len; else { r = get_max_match_length(en->target, max, env); if (r == 0) { en->max_len = *max; - SET_EFFECT_STATUS(node, NST_MAX_FIXED); + SET_ENCLOSE_STATUS(node, NST_MAX_FIXED); } } break; #endif - case EFFECT_OPTION: - case EFFECT_STOP_BACKTRACK: + case ENCLOSE_OPTION: + case ENCLOSE_STOP_BACKTRACK: r = get_max_match_length(en->target, max, env); break; } } break; - case N_ANCHOR: + case NT_ANCHOR: default: break; } @@ -2264,22 +2273,22 @@ get_char_length_tree1(Node* node, regex_t* reg, int* len, int level) level++; *len = 0; switch (NTYPE(node)) { - case N_LIST: + case NT_LIST: do { - r = get_char_length_tree1(NCONS(node).left, reg, &tlen, level); + r = get_char_length_tree1(NCAR(node), reg, &tlen, level); if (r == 0) *len = distance_add(*len, tlen); - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_ALT: + case NT_ALT: { int tlen2; int varlen = 0; - r = get_char_length_tree1(NCONS(node).left, reg, &tlen, level); - while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)) { - r = get_char_length_tree1(NCONS(node).left, reg, &tlen2, level); + r = get_char_length_tree1(NCAR(node), reg, &tlen, level); + while (r == 0 && IS_NOT_NULL(node = NCDR(node))) { + r = get_char_length_tree1(NCAR(node), reg, &tlen2, level); if (r == 0) { if (tlen != tlen2) varlen = 1; @@ -2298,20 +2307,20 @@ get_char_length_tree1(Node* node, regex_t* reg, int* len, int level) } break; - case N_STRING: + case NT_STR: { - StrNode* sn = &(NSTRING(node)); + StrNode* sn = NSTR(node); UChar *s = sn->s; while (s < sn->end) { - s += enc_len(reg->enc, s); + s += enclen(reg->enc, s); (*len)++; } } break; - case N_QUANTIFIER: + case NT_QTFR: { - QuantifierNode* qn = &(NQUANTIFIER(node)); + QtfrNode* qn = NQTFR(node); if (qn->lower == qn->upper) { r = get_char_length_tree1(qn->target, reg, &tlen, level); if (r == 0) @@ -2323,47 +2332,42 @@ get_char_length_tree1(Node* node, regex_t* reg, int* len, int level) break; #ifdef USE_SUBEXP_CALL - case N_CALL: - if (! IS_CALL_RECURSION(&(NCALL(node)))) - r = get_char_length_tree1(NCALL(node).target, reg, len, level); + case NT_CALL: + if (! IS_CALL_RECURSION(NCALL(node))) + r = get_char_length_tree1(NCALL(node)->target, reg, len, level); else r = GET_CHAR_LEN_VARLEN; break; #endif - case N_CTYPE: - switch (NCTYPE(node).type) { - case CTYPE_WORD: - case CTYPE_NOT_WORD: - *len = 1; - break; - } + case NT_CTYPE: + *len = 1; break; - case N_CCLASS: - case N_ANYCHAR: + case NT_CCLASS: + case NT_CANY: *len = 1; break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); + EncloseNode* en = NENCLOSE(node); switch (en->type) { - case EFFECT_MEMORY: + case ENCLOSE_MEMORY: #ifdef USE_SUBEXP_CALL - if (IS_EFFECT_CLEN_FIXED(en)) + if (IS_ENCLOSE_CLEN_FIXED(en)) *len = en->char_len; else { r = get_char_length_tree1(en->target, reg, len, level); if (r == 0) { en->char_len = *len; - SET_EFFECT_STATUS(node, NST_CLEN_FIXED); + SET_ENCLOSE_STATUS(node, NST_CLEN_FIXED); } } break; #endif - case EFFECT_OPTION: - case EFFECT_STOP_BACKTRACK: + case ENCLOSE_OPTION: + case ENCLOSE_STOP_BACKTRACK: r = get_char_length_tree1(en->target, reg, len, level); break; default: @@ -2372,7 +2376,7 @@ get_char_length_tree1(Node* node, regex_t* reg, int* len, int level) } break; - case N_ANCHOR: + case NT_ANCHOR: break; default: @@ -2401,29 +2405,18 @@ is_not_included(Node* x, Node* y, regex_t* reg) retry: ytype = NTYPE(y); switch (NTYPE(x)) { - case N_CTYPE: + case NT_CTYPE: { switch (ytype) { - case N_CTYPE: - switch (NCTYPE(x).type) { - case CTYPE_WORD: - if (NCTYPE(y).type == CTYPE_NOT_WORD) - return 1; - else - return 0; - break; - case CTYPE_NOT_WORD: - if (NCTYPE(y).type == CTYPE_WORD) - return 1; - else - return 0; - break; - default: - break; - } + case NT_CTYPE: + if (NCTYPE(y)->ctype == NCTYPE(x)->ctype && + NCTYPE(y)->not != NCTYPE(x)->not) + return 1; + else + return 0; break; - case N_CCLASS: + case NT_CCLASS: swap: { Node* tmp; @@ -2432,7 +2425,7 @@ is_not_included(Node* x, Node* y, regex_t* reg) } break; - case N_STRING: + case NT_STR: goto swap; break; @@ -2442,37 +2435,39 @@ is_not_included(Node* x, Node* y, regex_t* reg) } break; - case N_CCLASS: + case NT_CCLASS: { - CClassNode* xc = &(NCCLASS(x)); + CClassNode* xc = NCCLASS(x); switch (ytype) { - case N_CTYPE: - switch (NCTYPE(y).type) { - case CTYPE_WORD: - if (IS_NULL(xc->mbuf) && !IS_CCLASS_NOT(xc)) { - for (i = 0; i < SINGLE_BYTE_SIZE; i++) { - if (BITSET_AT(xc->bs, i)) { - if (ONIGENC_IS_CODE_SB_WORD(reg->enc, i)) return 0; + case NT_CTYPE: + switch (NCTYPE(y)->ctype) { + case ONIGENC_CTYPE_WORD: + if (NCTYPE(y)->not == 0) { + if (IS_NULL(xc->mbuf) && !IS_NCCLASS_NOT(xc)) { + for (i = 0; i < SINGLE_BYTE_SIZE; i++) { + if (BITSET_AT(xc->bs, i)) { + if (IS_CODE_SB_WORD(reg->enc, i)) return 0; + } } + return 1; } - return 1; + return 0; } - return 0; - break; - case CTYPE_NOT_WORD: - for (i = 0; i < SINGLE_BYTE_SIZE; i++) { - if (! ONIGENC_IS_CODE_SB_WORD(reg->enc, i)) { - if (!IS_CCLASS_NOT(xc)) { - if (BITSET_AT(xc->bs, i)) - return 0; - } - else { - if (! BITSET_AT(xc->bs, i)) - return 0; + else { + for (i = 0; i < SINGLE_BYTE_SIZE; i++) { + if (! IS_CODE_SB_WORD(reg->enc, i)) { + if (!IS_NCCLASS_NOT(xc)) { + if (BITSET_AT(xc->bs, i)) + return 0; + } + else { + if (! BITSET_AT(xc->bs, i)) + return 0; + } } } + return 1; } - return 1; break; default: @@ -2480,29 +2475,29 @@ is_not_included(Node* x, Node* y, regex_t* reg) } break; - case N_CCLASS: + case NT_CCLASS: { int v; - CClassNode* yc = &(NCCLASS(y)); + CClassNode* yc = NCCLASS(y); for (i = 0; i < SINGLE_BYTE_SIZE; i++) { v = BITSET_AT(xc->bs, i); - if ((v != 0 && !IS_CCLASS_NOT(xc)) || - (v == 0 && IS_CCLASS_NOT(xc))) { + if ((v != 0 && !IS_NCCLASS_NOT(xc)) || + (v == 0 && IS_NCCLASS_NOT(xc))) { v = BITSET_AT(yc->bs, i); - if ((v != 0 && !IS_CCLASS_NOT(yc)) || - (v == 0 && IS_CCLASS_NOT(yc))) + if ((v != 0 && !IS_NCCLASS_NOT(yc)) || + (v == 0 && IS_NCCLASS_NOT(yc))) return 0; } } - if ((IS_NULL(xc->mbuf) && !IS_CCLASS_NOT(xc)) || - (IS_NULL(yc->mbuf) && !IS_CCLASS_NOT(yc))) + if ((IS_NULL(xc->mbuf) && !IS_NCCLASS_NOT(xc)) || + (IS_NULL(yc->mbuf) && !IS_NCCLASS_NOT(yc))) return 1; return 0; } break; - case N_STRING: + case NT_STR: goto swap; break; @@ -2512,30 +2507,30 @@ is_not_included(Node* x, Node* y, regex_t* reg) } break; - case N_STRING: + case NT_STR: { - StrNode* xs = &(NSTRING(x)); + StrNode* xs = NSTR(x); if (NSTRING_LEN(x) == 0) break; c = *(xs->s); switch (ytype) { - case N_CTYPE: - switch (NCTYPE(y).type) { - case CTYPE_WORD: - return (ONIGENC_IS_MBC_WORD(reg->enc, xs->s, xs->end) ? 0 : 1); - break; - case CTYPE_NOT_WORD: - return (ONIGENC_IS_MBC_WORD(reg->enc, xs->s, xs->end) ? 1 : 0); + case NT_CTYPE: + switch (NCTYPE(y)->ctype) { + case ONIGENC_CTYPE_WORD: + if (ONIGENC_IS_MBC_WORD(reg->enc, xs->s, xs->end)) + return NCTYPE(y)->not; + else + return !(NCTYPE(y)->not); break; default: break; } break; - case N_CCLASS: + case NT_CCLASS: { - CClassNode* cc = &(NCCLASS(y)); + CClassNode* cc = NCCLASS(y); code = ONIGENC_MBC_TO_CODE(reg->enc, xs->s, xs->s + ONIGENC_MBC_MAXLEN(reg->enc)); @@ -2543,10 +2538,10 @@ is_not_included(Node* x, Node* y, regex_t* reg) } break; - case N_STRING: + case NT_STR: { UChar *q; - StrNode* ys = &(NSTRING(y)); + StrNode* ys = NSTR(y); len = NSTRING_LEN(x); if (len > NSTRING_LEN(y)) len = NSTRING_LEN(y); if (NSTRING_IS_AMBIG(x) || NSTRING_IS_AMBIG(y)) { @@ -2580,40 +2575,34 @@ get_head_value_node(Node* node, int exact, regex_t* reg) Node* n = NULL_NODE; switch (NTYPE(node)) { - case N_BACKREF: - case N_ALT: - case N_ANYCHAR: + case NT_BREF: + case NT_ALT: + case NT_CANY: #ifdef USE_SUBEXP_CALL - case N_CALL: + case NT_CALL: #endif break; - case N_CTYPE: - case N_CCLASS: + case NT_CTYPE: + case NT_CCLASS: if (exact == 0) { n = node; } break; - case N_LIST: - n = get_head_value_node(NCONS(node).left, exact, reg); + case NT_LIST: + n = get_head_value_node(NCAR(node), exact, reg); break; - case N_STRING: + case NT_STR: { - StrNode* sn = &(NSTRING(node)); + StrNode* sn = NSTR(node); if (sn->end <= sn->s) break; if (exact != 0 && !NSTRING_IS_RAW(node) && IS_IGNORECASE(reg->options)) { -#if 0 - UChar* tmp = sn->s; - if (! ONIGENC_IS_MBC_AMBIGUOUS(reg->enc, reg->ambig_flag, - &tmp, sn->end)) - n = node; -#endif } else { n = node; @@ -2621,9 +2610,9 @@ get_head_value_node(Node* node, int exact, regex_t* reg) } break; - case N_QUANTIFIER: + case NT_QTFR: { - QuantifierNode* qn = &(NQUANTIFIER(node)); + QtfrNode* qn = NQTFR(node); if (qn->lower > 0) { if (IS_NOT_NULL(qn->head_exact)) n = qn->head_exact; @@ -2633,31 +2622,31 @@ get_head_value_node(Node* node, int exact, regex_t* reg) } break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); + EncloseNode* en = NENCLOSE(node); switch (en->type) { - case EFFECT_OPTION: + case ENCLOSE_OPTION: { OnigOptionType options = reg->options; - reg->options = NEFFECT(node).option; - n = get_head_value_node(NEFFECT(node).target, exact, reg); + reg->options = NENCLOSE(node)->option; + n = get_head_value_node(NENCLOSE(node)->target, exact, reg); reg->options = options; } break; - case EFFECT_MEMORY: - case EFFECT_STOP_BACKTRACK: + case ENCLOSE_MEMORY: + case ENCLOSE_STOP_BACKTRACK: n = get_head_value_node(en->target, exact, reg); break; } } break; - case N_ANCHOR: - if (NANCHOR(node).type == ANCHOR_PREC_READ) - n = get_head_value_node(NANCHOR(node).target, exact, reg); + case NT_ANCHOR: + if (NANCHOR(node)->type == ANCHOR_PREC_READ) + n = get_head_value_node(NANCHOR(node)->target, exact, reg); break; default: @@ -2668,45 +2657,46 @@ get_head_value_node(Node* node, int exact, regex_t* reg) } static int -check_type_tree(Node* node, int type_mask, int effect_mask, int anchor_mask) +check_type_tree(Node* node, int type_mask, int enclose_mask, int anchor_mask) { int type, r = 0; type = NTYPE(node); - if ((type & type_mask) == 0) + if ((NTYPE2BIT(type) & type_mask) == 0) return 1; switch (type) { - case N_LIST: - case N_ALT: + case NT_LIST: + case NT_ALT: do { - r = check_type_tree(NCONS(node).left, type_mask, effect_mask, anchor_mask); - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + r = check_type_tree(NCAR(node), type_mask, enclose_mask, + anchor_mask); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_QUANTIFIER: - r = check_type_tree(NQUANTIFIER(node).target, type_mask, effect_mask, + case NT_QTFR: + r = check_type_tree(NQTFR(node)->target, type_mask, enclose_mask, anchor_mask); break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); - if ((en->type & effect_mask) == 0) + EncloseNode* en = NENCLOSE(node); + if ((en->type & enclose_mask) == 0) return 1; - r = check_type_tree(en->target, type_mask, effect_mask, anchor_mask); + r = check_type_tree(en->target, type_mask, enclose_mask, anchor_mask); } break; - case N_ANCHOR: - type = NANCHOR(node).type; + case NT_ANCHOR: + type = NANCHOR(node)->type; if ((type & anchor_mask) == 0) return 1; - if (NANCHOR(node).target) - r = check_type_tree(NANCHOR(node).target, - type_mask, effect_mask, anchor_mask); + if (NANCHOR(node)->target) + r = check_type_tree(NANCHOR(node)->target, + type_mask, enclose_mask, anchor_mask); break; default: @@ -2728,7 +2718,7 @@ subexp_inf_recursive_check(Node* node, ScanEnv* env, int head) type = NTYPE(node); switch (type) { - case N_LIST: + case NT_LIST: { Node *x; OnigDistance min; @@ -2736,40 +2726,40 @@ subexp_inf_recursive_check(Node* node, ScanEnv* env, int head) x = node; do { - ret = subexp_inf_recursive_check(NCONS(x).left, env, head); + ret = subexp_inf_recursive_check(NCAR(x), env, head); if (ret < 0 || ret == RECURSION_INFINITE) return ret; r |= ret; if (head) { - ret = get_min_match_length(NCONS(x).left, &min, env); + ret = get_min_match_length(NCAR(x), &min, env); if (ret != 0) return ret; if (min != 0) head = 0; } - } while (IS_NOT_NULL(x = NCONS(x).right)); + } while (IS_NOT_NULL(x = NCDR(x))); } break; - case N_ALT: + case NT_ALT: { int ret; r = RECURSION_EXIST; do { - ret = subexp_inf_recursive_check(NCONS(node).left, env, head); + ret = subexp_inf_recursive_check(NCAR(node), env, head); if (ret < 0 || ret == RECURSION_INFINITE) return ret; r &= ret; - } while (IS_NOT_NULL(node = NCONS(node).right)); + } while (IS_NOT_NULL(node = NCDR(node))); } break; - case N_QUANTIFIER: - r = subexp_inf_recursive_check(NQUANTIFIER(node).target, env, head); + case NT_QTFR: + r = subexp_inf_recursive_check(NQTFR(node)->target, env, head); if (r == RECURSION_EXIST) { - if (NQUANTIFIER(node).lower == 0) r = 0; + if (NQTFR(node)->lower == 0) r = 0; } break; - case N_ANCHOR: + case NT_ANCHOR: { - AnchorNode* an = &(NANCHOR(node)); + AnchorNode* an = NANCHOR(node); switch (an->type) { case ANCHOR_PREC_READ: case ANCHOR_PREC_READ_NOT: @@ -2781,19 +2771,19 @@ subexp_inf_recursive_check(Node* node, ScanEnv* env, int head) } break; - case N_CALL: - r = subexp_inf_recursive_check(NCALL(node).target, env, head); + case NT_CALL: + r = subexp_inf_recursive_check(NCALL(node)->target, env, head); break; - case N_EFFECT: - if (IS_EFFECT_MARK2(&(NEFFECT(node)))) + case NT_ENCLOSE: + if (IS_ENCLOSE_MARK2(NENCLOSE(node))) return 0; - else if (IS_EFFECT_MARK1(&(NEFFECT(node)))) + else if (IS_ENCLOSE_MARK1(NENCLOSE(node))) return (head == 0 ? RECURSION_EXIST : RECURSION_INFINITE); else { - SET_EFFECT_STATUS(node, NST_MARK2); - r = subexp_inf_recursive_check(NEFFECT(node).target, env, head); - CLEAR_EFFECT_STATUS(node, NST_MARK2); + SET_ENCLOSE_STATUS(node, NST_MARK2); + r = subexp_inf_recursive_check(NENCLOSE(node)->target, env, head); + CLEAR_ENCLOSE_STATUS(node, NST_MARK2); } break; @@ -2812,20 +2802,20 @@ subexp_inf_recursive_check_trav(Node* node, ScanEnv* env) type = NTYPE(node); switch (type) { - case N_LIST: - case N_ALT: + case NT_LIST: + case NT_ALT: do { - r = subexp_inf_recursive_check_trav(NCONS(node).left, env); - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + r = subexp_inf_recursive_check_trav(NCAR(node), env); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_QUANTIFIER: - r = subexp_inf_recursive_check_trav(NQUANTIFIER(node).target, env); + case NT_QTFR: + r = subexp_inf_recursive_check_trav(NQTFR(node)->target, env); break; - case N_ANCHOR: + case NT_ANCHOR: { - AnchorNode* an = &(NANCHOR(node)); + AnchorNode* an = NANCHOR(node); switch (an->type) { case ANCHOR_PREC_READ: case ANCHOR_PREC_READ_NOT: @@ -2837,15 +2827,15 @@ subexp_inf_recursive_check_trav(Node* node, ScanEnv* env) } break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); + EncloseNode* en = NENCLOSE(node); - if (IS_EFFECT_RECURSION(en)) { - SET_EFFECT_STATUS(node, NST_MARK1); + if (IS_ENCLOSE_RECURSION(en)) { + SET_ENCLOSE_STATUS(node, NST_MARK1); r = subexp_inf_recursive_check(en->target, env, 1); if (r > 0) return ONIGERR_NEVER_ENDING_RECURSION; - CLEAR_EFFECT_STATUS(node, NST_MARK1); + CLEAR_ENCLOSE_STATUS(node, NST_MARK1); } r = subexp_inf_recursive_check_trav(en->target, env); } @@ -2862,25 +2852,23 @@ subexp_inf_recursive_check_trav(Node* node, ScanEnv* env) static int subexp_recursive_check(Node* node) { - int type; int r = 0; - type = NTYPE(node); - switch (type) { - case N_LIST: - case N_ALT: + switch (NTYPE(node)) { + case NT_LIST: + case NT_ALT: do { - r |= subexp_recursive_check(NCONS(node).left); - } while (IS_NOT_NULL(node = NCONS(node).right)); + r |= subexp_recursive_check(NCAR(node)); + } while (IS_NOT_NULL(node = NCDR(node))); break; - case N_QUANTIFIER: - r = subexp_recursive_check(NQUANTIFIER(node).target); + case NT_QTFR: + r = subexp_recursive_check(NQTFR(node)->target); break; - case N_ANCHOR: + case NT_ANCHOR: { - AnchorNode* an = &(NANCHOR(node)); + AnchorNode* an = NANCHOR(node); switch (an->type) { case ANCHOR_PREC_READ: case ANCHOR_PREC_READ_NOT: @@ -2892,20 +2880,20 @@ subexp_recursive_check(Node* node) } break; - case N_CALL: - r = subexp_recursive_check(NCALL(node).target); + case NT_CALL: + r = subexp_recursive_check(NCALL(node)->target); if (r != 0) SET_CALL_RECURSION(node); break; - case N_EFFECT: - if (IS_EFFECT_MARK2(&(NEFFECT(node)))) + case NT_ENCLOSE: + if (IS_ENCLOSE_MARK2(NENCLOSE(node))) return 0; - else if (IS_EFFECT_MARK1(&(NEFFECT(node)))) + else if (IS_ENCLOSE_MARK1(NENCLOSE(node))) return 1; /* recursion */ else { - SET_EFFECT_STATUS(node, NST_MARK2); - r = subexp_recursive_check(NEFFECT(node).target); - CLEAR_EFFECT_STATUS(node, NST_MARK2); + SET_ENCLOSE_STATUS(node, NST_MARK2); + r = subexp_recursive_check(NENCLOSE(node)->target); + CLEAR_ENCLOSE_STATUS(node, NST_MARK2); } break; @@ -2927,29 +2915,29 @@ subexp_recursive_check_trav(Node* node, ScanEnv* env) type = NTYPE(node); switch (type) { - case N_LIST: - case N_ALT: + case NT_LIST: + case NT_ALT: { int ret; do { - ret = subexp_recursive_check_trav(NCONS(node).left, env); + ret = subexp_recursive_check_trav(NCAR(node), env); if (ret == FOUND_CALLED_NODE) r = FOUND_CALLED_NODE; else if (ret < 0) return ret; - } while (IS_NOT_NULL(node = NCONS(node).right)); + } while (IS_NOT_NULL(node = NCDR(node))); } break; - case N_QUANTIFIER: - r = subexp_recursive_check_trav(NQUANTIFIER(node).target, env); - if (NQUANTIFIER(node).upper == 0) { + case NT_QTFR: + r = subexp_recursive_check_trav(NQTFR(node)->target, env); + if (NQTFR(node)->upper == 0) { if (r == FOUND_CALLED_NODE) - NQUANTIFIER(node).is_refered = 1; + NQTFR(node)->is_refered = 1; } break; - case N_ANCHOR: + case NT_ANCHOR: { - AnchorNode* an = &(NANCHOR(node)); + AnchorNode* an = NANCHOR(node); switch (an->type) { case ANCHOR_PREC_READ: case ANCHOR_PREC_READ_NOT: @@ -2961,20 +2949,20 @@ subexp_recursive_check_trav(Node* node, ScanEnv* env) } break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); + EncloseNode* en = NENCLOSE(node); - if (! IS_EFFECT_RECURSION(en)) { - if (IS_EFFECT_CALLED(en)) { - SET_EFFECT_STATUS(node, NST_MARK1); + if (! IS_ENCLOSE_RECURSION(en)) { + if (IS_ENCLOSE_CALLED(en)) { + SET_ENCLOSE_STATUS(node, NST_MARK1); r = subexp_recursive_check(en->target); - if (r != 0) SET_EFFECT_STATUS(node, NST_RECURSION); - CLEAR_EFFECT_STATUS(node, NST_MARK1); + if (r != 0) SET_ENCLOSE_STATUS(node, NST_RECURSION); + CLEAR_ENCLOSE_STATUS(node, NST_MARK1); } } r = subexp_recursive_check_trav(en->target, env); - if (IS_EFFECT_CALLED(en)) + if (IS_ENCLOSE_CALLED(en)) r |= FOUND_CALLED_NODE; } break; @@ -2994,46 +2982,33 @@ setup_subexp_call(Node* node, ScanEnv* env) type = NTYPE(node); switch (type) { - case N_LIST: + case NT_LIST: do { - r = setup_subexp_call(NCONS(node).left, env); - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + r = setup_subexp_call(NCAR(node), env); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_ALT: + case NT_ALT: do { - r = setup_subexp_call(NCONS(node).left, env); - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + r = setup_subexp_call(NCAR(node), env); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_QUANTIFIER: - r = setup_subexp_call(NQUANTIFIER(node).target, env); + case NT_QTFR: + r = setup_subexp_call(NQTFR(node)->target, env); break; - case N_EFFECT: - r = setup_subexp_call(NEFFECT(node).target, env); + case NT_ENCLOSE: + r = setup_subexp_call(NENCLOSE(node)->target, env); break; - case N_CALL: + case NT_CALL: { - int n, num, *refs; - UChar *p; - CallNode* cn = &(NCALL(node)); + CallNode* cn = NCALL(node); Node** nodes = SCANENV_MEM_NODES(env); -#ifdef USE_NAMED_GROUP - n = onig_name_to_group_numbers(env->reg, cn->name, cn->name_end, &refs); -#else - n = -1; -#endif - if (n <= 0) { - /* name not found, check group number. (?*ddd) */ - p = cn->name; - num = onig_scan_unsigned_number(&p, cn->name_end, env->enc); - if (num <= 0 || p != cn->name_end) { - onig_scan_env_set_error_string(env, - ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end); - return ONIGERR_UNDEFINED_NAME_REFERENCE; - } + if (cn->group_num != 0) { + int gnum = cn->group_num; + #ifdef USE_NAMED_GROUP if (env->num_named > 0 && IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) && @@ -3041,38 +3016,53 @@ setup_subexp_call(Node* node, ScanEnv* env) return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED; } #endif - if (num > env->num_mem) { + if (gnum > env->num_mem) { onig_scan_env_set_error_string(env, ONIGERR_UNDEFINED_GROUP_REFERENCE, cn->name, cn->name_end); return ONIGERR_UNDEFINED_GROUP_REFERENCE; } - cn->ref_num = num; - goto set_call_attr; - } - else if (n > 1) { - onig_scan_env_set_error_string(env, - ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL, cn->name, cn->name_end); - return ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL; - } - else { - cn->ref_num = refs[0]; + +#ifdef USE_NAMED_GROUP set_call_attr: - cn->target = nodes[cn->ref_num]; +#endif + cn->target = nodes[cn->group_num]; if (IS_NULL(cn->target)) { onig_scan_env_set_error_string(env, - ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end); + ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end); return ONIGERR_UNDEFINED_NAME_REFERENCE; } - SET_EFFECT_STATUS(cn->target, NST_CALLED); - BIT_STATUS_ON_AT(env->bt_mem_start, cn->ref_num); + SET_ENCLOSE_STATUS(cn->target, NST_CALLED); + BIT_STATUS_ON_AT(env->bt_mem_start, cn->group_num); cn->unset_addr_list = env->unset_addr_list; } +#ifdef USE_NAMED_GROUP + else { + int *refs; + + int n = onig_name_to_group_numbers(env->reg, cn->name, cn->name_end, + &refs); + if (n <= 0) { + onig_scan_env_set_error_string(env, + ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end); + return ONIGERR_UNDEFINED_NAME_REFERENCE; + } + else if (n > 1) { + onig_scan_env_set_error_string(env, + ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL, cn->name, cn->name_end); + return ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL; + } + else { + cn->group_num = refs[0]; + goto set_call_attr; + } + } +#endif } break; - case N_ANCHOR: + case NT_ANCHOR: { - AnchorNode* an = &(NANCHOR(node)); + AnchorNode* an = NANCHOR(node); switch (an->type) { case ANCHOR_PREC_READ: @@ -3100,30 +3090,29 @@ setup_subexp_call(Node* node, ScanEnv* env) static int divide_look_behind_alternatives(Node* node) { - Node tmp_node; Node *head, *np, *insert_node; - AnchorNode* an = &(NANCHOR(node)); + AnchorNode* an = NANCHOR(node); int anc_type = an->type; head = an->target; - np = NCONS(head).left; - tmp_node = *node; *node = *head; *head = tmp_node; - NCONS(node).left = head; - NANCHOR(head).target = np; + np = NCAR(head); + swap_node(node, head); + NCAR(node) = head; + NANCHOR(head)->target = np; np = node; - while ((np = NCONS(np).right) != NULL_NODE) { + while ((np = NCDR(np)) != NULL_NODE) { insert_node = onig_node_new_anchor(anc_type); - CHECK_NULL_RETURN_VAL(insert_node, ONIGERR_MEMORY); - NANCHOR(insert_node).target = NCONS(np).left; - NCONS(np).left = insert_node; + CHECK_NULL_RETURN_MEMERR(insert_node); + NANCHOR(insert_node)->target = NCAR(np); + NCAR(np) = insert_node; } if (anc_type == ANCHOR_LOOK_BEHIND_NOT) { np = node; do { - np->type = N_LIST; /* alt -> list */ - } while ((np = NCONS(np).right) != NULL_NODE); + SET_NTYPE(np, NT_LIST); /* alt -> list */ + } while ((np = NCDR(np)) != NULL_NODE); } return 0; } @@ -3132,7 +3121,7 @@ static int setup_look_behind(Node* node, regex_t* reg, ScanEnv* env) { int r, len; - AnchorNode* an = &(NANCHOR(node)); + AnchorNode* an = NANCHOR(node); r = get_char_length_tree(an->target, reg, &len); if (r == 0) @@ -3156,11 +3145,15 @@ next_setup(Node* node, Node* next_node, regex_t* reg) retry: type = NTYPE(node); - if (type == N_QUANTIFIER) { - QuantifierNode* qn = &(NQUANTIFIER(node)); + if (type == NT_QTFR) { + QtfrNode* qn = NQTFR(node); if (qn->greedy && IS_REPEAT_INFINITE(qn->upper)) { -#ifdef USE_QUANTIFIER_PEEK_NEXT - qn->next_head_exact = get_head_value_node(next_node, 1, reg); +#ifdef USE_QTFR_PEEK_NEXT + Node* n = get_head_value_node(next_node, 1, reg); + /* '\0': for UTF-16BE etc... */ + if (IS_NOT_NULL(n) && NSTR(n)->s[0] != '\0') { + qn->next_head_exact = n; + } #endif /* automatic posseivation a*b ==> (?>a*)b */ if (qn->lower <= 1) { @@ -3171,20 +3164,20 @@ next_setup(Node* node, Node* next_node, regex_t* reg) if (IS_NOT_NULL(x)) { y = get_head_value_node(next_node, 0, reg); if (IS_NOT_NULL(y) && is_not_included(x, y, reg)) { - Node* en = onig_node_new_effect(EFFECT_STOP_BACKTRACK); - CHECK_NULL_RETURN_VAL(en, ONIGERR_MEMORY); - SET_EFFECT_STATUS(en, NST_STOP_BT_SIMPLE_REPEAT); + Node* en = onig_node_new_enclose(ENCLOSE_STOP_BACKTRACK); + CHECK_NULL_RETURN_MEMERR(en); + SET_ENCLOSE_STATUS(en, NST_STOP_BT_SIMPLE_REPEAT); swap_node(node, en); - NEFFECT(node).target = en; + NENCLOSE(node)->target = en; } } } } } } - else if (type == N_EFFECT) { - EffectNode* en = &(NEFFECT(node)); - if (en->type == EFFECT_MEMORY) { + else if (type == NT_ENCLOSE) { + EncloseNode* en = NENCLOSE(node); + if (en->type == ENCLOSE_MEMORY) { node = en->target; goto retry; } @@ -3194,100 +3187,318 @@ next_setup(Node* node, Node* next_node, regex_t* reg) static int -divide_ambig_string_node_sub(regex_t* reg, int prev_ambig, - UChar* prev_start, UChar* prev, - UChar* end, Node*** tailp, Node** root) +update_string_node_case_fold(regex_t* reg, Node *node) { - UChar *tmp, *wp; - Node* snode; + UChar *p, *q, *end, buf[ONIGENC_MBC_CASE_FOLD_MAXLEN]; + UChar *sbuf, *ebuf, *sp; + int r, i, len, sbuf_size; + StrNode* sn = NSTR(node); + + end = sn->end; + sbuf_size = (end - sn->s) * 2; + sbuf = (UChar* )xmalloc(sbuf_size); + CHECK_NULL_RETURN_MEMERR(sbuf); + ebuf = sbuf + sbuf_size; - if (prev_ambig != 0) { - tmp = prev_start; - wp = prev_start; - while (tmp < prev) { - wp += ONIGENC_MBC_TO_NORMALIZE(reg->enc, reg->ambig_flag, - &tmp, end, wp); + sp = sbuf; + p = sn->s; + while (p < end) { + len = ONIGENC_MBC_CASE_FOLD(reg->enc, reg->case_fold_flag, &p, end, buf); + q = buf; + for (i = 0; i < len; i++) { + if (sp >= ebuf) { + sbuf = (UChar* )xrealloc(sbuf, sbuf_size * 2); + CHECK_NULL_RETURN_MEMERR(sbuf); + sp = sbuf + sbuf_size; + sbuf_size *= 2; + ebuf = sbuf + sbuf_size; + } + + *sp++ = buf[i]; } - snode = onig_node_new_str(prev_start, wp); - CHECK_NULL_RETURN_VAL(snode, ONIGERR_MEMORY); - NSTRING_SET_AMBIG(snode); - if (wp != prev) NSTRING_SET_AMBIG_REDUCE(snode); } - else { - snode = onig_node_new_str(prev_start, prev); - CHECK_NULL_RETURN_VAL(snode, ONIGERR_MEMORY); + + r = onig_node_str_set(node, sbuf, sp); + if (r != 0) { + xfree(sbuf); + return r; + } + + xfree(sbuf); + return 0; +} + +static int +expand_case_fold_make_rem_string(Node** rnode, UChar *s, UChar *end, + regex_t* reg) +{ + int r; + Node *node; + + node = onig_node_new_str(s, end); + if (IS_NULL(node)) return ONIGERR_MEMORY; + + r = update_string_node_case_fold(reg, node); + if (r != 0) { + onig_node_free(node); + return r; + } + + NSTRING_SET_AMBIG(node); + NSTRING_SET_DONT_GET_OPT_INFO(node); + *rnode = node; + return 0; +} + +static int +expand_case_fold_string_alt(int item_num, OnigCaseFoldCodeItem items[], + UChar *p, int slen, UChar *end, + regex_t* reg, Node **rnode) +{ + int r, i, j, len, varlen; + Node *anode, *var_anode, *snode, *xnode, *an; + UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN]; + + *rnode = var_anode = NULL_NODE; + + varlen = 0; + for (i = 0; i < item_num; i++) { + if (items[i].byte_len != slen) { + varlen = 1; + break; + } } - if (*tailp == (Node** )0) { - *root = onig_node_new_list(snode, NULL); - CHECK_NULL_RETURN_VAL(*root, ONIGERR_MEMORY); - *tailp = &(NCONS(*root).right); + if (varlen != 0) { + *rnode = var_anode = onig_node_new_alt(NULL_NODE, NULL_NODE); + if (IS_NULL(var_anode)) return ONIGERR_MEMORY; + + xnode = onig_node_new_list(NULL, NULL); + if (IS_NULL(xnode)) goto mem_err; + NCAR(var_anode) = xnode; + + anode = onig_node_new_alt(NULL_NODE, NULL_NODE); + if (IS_NULL(anode)) goto mem_err; + NCAR(xnode) = anode; } else { - **tailp = onig_node_new_list(snode, NULL); - CHECK_NULL_RETURN_VAL(**tailp, ONIGERR_MEMORY); - *tailp = &(NCONS(**tailp).right); + *rnode = anode = onig_node_new_alt(NULL_NODE, NULL_NODE); + if (IS_NULL(anode)) return ONIGERR_MEMORY; } - return 0; + snode = onig_node_new_str(p, p + slen); + if (IS_NULL(snode)) goto mem_err; + + NCAR(anode) = snode; + + for (i = 0; i < item_num; i++) { + snode = onig_node_new_str(NULL, NULL); + if (IS_NULL(snode)) goto mem_err; + + for (j = 0; j < items[i].code_len; j++) { + len = ONIGENC_CODE_TO_MBC(reg->enc, items[i].code[j], buf); + if (len < 0) { + r = len; + goto mem_err2; + } + + r = onig_node_str_cat(snode, buf, buf + len); + if (r != 0) goto mem_err2; + } + + an = onig_node_new_alt(NULL_NODE, NULL_NODE); + if (IS_NULL(an)) { + goto mem_err2; + } + + if (items[i].byte_len != slen) { + Node *rem; + UChar *q = p + items[i].byte_len; + + if (q < end) { + r = expand_case_fold_make_rem_string(&rem, q, end, reg); + if (r != 0) { + onig_node_free(an); + goto mem_err2; + } + + xnode = onig_node_list_add(NULL_NODE, snode); + if (IS_NULL(xnode)) { + onig_node_free(an); + onig_node_free(rem); + goto mem_err2; + } + if (IS_NULL(onig_node_list_add(xnode, rem))) { + onig_node_free(an); + onig_node_free(xnode); + onig_node_free(rem); + goto mem_err; + } + + NCAR(an) = xnode; + } + else { + NCAR(an) = snode; + } + + NCDR(var_anode) = an; + var_anode = an; + } + else { + NCAR(an) = snode; + NCDR(anode) = an; + anode = an; + } + } + + return varlen; + + mem_err2: + onig_node_free(snode); + + mem_err: + onig_node_free(*rnode); + + return ONIGERR_MEMORY; } static int -divide_ambig_string_node(Node* node, regex_t* reg) +expand_case_fold_string(Node* node, regex_t* reg) { - StrNode* sn = &NSTRING(node); - int ambig, prev_ambig; - UChar *prev, *p, *end, *prev_start, *start, *tmp, *wp; - Node *root = NULL_NODE; - Node **tailp = (Node** )0; - int r; +#define THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION 8 - start = prev_start = p = sn->s; - end = sn->end; - if (p >= end) return 0; + int r, n, len, alt_num; + UChar *start, *end, *p; + Node *top_root, *root, *snode, *prev_node; + OnigCaseFoldCodeItem items[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM]; + StrNode* sn = NSTR(node); - prev_ambig = ONIGENC_IS_MBC_AMBIGUOUS(reg->enc, reg->ambig_flag, &p, end); + if (NSTRING_IS_AMBIG(node)) return 0; + start = sn->s; + end = sn->end; + if (start >= end) return 0; + + r = 0; + top_root = root = prev_node = snode = NULL_NODE; + alt_num = 1; + p = start; while (p < end) { - prev = p; - if (prev_ambig != (ambig = ONIGENC_IS_MBC_AMBIGUOUS(reg->enc, - reg->ambig_flag, &p, end))) { + n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(reg->enc, reg->case_fold_flag, + p, end, items); + if (n < 0) { + r = n; + goto err; + } + + len = enclen(reg->enc, p); + + if (n == 0) { + if (IS_NULL(snode)) { + if (IS_NULL(root) && IS_NOT_NULL(prev_node)) { + top_root = root = onig_node_list_add(NULL_NODE, prev_node); + if (IS_NULL(root)) { + onig_node_free(prev_node); + goto mem_err; + } + } - r = divide_ambig_string_node_sub(reg, prev_ambig, prev_start, prev, - end, &tailp, &root); - if (r != 0) return r; + prev_node = snode = onig_node_new_str(NULL, NULL); + if (IS_NULL(snode)) goto mem_err; + if (IS_NOT_NULL(root)) { + if (IS_NULL(onig_node_list_add(root, snode))) { + onig_node_free(snode); + goto mem_err; + } + } + } - prev_ambig = ambig; - prev_start = prev; + r = onig_node_str_cat(snode, p, p + len); + if (r != 0) goto err; } - } + else { + alt_num *= (n + 1); + if (alt_num > THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION) break; + + if (IS_NULL(root) && IS_NOT_NULL(prev_node)) { + top_root = root = onig_node_list_add(NULL_NODE, prev_node); + if (IS_NULL(root)) { + onig_node_free(prev_node); + goto mem_err; + } + } - if (prev_start == start) { - if (prev_ambig != 0) { - NSTRING_SET_AMBIG(node); - tmp = start; - wp = start; - while (tmp < end) { - wp += ONIGENC_MBC_TO_NORMALIZE(reg->enc, reg->ambig_flag, - &tmp, end, wp); + r = expand_case_fold_string_alt(n, items, p, len, end, reg, &prev_node); + if (r < 0) goto mem_err; + if (r == 1) { + if (IS_NULL(root)) { + top_root = prev_node; + } + else { + if (IS_NULL(onig_node_list_add(root, prev_node))) { + onig_node_free(prev_node); + goto mem_err; + } + } + + root = NCAR(prev_node); + } + else { /* r == 0 */ + if (IS_NOT_NULL(root)) { + if (IS_NULL(onig_node_list_add(root, prev_node))) { + onig_node_free(prev_node); + goto mem_err; + } + } } - if (wp != sn->end) NSTRING_SET_AMBIG_REDUCE(node); - sn->end = wp; + + snode = NULL_NODE; } + + p += len; } - else { - r = divide_ambig_string_node_sub(reg, prev_ambig, prev_start, end, - end, &tailp, &root); - if (r != 0) return r; - swap_node(node, root); - onig_node_str_clear(root); /* should be after swap! */ - onig_node_free(root); /* free original string node */ + if (p < end) { + Node *srem; + + r = expand_case_fold_make_rem_string(&srem, p, end, reg); + if (r != 0) goto mem_err; + + if (IS_NOT_NULL(prev_node) && IS_NULL(root)) { + top_root = root = onig_node_list_add(NULL_NODE, prev_node); + if (IS_NULL(root)) { + onig_node_free(srem); + onig_node_free(prev_node); + goto mem_err; + } + } + + if (IS_NULL(root)) { + prev_node = srem; + } + else { + if (IS_NULL(onig_node_list_add(root, srem))) { + onig_node_free(srem); + goto mem_err; + } + } } + /* ending */ + top_root = (IS_NOT_NULL(top_root) ? top_root : prev_node); + swap_node(node, top_root); + onig_node_free(top_root); return 0; + + mem_err: + r = ONIGERR_MEMORY; + + err: + onig_node_free(top_root); + return r; } + #ifdef USE_COMBINATION_EXPLOSION_CHECK #define CEC_THRES_NUM_BIG_REPEAT 512 @@ -3305,31 +3516,31 @@ setup_comb_exp_check(Node* node, int state, ScanEnv* env) type = NTYPE(node); switch (type) { - case N_LIST: + case NT_LIST: { Node* prev = NULL_NODE; do { - r = setup_comb_exp_check(NCONS(node).left, r, env); - prev = NCONS(node).left; - } while (r >= 0 && IS_NOT_NULL(node = NCONS(node).right)); + r = setup_comb_exp_check(NCAR(node), r, env); + prev = NCAR(node); + } while (r >= 0 && IS_NOT_NULL(node = NCDR(node))); } break; - case N_ALT: + case NT_ALT: { int ret; do { - ret = setup_comb_exp_check(NCONS(node).left, state, env); + ret = setup_comb_exp_check(NCAR(node), state, env); r |= ret; - } while (ret >= 0 && IS_NOT_NULL(node = NCONS(node).right)); + } while (ret >= 0 && IS_NOT_NULL(node = NCDR(node))); } break; - case N_QUANTIFIER: + case NT_QTFR: { int child_state = state; int add_state = 0; - QuantifierNode* qn = &(NQUANTIFIER(node)); + QtfrNode* qn = NQTFR(node); Node* target = qn->target; int var_num; @@ -3340,11 +3551,11 @@ setup_comb_exp_check(Node* node, int state, ScanEnv* env) /* check (a*){n,m}, (a+){n,m} => (a*){n,n}, (a+){n,n} */ if (env->backrefed_mem == 0) { - if (NTYPE(qn->target) == N_EFFECT) { - EffectNode* en = &(NEFFECT(qn->target)); - if (en->type == EFFECT_MEMORY) { - if (NTYPE(en->target) == N_QUANTIFIER) { - QuantifierNode* q = &(NQUANTIFIER(en->target)); + if (NTYPE(qn->target) == NT_ENCLOSE) { + EncloseNode* en = NENCLOSE(qn->target); + if (en->type == ENCLOSE_MEMORY) { + if (NTYPE(en->target) == NT_QTFR) { + QtfrNode* q = NQTFR(en->target); if (IS_REPEAT_INFINITE(q->upper) && q->greedy == qn->greedy) { qn->upper = (qn->lower == 0 ? 1 : qn->lower); @@ -3390,12 +3601,12 @@ setup_comb_exp_check(Node* node, int state, ScanEnv* env) } break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); + EncloseNode* en = NENCLOSE(node); switch (en->type) { - case EFFECT_MEMORY: + case ENCLOSE_MEMORY: { if (env->curr_max_regnum < en->regnum) env->curr_max_regnum = en->regnum; @@ -3412,11 +3623,11 @@ setup_comb_exp_check(Node* node, int state, ScanEnv* env) break; #ifdef USE_SUBEXP_CALL - case N_CALL: - if (IS_CALL_RECURSION(&(NCALL(node)))) + case NT_CALL: + if (IS_CALL_RECURSION(NCALL(node))) env->has_recursion = 1; else - r = setup_comb_exp_check(NCALL(node).target, state, env); + r = setup_comb_exp_check(NCALL(node)->target, state, env); break; #endif @@ -3449,68 +3660,68 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env) type = NTYPE(node); switch (type) { - case N_LIST: + case NT_LIST: { Node* prev = NULL_NODE; do { - r = setup_tree(NCONS(node).left, reg, state, env); + r = setup_tree(NCAR(node), reg, state, env); if (IS_NOT_NULL(prev) && r == 0) { - r = next_setup(prev, NCONS(node).left, reg); + r = next_setup(prev, NCAR(node), reg); } - prev = NCONS(node).left; - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + prev = NCAR(node); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); } break; - case N_ALT: + case NT_ALT: do { - r = setup_tree(NCONS(node).left, reg, (state | IN_ALT), env); - } while (r == 0 && IS_NOT_NULL(node = NCONS(node).right)); + r = setup_tree(NCAR(node), reg, (state | IN_ALT), env); + } while (r == 0 && IS_NOT_NULL(node = NCDR(node))); break; - case N_CCLASS: + case NT_CCLASS: break; - case N_STRING: + case NT_STR: if (IS_IGNORECASE(reg->options) && !NSTRING_IS_RAW(node)) { - r = divide_ambig_string_node(node, reg); + r = expand_case_fold_string(node, reg); } break; - case N_CTYPE: - case N_ANYCHAR: + case NT_CTYPE: + case NT_CANY: break; #ifdef USE_SUBEXP_CALL - case N_CALL: + case NT_CALL: break; #endif - case N_BACKREF: + case NT_BREF: { int i; int* p; Node** nodes = SCANENV_MEM_NODES(env); - BackrefNode* br = &(NBACKREF(node)); + BRefNode* br = NBREF(node); p = BACKREFS_P(br); for (i = 0; i < br->back_num; i++) { if (p[i] > env->num_mem) return ONIGERR_INVALID_BACKREF; BIT_STATUS_ON_AT(env->backrefed_mem, p[i]); BIT_STATUS_ON_AT(env->bt_mem_start, p[i]); -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL if (IS_BACKREF_NEST_LEVEL(br)) { BIT_STATUS_ON_AT(env->bt_mem_end, p[i]); } #endif - SET_EFFECT_STATUS(nodes[p[i]], NST_MEM_BACKREFED); + SET_ENCLOSE_STATUS(nodes[p[i]], NST_MEM_BACKREFED); } } break; - case N_QUANTIFIER: + case NT_QTFR: { OnigDistance d; - QuantifierNode* qn = &(NQUANTIFIER(node)); + QtfrNode* qn = NQTFR(node); Node* target = qn->target; if ((state & IN_REPEAT) != 0) { @@ -3522,7 +3733,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env) if (r) break; if (d == 0) { qn->target_empty_info = NQ_TARGET_IS_EMPTY; -#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK +#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT r = quantifiers_memory_node_info(target); if (r < 0) break; if (r > 0) { @@ -3535,7 +3746,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env) /* ()* ==> ()?, ()+ ==> () */ qn->upper = 1; if (qn->lower > 1) qn->lower = 1; - if (NTYPE(target) == N_STRING) { + if (NTYPE(target) == NT_STR) { qn->upper = qn->lower = 0; /* /(?:)+/ ==> // */ } } @@ -3551,29 +3762,29 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env) /* expand string */ #define EXPAND_STRING_MAX_LENGTH 100 - if (NTYPE(target) == N_STRING) { + if (NTYPE(target) == NT_STR) { if (!IS_REPEAT_INFINITE(qn->lower) && qn->lower == qn->upper && qn->lower > 1 && qn->lower <= EXPAND_STRING_MAX_LENGTH) { int len = NSTRING_LEN(target); - StrNode* sn = &(NSTRING(target)); + StrNode* sn = NSTR(target); if (len * qn->lower <= EXPAND_STRING_MAX_LENGTH) { int i, n = qn->lower; - onig_node_conv_to_str_node(node, NSTRING(target).flag); + onig_node_conv_to_str_node(node, NSTR(target)->flag); for (i = 0; i < n; i++) { r = onig_node_str_cat(node, sn->s, sn->end); if (r) break; } onig_node_free(target); - break; /* break case N_QUANTIFIER: */ + break; /* break case NT_QTFR: */ } } } #ifdef USE_OP_PUSH_OR_JUMP_EXACT if (qn->greedy && (qn->target_empty_info != 0)) { - if (NTYPE(target) == N_QUANTIFIER) { - QuantifierNode* tqn = &(NQUANTIFIER(target)); + if (NTYPE(target) == NT_QTFR) { + QtfrNode* tqn = NQTFR(target); if (IS_NOT_NULL(tqn->head_exact)) { qn->head_exact = tqn->head_exact; tqn->head_exact = NULL; @@ -3587,39 +3798,39 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env) } break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); + EncloseNode* en = NENCLOSE(node); switch (en->type) { - case EFFECT_OPTION: + case ENCLOSE_OPTION: { OnigOptionType options = reg->options; - reg->options = NEFFECT(node).option; - r = setup_tree(NEFFECT(node).target, reg, state, env); + reg->options = NENCLOSE(node)->option; + r = setup_tree(NENCLOSE(node)->target, reg, state, env); reg->options = options; } break; - case EFFECT_MEMORY: + case ENCLOSE_MEMORY: if ((state & (IN_ALT | IN_NOT | IN_VAR_REPEAT)) != 0) { BIT_STATUS_ON_AT(env->bt_mem_start, en->regnum); - /* SET_EFFECT_STATUS(node, NST_MEM_IN_ALT_NOT); */ + /* SET_ENCLOSE_STATUS(node, NST_MEM_IN_ALT_NOT); */ } r = setup_tree(en->target, reg, state, env); break; - case EFFECT_STOP_BACKTRACK: + case ENCLOSE_STOP_BACKTRACK: { Node* target = en->target; r = setup_tree(target, reg, state, env); - if (NTYPE(target) == N_QUANTIFIER) { - QuantifierNode* tqn = &(NQUANTIFIER(target)); + if (NTYPE(target) == NT_QTFR) { + QtfrNode* tqn = NQTFR(target); if (IS_REPEAT_INFINITE(tqn->upper) && tqn->lower <= 1 && tqn->greedy != 0) { /* (?>a*), a*+ etc... */ int qtype = NTYPE(tqn->target); if (IS_NODE_TYPE_SIMPLE(qtype)) - SET_EFFECT_STATUS(node, NST_STOP_BT_SIMPLE_REPEAT); + SET_ENCLOSE_STATUS(node, NST_STOP_BT_SIMPLE_REPEAT); } } } @@ -3628,9 +3839,9 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env) } break; - case N_ANCHOR: + case NT_ANCHOR: { - AnchorNode* an = &(NANCHOR(node)); + AnchorNode* an = NANCHOR(node); switch (an->type) { case ANCHOR_PREC_READ: @@ -3642,11 +3853,11 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env) /* allowed node types in look-behind */ #define ALLOWED_TYPE_IN_LB \ - ( N_LIST | N_ALT | N_STRING | N_CCLASS | N_CTYPE | \ - N_ANYCHAR | N_ANCHOR | N_EFFECT | N_QUANTIFIER | N_CALL ) + ( BIT_NT_LIST | BIT_NT_ALT | BIT_NT_STR | BIT_NT_CCLASS | BIT_NT_CTYPE | \ + BIT_NT_CANY | BIT_NT_ANCHOR | BIT_NT_ENCLOSE | BIT_NT_QTFR | BIT_NT_CALL ) -#define ALLOWED_EFFECT_IN_LB ( EFFECT_MEMORY ) -#define ALLOWED_EFFECT_IN_LB_NOT 0 +#define ALLOWED_ENCLOSE_IN_LB ( ENCLOSE_MEMORY ) +#define ALLOWED_ENCLOSE_IN_LB_NOT 0 #define ALLOWED_ANCHOR_IN_LB \ ( ANCHOR_LOOK_BEHIND | ANCHOR_BEGIN_LINE | ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION ) @@ -3656,7 +3867,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env) case ANCHOR_LOOK_BEHIND: { r = check_type_tree(an->target, ALLOWED_TYPE_IN_LB, - ALLOWED_EFFECT_IN_LB, ALLOWED_ANCHOR_IN_LB); + ALLOWED_ENCLOSE_IN_LB, ALLOWED_ANCHOR_IN_LB); if (r < 0) return r; if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN; r = setup_look_behind(node, reg, env); @@ -3668,7 +3879,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env) case ANCHOR_LOOK_BEHIND_NOT: { r = check_type_tree(an->target, ALLOWED_TYPE_IN_LB, - ALLOWED_EFFECT_IN_LB_NOT, ALLOWED_ANCHOR_IN_LB_NOT); + ALLOWED_ENCLOSE_IN_LB_NOT, ALLOWED_ANCHOR_IN_LB_NOT); if (r < 0) return r; if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN; r = setup_look_behind(node, reg, env); @@ -3689,7 +3900,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env) /* set skip map for Boyer-Moor search */ static int -set_bm_skip(UChar* s, UChar* end, OnigEncoding enc, +set_bm_skip(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED, UChar skip[], int** int_skip) { int i, len; @@ -3722,11 +3933,11 @@ typedef struct { } MinMaxLen; typedef struct { - MinMaxLen mmd; - OnigEncoding enc; - OnigOptionType options; - OnigAmbigType ambig_flag; - ScanEnv* scan_env; + MinMaxLen mmd; + OnigEncoding enc; + OnigOptionType options; + OnigCaseFoldType case_fold_flag; + ScanEnv* scan_env; } OptEnv; typedef struct { @@ -3778,7 +3989,7 @@ map_position_value(OnigEncoding enc, int i) 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 1 }; - if (i < sizeof(ByteValTable)/sizeof(ByteValTable[0])) { + if (i < (int )(sizeof(ByteValTable)/sizeof(ByteValTable[0]))) { if (i == 0 && ONIGENC_MBC_MINLEN(enc) > 1) return 20; else @@ -3810,7 +4021,7 @@ distance_value(MinMaxLen* mm) if (mm->max == ONIG_INFINITE_DISTANCE) return 0; d = mm->max - mm->min; - if (d < sizeof(dist_vals)/sizeof(dist_vals[0])) + if (d < (int )(sizeof(dist_vals)/sizeof(dist_vals[0]))) /* return dist_vals[d] * 16 / (mm->min + 12); */ return (int )dist_vals[d]; else @@ -4003,7 +4214,7 @@ concat_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OnigEncoding enc) p = add->s; end = p + add->len; for (i = to->len; p < end; ) { - len = enc_len(enc, p); + len = enclen(enc, p); if (i + len > OPT_EXACT_MAXLEN) break; for (j = 0; j < len && p < end; j++) to->s[i++] = *p++; @@ -4018,14 +4229,14 @@ concat_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OnigEncoding enc) } static void -concat_opt_exact_info_str(OptExactInfo* to, - UChar* s, UChar* end, int raw, OnigEncoding enc) +concat_opt_exact_info_str(OptExactInfo* to, UChar* s, UChar* end, + int raw ARG_UNUSED, OnigEncoding enc) { int i, j, len; UChar *p; for (i = to->len, p = s; p < end && i < OPT_EXACT_MAXLEN; ) { - len = enc_len(enc, p); + len = enclen(enc, p); if (i + len > OPT_EXACT_MAXLEN) break; for (j = 0; j < len && p < end; j++) to->s[i++] = *p++; @@ -4051,7 +4262,7 @@ alt_merge_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OptEnv* env) for (i = 0; i < to->len && i < add->len; ) { if (to->s[i] != add->s[i]) break; - len = enc_len(env->enc, to->s + i); + len = enclen(env->enc, to->s + i); for (j = 1; j < len; j++) { if (to->s[i+j] != add->s[i+j]) break; @@ -4146,29 +4357,23 @@ add_char_opt_map_info(OptMapInfo* map, UChar c, OnigEncoding enc) static int add_char_amb_opt_map_info(OptMapInfo* map, UChar* p, UChar* end, - OnigEncoding enc, OnigAmbigType ambig_flag) + OnigEncoding enc, OnigCaseFoldType case_fold_flag) { - int i, n, len; - UChar buf[ONIGENC_MBC_NORMALIZE_MAXLEN]; - OnigCodePoint code; - const OnigPairAmbigCodes* pccs; - OnigAmbigType amb; + OnigCaseFoldCodeItem items[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM]; + UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN]; + int i, n; add_char_opt_map_info(map, p[0], enc); - code = ONIGENC_MBC_TO_CODE(enc, p, end); - for (amb = 0x01; amb <= ONIGENC_AMBIGUOUS_MATCH_LIMIT; amb <<= 1) { - if ((amb & ambig_flag) == 0) continue; + case_fold_flag = DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag); + n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, case_fold_flag, p, end, items); + if (n < 0) return n; - n = ONIGENC_GET_ALL_PAIR_AMBIG_CODES(enc, amb, &pccs); - for (i = 0; i < n; i++) { - if (pccs[i].from == code) { - len = ONIGENC_CODE_TO_MBC(enc, pccs[i].to, buf); - if (len < 0) return len; - add_char_opt_map_info(map, buf[0], enc); - } - } + for (i = 0; i < n; i++) { + ONIGENC_CODE_TO_MBC(enc, items[i].code[0], buf); + add_char_opt_map_info(map, buf[0], enc); } + return 0; } @@ -4341,7 +4546,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) type = NTYPE(node); switch (type) { - case N_LIST: + case NT_LIST: { OptEnv nenv; NodeOptInfo nopt; @@ -4349,33 +4554,33 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) copy_opt_env(&nenv, env); do { - r = optimize_node_left(NCONS(nd).left, &nopt, &nenv); + r = optimize_node_left(NCAR(nd), &nopt, &nenv); if (r == 0) { add_mml(&nenv.mmd, &nopt.len); concat_left_node_opt_info(env->enc, opt, &nopt); } - } while (r == 0 && IS_NOT_NULL(nd = NCONS(nd).right)); + } while (r == 0 && IS_NOT_NULL(nd = NCDR(nd))); } break; - case N_ALT: + case NT_ALT: { NodeOptInfo nopt; Node* nd = node; do { - r = optimize_node_left(NCONS(nd).left, &nopt, env); + r = optimize_node_left(NCAR(nd), &nopt, env); if (r == 0) { if (nd == node) copy_node_opt_info(opt, &nopt); else alt_merge_node_opt_info(opt, &nopt, env); } - } while ((r == 0) && IS_NOT_NULL(nd = NCONS(nd).right)); + } while ((r == 0) && IS_NOT_NULL(nd = NCDR(nd))); } break; - case N_STRING: + case NT_STR: { - StrNode* sn = &(NSTRING(node)); + StrNode* sn = NSTR(node); int slen = sn->end - sn->s; int is_raw = NSTRING_IS_RAW(node); @@ -4388,25 +4593,26 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) set_mml(&opt->len, slen, slen); } else { - int n, max; + int max; - concat_opt_exact_info_str(&opt->exb, sn->s, sn->end, - is_raw, env->enc); - opt->exb.ignore_case = 1; + if (NSTRING_IS_DONT_GET_OPT_INFO(node)) { + int n = onigenc_strlen(env->enc, sn->s, sn->end); + max = ONIGENC_MBC_MAXLEN_DIST(env->enc) * n; + } + else { + concat_opt_exact_info_str(&opt->exb, sn->s, sn->end, + is_raw, env->enc); + opt->exb.ignore_case = 1; + + if (slen > 0) { + r = add_char_amb_opt_map_info(&opt->map, sn->s, sn->end, + env->enc, env->case_fold_flag); + if (r != 0) break; + } - if (slen > 0) { - r = add_char_amb_opt_map_info(&opt->map, sn->s, sn->end, - env->enc, env->ambig_flag); - if (r != 0) break; + max = slen; } - if (NSTRING_IS_AMBIG_REDUCE(node)) { - n = onigenc_strlen(env->enc, sn->s, sn->end); - max = ONIGENC_MBC_MAXLEN_DIST(env->enc) * n; - } - else { - max = slen; - } set_mml(&opt->len, slen, max); } @@ -4415,14 +4621,14 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) } break; - case N_CCLASS: + case NT_CCLASS: { int i, z; - CClassNode* cc = &(NCCLASS(node)); + CClassNode* cc = NCCLASS(node); /* no need to check ignore case. (setted in setup_tree()) */ - if (IS_NOT_NULL(cc->mbuf) || IS_CCLASS_NOT(cc)) { + if (IS_NOT_NULL(cc->mbuf) || IS_NCCLASS_NOT(cc)) { OnigDistance min = ONIGENC_MBC_MINLEN(env->enc); OnigDistance max = ONIGENC_MBC_MAXLEN_DIST(env->enc); @@ -4431,7 +4637,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) else { for (i = 0; i < SINGLE_BYTE_SIZE; i++) { z = BITSET_AT(cc->bs, i); - if ((z && !IS_CCLASS_NOT(cc)) || (!z && IS_CCLASS_NOT(cc))) { + if ((z && !IS_NCCLASS_NOT(cc)) || (!z && IS_NCCLASS_NOT(cc))) { add_char_opt_map_info(&opt->map, (UChar )i, env->enc); } } @@ -4440,7 +4646,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) } break; - case N_CTYPE: + case NT_CTYPE: { int i, min, max; @@ -4449,21 +4655,22 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) if (max == 1) { min = 1; - switch (NCTYPE(node).type) { - case CTYPE_NOT_WORD: - for (i = 0; i < SINGLE_BYTE_SIZE; i++) { - if (! ONIGENC_IS_CODE_WORD(env->enc, i)) { - add_char_opt_map_info(&opt->map, (UChar )i, env->enc); - } - } - break; - - case CTYPE_WORD: - for (i = 0; i < SINGLE_BYTE_SIZE; i++) { - if (ONIGENC_IS_CODE_WORD(env->enc, i)) { - add_char_opt_map_info(&opt->map, (UChar )i, env->enc); - } - } + switch (NCTYPE(node)->ctype) { + case ONIGENC_CTYPE_WORD: + if (NCTYPE(node)->not != 0) { + for (i = 0; i < SINGLE_BYTE_SIZE; i++) { + if (! ONIGENC_IS_CODE_WORD(env->enc, i)) { + add_char_opt_map_info(&opt->map, (UChar )i, env->enc); + } + } + } + else { + for (i = 0; i < SINGLE_BYTE_SIZE; i++) { + if (ONIGENC_IS_CODE_WORD(env->enc, i)) { + add_char_opt_map_info(&opt->map, (UChar )i, env->enc); + } + } + } break; } } @@ -4474,7 +4681,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) } break; - case N_ANYCHAR: + case NT_CANY: { OnigDistance min = ONIGENC_MBC_MINLEN(env->enc); OnigDistance max = ONIGENC_MBC_MAXLEN_DIST(env->enc); @@ -4482,22 +4689,22 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) } break; - case N_ANCHOR: - switch (NANCHOR(node).type) { + case NT_ANCHOR: + switch (NANCHOR(node)->type) { case ANCHOR_BEGIN_BUF: case ANCHOR_BEGIN_POSITION: case ANCHOR_BEGIN_LINE: case ANCHOR_END_BUF: case ANCHOR_SEMI_END_BUF: case ANCHOR_END_LINE: - add_opt_anc_info(&opt->anc, NANCHOR(node).type); + add_opt_anc_info(&opt->anc, NANCHOR(node)->type); break; case ANCHOR_PREC_READ: { NodeOptInfo nopt; - r = optimize_node_left(NANCHOR(node).target, &nopt, env); + r = optimize_node_left(NANCHOR(node)->target, &nopt, env); if (r == 0) { if (nopt.exb.len > 0) copy_opt_exact_info(&opt->expr, &nopt.exb); @@ -4519,13 +4726,13 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) } break; - case N_BACKREF: + case NT_BREF: { int i; int* backs; OnigDistance min, max, tmin, tmax; Node** nodes = SCANENV_MEM_NODES(env->scan_env); - BackrefNode* br = &(NBACKREF(node)); + BRefNode* br = NBREF(node); if (br->state & NST_RECURSION) { set_mml(&opt->len, 0, ONIG_INFINITE_DISTANCE); @@ -4549,31 +4756,31 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) break; #ifdef USE_SUBEXP_CALL - case N_CALL: - if (IS_CALL_RECURSION(&(NCALL(node)))) + case NT_CALL: + if (IS_CALL_RECURSION(NCALL(node))) set_mml(&opt->len, 0, ONIG_INFINITE_DISTANCE); else { OnigOptionType save = env->options; - env->options = NEFFECT(NCALL(node).target).option; - r = optimize_node_left(NCALL(node).target, opt, env); + env->options = NENCLOSE(NCALL(node)->target)->option; + r = optimize_node_left(NCALL(node)->target, opt, env); env->options = save; } break; #endif - case N_QUANTIFIER: + case NT_QTFR: { int i; OnigDistance min, max; NodeOptInfo nopt; - QuantifierNode* qn = &(NQUANTIFIER(node)); + QtfrNode* qn = NQTFR(node); r = optimize_node_left(qn->target, &nopt, env); if (r) break; if (qn->lower == 0 && IS_REPEAT_INFINITE(qn->upper)) { if (env->mmd.max == 0 && - NTYPE(qn->target) == N_ANYCHAR && qn->greedy) { + NTYPE(qn->target) == NT_CANY && qn->greedy) { if (IS_MULTILINE(env->options)) add_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_STAR_ML); else @@ -4585,7 +4792,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) copy_node_opt_info(opt, &nopt); if (nopt.exb.len > 0) { if (nopt.exb.reach_end) { - for (i = 2; i < qn->lower && + for (i = 2; i <= qn->lower && ! is_full_opt_exact_info(&opt->exb); i++) { concat_opt_exact_info(&opt->exb, &nopt.exb, env->enc); } @@ -4614,12 +4821,12 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) } break; - case N_EFFECT: + case NT_ENCLOSE: { - EffectNode* en = &(NEFFECT(node)); + EncloseNode* en = NENCLOSE(node); switch (en->type) { - case EFFECT_OPTION: + case ENCLOSE_OPTION: { OnigOptionType save = env->options; @@ -4629,7 +4836,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) } break; - case EFFECT_MEMORY: + case ENCLOSE_MEMORY: #ifdef USE_SUBEXP_CALL en->opt_count++; if (en->opt_count > MAX_NODE_OPT_INFO_REF_COUNT) { @@ -4637,8 +4844,8 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) min = 0; max = ONIG_INFINITE_DISTANCE; - if (IS_EFFECT_MIN_FIXED(en)) min = en->min_len; - if (IS_EFFECT_MAX_FIXED(en)) max = en->max_len; + if (IS_ENCLOSE_MIN_FIXED(en)) min = en->min_len; + if (IS_ENCLOSE_MAX_FIXED(en)) max = en->max_len; set_mml(&opt->len, min, max); } else @@ -4653,7 +4860,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) } break; - case EFFECT_STOP_BACKTRACK: + case ENCLOSE_STOP_BACKTRACK: r = optimize_node_left(en->target, opt, env); break; } @@ -4681,7 +4888,7 @@ set_optimize_exact_info(regex_t* reg, OptExactInfo* e) if (e->ignore_case) { reg->exact = (UChar* )xmalloc(e->len); - CHECK_NULL_RETURN_VAL(reg->exact, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(reg->exact); xmemcpy(reg->exact, e->s, e->len); reg->exact_end = reg->exact + e->len; reg->optimize = ONIG_OPTIMIZE_EXACT_IC; @@ -4689,8 +4896,8 @@ set_optimize_exact_info(regex_t* reg, OptExactInfo* e) else { int allow_reverse; - reg->exact = k_strdup(e->s, e->s + e->len); - CHECK_NULL_RETURN_VAL(reg->exact, ONIGERR_MEMORY); + reg->exact = str_dup(e->s, e->s + e->len); + CHECK_NULL_RETURN_MEMERR(reg->exact); reg->exact_end = reg->exact + e->len; allow_reverse = @@ -4755,9 +4962,9 @@ set_optimize_info_from_tree(Node* node, regex_t* reg, ScanEnv* scan_env) NodeOptInfo opt; OptEnv env; - env.enc = reg->enc; - env.options = reg->options; - env.ambig_flag = reg->ambig_flag; + env.enc = reg->enc; + env.options = reg->options; + env.case_fold_flag = reg->case_fold_flag; env.scan_env = scan_env; clear_mml(&env.mmd); @@ -4839,7 +5046,7 @@ static void print_enc_string(FILE* fp, OnigEncoding enc, fputc((int )code, fp); } - p += enc_len(enc, p); + p += enclen(enc, p); } } else { @@ -4971,19 +5178,21 @@ print_optimize_info(FILE* f, regex_t* reg) #endif /* ONIG_DEBUG */ -static void +extern void onig_free_body(regex_t* reg) { - if (IS_NOT_NULL(reg->p)) xfree(reg->p); - if (IS_NOT_NULL(reg->exact)) xfree(reg->exact); - if (IS_NOT_NULL(reg->int_map)) xfree(reg->int_map); - if (IS_NOT_NULL(reg->int_map_backward)) xfree(reg->int_map_backward); - if (IS_NOT_NULL(reg->repeat_range)) xfree(reg->repeat_range); - if (IS_NOT_NULL(reg->chain)) onig_free(reg->chain); + if (IS_NOT_NULL(reg)) { + if (IS_NOT_NULL(reg->p)) xfree(reg->p); + if (IS_NOT_NULL(reg->exact)) xfree(reg->exact); + if (IS_NOT_NULL(reg->int_map)) xfree(reg->int_map); + if (IS_NOT_NULL(reg->int_map_backward)) xfree(reg->int_map_backward); + if (IS_NOT_NULL(reg->repeat_range)) xfree(reg->repeat_range); + if (IS_NOT_NULL(reg->chain)) onig_free(reg->chain); #ifdef USE_NAMED_GROUP - onig_names_free(reg); + onig_names_free(reg); #endif + } } extern void @@ -5043,84 +5252,6 @@ onig_chain_reduce(regex_t* reg) } } -#if 0 -extern int -onig_clone(regex_t** to, regex_t* from) -{ - int r, size; - regex_t* reg; - -#ifdef USE_MULTI_THREAD_SYSTEM - if (ONIG_STATE(from) >= ONIG_STATE_NORMAL) { - ONIG_STATE_INC(from); - if (IS_NOT_NULL(from->chain) && ONIG_STATE(reg) == ONIG_STATE_NORMAL) { - onig_chain_reduce(from); - ONIG_STATE_INC(from); - } - } - else { - int n = 0; - while (ONIG_STATE(from) < ONIG_STATE_NORMAL) { - if (++n > THREAD_PASS_LIMIT_COUNT) - return ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT; - THREAD_PASS; - } - ONIG_STATE_INC(from); - } -#endif /* USE_MULTI_THREAD_SYSTEM */ - - r = onig_alloc_init(®, ONIG_OPTION_NONE, ONIGENC_AMBIGUOUS_MATCH_DEFAULT, - from->enc, ONIG_SYNTAX_DEFAULT); - if (r != 0) { - ONIG_STATE_DEC(from); - return r; - } - - xmemcpy(reg, from, sizeof(onig_t)); - reg->chain = (regex_t* )NULL; - reg->state = ONIG_STATE_NORMAL; - - if (from->p) { - reg->p = (UChar* )xmalloc(reg->alloc); - if (IS_NULL(reg->p)) goto mem_error; - xmemcpy(reg->p, from->p, reg->alloc); - } - - if (from->exact) { - reg->exact = (UChar* )xmalloc(from->exact_end - from->exact); - if (IS_NULL(reg->exact)) goto mem_error; - reg->exact_end = reg->exact + (from->exact_end - from->exact); - xmemcpy(reg->exact, from->exact, reg->exact_end - reg->exact); - } - - if (from->int_map) { - size = sizeof(int) * ONIG_CHAR_TABLE_SIZE; - reg->int_map = (int* )xmalloc(size); - if (IS_NULL(reg->int_map)) goto mem_error; - xmemcpy(reg->int_map, from->int_map, size); - } - - if (from->int_map_backward) { - size = sizeof(int) * ONIG_CHAR_TABLE_SIZE; - reg->int_map_backward = (int* )xmalloc(size); - if (IS_NULL(reg->int_map_backward)) goto mem_error; - xmemcpy(reg->int_map_backward, from->int_map_backward, size); - } - -#ifdef USE_NAMED_GROUP - reg->name_table = names_clone(from); /* names_clone is not implemented */ -#endif - - ONIG_STATE_DEC(from); - *to = reg; - return 0; - - mem_error: - ONIG_STATE_DEC(from); - return ONIGERR_MEMORY; -} -#endif - #ifdef ONIG_DEBUG static void print_compiled_byte_code_list P_((FILE* f, regex_t* reg)); #endif @@ -5141,6 +5272,8 @@ onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end, UnsetAddrList uslist; #endif + if (IS_NOT_NULL(einfo)) einfo->par = (UChar* )NULL; + reg->state = ONIG_STATE_COMPILING; #ifdef ONIG_DEBUG @@ -5182,10 +5315,6 @@ onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end, } #endif -#ifdef ONIG_DEBUG_PARSE_TREE - print_tree(stderr, root); -#endif - #ifdef USE_SUBEXP_CALL if (scan_env.num_call > 0) { r = unset_addr_list_init(&uslist, scan_env.num_call); @@ -5207,6 +5336,10 @@ onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end, r = setup_tree(root, reg, 0, &scan_env); if (r != 0) goto err_unset; +#ifdef ONIG_DEBUG_PARSE_TREE + print_tree(stderr, root); +#endif + reg->capture_history = scan_env.capture_history; reg->bt_mem_start = scan_env.bt_mem_start; reg->bt_mem_start |= reg->capture_history; @@ -5308,7 +5441,7 @@ onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end, } } - if (IS_NOT_NULL(root)) onig_node_free(root); + onig_node_free(root); if (IS_NOT_NULL(scan_env.mem_nodes_dynamic)) xfree(scan_env.mem_nodes_dynamic); return r; @@ -5338,12 +5471,16 @@ onig_recompile(regex_t* reg, const UChar* pattern, const UChar* pattern_end, static int onig_inited = 0; extern int -onig_alloc_init(regex_t** reg, OnigOptionType option, OnigAmbigType ambig_flag, - OnigEncoding enc, OnigSyntaxType* syntax) +onig_reg_init(regex_t* reg, OnigOptionType option, + OnigCaseFoldType case_fold_flag, + OnigEncoding enc, OnigSyntaxType* syntax) { if (! onig_inited) onig_init(); + if (IS_NULL(reg)) + return ONIGERR_INVALID_ARGUMENT; + if (ONIGENC_IS_UNDEF(enc)) return ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED; @@ -5352,9 +5489,7 @@ onig_alloc_init(regex_t** reg, OnigOptionType option, OnigAmbigType ambig_flag, return ONIGERR_INVALID_COMBINATION_OF_OPTIONS; } - *reg = (regex_t* )xmalloc(sizeof(regex_t)); - if (IS_NULL(*reg)) return ONIGERR_MEMORY; - (*reg)->state = ONIG_STATE_MODIFY; + (reg)->state = ONIG_STATE_MODIFY; if ((option & ONIG_OPTION_NEGATE_SINGLELINE) != 0) { option |= syntax->options; @@ -5363,24 +5498,36 @@ onig_alloc_init(regex_t** reg, OnigOptionType option, OnigAmbigType ambig_flag, else option |= syntax->options; - (*reg)->enc = enc; - (*reg)->options = option; - (*reg)->syntax = syntax; - (*reg)->optimize = 0; - (*reg)->exact = (UChar* )NULL; - (*reg)->int_map = (int* )NULL; - (*reg)->int_map_backward = (int* )NULL; - (*reg)->chain = (regex_t* )NULL; + (reg)->enc = enc; + (reg)->options = option; + (reg)->syntax = syntax; + (reg)->optimize = 0; + (reg)->exact = (UChar* )NULL; + (reg)->int_map = (int* )NULL; + (reg)->int_map_backward = (int* )NULL; + (reg)->chain = (regex_t* )NULL; + + (reg)->p = (UChar* )NULL; + (reg)->alloc = 0; + (reg)->used = 0; + (reg)->name_table = (void* )NULL; + + (reg)->case_fold_flag = case_fold_flag; + return 0; +} - (*reg)->p = (UChar* )NULL; - (*reg)->alloc = 0; - (*reg)->used = 0; - (*reg)->name_table = (void* )NULL; +extern int +onig_new_without_alloc(regex_t* reg, const UChar* pattern, + const UChar* pattern_end, OnigOptionType option, OnigEncoding enc, + OnigSyntaxType* syntax, OnigErrorInfo* einfo) +{ + int r; - (*reg)->ambig_flag = ambig_flag; - (*reg)->ambig_flag &= ONIGENC_SUPPORT_AMBIG_FLAG(enc); + r = onig_reg_init(reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax); + if (r) return r; - return 0; + r = onig_compile(reg, pattern, pattern_end, einfo); + return r; } extern int @@ -5390,33 +5537,35 @@ onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end, { int r; - if (IS_NOT_NULL(einfo)) einfo->par = (UChar* )NULL; + *reg = (regex_t* )xmalloc(sizeof(regex_t)); + if (IS_NULL(*reg)) return ONIGERR_MEMORY; - r = onig_alloc_init(reg, option, ONIGENC_AMBIGUOUS_MATCH_DEFAULT, - enc, syntax); - if (r) return r; + r = onig_reg_init(*reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax); + if (r) goto err; r = onig_compile(*reg, pattern, pattern_end, einfo); if (r) { + err: onig_free(*reg); *reg = NULL; } return r; } + extern int onig_init(void) { if (onig_inited != 0) return 0; - onig_inited = 1; - THREAD_SYSTEM_INIT; THREAD_ATOMIC_START; + onig_inited = 1; + onigenc_init(); - onigenc_set_default_caseconv_table((UChar* )0); + /* onigenc_set_default_caseconv_table((UChar* )0); */ #ifdef ONIG_DEBUG_STATISTICS onig_statistics_init(); @@ -5430,8 +5579,6 @@ onig_init(void) extern int onig_end(void) { - extern int onig_free_shared_cclass_table(void); - THREAD_ATOMIC_START; #ifdef ONIG_DEBUG_STATISTICS @@ -5442,7 +5589,7 @@ onig_end(void) onig_free_shared_cclass_table(); #endif -#ifdef USE_RECYCLE_NODE +#ifdef USE_PARSE_TREE_NODE_RECYCLE onig_free_node_list(); #endif @@ -5453,6 +5600,64 @@ onig_end(void) return 0; } +extern int +onig_is_in_code_range(const UChar* p, OnigCodePoint code) +{ + OnigCodePoint n, *data; + OnigCodePoint low, high, x; + + GET_CODE_POINT(n, p); + data = (OnigCodePoint* )p; + data++; + + for (low = 0, high = n; low < high; ) { + x = (low + high) >> 1; + if (code > data[x * 2 + 1]) + low = x + 1; + else + high = x; + } + + return ((low < n && code >= data[low * 2]) ? 1 : 0); +} + +extern int +onig_is_code_in_cc_len(int elen, OnigCodePoint code, CClassNode* cc) +{ + int found; + + if (elen > 1 || (code >= SINGLE_BYTE_SIZE)) { + if (IS_NULL(cc->mbuf)) { + found = 0; + } + else { + found = (onig_is_in_code_range(cc->mbuf->p, code) != 0 ? 1 : 0); + } + } + else { + found = (BITSET_AT(cc->bs, code) == 0 ? 0 : 1); + } + + if (IS_NCCLASS_NOT(cc)) + return !found; + else + return found; +} + +extern int +onig_is_code_in_cc(OnigEncoding enc, OnigCodePoint code, CClassNode* cc) +{ + int len; + + if (ONIGENC_MBC_MINLEN(enc) > 1) { + len = 2; + } + else { + len = ONIGENC_CODE_TO_MBCLEN(enc, code); + } + return onig_is_code_in_cc_len(len, code, cc); +} + #ifdef ONIG_DEBUG @@ -5514,7 +5719,7 @@ OnigOpInfoType OnigOpInfo[] = { { OP_BACKREFN_IC, "backrefn-ic", ARG_SPECIAL }, { OP_BACKREF_MULTI, "backref_multi", ARG_SPECIAL }, { OP_BACKREF_MULTI_IC, "backref_multi-ic", ARG_SPECIAL }, - { OP_BACKREF_AT_LEVEL, "backref_at_level", ARG_SPECIAL }, + { OP_BACKREF_WITH_LEVEL, "backref_at_level", ARG_SPECIAL }, { OP_MEMORY_START_PUSH, "mem-start-push", ARG_MEMNUM }, { OP_MEMORY_START, "mem-start", ARG_MEMNUM }, { OP_MEMORY_END_PUSH, "mem-end-push", ARG_MEMNUM }, @@ -5706,7 +5911,7 @@ onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp, break; case OP_EXACT1_IC: - len = enc_len(enc, bp); + len = enclen(enc, bp); p_string(f, len, bp); bp += len; break; @@ -5781,7 +5986,7 @@ onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp, } break; - case OP_BACKREF_AT_LEVEL: + case OP_BACKREF_WITH_LEVEL: { OnigOptionType option; LengthType level; @@ -5889,27 +6094,27 @@ print_indent_tree(FILE* f, Node* node, int indent) type = NTYPE(node); switch (type) { - case N_LIST: - case N_ALT: - if (NTYPE(node) == N_LIST) + case NT_LIST: + case NT_ALT: + if (NTYPE(node) == NT_LIST) fprintf(f, "\n", (int )node); else fprintf(f, "\n", (int )node); - print_indent_tree(f, NCONS(node).left, indent + add); - while (IS_NOT_NULL(node = NCONS(node).right)) { + print_indent_tree(f, NCAR(node), indent + add); + while (IS_NOT_NULL(node = NCDR(node))) { if (NTYPE(node) != type) { fprintf(f, "ERROR: list/alt right is not a cons. %d\n", NTYPE(node)); exit(0); } - print_indent_tree(f, NCONS(node).left, indent + add); + print_indent_tree(f, NCAR(node), indent + add); } break; - case N_STRING: + case NT_STR: fprintf(f, "", (NSTRING_IS_RAW(node) ? "-raw" : ""), (int )node); - for (p = NSTRING(node).s; p < NSTRING(node).end; p++) { + for (p = NSTR(node)->s; p < NSTR(node)->end; p++) { if (*p >= 0x20 && *p < 0x7f) fputc(*p, f); else { @@ -5918,11 +6123,11 @@ print_indent_tree(FILE* f, Node* node, int indent) } break; - case N_CCLASS: + case NT_CCLASS: fprintf(f, "", (int )node); - if (IS_CCLASS_NOT(&NCCLASS(node))) fputs(" not", f); - if (NCCLASS(node).mbuf) { - BBuf* bbuf = NCCLASS(node).mbuf; + if (IS_NCCLASS_NOT(NCCLASS(node))) fputs(" not", f); + if (NCCLASS(node)->mbuf) { + BBuf* bbuf = NCCLASS(node)->mbuf; for (i = 0; i < bbuf->used; i++) { if (i > 0) fprintf(f, ","); fprintf(f, "%0x", bbuf->p[i]); @@ -5930,24 +6135,29 @@ print_indent_tree(FILE* f, Node* node, int indent) } break; - case N_CTYPE: + case NT_CTYPE: fprintf(f, " ", (int )node); - switch (NCTYPE(node).type) { - case CTYPE_WORD: fputs("word", f); break; - case CTYPE_NOT_WORD: fputs("not word", f); break; + switch (NCTYPE(node)->ctype) { + case ONIGENC_CTYPE_WORD: + if (NCTYPE(node)->not != 0) + fputs("not word", f); + else + fputs("word", f); + break; + default: fprintf(f, "ERROR: undefined ctype.\n"); exit(0); } break; - case N_ANYCHAR: + case NT_CANY: fprintf(f, "", (int )node); break; - case N_ANCHOR: + case NT_ANCHOR: fprintf(f, " ", (int )node); - switch (NANCHOR(node).type) { + switch (NANCHOR(node)->type) { case ANCHOR_BEGIN_BUF: fputs("begin buf", f); break; case ANCHOR_END_BUF: fputs("end buf", f); break; case ANCHOR_BEGIN_LINE: fputs("begin line", f); break; @@ -5972,10 +6182,10 @@ print_indent_tree(FILE* f, Node* node, int indent) } break; - case N_BACKREF: + case NT_BREF: { int* p; - BackrefNode* br = &(NBACKREF(node)); + BRefNode* br = NBREF(node); p = BACKREFS_P(br); fprintf(f, "", (int )node); for (i = 0; i < br->back_num; i++) { @@ -5986,33 +6196,33 @@ print_indent_tree(FILE* f, Node* node, int indent) break; #ifdef USE_SUBEXP_CALL - case N_CALL: + case NT_CALL: { - CallNode* cn = &(NCALL(node)); + CallNode* cn = NCALL(node); fprintf(f, "", (int )node); p_string(f, cn->name_end - cn->name, cn->name); } break; #endif - case N_QUANTIFIER: + case NT_QTFR: fprintf(f, "{%d,%d}%s\n", (int )node, - NQUANTIFIER(node).lower, NQUANTIFIER(node).upper, - (NQUANTIFIER(node).greedy ? "" : "?")); - print_indent_tree(f, NQUANTIFIER(node).target, indent + add); + NQTFR(node)->lower, NQTFR(node)->upper, + (NQTFR(node)->greedy ? "" : "?")); + print_indent_tree(f, NQTFR(node)->target, indent + add); break; - case N_EFFECT: - fprintf(f, " ", (int )node); - switch (NEFFECT(node).type) { - case EFFECT_OPTION: - fprintf(f, "option:%d\n", NEFFECT(node).option); - print_indent_tree(f, NEFFECT(node).target, indent + add); + case NT_ENCLOSE: + fprintf(f, " ", (int )node); + switch (NENCLOSE(node)->type) { + case ENCLOSE_OPTION: + fprintf(f, "option:%d\n", NENCLOSE(node)->option); + print_indent_tree(f, NENCLOSE(node)->target, indent + add); break; - case EFFECT_MEMORY: - fprintf(f, "memory:%d", NEFFECT(node).regnum); + case ENCLOSE_MEMORY: + fprintf(f, "memory:%d", NENCLOSE(node)->regnum); break; - case EFFECT_STOP_BACKTRACK: + case ENCLOSE_STOP_BACKTRACK: fprintf(f, "stop-bt"); break; @@ -6020,7 +6230,7 @@ print_indent_tree(FILE* f, Node* node, int indent) break; } fprintf(f, "\n"); - print_indent_tree(f, NEFFECT(node).target, indent + add); + print_indent_tree(f, NENCLOSE(node)->target, indent + add); break; default: @@ -6028,8 +6238,8 @@ print_indent_tree(FILE* f, Node* node, int indent) break; } - if (type != N_LIST && type != N_ALT && type != N_QUANTIFIER && - type != N_EFFECT) + if (type != NT_LIST && type != NT_ALT && type != NT_QTFR && + type != NT_ENCLOSE) fprintf(f, "\n"); fflush(f); } diff --git a/ext/mbstring/oniguruma/regenc.c b/ext/mbstring/oniguruma/regenc.c index 958917e122686..80903508b8c7a 100644 --- a/ext/mbstring/oniguruma/regenc.c +++ b/ext/mbstring/oniguruma/regenc.c @@ -55,7 +55,7 @@ onigenc_get_right_adjust_char_head(OnigEncoding enc, const UChar* start, const U { UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s); if (p < s) { - p += enc_len(enc, p); + p += enclen(enc, p); } return p; } @@ -68,7 +68,7 @@ onigenc_get_right_adjust_char_head_with_prev(OnigEncoding enc, if (p < s) { if (prev) *prev = (const UChar* )p; - p += enc_len(enc, p); + p += enclen(enc, p); } else { if (prev) *prev = (const UChar* )NULL; /* Sorry */ @@ -169,52 +169,7 @@ onigenc_str_bytelen_null(OnigEncoding enc, const UChar* s) } } -#ifndef ONIG_RUBY_M17N - -#ifndef NOT_RUBY - -#define USE_APPLICATION_TO_LOWER_CASE_TABLE - -const unsigned short OnigEnc_Unicode_ISO_8859_1_CtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x228c, 0x2289, 0x2288, 0x2288, 0x2288, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, - 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0288, 0x0008, 0x0008, - 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, - 0x00a0, 0x00a0, 0x10e2, 0x01a0, 0x00a0, 0x00a8, 0x00a0, 0x00a0, - 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x10e2, 0x00a0, 0x01a0, - 0x00a0, 0x10a0, 0x10e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0, - 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0, - 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2 -}; -#endif - -const UChar* OnigEncAsciiToLowerCaseTable = (const UChar* )0; - -#ifndef USE_APPLICATION_TO_LOWER_CASE_TABLE -static const UChar BuiltInAsciiToLowerCaseTable[] = { +const UChar OnigEncAsciiToLowerCaseTable[] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', @@ -248,7 +203,6 @@ static const UChar BuiltInAsciiToLowerCaseTable[] = { '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', }; -#endif /* not USE_APPLICATION_TO_LOWER_CASE_TABLE */ #ifdef USE_UPPER_CASE_TABLE const UChar OnigEncAsciiToUpperCaseTable[256] = { @@ -288,23 +242,22 @@ const UChar OnigEncAsciiToUpperCaseTable[256] = { #endif const unsigned short OnigEncAsciiCtypeTable[256] = { - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, - 0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, - 0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, - 0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, - 0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0, - 0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, - 0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008, - + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, + 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, + 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, + 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, + 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0, + 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, + 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -396,19 +349,10 @@ const UChar OnigEncISO_8859_1_ToUpperCaseTable[256] = { #endif extern void -onigenc_set_default_caseconv_table(const UChar* table) +onigenc_set_default_caseconv_table(const UChar* table ARG_UNUSED) { - if (table == (const UChar* )0) { -#ifndef USE_APPLICATION_TO_LOWER_CASE_TABLE - table = BuiltInAsciiToLowerCaseTable; -#else - return ; -#endif - } - - if (table != OnigEncAsciiToLowerCaseTable) { - OnigEncAsciiToLowerCaseTable = table; - } + /* nothing */ + /* obsoleted. */ } extern UChar* @@ -417,7 +361,7 @@ onigenc_get_left_adjust_char_head(OnigEncoding enc, const UChar* start, const UC return ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s); } -const OnigPairAmbigCodes OnigAsciiPairAmbigCodes[] = { +const OnigPairCaseFoldCodes OnigAsciiLowerMap[] = { { 0x41, 0x61 }, { 0x42, 0x62 }, { 0x43, 0x63 }, @@ -443,157 +387,175 @@ const OnigPairAmbigCodes OnigAsciiPairAmbigCodes[] = { { 0x57, 0x77 }, { 0x58, 0x78 }, { 0x59, 0x79 }, - { 0x5a, 0x7a }, - - { 0x61, 0x41 }, - { 0x62, 0x42 }, - { 0x63, 0x43 }, - { 0x64, 0x44 }, - { 0x65, 0x45 }, - { 0x66, 0x46 }, - { 0x67, 0x47 }, - { 0x68, 0x48 }, - { 0x69, 0x49 }, - { 0x6a, 0x4a }, - { 0x6b, 0x4b }, - { 0x6c, 0x4c }, - { 0x6d, 0x4d }, - { 0x6e, 0x4e }, - { 0x6f, 0x4f }, - { 0x70, 0x50 }, - { 0x71, 0x51 }, - { 0x72, 0x52 }, - { 0x73, 0x53 }, - { 0x74, 0x54 }, - { 0x75, 0x55 }, - { 0x76, 0x56 }, - { 0x77, 0x57 }, - { 0x78, 0x58 }, - { 0x79, 0x59 }, - { 0x7a, 0x5a } + { 0x5a, 0x7a } }; extern int -onigenc_ascii_get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) +onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED, + OnigApplyAllCaseFoldFunc f, void* arg) { - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return (sizeof(OnigAsciiPairAmbigCodes) / sizeof(OnigPairAmbigCodes)); - } - else { - return 0; + OnigCodePoint code; + int i, r; + + for (i = 0; + i < (int )(sizeof(OnigAsciiLowerMap)/sizeof(OnigPairCaseFoldCodes)); + i++) { + code = OnigAsciiLowerMap[i].to; + r = (*f)(OnigAsciiLowerMap[i].from, &code, 1, arg); + if (r != 0) return r; + + code = OnigAsciiLowerMap[i].from; + r = (*f)(OnigAsciiLowerMap[i].to, &code, 1, arg); + if (r != 0) return r; } -} -extern int -onigenc_nothing_get_all_comp_ambig_codes(OnigAmbigType flag, - const OnigCompAmbigCodes** ccs) -{ return 0; } extern int -onigenc_iso_8859_1_get_all_pair_ambig_codes(OnigAmbigType flag, - const OnigPairAmbigCodes** ccs) +onigenc_ascii_get_case_fold_codes_by_str(OnigCaseFoldType flag ARG_UNUSED, + const OnigUChar* p, const OnigUChar* end ARG_UNUSED, + OnigCaseFoldCodeItem items[]) { - static const OnigPairAmbigCodes cc[] = { - { 0xc0, 0xe0 }, - { 0xc1, 0xe1 }, - { 0xc2, 0xe2 }, - { 0xc3, 0xe3 }, - { 0xc4, 0xe4 }, - { 0xc5, 0xe5 }, - { 0xc6, 0xe6 }, - { 0xc7, 0xe7 }, - { 0xc8, 0xe8 }, - { 0xc9, 0xe9 }, - { 0xca, 0xea }, - { 0xcb, 0xeb }, - { 0xcc, 0xec }, - { 0xcd, 0xed }, - { 0xce, 0xee }, - { 0xcf, 0xef }, - - { 0xd0, 0xf0 }, - { 0xd1, 0xf1 }, - { 0xd2, 0xf2 }, - { 0xd3, 0xf3 }, - { 0xd4, 0xf4 }, - { 0xd5, 0xf5 }, - { 0xd6, 0xf6 }, - { 0xd8, 0xf8 }, - { 0xd9, 0xf9 }, - { 0xda, 0xfa }, - { 0xdb, 0xfb }, - { 0xdc, 0xfc }, - { 0xdd, 0xfd }, - { 0xde, 0xfe }, - - { 0xe0, 0xc0 }, - { 0xe1, 0xc1 }, - { 0xe2, 0xc2 }, - { 0xe3, 0xc3 }, - { 0xe4, 0xc4 }, - { 0xe5, 0xc5 }, - { 0xe6, 0xc6 }, - { 0xe7, 0xc7 }, - { 0xe8, 0xc8 }, - { 0xe9, 0xc9 }, - { 0xea, 0xca }, - { 0xeb, 0xcb }, - { 0xec, 0xcc }, - { 0xed, 0xcd }, - { 0xee, 0xce }, - { 0xef, 0xcf }, - - { 0xf0, 0xd0 }, - { 0xf1, 0xd1 }, - { 0xf2, 0xd2 }, - { 0xf3, 0xd3 }, - { 0xf4, 0xd4 }, - { 0xf5, 0xd5 }, - { 0xf6, 0xd6 }, - { 0xf8, 0xd8 }, - { 0xf9, 0xd9 }, - { 0xfa, 0xda }, - { 0xfb, 0xdb }, - { 0xfc, 0xdc }, - { 0xfd, 0xdd }, - { 0xfe, 0xde } - }; - - if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) { - *ccs = OnigAsciiPairAmbigCodes; - return (sizeof(OnigAsciiPairAmbigCodes) / sizeof(OnigPairAmbigCodes)); + if (0x41 <= *p && *p <= 0x5a) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = (OnigCodePoint )(*p + 0x20); + return 1; } - else if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = cc; - return sizeof(cc) / sizeof(OnigPairAmbigCodes); + else if (0x61 <= *p && *p <= 0x7a) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = (OnigCodePoint )(*p - 0x20); + return 1; } else return 0; } +static int +ss_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED, + OnigApplyAllCaseFoldFunc f, void* arg) +{ + static OnigCodePoint ss[] = { 0x73, 0x73 }; + + return (*f)((OnigCodePoint )0xdf, ss, 2, arg); +} + extern int -onigenc_ess_tsett_get_all_comp_ambig_codes(OnigAmbigType flag, - const OnigCompAmbigCodes** ccs) +onigenc_apply_all_case_fold_with_map(int map_size, + const OnigPairCaseFoldCodes map[], + int ess_tsett_flag, OnigCaseFoldType flag, + OnigApplyAllCaseFoldFunc f, void* arg) { - static const OnigCompAmbigCodes folds[] = { - { 2, 0xdf, {{ 2, { 0x53, 0x53 } }, { 2, { 0x73, 0x73} } } } - }; + OnigCodePoint code; + int i, r; + + r = onigenc_ascii_apply_all_case_fold(flag, f, arg); + if (r != 0) return r; - if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) { - *ccs = folds; - return sizeof(folds) / sizeof(OnigCompAmbigCodes); + for (i = 0; i < map_size; i++) { + code = map[i].to; + r = (*f)(map[i].from, &code, 1, arg); + if (r != 0) return r; + + code = map[i].from; + r = (*f)(map[i].to, &code, 1, arg); + if (r != 0) return r; } - else - return 0; + + if (ess_tsett_flag != 0) + return ss_apply_all_case_fold(flag, f, arg); + + return 0; } extern int -onigenc_not_support_get_ctype_code_range(int ctype, - const OnigCodePoint* sbr[], const OnigCodePoint* mbr[]) +onigenc_get_case_fold_codes_by_str_with_map(int map_size, + const OnigPairCaseFoldCodes map[], + int ess_tsett_flag, OnigCaseFoldType flag ARG_UNUSED, + const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]) +{ + if (0x41 <= *p && *p <= 0x5a) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = (OnigCodePoint )(*p + 0x20); + if (*p == 0x53 && ess_tsett_flag != 0 && end > p + 1 + && (*(p+1) == 0x53 || *(p+1) == 0x73)) { + /* SS */ + items[1].byte_len = 2; + items[1].code_len = 1; + items[1].code[0] = (OnigCodePoint )0xdf; + return 2; + } + else + return 1; + } + else if (0x61 <= *p && *p <= 0x7a) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = (OnigCodePoint )(*p - 0x20); + if (*p == 0x73 && ess_tsett_flag != 0 && end > p + 1 + && (*(p+1) == 0x73 || *(p+1) == 0x53)) { + /* ss */ + items[1].byte_len = 2; + items[1].code_len = 1; + items[1].code[0] = (OnigCodePoint )0xdf; + return 2; + } + else + return 1; + } + else if (*p == 0xdf && ess_tsett_flag != 0) { + items[0].byte_len = 1; + items[0].code_len = 2; + items[0].code[0] = (OnigCodePoint )'s'; + items[0].code[1] = (OnigCodePoint )'s'; + + items[1].byte_len = 1; + items[1].code_len = 2; + items[1].code[0] = (OnigCodePoint )'S'; + items[1].code[1] = (OnigCodePoint )'S'; + + items[2].byte_len = 1; + items[2].code_len = 2; + items[2].code[0] = (OnigCodePoint )'s'; + items[2].code[1] = (OnigCodePoint )'S'; + + items[3].byte_len = 1; + items[3].code_len = 2; + items[3].code[0] = (OnigCodePoint )'S'; + items[3].code[1] = (OnigCodePoint )'s'; + + return 4; + } + else { + int i; + + for (i = 0; i < map_size; i++) { + if (*p == map[i].from) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = map[i].to; + return 1; + } + else if (*p == map[i].to) { + items[0].byte_len = 1; + items[0].code_len = 1; + items[0].code[0] = map[i].from; + return 1; + } + } + } + + return 0; +} + + +extern int +onigenc_not_support_get_ctype_code_range(OnigCtype ctype ARG_UNUSED, + OnigCodePoint* sb_out ARG_UNUSED, + const OnigCodePoint* ranges[] ARG_UNUSED) { return ONIG_NO_SUPPORT_CONFIG; } @@ -609,57 +571,43 @@ onigenc_is_mbc_newline_0x0a(const UChar* p, const UChar* end) /* for single byte encodings */ extern int -onigenc_ascii_mbc_to_normalize(OnigAmbigType flag, const UChar** p, const UChar*end, - UChar* lower) +onigenc_ascii_mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, const UChar** p, + const UChar*end ARG_UNUSED, UChar* lower) { - if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { - *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(**p); - } - else { - *lower = **p; - } + *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(**p); (*p)++; return 1; /* return byte length of converted char to lower */ } +#if 0 extern int -onigenc_ascii_is_mbc_ambiguous(OnigAmbigType flag, +onigenc_ascii_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end) { const UChar* p = *pp; (*pp)++; - if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { - return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p); - } - else { - return FALSE; - } + return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p); } +#endif extern int -onigenc_single_byte_mbc_enc_len(const UChar* p) +onigenc_single_byte_mbc_enc_len(const UChar* p ARG_UNUSED) { return 1; } extern OnigCodePoint -onigenc_single_byte_mbc_to_code(const UChar* p, const UChar* end) +onigenc_single_byte_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED) { return (OnigCodePoint )(*p); } extern int -onigenc_single_byte_code_to_mbclen(OnigCodePoint code) -{ - return 1; -} - -extern int -onigenc_single_byte_code_to_mbc_first(OnigCodePoint code) +onigenc_single_byte_code_to_mbclen(OnigCodePoint code ARG_UNUSED) { - return (code & 0xff); + return (code < 0x100 ? 1 : ONIGERR_INVALID_CODE_POINT_VALUE); } extern int @@ -670,19 +618,22 @@ onigenc_single_byte_code_to_mbc(OnigCodePoint code, UChar *buf) } extern UChar* -onigenc_single_byte_left_adjust_char_head(const UChar* start, const UChar* s) +onigenc_single_byte_left_adjust_char_head(const UChar* start ARG_UNUSED, + const UChar* s) { return (UChar* )s; } extern int -onigenc_always_true_is_allowed_reverse_match(const UChar* s, const UChar* end) +onigenc_always_true_is_allowed_reverse_match(const UChar* s ARG_UNUSED, + const UChar* end ARG_UNUSED) { return TRUE; } extern int -onigenc_always_false_is_allowed_reverse_match(const UChar* s, const UChar* end) +onigenc_always_false_is_allowed_reverse_match(const UChar* s ARG_UNUSED, + const UChar* end ARG_UNUSED) { return FALSE; } @@ -693,7 +644,7 @@ onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end) int c, i, len; OnigCodePoint n; - len = enc_len(enc, p); + len = enclen(enc, p); n = (OnigCodePoint )(*p++); if (len == 1) return n; @@ -706,54 +657,46 @@ onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end) } extern int -onigenc_mbn_mbc_to_normalize(OnigEncoding enc, OnigAmbigType flag, - const UChar** pp, const UChar* end, UChar* lower) +onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag ARG_UNUSED, + const UChar** pp, const UChar* end ARG_UNUSED, + UChar* lower) { int len; const UChar *p = *pp; if (ONIGENC_IS_MBC_ASCII(p)) { - if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { - *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); - } - else { - *lower = *p; - } + *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); (*pp)++; return 1; } else { - len = enc_len(enc, p); - if (lower != p) { - int i; - for (i = 0; i < len; i++) { - *lower++ = *p++; - } + int i; + + len = enclen(enc, p); + for (i = 0; i < len; i++) { + *lower++ = *p++; } (*pp) += len; return len; /* return byte length of converted to lower char */ } } +#if 0 extern int -onigenc_mbn_is_mbc_ambiguous(OnigEncoding enc, OnigAmbigType flag, +onigenc_mbn_is_mbc_ambiguous(OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end) { const UChar* p = *pp; if (ONIGENC_IS_MBC_ASCII(p)) { (*pp)++; - if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { - return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p); - } - else { - return FALSE; - } + return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p); } - (*pp) += enc_len(enc, p); + (*pp) += enclen(enc, p); return FALSE; } +#endif extern int onigenc_mb2_code_to_mbclen(OnigCodePoint code) @@ -771,40 +714,6 @@ onigenc_mb4_code_to_mbclen(OnigCodePoint code) else return 1; } -extern int -onigenc_mb2_code_to_mbc_first(OnigCodePoint code) -{ - int first; - - if ((code & 0xff00) != 0) { - first = (code >> 8) & 0xff; - } - else { - return (int )code; - } - return first; -} - -extern int -onigenc_mb4_code_to_mbc_first(OnigCodePoint code) -{ - int first; - - if ((code & 0xff000000) != 0) { - first = (code >> 24) & 0xff; - } - else if ((code & 0xff0000) != 0) { - first = (code >> 16) & 0xff; - } - else if ((code & 0xff00) != 0) { - first = (code >> 8) & 0xff; - } - else { - return (int )code; - } - return first; -} - extern int onigenc_mb2_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf) { @@ -816,8 +725,8 @@ onigenc_mb2_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf) *p++ = (UChar )(code & 0xff); #if 1 - if (enc_len(enc, buf) != (p - buf)) - return ONIGENCERR_INVALID_WIDE_CHAR_VALUE; + if (enclen(enc, buf) != (p - buf)) + return ONIGERR_INVALID_CODE_POINT_VALUE; #endif return p - buf; } @@ -839,12 +748,46 @@ onigenc_mb4_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf) *p++ = (UChar )(code & 0xff); #if 1 - if (enc_len(enc, buf) != (p - buf)) - return ONIGENCERR_INVALID_WIDE_CHAR_VALUE; + if (enclen(enc, buf) != (p - buf)) + return ONIGERR_INVALID_CODE_POINT_VALUE; #endif return p - buf; } +extern int +onigenc_minimum_property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end) +{ + static PosixBracketEntryType PBS[] = { + { (UChar* )"Alnum", ONIGENC_CTYPE_ALNUM, 5 }, + { (UChar* )"Alpha", ONIGENC_CTYPE_ALPHA, 5 }, + { (UChar* )"Blank", ONIGENC_CTYPE_BLANK, 5 }, + { (UChar* )"Cntrl", ONIGENC_CTYPE_CNTRL, 5 }, + { (UChar* )"Digit", ONIGENC_CTYPE_DIGIT, 5 }, + { (UChar* )"Graph", ONIGENC_CTYPE_GRAPH, 5 }, + { (UChar* )"Lower", ONIGENC_CTYPE_LOWER, 5 }, + { (UChar* )"Print", ONIGENC_CTYPE_PRINT, 5 }, + { (UChar* )"Punct", ONIGENC_CTYPE_PUNCT, 5 }, + { (UChar* )"Space", ONIGENC_CTYPE_SPACE, 5 }, + { (UChar* )"Upper", ONIGENC_CTYPE_UPPER, 5 }, + { (UChar* )"XDigit", ONIGENC_CTYPE_XDIGIT, 6 }, + { (UChar* )"ASCII", ONIGENC_CTYPE_ASCII, 5 }, + { (UChar* )"Word", ONIGENC_CTYPE_WORD, 4 }, + { (UChar* )NULL, -1, 0 } + }; + + PosixBracketEntryType *pb; + int len; + + len = onigenc_strlen(enc, p, end); + for (pb = PBS; IS_NOT_NULL(pb->name); pb++) { + if (len == pb->len && + onigenc_with_ascii_strncmp(enc, p, end, pb->name, pb->len) == 0) + return pb->ctype; + } + + return ONIGERR_INVALID_CHAR_PROPERTY_NAME; +} + extern int onigenc_mb2_is_code_ctype(OnigEncoding enc, OnigCodePoint code, unsigned int ctype) @@ -852,8 +795,7 @@ onigenc_mb2_is_code_ctype(OnigEncoding enc, OnigCodePoint code, if (code < 128) return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype); else { - if ((ctype & (ONIGENC_CTYPE_WORD | - ONIGENC_CTYPE_GRAPH | ONIGENC_CTYPE_PRINT)) != 0) { + if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) { return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE); } } @@ -868,8 +810,7 @@ onigenc_mb4_is_code_ctype(OnigEncoding enc, OnigCodePoint code, if (code < 128) return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype); else { - if ((ctype & (ONIGENC_CTYPE_WORD | - ONIGENC_CTYPE_GRAPH | ONIGENC_CTYPE_PRINT)) != 0) { + if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) { return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE); } } @@ -891,138 +832,71 @@ onigenc_with_ascii_strncmp(OnigEncoding enc, const UChar* p, const UChar* end, if (x) return x; sascii++; - p += enc_len(enc, p); + p += enclen(enc, p); } return 0; } -#else /* ONIG_RUBY_M17N */ - -extern int -onigenc_is_code_ctype(OnigEncoding enc, OnigCodePoint code, int ctype) +/* Property management */ +static int +resize_property_list(int new_size, const OnigCodePoint*** plist, int* psize) { - switch (ctype) { - case ONIGENC_CTYPE_NEWLINE: - if (code == 0x0a) return 1; - break; - - case ONIGENC_CTYPE_ALPHA: - return m17n_isalpha(enc, code); - break; - case ONIGENC_CTYPE_BLANK: - return ONIGENC_IS_CODE_BLANK(enc, (int )(code)); - break; - case ONIGENC_CTYPE_CNTRL: - return m17n_iscntrl(enc, code); - break; - case ONIGENC_CTYPE_DIGIT: - return m17n_isdigit(enc, code); - break; - case ONIGENC_CTYPE_GRAPH: - return ONIGENC_IS_CODE_GRAPH(enc, (int )(code)); - break; - case ONIGENC_CTYPE_LOWER: - return m17n_islower(enc, code); - break; - case ONIGENC_CTYPE_PRINT: - return m17n_isprint(enc, code); - break; - case ONIGENC_CTYPE_PUNCT: - return m17n_ispunct(enc, code); - break; - case ONIGENC_CTYPE_SPACE: - return m17n_isspace(enc, code); - break; - case ONIGENC_CTYPE_UPPER: - return m17n_isupper(enc, code); - break; - case ONIGENC_CTYPE_XDIGIT: - return m17n_isxdigit(enc, code); - break; - case ONIGENC_CTYPE_WORD: - return m17n_iswchar(enc, code); - break; - case ONIGENC_CTYPE_ASCII: - return (code < 128 ? TRUE : FALSE); - break; - case ONIGENC_CTYPE_ALNUM: - return m17n_isalnum(enc, code); - break; - default: - break; + int size; + const OnigCodePoint **list = *plist; + + size = sizeof(OnigCodePoint*) * new_size; + if (IS_NULL(list)) { + list = (const OnigCodePoint** )xmalloc(size); + } + else { + list = (const OnigCodePoint** )xrealloc((void* )list, size); } - return 0; -} + if (IS_NULL(list)) return ONIGERR_MEMORY; -extern int -onigenc_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf) -{ - int c, len; + *plist = list; + *psize = new_size; - m17n_mbcput(enc, code, buf); - c = m17n_firstbyte(enc, code); - len = enc_len(enc, c); - return len; + return 0; } extern int -onigenc_mbc_to_lower(OnigEncoding enc, UChar* p, UChar* buf) +onigenc_property_list_add_property(UChar* name, const OnigCodePoint* prop, + hash_table_type **table, const OnigCodePoint*** plist, int *pnum, + int *psize) { - unsigned int c, low; - - c = m17n_codepoint(enc, p, p + enc_len(enc, *p)); - low = m17n_tolower(enc, c); - m17n_mbcput(enc, low, buf); +#define PROP_INIT_SIZE 16 - return m17n_codelen(enc, low); -} + int r; -extern int -onigenc_is_mbc_ambiguous(OnigEncoding enc, OnigAmbigType flag, - UChar** pp, UChar* end) -{ - int len; - unsigned int c; - UChar* p = *pp; + if (*psize <= *pnum) { + int new_size = (*psize == 0 ? PROP_INIT_SIZE : *psize * 2); + r = resize_property_list(new_size, plist, psize); + if (r != 0) return r; + } - len = enc_len(enc, *p); - (*pp) += len; - c = m17n_codepoint(enc, p, p + len); + (*plist)[*pnum] = prop; - if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { - if (m17n_isupper(enc, c) || m17n_islower(enc, c)) - return TRUE; + if (ONIG_IS_NULL(*table)) { + *table = onig_st_init_strend_table_with_size(PROP_INIT_SIZE); + if (ONIG_IS_NULL(*table)) return ONIGERR_MEMORY; } - return FALSE; + *pnum = *pnum + 1; + onig_st_insert_strend(*table, name, name + strlen((char* )name), + (hash_data_type )(*pnum + ONIGENC_MAX_STD_CTYPE)); + return 0; } -extern UChar* -onigenc_get_left_adjust_char_head(OnigEncoding enc, UChar* start, UChar* s) +extern int +onigenc_property_list_init(int (*f)(void)) { - UChar *p; - int len; + int r; - if (s <= start) return s; - p = s; + THREAD_ATOMIC_START; - while (!m17n_islead(enc, *p) && p > start) p--; - while (p + (len = enc_len(enc, *p)) < s) { - p += len; - } - if (p + len == s) return s; - return p; -} + r = f(); -extern int -onigenc_is_allowed_reverse_match(OnigEncoding enc, - const UChar* s, const UChar* end) -{ - return ONIGENC_IS_SINGLEBYTE(enc); + THREAD_ATOMIC_END; + return r; } - -extern void -onigenc_set_default_caseconv_table(UChar* table) { } - -#endif /* ONIG_RUBY_M17N */ diff --git a/ext/mbstring/oniguruma/regenc.h b/ext/mbstring/oniguruma/regenc.h index 58ee3e7f22f0b..40963280dc704 100644 --- a/ext/mbstring/oniguruma/regenc.h +++ b/ext/mbstring/oniguruma/regenc.h @@ -4,7 +4,7 @@ regenc.h - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,11 +29,23 @@ * SUCH DAMAGE. */ -#ifndef RUBY_PLATFORM +#ifndef PACKAGE +/* PACKAGE is defined in config.h */ #include "config.h" #endif + +#ifdef ONIG_ESCAPE_UCHAR_COLLISION +#undef ONIG_ESCAPE_UCHAR_COLLISION +#endif + #include "oniguruma.h" +typedef struct { + OnigCodePoint from; + OnigCodePoint to; +} OnigPairCaseFoldCodes; + + #ifndef NULL #define NULL ((void* )0) #endif @@ -46,45 +58,73 @@ #define FALSE 0 #endif -/* error codes */ -#define ONIGENCERR_MEMORY -5 -#define ONIGENCERR_TYPE_BUG -6 -#define ONIGENCERR_INVALID_WIDE_CHAR_VALUE -400 -#define ONIGENCERR_TOO_BIG_WIDE_CHAR_VALUE -401 +#ifndef ARG_UNUSED +#if defined(__GNUC__) +# define ARG_UNUSED __attribute__ ((unused)) +#else +# define ARG_UNUSED +#endif +#endif #define ONIG_IS_NULL(p) (((void*)(p)) == (void*)0) #define ONIG_IS_NOT_NULL(p) (((void*)(p)) != (void*)0) #define ONIG_CHECK_NULL_RETURN(p) if (ONIG_IS_NULL(p)) return NULL #define ONIG_CHECK_NULL_RETURN_VAL(p,val) if (ONIG_IS_NULL(p)) return (val) - -#ifdef ONIG_RUBY_M17N - -#define ONIG_ENCODING_INIT_DEFAULT ONIG_ENCODING_UNDEF - -#else /* ONIG_RUBY_M17N */ - -#define USE_UNICODE_FULL_RANGE_CTYPE -/* following must not use with USE_CRNL_AS_LINE_TERMINATOR */ +#define enclen(enc,p) ONIGENC_MBC_ENC_LEN(enc,p) + +/* character types bit flag */ +#define BIT_CTYPE_NEWLINE (1<< ONIGENC_CTYPE_NEWLINE) +#define BIT_CTYPE_ALPHA (1<< ONIGENC_CTYPE_ALPHA) +#define BIT_CTYPE_BLANK (1<< ONIGENC_CTYPE_BLANK) +#define BIT_CTYPE_CNTRL (1<< ONIGENC_CTYPE_CNTRL) +#define BIT_CTYPE_DIGIT (1<< ONIGENC_CTYPE_DIGIT) +#define BIT_CTYPE_GRAPH (1<< ONIGENC_CTYPE_GRAPH) +#define BIT_CTYPE_LOWER (1<< ONIGENC_CTYPE_LOWER) +#define BIT_CTYPE_PRINT (1<< ONIGENC_CTYPE_PRINT) +#define BIT_CTYPE_PUNCT (1<< ONIGENC_CTYPE_PUNCT) +#define BIT_CTYPE_SPACE (1<< ONIGENC_CTYPE_SPACE) +#define BIT_CTYPE_UPPER (1<< ONIGENC_CTYPE_UPPER) +#define BIT_CTYPE_XDIGIT (1<< ONIGENC_CTYPE_XDIGIT) +#define BIT_CTYPE_WORD (1<< ONIGENC_CTYPE_WORD) +#define BIT_CTYPE_ALNUM (1<< ONIGENC_CTYPE_ALNUM) +#define BIT_CTYPE_ASCII (1<< ONIGENC_CTYPE_ASCII) + +#define CTYPE_TO_BIT(ctype) (1<<(ctype)) +#define CTYPE_IS_WORD_GRAPH_PRINT(ctype) \ + ((ctype) == ONIGENC_CTYPE_WORD || (ctype) == ONIGENC_CTYPE_GRAPH ||\ + (ctype) == ONIGENC_CTYPE_PRINT) + + +typedef struct { + UChar *name; + int ctype; + short int len; +} PosixBracketEntryType; + + +/* #define USE_CRNL_AS_LINE_TERMINATOR */ +#define USE_UNICODE_PROPERTIES +/* #define USE_UNICODE_CASE_FOLD_TURKISH_AZERI */ /* #define USE_UNICODE_ALL_LINE_TERMINATORS */ /* see Unicode.org UTF#18 */ + #define ONIG_ENCODING_INIT_DEFAULT ONIG_ENCODING_ASCII /* for encoding system implementation (internal) */ -ONIG_EXTERN int onigenc_ascii_get_all_pair_ambig_codes P_((OnigAmbigType flag, const OnigPairAmbigCodes** acs)); -ONIG_EXTERN int onigenc_nothing_get_all_comp_ambig_codes P_((OnigAmbigType flag, const OnigCompAmbigCodes** acs)); -ONIG_EXTERN int onigenc_iso_8859_1_get_all_pair_ambig_codes P_((OnigAmbigType flag, const OnigPairAmbigCodes** acs)); -ONIG_EXTERN int onigenc_ess_tsett_get_all_comp_ambig_codes P_((OnigAmbigType flag, const OnigCompAmbigCodes** acs)); -ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((int ctype, const OnigCodePoint* sbr[], const OnigCodePoint* mbr[])); +ONIG_EXTERN int onigenc_ascii_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg)); +ONIG_EXTERN int onigenc_ascii_get_case_fold_codes_by_str P_((OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])); +ONIG_EXTERN int onigenc_apply_all_case_fold_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg)); +ONIG_EXTERN int onigenc_get_case_fold_codes_by_str_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])); +ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[])); ONIG_EXTERN int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end)); + /* methods for single byte encoding */ -ONIG_EXTERN int onigenc_ascii_mbc_to_normalize P_((OnigAmbigType flag, const UChar** p, const UChar* end, UChar* lower)); -ONIG_EXTERN int onigenc_ascii_is_mbc_ambiguous P_((OnigAmbigType flag, const UChar** p, const UChar* end)); +ONIG_EXTERN int onigenc_ascii_mbc_case_fold P_((OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower)); ONIG_EXTERN int onigenc_single_byte_mbc_enc_len P_((const UChar* p)); ONIG_EXTERN OnigCodePoint onigenc_single_byte_mbc_to_code P_((const UChar* p, const UChar* end)); ONIG_EXTERN int onigenc_single_byte_code_to_mbclen P_((OnigCodePoint code)); -ONIG_EXTERN int onigenc_single_byte_code_to_mbc_first P_((OnigCodePoint code)); ONIG_EXTERN int onigenc_single_byte_code_to_mbc P_((OnigCodePoint code, UChar *buf)); ONIG_EXTERN UChar* onigenc_single_byte_left_adjust_char_head P_((const UChar* start, const UChar* s)); ONIG_EXTERN int onigenc_always_true_is_allowed_reverse_match P_((const UChar* s, const UChar* end)); @@ -92,37 +132,36 @@ ONIG_EXTERN int onigenc_always_false_is_allowed_reverse_match P_((const UChar* s /* methods for multi byte encoding */ ONIG_EXTERN OnigCodePoint onigenc_mbn_mbc_to_code P_((OnigEncoding enc, const UChar* p, const UChar* end)); -ONIG_EXTERN int onigenc_mbn_mbc_to_normalize P_((OnigEncoding enc, OnigAmbigType flag, const UChar** p, const UChar* end, UChar* lower)); -ONIG_EXTERN int onigenc_mbn_is_mbc_ambiguous P_((OnigEncoding enc, OnigAmbigType flag, const UChar** p, const UChar* end)); +ONIG_EXTERN int onigenc_mbn_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower)); ONIG_EXTERN int onigenc_mb2_code_to_mbclen P_((OnigCodePoint code)); -ONIG_EXTERN int onigenc_mb2_code_to_mbc_first P_((OnigCodePoint code)); ONIG_EXTERN int onigenc_mb2_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf)); +ONIG_EXTERN int onigenc_minimum_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end)); +ONIG_EXTERN int onigenc_unicode_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end)); ONIG_EXTERN int onigenc_mb2_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype)); ONIG_EXTERN int onigenc_mb4_code_to_mbclen P_((OnigCodePoint code)); -ONIG_EXTERN int onigenc_mb4_code_to_mbc_first P_((OnigCodePoint code)); ONIG_EXTERN int onigenc_mb4_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf)); ONIG_EXTERN int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype)); -ONIG_EXTERN int onigenc_get_all_fold_match_code_ss_0xdf P_((OnigCodePoint** codes)); /* in enc/unicode.c */ ONIG_EXTERN int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype)); -ONIG_EXTERN int onigenc_unicode_get_ctype_code_range P_((int ctype, const OnigCodePoint* sbr[], const OnigCodePoint* mbr[])); +ONIG_EXTERN int onigenc_utf16_32_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[])); +ONIG_EXTERN int onigenc_unicode_ctype_code_range P_((int ctype, const OnigCodePoint* ranges[])); +ONIG_EXTERN int onigenc_unicode_get_case_fold_codes_by_str P_((OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])); +ONIG_EXTERN int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold)); +ONIG_EXTERN int onigenc_unicode_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg)); + +#define UTF16_IS_SURROGATE_FIRST(c) (((c) & 0xfc) == 0xd8) +#define UTF16_IS_SURROGATE_SECOND(c) (((c) & 0xfc) == 0xdc) #define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \ OnigEncISO_8859_1_ToLowerCaseTable[c] #define ONIGENC_ISO_8859_1_TO_UPPER_CASE(c) \ OnigEncISO_8859_1_ToUpperCaseTable[c] -#define ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(code,ctype) \ - ((OnigEnc_Unicode_ISO_8859_1_CtypeTable[code] & ctype) != 0) ONIG_EXTERN const UChar OnigEncISO_8859_1_ToLowerCaseTable[]; ONIG_EXTERN const UChar OnigEncISO_8859_1_ToUpperCaseTable[]; -ONIG_EXTERN const unsigned short OnigEnc_Unicode_ISO_8859_1_CtypeTable[]; -ONIG_EXTERN const OnigPairAmbigCodes OnigAsciiPairAmbigCodes[]; - -#endif /* is not ONIG_RUBY_M17N */ ONIG_EXTERN int onigenc_with_ascii_strncmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n)); @@ -133,15 +172,18 @@ onigenc_step P_((OnigEncoding enc, const UChar* p, const UChar* end, int n)); extern int onig_is_in_code_range P_((const UChar* p, OnigCodePoint code)); ONIG_EXTERN OnigEncoding OnigEncDefaultCharEncoding; -ONIG_EXTERN const UChar* OnigEncAsciiToLowerCaseTable; +ONIG_EXTERN const UChar OnigEncAsciiToLowerCaseTable[]; ONIG_EXTERN const UChar OnigEncAsciiToUpperCaseTable[]; ONIG_EXTERN const unsigned short OnigEncAsciiCtypeTable[]; +#define ONIGENC_IS_ASCII_CODE(code) ((code) < 0x80) #define ONIGENC_ASCII_CODE_TO_LOWER_CASE(c) OnigEncAsciiToLowerCaseTable[c] #define ONIGENC_ASCII_CODE_TO_UPPER_CASE(c) OnigEncAsciiToUpperCaseTable[c] #define ONIGENC_IS_ASCII_CODE_CTYPE(code,ctype) \ - ((OnigEncAsciiCtypeTable[code] & ctype) != 0) + ((OnigEncAsciiCtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0) #define ONIGENC_IS_ASCII_CODE_CASE_AMBIG(code) \ - ONIGENC_IS_ASCII_CODE_CTYPE(code, (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER)) + (ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_UPPER) ||\ + ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_LOWER)) + #endif /* REGENC_H */ diff --git a/ext/mbstring/oniguruma/regerror.c b/ext/mbstring/oniguruma/regerror.c index d6ec91856d1f4..385e560d98d74 100644 --- a/ext/mbstring/oniguruma/regerror.c +++ b/ext/mbstring/oniguruma/regerror.c @@ -2,7 +2,7 @@ regerror.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,9 +85,9 @@ onig_error_code_to_format(int code) case ONIGERR_END_PATTERN_AT_CONTROL: p = "end pattern at control"; break; case ONIGERR_META_CODE_SYNTAX: - p = "illegal meta-code syntax"; break; + p = "invalid meta-code syntax"; break; case ONIGERR_CONTROL_CODE_SYNTAX: - p = "illegal control-code syntax"; break; + p = "invalid control-code syntax"; break; case ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE: p = "char-class value at end of range"; break; case ONIGERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE: @@ -142,8 +142,8 @@ onig_error_code_to_format(int code) p = "too big wide-char value"; break; case ONIGERR_TOO_LONG_WIDE_CHAR_VALUE: p = "too long wide-char value"; break; - case ONIGERR_INVALID_WIDE_CHAR_VALUE: - p = "invalid wide-char value"; break; + case ONIGERR_INVALID_CODE_POINT_VALUE: + p = "invalid code point value"; break; case ONIGERR_EMPTY_GROUP_NAME: p = "group name is empty"; break; case ONIGERR_INVALID_GROUP_NAME: @@ -182,6 +182,15 @@ onig_error_code_to_format(int code) return (UChar* )p; } +static void sprint_byte(char* s, unsigned int v) +{ + sprintf(s, "%02x", (v & 0377)); +} + +static void sprint_byte_with_x(char* s, unsigned int v) +{ + sprintf(s, "\\x%02x", (v & 0377)); +} static int to_ascii(OnigEncoding enc, UChar *s, UChar *end, UChar buf[], int buf_size, int *is_over) @@ -196,10 +205,17 @@ static int to_ascii(OnigEncoding enc, UChar *s, UChar *end, while (p < end) { code = ONIGENC_MBC_TO_CODE(enc, p, end); if (code >= 0x80) { - if (len + 5 <= buf_size) { - sprintf((char* )(&(buf[len])), "\\%03o", - (unsigned int)(code & 0377)); - len += 5; + if (code > 0xffff && len + 10 <= buf_size) { + sprint_byte_with_x((char*)(&(buf[len])), (unsigned int)(code >> 24)); + sprint_byte((char*)(&(buf[len+4])), (unsigned int)(code >> 16)); + sprint_byte((char*)(&(buf[len+6])), (unsigned int)(code >> 8)); + sprint_byte((char*)(&(buf[len+8])), (unsigned int)code); + len += 10; + } + else if (len + 6 <= buf_size) { + sprint_byte_with_x((char*)(&(buf[len])), (unsigned int)(code >> 8)); + sprint_byte((char*)(&(buf[len+4])), (unsigned int)code); + len += 6; } else { break; @@ -209,7 +225,7 @@ static int to_ascii(OnigEncoding enc, UChar *s, UChar *end, buf[len++] = (UChar )code; } - p += enc_len(enc, p); + p += enclen(enc, p); if (len >= buf_size) break; } @@ -317,7 +333,7 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist) va_list args; va_init_list(args, fmt); - n = vsnprintf((char* )buf, bufsize, (const char* )fmt, args); + n = xvsnprintf((char* )buf, bufsize, (const char* )fmt, args); va_end(args); need = (pat_end - pat) * 4 + 4; @@ -328,17 +344,17 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist) p = pat; while (p < pat_end) { - if (*p == MC_ESC(enc)) { + if (*p == '\\') { *s++ = *p++; - len = enc_len(enc, p); + len = enclen(enc, p); while (len-- > 0) *s++ = *p++; } else if (*p == '/') { - *s++ = (unsigned char )MC_ESC(enc); + *s++ = (unsigned char )'\\'; *s++ = *p++; } else if (ONIGENC_IS_MBC_HEAD(enc, p)) { - len = enc_len(enc, p); + len = enclen(enc, p); if (ONIGENC_MBC_MINLEN(enc) == 1) { while (len-- > 0) *s++ = *p++; } @@ -346,7 +362,7 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist) int blen; while (len-- > 0) { - sprintf((char* )bs, "\\%03o", *p++ & 0377); + sprint_byte_with_x((char* )bs, (unsigned int )(*p++)); blen = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs); bp = bs; while (blen-- > 0) *s++ = *bp++; @@ -355,7 +371,7 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist) } else if (!ONIGENC_IS_CODE_PRINT(enc, *p) && !ONIGENC_IS_CODE_SPACE(enc, *p)) { - sprintf((char* )bs, "\\%03o", *p++ & 0377); + sprint_byte_with_x((char* )bs, (unsigned int )(*p++)); len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs); bp = bs; while (len-- > 0) *s++ = *bp++; diff --git a/ext/mbstring/oniguruma/regexec.c b/ext/mbstring/oniguruma/regexec.c index 918aa67aa88bd..7430d7851491c 100644 --- a/ext/mbstring/oniguruma/regexec.c +++ b/ext/mbstring/oniguruma/regexec.c @@ -2,7 +2,7 @@ regexec.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2007 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,10 +29,12 @@ #include "regint.h" +#define USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE + #ifdef USE_CRNL_AS_LINE_TERMINATOR #define ONIGENC_IS_MBC_CRNL(enc,p,end) \ (ONIGENC_MBC_TO_CODE(enc,p,end) == 13 && \ - ONIGENC_IS_MBC_NEWLINE(enc,(p+enc_len(enc,p)),end)) + ONIGENC_IS_MBC_NEWLINE(enc,(p+enclen(enc,p)),end)) #endif #ifdef USE_CAPTURE_HISTORY @@ -111,7 +113,7 @@ history_tree_add_child(OnigCaptureTreeNode* parent, OnigCaptureTreeNode* child) (OnigCaptureTreeNode** )xrealloc(parent->childs, sizeof(OnigCaptureTreeNode*) * n); } - CHECK_NULL_RETURN_VAL(parent->childs, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(parent->childs); for (i = parent->allocated; i < n; i++) { parent->childs[i] = (OnigCaptureTreeNode* )0; } @@ -196,7 +198,7 @@ onig_region_resize(OnigRegion* region, int n) return 0; } -extern int +static int onig_region_resize_clear(OnigRegion* region, int n) { int r; @@ -297,47 +299,6 @@ onig_region_copy(OnigRegion* to, OnigRegion* from) /** stack **/ #define INVALID_STACK_INDEX -1 -typedef long StackIndex; - -typedef struct _StackType { - unsigned int type; - union { - struct { - UChar *pcode; /* byte code position */ - UChar *pstr; /* string position */ - UChar *pstr_prev; /* previous char position of pstr */ -#ifdef USE_COMBINATION_EXPLOSION_CHECK - unsigned int state_check; -#endif - } state; - struct { - int count; /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */ - UChar *pcode; /* byte code position (head of repeated target) */ - int num; /* repeat id */ - } repeat; - struct { - StackIndex si; /* index of stack */ - } repeat_inc; - struct { - int num; /* memory num */ - UChar *pstr; /* start/end position */ - /* Following information is setted, if this stack type is MEM-START */ - StackIndex start; /* prev. info (for backtrack "(...)*" ) */ - StackIndex end; /* prev. info (for backtrack "(...)*" ) */ - } mem; - struct { - int num; /* null check id */ - UChar *pstr; /* start position */ - } null_check; -#ifdef USE_SUBEXP_CALL - struct { - UChar *ret_addr; /* byte code position */ - int num; /* null check id */ - UChar *pstr; /* string position */ - } call_frame; -#endif - } u; -} StackType; /* stack type */ /* used by normal-POP */ @@ -365,22 +326,6 @@ typedef struct _StackType { #define STK_MASK_TO_VOID_TARGET 0x10ff #define STK_MASK_MEM_END_OR_MARK 0x8000 /* MEM_END or MEM_END_MARK */ -typedef struct { - void* stack_p; - int stack_n; - OnigOptionType options; - OnigRegion* region; - const UChar* start; /* search start position (for \G: BEGIN_POSITION) */ -#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE - int best_len; /* for ONIG_OPTION_FIND_LONGEST */ - UChar* best_s; -#endif -#ifdef USE_COMBINATION_EXPLOSION_CHECK - void* state_check_buff; - int state_check_buff_size; -#endif -} MatchArg; - #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE #define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start) do {\ (msa).stack_p = (void* )0;\ @@ -388,14 +333,14 @@ typedef struct { (msa).region = (arg_region);\ (msa).start = (arg_start);\ (msa).best_len = ONIG_MISMATCH;\ -} while (0) +} while(0) #else #define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start) do {\ (msa).stack_p = (void* )0;\ (msa).options = (arg_option);\ (msa).region = (arg_region);\ (msa).start = (arg_start);\ -} while (0) +} while(0) #endif #ifdef USE_COMBINATION_EXPLOSION_CHECK @@ -424,14 +369,14 @@ typedef struct { (msa).state_check_buff = (void* )0;\ (msa).state_check_buff_size = 0;\ }\ -} while (0) + } while(0) #define MATCH_ARG_FREE(msa) do {\ if ((msa).stack_p) xfree((msa).stack_p);\ if ((msa).state_check_buff_size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) { \ if ((msa).state_check_buff) xfree((msa).state_check_buff);\ }\ -} while (0); +} while(0) #else #define STATE_CHECK_BUFF_INIT(msa, str_len, offset, state_num) #define MATCH_ARG_FREE(msa) if ((msa).stack_p) xfree((msa).stack_p) @@ -442,15 +387,15 @@ typedef struct { #define STACK_INIT(alloc_addr, ptr_num, stack_num) do {\ if (msa->stack_p) {\ alloc_addr = (char* )xalloca(sizeof(char*) * (ptr_num));\ - stk_alloc = (StackType* )(msa->stack_p);\ + stk_alloc = (OnigStackType* )(msa->stack_p);\ stk_base = stk_alloc;\ stk = stk_base;\ stk_end = stk_base + msa->stack_n;\ }\ else {\ alloc_addr = (char* )xalloca(sizeof(char*) * (ptr_num)\ - + sizeof(StackType) * (stack_num));\ - stk_alloc = (StackType* )(alloc_addr + sizeof(char*) * (ptr_num));\ + + sizeof(OnigStackType) * (stack_num));\ + stk_alloc = (OnigStackType* )(alloc_addr + sizeof(char*) * (ptr_num));\ stk_base = stk_alloc;\ stk = stk_base;\ stk_end = stk_base + (stack_num);\ @@ -480,11 +425,11 @@ onig_set_match_stack_limit_size(unsigned int size) } static int -stack_double(StackType** arg_stk_base, StackType** arg_stk_end, - StackType** arg_stk, StackType* stk_alloc, MatchArg* msa) +stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end, + OnigStackType** arg_stk, OnigStackType* stk_alloc, OnigMatchArg* msa) { unsigned int n; - StackType *x, *stk_base, *stk_end, *stk; + OnigStackType *x, *stk_base, *stk_end, *stk; stk_base = *arg_stk_base; stk_end = *arg_stk_end; @@ -492,12 +437,12 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, n = stk_end - stk_base; if (stk_base == stk_alloc && IS_NULL(msa->stack_p)) { - x = (StackType* )xmalloc(sizeof(StackType) * n * 2); + x = (OnigStackType* )xmalloc(sizeof(OnigStackType) * n * 2); if (IS_NULL(x)) { STACK_SAVE; return ONIGERR_MEMORY; } - xmemcpy(x, stk_base, n * sizeof(StackType)); + xmemcpy(x, stk_base, n * sizeof(OnigStackType)); n *= 2; } else { @@ -508,7 +453,7 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, else n = MatchStackLimitSize; } - x = (StackType* )xrealloc(stk_base, sizeof(StackType) * n); + x = (OnigStackType* )xrealloc(stk_base, sizeof(OnigStackType) * n); if (IS_NULL(x)) { STACK_SAVE; return ONIGERR_MEMORY; @@ -680,7 +625,7 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, level--;\ }\ }\ -} while (0) +} while(0) #define STACK_GET_MEM_RANGE(k, mnum, start, end) do {\ int level = 0;\ @@ -698,7 +643,7 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, }\ k++;\ }\ -} while (0) +} while(0) #define STACK_PUSH_NULL_CHECK_START(cnum, s) do {\ STACK_ENSURE(1);\ @@ -844,7 +789,7 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, } while(0) #define STACK_STOP_BT_END do {\ - StackType *k = stk;\ + OnigStackType *k = stk;\ while (1) {\ k--;\ STACK_BASE_CHECK(k, "STACK_STOP_BT_END"); \ @@ -859,7 +804,7 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, } while(0) #define STACK_NULL_CHECK(isnull,id,s) do {\ - StackType* k = stk;\ + OnigStackType* k = stk;\ while (1) {\ k--;\ STACK_BASE_CHECK(k, "STACK_NULL_CHECK"); \ @@ -874,7 +819,7 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, #define STACK_NULL_CHECK_REC(isnull,id,s) do {\ int level = 0;\ - StackType* k = stk;\ + OnigStackType* k = stk;\ while (1) {\ k--;\ STACK_BASE_CHECK(k, "STACK_NULL_CHECK_REC"); \ @@ -894,7 +839,7 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, } while(0) #define STACK_NULL_CHECK_MEMST(isnull,id,s,reg) do {\ - StackType* k = stk;\ + OnigStackType* k = stk;\ while (1) {\ k--;\ STACK_BASE_CHECK(k, "STACK_NULL_CHECK_MEMST"); \ @@ -934,7 +879,7 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, #define STACK_NULL_CHECK_MEMST_REC(isnull,id,s,reg) do {\ int level = 0;\ - StackType* k = stk;\ + OnigStackType* k = stk;\ while (1) {\ k--;\ STACK_BASE_CHECK(k, "STACK_NULL_CHECK_MEMST_REC"); \ @@ -996,11 +941,11 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, else if (k->type == STK_CALL_FRAME) level--;\ else if (k->type == STK_RETURN) level++;\ }\ -} while (0) +} while(0) #define STACK_RETURN(addr) do {\ int level = 0;\ - StackType* k = stk;\ + OnigStackType* k = stk;\ while (1) {\ k--;\ STACK_BASE_CHECK(k, "STACK_RETURN"); \ @@ -1023,25 +968,25 @@ stack_double(StackType** arg_stk_base, StackType** arg_stk_end, }\ } while(0) -#define STRING_CMP_IC(ambig_flag,s1,ps2,len) do {\ - if (string_cmp_ic(encode, ambig_flag, s1, ps2, len) == 0) \ +#define STRING_CMP_IC(case_fold_flag,s1,ps2,len) do {\ + if (string_cmp_ic(encode, case_fold_flag, s1, ps2, len) == 0) \ goto fail; \ } while(0) -static int string_cmp_ic(OnigEncoding enc, int ambig_flag, +static int string_cmp_ic(OnigEncoding enc, int case_fold_flag, UChar* s1, UChar** ps2, int mblen) { - UChar buf1[ONIGENC_MBC_NORMALIZE_MAXLEN]; - UChar buf2[ONIGENC_MBC_NORMALIZE_MAXLEN]; - UChar *p1, *p2, *end, *s2, *end2; + UChar buf1[ONIGENC_MBC_CASE_FOLD_MAXLEN]; + UChar buf2[ONIGENC_MBC_CASE_FOLD_MAXLEN]; + UChar *p1, *p2, *end1, *s2, *end2; int len1, len2; s2 = *ps2; - end = s1 + mblen; + end1 = s1 + mblen; end2 = s2 + mblen; - while (s1 < end) { - len1 = ONIGENC_MBC_TO_NORMALIZE(enc, ambig_flag, &s1, end, buf1); - len2 = ONIGENC_MBC_TO_NORMALIZE(enc, ambig_flag, &s2, end2, buf2); + while (s1 < end1) { + len1 = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &s1, end1, buf1); + len2 = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &s2, end2, buf2); if (len1 != len2) return 0; p1 = buf1; p2 = buf2; @@ -1065,31 +1010,36 @@ static int string_cmp_ic(OnigEncoding enc, int ambig_flag, }\ } while(0) -#define STRING_CMP_VALUE_IC(ambig_flag,s1,ps2,len,is_fail) do {\ - if (string_cmp_ic(encode, ambig_flag, s1, ps2, len) == 0) \ +#define STRING_CMP_VALUE_IC(case_fold_flag,s1,ps2,len,is_fail) do {\ + if (string_cmp_ic(encode, case_fold_flag, s1, ps2, len) == 0) \ is_fail = 1; \ else \ is_fail = 0; \ } while(0) -#define ON_STR_BEGIN(s) ((s) == str) -#define ON_STR_END(s) ((s) == end) -#define IS_EMPTY_STR (str == end) - -#define DATA_ENSURE(n) \ - if (s + (n) > end) goto fail - +#define IS_EMPTY_STR (str == end) +#define ON_STR_BEGIN(s) ((s) == str) +#define ON_STR_END(s) ((s) == end) +#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE +#define DATA_ENSURE_CHECK1 (s < right_range) +#define DATA_ENSURE_CHECK(n) (s + (n) <= right_range) +#define DATA_ENSURE(n) if (s + (n) > right_range) goto fail +#else +#define DATA_ENSURE_CHECK1 (s < end) #define DATA_ENSURE_CHECK(n) (s + (n) <= end) +#define DATA_ENSURE(n) if (s + (n) > end) goto fail +#endif /* USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE */ + #ifdef USE_CAPTURE_HISTORY static int -make_capture_history_tree(OnigCaptureTreeNode* node, StackType** kp, - StackType* stk_top, UChar* str, regex_t* reg) +make_capture_history_tree(OnigCaptureTreeNode* node, OnigStackType** kp, + OnigStackType* stk_top, UChar* str, regex_t* reg) { int n, r; OnigCaptureTreeNode* child; - StackType* k = *kp; + OnigStackType* k = *kp; while (k < stk_top) { if (k->type == STK_MEM_START) { @@ -1097,7 +1047,7 @@ make_capture_history_tree(OnigCaptureTreeNode* node, StackType** kp, if (n <= ONIG_MAX_CAPTURE_HISTORY_GROUP && BIT_STATUS_AT(reg->capture_history, n) != 0) { child = history_node_new(); - CHECK_NULL_RETURN_VAL(child, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(child); child->group = n; child->beg = (int )(k->u.mem.pstr - str); r = history_tree_add_child(node, child); @@ -1124,7 +1074,7 @@ make_capture_history_tree(OnigCaptureTreeNode* node, StackType** kp, } #endif -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL static int mem_is_in_memp(int mem, int num, UChar* memp) { int i; @@ -1138,13 +1088,13 @@ static int mem_is_in_memp(int mem, int num, UChar* memp) } static int backref_match_at_nested_level(regex_t* reg - , StackType* top, StackType* stk_base - , int ignore_case, int ambig_flag + , OnigStackType* top, OnigStackType* stk_base + , int ignore_case, int case_fold_flag , int nest, int mem_num, UChar* memp, UChar** s, const UChar* send) { UChar *ss, *p, *pstart, *pend = NULL_UCHARP; int level; - StackType* k; + OnigStackType* k; level = 0; k = top; @@ -1166,7 +1116,7 @@ static int backref_match_at_nested_level(regex_t* reg ss = *s; if (ignore_case != 0) { - if (string_cmp_ic(reg->enc, ambig_flag, + if (string_cmp_ic(reg->enc, case_fold_flag, pstart, &ss, (int )(pend - pstart)) == 0) return 0; /* or goto next_mem; */ } @@ -1192,70 +1142,8 @@ static int backref_match_at_nested_level(regex_t* reg return 0; } -#endif /* USE_BACKREF_AT_LEVEL */ - - -#ifdef RUBY_PLATFORM - -typedef struct { - int state; - regex_t* reg; - MatchArg* msa; - StackType* stk_base; -} TrapEnsureArg; - -static VALUE -trap_ensure(VALUE arg) -{ - TrapEnsureArg* ta = (TrapEnsureArg* )arg; - - if (ta->state == 0) { /* trap_exec() is not normal return */ - ONIG_STATE_DEC_THREAD(ta->reg); - if (! IS_NULL(ta->msa->stack_p) && ta->stk_base != ta->msa->stack_p) - xfree(ta->stk_base); - - MATCH_ARG_FREE(*(ta->msa)); - } - - return Qnil; -} +#endif /* USE_BACKREF_WITH_LEVEL */ -static VALUE -trap_exec(VALUE arg) -{ - TrapEnsureArg* ta; - - rb_trap_exec(); - - ta = (TrapEnsureArg* )arg; - ta->state = 1; /* normal return */ - return Qnil; -} - -extern void -onig_exec_trap(regex_t* reg, MatchArg* msa, StackType* stk_base) -{ - VALUE arg; - TrapEnsureArg ta; - - ta.state = 0; - ta.reg = reg; - ta.msa = msa; - ta.stk_base = stk_base; - arg = (VALUE )(&ta); - rb_ensure(trap_exec, arg, trap_ensure, arg); -} - -#define CHECK_INTERRUPT_IN_MATCH_AT do {\ - if (rb_trap_pending) {\ - if (! rb_prohibit_interrupt) {\ - onig_exec_trap(reg, msa, stk_base);\ - }\ - }\ -} while (0) -#else -#define CHECK_INTERRUPT_IN_MATCH_AT -#endif /* RUBY_PLATFORM */ #ifdef ONIG_DEBUG_STATISTICS @@ -1288,41 +1176,26 @@ static int OpCurr = OP_FINISH; static int OpPrevTarget = OP_FAIL; static int MaxStackDepth = 0; -#define STAT_OP_IN(opcode) do {\ +#define MOP_IN(opcode) do {\ if (opcode == OpPrevTarget) OpPrevCounter[OpCurr]++;\ OpCurr = opcode;\ OpCounter[opcode]++;\ GETTIME(ts);\ -} while (0) +} while(0) -#define STAT_OP_OUT do {\ +#define MOP_OUT do {\ GETTIME(te);\ OpTime[OpCurr] += TIMEDIFF(te, ts);\ -} while (0) - -#ifdef RUBY_PLATFORM - -/* - * :nodoc: - */ -static VALUE onig_stat_print(void) -{ - onig_print_statistics(stderr); - return Qnil; -} -#endif +} while(0) -extern void onig_statistics_init(void) +extern void +onig_statistics_init(void) { int i; for (i = 0; i < 256; i++) { OpCounter[i] = OpPrevCounter[i] = 0; OpTime[i] = 0; } MaxStackDepth = 0; - -#ifdef RUBY_PLATFORM - rb_define_global_function("onig_stat_print", onig_stat_print, 0); -#endif } extern void @@ -1341,73 +1214,15 @@ onig_print_statistics(FILE* f) stk++;\ if (stk - stk_base > MaxStackDepth) \ MaxStackDepth = stk - stk_base;\ -} while (0) +} while(0) #else #define STACK_INC stk++ -#define STAT_OP_IN(opcode) -#define STAT_OP_OUT +#define MOP_IN(opcode) +#define MOP_OUT #endif -extern int -onig_is_in_code_range(const UChar* p, OnigCodePoint code) -{ - OnigCodePoint n, *data; - OnigCodePoint low, high, x; - - GET_CODE_POINT(n, p); - data = (OnigCodePoint* )p; - data++; - - for (low = 0, high = n; low < high; ) { - x = (low + high) >> 1; - if (code > data[x * 2 + 1]) - low = x + 1; - else - high = x; - } - - return ((low < n && code >= data[low * 2]) ? 1 : 0); -} - -static int -is_code_in_cc(int enclen, OnigCodePoint code, CClassNode* cc) -{ - int found; - - if (enclen > 1 || (code >= SINGLE_BYTE_SIZE)) { - if (IS_NULL(cc->mbuf)) { - found = 0; - } - else { - found = (onig_is_in_code_range(cc->mbuf->p, code) != 0 ? 1 : 0); - } - } - else { - found = (BITSET_AT(cc->bs, code) == 0 ? 0 : 1); - } - - if (IS_CCLASS_NOT(cc)) - return !found; - else - return found; -} - -extern int -onig_is_code_in_cc(OnigEncoding enc, OnigCodePoint code, CClassNode* cc) -{ - int len; - - if (ONIGENC_MBC_MINLEN(enc) > 1) { - len = 2; - } - else { - len = ONIGENC_CODE_TO_MBCLEN(enc, code); - } - return is_code_in_cc(len, code, cc); -} - /* matching region of POSIX API */ typedef int regoff_t; @@ -1420,8 +1235,11 @@ typedef struct { /* match data(str - end) from position (sstart). */ /* if sstart == str then set sprev to NULL. */ static int -match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, - UChar* sprev, MatchArg* msa) +match_at(regex_t* reg, const UChar* str, const UChar* end, +#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE + const UChar* right_range, +#endif + const UChar* sstart, UChar* sprev, OnigMatchArg* msa) { static UChar FinishCode[] = { OP_FINISH }; @@ -1431,15 +1249,15 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, RelAddrType addr; OnigOptionType option = reg->options; OnigEncoding encode = reg->enc; - OnigAmbigType ambig_flag = reg->ambig_flag; + OnigCaseFoldType case_fold_flag = reg->case_fold_flag; UChar *s, *q, *sbegin; UChar *p = reg->p; char *alloca_base; - StackType *stk_alloc, *stk_base, *stk, *stk_end; - StackType *stkp; /* used as any purpose. */ - StackIndex si; - StackIndex *repeat_stk; - StackIndex *mem_start_stk, *mem_end_stk; + OnigStackType *stk_alloc, *stk_base, *stk, *stk_end; + OnigStackType *stkp; /* used as any purpose. */ + OnigStackIndex si; + OnigStackIndex *repeat_stk; + OnigStackIndex *mem_start_stk, *mem_end_stk; #ifdef USE_COMBINATION_EXPLOSION_CHECK int scv; unsigned char* state_check_buff = msa->state_check_buff; @@ -1450,9 +1268,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, STACK_INIT(alloca_base, n, INIT_MATCH_STACK_SIZE); pop_level = reg->stack_pop_level; num_mem = reg->num_mem; - repeat_stk = (StackIndex* )alloca_base; + repeat_stk = (OnigStackIndex* )alloca_base; - mem_start_stk = (StackIndex* )(repeat_stk + reg->num_repeat); + mem_start_stk = (OnigStackIndex* )(repeat_stk + reg->num_repeat); mem_end_stk = mem_start_stk + num_mem; mem_start_stk--; /* for index start from 1, mem_start_stk[1]..mem_start_stk[num_mem] */ @@ -1480,13 +1298,13 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, fprintf(stderr, "%4d> \"", (int )(s - str)); bp = buf; for (i = 0, q = s; i < 7 && q < end; i++) { - len = enc_len(encode, q); + len = enclen(encode, q); while (len-- > 0) *bp++ = *q++; } if (q < end) { xmemcpy(bp, "...\"", 4); bp += 4; } else { xmemcpy(bp, "\"", 1); bp += 1; } *bp = 0; - fputs(buf, stderr); + fputs((char* )buf, stderr); for (i = 0; i < 20 - (bp - buf); i++) fputc(' ', stderr); onig_print_compiled_byte_code(stderr, p, NULL, encode); fprintf(stderr, "\n"); @@ -1495,7 +1313,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, sbegin = s; switch (*p++) { - case OP_END: STAT_OP_IN(OP_END); + case OP_END: MOP_IN(OP_END); n = s - sstart; if (n > best_len) { OnigRegion* region; @@ -1512,7 +1330,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, best_len = n; region = msa->region; if (region) { -#ifdef USE_POSIX_REGION_OPTION +#ifdef USE_POSIX_API_REGION_OPTION if (IS_POSIX_REGION(msa->options)) { posix_regmatch_t* rmt = (posix_regmatch_t* )region; @@ -1535,7 +1353,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, } } else { -#endif /* USE_POSIX_REGION_OPTION */ +#endif /* USE_POSIX_API_REGION_OPTION */ region->beg[0] = sstart - str; region->end[0] = s - str; for (i = 1; i <= num_mem; i++) { @@ -1561,7 +1379,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, if (IS_NULL(region->history_root)) { region->history_root = node = history_node_new(); - CHECK_NULL_RETURN_VAL(node, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(node); } else { node = region->history_root; @@ -1581,7 +1399,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, } } #endif /* USE_CAPTURE_HISTORY */ -#ifdef USE_POSIX_REGION_OPTION +#ifdef USE_POSIX_API_REGION_OPTION } /* else IS_POSIX_REGION() */ #endif } /* if (region) */ @@ -1590,14 +1408,14 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE end_best_len: #endif - STAT_OP_OUT; + MOP_OUT; if (IS_FIND_CONDITION(option)) { if (IS_FIND_NOT_EMPTY(option) && s == sstart) { best_len = ONIG_MISMATCH; goto fail; /* for retry */ } - if (IS_FIND_LONGEST(option) && s < end) { + if (IS_FIND_LONGEST(option) && DATA_ENSURE_CHECK1) { goto fail; /* for retry */ } } @@ -1606,7 +1424,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, goto finish; break; - case OP_EXACT1: STAT_OP_IN(OP_EXACT1); + case OP_EXACT1: MOP_IN(OP_EXACT1); #if 0 DATA_ENSURE(1); if (*p != *s) goto fail; @@ -1615,19 +1433,19 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, if (*p != *s++) goto fail; DATA_ENSURE(0); p++; - STAT_OP_OUT; + MOP_OUT; break; - case OP_EXACT1_IC: STAT_OP_IN(OP_EXACT1_IC); + case OP_EXACT1_IC: MOP_IN(OP_EXACT1_IC); { int len; - UChar *q, *ss, *sp, lowbuf[ONIGENC_MBC_NORMALIZE_MAXLEN]; + UChar *q, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN]; DATA_ENSURE(1); - ss = s; - sp = p; - - len = ONIGENC_MBC_TO_NORMALIZE(encode, ambig_flag, &s, end, lowbuf); + len = ONIGENC_MBC_CASE_FOLD(encode, + /* DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag), */ + case_fold_flag, + &s, end, lowbuf); DATA_ENSURE(0); q = lowbuf; while (len-- > 0) { @@ -1637,21 +1455,21 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, p++; q++; } } - STAT_OP_OUT; + MOP_OUT; break; - case OP_EXACT2: STAT_OP_IN(OP_EXACT2); + case OP_EXACT2: MOP_IN(OP_EXACT2); DATA_ENSURE(2); if (*p != *s) goto fail; p++; s++; if (*p != *s) goto fail; sprev = s; p++; s++; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_EXACT3: STAT_OP_IN(OP_EXACT3); + case OP_EXACT3: MOP_IN(OP_EXACT3); DATA_ENSURE(3); if (*p != *s) goto fail; p++; s++; @@ -1660,11 +1478,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, if (*p != *s) goto fail; sprev = s; p++; s++; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_EXACT4: STAT_OP_IN(OP_EXACT4); + case OP_EXACT4: MOP_IN(OP_EXACT4); DATA_ENSURE(4); if (*p != *s) goto fail; p++; s++; @@ -1675,11 +1493,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, if (*p != *s) goto fail; sprev = s; p++; s++; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_EXACT5: STAT_OP_IN(OP_EXACT5); + case OP_EXACT5: MOP_IN(OP_EXACT5); DATA_ENSURE(5); if (*p != *s) goto fail; p++; s++; @@ -1692,25 +1510,25 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, if (*p != *s) goto fail; sprev = s; p++; s++; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_EXACTN: STAT_OP_IN(OP_EXACTN); + case OP_EXACTN: MOP_IN(OP_EXACTN); GET_LENGTH_INC(tlen, p); DATA_ENSURE(tlen); while (tlen-- > 0) { if (*p++ != *s++) goto fail; } sprev = s - 1; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_EXACTN_IC: STAT_OP_IN(OP_EXACTN_IC); + case OP_EXACTN_IC: MOP_IN(OP_EXACTN_IC); { int len; - UChar *ss, *sp, *q, *endp, lowbuf[ONIGENC_MBC_NORMALIZE_MAXLEN]; + UChar *q, *endp, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN]; GET_LENGTH_INC(tlen, p); endp = p + tlen; @@ -1718,35 +1536,33 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, while (p < endp) { sprev = s; DATA_ENSURE(1); - ss = s; - sp = p; - - len = ONIGENC_MBC_TO_NORMALIZE(encode, ambig_flag, &s, end, lowbuf); + len = ONIGENC_MBC_CASE_FOLD(encode, + /* DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag), */ + case_fold_flag, + &s, end, lowbuf); DATA_ENSURE(0); q = lowbuf; while (len-- > 0) { - if (*p != *q) { - goto fail; - } + if (*p != *q) goto fail; p++; q++; } } } - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_EXACTMB2N1: STAT_OP_IN(OP_EXACTMB2N1); + case OP_EXACTMB2N1: MOP_IN(OP_EXACTMB2N1); DATA_ENSURE(2); if (*p != *s) goto fail; p++; s++; if (*p != *s) goto fail; p++; s++; - STAT_OP_OUT; + MOP_OUT; break; - case OP_EXACTMB2N2: STAT_OP_IN(OP_EXACTMB2N2); + case OP_EXACTMB2N2: MOP_IN(OP_EXACTMB2N2); DATA_ENSURE(4); if (*p != *s) goto fail; p++; s++; @@ -1757,11 +1573,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, p++; s++; if (*p != *s) goto fail; p++; s++; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_EXACTMB2N3: STAT_OP_IN(OP_EXACTMB2N3); + case OP_EXACTMB2N3: MOP_IN(OP_EXACTMB2N3); DATA_ENSURE(6); if (*p != *s) goto fail; p++; s++; @@ -1776,11 +1592,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, p++; s++; if (*p != *s) goto fail; p++; s++; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_EXACTMB2N: STAT_OP_IN(OP_EXACTMB2N); + case OP_EXACTMB2N: MOP_IN(OP_EXACTMB2N); GET_LENGTH_INC(tlen, p); DATA_ENSURE(tlen * 2); while (tlen-- > 0) { @@ -1790,11 +1606,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, p++; s++; } sprev = s - 2; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_EXACTMB3N: STAT_OP_IN(OP_EXACTMB3N); + case OP_EXACTMB3N: MOP_IN(OP_EXACTMB3N); GET_LENGTH_INC(tlen, p); DATA_ENSURE(tlen * 3); while (tlen-- > 0) { @@ -1806,11 +1622,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, p++; s++; } sprev = s - 3; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_EXACTMBN: STAT_OP_IN(OP_EXACTMBN); + case OP_EXACTMBN: MOP_IN(OP_EXACTMBN); GET_LENGTH_INC(tlen, p); /* mb-len */ GET_LENGTH_INC(tlen2, p); /* string len */ tlen2 *= tlen; @@ -1820,19 +1636,19 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, p++; s++; } sprev = s - tlen; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_CCLASS: STAT_OP_IN(OP_CCLASS); + case OP_CCLASS: MOP_IN(OP_CCLASS); DATA_ENSURE(1); if (BITSET_AT(((BitSetRef )p), *s) == 0) goto fail; p += SIZE_BITSET; - s += enc_len(encode, s); /* OP_CCLASS can match mb-code. \D, \S */ - STAT_OP_OUT; + s += enclen(encode, s); /* OP_CCLASS can match mb-code. \D, \S */ + MOP_OUT; break; - case OP_CCLASS_MB: STAT_OP_IN(OP_CCLASS_MB); + case OP_CCLASS_MB: MOP_IN(OP_CCLASS_MB); if (! ONIGENC_IS_MBC_HEAD(encode, s)) goto fail; cclass_mb: @@ -1843,7 +1659,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, int mb_len; DATA_ENSURE(1); - mb_len = enc_len(encode, s); + mb_len = enclen(encode, s); DATA_ENSURE(mb_len); ss = s; s += mb_len; @@ -1858,10 +1674,10 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, #endif } p += tlen; - STAT_OP_OUT; + MOP_OUT; break; - case OP_CCLASS_MIX: STAT_OP_IN(OP_CCLASS_MIX); + case OP_CCLASS_MIX: MOP_IN(OP_CCLASS_MIX); DATA_ENSURE(1); if (ONIGENC_IS_MBC_HEAD(encode, s)) { p += SIZE_BITSET; @@ -1876,18 +1692,18 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, p += tlen; s++; } - STAT_OP_OUT; + MOP_OUT; break; - case OP_CCLASS_NOT: STAT_OP_IN(OP_CCLASS_NOT); + case OP_CCLASS_NOT: MOP_IN(OP_CCLASS_NOT); DATA_ENSURE(1); if (BITSET_AT(((BitSetRef )p), *s) != 0) goto fail; p += SIZE_BITSET; - s += enc_len(encode, s); - STAT_OP_OUT; + s += enclen(encode, s); + MOP_OUT; break; - case OP_CCLASS_MB_NOT: STAT_OP_IN(OP_CCLASS_MB_NOT); + case OP_CCLASS_MB_NOT: MOP_IN(OP_CCLASS_MB_NOT); DATA_ENSURE(1); if (! ONIGENC_IS_MBC_HEAD(encode, s)) { s++; @@ -1901,9 +1717,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, { OnigCodePoint code; UChar *ss; - int mb_len = enc_len(encode, s); + int mb_len = enclen(encode, s); - if (s + mb_len > end) { + if (! DATA_ENSURE_CHECK(mb_len)) { DATA_ENSURE(1); s = (UChar* )end; p += tlen; @@ -1925,10 +1741,10 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, p += tlen; cc_mb_not_success: - STAT_OP_OUT; + MOP_OUT; break; - case OP_CCLASS_MIX_NOT: STAT_OP_IN(OP_CCLASS_MIX_NOT); + case OP_CCLASS_MIX_NOT: MOP_IN(OP_CCLASS_MIX_NOT); DATA_ENSURE(1); if (ONIGENC_IS_MBC_HEAD(encode, s)) { p += SIZE_BITSET; @@ -1943,10 +1759,10 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, p += tlen; s++; } - STAT_OP_OUT; + MOP_OUT; break; - case OP_CCLASS_NODE: STAT_OP_IN(OP_CCLASS_NODE); + case OP_CCLASS_NODE: MOP_IN(OP_CCLASS_NODE); { OnigCodePoint code; void *node; @@ -1955,49 +1771,49 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, DATA_ENSURE(1); GET_POINTER_INC(node, p); - mb_len = enc_len(encode, s); + mb_len = enclen(encode, s); ss = s; s += mb_len; DATA_ENSURE(0); code = ONIGENC_MBC_TO_CODE(encode, ss, s); - if (is_code_in_cc(mb_len, code, node) == 0) goto fail; + if (onig_is_code_in_cc_len(mb_len, code, node) == 0) goto fail; } - STAT_OP_OUT; + MOP_OUT; break; - case OP_ANYCHAR: STAT_OP_IN(OP_ANYCHAR); + case OP_ANYCHAR: MOP_IN(OP_ANYCHAR); DATA_ENSURE(1); - n = enc_len(encode, s); + n = enclen(encode, s); DATA_ENSURE(n); if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail; s += n; - STAT_OP_OUT; + MOP_OUT; break; - case OP_ANYCHAR_ML: STAT_OP_IN(OP_ANYCHAR_ML); + case OP_ANYCHAR_ML: MOP_IN(OP_ANYCHAR_ML); DATA_ENSURE(1); - n = enc_len(encode, s); + n = enclen(encode, s); DATA_ENSURE(n); s += n; - STAT_OP_OUT; + MOP_OUT; break; - case OP_ANYCHAR_STAR: STAT_OP_IN(OP_ANYCHAR_STAR); - while (s < end) { + case OP_ANYCHAR_STAR: MOP_IN(OP_ANYCHAR_STAR); + while (DATA_ENSURE_CHECK1) { STACK_PUSH_ALT(p, s, sprev); - n = enc_len(encode, s); + n = enclen(encode, s); DATA_ENSURE(n); if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail; sprev = s; s += n; } - STAT_OP_OUT; + MOP_OUT; break; - case OP_ANYCHAR_ML_STAR: STAT_OP_IN(OP_ANYCHAR_ML_STAR); - while (s < end) { + case OP_ANYCHAR_ML_STAR: MOP_IN(OP_ANYCHAR_ML_STAR); + while (DATA_ENSURE_CHECK1) { STACK_PUSH_ALT(p, s, sprev); - n = enc_len(encode, s); + n = enclen(encode, s); if (n > 1) { DATA_ENSURE(n); sprev = s; @@ -2008,31 +1824,31 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, s++; } } - STAT_OP_OUT; + MOP_OUT; break; - case OP_ANYCHAR_STAR_PEEK_NEXT: STAT_OP_IN(OP_ANYCHAR_STAR_PEEK_NEXT); - while (s < end) { + case OP_ANYCHAR_STAR_PEEK_NEXT: MOP_IN(OP_ANYCHAR_STAR_PEEK_NEXT); + while (DATA_ENSURE_CHECK1) { if (*p == *s) { STACK_PUSH_ALT(p + 1, s, sprev); } - n = enc_len(encode, s); + n = enclen(encode, s); DATA_ENSURE(n); if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail; sprev = s; s += n; } p++; - STAT_OP_OUT; + MOP_OUT; break; - case OP_ANYCHAR_ML_STAR_PEEK_NEXT:STAT_OP_IN(OP_ANYCHAR_ML_STAR_PEEK_NEXT); - while (s < end) { + case OP_ANYCHAR_ML_STAR_PEEK_NEXT:MOP_IN(OP_ANYCHAR_ML_STAR_PEEK_NEXT); + while (DATA_ENSURE_CHECK1) { if (*p == *s) { STACK_PUSH_ALT(p + 1, s, sprev); } - n = enc_len(encode, s); - if (n >1) { + n = enclen(encode, s); + if (n > 1) { DATA_ENSURE(n); sprev = s; s += n; @@ -2043,36 +1859,36 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, } } p++; - STAT_OP_OUT; + MOP_OUT; break; #ifdef USE_COMBINATION_EXPLOSION_CHECK - case OP_STATE_CHECK_ANYCHAR_STAR: STAT_OP_IN(OP_STATE_CHECK_ANYCHAR_STAR); + case OP_STATE_CHECK_ANYCHAR_STAR: MOP_IN(OP_STATE_CHECK_ANYCHAR_STAR); GET_STATE_CHECK_NUM_INC(mem, p); - while (s < end) { + while (DATA_ENSURE_CHECK1) { STATE_CHECK_VAL(scv, mem); if (scv) goto fail; STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem); - n = enc_len(encode, s); + n = enclen(encode, s); DATA_ENSURE(n); if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail; sprev = s; s += n; } - STAT_OP_OUT; + MOP_OUT; break; case OP_STATE_CHECK_ANYCHAR_ML_STAR: - STAT_OP_IN(OP_STATE_CHECK_ANYCHAR_ML_STAR); + MOP_IN(OP_STATE_CHECK_ANYCHAR_ML_STAR); GET_STATE_CHECK_NUM_INC(mem, p); - while (s < end) { + while (DATA_ENSURE_CHECK1) { STATE_CHECK_VAL(scv, mem); if (scv) goto fail; STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem); - n = enc_len(encode, s); + n = enclen(encode, s); if (n > 1) { DATA_ENSURE(n); sprev = s; @@ -2083,29 +1899,29 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, s++; } } - STAT_OP_OUT; + MOP_OUT; break; #endif /* USE_COMBINATION_EXPLOSION_CHECK */ - case OP_WORD: STAT_OP_IN(OP_WORD); + case OP_WORD: MOP_IN(OP_WORD); DATA_ENSURE(1); if (! ONIGENC_IS_MBC_WORD(encode, s, end)) goto fail; - s += enc_len(encode, s); - STAT_OP_OUT; + s += enclen(encode, s); + MOP_OUT; break; - case OP_NOT_WORD: STAT_OP_IN(OP_NOT_WORD); + case OP_NOT_WORD: MOP_IN(OP_NOT_WORD); DATA_ENSURE(1); if (ONIGENC_IS_MBC_WORD(encode, s, end)) goto fail; - s += enc_len(encode, s); - STAT_OP_OUT; + s += enclen(encode, s); + MOP_OUT; break; - case OP_WORD_BOUND: STAT_OP_IN(OP_WORD_BOUND); + case OP_WORD_BOUND: MOP_IN(OP_WORD_BOUND); if (ON_STR_BEGIN(s)) { DATA_ENSURE(1); if (! ONIGENC_IS_MBC_WORD(encode, s, end)) @@ -2120,13 +1936,13 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, == ONIGENC_IS_MBC_WORD(encode, sprev, end)) goto fail; } - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_NOT_WORD_BOUND: STAT_OP_IN(OP_NOT_WORD_BOUND); + case OP_NOT_WORD_BOUND: MOP_IN(OP_NOT_WORD_BOUND); if (ON_STR_BEGIN(s)) { - if (DATA_ENSURE_CHECK(1) && ONIGENC_IS_MBC_WORD(encode, s, end)) + if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_WORD(encode, s, end)) goto fail; } else if (ON_STR_END(s)) { @@ -2138,25 +1954,25 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, != ONIGENC_IS_MBC_WORD(encode, sprev, end)) goto fail; } - STAT_OP_OUT; + MOP_OUT; continue; break; #ifdef USE_WORD_BEGIN_END - case OP_WORD_BEGIN: STAT_OP_IN(OP_WORD_BEGIN); - if (DATA_ENSURE_CHECK(1) && ONIGENC_IS_MBC_WORD(encode, s, end)) { + case OP_WORD_BEGIN: MOP_IN(OP_WORD_BEGIN); + if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_WORD(encode, s, end)) { if (ON_STR_BEGIN(s) || !ONIGENC_IS_MBC_WORD(encode, sprev, end)) { - STAT_OP_OUT; + MOP_OUT; continue; } } goto fail; break; - case OP_WORD_END: STAT_OP_IN(OP_WORD_END); + case OP_WORD_END: MOP_IN(OP_WORD_END); if (!ON_STR_BEGIN(s) && ONIGENC_IS_MBC_WORD(encode, sprev, end)) { if (ON_STR_END(s) || !ONIGENC_IS_MBC_WORD(encode, s, end)) { - STAT_OP_OUT; + MOP_OUT; continue; } } @@ -2164,80 +1980,81 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, break; #endif - case OP_BEGIN_BUF: STAT_OP_IN(OP_BEGIN_BUF); + case OP_BEGIN_BUF: MOP_IN(OP_BEGIN_BUF); if (! ON_STR_BEGIN(s)) goto fail; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_END_BUF: STAT_OP_IN(OP_END_BUF); + case OP_END_BUF: MOP_IN(OP_END_BUF); if (! ON_STR_END(s)) goto fail; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_BEGIN_LINE: STAT_OP_IN(OP_BEGIN_LINE); + case OP_BEGIN_LINE: MOP_IN(OP_BEGIN_LINE); if (ON_STR_BEGIN(s)) { if (IS_NOTBOL(msa->options)) goto fail; - STAT_OP_OUT; + MOP_OUT; continue; } else if (ONIGENC_IS_MBC_NEWLINE(encode, sprev, end) && !ON_STR_END(s)) { - STAT_OP_OUT; + MOP_OUT; continue; } goto fail; break; - case OP_END_LINE: STAT_OP_IN(OP_END_LINE); + case OP_END_LINE: MOP_IN(OP_END_LINE); if (ON_STR_END(s)) { #ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE if (IS_EMPTY_STR || !ONIGENC_IS_MBC_NEWLINE(encode, sprev, end)) { #endif if (IS_NOTEOL(msa->options)) goto fail; - STAT_OP_OUT; + MOP_OUT; continue; #ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE } #endif } else if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) { - STAT_OP_OUT; + MOP_OUT; continue; } #ifdef USE_CRNL_AS_LINE_TERMINATOR else if (ONIGENC_IS_MBC_CRNL(encode, s, end)) { - STAT_OP_OUT; + MOP_OUT; continue; } #endif goto fail; break; - case OP_SEMI_END_BUF: STAT_OP_IN(OP_SEMI_END_BUF); + case OP_SEMI_END_BUF: MOP_IN(OP_SEMI_END_BUF); if (ON_STR_END(s)) { #ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE if (IS_EMPTY_STR || !ONIGENC_IS_MBC_NEWLINE(encode, sprev, end)) { #endif - if (IS_NOTEOL(msa->options)) goto fail; /* Is it needed? */ - STAT_OP_OUT; + if (IS_NOTEOL(msa->options)) goto fail; + MOP_OUT; continue; #ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE } #endif } else if (ONIGENC_IS_MBC_NEWLINE(encode, s, end) && - ON_STR_END(s + enc_len(encode, s))) { - STAT_OP_OUT; + ON_STR_END(s + enclen(encode, s))) { + MOP_OUT; continue; } #ifdef USE_CRNL_AS_LINE_TERMINATOR else if (ONIGENC_IS_MBC_CRNL(encode, s, end)) { - UChar* ss = s + enc_len(encode, s); - if (ON_STR_END(ss + enc_len(encode, ss))) { - STAT_OP_OUT; + UChar* ss = s + enclen(encode, s); + ss += enclen(encode, ss); + if (ON_STR_END(ss)) { + MOP_OUT; continue; } } @@ -2245,79 +2062,79 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, goto fail; break; - case OP_BEGIN_POSITION: STAT_OP_IN(OP_BEGIN_POSITION); + case OP_BEGIN_POSITION: MOP_IN(OP_BEGIN_POSITION); if (s != msa->start) goto fail; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_MEMORY_START_PUSH: STAT_OP_IN(OP_MEMORY_START_PUSH); + case OP_MEMORY_START_PUSH: MOP_IN(OP_MEMORY_START_PUSH); GET_MEMNUM_INC(mem, p); STACK_PUSH_MEM_START(mem, s); - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_MEMORY_START: STAT_OP_IN(OP_MEMORY_START); + case OP_MEMORY_START: MOP_IN(OP_MEMORY_START); GET_MEMNUM_INC(mem, p); - mem_start_stk[mem] = (StackIndex )((void* )s); - STAT_OP_OUT; + mem_start_stk[mem] = (OnigStackIndex )((void* )s); + MOP_OUT; continue; break; - case OP_MEMORY_END_PUSH: STAT_OP_IN(OP_MEMORY_END_PUSH); + case OP_MEMORY_END_PUSH: MOP_IN(OP_MEMORY_END_PUSH); GET_MEMNUM_INC(mem, p); STACK_PUSH_MEM_END(mem, s); - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_MEMORY_END: STAT_OP_IN(OP_MEMORY_END); + case OP_MEMORY_END: MOP_IN(OP_MEMORY_END); GET_MEMNUM_INC(mem, p); - mem_end_stk[mem] = (StackIndex )((void* )s); - STAT_OP_OUT; + mem_end_stk[mem] = (OnigStackIndex )((void* )s); + MOP_OUT; continue; break; #ifdef USE_SUBEXP_CALL - case OP_MEMORY_END_PUSH_REC: STAT_OP_IN(OP_MEMORY_END_PUSH_REC); + case OP_MEMORY_END_PUSH_REC: MOP_IN(OP_MEMORY_END_PUSH_REC); GET_MEMNUM_INC(mem, p); STACK_GET_MEM_START(mem, stkp); /* should be before push mem-end. */ STACK_PUSH_MEM_END(mem, s); mem_start_stk[mem] = GET_STACK_INDEX(stkp); - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_MEMORY_END_REC: STAT_OP_IN(OP_MEMORY_END_REC); + case OP_MEMORY_END_REC: MOP_IN(OP_MEMORY_END_REC); GET_MEMNUM_INC(mem, p); - mem_end_stk[mem] = (StackIndex )((void* )s); + mem_end_stk[mem] = (OnigStackIndex )((void* )s); STACK_GET_MEM_START(mem, stkp); if (BIT_STATUS_AT(reg->bt_mem_start, mem)) mem_start_stk[mem] = GET_STACK_INDEX(stkp); else - mem_start_stk[mem] = (StackIndex )((void* )stkp->u.mem.pstr); + mem_start_stk[mem] = (OnigStackIndex )((void* )stkp->u.mem.pstr); STACK_PUSH_MEM_END_MARK(mem); - STAT_OP_OUT; + MOP_OUT; continue; break; #endif - case OP_BACKREF1: STAT_OP_IN(OP_BACKREF1); + case OP_BACKREF1: MOP_IN(OP_BACKREF1); mem = 1; goto backref; break; - case OP_BACKREF2: STAT_OP_IN(OP_BACKREF2); + case OP_BACKREF2: MOP_IN(OP_BACKREF2); mem = 2; goto backref; break; - case OP_BACKREFN: STAT_OP_IN(OP_BACKREFN); + case OP_BACKREFN: MOP_IN(OP_BACKREFN); GET_MEMNUM_INC(mem, p); backref: { @@ -2342,15 +2159,15 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, DATA_ENSURE(n); sprev = s; STRING_CMP(pstart, s, n); - while (sprev + (len = enc_len(encode, sprev)) < s) + while (sprev + (len = enclen(encode, sprev)) < s) sprev += len; - STAT_OP_OUT; + MOP_OUT; continue; } break; - case OP_BACKREFN_IC: STAT_OP_IN(OP_BACKREFN_IC); + case OP_BACKREFN_IC: MOP_IN(OP_BACKREFN_IC); GET_MEMNUM_INC(mem, p); { int len; @@ -2373,16 +2190,16 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, n = pend - pstart; DATA_ENSURE(n); sprev = s; - STRING_CMP_IC(ambig_flag, pstart, &s, n); - while (sprev + (len = enc_len(encode, sprev)) < s) + STRING_CMP_IC(case_fold_flag, pstart, &s, n); + while (sprev + (len = enclen(encode, sprev)) < s) sprev += len; - STAT_OP_OUT; + MOP_OUT; continue; } break; - case OP_BACKREF_MULTI: STAT_OP_IN(OP_BACKREF_MULTI); + case OP_BACKREF_MULTI: MOP_IN(OP_BACKREF_MULTI); { int len, is_fail; UChar *pstart, *pend, *swork; @@ -2409,19 +2226,19 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, STRING_CMP_VALUE(pstart, swork, n, is_fail); if (is_fail) continue; s = swork; - while (sprev + (len = enc_len(encode, sprev)) < s) + while (sprev + (len = enclen(encode, sprev)) < s) sprev += len; p += (SIZE_MEMNUM * (tlen - i - 1)); break; /* success */ } if (i == tlen) goto fail; - STAT_OP_OUT; + MOP_OUT; continue; } break; - case OP_BACKREF_MULTI_IC: STAT_OP_IN(OP_BACKREF_MULTI_IC); + case OP_BACKREF_MULTI_IC: MOP_IN(OP_BACKREF_MULTI_IC); { int len, is_fail; UChar *pstart, *pend, *swork; @@ -2445,23 +2262,23 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, DATA_ENSURE(n); sprev = s; swork = s; - STRING_CMP_VALUE_IC(ambig_flag, pstart, &swork, n, is_fail); + STRING_CMP_VALUE_IC(case_fold_flag, pstart, &swork, n, is_fail); if (is_fail) continue; s = swork; - while (sprev + (len = enc_len(encode, sprev)) < s) + while (sprev + (len = enclen(encode, sprev)) < s) sprev += len; p += (SIZE_MEMNUM * (tlen - i - 1)); break; /* success */ } if (i == tlen) goto fail; - STAT_OP_OUT; + MOP_OUT; continue; } break; -#ifdef USE_BACKREF_AT_LEVEL - case OP_BACKREF_AT_LEVEL: +#ifdef USE_BACKREF_WITH_LEVEL + case OP_BACKREF_WITH_LEVEL: { int len; OnigOptionType ic; @@ -2472,9 +2289,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, GET_LENGTH_INC(tlen, p); sprev = s; - if (backref_match_at_nested_level(reg, stk, stk_base, ic, ambig_flag - , (int )level, (int )tlen, p, &s, end)) { - while (sprev + (len = enc_len(encode, sprev)) < s) + if (backref_match_at_nested_level(reg, stk, stk_base, ic + , case_fold_flag, (int )level, (int )tlen, p, &s, end)) { + while (sprev + (len = enclen(encode, sprev)) < s) sprev += len; p += (SIZE_MEMNUM * tlen); @@ -2482,35 +2299,37 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, else goto fail; - STAT_OP_OUT; + MOP_OUT; continue; } break; #endif - - case OP_SET_OPTION_PUSH: STAT_OP_IN(OP_SET_OPTION_PUSH); + +#if 0 /* no need: IS_DYNAMIC_OPTION() == 0 */ + case OP_SET_OPTION_PUSH: MOP_IN(OP_SET_OPTION_PUSH); GET_OPTION_INC(option, p); STACK_PUSH_ALT(p, s, sprev); p += SIZE_OP_SET_OPTION + SIZE_OP_FAIL; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_SET_OPTION: STAT_OP_IN(OP_SET_OPTION); + case OP_SET_OPTION: MOP_IN(OP_SET_OPTION); GET_OPTION_INC(option, p); - STAT_OP_OUT; + MOP_OUT; continue; break; +#endif - case OP_NULL_CHECK_START: STAT_OP_IN(OP_NULL_CHECK_START); + case OP_NULL_CHECK_START: MOP_IN(OP_NULL_CHECK_START); GET_MEMNUM_INC(mem, p); /* mem: null check id */ STACK_PUSH_NULL_CHECK_START(mem, s); - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_NULL_CHECK_END: STAT_OP_IN(OP_NULL_CHECK_END); + case OP_NULL_CHECK_END: MOP_IN(OP_NULL_CHECK_END); { int isnull; @@ -2540,12 +2359,12 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, } } } - STAT_OP_OUT; + MOP_OUT; continue; break; -#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK - case OP_NULL_CHECK_END_MEMST: STAT_OP_IN(OP_NULL_CHECK_END_MEMST); +#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT + case OP_NULL_CHECK_END_MEMST: MOP_IN(OP_NULL_CHECK_END_MEMST); { int isnull; @@ -2560,19 +2379,19 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, goto null_check_found; } } - STAT_OP_OUT; + MOP_OUT; continue; break; #endif #ifdef USE_SUBEXP_CALL case OP_NULL_CHECK_END_MEMST_PUSH: - STAT_OP_IN(OP_NULL_CHECK_END_MEMST_PUSH); + MOP_IN(OP_NULL_CHECK_END_MEMST_PUSH); { int isnull; GET_MEMNUM_INC(mem, p); /* mem: null check id */ -#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK +#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT STACK_NULL_CHECK_MEMST_REC(isnull, mem, s, reg); #else STACK_NULL_CHECK_REC(isnull, mem, s); @@ -2589,39 +2408,39 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, STACK_PUSH_NULL_CHECK_END(mem); } } - STAT_OP_OUT; + MOP_OUT; continue; break; #endif - case OP_JUMP: STAT_OP_IN(OP_JUMP); + case OP_JUMP: MOP_IN(OP_JUMP); GET_RELADDR_INC(addr, p); p += addr; - STAT_OP_OUT; + MOP_OUT; CHECK_INTERRUPT_IN_MATCH_AT; continue; break; - case OP_PUSH: STAT_OP_IN(OP_PUSH); + case OP_PUSH: MOP_IN(OP_PUSH); GET_RELADDR_INC(addr, p); STACK_PUSH_ALT(p + addr, s, sprev); - STAT_OP_OUT; + MOP_OUT; continue; break; #ifdef USE_COMBINATION_EXPLOSION_CHECK - case OP_STATE_CHECK_PUSH: STAT_OP_IN(OP_STATE_CHECK_PUSH); + case OP_STATE_CHECK_PUSH: MOP_IN(OP_STATE_CHECK_PUSH); GET_STATE_CHECK_NUM_INC(mem, p); STATE_CHECK_VAL(scv, mem); if (scv) goto fail; GET_RELADDR_INC(addr, p); STACK_PUSH_ALT_WITH_STATE_CHECK(p + addr, s, sprev, mem); - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_STATE_CHECK_PUSH_OR_JUMP: STAT_OP_IN(OP_STATE_CHECK_PUSH_OR_JUMP); + case OP_STATE_CHECK_PUSH_OR_JUMP: MOP_IN(OP_STATE_CHECK_PUSH_OR_JUMP); GET_STATE_CHECK_NUM_INC(mem, p); GET_RELADDR_INC(addr, p); STATE_CHECK_VAL(scv, mem); @@ -2631,54 +2450,54 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, else { STACK_PUSH_ALT_WITH_STATE_CHECK(p + addr, s, sprev, mem); } - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_STATE_CHECK: STAT_OP_IN(OP_STATE_CHECK); + case OP_STATE_CHECK: MOP_IN(OP_STATE_CHECK); GET_STATE_CHECK_NUM_INC(mem, p); STATE_CHECK_VAL(scv, mem); if (scv) goto fail; STACK_PUSH_STATE_CHECK(s, mem); - STAT_OP_OUT; + MOP_OUT; continue; break; #endif /* USE_COMBINATION_EXPLOSION_CHECK */ - case OP_POP: STAT_OP_IN(OP_POP); + case OP_POP: MOP_IN(OP_POP); STACK_POP_ONE; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_PUSH_OR_JUMP_EXACT1: STAT_OP_IN(OP_PUSH_OR_JUMP_EXACT1); + case OP_PUSH_OR_JUMP_EXACT1: MOP_IN(OP_PUSH_OR_JUMP_EXACT1); GET_RELADDR_INC(addr, p); - if (*p == *s && DATA_ENSURE_CHECK(1)) { + if (*p == *s && DATA_ENSURE_CHECK1) { p++; STACK_PUSH_ALT(p + addr, s, sprev); - STAT_OP_OUT; + MOP_OUT; continue; } p += (addr + 1); - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_PUSH_IF_PEEK_NEXT: STAT_OP_IN(OP_PUSH_IF_PEEK_NEXT); + case OP_PUSH_IF_PEEK_NEXT: MOP_IN(OP_PUSH_IF_PEEK_NEXT); GET_RELADDR_INC(addr, p); if (*p == *s) { p++; STACK_PUSH_ALT(p + addr, s, sprev); - STAT_OP_OUT; + MOP_OUT; continue; } p++; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_REPEAT: STAT_OP_IN(OP_REPEAT); + case OP_REPEAT: MOP_IN(OP_REPEAT); { GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */ GET_RELADDR_INC(addr, p); @@ -2691,11 +2510,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, STACK_PUSH_ALT(p + addr, s, sprev); } } - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_REPEAT_NG: STAT_OP_IN(OP_REPEAT_NG); + case OP_REPEAT_NG: MOP_IN(OP_REPEAT_NG); { GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */ GET_RELADDR_INC(addr, p); @@ -2709,11 +2528,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, p += addr; } } - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_REPEAT_INC: STAT_OP_IN(OP_REPEAT_INC); + case OP_REPEAT_INC: MOP_IN(OP_REPEAT_INC); GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */ si = repeat_stk[mem]; stkp = STACK_AT(si); @@ -2731,19 +2550,19 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, p = stkp->u.repeat.pcode; } STACK_PUSH_REPEAT_INC(si); - STAT_OP_OUT; + MOP_OUT; CHECK_INTERRUPT_IN_MATCH_AT; continue; break; - case OP_REPEAT_INC_SG: STAT_OP_IN(OP_REPEAT_INC_SG); + case OP_REPEAT_INC_SG: MOP_IN(OP_REPEAT_INC_SG); GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */ STACK_GET_REPEAT(mem, stkp); si = GET_STACK_INDEX(stkp); goto repeat_inc; break; - case OP_REPEAT_INC_NG: STAT_OP_IN(OP_REPEAT_INC_NG); + case OP_REPEAT_INC_NG: MOP_IN(OP_REPEAT_INC_NG); GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */ si = repeat_stk[mem]; stkp = STACK_AT(si); @@ -2765,68 +2584,68 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, else if (stkp->u.repeat.count == reg->repeat_range[mem].upper) { STACK_PUSH_REPEAT_INC(si); } - STAT_OP_OUT; + MOP_OUT; CHECK_INTERRUPT_IN_MATCH_AT; continue; break; - case OP_REPEAT_INC_NG_SG: STAT_OP_IN(OP_REPEAT_INC_NG_SG); + case OP_REPEAT_INC_NG_SG: MOP_IN(OP_REPEAT_INC_NG_SG); GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */ STACK_GET_REPEAT(mem, stkp); si = GET_STACK_INDEX(stkp); goto repeat_inc_ng; break; - case OP_PUSH_POS: STAT_OP_IN(OP_PUSH_POS); + case OP_PUSH_POS: MOP_IN(OP_PUSH_POS); STACK_PUSH_POS(s, sprev); - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_POP_POS: STAT_OP_IN(OP_POP_POS); + case OP_POP_POS: MOP_IN(OP_POP_POS); { STACK_POS_END(stkp); s = stkp->u.state.pstr; sprev = stkp->u.state.pstr_prev; } - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_PUSH_POS_NOT: STAT_OP_IN(OP_PUSH_POS_NOT); + case OP_PUSH_POS_NOT: MOP_IN(OP_PUSH_POS_NOT); GET_RELADDR_INC(addr, p); STACK_PUSH_POS_NOT(p + addr, s, sprev); - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_FAIL_POS: STAT_OP_IN(OP_FAIL_POS); + case OP_FAIL_POS: MOP_IN(OP_FAIL_POS); STACK_POP_TIL_POS_NOT; goto fail; break; - case OP_PUSH_STOP_BT: STAT_OP_IN(OP_PUSH_STOP_BT); + case OP_PUSH_STOP_BT: MOP_IN(OP_PUSH_STOP_BT); STACK_PUSH_STOP_BT; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_POP_STOP_BT: STAT_OP_IN(OP_POP_STOP_BT); + case OP_POP_STOP_BT: MOP_IN(OP_POP_STOP_BT); STACK_STOP_BT_END; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_LOOK_BEHIND: STAT_OP_IN(OP_LOOK_BEHIND); + case OP_LOOK_BEHIND: MOP_IN(OP_LOOK_BEHIND); GET_LENGTH_INC(tlen, p); s = (UChar* )ONIGENC_STEP_BACK(encode, str, s, (int )tlen); if (IS_NULL(s)) goto fail; sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s); - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_PUSH_LOOK_BEHIND_NOT: STAT_OP_IN(OP_PUSH_LOOK_BEHIND_NOT); + case OP_PUSH_LOOK_BEHIND_NOT: MOP_IN(OP_PUSH_LOOK_BEHIND_NOT); GET_RELADDR_INC(addr, p); GET_LENGTH_INC(tlen, p); q = (UChar* )ONIGENC_STEP_BACK(encode, str, s, (int )tlen); @@ -2841,28 +2660,28 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, s = q; sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s); } - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_FAIL_LOOK_BEHIND_NOT: STAT_OP_IN(OP_FAIL_LOOK_BEHIND_NOT); + case OP_FAIL_LOOK_BEHIND_NOT: MOP_IN(OP_FAIL_LOOK_BEHIND_NOT); STACK_POP_TIL_LOOK_BEHIND_NOT; goto fail; break; #ifdef USE_SUBEXP_CALL - case OP_CALL: STAT_OP_IN(OP_CALL); + case OP_CALL: MOP_IN(OP_CALL); GET_ABSADDR_INC(addr, p); STACK_PUSH_CALL_FRAME(p); p = reg->p + addr; - STAT_OP_OUT; + MOP_OUT; continue; break; - case OP_RETURN: STAT_OP_IN(OP_RETURN); + case OP_RETURN: MOP_IN(OP_RETURN); STACK_RETURN(p); STACK_PUSH_RETURN; - STAT_OP_OUT; + MOP_OUT; continue; break; #endif @@ -2872,9 +2691,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, break; fail: - STAT_OP_OUT; + MOP_OUT; /* fall */ - case OP_FAIL: STAT_OP_IN(OP_FAIL); + case OP_FAIL: MOP_IN(OP_FAIL); STACK_POP; p = stk->u.state.pcode; s = stk->u.state.pstr; @@ -2887,7 +2706,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, const UChar* sstart, } #endif - STAT_OP_OUT; + MOP_OUT; continue; break; @@ -2943,32 +2762,25 @@ slow_search(OnigEncoding enc, UChar* target, UChar* target_end, if (t == target_end) return s; } - s += enc_len(enc, s); + s += enclen(enc, s); } return (UChar* )NULL; } static int -str_lower_case_match(OnigEncoding enc, int ambig_flag, +str_lower_case_match(OnigEncoding enc, int case_fold_flag, const UChar* t, const UChar* tend, const UChar* p, const UChar* end) { int lowlen; - UChar *q, lowbuf[ONIGENC_MBC_NORMALIZE_MAXLEN]; - const UChar* tsave; - const UChar* psave; - - tsave = t; - psave = p; + UChar *q, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN]; while (t < tend) { - lowlen = ONIGENC_MBC_TO_NORMALIZE(enc, ambig_flag, &p, end, lowbuf); + lowlen = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &p, end, lowbuf); q = lowbuf; while (lowlen > 0) { - if (*t++ != *q++) { - return 0; - } + if (*t++ != *q++) return 0; lowlen--; } } @@ -2977,7 +2789,7 @@ str_lower_case_match(OnigEncoding enc, int ambig_flag, } static UChar* -slow_search_ic(OnigEncoding enc, int ambig_flag, +slow_search_ic(OnigEncoding enc, int case_fold_flag, UChar* target, UChar* target_end, const UChar* text, const UChar* text_end, UChar* text_range) { @@ -2991,10 +2803,11 @@ slow_search_ic(OnigEncoding enc, int ambig_flag, s = (UChar* )text; while (s < end) { - if (str_lower_case_match(enc, ambig_flag, target, target_end, s, text_end)) + if (str_lower_case_match(enc, case_fold_flag, target, target_end, + s, text_end)) return s; - s += enc_len(enc, s); + s += enclen(enc, s); } return (UChar* )NULL; @@ -3033,7 +2846,7 @@ slow_search_backward(OnigEncoding enc, UChar* target, UChar* target_end, } static UChar* -slow_search_backward_ic(OnigEncoding enc, int ambig_flag, +slow_search_backward_ic(OnigEncoding enc, int case_fold_flag, UChar* target, UChar* target_end, const UChar* text, const UChar* adjust_text, const UChar* text_end, const UChar* text_start) @@ -3048,7 +2861,7 @@ slow_search_backward_ic(OnigEncoding enc, int ambig_flag, s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, adjust_text, s); while (s >= text) { - if (str_lower_case_match(enc, ambig_flag, + if (str_lower_case_match(enc, case_fold_flag, target, target_end, s, text_end)) return s; @@ -3084,15 +2897,14 @@ bm_search_notrev(regex_t* reg, const UChar* target, const UChar* target_end, while (s < end) { p = se = s + tlen1; t = tail; - while (t >= target && *p == *t) { - p--; t--; + while (*p == *t) { + if (t == target) return (UChar* )s; + p--; t--; } - if (t < target) return (UChar* )s; - skip = reg->map[*se]; t = s; do { - s += enc_len(reg->enc, s); + s += enclen(reg->enc, s); } while ((s - t) < skip && s < end); } } @@ -3100,15 +2912,14 @@ bm_search_notrev(regex_t* reg, const UChar* target, const UChar* target_end, while (s < end) { p = se = s + tlen1; t = tail; - while (t >= target && *p == *t) { - p--; t--; + while (*p == *t) { + if (t == target) return (UChar* )s; + p--; t--; } - if (t < target) return (UChar* )s; - skip = reg->int_map[*se]; t = s; do { - s += enc_len(reg->enc, s); + s += enclen(reg->enc, s); } while ((s - t) < skip && s < end); } } @@ -3133,10 +2944,10 @@ bm_search(regex_t* reg, const UChar* target, const UChar* target_end, while (s < end) { p = s; t = tail; - while (t >= target && *p == *t) { + while (*p == *t) { + if (t == target) return (UChar* )p; p--; t--; } - if (t < target) return (UChar* )(p + 1); s += reg->map[*s]; } } @@ -3144,10 +2955,10 @@ bm_search(regex_t* reg, const UChar* target, const UChar* target_end, while (s < end) { p = s; t = tail; - while (t >= target && *p == *t) { + while (*p == *t) { + if (t == target) return (UChar* )p; p--; t--; } - if (t < target) return (UChar* )(p + 1); s += reg->int_map[*s]; } } @@ -3155,7 +2966,8 @@ bm_search(regex_t* reg, const UChar* target, const UChar* target_end, } static int -set_bm_backward_skip(UChar* s, UChar* end, OnigEncoding enc, int** skip) +set_bm_backward_skip(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED, + int** skip) { int i, len; @@ -3213,7 +3025,7 @@ map_search(OnigEncoding enc, UChar map[], while (s < text_range) { if (map[*s]) return (UChar* )s; - s += enc_len(enc, s); + s += enclen(enc, s); } return (UChar* )NULL; } @@ -3239,7 +3051,7 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, On { int r; UChar *prev; - MatchArg msa; + OnigMatchArg msa; #if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM) start: @@ -3275,7 +3087,7 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, On #endif if (region -#ifdef USE_POSIX_REGION_OPTION +#ifdef USE_POSIX_API_REGION_OPTION && !IS_POSIX_REGION(option) #endif ) { @@ -3286,7 +3098,11 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, On if (r == 0) { prev = (UChar* )onigenc_get_prev_char_head(reg->enc, str, at); - r = match_at(reg, str, end, at, prev, &msa); + r = match_at(reg, str, end, +#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE + end, +#endif + at, prev, &msa); } MATCH_ARG_FREE(msa); @@ -3312,7 +3128,7 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s, } else { UChar *q = p + reg->dmin; - while (p < q) p += enc_len(reg->enc, p); + while (p < q) p += enclen(reg->enc, p); } } @@ -3322,7 +3138,7 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s, p = slow_search(reg->enc, reg->exact, reg->exact_end, p, end, range); break; case ONIG_OPTIMIZE_EXACT_IC: - p = slow_search_ic(reg->enc, reg->ambig_flag, + p = slow_search_ic(reg->enc, reg->case_fold_flag, reg->exact, reg->exact_end, p, end, range); break; @@ -3343,7 +3159,7 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s, if (p - reg->dmin < s) { retry_gate: pprev = p; - p += enc_len(reg->enc, p); + p += enclen(reg->enc, p); goto retry; } @@ -3362,10 +3178,12 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s, case ANCHOR_END_LINE: if (ON_STR_END(p)) { +#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE prev = (UChar* )onigenc_get_prev_char_head(reg->enc, (pprev ? pprev : str), p); if (prev && ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end)) goto retry_gate; +#endif } else if (! ONIGENC_IS_MBC_NEWLINE(reg->enc, p, end) #ifdef USE_CRNL_AS_LINE_TERMINATOR @@ -3443,7 +3261,7 @@ backward_search_range(regex_t* reg, const UChar* str, const UChar* end, break; case ONIG_OPTIMIZE_EXACT_IC: - p = slow_search_backward_ic(reg->enc, reg->ambig_flag, + p = slow_search_backward_ic(reg->enc, reg->case_fold_flag, reg->exact, reg->exact_end, range, adjrange, end, p); break; @@ -3484,12 +3302,14 @@ backward_search_range(regex_t* reg, const UChar* str, const UChar* end, case ANCHOR_END_LINE: if (ON_STR_END(p)) { +#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE prev = onigenc_get_prev_char_head(reg->enc, adjrange, p); if (IS_NULL(prev)) goto fail; if (ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end)) { p = prev; goto retry; } +#endif } else if (! ONIGENC_IS_MBC_NEWLINE(reg->enc, p, end) #ifdef USE_CRNL_AS_LINE_TERMINATOR @@ -3532,8 +3352,11 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, { int r; UChar *s, *prev; - MatchArg msa; + OnigMatchArg msa; const UChar *orig_start = start; +#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE + const UChar *orig_range = range; +#endif #if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM) start: @@ -3567,7 +3390,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, #endif if (region -#ifdef USE_POSIX_REGION_OPTION +#ifdef USE_POSIX_API_REGION_OPTION && !IS_POSIX_REGION(option) #endif ) { @@ -3577,8 +3400,32 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, if (start > end || start < str) goto mismatch_no_msa; + +#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE +#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE +#define MATCH_AND_RETURN_CHECK(upper_range) \ + r = match_at(reg, str, end, (upper_range), s, prev, &msa); \ + if (r != ONIG_MISMATCH) {\ + if (r >= 0) {\ + if (! IS_FIND_LONGEST(reg->options)) {\ + goto match;\ + }\ + }\ + else goto finish; /* error */ \ + } +#else +#define MATCH_AND_RETURN_CHECK(upper_range) \ + r = match_at(reg, str, end, (upper_range), s, prev, &msa); \ + if (r != ONIG_MISMATCH) {\ + if (r >= 0) {\ + goto match;\ + }\ + else goto finish; /* error */ \ + } +#endif /* USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE */ +#else #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE -#define MATCH_AND_RETURN_CHECK \ +#define MATCH_AND_RETURN_CHECK(none) \ r = match_at(reg, str, end, s, prev, &msa);\ if (r != ONIG_MISMATCH) {\ if (r >= 0) {\ @@ -3589,7 +3436,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, else goto finish; /* error */ \ } #else -#define MATCH_AND_RETURN_CHECK \ +#define MATCH_AND_RETURN_CHECK(none) \ r = match_at(reg, str, end, s, prev, &msa);\ if (r != ONIG_MISMATCH) {\ if (r >= 0) {\ @@ -3597,7 +3444,9 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, }\ else goto finish; /* error */ \ } -#endif +#endif /* USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE */ +#endif /* USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE */ + /* anchor optimize: resume search range */ if (reg->anchor != 0 && str < end) { @@ -3700,10 +3549,10 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, MATCH_ARG_INIT(msa, option, region, start); #ifdef USE_COMBINATION_EXPLOSION_CHECK - msa.state_check_buff = (void* )0; - msa.state_check_buff_size = 0; + msa.state_check_buff = (void* )0; + msa.state_check_buff_size = 0; /* NO NEED, for valgrind */ #endif - MATCH_AND_RETURN_CHECK; + MATCH_AND_RETURN_CHECK(end); goto mismatch; } goto mismatch_no_msa; @@ -3754,9 +3603,9 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, prev = low_prev; } while (s <= high) { - MATCH_AND_RETURN_CHECK; + MATCH_AND_RETURN_CHECK(orig_range); prev = s; - s += enc_len(reg->enc, s); + s += enclen(reg->enc, s); } } while (s < range); goto mismatch; @@ -3767,13 +3616,13 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, if ((reg->anchor & ANCHOR_ANYCHAR_STAR) != 0) { do { - MATCH_AND_RETURN_CHECK; + MATCH_AND_RETURN_CHECK(orig_range); prev = s; - s += enc_len(reg->enc, s); + s += enclen(reg->enc, s); while (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end) && s < range) { prev = s; - s += enc_len(reg->enc, s); + s += enclen(reg->enc, s); } } while (s < range); goto mismatch; @@ -3782,16 +3631,21 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, } do { - MATCH_AND_RETURN_CHECK; + MATCH_AND_RETURN_CHECK(orig_range); prev = s; - s += enc_len(reg->enc, s); + s += enclen(reg->enc, s); } while (s < range); if (s == range) { /* because empty match with /$/. */ - MATCH_AND_RETURN_CHECK; + MATCH_AND_RETURN_CHECK(orig_range); } } else { /* backward search */ +#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE + if (orig_start < end) + orig_start += enclen(reg->enc, orig_start); /* is upper range */ +#endif + if (reg->optimize != ONIG_OPTIMIZE_NONE) { UChar *low, *high, *adjrange, *sch_start; @@ -3814,7 +3668,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, while (s >= low) { prev = onigenc_get_prev_char_head(reg->enc, str, s); - MATCH_AND_RETURN_CHECK; + MATCH_AND_RETURN_CHECK(orig_start); s = prev; } } while (s >= range); @@ -3842,7 +3696,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, do { prev = onigenc_get_prev_char_head(reg->enc, str, s); - MATCH_AND_RETURN_CHECK; + MATCH_AND_RETURN_CHECK(orig_start); s = prev; } while (s >= range); } @@ -3865,7 +3719,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, /* If result is mismatch and no FIND_NOT_EMPTY option, then the region is not setted in match_at(). */ if (IS_FIND_NOT_EMPTY(reg->options) && region -#ifdef USE_POSIX_REGION_OPTION +#ifdef USE_POSIX_API_REGION_OPTION && !IS_POSIX_REGION(option) #endif ) { @@ -3906,10 +3760,10 @@ onig_get_options(regex_t* reg) return reg->options; } -extern OnigAmbigType -onig_get_ambig_flag(regex_t* reg) +extern OnigCaseFoldType +onig_get_case_fold_flag(regex_t* reg) { - return reg->ambig_flag; + return reg->case_fold_flag; } extern OnigSyntaxType* diff --git a/ext/mbstring/oniguruma/regext.c b/ext/mbstring/oniguruma/regext.c index f5ad1f35a29e6..b1b957b40c1b3 100644 --- a/ext/mbstring/oniguruma/regext.c +++ b/ext/mbstring/oniguruma/regext.c @@ -2,7 +2,7 @@ regext.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -100,7 +100,7 @@ conv_encoding(OnigEncoding from, OnigEncoding to, const UChar* s, const UChar* e if (to == ONIG_ENCODING_UTF16_BE) { if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) { *conv = (UChar* )xmalloc(len * 2); - CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*conv); *conv_end = *conv + (len * 2); conv_ext0be(s, end, *conv); return 0; @@ -108,7 +108,7 @@ conv_encoding(OnigEncoding from, OnigEncoding to, const UChar* s, const UChar* e else if (from == ONIG_ENCODING_UTF16_LE) { swap16: *conv = (UChar* )xmalloc(len); - CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*conv); *conv_end = *conv + len; conv_swap2bytes(s, end, *conv); return 0; @@ -117,7 +117,7 @@ conv_encoding(OnigEncoding from, OnigEncoding to, const UChar* s, const UChar* e else if (to == ONIG_ENCODING_UTF16_LE) { if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) { *conv = (UChar* )xmalloc(len * 2); - CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*conv); *conv_end = *conv + (len * 2); conv_ext0le(s, end, *conv); return 0; @@ -129,7 +129,7 @@ conv_encoding(OnigEncoding from, OnigEncoding to, const UChar* s, const UChar* e if (to == ONIG_ENCODING_UTF32_BE) { if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) { *conv = (UChar* )xmalloc(len * 4); - CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*conv); *conv_end = *conv + (len * 4); conv_ext0be32(s, end, *conv); return 0; @@ -137,7 +137,7 @@ conv_encoding(OnigEncoding from, OnigEncoding to, const UChar* s, const UChar* e else if (from == ONIG_ENCODING_UTF32_LE) { swap32: *conv = (UChar* )xmalloc(len); - CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*conv); *conv_end = *conv + len; conv_swap4bytes(s, end, *conv); return 0; @@ -146,7 +146,7 @@ conv_encoding(OnigEncoding from, OnigEncoding to, const UChar* s, const UChar* e else if (to == ONIG_ENCODING_UTF32_LE) { if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) { *conv = (UChar* )xmalloc(len * 4); - CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*conv); *conv_end = *conv + (len * 4); conv_ext0le32(s, end, *conv); return 0; @@ -178,17 +178,24 @@ onig_new_deluxe(regex_t** reg, const UChar* pattern, const UChar* pattern_end, cpat_end = (UChar* )pattern_end; } - r = onig_alloc_init(reg, ci->option, ci->ambig_flag, ci->target_enc, - ci->syntax); + *reg = (regex_t* )xmalloc(sizeof(regex_t)); + if (IS_NULL(*reg)) { + r = ONIGERR_MEMORY; + goto err2; + } + + r = onig_reg_init(*reg, ci->option, ci->case_fold_flag, ci->target_enc, + ci->syntax); if (r) goto err; r = onig_compile(*reg, cpat, cpat_end, einfo); if (r) { + err: onig_free(*reg); *reg = NULL; } - err: + err2: if (cpat != pattern) xfree(cpat); return r; diff --git a/ext/mbstring/oniguruma/reggnu.c b/ext/mbstring/oniguruma/reggnu.c index 248957c9d9a2e..4bd18c45e1a8b 100644 --- a/ext/mbstring/oniguruma/reggnu.c +++ b/ext/mbstring/oniguruma/reggnu.c @@ -2,7 +2,7 @@ reggnu.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,7 +85,7 @@ re_compile_pattern(const char* pattern, int size, regex_t* reg, char* ebuf) OnigErrorInfo einfo; r = onig_compile(reg, (UChar* )pattern, (UChar* )(pattern + size), &einfo); - if (r != 0) { + if (r != ONIG_NORMAL) { if (IS_NOT_NULL(ebuf)) (void )onig_error_code_to_str((UChar* )ebuf, r, &einfo); } @@ -108,7 +108,7 @@ re_recompile_pattern(const char* pattern, int size, regex_t* reg, char* ebuf) r = onig_recompile(reg, (UChar* )pattern, (UChar* )(pattern + size), reg->options, enc, OnigDefaultSyntax, &einfo); - if (r != 0) { + if (r != ONIG_NORMAL) { if (IS_NOT_NULL(ebuf)) (void )onig_error_code_to_str((UChar* )ebuf, r, &einfo); } @@ -125,10 +125,13 @@ re_free_pattern(regex_t* reg) extern int re_alloc_pattern(regex_t** reg) { - return onig_alloc_init(reg, ONIG_OPTION_DEFAULT, - ONIGENC_AMBIGUOUS_MATCH_DEFAULT, - OnigEncDefaultCharEncoding, - OnigDefaultSyntax); + *reg = (regex_t* )xmalloc(sizeof(regex_t)); + if (IS_NULL(*reg)) return ONIGERR_MEMORY; + + return onig_reg_init(*reg, ONIG_OPTION_DEFAULT, + ONIGENC_CASE_FOLD_DEFAULT, + OnigEncDefaultCharEncoding, + OnigDefaultSyntax); } extern void @@ -138,18 +141,8 @@ re_set_casetable(const char* table) } extern void -#ifdef ONIG_RUBY_M17N -re_mbcinit(OnigEncoding enc) -#else re_mbcinit(int mb_code) -#endif { -#ifdef ONIG_RUBY_M17N - - onigenc_set_default_encoding(enc); - -#else - OnigEncoding enc; switch (mb_code) { @@ -171,5 +164,4 @@ re_mbcinit(int mb_code) } onigenc_set_default_encoding(enc); -#endif } diff --git a/ext/mbstring/oniguruma/regint.h b/ext/mbstring/oniguruma/regint.h index d6819d8f949d4..a0ce4912d8cf5 100644 --- a/ext/mbstring/oniguruma/regint.h +++ b/ext/mbstring/oniguruma/regint.h @@ -4,7 +4,7 @@ regint.h - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2007 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,64 +56,77 @@ /* config */ /* spec. config */ -/* #define USE_UNICODE_FULL_RANGE_CTYPE */ /* --> move to regenc.h */ #define USE_NAMED_GROUP #define USE_SUBEXP_CALL -#define USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK /* /(?:()|())*\2/ */ +#define USE_BACKREF_WITH_LEVEL /* \k, \k */ +#define USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT /* /(?:()|())*\2/ */ #define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */ #define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR /* #define USE_RECOMPILE_API */ -/* treat \r\n as line terminator. - !!! NO SUPPORT !!! - use this configuration on your own responsibility */ -/* #define USE_CRNL_AS_LINE_TERMINATOR */ +/* !!! moved to regenc.h. */ /* #define USE_CRNL_AS_LINE_TERMINATOR */ /* internal config */ -#define USE_RECYCLE_NODE +#define USE_PARSE_TREE_NODE_RECYCLE #define USE_OP_PUSH_OR_JUMP_EXACT -#define USE_QUANTIFIER_PEEK_NEXT -#define USE_ST_HASH_TABLE +#define USE_QTFR_PEEK_NEXT +#define USE_ST_LIBRARY #define USE_SHARED_CCLASS_TABLE #define INIT_MATCH_STACK_SIZE 160 #define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */ -/* interface to external system */ -#ifdef NOT_RUBY /* given from Makefile */ +#if defined(__GNUC__) +# define ARG_UNUSED __attribute__ ((unused)) +#else +# define ARG_UNUSED +#endif + +/* */ +/* escape other system UChar definition */ #include "config.h" -#define USE_BACKREF_AT_LEVEL +#ifdef ONIG_ESCAPE_UCHAR_COLLISION +#undef ONIG_ESCAPE_UCHAR_COLLISION +#endif + +#define USE_WORD_BEGIN_END /* "\<", "\>" */ #define USE_CAPTURE_HISTORY #define USE_VARIABLE_META_CHARS -#define USE_WORD_BEGIN_END /* "\<": word-begin, "\>": word-end */ -#define USE_POSIX_REGION_OPTION /* needed for POSIX API support */ +#define USE_POSIX_API_REGION_OPTION #define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE /* #define USE_COMBINATION_EXPLOSION_CHECK */ /* (X*)* */ + /* #define USE_MULTI_THREAD_SYSTEM */ -#define THREAD_SYSTEM_INIT /* depend on thread system */ -#define THREAD_SYSTEM_END /* depend on thread system */ -#define THREAD_ATOMIC_START /* depend on thread system */ -#define THREAD_ATOMIC_END /* depend on thread system */ -#define THREAD_PASS /* depend on thread system */ +#define THREAD_SYSTEM_INIT /* depend on thread system */ +#define THREAD_SYSTEM_END /* depend on thread system */ +#define THREAD_ATOMIC_START /* depend on thread system */ +#define THREAD_ATOMIC_END /* depend on thread system */ +#define THREAD_PASS /* depend on thread system */ #define xmalloc malloc #define xrealloc realloc #define xcalloc calloc #define xfree free -#else -#include "ruby.h" -#include "rubysig.h" /* for DEFER_INTS, ENABLE_INTS */ - -#define USE_COMBINATION_EXPLOSION_CHECK /* (X*)* */ -#define USE_MULTI_THREAD_SYSTEM -#define THREAD_SYSTEM_INIT -#define THREAD_SYSTEM_END -#define THREAD_ATOMIC_START DEFER_INTS -#define THREAD_ATOMIC_END ENABLE_INTS -#define THREAD_PASS rb_thread_schedule() -#define DEFAULT_WARN_FUNCTION onig_rb_warn -#define DEFAULT_VERB_WARN_FUNCTION onig_rb_warning +#define CHECK_INTERRUPT_IN_MATCH_AT -#endif /* else NOT_RUBY */ +#define st_init_table onig_st_init_table +#define st_init_table_with_size onig_st_init_table_with_size +#define st_init_numtable onig_st_init_numtable +#define st_init_numtable_with_size onig_st_init_numtable_with_size +#define st_init_strtable onig_st_init_strtable +#define st_init_strtable_with_size onig_st_init_strtable_with_size +#define st_delete onig_st_delete +#define st_delete_safe onig_st_delete_safe +#define st_insert onig_st_insert +#define st_lookup onig_st_lookup +#define st_foreach onig_st_foreach +#define st_add_direct onig_st_add_direct +#define st_free_table onig_st_free_table +#define st_cleanup_safe onig_st_cleanup_safe +#define st_copy onig_st_copy +#define st_nothing_key_clone onig_st_nothing_key_clone +#define st_nothing_key_free onig_st_nothing_key_free +/* */ +#define onig_st_is_member st_is_member #define STATE_CHECK_STRING_THRESHOLD_LEN 7 #define STATE_CHECK_BUFF_MAX_SIZE 0x4000 @@ -122,17 +135,16 @@ #define xmemset memset #define xmemcpy memcpy #define xmemmove memmove + #if defined(_WIN32) && !defined(__GNUC__) #define xalloca _alloca -#if _MSC_VER < 1500 -#ifndef vsnprintf -#define vsnprintf _vsnprintf -#endif -#endif +#define xvsnprintf _vsnprintf #else #define xalloca alloca +#define xvsnprintf vsnprintf #endif + #if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM) #define ONIG_STATE_INC(reg) (reg)->state++ #define ONIG_STATE_DEC(reg) (reg)->state-- @@ -154,60 +166,6 @@ #define ONIG_STATE_DEC_THREAD(reg) /* Nothing */ #endif /* USE_RECOMPILE_API && USE_MULTI_THREAD_SYSTEM */ - -#define onig_st_is_member st_is_member - -#ifdef NOT_RUBY - -#define st_init_table onig_st_init_table -#define st_init_table_with_size onig_st_init_table_with_size -#define st_init_numtable onig_st_init_numtable -#define st_init_numtable_with_size onig_st_init_numtable_with_size -#define st_init_strtable onig_st_init_strtable -#define st_init_strtable_with_size onig_st_init_strtable_with_size -#define st_init_strend_table_with_size onig_st_init_strend_table_with_size -#define st_delete onig_st_delete -#define st_delete_safe onig_st_delete_safe -#define st_insert onig_st_insert -#define st_insert_strend onig_st_insert_strend -#define st_lookup onig_st_lookup -#define st_lookup_strend onig_st_lookup_strend -#define st_foreach onig_st_foreach -#define st_add_direct onig_st_add_direct -#define st_add_direct_strend onig_st_add_direct_strend -#define st_free_table onig_st_free_table -#define st_cleanup_safe onig_st_cleanup_safe -#define st_copy onig_st_copy -#define st_nothing_key_clone onig_st_nothing_key_clone -#define st_nothing_key_free onig_st_nothing_key_free - -#else /* NOT_RUBY */ - -#define onig_st_init_table st_init_table -#define onig_st_init_table_with_size st_init_table_with_size -#define onig_st_init_numtable st_init_numtable -#define onig_st_init_numtable_with_size st_init_numtable_with_size -#define onig_st_init_strtable st_init_strtable -#define onig_st_init_strtable_with_size st_init_strtable_with_size -#define onig_st_init_strend_table_with_size st_init_strend_table_with_size -#define onig_st_delete st_delete -#define onig_st_delete_safe st_delete_safe -#define onig_st_insert st_insert -#define onig_st_insert_strend st_insert_strend -#define onig_st_lookup st_lookup -#define onig_st_lookup_strend st_lookup_strend -#define onig_st_foreach st_foreach -#define onig_st_add_direct st_add_direct -#define onig_st_add_direct_strend st_add_direct_strend -#define onig_st_free_table st_free_table -#define onig_st_cleanup_safe st_cleanup_safe -#define onig_st_copy st_copy -#define onig_st_nothing_key_clone st_nothing_key_clone -#define onig_st_nothing_key_free st_nothing_key_free - -#endif /* NOT_RUBY */ - - #ifdef HAVE_STDLIB_H #include #endif @@ -238,7 +196,6 @@ #endif #include "regenc.h" -#include "oniguruma.h" #ifdef MIN #undef MIN @@ -252,10 +209,23 @@ #define IS_NULL(p) (((void*)(p)) == (void*)0) #define IS_NOT_NULL(p) (((void*)(p)) != (void*)0) #define CHECK_NULL_RETURN(p) if (IS_NULL(p)) return NULL -#define CHECK_NULL_RETURN_VAL(p,val) if (IS_NULL(p)) return (val) +#define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY #define NULL_UCHARP ((UChar* )0) -#ifndef PLATFORM_UNALIGNED_WORD_ACCESS +#ifdef PLATFORM_UNALIGNED_WORD_ACCESS + +#define PLATFORM_GET_INC(val,p,type) do{\ + val = *(type* )p;\ + (p) += sizeof(type);\ +} while(0) + +#else + +#define PLATFORM_GET_INC(val,p,type) do{\ + xmemcpy(&val, (p), sizeof(type));\ + (p) += sizeof(type);\ +} while(0) + /* sizeof(OnigCodePoint) */ #define WORD_ALIGNMENT_SIZE SIZEOF_LONG @@ -270,86 +240,6 @@ (addr) -= ((unsigned int )(addr) % WORD_ALIGNMENT_SIZE);\ } while (0) - -#define B_SHIFT 8 -#define B_MASK 0xff - -#define SERIALIZE_2BYTE_INT(i,p) do {\ - *(p) = ((i) >> B_SHIFT) & B_MASK;\ - *((p)+1) = (i) & B_MASK;\ -} while (0) - -#define SERIALIZE_4BYTE_INT(i,p) do {\ - *(p) = ((i) >> B_SHIFT*3) & B_MASK;\ - *((p)+1) = ((i) >> B_SHIFT*2) & B_MASK;\ - *((p)+2) = ((i) >> B_SHIFT ) & B_MASK;\ - *((p)+3) = (i) & B_MASK;\ -} while (0) - -#define SERIALIZE_8BYTE_INT(i,p) do {\ - *(p) = ((i) >> B_SHIFT*7) & B_MASK;\ - *((p)+1) = ((i) >> B_SHIFT*6) & B_MASK;\ - *((p)+2) = ((i) >> B_SHIFT*5) & B_MASK;\ - *((p)+3) = ((i) >> B_SHIFT*4) & B_MASK;\ - *((p)+4) = ((i) >> B_SHIFT*3) & B_MASK;\ - *((p)+5) = ((i) >> B_SHIFT*2) & B_MASK;\ - *((p)+6) = ((i) >> B_SHIFT ) & B_MASK;\ - *((p)+7) = (i) & B_MASK;\ -} while (0) - -#define GET_2BYTE_INT_INC(type,i,p) do {\ - (i) = (type )(((unsigned int )(*(p)) << B_SHIFT) | (unsigned int )((p)[1]));\ - (p) += 2;\ -} while (0) - -#define GET_4BYTE_INT_INC(type,i,p) do {\ - (i) = (type )(((unsigned int )((p)[0]) << B_SHIFT*3) | \ - ((unsigned int )((p)[1]) << B_SHIFT*2) | \ - ((unsigned int )((p)[2]) << B_SHIFT ) | \ - ((unsigned int )((p)[3]) )); \ - (p) += 4;\ -} while (0) - -#define GET_8BYTE_INT_INC(type,i,p) do {\ - (i) = (type )(((unsigned long )((p)[0]) << B_SHIFT*7) | \ - ((unsigned long )((p)[1]) << B_SHIFT*6) | \ - ((unsigned long )((p)[2]) << B_SHIFT*5) | \ - ((unsigned long )((p)[3]) << B_SHIFT*4) | \ - ((unsigned long )((p)[4]) << B_SHIFT*3) | \ - ((unsigned long )((p)[5]) << B_SHIFT*2) | \ - ((unsigned long )((p)[6]) << B_SHIFT ) | \ - ((unsigned long )((p)[7]) )); \ - (p) += 8;\ -} while (0) - -#if SIZEOF_SHORT == 2 -#define GET_SHORT_INC(i,p) GET_2BYTE_INT_INC(short,i,p) -#define SERIALIZE_SHORT(i,p) SERIALIZE_2BYTE_INT(i,p) -#elif SIZEOF_SHORT == 4 -#define GET_SHORT_INC(i,p) GET_4BYTE_INT_INC(short,i,p) -#define SERIALIZE_SHORT(i,p) SERIALIZE_4BYTE_INT(i,p) -#elif SIZEOF_SHORT == 8 -#define GET_SHORT_INC(i,p) GET_8BYTE_INT_INC(short,i,p) -#define SERIALIZE_SHORT(i,p) SERIALIZE_8BYTE_INT(i,p) -#endif - -#if SIZEOF_INT == 2 -#define GET_INT_INC(i,p) GET_2BYTE_INT_INC(int,i,p) -#define GET_UINT_INC(i,p) GET_2BYTE_INT_INC(unsigned,i,p) -#define SERIALIZE_INT(i,p) SERIALIZE_2BYTE_INT(i,p) -#define SERIALIZE_UINT(i,p) SERIALIZE_2BYTE_INT(i,p) -#elif SIZEOF_INT == 4 -#define GET_INT_INC(i,p) GET_4BYTE_INT_INC(int,i,p) -#define GET_UINT_INC(i,p) GET_4BYTE_INT_INC(unsigned,i,p) -#define SERIALIZE_INT(i,p) SERIALIZE_4BYTE_INT(i,p) -#define SERIALIZE_UINT(i,p) SERIALIZE_4BYTE_INT(i,p) -#elif SIZEOF_INT == 8 -#define GET_INT_INC(i,p) GET_8BYTE_INT_INC(int,i,p) -#define GET_UINT_INC(i,p) GET_8BYTE_INT_INC(unsigned,i,p) -#define SERIALIZE_INT(i,p) SERIALIZE_8BYTE_INT(i,p) -#define SERIALIZE_UINT(i,p) SERIALIZE_8BYTE_INT(i,p) -#endif - #endif /* PLATFORM_UNALIGNED_WORD_ACCESS */ /* stack pop level */ @@ -372,17 +262,17 @@ typedef unsigned int BitStatusType; #define BIT_STATUS_CLEAR(stats) (stats) = 0 #define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0) #define BIT_STATUS_AT(stats,n) \ - ((n) < BIT_STATUS_BITS_NUM ? ((stats) & (1 << n)) : ((stats) & 1)) + ((n) < (int )BIT_STATUS_BITS_NUM ? ((stats) & (1 << n)) : ((stats) & 1)) #define BIT_STATUS_ON_AT(stats,n) do {\ - if ((n) < BIT_STATUS_BITS_NUM)\ + if ((n) < (int )BIT_STATUS_BITS_NUM) \ (stats) |= (1 << (n));\ else\ (stats) |= 1;\ } while (0) #define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\ - if ((n) < BIT_STATUS_BITS_NUM)\ + if ((n) < (int )BIT_STATUS_BITS_NUM)\ (stats) |= (1 << (n));\ } while (0) @@ -401,7 +291,6 @@ typedef unsigned int BitStatusType; #define IS_EXTEND(option) ((option) & ONIG_OPTION_EXTEND) #define IS_FIND_LONGEST(option) ((option) & ONIG_OPTION_FIND_LONGEST) #define IS_FIND_NOT_EMPTY(option) ((option) & ONIG_OPTION_FIND_NOT_EMPTY) -#define IS_POSIXLINE(option) (IS_SINGLELINE(option) && IS_MULTILINE(option)) #define IS_FIND_CONDITION(option) ((option) & \ (ONIG_OPTION_FIND_LONGEST | ONIG_OPTION_FIND_NOT_EMPTY)) #define IS_NOTBOL(option) ((option) & ONIG_OPTION_NOTBOL) @@ -415,6 +304,9 @@ typedef unsigned int BitStatusType; /* ignore-case and multibyte status are included in compiled code. */ #define IS_DYNAMIC_OPTION(option) 0 +#define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag) \ + ((case_fold_flag) & ~INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) + #define REPEAT_INFINITE -1 #define IS_REPEAT_INFINITE(n) ((n) == REPEAT_INFINITE) @@ -436,7 +328,7 @@ typedef Bits* BitSetRef; #define BITSET_CLEAR(bs) do {\ int i;\ - for (i = 0; i < BITSET_SIZE; i++) { (bs)[i] = 0; }\ + for (i = 0; i < (int )BITSET_SIZE; i++) { (bs)[i] = 0; } \ } while (0) #define BS_ROOM(bs,pos) (bs)[pos / BITS_IN_ROOM] @@ -603,7 +495,7 @@ enum OpCode { OP_BACKREFN_IC, OP_BACKREF_MULTI, OP_BACKREF_MULTI_IC, - OP_BACKREF_AT_LEVEL, /* \k, \k */ + OP_BACKREF_WITH_LEVEL, /* \k, \k */ OP_MEMORY_START, OP_MEMORY_START_PUSH, /* push back-tracker to stack */ @@ -612,9 +504,6 @@ enum OpCode { OP_MEMORY_END, OP_MEMORY_END_REC, /* push marker to stack */ - OP_SET_OPTION_PUSH, /* set option and push recover option */ - OP_SET_OPTION, /* set option */ - OP_FAIL, /* pop stack and move */ OP_JUMP, OP_PUSH, @@ -649,7 +538,11 @@ enum OpCode { OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump */ OP_STATE_CHECK, /* check only */ OP_STATE_CHECK_ANYCHAR_STAR, - OP_STATE_CHECK_ANYCHAR_ML_STAR + OP_STATE_CHECK_ANYCHAR_ML_STAR, + + /* no need: IS_DYNAMIC_OPTION() == 0 */ + OP_SET_OPTION_PUSH, /* set option and push recover option */ + OP_SET_OPTION /* set option */ }; typedef int RelAddrType; @@ -672,22 +565,6 @@ typedef void* PointerType; #define SIZE_POINTER sizeof(PointerType) -#ifdef PLATFORM_UNALIGNED_WORD_ACCESS - -#define PLATFORM_GET_INC(val,p,type) do{\ - val = *(type* )p;\ - (p) += sizeof(type);\ -} while(0) - -#else - -#define PLATFORM_GET_INC(val,p,type) do{\ - xmemcpy(&val, (p), sizeof(type));\ - (p) += sizeof(type);\ -} while(0) - -#endif /* PLATFORM_UNALIGNED_WORD_ACCESS */ - #define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType) #define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType) #define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType) @@ -745,15 +622,15 @@ typedef void* PointerType; #define SIZE_OP_STATE_CHECK_ANYCHAR_STAR (SIZE_OPCODE + SIZE_STATE_CHECK_NUM) #endif -#define MC_ESC(enc) (enc)->meta_char_table.esc -#define MC_ANYCHAR(enc) (enc)->meta_char_table.anychar -#define MC_ANYTIME(enc) (enc)->meta_char_table.anytime -#define MC_ZERO_OR_ONE_TIME(enc) (enc)->meta_char_table.zero_or_one_time -#define MC_ONE_OR_MORE_TIME(enc) (enc)->meta_char_table.one_or_more_time -#define MC_ANYCHAR_ANYTIME(enc) (enc)->meta_char_table.anychar_anytime +#define MC_ESC(syn) (syn)->meta_char_table.esc +#define MC_ANYCHAR(syn) (syn)->meta_char_table.anychar +#define MC_ANYTIME(syn) (syn)->meta_char_table.anytime +#define MC_ZERO_OR_ONE_TIME(syn) (syn)->meta_char_table.zero_or_one_time +#define MC_ONE_OR_MORE_TIME(syn) (syn)->meta_char_table.one_or_more_time +#define MC_ANYCHAR_ANYTIME(syn) (syn)->meta_char_table.anychar_anytime -#define IS_MC_ESC_CODE(code, enc, syn) \ - ((code) == MC_ESC(enc) && \ +#define IS_MC_ESC_CODE(code, syn) \ + ((code) == MC_ESC(syn) && \ !IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE)) @@ -782,22 +659,96 @@ typedef void* PointerType; ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \ ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC ) + +#define NCCLASS_FLAGS(cc) ((cc)->flags) +#define NCCLASS_FLAG_SET(cc,flag) (NCCLASS_FLAGS(cc) |= (flag)) +#define NCCLASS_FLAG_CLEAR(cc,flag) (NCCLASS_FLAGS(cc) &= ~(flag)) +#define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0) + /* cclass node */ -#define FLAG_CCLASS_NOT 1 -#define FLAG_CCLASS_SHARE (1<<1) +#define FLAG_NCCLASS_NOT (1<<0) +#define FLAG_NCCLASS_SHARE (1<<1) -#define CCLASS_SET_NOT(cc) (cc)->flags |= FLAG_CCLASS_NOT -#define CCLASS_CLEAR_NOT(cc) (cc)->flags &= ~FLAG_CCLASS_NOT -#define CCLASS_SET_SHARE(cc) (cc)->flags |= FLAG_CCLASS_SHARE -#define IS_CCLASS_NOT(cc) (((cc)->flags & FLAG_CCLASS_NOT) != 0) -#define IS_CCLASS_SHARE(cc) (((cc)->flags & FLAG_CCLASS_SHARE) != 0) +#define NCCLASS_SET_NOT(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT) +#define NCCLASS_SET_SHARE(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_SHARE) +#define NCCLASS_CLEAR_NOT(nd) NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT) +#define IS_NCCLASS_NOT(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT) +#define IS_NCCLASS_SHARE(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_SHARE) typedef struct { - int flags; + int type; + /* struct _Node* next; */ + /* unsigned int flags; */ +} NodeBase; + +typedef struct { + NodeBase base; + unsigned int flags; BitSet bs; - BBuf* mbuf; /* multi-byte info or NULL */ + BBuf* mbuf; /* multi-byte info or NULL */ } CClassNode; +typedef long OnigStackIndex; + +typedef struct _OnigStackType { + unsigned int type; + union { + struct { + UChar *pcode; /* byte code position */ + UChar *pstr; /* string position */ + UChar *pstr_prev; /* previous char position of pstr */ +#ifdef USE_COMBINATION_EXPLOSION_CHECK + unsigned int state_check; +#endif + } state; + struct { + int count; /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */ + UChar *pcode; /* byte code position (head of repeated target) */ + int num; /* repeat id */ + } repeat; + struct { + OnigStackIndex si; /* index of stack */ + } repeat_inc; + struct { + int num; /* memory num */ + UChar *pstr; /* start/end position */ + /* Following information is setted, if this stack type is MEM-START */ + OnigStackIndex start; /* prev. info (for backtrack "(...)*" ) */ + OnigStackIndex end; /* prev. info (for backtrack "(...)*" ) */ + } mem; + struct { + int num; /* null check id */ + UChar *pstr; /* start position */ + } null_check; +#ifdef USE_SUBEXP_CALL + struct { + UChar *ret_addr; /* byte code position */ + int num; /* null check id */ + UChar *pstr; /* string position */ + } call_frame; +#endif + } u; +} OnigStackType; + +typedef struct { + void* stack_p; + int stack_n; + OnigOptionType options; + OnigRegion* region; + const UChar* start; /* search start position (for \G: BEGIN_POSITION) */ +#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE + int best_len; /* for ONIG_OPTION_FIND_LONGEST */ + UChar* best_s; +#endif +#ifdef USE_COMBINATION_EXPLOSION_CHECK + void* state_check_buff; + int state_check_buff_size; +#endif +} OnigMatchArg; + + +#define IS_CODE_SB_WORD(enc,code) \ + (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code)) #ifdef ONIG_DEBUG @@ -820,11 +771,38 @@ extern void onig_print_statistics P_((FILE* f)); extern UChar* onig_error_code_to_format P_((int code)); extern void onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...)); extern int onig_bbuf_init P_((BBuf* buf, int size)); -extern int onig_alloc_init P_((regex_t** reg, OnigOptionType option, OnigAmbigType ambig_flag, OnigEncoding enc, OnigSyntaxType* syntax)); extern int onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo)); extern void onig_chain_reduce P_((regex_t* reg)); extern void onig_chain_link_add P_((regex_t* to, regex_t* add)); extern void onig_transfer P_((regex_t* to, regex_t* from)); extern int onig_is_code_in_cc P_((OnigEncoding enc, OnigCodePoint code, CClassNode* cc)); +extern int onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, CClassNode* cc)); + +/* strend hash */ +typedef void hash_table_type; +typedef unsigned long hash_data_type; + +extern hash_table_type* onig_st_init_strend_table_with_size P_((int size)); +extern int onig_st_lookup_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value)); +extern int onig_st_insert_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value)); + +/* encoding property management */ +#define PROPERTY_LIST_ADD_PROP(Name, CR) \ + r = onigenc_property_list_add_property((UChar* )Name, CR,\ + &PropertyNameTable, &PropertyList, &PropertyListNum,\ + &PropertyListSize);\ + if (r != 0) goto end + +#define PROPERTY_LIST_INIT_CHECK \ + if (PropertyInited == 0) {\ + int r = onigenc_property_list_init(init_property_list);\ + if (r != 0) return r;\ + } + +extern int onigenc_property_list_add_property P_((UChar* name, const OnigCodePoint* prop, hash_table_type **table, const OnigCodePoint*** plist, int *pnum, int *psize)); + +typedef int (*ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE)(void); + +extern int onigenc_property_list_init P_((ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE)); #endif /* REGINT_H */ diff --git a/ext/mbstring/oniguruma/regparse.c b/ext/mbstring/oniguruma/regparse.c index abf2cc1cb5a8d..01131300c66a8 100644 --- a/ext/mbstring/oniguruma/regparse.c +++ b/ext/mbstring/oniguruma/regparse.c @@ -2,7 +2,7 @@ regparse.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2007 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,9 +28,13 @@ */ #include "regparse.h" +#include "st.h" #define WARN_BUFSIZE 256 +#define CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS + + OnigSyntaxType OnigSyntaxRuby = { (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY | ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 | @@ -41,6 +45,8 @@ OnigSyntaxType OnigSyntaxRuby = { ONIG_SYN_OP2_OPTION_RUBY | ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP | ONIG_SYN_OP2_ESC_K_NAMED_BACKREF | ONIG_SYN_OP2_ESC_G_SUBEXP_CALL | + ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY | + ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT | ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT | ONIG_SYN_OP2_CCLASS_SET_OP | ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL | ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META | ONIG_SYN_OP2_ESC_V_VTAB | @@ -54,25 +60,20 @@ OnigSyntaxType OnigSyntaxRuby = { ONIG_SYN_WARN_CC_OP_NOT_ESCAPED | ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT ) , ONIG_OPTION_NONE + , + { + (OnigCodePoint )'\\' /* esc */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ + } }; OnigSyntaxType* OnigDefaultSyntax = ONIG_SYNTAX_RUBY; -extern void onig_null_warn(const char* s) { } - -#ifdef RUBY_PLATFORM -extern void -onig_rb_warn(const char* s) -{ - rb_warn("%s", s); -} - -extern void -onig_rb_warning(const char* s) -{ - rb_warning("%s", s); -} -#endif +extern void onig_null_warn(const char* s ARG_UNUSED) { } #ifdef DEFAULT_WARN_FUNCTION static OnigWarnFunc onig_warn = (OnigWarnFunc )DEFAULT_WARN_FUNCTION; @@ -112,7 +113,7 @@ bbuf_clone(BBuf** rto, BBuf* from) BBuf *to; *rto = to = (BBuf* )xmalloc(sizeof(BBuf)); - CHECK_NULL_RETURN_VAL(to, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(to); r = BBUF_INIT(to, from->alloc); if (r != 0) return r; to->used = from->used; @@ -120,6 +121,9 @@ bbuf_clone(BBuf** rto, BBuf* from) return 0; } +#define BACKREF_REL_TO_ABS(rel_no, env) \ + ((env)->num_mem + 1 + (rel_no)) + #define ONOFF(v,f,negative) (negative) ? ((v) &= ~(f)) : ((v) |= (f)) #define MBCODE_START_POS(enc) \ @@ -139,7 +143,7 @@ bbuf_clone(BBuf** rto, BBuf* from) #define BITSET_IS_EMPTY(bs,empty) do {\ int i;\ empty = 1;\ - for (i = 0; i < BITSET_SIZE; i++) {\ + for (i = 0; i < (int )BITSET_SIZE; i++) {\ if ((bs)[i] != 0) {\ empty = 0; break;\ }\ @@ -160,9 +164,7 @@ static void bitset_set_all(BitSetRef bs) { int i; - for (i = 0; i < BITSET_SIZE; i++) { - bs[i] = ~((Bits )0); - } + for (i = 0; i < BITSET_SIZE; i++) { bs[i] = ~((Bits )0); } } #endif @@ -170,45 +172,35 @@ static void bitset_invert(BitSetRef bs) { int i; - for (i = 0; i < BITSET_SIZE; i++) { - bs[i] = ~(bs[i]); - } + for (i = 0; i < (int )BITSET_SIZE; i++) { bs[i] = ~(bs[i]); } } static void bitset_invert_to(BitSetRef from, BitSetRef to) { int i; - for (i = 0; i < BITSET_SIZE; i++) { - to[i] = ~(from[i]); - } + for (i = 0; i < (int )BITSET_SIZE; i++) { to[i] = ~(from[i]); } } static void bitset_and(BitSetRef dest, BitSetRef bs) { int i; - for (i = 0; i < BITSET_SIZE; i++) { - dest[i] &= bs[i]; - } + for (i = 0; i < (int )BITSET_SIZE; i++) { dest[i] &= bs[i]; } } static void bitset_or(BitSetRef dest, BitSetRef bs) { int i; - for (i = 0; i < BITSET_SIZE; i++) { - dest[i] |= bs[i]; - } + for (i = 0; i < (int )BITSET_SIZE; i++) { dest[i] |= bs[i]; } } static void bitset_copy(BitSetRef dest, BitSetRef bs) { int i; - for (i = 0; i < BITSET_SIZE; i++) { - dest[i] = bs[i]; - } + for (i = 0; i < (int )BITSET_SIZE; i++) { dest[i] = bs[i]; } } extern int @@ -223,8 +215,8 @@ onig_strncmp(const UChar* s1, const UChar* s2, int n) return 0; } -static void -k_strcpy(UChar* dest, const UChar* src, const UChar* end) +extern void +onig_strcpy(UChar* dest, const UChar* src, const UChar* end) { int len = end - src; if (len > 0) { @@ -233,6 +225,7 @@ k_strcpy(UChar* dest, const UChar* src, const UChar* end) } } +#ifdef USE_NAMED_GROUP static UChar* strdup_with_null(OnigEncoding enc, UChar* s, UChar* end) { @@ -251,7 +244,7 @@ strdup_with_null(OnigEncoding enc, UChar* s, UChar* end) return r; } - +#endif /* scan pattern methods */ #define PEND_VALUE 0 @@ -273,7 +266,7 @@ strdup_with_null(OnigEncoding enc, UChar* s, UChar* end) #define PPEEK_IS(c) (PPEEK == (OnigCodePoint )c) static UChar* -k_strcat_capa(UChar* dest, UChar* dest_end, const UChar* src, const UChar* src_end, +strcat_capa(UChar* dest, UChar* dest_end, const UChar* src, const UChar* src_end, int capa) { UChar* r; @@ -284,7 +277,7 @@ k_strcat_capa(UChar* dest, UChar* dest_end, const UChar* src, const UChar* src_e r = (UChar* )xmalloc(capa + 1); CHECK_NULL_RETURN(r); - k_strcpy(r + (dest_end - dest), src, src_end); + onig_strcpy(r + (dest_end - dest), src, src_end); return r; } @@ -297,78 +290,23 @@ strcat_capa_from_static(UChar* dest, UChar* dest_end, r = (UChar* )xmalloc(capa + 1); CHECK_NULL_RETURN(r); - k_strcpy(r, dest, dest_end); - k_strcpy(r + (dest_end - dest), src, src_end); + onig_strcpy(r, dest, dest_end); + onig_strcpy(r + (dest_end - dest), src, src_end); return r; } -#ifdef USE_NAMED_GROUP - -#define INIT_NAME_BACKREFS_ALLOC_NUM 8 - -typedef struct { - UChar* name; - int name_len; /* byte length */ - int back_num; /* number of backrefs */ - int back_alloc; - int back_ref1; - int* back_refs; -} NameEntry; - -#ifdef USE_ST_HASH_TABLE -#include "st.h" +#ifdef USE_ST_LIBRARY typedef struct { - unsigned char* s; - unsigned char* end; -} st_strend_key; - -static int strend_cmp(st_strend_key*, st_strend_key*); -static int strend_hash(st_strend_key*); - -static struct st_hash_type type_strend_hash = { - strend_cmp, - strend_hash, -}; - -static st_table* -onig_st_init_strend_table_with_size(int size) -{ - return onig_st_init_table_with_size(&type_strend_hash, size); -} - -static int -onig_st_lookup_strend(st_table *table, const UChar* str_key, const UChar* end_key, st_data_t *value) -{ - st_strend_key key; - - key.s = (unsigned char* )str_key; - key.end = (unsigned char* )end_key; - - return onig_st_lookup(table, (st_data_t )(&key), value); -} - -static int -onig_st_insert_strend(st_table *table, const UChar* str_key, const UChar* end_key, st_data_t value) -{ - st_strend_key* key; - int result; - - key = (st_strend_key* )xmalloc(sizeof(st_strend_key)); - key->s = (unsigned char* )str_key; - key->end = (unsigned char* )end_key; - result = onig_st_insert(table, (st_data_t )key, value); - if (result) { - xfree(key); - } - return result; -} + UChar* s; + UChar* end; +} st_str_end_key; static int -strend_cmp(st_strend_key* x, st_strend_key* y) +str_end_cmp(st_str_end_key* x, st_str_end_key* y) { - unsigned char *p, *q; + UChar *p, *q; int c; if ((x->end - x->s) != (y->end - y->s)) @@ -387,12 +325,11 @@ strend_cmp(st_strend_key* x, st_strend_key* y) } static int -strend_hash(st_strend_key* x) +str_end_hash(st_str_end_key* x) { - int val; - unsigned char *p; + UChar *p; + int val = 0; - val = 0; p = x->s; while (p < x->end) { val = val * 997 + (int )*p++; @@ -401,6 +338,65 @@ strend_hash(st_strend_key* x) return val + (val >> 5); } +extern hash_table_type* +onig_st_init_strend_table_with_size(int size) +{ + static struct st_hash_type hashType = { + str_end_cmp, + str_end_hash, + }; + + return (hash_table_type* ) + onig_st_init_table_with_size(&hashType, size); +} + +extern int +onig_st_lookup_strend(hash_table_type* table, const UChar* str_key, + const UChar* end_key, hash_data_type *value) +{ + st_str_end_key key; + + key.s = (UChar* )str_key; + key.end = (UChar* )end_key; + + return onig_st_lookup(table, (st_data_t )(&key), value); +} + +extern int +onig_st_insert_strend(hash_table_type* table, const UChar* str_key, + const UChar* end_key, hash_data_type value) +{ + st_str_end_key* key; + int result; + + key = (st_str_end_key* )xmalloc(sizeof(st_str_end_key)); + key->s = (UChar* )str_key; + key->end = (UChar* )end_key; + result = onig_st_insert(table, (st_data_t )key, value); + if (result) { + xfree(key); + } + return result; +} + +#endif /* USE_ST_LIBRARY */ + + +#ifdef USE_NAMED_GROUP + +#define INIT_NAME_BACKREFS_ALLOC_NUM 8 + +typedef struct { + UChar* name; + int name_len; /* byte length */ + int back_num; /* number of backrefs */ + int back_alloc; + int back_ref1; + int* back_refs; +} NameEntry; + +#ifdef USE_ST_LIBRARY + typedef st_table NameTable; typedef st_data_t HashDataType; /* 1.6 st.h doesn't define st_data_t type */ @@ -441,10 +437,10 @@ onig_print_names(FILE* fp, regex_t* reg) } return 0; } -#endif +#endif /* ONIG_DEBUG */ static int -i_free_name_entry(UChar* key, NameEntry* e, void* arg) +i_free_name_entry(UChar* key, NameEntry* e, void* arg ARG_UNUSED) { xfree(e->name); if (IS_NOT_NULL(e->back_refs)) xfree(e->back_refs); @@ -501,10 +497,9 @@ typedef struct { } INamesArg; static int -i_names(UChar* key, NameEntry* e, INamesArg* arg) +i_names(UChar* key ARG_UNUSED, NameEntry* e, INamesArg* arg) { int r = (*(arg->func))(e->name, - /*e->name + onigenc_str_bytelen_null(arg->enc, e->name), */ e->name + e->name_len, e->back_num, (e->back_num > 1 ? e->back_refs : &(e->back_ref1)), @@ -518,8 +513,7 @@ i_names(UChar* key, NameEntry* e, INamesArg* arg) extern int onig_foreach_name(regex_t* reg, - int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), - void* arg) + int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), void* arg) { INamesArg narg; NameTable* t = (NameTable* )reg->name_table; @@ -536,7 +530,7 @@ onig_foreach_name(regex_t* reg, } static int -i_renumber_name(UChar* key, NameEntry* e, GroupNumRemap* map) +i_renumber_name(UChar* key ARG_UNUSED, NameEntry* e, GroupNumRemap* map) { int i; @@ -575,7 +569,7 @@ onig_number_of_names(regex_t* reg) return 0; } -#else /* USE_ST_HASH_TABLE */ +#else /* USE_ST_LIBRARY */ #define INIT_NAMES_ALLOC_NUM 8 @@ -585,7 +579,6 @@ typedef struct { int alloc; } NameTable; - #ifdef ONIG_DEBUG extern int onig_print_names(FILE* fp, regex_t* reg) @@ -683,8 +676,7 @@ name_find(regex_t* reg, UChar* name, UChar* name_end) extern int onig_foreach_name(regex_t* reg, - int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), - void* arg) + int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), void* arg) { int i, r; NameEntry* e; @@ -713,7 +705,7 @@ onig_number_of_names(regex_t* reg) return 0; } -#endif /* else USE_ST_HASH_TABLE */ +#endif /* else USE_ST_LIBRARY */ static int name_add(regex_t* reg, UChar* name, UChar* name_end, int backref, ScanEnv* env) @@ -727,16 +719,18 @@ name_add(regex_t* reg, UChar* name, UChar* name_end, int backref, ScanEnv* env) e = name_find(reg, name, name_end); if (IS_NULL(e)) { -#ifdef USE_ST_HASH_TABLE +#ifdef USE_ST_LIBRARY if (IS_NULL(t)) { t = onig_st_init_strend_table_with_size(5); reg->name_table = (void* )t; } e = (NameEntry* )xmalloc(sizeof(NameEntry)); - CHECK_NULL_RETURN_VAL(e, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(e); e->name = strdup_with_null(reg->enc, name, name_end); - if (IS_NULL(e->name)) return ONIGERR_MEMORY; + if (IS_NULL(e->name)) { + xfree(e); return ONIGERR_MEMORY; + } onig_st_insert_strend(t, e->name, (e->name + (name_end - name)), (HashDataType )e); @@ -750,7 +744,7 @@ name_add(regex_t* reg, UChar* name, UChar* name_end, int backref, ScanEnv* env) if (IS_NULL(t)) { alloc = INIT_NAMES_ALLOC_NUM; t = (NameTable* )xmalloc(sizeof(NameTable)); - CHECK_NULL_RETURN_VAL(t, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(t); t->e = NULL; t->alloc = 0; t->num = 0; @@ -769,7 +763,7 @@ name_add(regex_t* reg, UChar* name, UChar* name_end, int backref, ScanEnv* env) alloc = t->alloc * 2; t->e = (NameEntry* )xrealloc(t->e, sizeof(NameEntry) * alloc); - CHECK_NULL_RETURN_VAL(t->e, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(t->e); t->alloc = alloc; clear: @@ -784,6 +778,7 @@ name_add(regex_t* reg, UChar* name, UChar* name_end, int backref, ScanEnv* env) e = &(t->e[t->num]); t->num++; e->name = strdup_with_null(reg->enc, name, name_end); + if (IS_NULL(e->name)) return ONIGERR_MEMORY; e->name_len = name_end - name; #endif } @@ -803,7 +798,7 @@ name_add(regex_t* reg, UChar* name, UChar* name_end, int backref, ScanEnv* env) if (e->back_num == 2) { alloc = INIT_NAME_BACKREFS_ALLOC_NUM; e->back_refs = (int* )xmalloc(sizeof(int) * alloc); - CHECK_NULL_RETURN_VAL(e->back_refs, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(e->back_refs); e->back_alloc = alloc; e->back_refs[0] = e->back_ref1; e->back_refs[1] = backref; @@ -812,7 +807,7 @@ name_add(regex_t* reg, UChar* name, UChar* name_end, int backref, ScanEnv* env) if (e->back_num > e->back_alloc) { alloc = e->back_alloc * 2; e->back_refs = (int* )xrealloc(e->back_refs, sizeof(int) * alloc); - CHECK_NULL_RETURN_VAL(e->back_refs, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(e->back_refs); e->back_alloc = alloc; } e->back_refs[e->back_num - 1] = backref; @@ -826,9 +821,8 @@ extern int onig_name_to_group_numbers(regex_t* reg, const UChar* name, const UChar* name_end, int** nums) { - NameEntry* e; + NameEntry* e = name_find(reg, name, name_end); - e = name_find(reg, name, name_end); if (IS_NULL(e)) return ONIGERR_UNDEFINED_NAME_REFERENCE; switch (e->back_num) { @@ -886,8 +880,7 @@ onig_name_to_backref_number(regex_t* reg, const UChar* name, extern int onig_foreach_name(regex_t* reg, - int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), - void* arg) + int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), void* arg) { return ONIG_NO_SUPPORT_CONFIG; } @@ -928,12 +921,12 @@ scan_env_clear(ScanEnv* env) BIT_STATUS_CLEAR(env->bt_mem_start); BIT_STATUS_CLEAR(env->bt_mem_end); BIT_STATUS_CLEAR(env->backrefed_mem); - env->error = (UChar* )NULL; - env->error_end = (UChar* )NULL; - env->num_call = 0; - env->num_mem = 0; + env->error = (UChar* )NULL; + env->error_end = (UChar* )NULL; + env->num_call = 0; + env->num_mem = 0; #ifdef USE_NAMED_GROUP - env->num_named = 0; + env->num_named = 0; #endif env->mem_alloc = 0; env->mem_nodes_dynamic = (Node** )NULL; @@ -968,7 +961,7 @@ scan_env_add_mem_entry(ScanEnv* env) alloc = env->mem_alloc * 2; p = (Node** )xrealloc(env->mem_nodes_dynamic, sizeof(Node*) * alloc); } - CHECK_NULL_RETURN_VAL(p, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(p); for (i = env->num_mem + 1; i < alloc; i++) p[i] = NULL_NODE; @@ -993,7 +986,7 @@ scan_env_set_mem_node(ScanEnv* env, int num, Node* node) } -#ifdef USE_RECYCLE_NODE +#ifdef USE_PARSE_TREE_NODE_RECYCLE typedef struct _FreeNode { struct _FreeNode* next; } FreeNode; @@ -1008,20 +1001,20 @@ onig_node_free(Node* node) if (IS_NULL(node)) return ; switch (NTYPE(node)) { - case N_STRING: - if (IS_NOT_NULL(NSTRING(node).s) && NSTRING(node).s != NSTRING(node).buf) { - xfree(NSTRING(node).s); + case NT_STR: + if (NSTR(node)->capa != 0 && + IS_NOT_NULL(NSTR(node)->s) && NSTR(node)->s != NSTR(node)->buf) { + xfree(NSTR(node)->s); } break; - case N_LIST: - case N_ALT: - onig_node_free(NCONS(node).left); - /* onig_node_free(NCONS(node).right); */ + case NT_LIST: + case NT_ALT: + onig_node_free(NCAR(node)); { - Node* next_node = NCONS(node).right; + Node* next_node = NCDR(node); -#ifdef USE_RECYCLE_NODE +#ifdef USE_PARSE_TREE_NODE_RECYCLE { FreeNode* n = (FreeNode* )node; @@ -1033,46 +1026,43 @@ onig_node_free(Node* node) #else xfree(node); #endif - node = next_node; goto start; } break; - case N_CCLASS: + case NT_CCLASS: { - CClassNode* cc = &(NCCLASS(node)); - - if (IS_CCLASS_SHARE(cc)) - return ; + CClassNode* cc = NCCLASS(node); + if (IS_NCCLASS_SHARE(cc)) return ; if (cc->mbuf) bbuf_free(cc->mbuf); } break; - case N_QUANTIFIER: - if (NQUANTIFIER(node).target) - onig_node_free(NQUANTIFIER(node).target); + case NT_QTFR: + if (NQTFR(node)->target) + onig_node_free(NQTFR(node)->target); break; - case N_EFFECT: - if (NEFFECT(node).target) - onig_node_free(NEFFECT(node).target); + case NT_ENCLOSE: + if (NENCLOSE(node)->target) + onig_node_free(NENCLOSE(node)->target); break; - case N_BACKREF: - if (IS_NOT_NULL(NBACKREF(node).back_dynamic)) - xfree(NBACKREF(node).back_dynamic); + case NT_BREF: + if (IS_NOT_NULL(NBREF(node)->back_dynamic)) + xfree(NBREF(node)->back_dynamic); break; - case N_ANCHOR: - if (NANCHOR(node).target) - onig_node_free(NANCHOR(node).target); + case NT_ANCHOR: + if (NANCHOR(node)->target) + onig_node_free(NANCHOR(node)->target); break; } -#ifdef USE_RECYCLE_NODE +#ifdef USE_PARSE_TREE_NODE_RECYCLE { FreeNode* n = (FreeNode* )node; @@ -1086,7 +1076,7 @@ onig_node_free(Node* node) #endif } -#ifdef USE_RECYCLE_NODE +#ifdef USE_PARSE_TREE_NODE_RECYCLE extern int onig_free_node_list(void) { @@ -1108,7 +1098,7 @@ node_new(void) { Node* node; -#ifdef USE_RECYCLE_NODE +#ifdef USE_PARSE_TREE_NODE_RECYCLE THREAD_ATOMIC_START; if (IS_NOT_NULL(FreeNodeList)) { node = (Node* )FreeNodeList; @@ -1120,6 +1110,7 @@ node_new(void) #endif node = (Node* )xmalloc(sizeof(Node)); + /* xmemset(node, 0, sizeof(Node)); */ return node; } @@ -1128,6 +1119,7 @@ static void initialize_cclass(CClassNode* cc) { BITSET_CLEAR(cc->bs); + /* cc->base.flags = 0; */ cc->flags = 0; cc->mbuf = NULL; } @@ -1137,53 +1129,55 @@ node_new_cclass(void) { Node* node = node_new(); CHECK_NULL_RETURN(node); - node->type = N_CCLASS; - initialize_cclass(&(NCCLASS(node))); + SET_NTYPE(node, NT_CCLASS); + initialize_cclass(NCCLASS(node)); return node; } static Node* -node_new_cclass_by_codepoint_range(int not, - const OnigCodePoint sbr[], const OnigCodePoint mbr[]) +node_new_cclass_by_codepoint_range(int not, OnigCodePoint sb_out, + const OnigCodePoint ranges[]) { + int n, i; CClassNode* cc; - int n, i, j; + OnigCodePoint j; - Node* node = node_new(); + Node* node = node_new_cclass(); CHECK_NULL_RETURN(node); - node->type = N_CCLASS; - cc = &(NCCLASS(node)); - cc->flags = 0; - if (not != 0) CCLASS_SET_NOT(cc); + cc = NCCLASS(node); + if (not != 0) NCCLASS_SET_NOT(cc); BITSET_CLEAR(cc->bs); - if (IS_NOT_NULL(sbr)) { - n = ONIGENC_CODE_RANGE_NUM(sbr); + if (sb_out > 0 && IS_NOT_NULL(ranges)) { + n = ONIGENC_CODE_RANGE_NUM(ranges); for (i = 0; i < n; i++) { - for (j = ONIGENC_CODE_RANGE_FROM(sbr, i); - j <= (int )ONIGENC_CODE_RANGE_TO(sbr, i); j++) { + for (j = ONIGENC_CODE_RANGE_FROM(ranges, i); + j <= (OnigCodePoint )ONIGENC_CODE_RANGE_TO(ranges, i); j++) { + if (j >= sb_out) goto sb_end; + BITSET_SET_BIT(cc->bs, j); } } } - if (IS_NULL(mbr)) { + sb_end: + if (IS_NULL(ranges)) { is_null: cc->mbuf = NULL; } else { BBuf* bbuf; - n = ONIGENC_CODE_RANGE_NUM(mbr); + n = ONIGENC_CODE_RANGE_NUM(ranges); if (n == 0) goto is_null; bbuf = (BBuf* )xmalloc(sizeof(BBuf)); - CHECK_NULL_RETURN_VAL(bbuf, NULL); + CHECK_NULL_RETURN(bbuf); bbuf->alloc = n + 1; bbuf->used = n + 1; - bbuf->p = (UChar* )((void* )mbr); + bbuf->p = (UChar* )((void* )ranges); cc->mbuf = bbuf; } @@ -1192,12 +1186,14 @@ node_new_cclass_by_codepoint_range(int not, } static Node* -node_new_ctype(int type) +node_new_ctype(int type, int not) { Node* node = node_new(); CHECK_NULL_RETURN(node); - node->type = N_CTYPE; - NCTYPE(node).type = type; + + SET_NTYPE(node, NT_CTYPE); + NCTYPE(node)->ctype = type; + NCTYPE(node)->not = not; return node; } @@ -1206,7 +1202,8 @@ node_new_anychar(void) { Node* node = node_new(); CHECK_NULL_RETURN(node); - node->type = N_ANYCHAR; + + SET_NTYPE(node, NT_CANY); return node; } @@ -1215,9 +1212,10 @@ node_new_list(Node* left, Node* right) { Node* node = node_new(); CHECK_NULL_RETURN(node); - node->type = N_LIST; - NCONS(node).left = left; - NCONS(node).right = right; + + SET_NTYPE(node, NT_LIST); + NCAR(node) = left; + NCDR(node) = right; return node; } @@ -1227,14 +1225,33 @@ onig_node_new_list(Node* left, Node* right) return node_new_list(left, right); } -static Node* -node_new_alt(Node* left, Node* right) +extern Node* +onig_node_list_add(Node* list, Node* x) +{ + Node *n; + + n = onig_node_new_list(x, NULL); + if (IS_NULL(n)) return NULL_NODE; + + if (IS_NOT_NULL(list)) { + while (IS_NOT_NULL(NCDR(list))) + list = NCDR(list); + + NCDR(list) = n; + } + + return n; +} + +extern Node* +onig_node_new_alt(Node* left, Node* right) { Node* node = node_new(); CHECK_NULL_RETURN(node); - node->type = N_ALT; - NCONS(node).left = left; - NCONS(node).right = right; + + SET_NTYPE(node, NT_ALT); + NCAR(node) = left; + NCDR(node) = right; return node; } @@ -1243,16 +1260,17 @@ onig_node_new_anchor(int type) { Node* node = node_new(); CHECK_NULL_RETURN(node); - node->type = N_ANCHOR; - NANCHOR(node).type = type; - NANCHOR(node).target = NULL; - NANCHOR(node).char_len = -1; + + SET_NTYPE(node, NT_ANCHOR); + NANCHOR(node)->type = type; + NANCHOR(node)->target = NULL; + NANCHOR(node)->char_len = -1; return node; } static Node* node_new_backref(int back_num, int* backrefs, int by_name, -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL int exist_level, int nest_level, #endif ScanEnv* env) @@ -1261,31 +1279,32 @@ node_new_backref(int back_num, int* backrefs, int by_name, Node* node = node_new(); CHECK_NULL_RETURN(node); - node->type = N_BACKREF; - NBACKREF(node).state = 0; - NBACKREF(node).back_num = back_num; - NBACKREF(node).back_dynamic = (int* )NULL; + + SET_NTYPE(node, NT_BREF); + NBREF(node)->state = 0; + NBREF(node)->back_num = back_num; + NBREF(node)->back_dynamic = (int* )NULL; if (by_name != 0) - NBACKREF(node).state |= NST_NAME_REF; + NBREF(node)->state |= NST_NAME_REF; -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL if (exist_level != 0) { - NBACKREF(node).state |= NST_NEST_LEVEL; - NBACKREF(node).nest_level = nest_level; + NBREF(node)->state |= NST_NEST_LEVEL; + NBREF(node)->nest_level = nest_level; } #endif for (i = 0; i < back_num; i++) { if (backrefs[i] <= env->num_mem && IS_NULL(SCANENV_MEM_NODES(env)[backrefs[i]])) { - NBACKREF(node).state |= NST_RECURSION; /* /...(\1).../ */ + NBREF(node)->state |= NST_RECURSION; /* /...(\1).../ */ break; } } if (back_num <= NODE_BACKREFS_SIZE) { for (i = 0; i < back_num; i++) - NBACKREF(node).back_static[i] = backrefs[i]; + NBREF(node)->back_static[i] = backrefs[i]; } else { int* p = (int* )xmalloc(sizeof(int) * back_num); @@ -1293,7 +1312,7 @@ node_new_backref(int back_num, int* backrefs, int by_name, onig_node_free(node); return NULL; } - NBACKREF(node).back_dynamic = p; + NBREF(node)->back_dynamic = p; for (i = 0; i < back_num; i++) p[i] = backrefs[i]; } @@ -1302,17 +1321,17 @@ node_new_backref(int back_num, int* backrefs, int by_name, #ifdef USE_SUBEXP_CALL static Node* -node_new_call(UChar* name, UChar* name_end) +node_new_call(UChar* name, UChar* name_end, int gnum) { Node* node = node_new(); CHECK_NULL_RETURN(node); - node->type = N_CALL; - NCALL(node).state = 0; - NCALL(node).ref_num = CALLNODE_REFNUM_UNDEF; - NCALL(node).target = NULL_NODE; - NCALL(node).name = name; - NCALL(node).name_end = name_end; + SET_NTYPE(node, NT_CALL); + NCALL(node)->state = 0; + NCALL(node)->target = NULL_NODE; + NCALL(node)->name = name; + NCALL(node)->name_end = name_end; + NCALL(node)->group_num = gnum; /* call by number if gnum != 0 */ return node; } #endif @@ -1322,58 +1341,60 @@ node_new_quantifier(int lower, int upper, int by_number) { Node* node = node_new(); CHECK_NULL_RETURN(node); - node->type = N_QUANTIFIER; - NQUANTIFIER(node).state = 0; - NQUANTIFIER(node).target = NULL; - NQUANTIFIER(node).lower = lower; - NQUANTIFIER(node).upper = upper; - NQUANTIFIER(node).greedy = 1; - NQUANTIFIER(node).target_empty_info = NQ_TARGET_ISNOT_EMPTY; - NQUANTIFIER(node).head_exact = NULL_NODE; - NQUANTIFIER(node).next_head_exact = NULL_NODE; - NQUANTIFIER(node).is_refered = 0; + + SET_NTYPE(node, NT_QTFR); + NQTFR(node)->state = 0; + NQTFR(node)->target = NULL; + NQTFR(node)->lower = lower; + NQTFR(node)->upper = upper; + NQTFR(node)->greedy = 1; + NQTFR(node)->target_empty_info = NQ_TARGET_ISNOT_EMPTY; + NQTFR(node)->head_exact = NULL_NODE; + NQTFR(node)->next_head_exact = NULL_NODE; + NQTFR(node)->is_refered = 0; if (by_number != 0) - NQUANTIFIER(node).state |= NST_BY_NUMBER; + NQTFR(node)->state |= NST_BY_NUMBER; #ifdef USE_COMBINATION_EXPLOSION_CHECK - NQUANTIFIER(node).comb_exp_check_num = 0; + NQTFR(node)->comb_exp_check_num = 0; #endif return node; } static Node* -node_new_effect(int type) +node_new_enclose(int type) { Node* node = node_new(); CHECK_NULL_RETURN(node); - node->type = N_EFFECT; - NEFFECT(node).type = type; - NEFFECT(node).state = 0; - NEFFECT(node).regnum = 0; - NEFFECT(node).option = 0; - NEFFECT(node).target = NULL; - NEFFECT(node).call_addr = -1; - NEFFECT(node).opt_count = 0; + + SET_NTYPE(node, NT_ENCLOSE); + NENCLOSE(node)->type = type; + NENCLOSE(node)->state = 0; + NENCLOSE(node)->regnum = 0; + NENCLOSE(node)->option = 0; + NENCLOSE(node)->target = NULL; + NENCLOSE(node)->call_addr = -1; + NENCLOSE(node)->opt_count = 0; return node; } extern Node* -onig_node_new_effect(int type) +onig_node_new_enclose(int type) { - return node_new_effect(type); + return node_new_enclose(type); } static Node* -node_new_effect_memory(OnigOptionType option, int is_named) +node_new_enclose_memory(OnigOptionType option, int is_named) { - Node* node = node_new_effect(EFFECT_MEMORY); + Node* node = node_new_enclose(ENCLOSE_MEMORY); CHECK_NULL_RETURN(node); if (is_named != 0) - SET_EFFECT_STATUS(node, NST_NAMED_GROUP); + SET_ENCLOSE_STATUS(node, NST_NAMED_GROUP); #ifdef USE_SUBEXP_CALL - NEFFECT(node).option = option; + NENCLOSE(node)->option = option; #endif return node; } @@ -1381,9 +1402,9 @@ node_new_effect_memory(OnigOptionType option, int is_named) static Node* node_new_option(OnigOptionType option) { - Node* node = node_new_effect(EFFECT_OPTION); + Node* node = node_new_enclose(ENCLOSE_OPTION); CHECK_NULL_RETURN(node); - NEFFECT(node).option = option; + NENCLOSE(node)->option = option; return node; } @@ -1393,36 +1414,43 @@ onig_node_str_cat(Node* node, const UChar* s, const UChar* end) int addlen = end - s; if (addlen > 0) { - int len = NSTRING(node).end - NSTRING(node).s; + int len = NSTR(node)->end - NSTR(node)->s; - if (NSTRING(node).capa > 0 || (len + addlen > NODE_STR_BUF_SIZE - 1)) { + if (NSTR(node)->capa > 0 || (len + addlen > NODE_STR_BUF_SIZE - 1)) { UChar* p; int capa = len + addlen + NODE_STR_MARGIN; - if (capa <= NSTRING(node).capa) { - k_strcpy(NSTRING(node).s + len, s, end); + if (capa <= NSTR(node)->capa) { + onig_strcpy(NSTR(node)->s + len, s, end); } else { - if (NSTRING(node).s == NSTRING(node).buf) - p = strcat_capa_from_static(NSTRING(node).s, NSTRING(node).end, + if (NSTR(node)->s == NSTR(node)->buf) + p = strcat_capa_from_static(NSTR(node)->s, NSTR(node)->end, s, end, capa); else - p = k_strcat_capa(NSTRING(node).s, NSTRING(node).end, s, end, capa); + p = strcat_capa(NSTR(node)->s, NSTR(node)->end, s, end, capa); - CHECK_NULL_RETURN_VAL(p, ONIGERR_MEMORY); - NSTRING(node).s = p; - NSTRING(node).capa = capa; + CHECK_NULL_RETURN_MEMERR(p); + NSTR(node)->s = p; + NSTR(node)->capa = capa; } } else { - k_strcpy(NSTRING(node).s + len, s, end); + onig_strcpy(NSTR(node)->s + len, s, end); } - NSTRING(node).end = NSTRING(node).s + len + addlen; + NSTR(node)->end = NSTR(node)->s + len + addlen; } return 0; } +extern int +onig_node_str_set(Node* node, const UChar* s, const UChar* end) +{ + onig_node_str_clear(node); + return onig_node_str_cat(node, s, end); +} + static int node_str_cat_char(Node* node, UChar c) { @@ -1435,26 +1463,25 @@ node_str_cat_char(Node* node, UChar c) extern void onig_node_conv_to_str_node(Node* node, int flag) { - node->type = N_STRING; - - NSTRING(node).flag = flag; - NSTRING(node).capa = 0; - NSTRING(node).s = NSTRING(node).buf; - NSTRING(node).end = NSTRING(node).buf; + SET_NTYPE(node, NT_STR); + NSTR(node)->flag = flag; + NSTR(node)->capa = 0; + NSTR(node)->s = NSTR(node)->buf; + NSTR(node)->end = NSTR(node)->buf; } extern void onig_node_str_clear(Node* node) { - if (NSTRING(node).capa != 0 && - IS_NOT_NULL(NSTRING(node).s) && NSTRING(node).s != NSTRING(node).buf) { - xfree(NSTRING(node).s); + if (NSTR(node)->capa != 0 && + IS_NOT_NULL(NSTR(node)->s) && NSTR(node)->s != NSTR(node)->buf) { + xfree(NSTR(node)->s); } - NSTRING(node).capa = 0; - NSTRING(node).flag = 0; - NSTRING(node).s = NSTRING(node).buf; - NSTRING(node).end = NSTRING(node).buf; + NSTR(node)->capa = 0; + NSTR(node)->flag = 0; + NSTR(node)->s = NSTR(node)->buf; + NSTR(node)->end = NSTR(node)->buf; } static Node* @@ -1463,11 +1490,11 @@ node_new_str(const UChar* s, const UChar* end) Node* node = node_new(); CHECK_NULL_RETURN(node); - node->type = N_STRING; - NSTRING(node).capa = 0; - NSTRING(node).flag = 0; - NSTRING(node).s = NSTRING(node).buf; - NSTRING(node).end = NSTRING(node).buf; + SET_NTYPE(node, NT_STR); + NSTR(node)->capa = 0; + NSTR(node)->flag = 0; + NSTR(node)->s = NSTR(node)->buf; + NSTR(node)->end = NSTR(node)->buf; if (onig_node_str_cat(node, s, end)) { onig_node_free(node); return NULL; @@ -1481,7 +1508,6 @@ onig_node_new_str(const UChar* s, const UChar* end) return node_new_str(s, end); } -#ifdef NUMBERED_CHAR_IS_NOT_CASE_AMBIG static Node* node_new_str_raw(UChar* s, UChar* end) { @@ -1489,7 +1515,6 @@ node_new_str_raw(UChar* s, UChar* end) NSTRING_SET_RAW(node); return node; } -#endif static Node* node_new_empty(void) @@ -1498,12 +1523,12 @@ node_new_empty(void) } static Node* -node_new_str_char(UChar c) +node_new_str_raw_char(UChar c) { UChar p[1]; p[0] = c; - return node_new_str(p, p + 1); + return node_new_str_raw(p, p + 1); } static Node* @@ -1528,7 +1553,7 @@ static int str_node_can_be_split(StrNode* sn, OnigEncoding enc) { if (sn->end > sn->s) { - return ((enc_len(enc, sn->s) < sn->end - sn->s) ? 1 : 0); + return ((enclen(enc, sn->s) < sn->end - sn->s) ? 1 : 0); } return 0; } @@ -1651,7 +1676,7 @@ new_code_range(BBuf** pbuf) BBuf* bbuf; bbuf = *pbuf = (BBuf* )xmalloc(sizeof(BBuf)); - CHECK_NULL_RETURN_VAL(*pbuf, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*pbuf); r = BBUF_INIT(*pbuf, INIT_MULTI_BYTE_RANGE_SIZE); if (r) return r; @@ -1952,10 +1977,10 @@ and_cclass(CClassNode* dest, CClassNode* cc, OnigEncoding enc) BitSetRef bsr1, bsr2; BitSet bs1, bs2; - not1 = IS_CCLASS_NOT(dest); + not1 = IS_NCCLASS_NOT(dest); bsr1 = dest->bs; buf1 = dest->mbuf; - not2 = IS_CCLASS_NOT(cc); + not2 = IS_NCCLASS_NOT(cc); bsr2 = cc->bs; buf2 = cc->mbuf; @@ -2010,10 +2035,10 @@ or_cclass(CClassNode* dest, CClassNode* cc, OnigEncoding enc) BitSetRef bsr1, bsr2; BitSet bs1, bs2; - not1 = IS_CCLASS_NOT(dest); + not1 = IS_NCCLASS_NOT(dest); bsr1 = dest->bs; buf1 = dest->mbuf; - not2 = IS_CCLASS_NOT(cc); + not2 = IS_NCCLASS_NOT(cc); bsr2 = cc->bs; buf2 = cc->mbuf; @@ -2066,13 +2091,13 @@ conv_backslash_value(int c, ScanEnv* env) { if (IS_SYNTAX_OP(env->syntax, ONIG_SYN_OP_ESC_CONTROL_CHARS)) { switch (c) { - case 'n': return '\n'; - case 't': return '\t'; - case 'r': return '\r'; - case 'f': return '\f'; - case 'a': return '\007'; - case 'b': return '\010'; - case 'e': return '\033'; + case 'n': return '\n'; + case 't': return '\t'; + case 'r': return '\r'; + case 'f': return '\f'; + case 'a': return '\007'; + case 'b': return '\010'; + case 'e': return '\033'; case 'v': if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ESC_V_VTAB)) return '\v'; @@ -2089,26 +2114,26 @@ static int is_invalid_quantifier_target(Node* node) { switch (NTYPE(node)) { - case N_ANCHOR: + case NT_ANCHOR: return 1; break; - case N_EFFECT: - if (NEFFECT(node).type == EFFECT_OPTION) - return is_invalid_quantifier_target(NEFFECT(node).target); + case NT_ENCLOSE: + /* allow enclosed elements */ + /* return is_invalid_quantifier_target(NENCLOSE(node)->target); */ break; - case N_LIST: /* ex. (?:\G\A)* */ + case NT_LIST: do { - if (! is_invalid_quantifier_target(NCONS(node).left)) return 0; - } while (IS_NOT_NULL(node = NCONS(node).right)); + if (! is_invalid_quantifier_target(NCAR(node))) return 0; + } while (IS_NOT_NULL(node = NCDR(node))); return 0; break; - case N_ALT: /* ex. (?:abc|\A)* */ + case NT_ALT: do { - if (is_invalid_quantifier_target(NCONS(node).left)) return 1; - } while (IS_NOT_NULL(node = NCONS(node).right)); + if (is_invalid_quantifier_target(NCAR(node))) return 1; + } while (IS_NOT_NULL(node = NCDR(node))); break; default: @@ -2119,24 +2144,24 @@ is_invalid_quantifier_target(Node* node) /* ?:0, *:1, +:2, ??:3, *?:4, +?:5 */ static int -popular_quantifier_num(QuantifierNode* qf) +popular_quantifier_num(QtfrNode* q) { - if (qf->greedy) { - if (qf->lower == 0) { - if (qf->upper == 1) return 0; - else if (IS_REPEAT_INFINITE(qf->upper)) return 1; + if (q->greedy) { + if (q->lower == 0) { + if (q->upper == 1) return 0; + else if (IS_REPEAT_INFINITE(q->upper)) return 1; } - else if (qf->lower == 1) { - if (IS_REPEAT_INFINITE(qf->upper)) return 2; + else if (q->lower == 1) { + if (IS_REPEAT_INFINITE(q->upper)) return 2; } } else { - if (qf->lower == 0) { - if (qf->upper == 1) return 3; - else if (IS_REPEAT_INFINITE(qf->upper)) return 4; + if (q->lower == 0) { + if (q->upper == 1) return 3; + else if (IS_REPEAT_INFINITE(q->upper)) return 4; } - else if (qf->lower == 1) { - if (IS_REPEAT_INFINITE(qf->upper)) return 5; + else if (q->lower == 1) { + if (IS_REPEAT_INFINITE(q->upper)) return 5; } } return -1; @@ -2166,16 +2191,17 @@ extern void onig_reduce_nested_quantifier(Node* pnode, Node* cnode) { int pnum, cnum; - QuantifierNode *p, *c; + QtfrNode *p, *c; - p = &(NQUANTIFIER(pnode)); - c = &(NQUANTIFIER(cnode)); + p = NQTFR(pnode); + c = NQTFR(cnode); pnum = popular_quantifier_num(p); cnum = popular_quantifier_num(c); + if (pnum < 0 || cnum < 0) return ; switch(ReduceTypeTable[cnum][pnum]) { case RQ_DEL: - *p = *c; + *pnode = *cnode; break; case RQ_A: p->target = c->target; @@ -2262,7 +2288,7 @@ typedef struct { int ref1; int* refs; int by_name; -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL int exist_level; int level; /* \k */ #endif @@ -2270,8 +2296,10 @@ typedef struct { struct { UChar* name; UChar* name_end; + int gnum; } call; struct { + int ctype; int not; } prop; } u; @@ -2346,7 +2374,7 @@ fetch_range_quantifier(UChar** src, UChar* end, OnigToken* tok, ScanEnv* env) if (PEND) goto invalid; PFETCH(c); if (IS_SYNTAX_OP(env->syntax, ONIG_SYN_OP_ESC_BRACE_INTERVAL)) { - if (c != MC_ESC(enc)) goto invalid; + if (c != MC_ESC(env->syntax)) goto invalid; PFETCH(c); } if (c != '}') goto invalid; @@ -2389,7 +2417,7 @@ fetch_escaped_value(UChar** src, UChar* end, ScanEnv* env) if (c != '-') return ONIGERR_META_CODE_SYNTAX; if (PEND) return ONIGERR_END_PATTERN_AT_META; PFETCH(c); - if (c == MC_ESC(enc)) { + if (c == MC_ESC(env->syntax)) { v = fetch_escaped_value(&p, end, env); if (v < 0) return v; c = (OnigCodePoint )v; @@ -2419,7 +2447,7 @@ fetch_escaped_value(UChar** src, UChar* end, ScanEnv* env) c = 0177; } else { - if (c == MC_ESC(enc)) { + if (c == MC_ESC(env->syntax)) { v = fetch_escaped_value(&p, end, env); if (v < 0) return v; c = (OnigCodePoint )v; @@ -2444,23 +2472,47 @@ fetch_escaped_value(UChar** src, UChar* end, ScanEnv* env) static int fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env); +static OnigCodePoint +get_name_end_code_point(OnigCodePoint start) +{ + switch (start) { + case '<': return (OnigCodePoint )'>'; break; + case '\'': return (OnigCodePoint )'\''; break; + default: + break; + } + + return (OnigCodePoint )0; +} + #ifdef USE_NAMED_GROUP -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL /* \k, \k + \k, \k + \k<-num+n>, \k<-num-n> */ static int -fetch_name_with_level(UChar** src, UChar* end, UChar** rname_end - , ScanEnv* env, int* level) +fetch_name_with_level(OnigCodePoint start_code, UChar** src, UChar* end, + UChar** rname_end, ScanEnv* env, + int* rback_num, int* rlevel) { - int r, exist_level = 0; + int r, sign, is_num, exist_level; + OnigCodePoint end_code; OnigCodePoint c = 0; - OnigCodePoint first_code; OnigEncoding enc = env->enc; UChar *name_end; + UChar *pnum_head; UChar *p = *src; PFETCH_READY; + *rback_num = 0; + is_num = exist_level = 0; + sign = 1; + pnum_head = *src; + + end_code = get_name_end_code_point(start_code); + name_end = end; r = 0; if (PEND) { @@ -2468,11 +2520,18 @@ fetch_name_with_level(UChar** src, UChar* end, UChar** rname_end } else { PFETCH(c); - first_code = c; - if (c == '>') + if (c == end_code) return ONIGERR_EMPTY_GROUP_NAME; - if (!ONIGENC_IS_CODE_WORD(enc, c)) { + if (ONIGENC_IS_CODE_DIGIT(enc, c)) { + is_num = 1; + } + else if (c == '-') { + is_num = 2; + sign = -1; + pnum_head = p; + } + else if (!ONIGENC_IS_CODE_WORD(enc, c)) { r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; } } @@ -2480,43 +2539,58 @@ fetch_name_with_level(UChar** src, UChar* end, UChar** rname_end while (!PEND) { name_end = p; PFETCH(c); - if (c == '>' || c == ')' || c == '+' || c == '-') break; + if (c == end_code || c == ')' || c == '+' || c == '-') { + if (is_num == 2) r = ONIGERR_INVALID_GROUP_NAME; + break; + } - if (!ONIGENC_IS_CODE_WORD(enc, c)) { + if (is_num != 0) { + if (ONIGENC_IS_CODE_DIGIT(enc, c)) { + is_num = 1; + } + else { + r = ONIGERR_INVALID_GROUP_NAME; + is_num = 0; + } + } + else if (!ONIGENC_IS_CODE_WORD(enc, c)) { r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; } } - if (c != '>') { + if (r == 0 && c != end_code) { if (c == '+' || c == '-') { - int num; + int level; int flag = (c == '-' ? -1 : 1); PFETCH(c); if (! ONIGENC_IS_CODE_DIGIT(enc, c)) goto err; PUNFETCH; - num = onig_scan_unsigned_number(&p, end, enc); - if (num < 0) return ONIGERR_TOO_BIG_NUMBER; - *level = (num * flag); + level = onig_scan_unsigned_number(&p, end, enc); + if (level < 0) return ONIGERR_TOO_BIG_NUMBER; + *rlevel = (level * flag); exist_level = 1; PFETCH(c); - if (c == '>') - goto first_check; + if (c == end_code) + goto end; } err: r = ONIGERR_INVALID_GROUP_NAME; name_end = end; } - else { - first_check: - if (ONIGENC_IS_CODE_ASCII(first_code) && - ONIGENC_IS_CODE_UPPER(enc, first_code)) - r = ONIGERR_INVALID_GROUP_NAME; - } + end: if (r == 0) { + if (is_num != 0) { + *rback_num = onig_scan_unsigned_number(&pnum_head, name_end, enc); + if (*rback_num < 0) return ONIGERR_TOO_BIG_NUMBER; + else if (*rback_num == 0) goto err; + + *rback_num *= sign; + } + *rname_end = name_end; *src = p; return (exist_level ? 1 : 0); @@ -2526,33 +2600,40 @@ fetch_name_with_level(UChar** src, UChar* end, UChar** rname_end return r; } } -#endif /* USE_BACKREF_AT_LEVEL */ +#endif /* USE_BACKREF_WITH_LEVEL */ /* def: 0 -> define name (don't allow number name) 1 -> reference name (allow number name) */ static int -fetch_name(UChar** src, UChar* end, UChar** rname_end, ScanEnv* env, int ref) +fetch_name(OnigCodePoint start_code, UChar** src, UChar* end, + UChar** rname_end, ScanEnv* env, int* rback_num, int ref) { - int r, is_num; + int r, is_num, sign; + OnigCodePoint end_code; OnigCodePoint c = 0; - OnigCodePoint first_code; OnigEncoding enc = env->enc; UChar *name_end; + UChar *pnum_head; UChar *p = *src; PFETCH_READY; + *rback_num = 0; + + end_code = get_name_end_code_point(start_code); + name_end = end; + pnum_head = *src; r = 0; is_num = 0; + sign = 1; if (PEND) { return ONIGERR_EMPTY_GROUP_NAME; } else { PFETCH(c); - first_code = c; - if (c == '>') + if (c == end_code) return ONIGERR_EMPTY_GROUP_NAME; if (ONIGENC_IS_CODE_DIGIT(enc, c)) { @@ -2560,6 +2641,18 @@ fetch_name(UChar** src, UChar* end, UChar** rname_end, ScanEnv* env, int ref) is_num = 1; else { r = ONIGERR_INVALID_GROUP_NAME; + is_num = 0; + } + } + else if (c == '-') { + if (ref == 1) { + is_num = 2; + sign = -1; + pnum_head = p; + } + else { + r = ONIGERR_INVALID_GROUP_NAME; + is_num = 0; } } else if (!ONIGENC_IS_CODE_WORD(enc, c)) { @@ -2567,74 +2660,137 @@ fetch_name(UChar** src, UChar* end, UChar** rname_end, ScanEnv* env, int ref) } } - while (!PEND) { - name_end = p; - PFETCH(c); - if (c == '>' || c == ')') break; + if (r == 0) { + while (!PEND) { + name_end = p; + PFETCH(c); + if (c == end_code || c == ')') { + if (is_num == 2) r = ONIGERR_INVALID_GROUP_NAME; + break; + } - if (is_num == 1) { - if (! ONIGENC_IS_CODE_DIGIT(enc, c)) { - if (!ONIGENC_IS_CODE_WORD(enc, c)) - r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; - else - r = ONIGERR_INVALID_GROUP_NAME; + if (is_num != 0) { + if (ONIGENC_IS_CODE_DIGIT(enc, c)) { + is_num = 1; + } + else { + if (!ONIGENC_IS_CODE_WORD(enc, c)) + r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; + else + r = ONIGERR_INVALID_GROUP_NAME; + + is_num = 0; + } } - } - else { - if (!ONIGENC_IS_CODE_WORD(enc, c)) { - r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; + else { + if (!ONIGENC_IS_CODE_WORD(enc, c)) { + r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; + } } } - } - if (c != '>') { - r = ONIGERR_INVALID_GROUP_NAME; - name_end = end; - } - else { - if (ONIGENC_IS_CODE_ASCII(first_code) && - ONIGENC_IS_CODE_UPPER(enc, first_code)) + if (c != end_code) { r = ONIGERR_INVALID_GROUP_NAME; - } + name_end = end; + } + + if (is_num != 0) { + *rback_num = onig_scan_unsigned_number(&pnum_head, name_end, enc); + if (*rback_num < 0) return ONIGERR_TOO_BIG_NUMBER; + else if (*rback_num == 0) { + r = ONIGERR_INVALID_GROUP_NAME; + goto err; + } + + *rback_num *= sign; + } - if (r == 0) { *rname_end = name_end; *src = p; return 0; } else { + while (!PEND) { + name_end = p; + PFETCH(c); + if (c == end_code || c == ')') + break; + } + if (PEND) + name_end = end; + + err: onig_scan_env_set_error_string(env, r, *src, name_end); return r; } } #else static int -fetch_name(UChar** src, UChar* end, UChar** rname_end, ScanEnv* env, int ref) +fetch_name(OnigCodePoint start_code, UChar** src, UChar* end, + UChar** rname_end, ScanEnv* env, int* rback_num, int ref) { - int r, len; + int r, is_num, sign; + OnigCodePoint end_code; OnigCodePoint c = 0; UChar *name_end; OnigEncoding enc = env->enc; + UChar *pnum_head; UChar *p = *src; PFETCH_READY; + *rback_num = 0; + + end_code = get_name_end_code_point(start_code); + + *rname_end = name_end = end; r = 0; + pnum_head = *src; + is_num = 0; + sign = 1; + + if (PEND) { + return ONIGERR_EMPTY_GROUP_NAME; + } + else { + PFETCH(c); + if (c == end_code) + return ONIGERR_EMPTY_GROUP_NAME; + + if (ONIGENC_IS_CODE_DIGIT(enc, c)) { + is_num = 1; + } + else if (c == '-') { + is_num = 2; + sign = -1; + pnum_head = p; + } + else { + r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; + } + } + while (!PEND) { name_end = p; - if (enc_len(enc, p) > 1) - r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; PFETCH(c); - if (c == '>' || c == ')') break; + if (c == end_code || c == ')') break; if (! ONIGENC_IS_CODE_DIGIT(enc, c)) r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; } - if (c != '>') { + if (r == 0 && c != end_code) { r = ONIGERR_INVALID_GROUP_NAME; name_end = end; } if (r == 0) { + *rback_num = onig_scan_unsigned_number(&pnum_head, name_end, enc); + if (*rback_num < 0) return ONIGERR_TOO_BIG_NUMBER; + else if (*rback_num == 0) { + r = ONIGERR_INVALID_GROUP_NAME; + goto err; + } + *rback_num *= sign; + *rname_end = name_end; *src = p; return 0; @@ -2645,7 +2801,7 @@ fetch_name(UChar** src, UChar* end, UChar** rname_end, ScanEnv* env, int ref) return r; } } -#endif +#endif /* USE_NAMED_GROUP */ static void CC_ESC_WARN(ScanEnv* env, UChar *c) @@ -2663,7 +2819,7 @@ CC_ESC_WARN(ScanEnv* env, UChar *c) } static void -CCEND_ESC_WARN(ScanEnv* env, UChar* c) +CLOSE_BRACKET_WITHOUT_ESC_WARN(ScanEnv* env, UChar* c) { if (onig_warn == onig_null_warn) return ; @@ -2687,12 +2843,12 @@ find_str_position(OnigCodePoint s[], int n, UChar* from, UChar* to, while (p < to) { x = ONIGENC_MBC_TO_CODE(enc, p, to); - q = p + enc_len(enc, p); + q = p + enclen(enc, p); if (x == s[0]) { for (i = 1; i < n && q < to; i++) { x = ONIGENC_MBC_TO_CODE(enc, q, to); if (x != s[i]) break; - q += enc_len(enc, q); + q += enclen(enc, q); } if (i >= n) { if (IS_NOT_NULL(next)) @@ -2707,7 +2863,7 @@ find_str_position(OnigCodePoint s[], int n, UChar* from, UChar* to, static int str_exist_check_with_esc(OnigCodePoint s[], int n, UChar* from, UChar* to, - OnigCodePoint bad, OnigEncoding enc) + OnigCodePoint bad, OnigEncoding enc, OnigSyntaxType* syn) { int i, in_esc; OnigCodePoint x; @@ -2718,24 +2874,24 @@ str_exist_check_with_esc(OnigCodePoint s[], int n, UChar* from, UChar* to, while (p < to) { if (in_esc) { in_esc = 0; - p += enc_len(enc, p); + p += enclen(enc, p); } else { x = ONIGENC_MBC_TO_CODE(enc, p, to); - q = p + enc_len(enc, p); + q = p + enclen(enc, p); if (x == s[0]) { for (i = 1; i < n && q < to; i++) { x = ONIGENC_MBC_TO_CODE(enc, q, to); if (x != s[i]) break; - q += enc_len(enc, q); + q += enclen(enc, q); } if (i >= n) return 1; - p += enc_len(enc, p); + p += enclen(enc, p); } else { x = ONIGENC_MBC_TO_CODE(enc, p, to); if (x == bad) return 0; - else if (x == MC_ESC(enc)) in_esc = 1; + else if (x == MC_ESC(syn)) in_esc = 1; p = q; } } @@ -2771,7 +2927,7 @@ fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) else if (c == '-') { tok->type = TK_CC_RANGE; } - else if (c == MC_ESC(enc)) { + else if (c == MC_ESC(syn)) { if (! IS_SYNTAX_BV(syn, ONIG_SYN_BACKSLASH_ESCAPE_IN_CC)) goto end; @@ -2783,37 +2939,45 @@ fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) switch (c) { case 'w': tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_WORD; + tok->u.prop.ctype = ONIGENC_CTYPE_WORD; + tok->u.prop.not = 0; break; case 'W': tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_NOT_WORD; + tok->u.prop.ctype = ONIGENC_CTYPE_WORD; + tok->u.prop.not = 1; break; case 'd': tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_DIGIT; + tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT; + tok->u.prop.not = 0; break; case 'D': tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_NOT_DIGIT; + tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT; + tok->u.prop.not = 1; break; case 's': tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_WHITE_SPACE; + tok->u.prop.ctype = ONIGENC_CTYPE_SPACE; + tok->u.prop.not = 0; break; case 'S': tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_NOT_WHITE_SPACE; + tok->u.prop.ctype = ONIGENC_CTYPE_SPACE; + tok->u.prop.not = 1; break; case 'h': if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break; tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_XDIGIT; + tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT; + tok->u.prop.not = 0; break; case 'H': if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break; tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_NOT_XDIGIT; + tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT; + tok->u.prop.not = 1; break; case 'p': @@ -2850,7 +3014,7 @@ fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE; } - if (p > prev + enc_len(enc, prev) && !PEND && (PPEEK_IS('}'))) { + if (p > prev + enclen(enc, prev) && !PEND && (PPEEK_IS('}'))) { PINC; tok->type = TK_CODE_POINT; tok->base = 16; @@ -2922,7 +3086,7 @@ fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) tok->backp = p; /* point at '[' is readed */ PINC; if (str_exist_check_with_esc(send, 2, p, end, - (OnigCodePoint )']', enc)) { + (OnigCodePoint )']', enc, syn)) { tok->type = TK_POSIX_BRACKET_OPEN; } else { @@ -2975,7 +3139,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) tok->backp = p; PFETCH(c); - if (IS_MC_ESC_CODE(c, enc, syn)) { + if (IS_MC_ESC_CODE(c, syn)) { if (PEND) return ONIGERR_END_PATTERN_AT_ESCAPE; tok->backp = p; @@ -3062,13 +3226,15 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) case 'w': if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_W_WORD)) break; tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_WORD; + tok->u.prop.ctype = ONIGENC_CTYPE_WORD; + tok->u.prop.not = 0; break; case 'W': if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_W_WORD)) break; tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_NOT_WORD; + tok->u.prop.ctype = ONIGENC_CTYPE_WORD; + tok->u.prop.not = 1; break; case 'b': @@ -3100,37 +3266,43 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) case 's': if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_S_WHITE_SPACE)) break; tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_WHITE_SPACE; + tok->u.prop.ctype = ONIGENC_CTYPE_SPACE; + tok->u.prop.not = 0; break; case 'S': if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_S_WHITE_SPACE)) break; tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_NOT_WHITE_SPACE; + tok->u.prop.ctype = ONIGENC_CTYPE_SPACE; + tok->u.prop.not = 1; break; case 'd': if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_D_DIGIT)) break; tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_DIGIT; + tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT; + tok->u.prop.not = 0; break; case 'D': if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_D_DIGIT)) break; tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_NOT_DIGIT; + tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT; + tok->u.prop.not = 1; break; case 'h': if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break; tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_XDIGIT; + tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT; + tok->u.prop.not = 0; break; case 'H': if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break; tok->type = TK_CHAR_TYPE; - tok->u.subtype = CTYPE_NOT_XDIGIT; + tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT; + tok->u.prop.not = 1; break; case 'A': @@ -3182,7 +3354,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE; } - if ((p > prev + enc_len(enc, prev)) && !PEND && PPEEK_IS('}')) { + if ((p > prev + enclen(enc, prev)) && !PEND && PPEEK_IS('}')) { PINC; tok->type = TK_CODE_POINT; tok->u.code = (OnigCodePoint )num; @@ -3240,7 +3412,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) tok->u.backref.num = 1; tok->u.backref.ref1 = num; tok->u.backref.by_name = 0; -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL tok->u.backref.exist_level = 0; #endif break; @@ -3276,46 +3448,67 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) case 'k': if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_K_NAMED_BACKREF)) { PFETCH(c); - if (c == '<') { + if (c == '<' || c == '\'') { UChar* name_end; int* backs; + int back_num; prev = p; -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL name_end = NULL_UCHARP; /* no need. escape gcc warning. */ - r = fetch_name_with_level(&p, end, &name_end, env, &tok->u.backref.level); + r = fetch_name_with_level((OnigCodePoint )c, &p, end, &name_end, + env, &back_num, &tok->u.backref.level); if (r == 1) tok->u.backref.exist_level = 1; else tok->u.backref.exist_level = 0; #else - r = fetch_name(&p, end, &name_end, env, 1); + r = fetch_name(&p, end, &name_end, env, &back_num, 1); #endif if (r < 0) return r; - num = onig_name_to_group_numbers(env->reg, prev, name_end, &backs); - if (num <= 0) { - onig_scan_env_set_error_string(env, - ONIGERR_UNDEFINED_NAME_REFERENCE, prev, name_end); - return ONIGERR_UNDEFINED_NAME_REFERENCE; - } - if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) { - int i; - for (i = 0; i < num; i++) { - if (backs[i] > env->num_mem || - IS_NULL(SCANENV_MEM_NODES(env)[backs[i]])) + if (back_num != 0) { + if (back_num < 0) { + back_num = BACKREF_REL_TO_ABS(back_num, env); + if (back_num <= 0) return ONIGERR_INVALID_BACKREF; } - } - tok->type = TK_BACKREF; - tok->u.backref.by_name = 1; - if (num == 1) { + if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) { + if (back_num > env->num_mem || + IS_NULL(SCANENV_MEM_NODES(env)[back_num])) + return ONIGERR_INVALID_BACKREF; + } + tok->type = TK_BACKREF; + tok->u.backref.by_name = 0; tok->u.backref.num = 1; - tok->u.backref.ref1 = backs[0]; + tok->u.backref.ref1 = back_num; } else { - tok->u.backref.num = num; - tok->u.backref.refs = backs; + num = onig_name_to_group_numbers(env->reg, prev, name_end, &backs); + if (num <= 0) { + onig_scan_env_set_error_string(env, + ONIGERR_UNDEFINED_NAME_REFERENCE, prev, name_end); + return ONIGERR_UNDEFINED_NAME_REFERENCE; + } + if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) { + int i; + for (i = 0; i < num; i++) { + if (backs[i] > env->num_mem || + IS_NULL(SCANENV_MEM_NODES(env)[backs[i]])) + return ONIGERR_INVALID_BACKREF; + } + } + + tok->type = TK_BACKREF; + tok->u.backref.by_name = 1; + if (num == 1) { + tok->u.backref.num = 1; + tok->u.backref.ref1 = backs[0]; + } + else { + tok->u.backref.num = num; + tok->u.backref.refs = backs; + } } } else @@ -3328,16 +3521,18 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) case 'g': if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_G_SUBEXP_CALL)) { PFETCH(c); - if (c == '<') { + if (c == '<' || c == '\'') { + int gnum; UChar* name_end; prev = p; - r = fetch_name(&p, end, &name_end, env, 1); + r = fetch_name((OnigCodePoint )c, &p, end, &name_end, env, &gnum, 1); if (r < 0) return r; tok->type = TK_CALL; tok->u.call.name = prev; tok->u.call.name_end = name_end; + tok->u.call.gnum = gnum; } else PUNFETCH; @@ -3380,7 +3575,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) tok->u.code = (OnigCodePoint )num; } else { /* string */ - p = tok->backp + enc_len(enc, tok->backp); + p = tok->backp + enclen(enc, tok->backp); } break; } @@ -3392,15 +3587,15 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) #ifdef USE_VARIABLE_META_CHARS if ((c != ONIG_INEFFECTIVE_META_CHAR) && IS_SYNTAX_OP(syn, ONIG_SYN_OP_VARIABLE_META_CHARACTERS)) { - if (c == MC_ANYCHAR(enc)) + if (c == MC_ANYCHAR(syn)) goto any_char; - else if (c == MC_ANYTIME(enc)) + else if (c == MC_ANYTIME(syn)) goto anytime; - else if (c == MC_ZERO_OR_ONE_TIME(enc)) + else if (c == MC_ZERO_OR_ONE_TIME(syn)) goto zero_or_one_time; - else if (c == MC_ONE_OR_MORE_TIME(enc)) + else if (c == MC_ONE_OR_MORE_TIME(syn)) goto one_or_more_time; - else if (c == MC_ANYCHAR_ANYTIME(enc)) { + else if (c == MC_ANYCHAR_ANYTIME(syn)) { tok->type = TK_ANYCHAR_ANYTIME; goto out; } @@ -3477,7 +3672,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) while (1) { if (PEND) return ONIGERR_END_PATTERN_IN_GROUP; PFETCH(c); - if (c == MC_ESC(enc)) { + if (c == MC_ESC(syn)) { if (!PEND) PFETCH(c); } else { @@ -3519,7 +3714,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) case ']': if (*src > env->pattern) /* /].../ is allowed. */ - CCEND_ESC_WARN(env, (UChar* )"]"); + CLOSE_BRACKET_WITHOUT_ESC_WARN(env, (UChar* )"]"); break; case '#': @@ -3553,24 +3748,36 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) } static int -add_ctype_to_cc_by_range(CClassNode* cc, int ctype, int not, OnigEncoding enc, - const OnigCodePoint sbr[], const OnigCodePoint mbr[]) +add_ctype_to_cc_by_range(CClassNode* cc, int ctype ARG_UNUSED, int not, + OnigEncoding enc ARG_UNUSED, + OnigCodePoint sb_out, const OnigCodePoint mbr[]) { int i, r; OnigCodePoint j; - int nsb = ONIGENC_CODE_RANGE_NUM(sbr); - int nmb = ONIGENC_CODE_RANGE_NUM(mbr); + int n = ONIGENC_CODE_RANGE_NUM(mbr); if (not == 0) { - for (i = 0; i < nsb; i++) { - for (j = ONIGENC_CODE_RANGE_FROM(sbr, i); - j <= ONIGENC_CODE_RANGE_TO(sbr, i); j++) { + for (i = 0; i < n; i++) { + for (j = ONIGENC_CODE_RANGE_FROM(mbr, i); + j <= ONIGENC_CODE_RANGE_TO(mbr, i); j++) { + if (j >= sb_out) { + if (j == ONIGENC_CODE_RANGE_TO(mbr, i)) i++; + else if (j > ONIGENC_CODE_RANGE_FROM(mbr, i)) { + r = add_code_range_to_buf(&(cc->mbuf), j, + ONIGENC_CODE_RANGE_TO(mbr, i)); + if (r != 0) return r; + i++; + } + + goto sb_end; + } BITSET_SET_BIT(cc->bs, j); } } - for (i = 0; i < nmb; i++) { + sb_end: + for ( ; i < n; i++) { r = add_code_range_to_buf(&(cc->mbuf), ONIGENC_CODE_RANGE_FROM(mbr, i), ONIGENC_CODE_RANGE_TO(mbr, i)); @@ -3580,24 +3787,24 @@ add_ctype_to_cc_by_range(CClassNode* cc, int ctype, int not, OnigEncoding enc, else { OnigCodePoint prev = 0; - if (ONIGENC_MBC_MINLEN(enc) == 1) { - for (i = 0; i < nsb; i++) { - for (j = prev; - j < ONIGENC_CODE_RANGE_FROM(sbr, i); j++) { - BITSET_SET_BIT(cc->bs, j); - } - prev = ONIGENC_CODE_RANGE_TO(sbr, i) + 1; - } - if (prev < 0x7f) { - for (j = prev; j < 0x7f; j++) { - BITSET_SET_BIT(cc->bs, j); - } + for (i = 0; i < n; i++) { + for (j = prev; + j < ONIGENC_CODE_RANGE_FROM(mbr, i); j++) { + if (j >= sb_out) { + goto sb_end2; + } + BITSET_SET_BIT(cc->bs, j); } - - prev = 0x80; + prev = ONIGENC_CODE_RANGE_TO(mbr, i) + 1; + } + for (j = prev; j < sb_out; j++) { + BITSET_SET_BIT(cc->bs, j); } - for (i = 0; i < nmb; i++) { + sb_end2: + prev = sb_out; + + for (i = 0; i < n; i++) { if (prev < ONIGENC_CODE_RANGE_FROM(mbr, i)) { r = add_code_range_to_buf(&(cc->mbuf), prev, ONIGENC_CODE_RANGE_FROM(mbr, i) - 1); @@ -3618,12 +3825,13 @@ static int add_ctype_to_cc(CClassNode* cc, int ctype, int not, ScanEnv* env) { int c, r; - const OnigCodePoint *sbr, *mbr; + const OnigCodePoint *ranges; + OnigCodePoint sb_out; OnigEncoding enc = env->enc; - r = ONIGENC_GET_CTYPE_CODE_RANGE(enc, ctype, &sbr, &mbr); + r = ONIGENC_GET_CTYPE_CODE_RANGE(enc, ctype, &sb_out, &ranges); if (r == 0) { - return add_ctype_to_cc_by_range(cc, ctype, not, env->enc, sbr, mbr); + return add_ctype_to_cc_by_range(cc, ctype, not, env->enc, sb_out, ranges); } else if (r != ONIG_NO_SUPPORT_CONFIG) { return r; @@ -3677,13 +3885,13 @@ add_ctype_to_cc(CClassNode* cc, int ctype, int not, ScanEnv* env) case ONIGENC_CTYPE_WORD: if (not == 0) { for (c = 0; c < SINGLE_BYTE_SIZE; c++) { - if (ONIGENC_IS_CODE_SB_WORD(enc, c)) BITSET_SET_BIT(cc->bs, c); + if (IS_CODE_SB_WORD(enc, c)) BITSET_SET_BIT(cc->bs, c); } ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf); } else { for (c = 0; c < SINGLE_BYTE_SIZE; c++) { - if ((ONIGENC_CODE_TO_MBCLEN(enc, c) > 0) /* 0: invalid code point */ + if ((ONIGENC_CODE_TO_MBCLEN(enc, c) > 0) /* check invalid code point */ && ! ONIGENC_IS_CODE_WORD(enc, c)) BITSET_SET_BIT(cc->bs, c); } @@ -3698,62 +3906,11 @@ add_ctype_to_cc(CClassNode* cc, int ctype, int not, ScanEnv* env) return r; } -static int -parse_ctype_to_enc_ctype(int pctype, int* not) -{ - int ctype; - - switch (pctype) { - case CTYPE_WORD: - ctype = ONIGENC_CTYPE_WORD; - *not = 0; - break; - case CTYPE_NOT_WORD: - ctype = ONIGENC_CTYPE_WORD; - *not = 1; - break; - case CTYPE_WHITE_SPACE: - ctype = ONIGENC_CTYPE_SPACE; - *not = 0; - break; - case CTYPE_NOT_WHITE_SPACE: - ctype = ONIGENC_CTYPE_SPACE; - *not = 1; - break; - case CTYPE_DIGIT: - ctype = ONIGENC_CTYPE_DIGIT; - *not = 0; - break; - case CTYPE_NOT_DIGIT: - ctype = ONIGENC_CTYPE_DIGIT; - *not = 1; - break; - case CTYPE_XDIGIT: - ctype = ONIGENC_CTYPE_XDIGIT; - *not = 0; - break; - case CTYPE_NOT_XDIGIT: - ctype = ONIGENC_CTYPE_XDIGIT; - *not = 1; - break; - default: - return ONIGERR_PARSER_BUG; - break; - } - return ctype; -} - -typedef struct { - UChar *name; - int ctype; - short int len; -} PosixBracketEntryType; - static int parse_posix_bracket(CClassNode* cc, UChar** src, UChar* end, ScanEnv* env) { #define POSIX_BRACKET_CHECK_LIMIT_LENGTH 20 -#define POSIX_BRACKET_NAME_MAX_LEN 6 +#define POSIX_BRACKET_NAME_MIN_LEN 4 static PosixBracketEntryType PBS[] = { { (UChar* )"alnum", ONIGENC_CTYPE_ALNUM, 5 }, @@ -3769,7 +3926,8 @@ parse_posix_bracket(CClassNode* cc, UChar** src, UChar* end, ScanEnv* env) { (UChar* )"upper", ONIGENC_CTYPE_UPPER, 5 }, { (UChar* )"xdigit", ONIGENC_CTYPE_XDIGIT, 6 }, { (UChar* )"ascii", ONIGENC_CTYPE_ASCII, 5 }, - { (UChar* )NULL, -1, 0 } + { (UChar* )"word", ONIGENC_CTYPE_WORD, 4 }, + { (UChar* )NULL, -1, 0 } }; PosixBracketEntryType *pb; @@ -3786,7 +3944,7 @@ parse_posix_bracket(CClassNode* cc, UChar** src, UChar* end, ScanEnv* env) else not = 0; - if (onigenc_strlen(enc, p, end) < POSIX_BRACKET_NAME_MAX_LEN + 2) + if (onigenc_strlen(enc, p, end) < POSIX_BRACKET_NAME_MIN_LEN + 3) goto not_posix_bracket; for (pb = PBS; IS_NOT_NULL(pb->name); pb++) { @@ -3820,86 +3978,39 @@ parse_posix_bracket(CClassNode* cc, UChar** src, UChar* end, ScanEnv* env) } } - return 1; /* 1: is not POSIX bracket, but no error. */ -} - -static int -property_name_to_ctype(UChar* p, UChar* end, OnigEncoding enc) -{ - static PosixBracketEntryType PBS[] = { - { (UChar* )"Alnum", ONIGENC_CTYPE_ALNUM, 5 }, - { (UChar* )"Alpha", ONIGENC_CTYPE_ALPHA, 5 }, - { (UChar* )"Blank", ONIGENC_CTYPE_BLANK, 5 }, - { (UChar* )"Cntrl", ONIGENC_CTYPE_CNTRL, 5 }, - { (UChar* )"Digit", ONIGENC_CTYPE_DIGIT, 5 }, - { (UChar* )"Graph", ONIGENC_CTYPE_GRAPH, 5 }, - { (UChar* )"Lower", ONIGENC_CTYPE_LOWER, 5 }, - { (UChar* )"Print", ONIGENC_CTYPE_PRINT, 5 }, - { (UChar* )"Punct", ONIGENC_CTYPE_PUNCT, 5 }, - { (UChar* )"Space", ONIGENC_CTYPE_SPACE, 5 }, - { (UChar* )"Upper", ONIGENC_CTYPE_UPPER, 5 }, - { (UChar* )"XDigit", ONIGENC_CTYPE_XDIGIT, 6 }, - { (UChar* )"ASCII", ONIGENC_CTYPE_ASCII, 5 }, - { (UChar* )NULL, -1, 0 } - }; - - PosixBracketEntryType *pb; - int len; - - len = onigenc_strlen(enc, p, end); - for (pb = PBS; IS_NOT_NULL(pb->name); pb++) { - if (len == pb->len && - onigenc_with_ascii_strncmp(enc, p, end, pb->name, pb->len) == 0) - return pb->ctype; - } - - return -1; + return 1; /* 1: is not POSIX bracket, but no error. */ } static int fetch_char_property_to_ctype(UChar** src, UChar* end, ScanEnv* env) { - int ctype; + int r; OnigCodePoint c; OnigEncoding enc = env->enc; UChar *prev, *start, *p = *src; PFETCH_READY; - /* 'IsXXXX' => 'XXXX' */ - if (!PEND && - IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS)) { - c = PPEEK; - if (c == 'I') { - PINC; - if (! PEND) { - c = PPEEK; - if (c == 's') - PINC; - else - PUNFETCH; - } - } - } - + r = 0; start = prev = p; while (!PEND) { prev = p; PFETCH(c); if (c == '}') { - ctype = property_name_to_ctype(start, prev, enc); - if (ctype < 0) break; + r = ONIGENC_PROPERTY_NAME_TO_CTYPE(enc, start, prev); + if (r < 0) break; *src = p; - return ctype; + return r; } - else if (c == '(' || c == ')' || c == '{' || c == '|') + else if (c == '(' || c == ')' || c == '{' || c == '|') { + r = ONIGERR_INVALID_CHAR_PROPERTY_NAME; break; + } } - onig_scan_env_set_error_string(env, ONIGERR_INVALID_CHAR_PROPERTY_NAME, - *src, prev); - return ONIGERR_INVALID_CHAR_PROPERTY_NAME; + onig_scan_env_set_error_string(env, r, *src, prev); + return r; } static int @@ -3913,11 +4024,11 @@ parse_char_property(Node** np, OnigToken* tok, UChar** src, UChar* end, if (ctype < 0) return ctype; *np = node_new_cclass(); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); - cc = &(NCCLASS(*np)); + CHECK_NULL_RETURN_MEMERR(*np); + cc = NCCLASS(*np); r = add_ctype_to_cc(cc, ctype, 0, env); if (r != 0) return r; - if (tok->u.prop.not != 0) CCLASS_SET_NOT(cc); + if (tok->u.prop.not != 0) NCCLASS_SET_NOT(cc); return 0; } @@ -3981,7 +4092,7 @@ next_state_val(CClassNode* cc, OnigCodePoint *vs, OnigCodePoint v, if (intype == *type) { if (intype == CCV_SB) { if (*vs > 0xff || v > 0xff) - return ONIGERR_INVALID_WIDE_CHAR_VALUE; + return ONIGERR_INVALID_CODE_POINT_VALUE; if (*vs > v) { if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC)) @@ -4036,10 +4147,11 @@ next_state_val(CClassNode* cc, OnigCodePoint *vs, OnigCodePoint v, static int code_exist_check(OnigCodePoint c, UChar* from, UChar* end, int ignore_escaped, - OnigEncoding enc) + ScanEnv* env) { int in_esc; OnigCodePoint code; + OnigEncoding enc = env->enc; UChar* p = from; PFETCH_READY; @@ -4051,7 +4163,7 @@ code_exist_check(OnigCodePoint c, UChar* from, UChar* end, int ignore_escaped, else { PFETCH(code); if (code == c) return 1; - if (code == MC_ESC(enc)) in_esc = 1; + if (code == MC_ESC(env->syntax)) in_esc = 1; } } return 0; @@ -4086,7 +4198,7 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end, if (r < 0) return r; if (r == TK_CC_CLOSE) { if (! code_exist_check((OnigCodePoint )']', - *src, env->pattern_end, 1, env->enc)) + *src, env->pattern_end, 1, env)) return ONIGERR_EMPTY_CHAR_CLASS; CC_ESC_WARN(env, (UChar* )"]"); @@ -4094,8 +4206,8 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end, } *np = node = node_new_cclass(); - CHECK_NULL_RETURN_VAL(node, ONIGERR_MEMORY); - cc = &(NCCLASS(node)); + CHECK_NULL_RETURN_MEMERR(node); + cc = NCCLASS(node); and_start = 0; state = CCS_START; @@ -4108,6 +4220,10 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end, if (len > 1) { in_type = CCV_CODE_POINT; } + else if (len < 0) { + r = len; + goto err; + } else { sb_char: in_type = CCV_SB; @@ -4141,7 +4257,7 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end, goto err; } - len = enc_len(env->enc, buf); + len = enclen(env->enc, buf); if (i < len) { r = ONIGERR_TOO_SHORT_MULTI_BYTE_STRING; goto err; @@ -4202,12 +4318,8 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end, break; case TK_CHAR_TYPE: - { - int ctype, not; - ctype = parse_ctype_to_enc_ctype(tok->u.subtype, ¬); - r = add_ctype_to_cc(cc, ctype, not, env); - if (r != 0) return r; - } + r = add_ctype_to_cc(cc, tok->u.prop.ctype, tok->u.prop.not, env); + if (r != 0) return r; next_class: r = next_state_class(cc, &vs, &val_type, &state, env); @@ -4287,7 +4399,7 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end, r = parse_char_class(&anode, tok, &p, end, env); if (r != 0) goto cc_open_err; - acc = &(NCCLASS(anode)); + acc = NCCLASS(anode); r = or_cclass(cc, acc, env->enc); onig_node_free(anode); @@ -4352,10 +4464,10 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end, } if (neg != 0) - CCLASS_SET_NOT(cc); + NCCLASS_SET_NOT(cc); else - CCLASS_CLEAR_NOT(cc); - if (IS_CCLASS_NOT(cc) && + NCCLASS_CLEAR_NOT(cc); + if (IS_NCCLASS_NOT(cc) && IS_SYNTAX_BV(env->syntax, ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC)) { int is_empty; @@ -4378,7 +4490,7 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end, return 0; err: - if (cc != &(NCCLASS(*np))) + if (cc != NCCLASS(*np)) bbuf_free(cc->mbuf); onig_node_free(*np); return r; @@ -4388,15 +4500,19 @@ static int parse_subexp(Node** top, OnigToken* tok, int term, UChar** src, UChar* end, ScanEnv* env); static int -parse_effect(Node** np, OnigToken* tok, int term, UChar** src, UChar* end, - ScanEnv* env) +parse_enclose(Node** np, OnigToken* tok, int term, UChar** src, UChar* end, + ScanEnv* env) { int r, num; - int list_capture; Node *target; OnigOptionType option; - OnigEncoding enc = env->enc; OnigCodePoint c; + OnigEncoding enc = env->enc; + +#ifdef USE_NAMED_GROUP + int list_capture; +#endif + UChar* p = *src; PFETCH_READY; @@ -4428,9 +4544,19 @@ parse_effect(Node** np, OnigToken* tok, int term, UChar** src, UChar* end, *np = onig_node_new_anchor(ANCHOR_PREC_READ_NOT); break; case '>': /* (?>...) stop backtrack */ - *np = node_new_effect(EFFECT_STOP_BACKTRACK); + *np = node_new_enclose(ENCLOSE_STOP_BACKTRACK); break; +#ifdef USE_NAMED_GROUP + case '\'': + if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) { + goto named_group1; + } + else + return ONIGERR_UNDEFINED_GROUP_OPTION; + break; +#endif + case '<': /* look behind (?<=...), (?syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) { - UChar *name; - UChar *name_end; + else { + if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) { + UChar *name; + UChar *name_end; - PUNFETCH; - list_capture = 0; + PUNFETCH; + c = '<'; - named_group: - name = p; - r = fetch_name(&p, end, &name_end, env, 0); - if (r < 0) return r; + named_group1: + list_capture = 0; - num = scan_env_add_mem_entry(env); - if (num < 0) return num; - if (list_capture != 0 && num >= BIT_STATUS_BITS_NUM) - return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY; + named_group2: + name = p; + r = fetch_name((OnigCodePoint )c, &p, end, &name_end, env, &num, 0); + if (r < 0) return r; - r = name_add(env->reg, name, name_end, num, env); - if (r != 0) return r; - *np = node_new_effect_memory(env->option, 1); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); - NEFFECT(*np).regnum = num; - if (list_capture != 0) - BIT_STATUS_ON_AT_SIMPLE(env->capture_history, num); - env->num_named++; + num = scan_env_add_mem_entry(env); + if (num < 0) return num; + if (list_capture != 0 && num >= (int )BIT_STATUS_BITS_NUM) + return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY; + + r = name_add(env->reg, name, name_end, num, env); + if (r != 0) return r; + *np = node_new_enclose_memory(env->option, 1); + CHECK_NULL_RETURN_MEMERR(*np); + NENCLOSE(*np)->regnum = num; + if (list_capture != 0) + BIT_STATUS_ON_AT_SIMPLE(env->capture_history, num); + env->num_named++; + } + else { + return ONIGERR_UNDEFINED_GROUP_OPTION; + } } -#endif - else +#else + else { return ONIGERR_UNDEFINED_GROUP_OPTION; + } +#endif break; case '@': @@ -4474,25 +4610,25 @@ parse_effect(Node** np, OnigToken* tok, int term, UChar** src, UChar* end, #ifdef USE_NAMED_GROUP if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) { PFETCH(c); - if (c == '<') { + if (c == '<' || c == '\'') { list_capture = 1; - goto named_group; /* (?@...) */ + goto named_group2; /* (?@...) */ } PUNFETCH; } #endif - *np = node_new_effect_memory(env->option, 0); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + *np = node_new_enclose_memory(env->option, 0); + CHECK_NULL_RETURN_MEMERR(*np); num = scan_env_add_mem_entry(env); if (num < 0) { onig_node_free(*np); return num; } - else if (num >= BIT_STATUS_BITS_NUM) { + else if (num >= (int )BIT_STATUS_BITS_NUM) { onig_node_free(*np); return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY; } - NEFFECT(*np).regnum = num; + NENCLOSE(*np)->regnum = num; BIT_STATUS_ON_AT_SIMPLE(env->capture_history, num); } else { @@ -4545,7 +4681,7 @@ parse_effect(Node** np, OnigToken* tok, int term, UChar** src, UChar* end, if (c == ')') { *np = node_new_option(option); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*np); *src = p; return 2; /* option only */ } @@ -4559,8 +4695,8 @@ parse_effect(Node** np, OnigToken* tok, int term, UChar** src, UChar* end, env->option = prev; if (r < 0) return r; *np = node_new_option(option); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); - NEFFECT(*np).target = target; + CHECK_NULL_RETURN_MEMERR(*np); + NENCLOSE(*np)->target = target; *src = p; return 0; } @@ -4579,26 +4715,26 @@ parse_effect(Node** np, OnigToken* tok, int term, UChar** src, UChar* end, if (ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_DONT_CAPTURE_GROUP)) goto group; - *np = node_new_effect_memory(env->option, 0); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + *np = node_new_enclose_memory(env->option, 0); + CHECK_NULL_RETURN_MEMERR(*np); num = scan_env_add_mem_entry(env); if (num < 0) return num; - NEFFECT(*np).regnum = num; + NENCLOSE(*np)->regnum = num; } - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*np); r = fetch_token(tok, &p, end, env); if (r < 0) return r; r = parse_subexp(&target, tok, term, &p, end, env); if (r < 0) return r; - if (NTYPE(*np) == N_ANCHOR) - NANCHOR(*np).target = target; + if (NTYPE(*np) == NT_ANCHOR) + NANCHOR(*np)->target = target; else { - NEFFECT(*np).target = target; - if (NEFFECT(*np).type == EFFECT_MEMORY) { + NENCLOSE(*np)->target = target; + if (NENCLOSE(*np)->type == ENCLOSE_MEMORY) { /* Don't move this to previous of parse_subexp() */ - r = scan_env_set_mem_node(env, NEFFECT(*np).regnum, *np); + r = scan_env_set_mem_node(env, NENCLOSE(*np)->regnum, *np); if (r != 0) return r; } } @@ -4618,17 +4754,17 @@ static const char* ReduceQStr[] = { static int set_quantifier(Node* qnode, Node* target, int group, ScanEnv* env) { - QuantifierNode* qn; + QtfrNode* qn; - qn = &(NQUANTIFIER(qnode)); + qn = NQTFR(qnode); if (qn->lower == 1 && qn->upper == 1) { return 1; } switch (NTYPE(target)) { - case N_STRING: + case NT_STR: if (! group) { - StrNode* sn = &(NSTRING(target)); + StrNode* sn = NSTR(target); if (str_node_can_be_split(sn, env->enc)) { Node* n = str_node_split_last_char(sn, env->enc); if (IS_NOT_NULL(n)) { @@ -4639,10 +4775,10 @@ set_quantifier(Node* qnode, Node* target, int group, ScanEnv* env) } break; - case N_QUANTIFIER: + case NT_QTFR: { /* check redundant double repeat. */ /* verbose warn (?:.?)? etc... but not warn (.?)? etc... */ - QuantifierNode* qnt = &(NQUANTIFIER(target)); + QtfrNode* qnt = NQTFR(target); int nestq_num = popular_quantifier_num(qn); int targetq_num = popular_quantifier_num(qnt); @@ -4705,6 +4841,7 @@ set_quantifier(Node* qnode, Node* target, int group, ScanEnv* env) return 0; } + #ifdef USE_SHARED_CCLASS_TABLE #define THRESHOLD_RANGE_NUM_FOR_SHARE_CCLASS 8 @@ -4728,17 +4865,17 @@ static int type_cclass_cmp(type_cclass_key* x, type_cclass_key* y) static int type_cclass_hash(type_cclass_key* key) { int i, val; - unsigned char *p; + UChar *p; val = 0; - p = (unsigned char* )&(key->enc); - for (i = 0; i < sizeof(key->enc); i++) { + p = (UChar* )&(key->enc); + for (i = 0; i < (int )sizeof(key->enc); i++) { val = val * 997 + (int )*p++; } - p = (unsigned char* )(&key->type); - for (i = 0; i < sizeof(key->type); i++) { + p = (UChar* )(&key->type); + for (i = 0; i < (int )sizeof(key->type); i++) { val = val * 997 + (int )*p++; } @@ -4755,10 +4892,10 @@ static st_table* OnigTypeCClassTable; static int -i_free_shared_class(type_cclass_key* key, Node* node, void* arg) +i_free_shared_class(type_cclass_key* key, Node* node, void* arg ARG_UNUSED) { if (IS_NOT_NULL(node)) { - CClassNode* cc = &(NCCLASS(node)); + CClassNode* cc = NCCLASS(node); if (IS_NOT_NULL(cc->mbuf)) xfree(cc->mbuf); xfree(node); } @@ -4782,6 +4919,118 @@ onig_free_shared_cclass_table(void) #endif /* USE_SHARED_CCLASS_TABLE */ +#ifndef CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS +static int +clear_not_flag_cclass(CClassNode* cc, OnigEncoding enc) +{ + BBuf *tbuf; + int r; + + if (IS_NCCLASS_NOT(cc)) { + bitset_invert(cc->bs); + + if (! ONIGENC_IS_SINGLEBYTE(enc)) { + r = not_code_range_buf(enc, cc->mbuf, &tbuf); + if (r != 0) return r; + + bbuf_free(cc->mbuf); + cc->mbuf = tbuf; + } + + NCCLASS_CLEAR_NOT(cc); + } + + return 0; +} +#endif /* CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS */ + +typedef struct { + ScanEnv* env; + CClassNode* cc; + Node* alt_root; + Node** ptail; +} IApplyCaseFoldArg; + +static int +i_apply_case_fold(OnigCodePoint from, OnigCodePoint to[], + int to_len, void* arg) +{ + IApplyCaseFoldArg* iarg; + ScanEnv* env; + CClassNode* cc; + BitSetRef bs; + + iarg = (IApplyCaseFoldArg* )arg; + env = iarg->env; + cc = iarg->cc; + bs = cc->bs; + + if (to_len == 1) { + int is_in = onig_is_code_in_cc(env->enc, from, cc); +#ifdef CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS + if ((is_in != 0 && !IS_NCCLASS_NOT(cc)) || + (is_in == 0 && IS_NCCLASS_NOT(cc))) { + if (ONIGENC_MBC_MINLEN(env->enc) > 1 || *to >= SINGLE_BYTE_SIZE) { + add_code_range(&(cc->mbuf), env, *to, *to); + } + else { + BITSET_SET_BIT(bs, *to); + } + } +#else + if (is_in != 0) { + if (ONIGENC_MBC_MINLEN(env->enc) > 1 || *to >= SINGLE_BYTE_SIZE) { + if (IS_NCCLASS_NOT(cc)) clear_not_flag_cclass(cc, env->enc); + add_code_range(&(cc->mbuf), env, *to, *to); + } + else { + if (IS_NCCLASS_NOT(cc)) { + BITSET_CLEAR_BIT(bs, *to); + } + else + BITSET_SET_BIT(bs, *to); + } + } +#endif /* CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS */ + } + else { + int r, i, len; + UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN]; + Node *snode = NULL_NODE; + + if (onig_is_code_in_cc(env->enc, from, cc) +#ifdef CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS + && !IS_NCCLASS_NOT(cc) +#endif + ) { + for (i = 0; i < to_len; i++) { + len = ONIGENC_CODE_TO_MBC(env->enc, to[i], buf); + if (i == 0) { + snode = onig_node_new_str(buf, buf + len); + CHECK_NULL_RETURN_MEMERR(snode); + + /* char-class expanded multi-char only + compare with string folded at match time. */ + NSTRING_SET_AMBIG(snode); + } + else { + r = onig_node_str_cat(snode, buf, buf + len); + if (r < 0) { + onig_node_free(snode); + return r; + } + } + } + + *(iarg->ptail) = onig_node_new_alt(snode, NULL_NODE); + CHECK_NULL_RETURN_MEMERR(*(iarg->ptail)); + iarg->ptail = &(NCDR((*(iarg->ptail)))); + } + } + + return 0; +} + static int parse_exp(Node** np, OnigToken* tok, int term, UChar** src, UChar* end, ScanEnv* env) @@ -4791,7 +5040,7 @@ parse_exp(Node** np, OnigToken* tok, int term, Node** targetp; *np = NULL; - if (tok->type == term) + if (tok->type == (enum TokenSyms )term) goto end_of_token; switch (tok->type) { @@ -4803,20 +5052,20 @@ parse_exp(Node** np, OnigToken* tok, int term, break; case TK_SUBEXP_OPEN: - r = parse_effect(np, tok, TK_SUBEXP_CLOSE, src, end, env); + r = parse_enclose(np, tok, TK_SUBEXP_CLOSE, src, end, env); if (r < 0) return r; if (r == 1) group = 1; else if (r == 2) { /* option only */ Node* target; OnigOptionType prev = env->option; - env->option = NEFFECT(*np).option; + env->option = NENCLOSE(*np)->option; r = fetch_token(tok, src, end, env); if (r < 0) return r; r = parse_subexp(&target, tok, term, src, end, env); env->option = prev; if (r < 0) return r; - NEFFECT(*np).target = target; + NENCLOSE(*np)->target = target; return tok->type; } break; @@ -4833,7 +5082,7 @@ parse_exp(Node** np, OnigToken* tok, int term, tk_byte: { *np = node_new_str(tok->backp, *src); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*np); while (1) { r = fetch_token(tok, src, end, env); @@ -4853,13 +5102,14 @@ parse_exp(Node** np, OnigToken* tok, int term, case TK_RAW_BYTE: tk_raw_byte: { - *np = node_new_str_char((UChar )tok->u.c); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + *np = node_new_str_raw_char((UChar )tok->u.c); + CHECK_NULL_RETURN_MEMERR(*np); len = 1; while (1) { if (len >= ONIGENC_MBC_MINLEN(env->enc)) { - if (len == enc_len(env->enc, NSTRING(*np).s)) { + if (len == enclen(env->enc, NSTR(*np)->s)) { r = fetch_token(tok, src, end, env); + NSTRING_CLEAR_RAW(*np); goto string_end; } } @@ -4867,12 +5117,14 @@ parse_exp(Node** np, OnigToken* tok, int term, r = fetch_token(tok, src, end, env); if (r < 0) return r; if (r != TK_RAW_BYTE) { + /* Don't use this, it is wrong for little endian encodings. */ #ifdef USE_PAD_TO_SHORT_BYTE_CHAR int rem; if (len < ONIGENC_MBC_MINLEN(env->enc)) { rem = ONIGENC_MBC_MINLEN(env->enc) - len; - (void )node_str_head_pad(&NSTRING(*np), rem, (UChar )0); - if (len + rem == enc_len(env->enc, NSTRING(*np).s)) { + (void )node_str_head_pad(NSTR(*np), rem, (UChar )0); + if (len + rem == enclen(env->enc, NSTR(*np)->s)) { + NSTRING_CLEAR_RAW(*np); goto string_end; } } @@ -4898,7 +5150,7 @@ parse_exp(Node** np, OnigToken* tok, int term, #else *np = node_new_str(buf, buf + num); #endif - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*np); } break; @@ -4907,7 +5159,7 @@ parse_exp(Node** np, OnigToken* tok, int term, OnigCodePoint end_op[2]; UChar *qstart, *qend, *nextp; - end_op[0] = (OnigCodePoint )MC_ESC(env->enc); + end_op[0] = (OnigCodePoint )MC_ESC(env->syntax); end_op[1] = (OnigCodePoint )'E'; qstart = *src; qend = find_str_position(end_op, 2, qstart, end, &nextp, env->enc); @@ -4915,35 +5167,31 @@ parse_exp(Node** np, OnigToken* tok, int term, nextp = qend = end; } *np = node_new_str(qstart, qend); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*np); *src = nextp; } break; case TK_CHAR_TYPE: { - switch (tok->u.subtype) { - case CTYPE_WORD: - case CTYPE_NOT_WORD: - *np = node_new_ctype(tok->u.subtype); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + switch (tok->u.prop.ctype) { + case ONIGENC_CTYPE_WORD: + *np = node_new_ctype(tok->u.prop.ctype, tok->u.prop.not); + CHECK_NULL_RETURN_MEMERR(*np); break; - case CTYPE_WHITE_SPACE: - case CTYPE_NOT_WHITE_SPACE: - case CTYPE_DIGIT: - case CTYPE_NOT_DIGIT: - case CTYPE_XDIGIT: - case CTYPE_NOT_XDIGIT: + case ONIGENC_CTYPE_SPACE: + case ONIGENC_CTYPE_DIGIT: + case ONIGENC_CTYPE_XDIGIT: { CClassNode* cc; - int ctype, not; #ifdef USE_SHARED_CCLASS_TABLE - const OnigCodePoint *sbr, *mbr; + const OnigCodePoint *mbr; + OnigCodePoint sb_out; - ctype = parse_ctype_to_enc_ctype(tok->u.subtype, ¬); - r = ONIGENC_GET_CTYPE_CODE_RANGE(env->enc, ctype, &sbr, &mbr); + r = ONIGENC_GET_CTYPE_CODE_RANGE(env->enc, tok->u.prop.ctype, + &sb_out, &mbr); if (r == 0 && ONIGENC_CODE_RANGE_NUM(mbr) >= THRESHOLD_RANGE_NUM_FOR_SHARE_CCLASS) { @@ -4951,8 +5199,8 @@ parse_exp(Node** np, OnigToken* tok, int term, type_cclass_key* new_key; key.enc = env->enc; - key.not = not; - key.type = ctype; + key.not = tok->u.prop.not; + key.type = tok->u.prop.ctype; THREAD_ATOMIC_START; @@ -4972,15 +5220,17 @@ parse_exp(Node** np, OnigToken* tok, int term, } } - *np = node_new_cclass_by_codepoint_range(not, sbr, mbr); + *np = node_new_cclass_by_codepoint_range(tok->u.prop.not, + sb_out, mbr); if (IS_NULL(*np)) { THREAD_ATOMIC_END; return ONIGERR_MEMORY; } - CCLASS_SET_SHARE(&(NCCLASS(*np))); + cc = NCCLASS(*np); + NCCLASS_SET_SHARE(cc); new_key = (type_cclass_key* )xmalloc(sizeof(type_cclass_key)); - xmemcpy(new_key, &key, sizeof(type_cclass_key)); + xmemcpy(new_key, &key, sizeof(type_cclass_key)); onig_st_add_direct(OnigTypeCClassTable, (st_data_t )new_key, (st_data_t )*np); @@ -4988,12 +5238,11 @@ parse_exp(Node** np, OnigToken* tok, int term, } else { #endif - ctype = parse_ctype_to_enc_ctype(tok->u.subtype, ¬); *np = node_new_cclass(); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); - cc = &(NCCLASS(*np)); - add_ctype_to_cc(cc, ctype, 0, env); - if (not != 0) CCLASS_SET_NOT(cc); + CHECK_NULL_RETURN_MEMERR(*np); + cc = NCCLASS(*np); + add_ctype_to_cc(cc, tok->u.prop.ctype, 0, env); + if (tok->u.prop.not != 0) NCCLASS_SET_NOT(cc); #ifdef USE_SHARED_CCLASS_TABLE } #endif @@ -5019,55 +5268,44 @@ parse_exp(Node** np, OnigToken* tok, int term, r = parse_char_class(np, tok, src, end, env); if (r != 0) return r; - cc = &(NCCLASS(*np)); - + cc = NCCLASS(*np); if (IS_IGNORECASE(env->option)) { - int i, n, in_cc; - const OnigPairAmbigCodes* ccs; - BitSetRef bs = cc->bs; - OnigAmbigType amb; - - for (amb = 0x01; amb <= ONIGENC_AMBIGUOUS_MATCH_LIMIT; amb <<= 1) { - if ((amb & env->ambig_flag) == 0) continue; - - n = ONIGENC_GET_ALL_PAIR_AMBIG_CODES(env->enc, amb, &ccs); - for (i = 0; i < n; i++) { - in_cc = onig_is_code_in_cc(env->enc, ccs[i].from, cc); - - if ((in_cc != 0 && !IS_CCLASS_NOT(cc)) || - (in_cc == 0 && IS_CCLASS_NOT(cc))) { - if (ONIGENC_MBC_MINLEN(env->enc) > 1 || - ccs[i].from >= SINGLE_BYTE_SIZE) { - /* if (cc->not) clear_not_flag_cclass(cc, env->enc); */ - add_code_range(&(cc->mbuf), env, ccs[i].to, ccs[i].to); - } - else { - if (BITSET_AT(bs, ccs[i].from)) { - /* /(?i:[^A-C])/.match("a") ==> fail. */ - BITSET_SET_BIT(bs, ccs[i].to); - } - if (BITSET_AT(bs, ccs[i].to)) { - BITSET_SET_BIT(bs, ccs[i].from); - } - } - } + IApplyCaseFoldArg iarg; + + iarg.env = env; + iarg.cc = cc; + iarg.alt_root = NULL_NODE; + iarg.ptail = &(iarg.alt_root); + + r = ONIGENC_APPLY_ALL_CASE_FOLD(env->enc, env->case_fold_flag, + i_apply_case_fold, &iarg); + if (r != 0) { + onig_node_free(iarg.alt_root); + return r; + } + if (IS_NOT_NULL(iarg.alt_root)) { + Node* work = onig_node_new_alt(*np, iarg.alt_root); + if (IS_NULL(work)) { + onig_node_free(iarg.alt_root); + return ONIGERR_MEMORY; } - } + *np = work; + } } } break; case TK_ANYCHAR: *np = node_new_anychar(); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*np); break; case TK_ANYCHAR_ANYTIME: *np = node_new_anychar(); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*np); qn = node_new_quantifier(0, REPEAT_INFINITE, 0); - CHECK_NULL_RETURN_VAL(qn, ONIGERR_MEMORY); - NQUANTIFIER(qn).target = *np; + CHECK_NULL_RETURN_MEMERR(qn); + NQTFR(qn)->target = *np; *np = qn; break; @@ -5076,19 +5314,28 @@ parse_exp(Node** np, OnigToken* tok, int term, *np = node_new_backref(len, (len > 1 ? tok->u.backref.refs : &(tok->u.backref.ref1)), tok->u.backref.by_name, -#ifdef USE_BACKREF_AT_LEVEL +#ifdef USE_BACKREF_WITH_LEVEL tok->u.backref.exist_level, tok->u.backref.level, #endif env); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); + CHECK_NULL_RETURN_MEMERR(*np); break; #ifdef USE_SUBEXP_CALL case TK_CALL: - *np = node_new_call(tok->u.call.name, tok->u.call.name_end); - CHECK_NULL_RETURN_VAL(*np, ONIGERR_MEMORY); - env->num_call++; + { + int gnum = tok->u.call.gnum; + + if (gnum < 0) { + gnum = BACKREF_REL_TO_ABS(gnum, env); + if (gnum <= 0) + return ONIGERR_INVALID_BACKREF; + } + *np = node_new_call(tok->u.call.name, tok->u.call.name_end, gnum); + CHECK_NULL_RETURN_MEMERR(*np); + env->num_call++; + } break; #endif @@ -5127,31 +5374,46 @@ parse_exp(Node** np, OnigToken* tok, int term, return ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID; qn = node_new_quantifier(tok->u.repeat.lower, tok->u.repeat.upper, - (r == TK_INTERVAL ? 1 : 0)); - CHECK_NULL_RETURN_VAL(qn, ONIGERR_MEMORY); - NQUANTIFIER(qn).greedy = tok->u.repeat.greedy; + (r == TK_INTERVAL ? 1 : 0)); + CHECK_NULL_RETURN_MEMERR(qn); + NQTFR(qn)->greedy = tok->u.repeat.greedy; r = set_quantifier(qn, *targetp, group, env); - if (r < 0) return r; - + if (r < 0) { + onig_node_free(qn); + return r; + } + if (tok->u.repeat.possessive != 0) { Node* en; - en = node_new_effect(EFFECT_STOP_BACKTRACK); - CHECK_NULL_RETURN_VAL(en, ONIGERR_MEMORY); - NEFFECT(en).target = qn; + en = node_new_enclose(ENCLOSE_STOP_BACKTRACK); + if (IS_NULL(en)) { + onig_node_free(qn); + return ONIGERR_MEMORY; + } + NENCLOSE(en)->target = qn; qn = en; } if (r == 0) { *targetp = qn; } + else if (r == 1) { + onig_node_free(qn); + } else if (r == 2) { /* split case: /abc+/ */ Node *tmp; *targetp = node_new_list(*targetp, NULL); - CHECK_NULL_RETURN_VAL(*targetp, ONIGERR_MEMORY); - tmp = NCONS(*targetp).right = node_new_list(qn, NULL); - CHECK_NULL_RETURN_VAL(tmp, ONIGERR_MEMORY); - targetp = &(NCONS(tmp).left); + if (IS_NULL(*targetp)) { + onig_node_free(qn); + return ONIGERR_MEMORY; + } + tmp = NCDR(*targetp) = node_new_list(qn, NULL); + if (IS_NULL(tmp)) { + onig_node_free(qn); + return ONIGERR_MEMORY; + } + targetp = &(NCAR(tmp)); } goto re_entry; } @@ -5176,19 +5438,19 @@ parse_branch(Node** top, OnigToken* tok, int term, } else { *top = node_new_list(node, NULL); - headp = &(NCONS(*top).right); + headp = &(NCDR(*top)); while (r != TK_EOT && r != term && r != TK_ALT) { r = parse_exp(&node, tok, term, src, end, env); if (r < 0) return r; - if (NTYPE(node) == N_LIST) { + if (NTYPE(node) == NT_LIST) { *headp = node; - while (IS_NOT_NULL(NCONS(node).right)) node = NCONS(node).right; - headp = &(NCONS(node).right); + while (IS_NOT_NULL(NCDR(node))) node = NCDR(node); + headp = &(NCDR(node)); } else { *headp = node_new_list(node, NULL); - headp = &(NCONS(*headp).right); + headp = &(NCDR(*headp)); } } } @@ -5215,19 +5477,19 @@ parse_subexp(Node** top, OnigToken* tok, int term, *top = node; } else if (r == TK_ALT) { - *top = node_new_alt(node, NULL); - headp = &(NCONS(*top).right); + *top = onig_node_new_alt(node, NULL); + headp = &(NCDR(*top)); while (r == TK_ALT) { r = fetch_token(tok, src, end, env); if (r < 0) return r; r = parse_branch(&node, tok, term, src, end, env); if (r < 0) return r; - *headp = node_new_alt(node, NULL); - headp = &(NCONS(*headp).right); + *headp = onig_node_new_alt(node, NULL); + headp = &(NCDR(*headp)); } - if (tok->type != term) + if (tok->type != (enum TokenSyms )term) goto err; } else { @@ -5255,8 +5517,8 @@ parse_regexp(Node** top, UChar** src, UChar* end, ScanEnv* env) } extern int -onig_parse_make_tree(Node** root, const UChar* pattern, const UChar* end, regex_t* reg, - ScanEnv* env) +onig_parse_make_tree(Node** root, const UChar* pattern, const UChar* end, + regex_t* reg, ScanEnv* env) { int r; UChar* p; @@ -5266,13 +5528,13 @@ onig_parse_make_tree(Node** root, const UChar* pattern, const UChar* end, regex_ #endif scan_env_clear(env); - env->option = reg->options; - env->ambig_flag = reg->ambig_flag; - env->enc = reg->enc; - env->syntax = reg->syntax; - env->pattern = (UChar* )pattern; - env->pattern_end = (UChar* )end; - env->reg = reg; + env->option = reg->options; + env->case_fold_flag = reg->case_fold_flag; + env->enc = reg->enc; + env->syntax = reg->syntax; + env->pattern = (UChar* )pattern; + env->pattern_end = (UChar* )end; + env->reg = reg; *root = NULL; p = (UChar* )pattern; @@ -5282,7 +5544,7 @@ onig_parse_make_tree(Node** root, const UChar* pattern, const UChar* end, regex_ } extern void -onig_scan_env_set_error_string(ScanEnv* env, int ecode, +onig_scan_env_set_error_string(ScanEnv* env, int ecode ARG_UNUSED, UChar* arg, UChar* arg_end) { env->error = arg; diff --git a/ext/mbstring/oniguruma/regparse.h b/ext/mbstring/oniguruma/regparse.h index b25618a33f996..0c5c2c936c044 100644 --- a/ext/mbstring/oniguruma/regparse.h +++ b/ext/mbstring/oniguruma/regparse.h @@ -32,47 +32,61 @@ #include "regint.h" /* node type */ -#define N_STRING (1<< 0) -#define N_CCLASS (1<< 1) -#define N_CTYPE (1<< 2) -#define N_ANYCHAR (1<< 3) -#define N_BACKREF (1<< 4) -#define N_QUANTIFIER (1<< 5) -#define N_EFFECT (1<< 6) -#define N_ANCHOR (1<< 7) -#define N_LIST (1<< 8) -#define N_ALT (1<< 9) -#define N_CALL (1<<10) +#define NT_STR 0 +#define NT_CCLASS 1 +#define NT_CTYPE 2 +#define NT_CANY 3 +#define NT_BREF 4 +#define NT_QTFR 5 +#define NT_ENCLOSE 6 +#define NT_ANCHOR 7 +#define NT_LIST 8 +#define NT_ALT 9 +#define NT_CALL 10 + +/* node type bit */ +#define NTYPE2BIT(type) (1<<(type)) + +#define BIT_NT_STR NTYPE2BIT(NT_STR) +#define BIT_NT_CCLASS NTYPE2BIT(NT_CCLASS) +#define BIT_NT_CTYPE NTYPE2BIT(NT_CTYPE) +#define BIT_NT_CANY NTYPE2BIT(NT_CANY) +#define BIT_NT_BREF NTYPE2BIT(NT_BREF) +#define BIT_NT_QTFR NTYPE2BIT(NT_QTFR) +#define BIT_NT_ENCLOSE NTYPE2BIT(NT_ENCLOSE) +#define BIT_NT_ANCHOR NTYPE2BIT(NT_ANCHOR) +#define BIT_NT_LIST NTYPE2BIT(NT_LIST) +#define BIT_NT_ALT NTYPE2BIT(NT_ALT) +#define BIT_NT_CALL NTYPE2BIT(NT_CALL) #define IS_NODE_TYPE_SIMPLE(type) \ - (((type) & (N_STRING | N_CCLASS | N_CTYPE | N_ANYCHAR | N_BACKREF)) != 0) - -#define NTYPE(node) ((node)->type) -#define NCONS(node) ((node)->u.cons) -#define NSTRING(node) ((node)->u.str) -#define NCCLASS(node) ((node)->u.cclass) -#define NCTYPE(node) ((node)->u.ctype) -#define NQUANTIFIER(node) ((node)->u.quantifier) -#define NANCHOR(node) ((node)->u.anchor) -#define NBACKREF(node) ((node)->u.backref) -#define NEFFECT(node) ((node)->u.effect) -#define NCALL(node) ((node)->u.call) - -#define CTYPE_WORD (1<<0) -#define CTYPE_NOT_WORD (1<<1) -#define CTYPE_WHITE_SPACE (1<<2) -#define CTYPE_NOT_WHITE_SPACE (1<<3) -#define CTYPE_DIGIT (1<<4) -#define CTYPE_NOT_DIGIT (1<<5) -#define CTYPE_XDIGIT (1<<6) -#define CTYPE_NOT_XDIGIT (1<<7) + ((NTYPE2BIT(type) & (BIT_NT_STR | BIT_NT_CCLASS | BIT_NT_CTYPE |\ + BIT_NT_CANY | BIT_NT_BREF)) != 0) + +#define NTYPE(node) ((node)->u.base.type) +#define SET_NTYPE(node, ntype) (node)->u.base.type = (ntype) + +#define NSTR(node) (&((node)->u.str)) +#define NCCLASS(node) (&((node)->u.cclass)) +#define NCTYPE(node) (&((node)->u.ctype)) +#define NBREF(node) (&((node)->u.bref)) +#define NQTFR(node) (&((node)->u.qtfr)) +#define NENCLOSE(node) (&((node)->u.enclose)) +#define NANCHOR(node) (&((node)->u.anchor)) +#define NCONS(node) (&((node)->u.cons)) +#define NCALL(node) (&((node)->u.call)) + +#define NCAR(node) (NCONS(node)->car) +#define NCDR(node) (NCONS(node)->cdr) + + #define ANCHOR_ANYCHAR_STAR_MASK (ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML) #define ANCHOR_END_BUF_MASK (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF) -#define EFFECT_MEMORY (1<<0) -#define EFFECT_OPTION (1<<1) -#define EFFECT_STOP_BACKTRACK (1<<2) +#define ENCLOSE_MEMORY (1<<0) +#define ENCLOSE_OPTION (1<<1) +#define ENCLOSE_STOP_BACKTRACK (1<<2) #define NODE_STR_MARGIN 16 #define NODE_STR_BUF_SIZE 24 /* sizeof(CClassNode) - sizeof(int)*4 */ @@ -80,17 +94,18 @@ #define NSTR_RAW (1<<0) /* by backslashed number */ #define NSTR_AMBIG (1<<1) -#define NSTR_AMBIG_REDUCE (1<<2) +#define NSTR_DONT_GET_OPT_INFO (1<<2) #define NSTRING_LEN(node) ((node)->u.str.end - (node)->u.str.s) #define NSTRING_SET_RAW(node) (node)->u.str.flag |= NSTR_RAW #define NSTRING_CLEAR_RAW(node) (node)->u.str.flag &= ~NSTR_RAW #define NSTRING_SET_AMBIG(node) (node)->u.str.flag |= NSTR_AMBIG -#define NSTRING_SET_AMBIG_REDUCE(node) (node)->u.str.flag |= NSTR_AMBIG_REDUCE +#define NSTRING_SET_DONT_GET_OPT_INFO(node) \ + (node)->u.str.flag |= NSTR_DONT_GET_OPT_INFO #define NSTRING_IS_RAW(node) (((node)->u.str.flag & NSTR_RAW) != 0) #define NSTRING_IS_AMBIG(node) (((node)->u.str.flag & NSTR_AMBIG) != 0) -#define NSTRING_IS_AMBIG_REDUCE(node) \ - (((node)->u.str.flag & NSTR_AMBIG_REDUCE) != 0) +#define NSTRING_IS_DONT_GET_OPT_INFO(node) \ + (((node)->u.str.flag & NSTR_DONT_GET_OPT_INFO) != 0) #define BACKREFS_P(br) \ (IS_NOT_NULL((br)->back_dynamic) ? (br)->back_dynamic : (br)->back_static); @@ -100,39 +115,6 @@ #define NQ_TARGET_IS_EMPTY_MEM 2 #define NQ_TARGET_IS_EMPTY_REC 3 - -typedef struct { - UChar* s; - UChar* end; - unsigned int flag; - int capa; /* (allocated size - 1) or 0: use buf[] */ - UChar buf[NODE_STR_BUF_SIZE]; -} StrNode; - -/* move to regint.h */ -#if 0 -typedef struct { - int flags; - BitSet bs; - BBuf* mbuf; /* multi-byte info or NULL */ -} CClassNode; -#endif - -typedef struct { - int state; - struct _Node* target; - int lower; - int upper; - int greedy; - int target_empty_info; - struct _Node* head_exact; - struct _Node* next_head_exact; - int is_refered; /* include called node. don't eliminate even if {0} */ -#ifdef USE_COMBINATION_EXPLOSION_CHECK - int comb_exp_check_num; /* 1,2,3...: check, 0: no check */ -#endif -} QuantifierNode; - /* status bits */ #define NST_MIN_FIXED (1<<0) #define NST_MAX_FIXED (1<<1) @@ -150,105 +132,142 @@ typedef struct { #define NST_NEST_LEVEL (1<<13) #define NST_BY_NUMBER (1<<14) /* {n,m} */ -#define SET_EFFECT_STATUS(node,f) (node)->u.effect.state |= (f) -#define CLEAR_EFFECT_STATUS(node,f) (node)->u.effect.state &= ~(f) - -#define IS_EFFECT_CALLED(en) (((en)->state & NST_CALLED) != 0) -#define IS_EFFECT_ADDR_FIXED(en) (((en)->state & NST_ADDR_FIXED) != 0) -#define IS_EFFECT_RECURSION(en) (((en)->state & NST_RECURSION) != 0) -#define IS_EFFECT_MARK1(en) (((en)->state & NST_MARK1) != 0) -#define IS_EFFECT_MARK2(en) (((en)->state & NST_MARK2) != 0) -#define IS_EFFECT_MIN_FIXED(en) (((en)->state & NST_MIN_FIXED) != 0) -#define IS_EFFECT_MAX_FIXED(en) (((en)->state & NST_MAX_FIXED) != 0) -#define IS_EFFECT_CLEN_FIXED(en) (((en)->state & NST_CLEN_FIXED) != 0) -#define IS_EFFECT_STOP_BT_SIMPLE_REPEAT(en) \ +#define SET_ENCLOSE_STATUS(node,f) (node)->u.enclose.state |= (f) +#define CLEAR_ENCLOSE_STATUS(node,f) (node)->u.enclose.state &= ~(f) + +#define IS_ENCLOSE_CALLED(en) (((en)->state & NST_CALLED) != 0) +#define IS_ENCLOSE_ADDR_FIXED(en) (((en)->state & NST_ADDR_FIXED) != 0) +#define IS_ENCLOSE_RECURSION(en) (((en)->state & NST_RECURSION) != 0) +#define IS_ENCLOSE_MARK1(en) (((en)->state & NST_MARK1) != 0) +#define IS_ENCLOSE_MARK2(en) (((en)->state & NST_MARK2) != 0) +#define IS_ENCLOSE_MIN_FIXED(en) (((en)->state & NST_MIN_FIXED) != 0) +#define IS_ENCLOSE_MAX_FIXED(en) (((en)->state & NST_MAX_FIXED) != 0) +#define IS_ENCLOSE_CLEN_FIXED(en) (((en)->state & NST_CLEN_FIXED) != 0) +#define IS_ENCLOSE_STOP_BT_SIMPLE_REPEAT(en) \ (((en)->state & NST_STOP_BT_SIMPLE_REPEAT) != 0) -#define IS_EFFECT_NAMED_GROUP(en) (((en)->state & NST_NAMED_GROUP) != 0) +#define IS_ENCLOSE_NAMED_GROUP(en) (((en)->state & NST_NAMED_GROUP) != 0) #define SET_CALL_RECURSION(node) (node)->u.call.state |= NST_RECURSION #define IS_CALL_RECURSION(cn) (((cn)->state & NST_RECURSION) != 0) #define IS_CALL_NAME_REF(cn) (((cn)->state & NST_NAME_REF) != 0) #define IS_BACKREF_NAME_REF(bn) (((bn)->state & NST_NAME_REF) != 0) #define IS_BACKREF_NEST_LEVEL(bn) (((bn)->state & NST_NEST_LEVEL) != 0) -#define IS_QUANTIFIER_IN_REPEAT(qn) (((qn)->state & NST_IN_REPEAT) != 0) -#define IS_QUANTIFIER_BY_NUMBER(qn) (((qn)->state & NST_BY_NUMBER) != 0) +#define IS_QUANTIFIER_IN_REPEAT(qn) (((qn)->state & NST_IN_REPEAT) != 0) +#define IS_QUANTIFIER_BY_NUMBER(qn) (((qn)->state & NST_BY_NUMBER) != 0) + +#define CALLNODE_REFNUM_UNDEF -1 typedef struct { + NodeBase base; + UChar* s; + UChar* end; + unsigned int flag; + int capa; /* (allocated size - 1) or 0: use buf[] */ + UChar buf[NODE_STR_BUF_SIZE]; +} StrNode; + +typedef struct { + NodeBase base; + int state; + struct _Node* target; + int lower; + int upper; + int greedy; + int target_empty_info; + struct _Node* head_exact; + struct _Node* next_head_exact; + int is_refered; /* include called node. don't eliminate even if {0} */ +#ifdef USE_COMBINATION_EXPLOSION_CHECK + int comb_exp_check_num; /* 1,2,3...: check, 0: no check */ +#endif +} QtfrNode; + +typedef struct { + NodeBase base; int state; int type; int regnum; OnigOptionType option; - struct _Node* target; - AbsAddrType call_addr; + struct _Node* target; + AbsAddrType call_addr; /* for multiple call reference */ OnigDistance min_len; /* min length (byte) */ OnigDistance max_len; /* max length (byte) */ - int char_len; /* character length */ - int opt_count; /* referenced count in optimize_node_left() */ -} EffectNode; - -#define CALLNODE_REFNUM_UNDEF -1 + int char_len; /* character length */ + int opt_count; /* referenced count in optimize_node_left() */ +} EncloseNode; #ifdef USE_SUBEXP_CALL typedef struct { - int offset; + int offset; struct _Node* target; } UnsetAddr; typedef struct { - int num; - int alloc; + int num; + int alloc; UnsetAddr* us; } UnsetAddrList; typedef struct { + NodeBase base; int state; - int ref_num; + int group_num; UChar* name; UChar* name_end; - struct _Node* target; /* EffectNode : EFFECT_MEMORY */ + struct _Node* target; /* EncloseNode : ENCLOSE_MEMORY */ UnsetAddrList* unset_addr_list; } CallNode; #endif typedef struct { - int state; - int back_num; - int back_static[NODE_BACKREFS_SIZE]; - int* back_dynamic; - int nest_level; -} BackrefNode; + NodeBase base; + int state; + int back_num; + int back_static[NODE_BACKREFS_SIZE]; + int* back_dynamic; + int nest_level; +} BRefNode; typedef struct { + NodeBase base; int type; struct _Node* target; int char_len; } AnchorNode; +typedef struct { + NodeBase base; + struct _Node* car; + struct _Node* cdr; +} ConsAltNode; + +typedef struct { + NodeBase base; + int ctype; + int not; +} CtypeNode; + typedef struct _Node { - int type; union { - StrNode str; - CClassNode cclass; - QuantifierNode quantifier; - EffectNode effect; + NodeBase base; + StrNode str; + CClassNode cclass; + QtfrNode qtfr; + EncloseNode enclose; + BRefNode bref; + AnchorNode anchor; + ConsAltNode cons; + CtypeNode ctype; #ifdef USE_SUBEXP_CALL - CallNode call; + CallNode call; #endif - BackrefNode backref; - AnchorNode anchor; - struct { - struct _Node* left; - struct _Node* right; - } cons; - struct { - int type; - } ctype; } u; } Node; + #define NULL_NODE ((Node* )0) #define SCANENV_MEMNODES_SIZE 8 @@ -257,30 +276,30 @@ typedef struct _Node { (senv)->mem_nodes_dynamic : (senv)->mem_nodes_static) typedef struct { - OnigOptionType option; - OnigAmbigType ambig_flag; - OnigEncoding enc; - OnigSyntaxType* syntax; - BitStatusType capture_history; - BitStatusType bt_mem_start; - BitStatusType bt_mem_end; - BitStatusType backrefed_mem; - UChar* pattern; - UChar* pattern_end; - UChar* error; - UChar* error_end; - regex_t* reg; /* for reg->names only */ - int num_call; + OnigOptionType option; + OnigCaseFoldType case_fold_flag; + OnigEncoding enc; + OnigSyntaxType* syntax; + BitStatusType capture_history; + BitStatusType bt_mem_start; + BitStatusType bt_mem_end; + BitStatusType backrefed_mem; + UChar* pattern; + UChar* pattern_end; + UChar* error; + UChar* error_end; + regex_t* reg; /* for reg->names only */ + int num_call; #ifdef USE_SUBEXP_CALL - UnsetAddrList* unset_addr_list; + UnsetAddrList* unset_addr_list; #endif - int num_mem; + int num_mem; #ifdef USE_NAMED_GROUP - int num_named; + int num_named; #endif - int mem_alloc; - Node* mem_nodes_static[SCANENV_MEMNODES_SIZE]; - Node** mem_nodes_dynamic; + int mem_alloc; + Node* mem_nodes_static[SCANENV_MEMNODES_SIZE]; + Node** mem_nodes_dynamic; #ifdef USE_COMBINATION_EXPLOSION_CHECK int num_comb_exp_check; int comb_exp_max_regnum; @@ -294,7 +313,6 @@ typedef struct { #define IS_SYNTAX_OP2(syn, opm) (((syn)->op2 & (opm)) != 0) #define IS_SYNTAX_BV(syn, bvm) (((syn)->behavior & (bvm)) != 0) - #ifdef USE_NAMED_GROUP typedef struct { int new_val; @@ -304,20 +322,25 @@ extern int onig_renumber_name_table P_((regex_t* reg, GroupNumRemap* map)); #endif extern int onig_strncmp P_((const UChar* s1, const UChar* s2, int n)); +extern void onig_strcpy P_((UChar* dest, const UChar* src, const UChar* end)); extern void onig_scan_env_set_error_string P_((ScanEnv* env, int ecode, UChar* arg, UChar* arg_end)); extern int onig_scan_unsigned_number P_((UChar** src, const UChar* end, OnigEncoding enc)); extern void onig_reduce_nested_quantifier P_((Node* pnode, Node* cnode)); extern void onig_node_conv_to_str_node P_((Node* node, int raw)); extern int onig_node_str_cat P_((Node* node, const UChar* s, const UChar* end)); +extern int onig_node_str_set P_((Node* node, const UChar* s, const UChar* end)); extern void onig_node_free P_((Node* node)); -extern Node* onig_node_new_effect P_((int type)); +extern Node* onig_node_new_enclose P_((int type)); extern Node* onig_node_new_anchor P_((int type)); extern Node* onig_node_new_str P_((const UChar* s, const UChar* end)); extern Node* onig_node_new_list P_((Node* left, Node* right)); +extern Node* onig_node_list_add P_((Node* list, Node* x)); +extern Node* onig_node_new_alt P_((Node* left, Node* right)); extern void onig_node_str_clear P_((Node* node)); extern int onig_free_node_list P_((void)); extern int onig_names_free P_((regex_t* reg)); extern int onig_parse_make_tree P_((Node** root, const UChar* pattern, const UChar* end, regex_t* reg, ScanEnv* env)); +extern int onig_free_shared_cclass_table P_((void)); #ifdef ONIG_DEBUG #ifdef USE_NAMED_GROUP diff --git a/ext/mbstring/oniguruma/regposerr.c b/ext/mbstring/oniguruma/regposerr.c index e54b5c4089e6d..56f75abfc1351 100644 --- a/ext/mbstring/oniguruma/regposerr.c +++ b/ext/mbstring/oniguruma/regposerr.c @@ -2,7 +2,7 @@ regposerr.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2005 K.Kosako + * Copyright (c) 2002-2007 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,6 +36,12 @@ # include #endif +#if defined(__GNUC__) +# define ARG_UNUSED __attribute__ ((unused)) +#else +# define ARG_UNUSED +#endif + static char* ESTRING[] = { NULL, "failed to match", /* REG_NOMATCH */ @@ -63,13 +69,15 @@ static char* ESTRING[] = { extern size_t -regerror(int posix_ecode, const regex_t* reg, char* buf, size_t size) +regerror(int posix_ecode, const regex_t* reg ARG_UNUSED, char* buf, + size_t size) { char* s; char tbuf[35]; size_t len; - if (posix_ecode > 0 && posix_ecode < sizeof(ESTRING) / sizeof(ESTRING[0])) { + if (posix_ecode > 0 + && posix_ecode < (int )(sizeof(ESTRING) / sizeof(ESTRING[0]))) { s = ESTRING[posix_ecode]; } else if (posix_ecode == 0) { diff --git a/ext/mbstring/oniguruma/regposix.c b/ext/mbstring/oniguruma/regposix.c index a3bacf722e863..7d1857cf2d4cb 100644 --- a/ext/mbstring/oniguruma/regposix.c +++ b/ext/mbstring/oniguruma/regposix.c @@ -2,7 +2,7 @@ regposix.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -102,7 +102,7 @@ onig2posix_error_code(int code) { ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED, REG_BADPAT }, { ONIGERR_TOO_BIG_WIDE_CHAR_VALUE, REG_EONIG_BADWC }, { ONIGERR_TOO_LONG_WIDE_CHAR_VALUE, REG_EONIG_BADWC }, - { ONIGERR_INVALID_WIDE_CHAR_VALUE, REG_EONIG_BADWC }, + { ONIGERR_INVALID_CODE_POINT_VALUE, REG_EONIG_BADWC }, { ONIGERR_EMPTY_GROUP_NAME, REG_BADPAT }, { ONIGERR_INVALID_GROUP_NAME, REG_BADPAT }, { ONIGERR_INVALID_CHAR_IN_GROUP_NAME, REG_BADPAT }, @@ -122,7 +122,7 @@ onig2posix_error_code(int code) if (code >= 0) return 0; - for (i = 0; i < sizeof(o2p) / sizeof(o2p[0]); i++) { + for (i = 0; i < (int )(sizeof(o2p) / sizeof(o2p[0])); i++) { if (code == o2p[i].onig_err) return o2p[i].posix_err; } @@ -273,9 +273,9 @@ typedef struct { void* arg; } i_wrap; -static int i_wrapper(const unsigned char* name, const unsigned char* name_end, - int ng, int* gs, - onig_regex_t* reg, void* arg) +static int +i_wrapper(const UChar* name, const UChar* name_end, int ng, int* gs, + onig_regex_t* reg ARG_UNUSED, void* arg) { i_wrap* warg = (i_wrap* )arg; diff --git a/ext/mbstring/oniguruma/regsyntax.c b/ext/mbstring/oniguruma/regsyntax.c index 9114e39e6b3f3..ade5b55f772a8 100644 --- a/ext/mbstring/oniguruma/regsyntax.c +++ b/ext/mbstring/oniguruma/regsyntax.c @@ -34,6 +34,15 @@ OnigSyntaxType OnigSyntaxASIS = { , ONIG_SYN_OP2_INEFFECTIVE_ESCAPE , 0 , ONIG_OPTION_NONE + , + { + (OnigCodePoint )'\\' /* esc */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ + } }; OnigSyntaxType OnigSyntaxPosixBasic = { @@ -42,6 +51,15 @@ OnigSyntaxType OnigSyntaxPosixBasic = { , 0 , 0 , ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE ) + , + { + (OnigCodePoint )'\\' /* esc */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ + } }; OnigSyntaxType OnigSyntaxPosixExtended = { @@ -54,6 +72,15 @@ OnigSyntaxType OnigSyntaxPosixExtended = { ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC ) , ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE ) + , + { + (OnigCodePoint )'\\' /* esc */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ + } }; OnigSyntaxType OnigSyntaxEmacs = { @@ -66,6 +93,15 @@ OnigSyntaxType OnigSyntaxEmacs = { , ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR , ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC , ONIG_OPTION_NONE + , + { + (OnigCodePoint )'\\' /* esc */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ + } }; OnigSyntaxType OnigSyntaxGrep = { @@ -79,6 +115,15 @@ OnigSyntaxType OnigSyntaxGrep = { , 0 , ( ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC | ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC ) , ONIG_OPTION_NONE + , + { + (OnigCodePoint )'\\' /* esc */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ + } }; OnigSyntaxType OnigSyntaxGnuRegex = { @@ -86,6 +131,15 @@ OnigSyntaxType OnigSyntaxGnuRegex = { , 0 , SYN_GNU_REGEX_BV , ONIG_OPTION_NONE + , + { + (OnigCodePoint )'\\' /* esc */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ + } }; OnigSyntaxType OnigSyntaxJava = { @@ -100,6 +154,15 @@ OnigSyntaxType OnigSyntaxJava = { ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY ) , ( SYN_GNU_REGEX_BV | ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND ) , ONIG_OPTION_SINGLELINE + , + { + (OnigCodePoint )'\\' /* esc */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ + } }; OnigSyntaxType OnigSyntaxPerl = { @@ -111,10 +174,18 @@ OnigSyntaxType OnigSyntaxPerl = { , ( ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE | ONIG_SYN_OP2_QMARK_GROUP_EFFECT | ONIG_SYN_OP2_OPTION_PERL | ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY | - ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT | - ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS ) + ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT ) , SYN_GNU_REGEX_BV , ONIG_OPTION_SINGLELINE + , + { + (OnigCodePoint )'\\' /* esc */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ + } }; /* Perl + named group */ @@ -128,7 +199,6 @@ OnigSyntaxType OnigSyntaxPerl_NG = { ONIG_SYN_OP2_QMARK_GROUP_EFFECT | ONIG_SYN_OP2_OPTION_PERL | ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY | ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT | - ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS | ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP | ONIG_SYN_OP2_ESC_K_NAMED_BACKREF | ONIG_SYN_OP2_ESC_G_SUBEXP_CALL ) @@ -136,6 +206,15 @@ OnigSyntaxType OnigSyntaxPerl_NG = { ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP | ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME ) , ONIG_OPTION_SINGLELINE + , + { + (OnigCodePoint )'\\' /* esc */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */ + , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */ + } }; @@ -205,7 +284,7 @@ onig_get_syntax_options(OnigSyntaxType* syntax) } #ifdef USE_VARIABLE_META_CHARS -extern int onig_set_meta_char(OnigEncoding enc, +extern int onig_set_meta_char(OnigSyntaxType* enc, unsigned int what, OnigCodePoint code) { switch (what) { diff --git a/ext/mbstring/oniguruma/regversion.c b/ext/mbstring/oniguruma/regversion.c index 5fad0cc18c337..113fbaedc6449 100644 --- a/ext/mbstring/oniguruma/regversion.c +++ b/ext/mbstring/oniguruma/regversion.c @@ -2,7 +2,7 @@ regversion.c - Oniguruma (regular expression library) **********************************************************************/ /*- - * Copyright (c) 2002-2006 K.Kosako + * Copyright (c) 2002-2008 K.Kosako * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,6 +27,7 @@ * SUCH DAMAGE. */ +#include "config.h" #include "oniguruma.h" #include @@ -47,7 +48,7 @@ onig_copyright(void) { static char s[58]; - sprintf(s, "Oniguruma %d.%d.%d : Copyright (C) 2002-2006 K.Kosako", + sprintf(s, "Oniguruma %d.%d.%d : Copyright (C) 2002-2008 K.Kosako", ONIGURUMA_VERSION_MAJOR, ONIGURUMA_VERSION_MINOR, ONIGURUMA_VERSION_TEENY); diff --git a/ext/mbstring/oniguruma/st.c b/ext/mbstring/oniguruma/st.c index 2324da263515f..022880ae360a4 100644 --- a/ext/mbstring/oniguruma/st.c +++ b/ext/mbstring/oniguruma/st.c @@ -2,7 +2,6 @@ /* static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible"; */ -#include "config.h" #include #include #include @@ -11,22 +10,7 @@ #include #endif -#ifdef NOT_RUBY #include "regint.h" -#else -#ifdef RUBY_PLATFORM -#define xmalloc ruby_xmalloc -#define xcalloc ruby_xcalloc -#define xrealloc ruby_xrealloc -#define xfree ruby_xfree - -void *xmalloc(long); -void *xcalloc(long, long); -void *xrealloc(void *, long); -void xfree(void *); -#endif -#endif - #include "st.h" typedef struct st_table_entry st_table_entry; @@ -467,8 +451,13 @@ st_delete_safe(table, key, value, never) } static int +#if defined(__GNUC__) +delete_never(st_data_t key __attribute__ ((unused)), st_data_t value, + st_data_t never) +#else delete_never(key, value, never) st_data_t key, value, never; +#endif { if (value == never) return ST_DELETE; return ST_CONTINUE; diff --git a/ext/mbstring/oniguruma/testc.c b/ext/mbstring/oniguruma/testc.c new file mode 100644 index 0000000000000..6a8c77896d833 --- /dev/null +++ b/ext/mbstring/oniguruma/testc.c @@ -0,0 +1,863 @@ +/* + * This program was generated by testconv.rb. + */ +#include "config.h" +#ifdef ONIG_ESCAPE_UCHAR_COLLISION +#undef ONIG_ESCAPE_UCHAR_COLLISION +#endif +#include + +#ifdef POSIX_TEST +#include "onigposix.h" +#else +#include "oniguruma.h" +#endif + +#ifdef HAVE_STRING_H +# include +#else +# include +#endif + +#define SLEN(s) strlen(s) + +static int nsucc = 0; +static int nfail = 0; +static int nerror = 0; + +static FILE* err_file; + +#ifndef POSIX_TEST +static OnigRegion* region; +#endif + +static void xx(char* pattern, char* str, int from, int to, int mem, int not) +{ + int r; + +#ifdef POSIX_TEST + regex_t reg; + char buf[200]; + regmatch_t pmatch[25]; + + r = regcomp(®, pattern, REG_EXTENDED | REG_NEWLINE); + if (r) { + regerror(r, ®, buf, sizeof(buf)); + fprintf(err_file, "ERROR: %s\n", buf); + nerror++; + return ; + } + + r = regexec(®, str, reg.re_nsub + 1, pmatch, 0); + if (r != 0 && r != REG_NOMATCH) { + regerror(r, ®, buf, sizeof(buf)); + fprintf(err_file, "ERROR: %s\n", buf); + nerror++; + return ; + } + + if (r == REG_NOMATCH) { + if (not) { + fprintf(stdout, "OK(N): /%s/ '%s'\n", pattern, str); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s'\n", pattern, str); + nfail++; + } + } + else { + if (not) { + fprintf(stdout, "FAIL(N): /%s/ '%s'\n", pattern, str); + nfail++; + } + else { + if (pmatch[mem].rm_so == from && pmatch[mem].rm_eo == to) { + fprintf(stdout, "OK: /%s/ '%s'\n", pattern, str); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d\n", pattern, str, + from, to, pmatch[mem].rm_so, pmatch[mem].rm_eo); + nfail++; + } + } + } + regfree(®); + +#else + regex_t* reg; + OnigErrorInfo einfo; + + r = onig_new(®, (UChar* )pattern, (UChar* )(pattern + SLEN(pattern)), + ONIG_OPTION_DEFAULT, ONIG_ENCODING_EUC_JP, ONIG_SYNTAX_DEFAULT, &einfo); + if (r) { + char s[ONIG_MAX_ERROR_MESSAGE_LEN]; + onig_error_code_to_str((UChar* )s, r, &einfo); + fprintf(err_file, "ERROR: %s\n", s); + nerror++; + return ; + } + + r = onig_search(reg, (UChar* )str, (UChar* )(str + SLEN(str)), + (UChar* )str, (UChar* )(str + SLEN(str)), + region, ONIG_OPTION_NONE); + if (r < ONIG_MISMATCH) { + char s[ONIG_MAX_ERROR_MESSAGE_LEN]; + onig_error_code_to_str((UChar* )s, r); + fprintf(err_file, "ERROR: %s\n", s); + nerror++; + return ; + } + + if (r == ONIG_MISMATCH) { + if (not) { + fprintf(stdout, "OK(N): /%s/ '%s'\n", pattern, str); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s'\n", pattern, str); + nfail++; + } + } + else { + if (not) { + fprintf(stdout, "FAIL(N): /%s/ '%s'\n", pattern, str); + nfail++; + } + else { + if (region->beg[mem] == from && region->end[mem] == to) { + fprintf(stdout, "OK: /%s/ '%s'\n", pattern, str); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d\n", pattern, str, + from, to, region->beg[mem], region->end[mem]); + nfail++; + } + } + } + onig_free(reg); +#endif +} + +static void x2(char* pattern, char* str, int from, int to) +{ + xx(pattern, str, from, to, 0, 0); +} + +static void x3(char* pattern, char* str, int from, int to, int mem) +{ + xx(pattern, str, from, to, mem, 0); +} + +static void n(char* pattern, char* str) +{ + xx(pattern, str, 0, 0, 0, 1); +} + +extern int main(int argc, char* argv[]) +{ + err_file = stdout; + +#ifdef POSIX_TEST + reg_set_encoding(REG_POSIX_ENCODING_EUC_JP); +#else + region = onig_region_new(); +#endif + + x2("", "", 0, 0); + x2("^", "", 0, 0); + x2("$", "", 0, 0); + x2("\\G", "", 0, 0); + x2("\\A", "", 0, 0); + x2("\\Z", "", 0, 0); + x2("\\z", "", 0, 0); + x2("^$", "", 0, 0); + x2("\\ca", "\001", 0, 1); + x2("\\C-b", "\002", 0, 1); + x2("\\c\\\\", "\034", 0, 1); + x2("q[\\c\\\\]", "q\034", 0, 2); + x2("", "a", 0, 0); + x2("a", "a", 0, 1); + x2("\\x61", "a", 0, 1); + x2("aa", "aa", 0, 2); + x2("aaa", "aaa", 0, 3); + x2("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0, 35); + x2("ab", "ab", 0, 2); + x2("b", "ab", 1, 2); + x2("bc", "abc", 1, 3); + x2("(?i:#RET#)", "#INS##RET#", 5, 10); + x2("\\17", "\017", 0, 1); + x2("\\x1f", "\x1f", 0, 1); + x2("a(?#....\\\\JJJJ)b", "ab", 0, 2); + x2("(?x) G (o O(?-x)oO) g L", "GoOoOgLe", 0, 7); + x2(".", "a", 0, 1); + n(".", ""); + x2("..", "ab", 0, 2); + x2("\\w", "e", 0, 1); + n("\\W", "e"); + x2("\\s", " ", 0, 1); + x2("\\S", "b", 0, 1); + x2("\\d", "4", 0, 1); + n("\\D", "4"); + x2("\\b", "z ", 0, 0); + x2("\\b", " z", 1, 1); + x2("\\B", "zz ", 1, 1); + x2("\\B", "z ", 2, 2); + x2("\\B", " z", 0, 0); + x2("[ab]", "b", 0, 1); + n("[ab]", "c"); + x2("[a-z]", "t", 0, 1); + n("[^a]", "a"); + x2("[^a]", "\n", 0, 1); + x2("[]]", "]", 0, 1); + n("[^]]", "]"); + x2("[\\^]+", "0^^1", 1, 3); + x2("[b-]", "b", 0, 1); + x2("[b-]", "-", 0, 1); + x2("[\\w]", "z", 0, 1); + n("[\\w]", " "); + x2("[\\W]", "b$", 1, 2); + x2("[\\d]", "5", 0, 1); + n("[\\d]", "e"); + x2("[\\D]", "t", 0, 1); + n("[\\D]", "3"); + x2("[\\s]", " ", 0, 1); + n("[\\s]", "a"); + x2("[\\S]", "b", 0, 1); + n("[\\S]", " "); + x2("[\\w\\d]", "2", 0, 1); + n("[\\w\\d]", " "); + x2("[[:upper:]]", "B", 0, 1); + x2("[*[:xdigit:]+]", "+", 0, 1); + x2("[*[:xdigit:]+]", "GHIKK-9+*", 6, 7); + x2("[*[:xdigit:]+]", "-@^+", 3, 4); + n("[[:upper]]", "A"); + x2("[[:upper]]", ":", 0, 1); + x2("[\\044-\\047]", "\046", 0, 1); + x2("[\\x5a-\\x5c]", "\x5b", 0, 1); + x2("[\\x6A-\\x6D]", "\x6c", 0, 1); + n("[\\x6A-\\x6D]", "\x6E"); + n("^[0-9A-F]+ 0+ UNDEF ", "75F 00000000 SECT14A notype () External | _rb_apply"); + x2("[\\[]", "[", 0, 1); + x2("[\\]]", "]", 0, 1); + x2("[&]", "&", 0, 1); + x2("[[ab]]", "b", 0, 1); + x2("[[ab]c]", "c", 0, 1); + n("[[^a]]", "a"); + n("[^[a]]", "a"); + x2("[[ab]&&bc]", "b", 0, 1); + n("[[ab]&&bc]", "a"); + n("[[ab]&&bc]", "c"); + x2("[a-z&&b-y&&c-x]", "w", 0, 1); + n("[^a-z&&b-y&&c-x]", "w"); + x2("[[^a&&a]&&a-z]", "b", 0, 1); + n("[[^a&&a]&&a-z]", "a"); + x2("[[^a-z&&bcdef]&&[^c-g]]", "h", 0, 1); + n("[[^a-z&&bcdef]&&[^c-g]]", "c"); + x2("[^[^abc]&&[^cde]]", "c", 0, 1); + x2("[^[^abc]&&[^cde]]", "e", 0, 1); + n("[^[^abc]&&[^cde]]", "f"); + x2("[a-&&-a]", "-", 0, 1); + n("[a\\-&&\\-a]", "&"); + n("\\wabc", " abc"); + x2("a\\Wbc", "a bc", 0, 4); + x2("a.b.c", "aabbc", 0, 5); + x2(".\\wb\\W..c", "abb bcc", 0, 7); + x2("\\s\\wzzz", " zzzz", 0, 5); + x2("aa.b", "aabb", 0, 4); + n(".a", "ab"); + x2(".a", "aa", 0, 2); + x2("^a", "a", 0, 1); + x2("^a$", "a", 0, 1); + x2("^\\w$", "a", 0, 1); + n("^\\w$", " "); + x2("^\\wab$", "zab", 0, 3); + x2("^\\wabcdef$", "zabcdef", 0, 7); + x2("^\\w...def$", "zabcdef", 0, 7); + x2("\\w\\w\\s\\Waaa\\d", "aa aaa4", 0, 8); + x2("\\A\\Z", "", 0, 0); + x2("\\Axyz", "xyz", 0, 3); + x2("xyz\\Z", "xyz", 0, 3); + x2("xyz\\z", "xyz", 0, 3); + x2("a\\Z", "a", 0, 1); + x2("\\Gaz", "az", 0, 2); + n("\\Gz", "bza"); + n("az\\G", "az"); + n("az\\A", "az"); + n("a\\Az", "az"); + x2("\\^\\$", "^$", 0, 2); + x2("^x?y", "xy", 0, 2); + x2("^(x?y)", "xy", 0, 2); + x2("\\w", "_", 0, 1); + n("\\W", "_"); + x2("(?=z)z", "z", 0, 1); + n("(?=z).", "a"); + x2("(?!z)a", "a", 0, 1); + n("(?!z)a", "z"); + x2("(?i:a)", "a", 0, 1); + x2("(?i:a)", "A", 0, 1); + x2("(?i:A)", "a", 0, 1); + n("(?i:A)", "b"); + x2("(?i:[A-Z])", "a", 0, 1); + x2("(?i:[f-m])", "H", 0, 1); + x2("(?i:[f-m])", "h", 0, 1); + n("(?i:[f-m])", "e"); + x2("(?i:[A-c])", "D", 0, 1); + n("(?i:[^a-z])", "A"); + n("(?i:[^a-z])", "a"); + x2("(?i:[!-k])", "Z", 0, 1); + x2("(?i:[!-k])", "7", 0, 1); + x2("(?i:[T-}])", "b", 0, 1); + x2("(?i:[T-}])", "{", 0, 1); + x2("(?i:\\?a)", "?A", 0, 2); + x2("(?i:\\*A)", "*a", 0, 2); + n(".", "\n"); + x2("(?m:.)", "\n", 0, 1); + x2("(?m:a.)", "a\n", 0, 2); + x2("(?m:.b)", "a\nb", 1, 3); + x2(".*abc", "dddabdd\nddabc", 8, 13); + x2("(?m:.*abc)", "dddabddabc", 0, 10); + n("(?i)(?-i)a", "A"); + n("(?i)(?-i:a)", "A"); + x2("a?", "", 0, 0); + x2("a?", "b", 0, 0); + x2("a?", "a", 0, 1); + x2("a*", "", 0, 0); + x2("a*", "a", 0, 1); + x2("a*", "aaa", 0, 3); + x2("a*", "baaaa", 0, 0); + n("a+", ""); + x2("a+", "a", 0, 1); + x2("a+", "aaaa", 0, 4); + x2("a+", "aabbb", 0, 2); + x2("a+", "baaaa", 1, 5); + x2(".?", "", 0, 0); + x2(".?", "f", 0, 1); + x2(".?", "\n", 0, 0); + x2(".*", "", 0, 0); + x2(".*", "abcde", 0, 5); + x2(".+", "z", 0, 1); + x2(".+", "zdswer\n", 0, 6); + x2("(.*)a\\1f", "babfbac", 0, 4); + x2("(.*)a\\1f", "bacbabf", 3, 7); + x2("((.*)a\\2f)", "bacbabf", 3, 7); + x2("(.*)a\\1f", "baczzzzzz\nbazz\nzzzzbabf", 19, 23); + x2("a|b", "a", 0, 1); + x2("a|b", "b", 0, 1); + x2("|a", "a", 0, 0); + x2("(|a)", "a", 0, 0); + x2("ab|bc", "ab", 0, 2); + x2("ab|bc", "bc", 0, 2); + x2("z(?:ab|bc)", "zbc", 0, 3); + x2("a(?:ab|bc)c", "aabc", 0, 4); + x2("ab|(?:ac|az)", "az", 0, 2); + x2("a|b|c", "dc", 1, 2); + x2("a|b|cd|efg|h|ijk|lmn|o|pq|rstuvwx|yz", "pqr", 0, 2); + n("a|b|cd|efg|h|ijk|lmn|o|pq|rstuvwx|yz", "mn"); + x2("a|^z", "ba", 1, 2); + x2("a|^z", "za", 0, 1); + x2("a|\\Gz", "bza", 2, 3); + x2("a|\\Gz", "za", 0, 1); + x2("a|\\Az", "bza", 2, 3); + x2("a|\\Az", "za", 0, 1); + x2("a|b\\Z", "ba", 1, 2); + x2("a|b\\Z", "b", 0, 1); + x2("a|b\\z", "ba", 1, 2); + x2("a|b\\z", "b", 0, 1); + x2("\\w|\\s", " ", 0, 1); + n("\\w|\\w", " "); + x2("\\w|%", "%", 0, 1); + x2("\\w|[&$]", "&", 0, 1); + x2("[b-d]|[^e-z]", "a", 0, 1); + x2("(?:a|[c-f])|bz", "dz", 0, 1); + x2("(?:a|[c-f])|bz", "bz", 0, 2); + x2("abc|(?=zz)..f", "zzf", 0, 3); + x2("abc|(?!zz)..f", "abf", 0, 3); + x2("(?=za)..a|(?=zz)..a", "zza", 0, 3); + n("(?>a|abd)c", "abdc"); + x2("(?>abd|a)c", "abdc", 0, 4); + x2("a?|b", "a", 0, 1); + x2("a?|b", "b", 0, 0); + x2("a?|b", "", 0, 0); + x2("a*|b", "aa", 0, 2); + x2("a*|b*", "ba", 0, 0); + x2("a*|b*", "ab", 0, 1); + x2("a+|b*", "", 0, 0); + x2("a+|b*", "bbb", 0, 3); + x2("a+|b*", "abbb", 0, 1); + n("a+|b+", ""); + x2("(a|b)?", "b", 0, 1); + x2("(a|b)*", "ba", 0, 2); + x2("(a|b)+", "bab", 0, 3); + x2("(ab|ca)+", "caabbc", 0, 4); + x2("(ab|ca)+", "aabca", 1, 5); + x2("(ab|ca)+", "abzca", 0, 2); + x2("(a|bab)+", "ababa", 0, 5); + x2("(a|bab)+", "ba", 1, 2); + x2("(a|bab)+", "baaaba", 1, 4); + x2("(?:a|b)(?:a|b)", "ab", 0, 2); + x2("(?:a*|b*)(?:a*|b*)", "aaabbb", 0, 3); + x2("(?:a*|b*)(?:a+|b+)", "aaabbb", 0, 6); + x2("(?:a+|b+){2}", "aaabbb", 0, 6); + x2("h{0,}", "hhhh", 0, 4); + x2("(?:a+|b+){1,2}", "aaabbb", 0, 6); + n("ax{2}*a", "0axxxa1"); + n("a.{0,2}a", "0aXXXa0"); + n("a.{0,2}?a", "0aXXXa0"); + n("a.{0,2}?a", "0aXXXXa0"); + x2("^a{2,}?a$", "aaa", 0, 3); + x2("^[a-z]{2,}?$", "aaa", 0, 3); + x2("(?:a+|\\Ab*)cc", "cc", 0, 2); + n("(?:a+|\\Ab*)cc", "abcc"); + x2("(?:^a+|b+)*c", "aabbbabc", 6, 8); + x2("(?:^a+|b+)*c", "aabbbbc", 0, 7); + x2("a|(?i)c", "C", 0, 1); + x2("(?i)c|a", "C", 0, 1); + x2("(?i)c|a", "A", 0, 1); + x2("(?i:c)|a", "C", 0, 1); + n("(?i:c)|a", "A"); + x2("[abc]?", "abc", 0, 1); + x2("[abc]*", "abc", 0, 3); + x2("[^abc]*", "abc", 0, 0); + n("[^abc]+", "abc"); + x2("a?\?", "aaa", 0, 0); + x2("ba?\?b", "bab", 0, 3); + x2("a*?", "aaa", 0, 0); + x2("ba*?", "baa", 0, 1); + x2("ba*?b", "baab", 0, 4); + x2("a+?", "aaa", 0, 1); + x2("ba+?", "baa", 0, 2); + x2("ba+?b", "baab", 0, 4); + x2("(?:a?)?\?", "a", 0, 0); + x2("(?:a?\?)?", "a", 0, 0); + x2("(?:a?)+?", "aaa", 0, 1); + x2("(?:a+)?\?", "aaa", 0, 0); + x2("(?:a+)?\?b", "aaab", 0, 4); + x2("(?:ab)?{2}", "", 0, 0); + x2("(?:ab)?{2}", "ababa", 0, 4); + x2("(?:ab)*{0}", "ababa", 0, 0); + x2("(?:ab){3,}", "abababab", 0, 8); + n("(?:ab){3,}", "abab"); + x2("(?:ab){2,4}", "ababab", 0, 6); + x2("(?:ab){2,4}", "ababababab", 0, 8); + x2("(?:ab){2,4}?", "ababababab", 0, 4); + x2("(?:ab){,}", "ab{,}", 0, 5); + x2("(?:abc)+?{2}", "abcabcabc", 0, 6); + x2("(?:X*)(?i:xa)", "XXXa", 0, 4); + x2("(d+)([^abc]z)", "dddz", 0, 4); + x2("([^abc]*)([^abc]z)", "dddz", 0, 4); + x2("(\\w+)(\\wz)", "dddz", 0, 4); + x3("(a)", "a", 0, 1, 1); + x3("(ab)", "ab", 0, 2, 1); + x2("((ab))", "ab", 0, 2); + x3("((ab))", "ab", 0, 2, 1); + x3("((ab))", "ab", 0, 2, 2); + x3("((((((((((((((((((((ab))))))))))))))))))))", "ab", 0, 2, 20); + x3("(ab)(cd)", "abcd", 0, 2, 1); + x3("(ab)(cd)", "abcd", 2, 4, 2); + x3("()(a)bc(def)ghijk", "abcdefghijk", 3, 6, 3); + x3("(()(a)bc(def)ghijk)", "abcdefghijk", 3, 6, 4); + x2("(^a)", "a", 0, 1); + x3("(a)|(a)", "ba", 1, 2, 1); + x3("(^a)|(a)", "ba", 1, 2, 2); + x3("(a?)", "aaa", 0, 1, 1); + x3("(a*)", "aaa", 0, 3, 1); + x3("(a*)", "", 0, 0, 1); + x3("(a+)", "aaaaaaa", 0, 7, 1); + x3("(a+|b*)", "bbbaa", 0, 3, 1); + x3("(a+|b?)", "bbbaa", 0, 1, 1); + x3("(abc)?", "abc", 0, 3, 1); + x3("(abc)*", "abc", 0, 3, 1); + x3("(abc)+", "abc", 0, 3, 1); + x3("(xyz|abc)+", "abc", 0, 3, 1); + x3("([xyz][abc]|abc)+", "abc", 0, 3, 1); + x3("((?i:abc))", "AbC", 0, 3, 1); + x2("(abc)(?i:\\1)", "abcABC", 0, 6); + x3("((?m:a.c))", "a\nc", 0, 3, 1); + x3("((?=az)a)", "azb", 0, 1, 1); + x3("abc|(.abd)", "zabd", 0, 4, 1); + x2("(?:abc)|(ABC)", "abc", 0, 3); + x3("(?i:(abc))|(zzz)", "ABC", 0, 3, 1); + x3("a*(.)", "aaaaz", 4, 5, 1); + x3("a*?(.)", "aaaaz", 0, 1, 1); + x3("a*?(c)", "aaaac", 4, 5, 1); + x3("[bcd]a*(.)", "caaaaz", 5, 6, 1); + x3("(\\Abb)cc", "bbcc", 0, 2, 1); + n("(\\Abb)cc", "zbbcc"); + x3("(^bb)cc", "bbcc", 0, 2, 1); + n("(^bb)cc", "zbbcc"); + x3("cc(bb$)", "ccbb", 2, 4, 1); + n("cc(bb$)", "ccbbb"); + n("(\\1)", ""); + n("\\1(a)", "aa"); + n("(a(b)\\1)\\2+", "ababb"); + n("(?:(?:\\1|z)(a))+$", "zaa"); + x2("(?:(?:\\1|z)(a))+$", "zaaa", 0, 4); + x2("(a)(?=\\1)", "aa", 0, 1); + n("(a)$|\\1", "az"); + x2("(a)\\1", "aa", 0, 2); + n("(a)\\1", "ab"); + x2("(a?)\\1", "aa", 0, 2); + x2("(a?\?)\\1", "aa", 0, 0); + x2("(a*)\\1", "aaaaa", 0, 4); + x3("(a*)\\1", "aaaaa", 0, 2, 1); + x2("a(b*)\\1", "abbbb", 0, 5); + x2("a(b*)\\1", "ab", 0, 1); + x2("(a*)(b*)\\1\\2", "aaabbaaabb", 0, 10); + x2("(a*)(b*)\\2", "aaabbbb", 0, 7); + x2("(((((((a*)b))))))c\\7", "aaabcaaa", 0, 8); + x3("(((((((a*)b))))))c\\7", "aaabcaaa", 0, 3, 7); + x2("(a)(b)(c)\\2\\1\\3", "abcbac", 0, 6); + x2("([a-d])\\1", "cc", 0, 2); + x2("(\\w\\d\\s)\\1", "f5 f5 ", 0, 6); + n("(\\w\\d\\s)\\1", "f5 f5"); + x2("(who|[a-c]{3})\\1", "whowho", 0, 6); + x2("...(who|[a-c]{3})\\1", "abcwhowho", 0, 9); + x2("(who|[a-c]{3})\\1", "cbccbc", 0, 6); + x2("(^a)\\1", "aa", 0, 2); + n("(^a)\\1", "baa"); + n("(a$)\\1", "aa"); + n("(ab\\Z)\\1", "ab"); + x2("(a*\\Z)\\1", "a", 1, 1); + x2(".(a*\\Z)\\1", "ba", 1, 2); + x3("(.(abc)\\2)", "zabcabc", 0, 7, 1); + x3("(.(..\\d.)\\2)", "z12341234", 0, 9, 1); + x2("((?i:az))\\1", "AzAz", 0, 4); + n("((?i:az))\\1", "Azaz"); + x2("(?<=a)b", "ab", 1, 2); + n("(?<=a)b", "bb"); + x2("(?<=a|b)b", "bb", 1, 2); + x2("(?<=a|bc)b", "bcb", 2, 3); + x2("(?<=a|bc)b", "ab", 1, 2); + x2("(?<=a|bc||defghij|klmnopq|r)z", "rz", 1, 2); + x2("(a)\\g<1>", "aa", 0, 2); + x2("(?a)", "a", 0, 1); + x2("(?ab)\\g", "abab", 0, 4); + x2("(?.zv.)\\k", "azvbazvb", 0, 8); + x2("(?<=\\g)|-\\zEND (?XyZ)", "XyZ", 3, 3); + x2("(?|a\\g)+", "", 0, 0); + x2("(?|\\(\\g\\))+$", "()(())", 0, 6); + x3("\\g(?.){0}", "X", 0, 1, 1); + x2("\\g(abc|df(?.YZ){2,8}){0}", "XYZ", 0, 3); + x2("\\A(?(a\\g)|)\\z", "aaaa", 0, 4); + x2("(?|\\g\\g)\\z|\\zEND (?a|(b)\\g)", "bbbbabba", 0, 8); + x2("(?\\w+\\sx)a+\\k", " fg xaaaaaaaafg x", 2, 18); + x3("(z)()()(?<_9>a)\\g<_9>", "zaa", 2, 3, 1); + x2("(.)(((?<_>a)))\\k<_>", "zaa", 0, 3); + x2("((?\\d)|(?\\w))(\\k|\\k)", "ff", 0, 2); + x2("(?:(?)|(?efg))\\k", "", 0, 0); + x2("(?:(?abc)|(?efg))\\k", "abcefgefg", 3, 9); + n("(?:(?abc)|(?efg))\\k", "abcefg"); + x2("(?:(?.)|(?..)|(?...)|(?....)|(?.....)|(?......)|(?.......)|(?........)|(?.........)|(?..........)|(?...........)|(?............)|(?.............)|(?..............))\\k$", "a-pyumpyum", 2, 10); + x3("(?:(?.)|(?..)|(?...)|(?....)|(?.....)|(?......)|(?.......)|(?........)|(?.........)|(?..........)|(?...........)|(?............)|(?.............)|(?..............))\\k$", "xxxxabcdefghijklmnabcdefghijklmn", 4, 18, 14); + x3("(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?aaa)(?)$", "aaa", 0, 3, 16); + x2("(?a|\\(\\g\\))", "a", 0, 1); + x2("(?a|\\(\\g\\))", "((((((a))))))", 0, 13); + x3("(?a|\\(\\g\\))", "((((((((a))))))))", 0, 17, 1); + x2("\\g|\\zEND(?.*abc$)", "abcxxxabc", 0, 9); + x2("\\g<1>|\\zEND(.a.)", "bac", 0, 3); + x3("\\g<_A>\\g<_A>|\\zEND(.a.)(?<_A>.b.)", "xbxyby", 3, 6, 1); + x2("\\A(?:\\g|\\g|\\zEND (?a|c\\gc)(?b|d\\gd))$", "cdcbcdc", 0, 7); + x2("\\A(?|a\\g)\\z|\\zEND (?\\g)", "aaaa", 0, 4); + x2("(?(a|b\\gc){3,5})", "baaaaca", 1, 5); + x2("(?(a|b\\gc){3,5})", "baaaacaaaaa", 0, 10); + x2("(?\\(([^\\(\\)]++|\\g)*+\\))", "((a))", 0, 5); + x2("()*\\1", "", 0, 0); + x2("(?:()|())*\\1\\2", "", 0, 0); + x3("(?:\\1a|())*", "a", 0, 0, 1); + x2("x((.)*)*x", "0x1x2x3", 1, 6); + x2("x((.)*)*x(?i:\\1)\\Z", "0x1x2x1X2", 1, 9); + x2("(?:()|()|()|()|()|())*\\2\\5", "", 0, 0); + x2("(?:()|()|()|(x)|()|())*\\2b\\5", "b", 0, 1); + x2("\\xED\\xF2", "\xed\xf2", 0, 2); + x2("", "", 0, 0); + x2("", "", 0, 2); + n("", ""); + x2("", "", 0, 4); + x2("", "", 0, 6); + x2("", "", 0, 70); + x2("", "", 2, 4); + x2("", "", 2, 6); + x2("\\xca\\xb8", "\xca\xb8", 0, 2); + x2(".", "", 0, 2); + x2("..", "", 0, 4); + x2("\\w", "", 0, 2); + n("\\W", ""); + x2("[\\W]", "$", 2, 3); + x2("\\S", "", 0, 2); + x2("\\S", "", 0, 2); + x2("\\b", " ", 0, 0); + x2("\\b", " ", 1, 1); + x2("\\B", " ", 2, 2); + x2("\\B", " ", 3, 3); + x2("\\B", " ", 0, 0); + x2("[]", "", 0, 2); + n("[ʤ]", ""); + x2("[-]", "", 0, 2); + n("[^]", ""); + x2("[\\w]", "", 0, 2); + n("[\\d]", ""); + x2("[\\D]", "", 0, 2); + n("[\\s]", ""); + x2("[\\S]", "", 0, 2); + x2("[\\w\\d]", "", 0, 2); + x2("[\\w\\d]", " ", 3, 5); + n("\\w", " "); + x2("\\W", " ", 0, 5); + x2("..", "", 0, 10); + x2(".\\w\\W..", " ", 0, 13); + x2("\\s\\w", " ", 0, 9); + x2(".", "", 0, 8); + n(".", ""); + x2(".", "", 0, 4); + x2("^", "", 0, 2); + x2("^$", "", 0, 2); + x2("^\\w$", "", 0, 2); + x2("^\\w$", "z", 0, 11); + x2("^\\w...$", "z", 0, 13); + x2("\\w\\w\\s\\W\\d", "a 4", 0, 12); + x2("\\A", "", 0, 6); + x2("\\Z", "", 0, 6); + x2("\\z", "", 0, 6); + x2("\\Z", "\n", 0, 6); + x2("\\Gݤ", "ݤ", 0, 4); + n("\\G", ""); + n("Ȥ\\G", "Ȥ"); + n("ޤ\\A", "ޤ"); + n("\\A", "ޤ"); + x2("(?=)", "", 0, 2); + n("(?=).", ""); + x2("(?!)", "", 0, 2); + n("(?!)", ""); + x2("(?i:)", "", 0, 2); + x2("(?i:֤)", "֤", 0, 4); + n("(?i:)", ""); + x2("(?m:.)", "\n", 0, 3); + x2("(?m:.)", "\n", 2, 5); + x2("?", "", 0, 0); + x2("?", "", 0, 0); + x2("?", "", 0, 2); + x2("*", "", 0, 0); + x2("*", "", 0, 2); + x2("*", "һһ", 0, 6); + x2("*", "", 0, 0); + n("+", ""); + x2("+", "", 0, 2); + x2("+", "", 0, 8); + x2("+", "", 0, 4); + x2("+", "", 2, 10); + x2(".?", "", 0, 2); + x2(".*", "ѤԤפ", 0, 8); + x2(".+", "", 0, 2); + x2(".+", "\n", 0, 8); + x2("|", "", 0, 2); + x2("|", "", 0, 2); + x2("|", "", 0, 4); + x2("|", "", 0, 4); + x2("(?:|)", "򤫤", 0, 6); + x2("(?:|)", "򤭤", 0, 8); + x2("|(?:|)", "", 0, 4); + x2("||", "", 2, 4); + x2("|||||||||ĤƤȤʤ|̤", "", 0, 6); + n("|||||||||ĤƤȤʤ|̤", ""); + x2("|^", "֤", 2, 4); + x2("|^", "", 0, 2); + x2("|\\G", "ֵ", 4, 6); + x2("|\\G", "ֵ", 0, 2); + x2("|\\A", "bֵ", 3, 5); + x2("|\\A", "", 0, 2); + x2("|\\Z", "ֵ", 2, 4); + x2("|\\Z", "", 0, 2); + x2("|\\Z", "\n", 0, 2); + x2("|\\z", "ֵ", 2, 4); + x2("|\\z", "", 0, 2); + x2("\\w|\\s", "", 0, 2); + x2("\\w|%", "%", 0, 1); + x2("\\w|[&$]", "&", 0, 2); + x2("[-]", "", 0, 2); + x2("[-]|[^-]", "", 0, 2); + x2("[-]|[^-]", "", 0, 2); + x2("[^]", "\n", 0, 1); + x2("(?:|[-])|", "", 0, 2); + x2("(?:|[-])|", "", 0, 4); + x2("|(?=)..", "", 0, 6); + x2("|(?!)..", "", 0, 6); + x2("(?=)..|(?=)..", "", 0, 6); + x2("(?<=|)", "", 4, 6); + n("(?>|)", ""); + x2("(?>|)", "", 0, 8); + x2("?|", "", 0, 2); + x2("?|", "", 0, 0); + x2("?|", "", 0, 0); + x2("*|", "", 0, 4); + x2("*|*", "", 0, 0); + x2("*|*", "", 0, 2); + x2("[a]*|*", "a", 0, 3); + x2("+|*", "", 0, 0); + x2("+|*", "", 0, 6); + x2("+|*", "", 0, 2); + x2("+|*", "a", 0, 0); + n("+|+", ""); + x2("(|)?", "", 0, 2); + x2("(|)*", "", 0, 4); + x2("(|)+", "", 0, 6); + x2("(|)+", "", 0, 8); + x2("(|)+", "", 4, 12); + x2("(|)+", "", 2, 10); + x2("(|)+", "򤦤", 0, 4); + x2("(|)+", "$$zzzz򤦤", 6, 10); + x2("(|)+", "", 0, 10); + x2("(|)+", "", 2, 4); + x2("(|)+", "", 2, 8); + x2("(?:|)(?:|)", "", 0, 4); + x2("(?:*|*)(?:*|*)", "", 0, 6); + x2("(?:*|*)(?:+|+)", "", 0, 12); + x2("(?:+|+){2}", "", 0, 12); + x2("(?:+|+){1,2}", "", 0, 12); + x2("(?:+|\\A*)", "", 0, 4); + n("(?:+|\\A*)", ""); + x2("(?:^+|+)*", "", 12, 16); + x2("(?:^+|+)*", "", 0, 14); + x2("{0,}", "", 0, 8); + x2("|(?i)c", "C", 0, 1); + x2("(?i)c|", "C", 0, 1); + x2("(?i:)|a", "a", 0, 1); + n("(?i:)|a", "A"); + x2("[]?", "", 0, 2); + x2("[]*", "", 0, 6); + x2("[^]*", "", 0, 0); + n("[^]+", ""); + x2("?\?", "", 0, 0); + x2("?\?", "", 0, 6); + x2("*?", "", 0, 0); + x2("*?", "", 0, 2); + x2("*?", "", 0, 8); + x2("+?", "", 0, 2); + x2("+?", "", 0, 4); + x2("+?", "", 0, 8); + x2("(?:ŷ?)?\?", "ŷ", 0, 0); + x2("(?:ŷ?\?)?", "ŷ", 0, 0); + x2("(?:̴?)+?", "̴̴̴", 0, 2); + x2("(?:+)?\?", "", 0, 0); + x2("(?:+)?\?", "", 0, 8); + x2("(?:)?{2}", "", 0, 0); + x2("(?:)?{2}", "ֵֵ", 0, 8); + x2("(?:)*{0}", "ֵֵ", 0, 0); + x2("(?:){3,}", "ֵֵֵ", 0, 16); + n("(?:){3,}", "ֵ"); + x2("(?:){2,4}", "ֵֵ", 0, 12); + x2("(?:){2,4}", "ֵֵֵֵ", 0, 16); + x2("(?:){2,4}?", "ֵֵֵֵ", 0, 8); + x2("(?:){,}", "{,}", 0, 7); + x2("(?:)+?{2}", "", 0, 12); + x3("()", "", 0, 2, 1); + x3("(п)", "п", 0, 4, 1); + x2("(())", "", 0, 4); + x3("(())", "", 0, 4, 1); + x3("(())", "", 0, 4, 2); + x3("((((((((((((((((((((̻))))))))))))))))))))", "̻", 0, 4, 20); + x3("()()", "", 0, 4, 1); + x3("()()", "", 4, 8, 2); + x3("()()()", "", 6, 12, 3); + x3("(()()())", "", 6, 12, 4); + x3(".*(ե)󡦥(()奿)", "ե󡦥ޥ󥷥奿", 10, 18, 2); + x2("(^)", "", 0, 2); + x3("()|()", "", 2, 4, 1); + x3("(^)|()", "", 2, 4, 2); + x3("(?)", "", 0, 2, 1); + x3("(*)", "ޤޤ", 0, 6, 1); + x3("(*)", "", 0, 0, 1); + x3("(+)", "", 0, 14, 1); + x3("(+|*)", "դդդؤ", 0, 6, 1); + x3("(+|?)", "", 0, 2, 1); + x3("()?", "", 0, 6, 1); + x3("()*", "", 0, 6, 1); + x3("()+", "", 0, 6, 1); + x3("(|)+", "", 0, 6, 1); + x3("([ʤˤ][]|)+", "", 0, 6, 1); + x3("((?i:))", "", 0, 6, 1); + x3("((?m:.))", "\n", 0, 5, 1); + x3("((?=))", "", 0, 2, 1); + x3("|(.)", "󤢤", 0, 8, 1); + x3("*(.)", "", 8, 10, 1); + x3("*?(.)", "", 0, 2, 1); + x3("*?()", "", 8, 10, 1); + x3("[]*(.)", "", 10, 12, 1); + x3("(\\A)", "", 0, 4, 1); + n("(\\A)", "󤤤"); + x3("(^)", "", 0, 4, 1); + n("(^)", "󤤤"); + x3("($)", "", 4, 8, 1); + n("($)", ""); + x2("(̵)\\1", "̵̵", 0, 4); + n("(̵)\\1", "̵"); + x2("(?)\\1", "", 0, 4); + x2("(?\?)\\1", "", 0, 0); + x2("(*)\\1", "", 0, 8); + x3("(*)\\1", "", 0, 4, 1); + x2("(*)\\1", "", 0, 10); + x2("(*)\\1", "", 0, 2); + x2("(*)(*)\\1\\2", "", 0, 20); + x2("(*)(*)\\2", "", 0, 14); + x3("(*)(*)\\2", "", 6, 10, 2); + x2("(((((((*)))))))\\7", "ݤݤݤڤԤݤݤ", 0, 16); + x3("(((((((*)))))))\\7", "ݤݤݤڤԤݤݤ", 0, 6, 7); + x2("()()()\\2\\1\\3", "ϤҤդҤϤ", 0, 12); + x2("([-])\\1", "", 0, 4); + x2("(\\w\\d\\s)\\1", "5 5 ", 0, 8); + n("(\\w\\d\\s)\\1", "5 5"); + x2("(ï|[-]{3})\\1", "ïï", 0, 8); + x2("...(ï|[-]{3})\\1", "aïï", 0, 13); + x2("(ï|[-]{3})\\1", "", 0, 12); + x2("(^)\\1", "", 0, 4); + n("(^)\\1", ""); + n("($)\\1", ""); + n("(\\Z)\\1", ""); + x2("(*\\Z)\\1", "", 2, 2); + x2(".(*\\Z)\\1", "", 2, 4); + x3("(.(䤤)\\2)", "z䤤䤤", 0, 13, 1); + x3("(.(..\\d.)\\2)", "12341234", 0, 10, 1); + x2("((?i:v))\\1", "vv", 0, 10); + x2("(?<>|\\(\\g<>\\))", "(((((())))))", 0, 14); + x2("\\A(?:\\g<_1>|\\g<_2>|\\zλ (?<_1>|\\g<_2>)(?<_2>|\\g<_1>))$", "߼", 0, 26); + x2("[[Ҥ]]", "", 0, 2); + x2("[[]]", "", 0, 2); + n("[[^]]", ""); + n("[^[]]", ""); + x2("[^[^]]", "", 0, 2); + x2("[[]&&]", "", 0, 2); + n("[[]&&]", ""); + n("[[]&&]", ""); + x2("[-&&-&&-]", "", 0, 2); + n("[^-&&-&&-]", ""); + x2("[[^&&]&&-]", "", 0, 2); + n("[[^&&]&&-]", ""); + x2("[[^-&&]&&[^-]]", "", 0, 2); + n("[[^-&&]&&[^-]]", ""); + x2("[^[^]&&[^]]", "", 0, 2); + x2("[^[^]&&[^]]", "", 0, 2); + n("[^[^]&&[^]]", ""); + x2("[-&&-]", "-", 0, 1); + x2("[^[^a-z]&&[^bcdefg]q-w]", "", 0, 2); + x2("[^[^a-z]&&[^bcdefg]g-w]", "f", 0, 1); + x2("[^[^a-z]&&[^bcdefg]g-w]", "g", 0, 1); + n("[^[^a-z]&&[^bcdefg]g-w]", "2"); + x2("aСΥ<\\/b>", "aСΥ", 0, 32); + x2(".СΥ<\\/b>", "aСΥ", 0, 32); + fprintf(stdout, + "\nRESULT SUCC: %d, FAIL: %d, ERROR: %d (by Oniguruma %s)\n", + nsucc, nfail, nerror, onig_version()); + +#ifndef POSIX_TEST + onig_region_free(region, 1); + onig_end(); +#endif + + return ((nfail == 0 && nerror == 0) ? 0 : -1); +} diff --git a/ext/mbstring/oniguruma/testu.c b/ext/mbstring/oniguruma/testu.c new file mode 100644 index 0000000000000..5652988ca91b7 --- /dev/null +++ b/ext/mbstring/oniguruma/testu.c @@ -0,0 +1,911 @@ +/* + * This program was generated by testconv.rb. + */ +#include + +#ifdef POSIX_TEST +#include "onigposix.h" +#else +#include "oniguruma.h" +#endif + +static int nsucc = 0; +static int nfail = 0; +static int nerror = 0; + +static FILE* err_file; + +#ifndef POSIX_TEST +static OnigRegion* region; +static OnigEncoding ENC; +#endif + +#define ulen(p) onigenc_str_bytelen_null(ENC, (UChar* )p) + +static void uconv(char* from, char* to, int len) +{ + int i; + unsigned char c; + char *q; + + q = to; + + for (i = 0; i < len; i += 2) { + c = (unsigned char )from[i]; + if (c == 0) { + c = (unsigned char )from[i+1]; + if (c < 0x20 || c >= 0x7f || c == 0x5c || c == 0x22) { + sprintf(q, "\\%03o", c); + q += 4; + } + else { + sprintf(q, "%c", c); + q++; + } + } + else { + sprintf(q, "\\%03o", c); + q += 4; + c = (unsigned char )from[i+1]; + sprintf(q, "\\%03o", c); + q += 4; + } + } + + *q = 0; +} + +static void xx(char* pattern, char* str, int from, int to, int mem, int not) +{ + int r; + char cpat[4000], cstr[4000]; + +#ifdef POSIX_TEST + regex_t reg; + char buf[200]; + regmatch_t pmatch[20]; + + uconv(pattern, cpat, ulen(pattern)); + uconv(str, cstr, ulen(str)); + + r = regcomp(®, pattern, REG_EXTENDED | REG_NEWLINE); + if (r) { + regerror(r, ®, buf, sizeof(buf)); + fprintf(err_file, "ERROR: %s\n", buf); + nerror++; + return ; + } + + r = regexec(®, str, reg.re_nsub + 1, pmatch, 0); + if (r != 0 && r != REG_NOMATCH) { + regerror(r, ®, buf, sizeof(buf)); + fprintf(err_file, "ERROR: %s\n", buf); + nerror++; + return ; + } + + if (r == REG_NOMATCH) { + if (not) { + fprintf(stdout, "OK(N): /%s/ '%s'\n", cpat, cstr); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s'\n", cpat, cstr); + nfail++; + } + } + else { + if (not) { + fprintf(stdout, "FAIL(N): /%s/ '%s'\n", cpat, cstr); + nfail++; + } + else { + if (pmatch[mem].rm_so == from && pmatch[mem].rm_eo == to) { + fprintf(stdout, "OK: /%s/ '%s'\n", cpat, cstr); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d\n", cpat, cstr, + from, to, pmatch[mem].rm_so, pmatch[mem].rm_eo); + nfail++; + } + } + } + regfree(®); + +#else + regex_t* reg; + OnigCompileInfo ci; + OnigErrorInfo einfo; + + uconv(pattern, cpat, ulen(pattern)); + uconv(str, cstr, ulen(str)); + +#if 0 + r = onig_new(®, (UChar* )pattern, (UChar* )(pattern + ulen(pattern)), + ONIG_OPTION_DEFAULT, ENC, ONIG_SYNTAX_DEFAULT, &einfo); +#else + ci.num_of_elements = 5; + ci.pattern_enc = ENC; + ci.target_enc = ENC; + ci.syntax = ONIG_SYNTAX_DEFAULT; + ci.option = ONIG_OPTION_DEFAULT; + ci.case_fold_flag = ONIGENC_CASE_FOLD_DEFAULT; + + r = onig_new_deluxe(®, (UChar* )pattern, + (UChar* )(pattern + ulen(pattern)), + &ci, &einfo); +#endif + + if (r) { + char s[ONIG_MAX_ERROR_MESSAGE_LEN]; + onig_error_code_to_str(s, r, &einfo); + fprintf(err_file, "ERROR: %s\n", s); + nerror++; + return ; + } + + r = onig_search(reg, (UChar* )str, (UChar* )(str + ulen(str)), + (UChar* )str, (UChar* )(str + ulen(str)), + region, ONIG_OPTION_NONE); + if (r < ONIG_MISMATCH) { + char s[ONIG_MAX_ERROR_MESSAGE_LEN]; + onig_error_code_to_str(s, r); + fprintf(err_file, "ERROR: %s\n", s); + nerror++; + return ; + } + + if (r == ONIG_MISMATCH) { + if (not) { + fprintf(stdout, "OK(N): /%s/ '%s'\n", cpat, cstr); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s'\n", cpat, cstr); + nfail++; + } + } + else { + if (not) { + fprintf(stdout, "FAIL(N): /%s/ '%s'\n", cpat, cstr); + nfail++; + } + else { + if (region->beg[mem] == from && region->end[mem] == to) { + fprintf(stdout, "OK: /%s/ '%s'\n", cpat, cstr); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d\n", cpat, cstr, + from, to, region->beg[mem], region->end[mem]); + nfail++; + } + } + } + onig_free(reg); +#endif +} + +static void x2(char* pattern, char* str, int from, int to) +{ + xx(pattern, str, from, to, 0, 0); +} + +static void x3(char* pattern, char* str, int from, int to, int mem) +{ + xx(pattern, str, from, to, mem, 0); +} + +static void n(char* pattern, char* str) +{ + xx(pattern, str, 0, 0, 0, 1); +} + +extern int main(int argc, char* argv[]) +{ + err_file = stdout; + +#ifndef POSIX_TEST + region = onig_region_new(); +#endif +#ifdef POSIX_TEST + reg_set_encoding(REG_POSIX_ENCODING_UTF16_BE); +#else + ENC = ONIG_ENCODING_UTF16_BE; +#endif + x2("\000\000", "\000\000", 0, 0); + x2("\000^\000\000", "\000\000", 0, 0); + x2("\000$\000\000", "\000\000", 0, 0); + x2("\000\134\000G\000\000", "\000\000", 0, 0); + x2("\000\134\000A\000\000", "\000\000", 0, 0); + x2("\000\134\000Z\000\000", "\000\000", 0, 0); + x2("\000\134\000z\000\000", "\000\000", 0, 0); + x2("\000^\000$\000\000", "\000\000", 0, 0); + x2("\000\134\000c\000a\000\000", "\000\001\000\000", 0, 2); + x2("\000\134\000C\000-\000b\000\000", "\000\002\000\000", 0, 2); + x2("\000\134\000c\000\134\000\134\000\000", "\000\034\000\000", 0, 2); + x2("\000q\000[\000\134\000c\000\134\000\134\000]\000\000", "\000q\000\034\000\000", 0, 4); + x2("\000\000", "\000a\000\000", 0, 0); + x2("\000a\000\000", "\000a\000\000", 0, 2); + x2("\000\134\000x\0000\0000\000\134\000x\0006\0001\000\000", "\000a\000\000", 0, 2); + x2("\000a\000a\000\000", "\000a\000a\000\000", 0, 4); + x2("\000a\000a\000a\000\000", "\000a\000a\000a\000\000", 0, 6); + x2("\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000\000", "\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000a\000\000", 0, 70); + x2("\000a\000b\000\000", "\000a\000b\000\000", 0, 4); + x2("\000b\000\000", "\000a\000b\000\000", 2, 4); + x2("\000b\000c\000\000", "\000a\000b\000c\000\000", 2, 6); + x2("\000(\000?\000i\000:\000#\000R\000E\000T\000#\000)\000\000", "\000#\000I\000N\000S\000#\000#\000R\000E\000T\000#\000\000", 10, 20); + x2("\000\134\0000\0000\0000\000\134\0001\0007\000\000", "\000\017\000\000", 0, 2); + x2("\000\134\000x\0000\0000\000\134\000x\0001\000f\000\000", "\000\037\000\000", 0, 2); + x2("\000a\000(\000?\000#\000.\000.\000.\000.\000\134\000\134\000J\000J\000J\000J\000)\000b\000\000", "\000a\000b\000\000", 0, 4); + x2("\000(\000?\000x\000)\000 \000 \000G\000 \000(\000o\000 \000O\000(\000?\000-\000x\000)\000o\000O\000)\000 \000g\000 \000L\000\000", "\000G\000o\000O\000o\000O\000g\000L\000e\000\000", 0, 14); + x2("\000.\000\000", "\000a\000\000", 0, 2); + n("\000.\000\000", "\000\000"); + x2("\000.\000.\000\000", "\000a\000b\000\000", 0, 4); + x2("\000\134\000w\000\000", "\000e\000\000", 0, 2); + n("\000\134\000W\000\000", "\000e\000\000"); + x2("\000\134\000s\000\000", "\000 \000\000", 0, 2); + x2("\000\134\000S\000\000", "\000b\000\000", 0, 2); + x2("\000\134\000d\000\000", "\0004\000\000", 0, 2); + n("\000\134\000D\000\000", "\0004\000\000"); + x2("\000\134\000b\000\000", "\000z\000 \000\000", 0, 0); + x2("\000\134\000b\000\000", "\000 \000z\000\000", 2, 2); + x2("\000\134\000B\000\000", "\000z\000z\000 \000\000", 2, 2); + x2("\000\134\000B\000\000", "\000z\000 \000\000", 4, 4); + x2("\000\134\000B\000\000", "\000 \000z\000\000", 0, 0); + x2("\000[\000a\000b\000]\000\000", "\000b\000\000", 0, 2); + n("\000[\000a\000b\000]\000\000", "\000c\000\000"); + x2("\000[\000a\000-\000z\000]\000\000", "\000t\000\000", 0, 2); + n("\000[\000^\000a\000]\000\000", "\000a\000\000"); + x2("\000[\000^\000a\000]\000\000", "\000\012\000\000", 0, 2); + x2("\000[\000]\000]\000\000", "\000]\000\000", 0, 2); + n("\000[\000^\000]\000]\000\000", "\000]\000\000"); + x2("\000[\000\134\000^\000]\000+\000\000", "\0000\000^\000^\0001\000\000", 2, 6); + x2("\000[\000b\000-\000]\000\000", "\000b\000\000", 0, 2); + x2("\000[\000b\000-\000]\000\000", "\000-\000\000", 0, 2); + x2("\000[\000\134\000w\000]\000\000", "\000z\000\000", 0, 2); + n("\000[\000\134\000w\000]\000\000", "\000 \000\000"); + x2("\000[\000\134\000W\000]\000\000", "\000b\000$\000\000", 2, 4); + x2("\000[\000\134\000d\000]\000\000", "\0005\000\000", 0, 2); + n("\000[\000\134\000d\000]\000\000", "\000e\000\000"); + x2("\000[\000\134\000D\000]\000\000", "\000t\000\000", 0, 2); + n("\000[\000\134\000D\000]\000\000", "\0003\000\000"); + x2("\000[\000\134\000s\000]\000\000", "\000 \000\000", 0, 2); + n("\000[\000\134\000s\000]\000\000", "\000a\000\000"); + x2("\000[\000\134\000S\000]\000\000", "\000b\000\000", 0, 2); + n("\000[\000\134\000S\000]\000\000", "\000 \000\000"); + x2("\000[\000\134\000w\000\134\000d\000]\000\000", "\0002\000\000", 0, 2); + n("\000[\000\134\000w\000\134\000d\000]\000\000", "\000 \000\000"); + x2("\000[\000[\000:\000u\000p\000p\000e\000r\000:\000]\000]\000\000", "\000B\000\000", 0, 2); + x2("\000[\000*\000[\000:\000x\000d\000i\000g\000i\000t\000:\000]\000+\000]\000\000", "\000+\000\000", 0, 2); + x2("\000[\000*\000[\000:\000x\000d\000i\000g\000i\000t\000:\000]\000+\000]\000\000", "\000G\000H\000I\000K\000K\000-\0009\000+\000*\000\000", 12, 14); + x2("\000[\000*\000[\000:\000x\000d\000i\000g\000i\000t\000:\000]\000+\000]\000\000", "\000-\000@\000^\000+\000\000", 6, 8); + n("\000[\000[\000:\000u\000p\000p\000e\000r\000]\000]\000\000", "\000A\000\000"); + x2("\000[\000[\000:\000u\000p\000p\000e\000r\000]\000]\000\000", "\000:\000\000", 0, 2); + x2("\000[\000\134\0000\0000\0000\000\134\0000\0004\0004\000-\000\134\0000\0000\0000\000\134\0000\0004\0007\000]\000\000", "\000&\000\000", 0, 2); + x2("\000[\000\134\000x\0000\0000\000\134\000x\0005\000a\000-\000\134\000x\0000\0000\000\134\000x\0005\000c\000]\000\000", "\000[\000\000", 0, 2); + x2("\000[\000\134\000x\0000\0000\000\134\000x\0006\000A\000-\000\134\000x\0000\0000\000\134\000x\0006\000D\000]\000\000", "\000l\000\000", 0, 2); + n("\000[\000\134\000x\0000\0000\000\134\000x\0006\000A\000-\000\134\000x\0000\0000\000\134\000x\0006\000D\000]\000\000", "\000n\000\000"); + n("\000^\000[\0000\000-\0009\000A\000-\000F\000]\000+\000 \0000\000+\000 \000U\000N\000D\000E\000F\000 \000\000", "\0007\0005\000F\000 \0000\0000\0000\0000\0000\0000\0000\0000\000 \000S\000E\000C\000T\0001\0004\000A\000 \000n\000o\000t\000y\000p\000e\000 \000(\000)\000 \000 \000 \000 \000E\000x\000t\000e\000r\000n\000a\000l\000 \000 \000 \000 \000|\000 \000_\000r\000b\000_\000a\000p\000p\000l\000y\000\000"); + x2("\000[\000\134\000[\000]\000\000", "\000[\000\000", 0, 2); + x2("\000[\000\134\000]\000]\000\000", "\000]\000\000", 0, 2); + x2("\000[\000&\000]\000\000", "\000&\000\000", 0, 2); + x2("\000[\000[\000a\000b\000]\000]\000\000", "\000b\000\000", 0, 2); + x2("\000[\000[\000a\000b\000]\000c\000]\000\000", "\000c\000\000", 0, 2); + n("\000[\000[\000^\000a\000]\000]\000\000", "\000a\000\000"); + n("\000[\000^\000[\000a\000]\000]\000\000", "\000a\000\000"); + x2("\000[\000[\000a\000b\000]\000&\000&\000b\000c\000]\000\000", "\000b\000\000", 0, 2); + n("\000[\000[\000a\000b\000]\000&\000&\000b\000c\000]\000\000", "\000a\000\000"); + n("\000[\000[\000a\000b\000]\000&\000&\000b\000c\000]\000\000", "\000c\000\000"); + x2("\000[\000a\000-\000z\000&\000&\000b\000-\000y\000&\000&\000c\000-\000x\000]\000\000", "\000w\000\000", 0, 2); + n("\000[\000^\000a\000-\000z\000&\000&\000b\000-\000y\000&\000&\000c\000-\000x\000]\000\000", "\000w\000\000"); + x2("\000[\000[\000^\000a\000&\000&\000a\000]\000&\000&\000a\000-\000z\000]\000\000", "\000b\000\000", 0, 2); + n("\000[\000[\000^\000a\000&\000&\000a\000]\000&\000&\000a\000-\000z\000]\000\000", "\000a\000\000"); + x2("\000[\000[\000^\000a\000-\000z\000&\000&\000b\000c\000d\000e\000f\000]\000&\000&\000[\000^\000c\000-\000g\000]\000]\000\000", "\000h\000\000", 0, 2); + n("\000[\000[\000^\000a\000-\000z\000&\000&\000b\000c\000d\000e\000f\000]\000&\000&\000[\000^\000c\000-\000g\000]\000]\000\000", "\000c\000\000"); + x2("\000[\000^\000[\000^\000a\000b\000c\000]\000&\000&\000[\000^\000c\000d\000e\000]\000]\000\000", "\000c\000\000", 0, 2); + x2("\000[\000^\000[\000^\000a\000b\000c\000]\000&\000&\000[\000^\000c\000d\000e\000]\000]\000\000", "\000e\000\000", 0, 2); + n("\000[\000^\000[\000^\000a\000b\000c\000]\000&\000&\000[\000^\000c\000d\000e\000]\000]\000\000", "\000f\000\000"); + x2("\000[\000a\000-\000&\000&\000-\000a\000]\000\000", "\000-\000\000", 0, 2); + n("\000[\000a\000\134\000-\000&\000&\000\134\000-\000a\000]\000\000", "\000&\000\000"); + n("\000\134\000w\000a\000b\000c\000\000", "\000 \000a\000b\000c\000\000"); + x2("\000a\000\134\000W\000b\000c\000\000", "\000a\000 \000b\000c\000\000", 0, 8); + x2("\000a\000.\000b\000.\000c\000\000", "\000a\000a\000b\000b\000c\000\000", 0, 10); + x2("\000.\000\134\000w\000b\000\134\000W\000.\000.\000c\000\000", "\000a\000b\000b\000 \000b\000c\000c\000\000", 0, 14); + x2("\000\134\000s\000\134\000w\000z\000z\000z\000\000", "\000 \000z\000z\000z\000z\000\000", 0, 10); + x2("\000a\000a\000.\000b\000\000", "\000a\000a\000b\000b\000\000", 0, 8); + n("\000.\000a\000\000", "\000a\000b\000\000"); + x2("\000.\000a\000\000", "\000a\000a\000\000", 0, 4); + x2("\000^\000a\000\000", "\000a\000\000", 0, 2); + x2("\000^\000a\000$\000\000", "\000a\000\000", 0, 2); + x2("\000^\000\134\000w\000$\000\000", "\000a\000\000", 0, 2); + n("\000^\000\134\000w\000$\000\000", "\000 \000\000"); + x2("\000^\000\134\000w\000a\000b\000$\000\000", "\000z\000a\000b\000\000", 0, 6); + x2("\000^\000\134\000w\000a\000b\000c\000d\000e\000f\000$\000\000", "\000z\000a\000b\000c\000d\000e\000f\000\000", 0, 14); + x2("\000^\000\134\000w\000.\000.\000.\000d\000e\000f\000$\000\000", "\000z\000a\000b\000c\000d\000e\000f\000\000", 0, 14); + x2("\000\134\000w\000\134\000w\000\134\000s\000\134\000W\000a\000a\000a\000\134\000d\000\000", "\000a\000a\000 \000 \000a\000a\000a\0004\000\000", 0, 16); + x2("\000\134\000A\000\134\000Z\000\000", "\000\000", 0, 0); + x2("\000\134\000A\000x\000y\000z\000\000", "\000x\000y\000z\000\000", 0, 6); + x2("\000x\000y\000z\000\134\000Z\000\000", "\000x\000y\000z\000\000", 0, 6); + x2("\000x\000y\000z\000\134\000z\000\000", "\000x\000y\000z\000\000", 0, 6); + x2("\000a\000\134\000Z\000\000", "\000a\000\000", 0, 2); + x2("\000\134\000G\000a\000z\000\000", "\000a\000z\000\000", 0, 4); + n("\000\134\000G\000z\000\000", "\000b\000z\000a\000\000"); + n("\000a\000z\000\134\000G\000\000", "\000a\000z\000\000"); + n("\000a\000z\000\134\000A\000\000", "\000a\000z\000\000"); + n("\000a\000\134\000A\000z\000\000", "\000a\000z\000\000"); + x2("\000\134\000^\000\134\000$\000\000", "\000^\000$\000\000", 0, 4); + x2("\000^\000x\000?\000y\000\000", "\000x\000y\000\000", 0, 4); + x2("\000^\000(\000x\000?\000y\000)\000\000", "\000x\000y\000\000", 0, 4); + x2("\000\134\000w\000\000", "\000_\000\000", 0, 2); + n("\000\134\000W\000\000", "\000_\000\000"); + x2("\000(\000?\000=\000z\000)\000z\000\000", "\000z\000\000", 0, 2); + n("\000(\000?\000=\000z\000)\000.\000\000", "\000a\000\000"); + x2("\000(\000?\000!\000z\000)\000a\000\000", "\000a\000\000", 0, 2); + n("\000(\000?\000!\000z\000)\000a\000\000", "\000z\000\000"); + x2("\000(\000?\000i\000:\000a\000)\000\000", "\000a\000\000", 0, 2); + x2("\000(\000?\000i\000:\000a\000)\000\000", "\000A\000\000", 0, 2); + x2("\000(\000?\000i\000:\000A\000)\000\000", "\000a\000\000", 0, 2); + n("\000(\000?\000i\000:\000A\000)\000\000", "\000b\000\000"); + x2("\000(\000?\000i\000:\000[\000A\000-\000Z\000]\000)\000\000", "\000a\000\000", 0, 2); + x2("\000(\000?\000i\000:\000[\000f\000-\000m\000]\000)\000\000", "\000H\000\000", 0, 2); + x2("\000(\000?\000i\000:\000[\000f\000-\000m\000]\000)\000\000", "\000h\000\000", 0, 2); + n("\000(\000?\000i\000:\000[\000f\000-\000m\000]\000)\000\000", "\000e\000\000"); + x2("\000(\000?\000i\000:\000[\000A\000-\000c\000]\000)\000\000", "\000D\000\000", 0, 2); + n("\000(\000?\000i\000:\000[\000^\000a\000-\000z\000]\000)\000\000", "\000A\000\000"); + n("\000(\000?\000i\000:\000[\000^\000a\000-\000z\000]\000)\000\000", "\000a\000\000"); + x2("\000(\000?\000i\000:\000[\000!\000-\000k\000]\000)\000\000", "\000Z\000\000", 0, 2); + x2("\000(\000?\000i\000:\000[\000!\000-\000k\000]\000)\000\000", "\0007\000\000", 0, 2); + x2("\000(\000?\000i\000:\000[\000T\000-\000}\000]\000)\000\000", "\000b\000\000", 0, 2); + x2("\000(\000?\000i\000:\000[\000T\000-\000}\000]\000)\000\000", "\000{\000\000", 0, 2); + x2("\000(\000?\000i\000:\000\134\000?\000a\000)\000\000", "\000?\000A\000\000", 0, 4); + x2("\000(\000?\000i\000:\000\134\000*\000A\000)\000\000", "\000*\000a\000\000", 0, 4); + n("\000.\000\000", "\000\012\000\000"); + x2("\000(\000?\000m\000:\000.\000)\000\000", "\000\012\000\000", 0, 2); + x2("\000(\000?\000m\000:\000a\000.\000)\000\000", "\000a\000\012\000\000", 0, 4); + x2("\000(\000?\000m\000:\000.\000b\000)\000\000", "\000a\000\012\000b\000\000", 2, 6); + x2("\000.\000*\000a\000b\000c\000\000", "\000d\000d\000d\000a\000b\000d\000d\000\012\000d\000d\000a\000b\000c\000\000", 16, 26); + x2("\000(\000?\000m\000:\000.\000*\000a\000b\000c\000)\000\000", "\000d\000d\000d\000a\000b\000d\000d\000a\000b\000c\000\000", 0, 20); + n("\000(\000?\000i\000)\000(\000?\000-\000i\000)\000a\000\000", "\000A\000\000"); + n("\000(\000?\000i\000)\000(\000?\000-\000i\000:\000a\000)\000\000", "\000A\000\000"); + x2("\000a\000?\000\000", "\000\000", 0, 0); + x2("\000a\000?\000\000", "\000b\000\000", 0, 0); + x2("\000a\000?\000\000", "\000a\000\000", 0, 2); + x2("\000a\000*\000\000", "\000\000", 0, 0); + x2("\000a\000*\000\000", "\000a\000\000", 0, 2); + x2("\000a\000*\000\000", "\000a\000a\000a\000\000", 0, 6); + x2("\000a\000*\000\000", "\000b\000a\000a\000a\000a\000\000", 0, 0); + n("\000a\000+\000\000", "\000\000"); + x2("\000a\000+\000\000", "\000a\000\000", 0, 2); + x2("\000a\000+\000\000", "\000a\000a\000a\000a\000\000", 0, 8); + x2("\000a\000+\000\000", "\000a\000a\000b\000b\000b\000\000", 0, 4); + x2("\000a\000+\000\000", "\000b\000a\000a\000a\000a\000\000", 2, 10); + x2("\000.\000?\000\000", "\000\000", 0, 0); + x2("\000.\000?\000\000", "\000f\000\000", 0, 2); + x2("\000.\000?\000\000", "\000\012\000\000", 0, 0); + x2("\000.\000*\000\000", "\000\000", 0, 0); + x2("\000.\000*\000\000", "\000a\000b\000c\000d\000e\000\000", 0, 10); + x2("\000.\000+\000\000", "\000z\000\000", 0, 2); + x2("\000.\000+\000\000", "\000z\000d\000s\000w\000e\000r\000\012\000\000", 0, 12); + x2("\000(\000.\000*\000)\000a\000\134\0001\000f\000\000", "\000b\000a\000b\000f\000b\000a\000c\000\000", 0, 8); + x2("\000(\000.\000*\000)\000a\000\134\0001\000f\000\000", "\000b\000a\000c\000b\000a\000b\000f\000\000", 6, 14); + x2("\000(\000(\000.\000*\000)\000a\000\134\0002\000f\000)\000\000", "\000b\000a\000c\000b\000a\000b\000f\000\000", 6, 14); + x2("\000(\000.\000*\000)\000a\000\134\0001\000f\000\000", "\000b\000a\000c\000z\000z\000z\000z\000z\000z\000\012\000b\000a\000z\000z\000\012\000z\000z\000z\000z\000b\000a\000b\000f\000\000", 38, 46); + x2("\000a\000|\000b\000\000", "\000a\000\000", 0, 2); + x2("\000a\000|\000b\000\000", "\000b\000\000", 0, 2); + x2("\000|\000a\000\000", "\000a\000\000", 0, 0); + x2("\000(\000|\000a\000)\000\000", "\000a\000\000", 0, 0); + x2("\000a\000b\000|\000b\000c\000\000", "\000a\000b\000\000", 0, 4); + x2("\000a\000b\000|\000b\000c\000\000", "\000b\000c\000\000", 0, 4); + x2("\000z\000(\000?\000:\000a\000b\000|\000b\000c\000)\000\000", "\000z\000b\000c\000\000", 0, 6); + x2("\000a\000(\000?\000:\000a\000b\000|\000b\000c\000)\000c\000\000", "\000a\000a\000b\000c\000\000", 0, 8); + x2("\000a\000b\000|\000(\000?\000:\000a\000c\000|\000a\000z\000)\000\000", "\000a\000z\000\000", 0, 4); + x2("\000a\000|\000b\000|\000c\000\000", "\000d\000c\000\000", 2, 4); + x2("\000a\000|\000b\000|\000c\000d\000|\000e\000f\000g\000|\000h\000|\000i\000j\000k\000|\000l\000m\000n\000|\000o\000|\000p\000q\000|\000r\000s\000t\000u\000v\000w\000x\000|\000y\000z\000\000", "\000p\000q\000r\000\000", 0, 4); + n("\000a\000|\000b\000|\000c\000d\000|\000e\000f\000g\000|\000h\000|\000i\000j\000k\000|\000l\000m\000n\000|\000o\000|\000p\000q\000|\000r\000s\000t\000u\000v\000w\000x\000|\000y\000z\000\000", "\000m\000n\000\000"); + x2("\000a\000|\000^\000z\000\000", "\000b\000a\000\000", 2, 4); + x2("\000a\000|\000^\000z\000\000", "\000z\000a\000\000", 0, 2); + x2("\000a\000|\000\134\000G\000z\000\000", "\000b\000z\000a\000\000", 4, 6); + x2("\000a\000|\000\134\000G\000z\000\000", "\000z\000a\000\000", 0, 2); + x2("\000a\000|\000\134\000A\000z\000\000", "\000b\000z\000a\000\000", 4, 6); + x2("\000a\000|\000\134\000A\000z\000\000", "\000z\000a\000\000", 0, 2); + x2("\000a\000|\000b\000\134\000Z\000\000", "\000b\000a\000\000", 2, 4); + x2("\000a\000|\000b\000\134\000Z\000\000", "\000b\000\000", 0, 2); + x2("\000a\000|\000b\000\134\000z\000\000", "\000b\000a\000\000", 2, 4); + x2("\000a\000|\000b\000\134\000z\000\000", "\000b\000\000", 0, 2); + x2("\000\134\000w\000|\000\134\000s\000\000", "\000 \000\000", 0, 2); + n("\000\134\000w\000|\000\134\000w\000\000", "\000 \000\000"); + x2("\000\134\000w\000|\000%\000\000", "\000%\000\000", 0, 2); + x2("\000\134\000w\000|\000[\000&\000$\000]\000\000", "\000&\000\000", 0, 2); + x2("\000[\000b\000-\000d\000]\000|\000[\000^\000e\000-\000z\000]\000\000", "\000a\000\000", 0, 2); + x2("\000(\000?\000:\000a\000|\000[\000c\000-\000f\000]\000)\000|\000b\000z\000\000", "\000d\000z\000\000", 0, 2); + x2("\000(\000?\000:\000a\000|\000[\000c\000-\000f\000]\000)\000|\000b\000z\000\000", "\000b\000z\000\000", 0, 4); + x2("\000a\000b\000c\000|\000(\000?\000=\000z\000z\000)\000.\000.\000f\000\000", "\000z\000z\000f\000\000", 0, 6); + x2("\000a\000b\000c\000|\000(\000?\000!\000z\000z\000)\000.\000.\000f\000\000", "\000a\000b\000f\000\000", 0, 6); + x2("\000(\000?\000=\000z\000a\000)\000.\000.\000a\000|\000(\000?\000=\000z\000z\000)\000.\000.\000a\000\000", "\000z\000z\000a\000\000", 0, 6); + n("\000(\000?\000>\000a\000|\000a\000b\000d\000)\000c\000\000", "\000a\000b\000d\000c\000\000"); + x2("\000(\000?\000>\000a\000b\000d\000|\000a\000)\000c\000\000", "\000a\000b\000d\000c\000\000", 0, 8); + x2("\000a\000?\000|\000b\000\000", "\000a\000\000", 0, 2); + x2("\000a\000?\000|\000b\000\000", "\000b\000\000", 0, 0); + x2("\000a\000?\000|\000b\000\000", "\000\000", 0, 0); + x2("\000a\000*\000|\000b\000\000", "\000a\000a\000\000", 0, 4); + x2("\000a\000*\000|\000b\000*\000\000", "\000b\000a\000\000", 0, 0); + x2("\000a\000*\000|\000b\000*\000\000", "\000a\000b\000\000", 0, 2); + x2("\000a\000+\000|\000b\000*\000\000", "\000\000", 0, 0); + x2("\000a\000+\000|\000b\000*\000\000", "\000b\000b\000b\000\000", 0, 6); + x2("\000a\000+\000|\000b\000*\000\000", "\000a\000b\000b\000b\000\000", 0, 2); + n("\000a\000+\000|\000b\000+\000\000", "\000\000"); + x2("\000(\000a\000|\000b\000)\000?\000\000", "\000b\000\000", 0, 2); + x2("\000(\000a\000|\000b\000)\000*\000\000", "\000b\000a\000\000", 0, 4); + x2("\000(\000a\000|\000b\000)\000+\000\000", "\000b\000a\000b\000\000", 0, 6); + x2("\000(\000a\000b\000|\000c\000a\000)\000+\000\000", "\000c\000a\000a\000b\000b\000c\000\000", 0, 8); + x2("\000(\000a\000b\000|\000c\000a\000)\000+\000\000", "\000a\000a\000b\000c\000a\000\000", 2, 10); + x2("\000(\000a\000b\000|\000c\000a\000)\000+\000\000", "\000a\000b\000z\000c\000a\000\000", 0, 4); + x2("\000(\000a\000|\000b\000a\000b\000)\000+\000\000", "\000a\000b\000a\000b\000a\000\000", 0, 10); + x2("\000(\000a\000|\000b\000a\000b\000)\000+\000\000", "\000b\000a\000\000", 2, 4); + x2("\000(\000a\000|\000b\000a\000b\000)\000+\000\000", "\000b\000a\000a\000a\000b\000a\000\000", 2, 8); + x2("\000(\000?\000:\000a\000|\000b\000)\000(\000?\000:\000a\000|\000b\000)\000\000", "\000a\000b\000\000", 0, 4); + x2("\000(\000?\000:\000a\000*\000|\000b\000*\000)\000(\000?\000:\000a\000*\000|\000b\000*\000)\000\000", "\000a\000a\000a\000b\000b\000b\000\000", 0, 6); + x2("\000(\000?\000:\000a\000*\000|\000b\000*\000)\000(\000?\000:\000a\000+\000|\000b\000+\000)\000\000", "\000a\000a\000a\000b\000b\000b\000\000", 0, 12); + x2("\000(\000?\000:\000a\000+\000|\000b\000+\000)\000{\0002\000}\000\000", "\000a\000a\000a\000b\000b\000b\000\000", 0, 12); + x2("\000h\000{\0000\000,\000}\000\000", "\000h\000h\000h\000h\000\000", 0, 8); + x2("\000(\000?\000:\000a\000+\000|\000b\000+\000)\000{\0001\000,\0002\000}\000\000", "\000a\000a\000a\000b\000b\000b\000\000", 0, 12); + n("\000a\000x\000{\0002\000}\000*\000a\000\000", "\0000\000a\000x\000x\000x\000a\0001\000\000"); + n("\000a\000.\000{\0000\000,\0002\000}\000a\000\000", "\0000\000a\000X\000X\000X\000a\0000\000\000"); + n("\000a\000.\000{\0000\000,\0002\000}\000?\000a\000\000", "\0000\000a\000X\000X\000X\000a\0000\000\000"); + n("\000a\000.\000{\0000\000,\0002\000}\000?\000a\000\000", "\0000\000a\000X\000X\000X\000X\000a\0000\000\000"); + x2("\000^\000a\000{\0002\000,\000}\000?\000a\000$\000\000", "\000a\000a\000a\000\000", 0, 6); + x2("\000^\000[\000a\000-\000z\000]\000{\0002\000,\000}\000?\000$\000\000", "\000a\000a\000a\000\000", 0, 6); + x2("\000(\000?\000:\000a\000+\000|\000\134\000A\000b\000*\000)\000c\000c\000\000", "\000c\000c\000\000", 0, 4); + n("\000(\000?\000:\000a\000+\000|\000\134\000A\000b\000*\000)\000c\000c\000\000", "\000a\000b\000c\000c\000\000"); + x2("\000(\000?\000:\000^\000a\000+\000|\000b\000+\000)\000*\000c\000\000", "\000a\000a\000b\000b\000b\000a\000b\000c\000\000", 12, 16); + x2("\000(\000?\000:\000^\000a\000+\000|\000b\000+\000)\000*\000c\000\000", "\000a\000a\000b\000b\000b\000b\000c\000\000", 0, 14); + x2("\000a\000|\000(\000?\000i\000)\000c\000\000", "\000C\000\000", 0, 2); + x2("\000(\000?\000i\000)\000c\000|\000a\000\000", "\000C\000\000", 0, 2); + x2("\000(\000?\000i\000)\000c\000|\000a\000\000", "\000A\000\000", 0, 2); + x2("\000(\000?\000i\000:\000c\000)\000|\000a\000\000", "\000C\000\000", 0, 2); + n("\000(\000?\000i\000:\000c\000)\000|\000a\000\000", "\000A\000\000"); + x2("\000[\000a\000b\000c\000]\000?\000\000", "\000a\000b\000c\000\000", 0, 2); + x2("\000[\000a\000b\000c\000]\000*\000\000", "\000a\000b\000c\000\000", 0, 6); + x2("\000[\000^\000a\000b\000c\000]\000*\000\000", "\000a\000b\000c\000\000", 0, 0); + n("\000[\000^\000a\000b\000c\000]\000+\000\000", "\000a\000b\000c\000\000"); + x2("\000a\000?\000?\000\000", "\000a\000a\000a\000\000", 0, 0); + x2("\000b\000a\000?\000?\000b\000\000", "\000b\000a\000b\000\000", 0, 6); + x2("\000a\000*\000?\000\000", "\000a\000a\000a\000\000", 0, 0); + x2("\000b\000a\000*\000?\000\000", "\000b\000a\000a\000\000", 0, 2); + x2("\000b\000a\000*\000?\000b\000\000", "\000b\000a\000a\000b\000\000", 0, 8); + x2("\000a\000+\000?\000\000", "\000a\000a\000a\000\000", 0, 2); + x2("\000b\000a\000+\000?\000\000", "\000b\000a\000a\000\000", 0, 4); + x2("\000b\000a\000+\000?\000b\000\000", "\000b\000a\000a\000b\000\000", 0, 8); + x2("\000(\000?\000:\000a\000?\000)\000?\000?\000\000", "\000a\000\000", 0, 0); + x2("\000(\000?\000:\000a\000?\000?\000)\000?\000\000", "\000a\000\000", 0, 0); + x2("\000(\000?\000:\000a\000?\000)\000+\000?\000\000", "\000a\000a\000a\000\000", 0, 2); + x2("\000(\000?\000:\000a\000+\000)\000?\000?\000\000", "\000a\000a\000a\000\000", 0, 0); + x2("\000(\000?\000:\000a\000+\000)\000?\000?\000b\000\000", "\000a\000a\000a\000b\000\000", 0, 8); + x2("\000(\000?\000:\000a\000b\000)\000?\000{\0002\000}\000\000", "\000\000", 0, 0); + x2("\000(\000?\000:\000a\000b\000)\000?\000{\0002\000}\000\000", "\000a\000b\000a\000b\000a\000\000", 0, 8); + x2("\000(\000?\000:\000a\000b\000)\000*\000{\0000\000}\000\000", "\000a\000b\000a\000b\000a\000\000", 0, 0); + x2("\000(\000?\000:\000a\000b\000)\000{\0003\000,\000}\000\000", "\000a\000b\000a\000b\000a\000b\000a\000b\000\000", 0, 16); + n("\000(\000?\000:\000a\000b\000)\000{\0003\000,\000}\000\000", "\000a\000b\000a\000b\000\000"); + x2("\000(\000?\000:\000a\000b\000)\000{\0002\000,\0004\000}\000\000", "\000a\000b\000a\000b\000a\000b\000\000", 0, 12); + x2("\000(\000?\000:\000a\000b\000)\000{\0002\000,\0004\000}\000\000", "\000a\000b\000a\000b\000a\000b\000a\000b\000a\000b\000\000", 0, 16); + x2("\000(\000?\000:\000a\000b\000)\000{\0002\000,\0004\000}\000?\000\000", "\000a\000b\000a\000b\000a\000b\000a\000b\000a\000b\000\000", 0, 8); + x2("\000(\000?\000:\000a\000b\000)\000{\000,\000}\000\000", "\000a\000b\000{\000,\000}\000\000", 0, 10); + x2("\000(\000?\000:\000a\000b\000c\000)\000+\000?\000{\0002\000}\000\000", "\000a\000b\000c\000a\000b\000c\000a\000b\000c\000\000", 0, 12); + x2("\000(\000?\000:\000X\000*\000)\000(\000?\000i\000:\000x\000a\000)\000\000", "\000X\000X\000X\000a\000\000", 0, 8); + x2("\000(\000d\000+\000)\000(\000[\000^\000a\000b\000c\000]\000z\000)\000\000", "\000d\000d\000d\000z\000\000", 0, 8); + x2("\000(\000[\000^\000a\000b\000c\000]\000*\000)\000(\000[\000^\000a\000b\000c\000]\000z\000)\000\000", "\000d\000d\000d\000z\000\000", 0, 8); + x2("\000(\000\134\000w\000+\000)\000(\000\134\000w\000z\000)\000\000", "\000d\000d\000d\000z\000\000", 0, 8); + x3("\000(\000a\000)\000\000", "\000a\000\000", 0, 2, 1); + x3("\000(\000a\000b\000)\000\000", "\000a\000b\000\000", 0, 4, 1); + x2("\000(\000(\000a\000b\000)\000)\000\000", "\000a\000b\000\000", 0, 4); + x3("\000(\000(\000a\000b\000)\000)\000\000", "\000a\000b\000\000", 0, 4, 1); + x3("\000(\000(\000a\000b\000)\000)\000\000", "\000a\000b\000\000", 0, 4, 2); + x3("\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000a\000b\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000\000", "\000a\000b\000\000", 0, 4, 20); + x3("\000(\000a\000b\000)\000(\000c\000d\000)\000\000", "\000a\000b\000c\000d\000\000", 0, 4, 1); + x3("\000(\000a\000b\000)\000(\000c\000d\000)\000\000", "\000a\000b\000c\000d\000\000", 4, 8, 2); + x3("\000(\000)\000(\000a\000)\000b\000c\000(\000d\000e\000f\000)\000g\000h\000i\000j\000k\000\000", "\000a\000b\000c\000d\000e\000f\000g\000h\000i\000j\000k\000\000", 6, 12, 3); + x3("\000(\000(\000)\000(\000a\000)\000b\000c\000(\000d\000e\000f\000)\000g\000h\000i\000j\000k\000)\000\000", "\000a\000b\000c\000d\000e\000f\000g\000h\000i\000j\000k\000\000", 6, 12, 4); + x2("\000(\000^\000a\000)\000\000", "\000a\000\000", 0, 2); + x3("\000(\000a\000)\000|\000(\000a\000)\000\000", "\000b\000a\000\000", 2, 4, 1); + x3("\000(\000^\000a\000)\000|\000(\000a\000)\000\000", "\000b\000a\000\000", 2, 4, 2); + x3("\000(\000a\000?\000)\000\000", "\000a\000a\000a\000\000", 0, 2, 1); + x3("\000(\000a\000*\000)\000\000", "\000a\000a\000a\000\000", 0, 6, 1); + x3("\000(\000a\000*\000)\000\000", "\000\000", 0, 0, 1); + x3("\000(\000a\000+\000)\000\000", "\000a\000a\000a\000a\000a\000a\000a\000\000", 0, 14, 1); + x3("\000(\000a\000+\000|\000b\000*\000)\000\000", "\000b\000b\000b\000a\000a\000\000", 0, 6, 1); + x3("\000(\000a\000+\000|\000b\000?\000)\000\000", "\000b\000b\000b\000a\000a\000\000", 0, 2, 1); + x3("\000(\000a\000b\000c\000)\000?\000\000", "\000a\000b\000c\000\000", 0, 6, 1); + x3("\000(\000a\000b\000c\000)\000*\000\000", "\000a\000b\000c\000\000", 0, 6, 1); + x3("\000(\000a\000b\000c\000)\000+\000\000", "\000a\000b\000c\000\000", 0, 6, 1); + x3("\000(\000x\000y\000z\000|\000a\000b\000c\000)\000+\000\000", "\000a\000b\000c\000\000", 0, 6, 1); + x3("\000(\000[\000x\000y\000z\000]\000[\000a\000b\000c\000]\000|\000a\000b\000c\000)\000+\000\000", "\000a\000b\000c\000\000", 0, 6, 1); + x3("\000(\000(\000?\000i\000:\000a\000b\000c\000)\000)\000\000", "\000A\000b\000C\000\000", 0, 6, 1); + x2("\000(\000a\000b\000c\000)\000(\000?\000i\000:\000\134\0001\000)\000\000", "\000a\000b\000c\000A\000B\000C\000\000", 0, 12); + x3("\000(\000(\000?\000m\000:\000a\000.\000c\000)\000)\000\000", "\000a\000\012\000c\000\000", 0, 6, 1); + x3("\000(\000(\000?\000=\000a\000z\000)\000a\000)\000\000", "\000a\000z\000b\000\000", 0, 2, 1); + x3("\000a\000b\000c\000|\000(\000.\000a\000b\000d\000)\000\000", "\000z\000a\000b\000d\000\000", 0, 8, 1); + x2("\000(\000?\000:\000a\000b\000c\000)\000|\000(\000A\000B\000C\000)\000\000", "\000a\000b\000c\000\000", 0, 6); + x3("\000(\000?\000i\000:\000(\000a\000b\000c\000)\000)\000|\000(\000z\000z\000z\000)\000\000", "\000A\000B\000C\000\000", 0, 6, 1); + x3("\000a\000*\000(\000.\000)\000\000", "\000a\000a\000a\000a\000z\000\000", 8, 10, 1); + x3("\000a\000*\000?\000(\000.\000)\000\000", "\000a\000a\000a\000a\000z\000\000", 0, 2, 1); + x3("\000a\000*\000?\000(\000c\000)\000\000", "\000a\000a\000a\000a\000c\000\000", 8, 10, 1); + x3("\000[\000b\000c\000d\000]\000a\000*\000(\000.\000)\000\000", "\000c\000a\000a\000a\000a\000z\000\000", 10, 12, 1); + x3("\000(\000\134\000A\000b\000b\000)\000c\000c\000\000", "\000b\000b\000c\000c\000\000", 0, 4, 1); + n("\000(\000\134\000A\000b\000b\000)\000c\000c\000\000", "\000z\000b\000b\000c\000c\000\000"); + x3("\000(\000^\000b\000b\000)\000c\000c\000\000", "\000b\000b\000c\000c\000\000", 0, 4, 1); + n("\000(\000^\000b\000b\000)\000c\000c\000\000", "\000z\000b\000b\000c\000c\000\000"); + x3("\000c\000c\000(\000b\000b\000$\000)\000\000", "\000c\000c\000b\000b\000\000", 4, 8, 1); + n("\000c\000c\000(\000b\000b\000$\000)\000\000", "\000c\000c\000b\000b\000b\000\000"); + n("\000(\000\134\0001\000)\000\000", "\000\000"); + n("\000\134\0001\000(\000a\000)\000\000", "\000a\000a\000\000"); + n("\000(\000a\000(\000b\000)\000\134\0001\000)\000\134\0002\000+\000\000", "\000a\000b\000a\000b\000b\000\000"); + n("\000(\000?\000:\000(\000?\000:\000\134\0001\000|\000z\000)\000(\000a\000)\000)\000+\000$\000\000", "\000z\000a\000a\000\000"); + x2("\000(\000?\000:\000(\000?\000:\000\134\0001\000|\000z\000)\000(\000a\000)\000)\000+\000$\000\000", "\000z\000a\000a\000a\000\000", 0, 8); + x2("\000(\000a\000)\000(\000?\000=\000\134\0001\000)\000\000", "\000a\000a\000\000", 0, 2); + n("\000(\000a\000)\000$\000|\000\134\0001\000\000", "\000a\000z\000\000"); + x2("\000(\000a\000)\000\134\0001\000\000", "\000a\000a\000\000", 0, 4); + n("\000(\000a\000)\000\134\0001\000\000", "\000a\000b\000\000"); + x2("\000(\000a\000?\000)\000\134\0001\000\000", "\000a\000a\000\000", 0, 4); + x2("\000(\000a\000?\000?\000)\000\134\0001\000\000", "\000a\000a\000\000", 0, 0); + x2("\000(\000a\000*\000)\000\134\0001\000\000", "\000a\000a\000a\000a\000a\000\000", 0, 8); + x3("\000(\000a\000*\000)\000\134\0001\000\000", "\000a\000a\000a\000a\000a\000\000", 0, 4, 1); + x2("\000a\000(\000b\000*\000)\000\134\0001\000\000", "\000a\000b\000b\000b\000b\000\000", 0, 10); + x2("\000a\000(\000b\000*\000)\000\134\0001\000\000", "\000a\000b\000\000", 0, 2); + x2("\000(\000a\000*\000)\000(\000b\000*\000)\000\134\0001\000\134\0002\000\000", "\000a\000a\000a\000b\000b\000a\000a\000a\000b\000b\000\000", 0, 20); + x2("\000(\000a\000*\000)\000(\000b\000*\000)\000\134\0002\000\000", "\000a\000a\000a\000b\000b\000b\000b\000\000", 0, 14); + x2("\000(\000(\000(\000(\000(\000(\000(\000a\000*\000)\000b\000)\000)\000)\000)\000)\000)\000c\000\134\0007\000\000", "\000a\000a\000a\000b\000c\000a\000a\000a\000\000", 0, 16); + x3("\000(\000(\000(\000(\000(\000(\000(\000a\000*\000)\000b\000)\000)\000)\000)\000)\000)\000c\000\134\0007\000\000", "\000a\000a\000a\000b\000c\000a\000a\000a\000\000", 0, 6, 7); + x2("\000(\000a\000)\000(\000b\000)\000(\000c\000)\000\134\0002\000\134\0001\000\134\0003\000\000", "\000a\000b\000c\000b\000a\000c\000\000", 0, 12); + x2("\000(\000[\000a\000-\000d\000]\000)\000\134\0001\000\000", "\000c\000c\000\000", 0, 4); + x2("\000(\000\134\000w\000\134\000d\000\134\000s\000)\000\134\0001\000\000", "\000f\0005\000 \000f\0005\000 \000\000", 0, 12); + n("\000(\000\134\000w\000\134\000d\000\134\000s\000)\000\134\0001\000\000", "\000f\0005\000 \000f\0005\000\000"); + x2("\000(\000w\000h\000o\000|\000[\000a\000-\000c\000]\000{\0003\000}\000)\000\134\0001\000\000", "\000w\000h\000o\000w\000h\000o\000\000", 0, 12); + x2("\000.\000.\000.\000(\000w\000h\000o\000|\000[\000a\000-\000c\000]\000{\0003\000}\000)\000\134\0001\000\000", "\000a\000b\000c\000w\000h\000o\000w\000h\000o\000\000", 0, 18); + x2("\000(\000w\000h\000o\000|\000[\000a\000-\000c\000]\000{\0003\000}\000)\000\134\0001\000\000", "\000c\000b\000c\000c\000b\000c\000\000", 0, 12); + x2("\000(\000^\000a\000)\000\134\0001\000\000", "\000a\000a\000\000", 0, 4); + n("\000(\000^\000a\000)\000\134\0001\000\000", "\000b\000a\000a\000\000"); + n("\000(\000a\000$\000)\000\134\0001\000\000", "\000a\000a\000\000"); + n("\000(\000a\000b\000\134\000Z\000)\000\134\0001\000\000", "\000a\000b\000\000"); + x2("\000(\000a\000*\000\134\000Z\000)\000\134\0001\000\000", "\000a\000\000", 2, 2); + x2("\000.\000(\000a\000*\000\134\000Z\000)\000\134\0001\000\000", "\000b\000a\000\000", 2, 4); + x3("\000(\000.\000(\000a\000b\000c\000)\000\134\0002\000)\000\000", "\000z\000a\000b\000c\000a\000b\000c\000\000", 0, 14, 1); + x3("\000(\000.\000(\000.\000.\000\134\000d\000.\000)\000\134\0002\000)\000\000", "\000z\0001\0002\0003\0004\0001\0002\0003\0004\000\000", 0, 18, 1); + x2("\000(\000(\000?\000i\000:\000a\000z\000)\000)\000\134\0001\000\000", "\000A\000z\000A\000z\000\000", 0, 8); + n("\000(\000(\000?\000i\000:\000a\000z\000)\000)\000\134\0001\000\000", "\000A\000z\000a\000z\000\000"); + x2("\000(\000?\000<\000=\000a\000)\000b\000\000", "\000a\000b\000\000", 2, 4); + n("\000(\000?\000<\000=\000a\000)\000b\000\000", "\000b\000b\000\000"); + x2("\000(\000?\000<\000=\000a\000|\000b\000)\000b\000\000", "\000b\000b\000\000", 2, 4); + x2("\000(\000?\000<\000=\000a\000|\000b\000c\000)\000b\000\000", "\000b\000c\000b\000\000", 4, 6); + x2("\000(\000?\000<\000=\000a\000|\000b\000c\000)\000b\000\000", "\000a\000b\000\000", 2, 4); + x2("\000(\000?\000<\000=\000a\000|\000b\000c\000|\000|\000d\000e\000f\000g\000h\000i\000j\000|\000k\000l\000m\000n\000o\000p\000q\000|\000r\000)\000z\000\000", "\000r\000z\000\000", 2, 4); + x2("\000(\000a\000)\000\134\000g\000<\0001\000>\000\000", "\000a\000a\000\000", 0, 4); + x2("\000(\000?\000<\000!\000a\000)\000b\000\000", "\000c\000b\000\000", 2, 4); + n("\000(\000?\000<\000!\000a\000)\000b\000\000", "\000a\000b\000\000"); + x2("\000(\000?\000<\000!\000a\000|\000b\000c\000)\000b\000\000", "\000b\000b\000b\000\000", 0, 2); + n("\000(\000?\000<\000!\000a\000|\000b\000c\000)\000z\000\000", "\000b\000c\000z\000\000"); + x2("\000(\000?\000<\000n\000a\000m\000e\0001\000>\000a\000)\000\000", "\000a\000\000", 0, 2); + x2("\000(\000?\000<\000n\000a\000m\000e\000_\0002\000>\000a\000b\000)\000\134\000g\000<\000n\000a\000m\000e\000_\0002\000>\000\000", "\000a\000b\000a\000b\000\000", 0, 8); + x2("\000(\000?\000<\000n\000a\000m\000e\000_\0003\000>\000.\000z\000v\000.\000)\000\134\000k\000<\000n\000a\000m\000e\000_\0003\000>\000\000", "\000a\000z\000v\000b\000a\000z\000v\000b\000\000", 0, 16); + x2("\000(\000?\000<\000=\000\134\000g\000<\000a\000b\000>\000)\000|\000-\000\134\000z\000E\000N\000D\000 \000(\000?\000<\000a\000b\000>\000X\000y\000Z\000)\000\000", "\000X\000y\000Z\000\000", 6, 6); + x2("\000(\000?\000<\000n\000>\000|\000a\000\134\000g\000<\000n\000>\000)\000+\000\000", "\000\000", 0, 0); + x2("\000(\000?\000<\000n\000>\000|\000\134\000(\000\134\000g\000<\000n\000>\000\134\000)\000)\000+\000$\000\000", "\000(\000)\000(\000(\000)\000)\000\000", 0, 12); + x3("\000\134\000g\000<\000n\000>\000(\000?\000<\000n\000>\000.\000)\000{\0000\000}\000\000", "\000X\000\000", 0, 2, 1); + x2("\000\134\000g\000<\000n\000>\000(\000a\000b\000c\000|\000d\000f\000(\000?\000<\000n\000>\000.\000Y\000Z\000)\000{\0002\000,\0008\000}\000)\000{\0000\000}\000\000", "\000X\000Y\000Z\000\000", 0, 6); + x2("\000\134\000A\000(\000?\000<\000n\000>\000(\000a\000\134\000g\000<\000n\000>\000)\000|\000)\000\134\000z\000\000", "\000a\000a\000a\000a\000\000", 0, 8); + x2("\000(\000?\000<\000n\000>\000|\000\134\000g\000<\000m\000>\000\134\000g\000<\000n\000>\000)\000\134\000z\000|\000\134\000z\000E\000N\000D\000 \000(\000?\000<\000m\000>\000a\000|\000(\000b\000)\000\134\000g\000<\000m\000>\000)\000\000", "\000b\000b\000b\000b\000a\000b\000b\000a\000\000", 0, 16); + x2("\000(\000?\000<\000n\000a\000m\000e\0001\0002\0004\0000\000>\000\134\000w\000+\000\134\000s\000x\000)\000a\000+\000\134\000k\000<\000n\000a\000m\000e\0001\0002\0004\0000\000>\000\000", "\000 \000 \000f\000g\000 \000x\000a\000a\000a\000a\000a\000a\000a\000a\000f\000g\000 \000x\000\000", 4, 36); + x3("\000(\000z\000)\000(\000)\000(\000)\000(\000?\000<\000_\0009\000>\000a\000)\000\134\000g\000<\000_\0009\000>\000\000", "\000z\000a\000a\000\000", 4, 6, 1); + x2("\000(\000.\000)\000(\000(\000(\000?\000<\000_\000>\000a\000)\000)\000)\000\134\000k\000<\000_\000>\000\000", "\000z\000a\000a\000\000", 0, 6); + x2("\000(\000(\000?\000<\000n\000a\000m\000e\0001\000>\000\134\000d\000)\000|\000(\000?\000<\000n\000a\000m\000e\0002\000>\000\134\000w\000)\000)\000(\000\134\000k\000<\000n\000a\000m\000e\0001\000>\000|\000\134\000k\000<\000n\000a\000m\000e\0002\000>\000)\000\000", "\000f\000f\000\000", 0, 4); + x2("\000(\000?\000:\000(\000?\000<\000x\000>\000)\000|\000(\000?\000<\000x\000>\000e\000f\000g\000)\000)\000\134\000k\000<\000x\000>\000\000", "\000\000", 0, 0); + x2("\000(\000?\000:\000(\000?\000<\000x\000>\000a\000b\000c\000)\000|\000(\000?\000<\000x\000>\000e\000f\000g\000)\000)\000\134\000k\000<\000x\000>\000\000", "\000a\000b\000c\000e\000f\000g\000e\000f\000g\000\000", 6, 18); + n("\000(\000?\000:\000(\000?\000<\000x\000>\000a\000b\000c\000)\000|\000(\000?\000<\000x\000>\000e\000f\000g\000)\000)\000\134\000k\000<\000x\000>\000\000", "\000a\000b\000c\000e\000f\000g\000\000"); + x2("\000(\000?\000:\000(\000?\000<\000n\0001\000>\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000)\000\134\000k\000<\000n\0001\000>\000$\000\000", "\000a\000-\000p\000y\000u\000m\000p\000y\000u\000m\000\000", 4, 20); + x3("\000(\000?\000:\000(\000?\000<\000n\0001\000>\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000|\000(\000?\000<\000n\0001\000>\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000.\000)\000)\000\134\000k\000<\000n\0001\000>\000$\000\000", "\000x\000x\000x\000x\000a\000b\000c\000d\000e\000f\000g\000h\000i\000j\000k\000l\000m\000n\000a\000b\000c\000d\000e\000f\000g\000h\000i\000j\000k\000l\000m\000n\000\000", 8, 36, 14); + x3("\000(\000?\000<\000n\000a\000m\000e\0001\000>\000)\000(\000?\000<\000n\000a\000m\000e\0002\000>\000)\000(\000?\000<\000n\000a\000m\000e\0003\000>\000)\000(\000?\000<\000n\000a\000m\000e\0004\000>\000)\000(\000?\000<\000n\000a\000m\000e\0005\000>\000)\000(\000?\000<\000n\000a\000m\000e\0006\000>\000)\000(\000?\000<\000n\000a\000m\000e\0007\000>\000)\000(\000?\000<\000n\000a\000m\000e\0008\000>\000)\000(\000?\000<\000n\000a\000m\000e\0009\000>\000)\000(\000?\000<\000n\000a\000m\000e\0001\0000\000>\000)\000(\000?\000<\000n\000a\000m\000e\0001\0001\000>\000)\000(\000?\000<\000n\000a\000m\000e\0001\0002\000>\000)\000(\000?\000<\000n\000a\000m\000e\0001\0003\000>\000)\000(\000?\000<\000n\000a\000m\000e\0001\0004\000>\000)\000(\000?\000<\000n\000a\000m\000e\0001\0005\000>\000)\000(\000?\000<\000n\000a\000m\000e\0001\0006\000>\000a\000a\000a\000)\000(\000?\000<\000n\000a\000m\000e\0001\0007\000>\000)\000$\000\000", "\000a\000a\000a\000\000", 0, 6, 16); + x2("\000(\000?\000<\000f\000o\000o\000>\000a\000|\000\134\000(\000\134\000g\000<\000f\000o\000o\000>\000\134\000)\000)\000\000", "\000a\000\000", 0, 2); + x2("\000(\000?\000<\000f\000o\000o\000>\000a\000|\000\134\000(\000\134\000g\000<\000f\000o\000o\000>\000\134\000)\000)\000\000", "\000(\000(\000(\000(\000(\000(\000a\000)\000)\000)\000)\000)\000)\000\000", 0, 26); + x3("\000(\000?\000<\000f\000o\000o\000>\000a\000|\000\134\000(\000\134\000g\000<\000f\000o\000o\000>\000\134\000)\000)\000\000", "\000(\000(\000(\000(\000(\000(\000(\000(\000a\000)\000)\000)\000)\000)\000)\000)\000)\000\000", 0, 34, 1); + x2("\000\134\000g\000<\000b\000a\000r\000>\000|\000\134\000z\000E\000N\000D\000(\000?\000<\000b\000a\000r\000>\000.\000*\000a\000b\000c\000$\000)\000\000", "\000a\000b\000c\000x\000x\000x\000a\000b\000c\000\000", 0, 18); + x2("\000\134\000g\000<\0001\000>\000|\000\134\000z\000E\000N\000D\000(\000.\000a\000.\000)\000\000", "\000b\000a\000c\000\000", 0, 6); + x3("\000\134\000g\000<\000_\000A\000>\000\134\000g\000<\000_\000A\000>\000|\000\134\000z\000E\000N\000D\000(\000.\000a\000.\000)\000(\000?\000<\000_\000A\000>\000.\000b\000.\000)\000\000", "\000x\000b\000x\000y\000b\000y\000\000", 6, 12, 1); + x2("\000\134\000A\000(\000?\000:\000\134\000g\000<\000p\000o\000n\000>\000|\000\134\000g\000<\000p\000a\000n\000>\000|\000\134\000z\000E\000N\000D\000 \000 \000(\000?\000<\000p\000a\000n\000>\000a\000|\000c\000\134\000g\000<\000p\000o\000n\000>\000c\000)\000(\000?\000<\000p\000o\000n\000>\000b\000|\000d\000\134\000g\000<\000p\000a\000n\000>\000d\000)\000)\000$\000\000", "\000c\000d\000c\000b\000c\000d\000c\000\000", 0, 14); + x2("\000\134\000A\000(\000?\000<\000n\000>\000|\000a\000\134\000g\000<\000m\000>\000)\000\134\000z\000|\000\134\000z\000E\000N\000D\000 \000(\000?\000<\000m\000>\000\134\000g\000<\000n\000>\000)\000\000", "\000a\000a\000a\000a\000\000", 0, 8); + x2("\000(\000?\000<\000n\000>\000(\000a\000|\000b\000\134\000g\000<\000n\000>\000c\000)\000{\0003\000,\0005\000}\000)\000\000", "\000b\000a\000a\000a\000a\000c\000a\000\000", 2, 10); + x2("\000(\000?\000<\000n\000>\000(\000a\000|\000b\000\134\000g\000<\000n\000>\000c\000)\000{\0003\000,\0005\000}\000)\000\000", "\000b\000a\000a\000a\000a\000c\000a\000a\000a\000a\000a\000\000", 0, 20); + x2("\000(\000?\000<\000p\000a\000r\000e\000>\000\134\000(\000(\000[\000^\000\134\000(\000\134\000)\000]\000+\000+\000|\000\134\000g\000<\000p\000a\000r\000e\000>\000)\000*\000+\000\134\000)\000)\000\000", "\000(\000(\000a\000)\000)\000\000", 0, 10); + x2("\000(\000)\000*\000\134\0001\000\000", "\000\000", 0, 0); + x2("\000(\000?\000:\000(\000)\000|\000(\000)\000)\000*\000\134\0001\000\134\0002\000\000", "\000\000", 0, 0); + x3("\000(\000?\000:\000\134\0001\000a\000|\000(\000)\000)\000*\000\000", "\000a\000\000", 0, 0, 1); + x2("\000x\000(\000(\000.\000)\000*\000)\000*\000x\000\000", "\0000\000x\0001\000x\0002\000x\0003\000\000", 2, 12); + x2("\000x\000(\000(\000.\000)\000*\000)\000*\000x\000(\000?\000i\000:\000\134\0001\000)\000\134\000Z\000\000", "\0000\000x\0001\000x\0002\000x\0001\000X\0002\000\000", 2, 18); + x2("\000(\000?\000:\000(\000)\000|\000(\000)\000|\000(\000)\000|\000(\000)\000|\000(\000)\000|\000(\000)\000)\000*\000\134\0002\000\134\0005\000\000", "\000\000", 0, 0); + x2("\000(\000?\000:\000(\000)\000|\000(\000)\000|\000(\000)\000|\000(\000x\000)\000|\000(\000)\000|\000(\000)\000)\000*\000\134\0002\000b\000\134\0005\000\000", "\000b\000\000", 0, 2); + x2("\217\372\000\000", "\217\372\000\000", 0, 2); + x2("\000\000", "0B\000\000", 0, 0); + x2("0B\000\000", "0B\000\000", 0, 2); + n("0D\000\000", "0B\000\000"); + x2("0F0F\000\000", "0F0F\000\000", 0, 4); + x2("0B0D0F\000\000", "0B0D0F\000\000", 0, 6); + x2("0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S\000\000", "0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S0S\000\000", 0, 70); + x2("0B\000\000", "0D0B\000\000", 2, 4); + x2("0D0F\000\000", "0B0D0F\000\000", 2, 6); + x2("e\207\000\000", "e\207\000\000", 0, 2); + x2("\000.\000\000", "0B\000\000", 0, 2); + x2("\000.\000.\000\000", "0K0M\000\000", 0, 4); + x2("\000\134\000w\000\000", "0J\000\000", 0, 2); + n("\000\134\000W\000\000", "0B\000\000"); + x2("\000[\000\134\000W\000]\000\000", "0F\000$\000\000", 2, 4); + x2("\000\134\000S\000\000", "0]\000\000", 0, 2); + x2("\000\134\000S\000\000", "o\042\000\000", 0, 2); + x2("\000\134\000b\000\000", "l\027\000 \000\000", 0, 0); + x2("\000\134\000b\000\000", "\000 0{\000\000", 2, 2); + x2("\000\134\000B\000\000", "0[0]\000 \000\000", 2, 2); + x2("\000\134\000B\000\000", "0F\000 \000\000", 4, 4); + x2("\000\134\000B\000\000", "\000 0D\000\000", 0, 0); + x2("\000[0_0a\000]\000\000", "0a\000\000", 0, 2); + n("\000[0j0k\000]\000\000", "0l\000\000"); + x2("\000[0F\000-0J\000]\000\000", "0H\000\000", 0, 2); + n("\000[\000^0Q\000]\000\000", "0Q\000\000"); + x2("\000[\000\134\000w\000]\000\000", "0m\000\000", 0, 2); + n("\000[\000\134\000d\000]\000\000", "0u\000\000"); + x2("\000[\000\134\000D\000]\000\000", "0o\000\000", 0, 2); + n("\000[\000\134\000s\000]\000\000", "0O\000\000"); + x2("\000[\000\134\000S\000]\000\000", "0x\000\000", 0, 2); + x2("\000[\000\134\000w\000\134\000d\000]\000\000", "0\210\000\000", 0, 2); + x2("\000[\000\134\000w\000\134\000d\000]\000\000", "\000 \000 \000 0\210\000\000", 6, 8); + n("\000\134\000w\233<\216\312\000\000", "\000 \233<\216\312\000\000"); + x2("\233<\000\134\000W\216\312\000\000", "\233<\000 \216\312\000\000", 0, 6); + x2("0B\000.0D\000.0F\000\000", "0B0B0D0D0F\000\000", 0, 10); + x2("\000.\000\134\000w0F\000\134\000W\000.\000.0^\000\000", "0H0F0F\000 0F0^0^\000\000", 0, 14); + x2("\000\134\000s\000\134\000w0S0S0S\000\000", "\000 0S0S0S0S\000\000", 0, 10); + x2("0B0B\000.0Q\000\000", "0B0B0Q0Q\000\000", 0, 8); + n("\000.0D\000\000", "0D0H\000\000"); + x2("\000.0J\000\000", "0J0J\000\000", 0, 4); + x2("\000^0B\000\000", "0B\000\000", 0, 2); + x2("\000^0\200\000$\000\000", "0\200\000\000", 0, 2); + x2("\000^\000\134\000w\000$\000\000", "0k\000\000", 0, 2); + x2("\000^\000\134\000w0K0M0O0Q0S\000$\000\000", "\000z0K0M0O0Q0S\000\000", 0, 12); + x2("\000^\000\134\000w\000.\000.\000.0F0H0J\000$\000\000", "\000z0B0D0F0F0H0J\000\000", 0, 14); + x2("\000\134\000w\000\134\000w\000\134\000s\000\134\000W0J0J0J\000\134\000d\000\000", "\000a0J\000 \000 0J0J0J\0004\000\000", 0, 16); + x2("\000\134\000A0_0a0d\000\000", "0_0a0d\000\000", 0, 6); + x2("0\2000\2010\202\000\134\000Z\000\000", "0\2000\2010\202\000\000", 0, 6); + x2("0K0M0O\000\134\000z\000\000", "0K0M0O\000\000", 0, 6); + x2("0K0M0O\000\134\000Z\000\000", "0K0M0O\000\012\000\000", 0, 6); + x2("\000\134\000G0}0t\000\000", "0}0t\000\000", 0, 4); + n("\000\134\000G0H\000\000", "0F0H0J\000\000"); + n("0h0f\000\134\000G\000\000", "0h0f\000\000"); + n("0~0\177\000\134\000A\000\000", "0~0\177\000\000"); + n("0~\000\134\000A0\177\000\000", "0~0\177\000\000"); + x2("\000(\000?\000=0[\000)0[\000\000", "0[\000\000", 0, 2); + n("\000(\000?\000=0F\000)\000.\000\000", "0D\000\000"); + x2("\000(\000?\000!0F\000)0K\000\000", "0K\000\000", 0, 2); + n("\000(\000?\000!0h\000)0B\000\000", "0h\000\000"); + x2("\000(\000?\000i\000:0B\000)\000\000", "0B\000\000", 0, 2); + x2("\000(\000?\000i\000:0v0y\000)\000\000", "0v0y\000\000", 0, 4); + n("\000(\000?\000i\000:0D\000)\000\000", "0F\000\000"); + x2("\000(\000?\000m\000:0\210\000.\000)\000\000", "0\210\000\012\000\000", 0, 4); + x2("\000(\000?\000m\000:\000.0\201\000)\000\000", "0~\000\0120\201\000\000", 2, 6); + x2("0B\000?\000\000", "\000\000", 0, 0); + x2("Y\011\000?\000\000", "S\026\000\000", 0, 0); + x2("Y\011\000?\000\000", "Y\011\000\000", 0, 2); + x2("\221\317\000*\000\000", "\000\000", 0, 0); + x2("\221\317\000*\000\000", "\221\317\000\000", 0, 2); + x2("[P\000*\000\000", "[P[P[P\000\000", 0, 6); + x2("\231\254\000*\000\000", "\236\177\231\254\231\254\231\254\231\254\000\000", 0, 0); + n("\134q\000+\000\000", "\000\000"); + x2("l\263\000+\000\000", "l\263\000\000", 0, 2); + x2("fB\000+\000\000", "fBfBfBfB\000\000", 0, 8); + x2("0H\000+\000\000", "0H0H0F0F0F\000\000", 0, 4); + x2("0F\000+\000\000", "0J0F0F0F0F\000\000", 2, 10); + x2("\000.\000?\000\000", "0_\000\000", 0, 2); + x2("\000.\000*\000\000", "0q0t0w0z\000\000", 0, 8); + x2("\000.\000+\000\000", "0\215\000\000", 0, 2); + x2("\000.\000+\000\000", "0D0F0H0K\000\012\000\000", 0, 8); + x2("0B\000|0D\000\000", "0B\000\000", 0, 2); + x2("0B\000|0D\000\000", "0D\000\000", 0, 2); + x2("0B0D\000|0D0F\000\000", "0B0D\000\000", 0, 4); + x2("0B0D\000|0D0F\000\000", "0D0F\000\000", 0, 4); + x2("0\222\000(\000?\000:0K0M\000|0M0O\000)\000\000", "0\2220K0M\000\000", 0, 6); + x2("0\222\000(\000?\000:0K0M\000|0M0O\000)0Q\000\000", "0\2220M0O0Q\000\000", 0, 8); + x2("0B0D\000|\000(\000?\000:0B0F\000|0B0\222\000)\000\000", "0B0\222\000\000", 0, 4); + x2("0B\000|0D\000|0F\000\000", "0H0F\000\000", 2, 4); + x2("0B\000|0D\000|0F0H\000|0J0K0M\000|0O\000|0Q0S0U\000|0W0Y0[\000|0]\000|0_0a\000|0d0f0h0j0k\000|0l0m\000\000", "0W0Y0[\000\000", 0, 6); + n("0B\000|0D\000|0F0H\000|0J0K0M\000|0O\000|0Q0S0U\000|0W0Y0[\000|0]\000|0_0a\000|0d0f0h0j0k\000|0l0m\000\000", "0Y0[\000\000"); + x2("0B\000|\000^0\217\000\000", "0v0B\000\000", 2, 4); + x2("0B\000|\000^0\222\000\000", "0\2220B\000\000", 0, 2); + x2("\233<\000|\000\134\000G\216\312\000\000", "0Q\216\312\233<\000\000", 4, 6); + x2("\233<\000|\000\134\000G\216\312\000\000", "\216\312\233<\000\000", 0, 2); + x2("\233<\000|\000\134\000A\216\312\000\000", "\000b\216\312\233<\000\000", 4, 6); + x2("\233<\000|\000\134\000A\216\312\000\000", "\216\312\000\000", 0, 2); + x2("\233<\000|\216\312\000\134\000Z\000\000", "\216\312\233<\000\000", 2, 4); + x2("\233<\000|\216\312\000\134\000Z\000\000", "\216\312\000\000", 0, 2); + x2("\233<\000|\216\312\000\134\000Z\000\000", "\216\312\000\012\000\000", 0, 2); + x2("\233<\000|\216\312\000\134\000z\000\000", "\216\312\233<\000\000", 2, 4); + x2("\233<\000|\216\312\000\134\000z\000\000", "\216\312\000\000", 0, 2); + x2("\000\134\000w\000|\000\134\000s\000\000", "0J\000\000", 0, 2); + x2("\000\134\000w\000|\000%\000\000", "\000%0J\000\000", 0, 2); + x2("\000\134\000w\000|\000[\000&\000$\000]\000\000", "0F\000&\000\000", 0, 2); + x2("\000[0D\000-0Q\000]\000\000", "0F\000\000", 0, 2); + x2("\000[0D\000-0Q\000]\000|\000[\000^0K\000-0S\000]\000\000", "0B\000\000", 0, 2); + x2("\000[0D\000-0Q\000]\000|\000[\000^0K\000-0S\000]\000\000", "0K\000\000", 0, 2); + x2("\000[\000^0B\000]\000\000", "\000\012\000\000", 0, 2); + x2("\000(\000?\000:0B\000|\000[0F\000-0M\000]\000)\000|0D0\222\000\000", "0F0\222\000\000", 0, 2); + x2("\000(\000?\000:0B\000|\000[0F\000-0M\000]\000)\000|0D0\222\000\000", "0D0\222\000\000", 0, 4); + x2("0B0D0F\000|\000(\000?\000=0Q0Q\000)\000.\000.0{\000\000", "0Q0Q0{\000\000", 0, 6); + x2("0B0D0F\000|\000(\000?\000!0Q0Q\000)\000.\000.0{\000\000", "0B0D0{\000\000", 0, 6); + x2("\000(\000?\000=0\2220B\000)\000.\000.0B\000|\000(\000?\000=0\2220\222\000)\000.\000.0B\000\000", "0\2220\2220B\000\000", 0, 6); + x2("\000(\000?\000<\000=0B\000|0D0F\000)0D\000\000", "0D0F0D\000\000", 4, 6); + n("\000(\000?\000>0B\000|0B0D0H\000)0F\000\000", "0B0D0H0F\000\000"); + x2("\000(\000?\000>0B0D0H\000|0B\000)0F\000\000", "0B0D0H0F\000\000", 0, 8); + x2("0B\000?\000|0D\000\000", "0B\000\000", 0, 2); + x2("0B\000?\000|0D\000\000", "0D\000\000", 0, 0); + x2("0B\000?\000|0D\000\000", "\000\000", 0, 0); + x2("0B\000*\000|0D\000\000", "0B0B\000\000", 0, 4); + x2("0B\000*\000|0D\000*\000\000", "0D0B\000\000", 0, 0); + x2("0B\000*\000|0D\000*\000\000", "0B0D\000\000", 0, 2); + x2("\000[\000a0B\000]\000*\000|0D\000*\000\000", "\000a0B0D0D0D\000\000", 0, 4); + x2("0B\000+\000|0D\000*\000\000", "\000\000", 0, 0); + x2("0B\000+\000|0D\000*\000\000", "0D0D0D\000\000", 0, 6); + x2("0B\000+\000|0D\000*\000\000", "0B0D0D0D\000\000", 0, 2); + x2("0B\000+\000|0D\000*\000\000", "\000a0B0D0D0D\000\000", 0, 0); + n("0B\000+\000|0D\000+\000\000", "\000\000"); + x2("\000(0B\000|0D\000)\000?\000\000", "0D\000\000", 0, 2); + x2("\000(0B\000|0D\000)\000*\000\000", "0D0B\000\000", 0, 4); + x2("\000(0B\000|0D\000)\000+\000\000", "0D0B0D\000\000", 0, 6); + x2("\000(0B0D\000|0F0B\000)\000+\000\000", "0F0B0B0D0F0H\000\000", 0, 8); + x2("\000(0B0D\000|0F0H\000)\000+\000\000", "0F0B0B0D0F0H\000\000", 4, 12); + x2("\000(0B0D\000|0F0B\000)\000+\000\000", "0B0B0D0F0B\000\000", 2, 10); + x2("\000(0B0D\000|0F0B\000)\000+\000\000", "0B0D0\2220F0B\000\000", 0, 4); + x2("\000(0B0D\000|0F0B\000)\000+\000\000", "\000$\000$\000z\000z\000z\000z0B0D0\2220F0B\000\000", 12, 16); + x2("\000(0B\000|0D0B0D\000)\000+\000\000", "0B0D0B0D0B\000\000", 0, 10); + x2("\000(0B\000|0D0B0D\000)\000+\000\000", "0D0B\000\000", 2, 4); + x2("\000(0B\000|0D0B0D\000)\000+\000\000", "0D0B0B0B0D0B\000\000", 2, 8); + x2("\000(\000?\000:0B\000|0D\000)\000(\000?\000:0B\000|0D\000)\000\000", "0B0D\000\000", 0, 4); + x2("\000(\000?\000:0B\000*\000|0D\000*\000)\000(\000?\000:0B\000*\000|0D\000*\000)\000\000", "0B0B0B0D0D0D\000\000", 0, 6); + x2("\000(\000?\000:0B\000*\000|0D\000*\000)\000(\000?\000:0B\000+\000|0D\000+\000)\000\000", "0B0B0B0D0D0D\000\000", 0, 12); + x2("\000(\000?\000:0B\000+\000|0D\000+\000)\000{\0002\000}\000\000", "0B0B0B0D0D0D\000\000", 0, 12); + x2("\000(\000?\000:0B\000+\000|0D\000+\000)\000{\0001\000,\0002\000}\000\000", "0B0B0B0D0D0D\000\000", 0, 12); + x2("\000(\000?\000:0B\000+\000|\000\134\000A0D\000*\000)0F0F\000\000", "0F0F\000\000", 0, 4); + n("\000(\000?\000:0B\000+\000|\000\134\000A0D\000*\000)0F0F\000\000", "0B0D0F0F\000\000"); + x2("\000(\000?\000:\000^0B\000+\000|0D\000+\000)\000*0F\000\000", "0B0B0D0D0D0B0D0F\000\000", 12, 16); + x2("\000(\000?\000:\000^0B\000+\000|0D\000+\000)\000*0F\000\000", "0B0B0D0D0D0D0F\000\000", 0, 14); + x2("0F\000{\0000\000,\000}\000\000", "0F0F0F0F\000\000", 0, 8); + x2("0B\000|\000(\000?\000i\000)\000c\000\000", "\000C\000\000", 0, 2); + x2("\000(\000?\000i\000)\000c\000|0B\000\000", "\000C\000\000", 0, 2); + x2("\000(\000?\000i\000:0B\000)\000|\000a\000\000", "\000a\000\000", 0, 2); + n("\000(\000?\000i\000:0B\000)\000|\000a\000\000", "\000A\000\000"); + x2("\000[0B0D0F\000]\000?\000\000", "0B0D0F\000\000", 0, 2); + x2("\000[0B0D0F\000]\000*\000\000", "0B0D0F\000\000", 0, 6); + x2("\000[\000^0B0D0F\000]\000*\000\000", "0B0D0F\000\000", 0, 0); + n("\000[\000^0B0D0F\000]\000+\000\000", "0B0D0F\000\000"); + x2("0B\000?\000?\000\000", "0B0B0B\000\000", 0, 0); + x2("0D0B\000?\000?0D\000\000", "0D0B0D\000\000", 0, 6); + x2("0B\000*\000?\000\000", "0B0B0B\000\000", 0, 0); + x2("0D0B\000*\000?\000\000", "0D0B0B\000\000", 0, 2); + x2("0D0B\000*\000?0D\000\000", "0D0B0B0D\000\000", 0, 8); + x2("0B\000+\000?\000\000", "0B0B0B\000\000", 0, 2); + x2("0D0B\000+\000?\000\000", "0D0B0B\000\000", 0, 4); + x2("0D0B\000+\000?0D\000\000", "0D0B0B0D\000\000", 0, 8); + x2("\000(\000?\000:Y)\000?\000)\000?\000?\000\000", "Y)\000\000", 0, 0); + x2("\000(\000?\000:Y)\000?\000?\000)\000?\000\000", "Y)\000\000", 0, 0); + x2("\000(\000?\000:Y\042\000?\000)\000+\000?\000\000", "Y\042Y\042Y\042\000\000", 0, 2); + x2("\000(\000?\000:\230\250\000+\000)\000?\000?\000\000", "\230\250\230\250\230\250\000\000", 0, 0); + x2("\000(\000?\000:\226\352\000+\000)\000?\000?\227\034\000\000", "\226\352\226\352\226\352\227\034\000\000", 0, 8); + x2("\000(\000?\000:0B0D\000)\000?\000{\0002\000}\000\000", "\000\000", 0, 0); + x2("\000(\000?\000:\233<\216\312\000)\000?\000{\0002\000}\000\000", "\233<\216\312\233<\216\312\233<\000\000", 0, 8); + x2("\000(\000?\000:\233<\216\312\000)\000*\000{\0000\000}\000\000", "\233<\216\312\233<\216\312\233<\000\000", 0, 0); + x2("\000(\000?\000:\233<\216\312\000)\000{\0003\000,\000}\000\000", "\233<\216\312\233<\216\312\233<\216\312\233<\216\312\000\000", 0, 16); + n("\000(\000?\000:\233<\216\312\000)\000{\0003\000,\000}\000\000", "\233<\216\312\233<\216\312\000\000"); + x2("\000(\000?\000:\233<\216\312\000)\000{\0002\000,\0004\000}\000\000", "\233<\216\312\233<\216\312\233<\216\312\000\000", 0, 12); + x2("\000(\000?\000:\233<\216\312\000)\000{\0002\000,\0004\000}\000\000", "\233<\216\312\233<\216\312\233<\216\312\233<\216\312\233<\216\312\000\000", 0, 16); + x2("\000(\000?\000:\233<\216\312\000)\000{\0002\000,\0004\000}\000?\000\000", "\233<\216\312\233<\216\312\233<\216\312\233<\216\312\233<\216\312\000\000", 0, 8); + x2("\000(\000?\000:\233<\216\312\000)\000{\000,\000}\000\000", "\233<\216\312\000{\000,\000}\000\000", 0, 10); + x2("\000(\000?\000:0K0M0O\000)\000+\000?\000{\0002\000}\000\000", "0K0M0O0K0M0O0K0M0O\000\000", 0, 12); + x3("\000(pk\000)\000\000", "pk\000\000", 0, 2, 1); + x3("\000(pkl4\000)\000\000", "pkl4\000\000", 0, 4, 1); + x2("\000(\000(fB\225\223\000)\000)\000\000", "fB\225\223\000\000", 0, 4); + x3("\000(\000(\230\250l4\000)\000)\000\000", "\230\250l4\000\000", 0, 4, 1); + x3("\000(\000(f(e\345\000)\000)\000\000", "f(e\345\000\000", 0, 4, 2); + x3("\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\000(\221\317[P\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000)\000\000", "\221\317[P\000\000", 0, 4, 20); + x3("\000(0B0D\000)\000(0F0H\000)\000\000", "0B0D0F0H\000\000", 0, 4, 1); + x3("\000(0B0D\000)\000(0F0H\000)\000\000", "0B0D0F0H\000\000", 4, 8, 2); + x3("\000(\000)\000(0B\000)0D0F\000(0H0J0K\000)0M0O0Q0S\000\000", "0B0D0F0H0J0K0M0O0Q0S\000\000", 6, 12, 3); + x3("\000(\000(\000)\000(0B\000)0D0F\000(0H0J0K\000)0M0O0Q0S\000)\000\000", "0B0D0F0H0J0K0M0O0Q0S\000\000", 6, 12, 4); + x3("\000.\000*\000(0\3250\251\000)0\3630\3730\336\000(0\363\000(\000)0\2670\3450\277\000)0\2440\363\000\000", "0\3250\2510\3630\3730\3360\3630\2670\3450\2770\2440\363\000\000", 10, 18, 2); + x2("\000(\000^0B\000)\000\000", "0B\000\000", 0, 2); + x3("\000(0B\000)\000|\000(0B\000)\000\000", "0D0B\000\000", 2, 4, 1); + x3("\000(\000^0B\000)\000|\000(0B\000)\000\000", "0D0B\000\000", 2, 4, 2); + x3("\000(0B\000?\000)\000\000", "0B0B0B\000\000", 0, 2, 1); + x3("\000(0~\000*\000)\000\000", "0~0~0~\000\000", 0, 6, 1); + x3("\000(0h\000*\000)\000\000", "\000\000", 0, 0, 1); + x3("\000(0\213\000+\000)\000\000", "0\2130\2130\2130\2130\2130\2130\213\000\000", 0, 14, 1); + x3("\000(0u\000+\000|0x\000*\000)\000\000", "0u0u0u0x0x\000\000", 0, 6, 1); + x3("\000(0B\000+\000|0D\000?\000)\000\000", "0D0D0D0B0B\000\000", 0, 2, 1); + x3("\000(0B0D0F\000)\000?\000\000", "0B0D0F\000\000", 0, 6, 1); + x3("\000(0B0D0F\000)\000*\000\000", "0B0D0F\000\000", 0, 6, 1); + x3("\000(0B0D0F\000)\000+\000\000", "0B0D0F\000\000", 0, 6, 1); + x3("\000(0U0W0Y\000|0B0D0F\000)\000+\000\000", "0B0D0F\000\000", 0, 6, 1); + x3("\000(\000[0j0k0l\000]\000[0K0M0O\000]\000|0K0M0O\000)\000+\000\000", "0K0M0O\000\000", 0, 6, 1); + x3("\000(\000(\000?\000i\000:0B0D0F\000)\000)\000\000", "0B0D0F\000\000", 0, 6, 1); + x3("\000(\000(\000?\000m\000:0B\000.0F\000)\000)\000\000", "0B\000\0120F\000\000", 0, 6, 1); + x3("\000(\000(\000?\000=0B0\223\000)0B\000)\000\000", "0B0\2230D\000\000", 0, 2, 1); + x3("0B0D0F\000|\000(\000.0B0D0H\000)\000\000", "0\2230B0D0H\000\000", 0, 8, 1); + x3("0B\000*\000(\000.\000)\000\000", "0B0B0B0B0\223\000\000", 8, 10, 1); + x3("0B\000*\000?\000(\000.\000)\000\000", "0B0B0B0B0\223\000\000", 0, 2, 1); + x3("0B\000*\000?\000(0\223\000)\000\000", "0B0B0B0B0\223\000\000", 8, 10, 1); + x3("\000[0D0F0H\000]0B\000*\000(\000.\000)\000\000", "0H0B0B0B0B0\223\000\000", 10, 12, 1); + x3("\000(\000\134\000A0D0D\000)0F0F\000\000", "0D0D0F0F\000\000", 0, 4, 1); + n("\000(\000\134\000A0D0D\000)0F0F\000\000", "0\2230D0D0F0F\000\000"); + x3("\000(\000^0D0D\000)0F0F\000\000", "0D0D0F0F\000\000", 0, 4, 1); + n("\000(\000^0D0D\000)0F0F\000\000", "0\2230D0D0F0F\000\000"); + x3("0\2150\215\000(0\2130\213\000$\000)\000\000", "0\2150\2150\2130\213\000\000", 4, 8, 1); + n("0\2150\215\000(0\2130\213\000$\000)\000\000", "0\2150\2150\2130\2130\213\000\000"); + x2("\000(q!\000)\000\134\0001\000\000", "q!q!\000\000", 0, 4); + n("\000(q!\000)\000\134\0001\000\000", "q!kf\000\000"); + x2("\000(zz\000?\000)\000\134\0001\000\000", "zzzz\000\000", 0, 4); + x2("\000(zz\000?\000?\000)\000\134\0001\000\000", "zzzz\000\000", 0, 0); + x2("\000(zz\000*\000)\000\134\0001\000\000", "zzzzzzzzzz\000\000", 0, 8); + x3("\000(zz\000*\000)\000\134\0001\000\000", "zzzzzzzzzz\000\000", 0, 4, 1); + x2("0B\000(0D\000*\000)\000\134\0001\000\000", "0B0D0D0D0D\000\000", 0, 10); + x2("0B\000(0D\000*\000)\000\134\0001\000\000", "0B0D\000\000", 0, 2); + x2("\000(0B\000*\000)\000(0D\000*\000)\000\134\0001\000\134\0002\000\000", "0B0B0B0D0D0B0B0B0D0D\000\000", 0, 20); + x2("\000(0B\000*\000)\000(0D\000*\000)\000\134\0002\000\000", "0B0B0B0D0D0D0D\000\000", 0, 14); + x3("\000(0B\000*\000)\000(0D\000*\000)\000\134\0002\000\000", "0B0B0B0D0D0D0D\000\000", 6, 10, 2); + x2("\000(\000(\000(\000(\000(\000(\000(0}\000*\000)0z\000)\000)\000)\000)\000)\000)0t\000\134\0007\000\000", "0}0}0}0z0t0}0}0}\000\000", 0, 16); + x3("\000(\000(\000(\000(\000(\000(\000(0}\000*\000)0z\000)\000)\000)\000)\000)\000)0t\000\134\0007\000\000", "0}0}0}0z0t0}0}0}\000\000", 0, 6, 7); + x2("\000(0o\000)\000(0r\000)\000(0u\000)\000\134\0002\000\134\0001\000\134\0003\000\000", "0o0r0u0r0o0u\000\000", 0, 12); + x2("\000(\000[0M\000-0Q\000]\000)\000\134\0001\000\000", "0O0O\000\000", 0, 4); + x2("\000(\000\134\000w\000\134\000d\000\134\000s\000)\000\134\0001\000\000", "0B\0005\000 0B\0005\000 \000\000", 0, 12); + n("\000(\000\134\000w\000\134\000d\000\134\000s\000)\000\134\0001\000\000", "0B\0005\000 0B\0005\000\000"); + x2("\000(\212\260\377\037\000|\000[0B\000-0F\000]\000{\0003\000}\000)\000\134\0001\000\000", "\212\260\377\037\212\260\377\037\000\000", 0, 8); + x2("\000.\000.\000.\000(\212\260\377\037\000|\000[0B\000-0F\000]\000{\0003\000}\000)\000\134\0001\000\000", "0B\000a0B\212\260\377\037\212\260\377\037\000\000", 0, 14); + x2("\000(\212\260\377\037\000|\000[0B\000-0F\000]\000{\0003\000}\000)\000\134\0001\000\000", "0F0D0F0F0D0F\000\000", 0, 12); + x2("\000(\000^0S\000)\000\134\0001\000\000", "0S0S\000\000", 0, 4); + n("\000(\000^0\200\000)\000\134\0001\000\000", "0\2010\2000\200\000\000"); + n("\000(0B\000$\000)\000\134\0001\000\000", "0B0B\000\000"); + n("\000(0B0D\000\134\000Z\000)\000\134\0001\000\000", "0B0D\000\000"); + x2("\000(0B\000*\000\134\000Z\000)\000\134\0001\000\000", "0B\000\000", 2, 2); + x2("\000.\000(0B\000*\000\134\000Z\000)\000\134\0001\000\000", "0D0B\000\000", 2, 4); + x3("\000(\000.\000(0\2040D0\206\000)\000\134\0002\000)\000\000", "\000z0\2040D0\2060\2040D0\206\000\000", 0, 14, 1); + x3("\000(\000.\000(\000.\000.\000\134\000d\000.\000)\000\134\0002\000)\000\000", "0B\0001\0002\0003\0004\0001\0002\0003\0004\000\000", 0, 18, 1); + x2("\000(\000(\000?\000i\000:0B\000v0Z\000)\000)\000\134\0001\000\000", "0B\000v0Z0B\000v0Z\000\000", 0, 12); + x2("\000(\000?\000Y\011\000|\000\134\000(\000\134\000g\000\000\134\000)\000)\000\000", "\000(\000(\000(\000(\000(\000(Y\011\000)\000)\000)\000)\000)\000)\000\000", 0, 26); + x2("\000\134\000A\000(\000?\000:\000\134\000g\000<\226?\000_\0001\000>\000|\000\134\000g\000\000|\000\134\000z}BN\206\000 \000 \000(\000?\000<\226?\000_\0001\000>\211\263\000|\201\352\000\134\000g\000\201\352\000)\000(\000?\000W(\000|\203\351\205\251\000\134\000g\000<\226?\000_\0001\000>\203\351\205\251\000)\000)\000$\000\000", "\203\351\205\251\201\352\203\351\205\251\201\352W(\201\352\203\351\205\251\201\352\203\351\205\251\000\000", 0, 26); + x2("\000[\000[0r0u\000]\000]\000\000", "0u\000\000", 0, 2); + x2("\000[\000[0D0J0F\000]0K\000]\000\000", "0K\000\000", 0, 2); + n("\000[\000[\000^0B\000]\000]\000\000", "0B\000\000"); + n("\000[\000^\000[0B\000]\000]\000\000", "0B\000\000"); + x2("\000[\000^\000[\000^0B\000]\000]\000\000", "0B\000\000", 0, 2); + x2("\000[\000[0K0M0O\000]\000&\000&0M0O\000]\000\000", "0O\000\000", 0, 2); + n("\000[\000[0K0M0O\000]\000&\000&0M0O\000]\000\000", "0K\000\000"); + n("\000[\000[0K0M0O\000]\000&\000&0M0O\000]\000\000", "0Q\000\000"); + x2("\000[0B\000-0\223\000&\000&0D\000-0\222\000&\000&0F\000-0\221\000]\000\000", "0\221\000\000", 0, 2); + n("\000[\000^0B\000-0\223\000&\000&0D\000-0\222\000&\000&0F\000-0\221\000]\000\000", "0\221\000\000"); + x2("\000[\000[\000^0B\000&\000&0B\000]\000&\000&0B\000-0\223\000]\000\000", "0D\000\000", 0, 2); + n("\000[\000[\000^0B\000&\000&0B\000]\000&\000&0B\000-0\223\000]\000\000", "0B\000\000"); + x2("\000[\000[\000^0B\000-0\223\000&\000&0D0F0H0J\000]\000&\000&\000[\000^0F\000-0K\000]\000]\000\000", "0M\000\000", 0, 2); + n("\000[\000[\000^0B\000-0\223\000&\000&0D0F0H0J\000]\000&\000&\000[\000^0F\000-0K\000]\000]\000\000", "0D\000\000"); + x2("\000[\000^\000[\000^0B0D0F\000]\000&\000&\000[\000^0F0H0J\000]\000]\000\000", "0F\000\000", 0, 2); + x2("\000[\000^\000[\000^0B0D0F\000]\000&\000&\000[\000^0F0H0J\000]\000]\000\000", "0H\000\000", 0, 2); + n("\000[\000^\000[\000^0B0D0F\000]\000&\000&\000[\000^0F0H0J\000]\000]\000\000", "0K\000\000"); + x2("\000[0B\000-\000&\000&\000-0B\000]\000\000", "\000-\000\000", 0, 2); + x2("\000[\000^\000[\000^\000a\000-\000z0B0D0F\000]\000&\000&\000[\000^\000b\000c\000d\000e\000f\000g0F0H0J\000]\000q\000-\000w\000]\000\000", "0H\000\000", 0, 2); + x2("\000[\000^\000[\000^\000a\000-\000z0B0D0F\000]\000&\000&\000[\000^\000b\000c\000d\000e\000f\000g0F0H0J\000]\000g\000-\000w\000]\000\000", "\000f\000\000", 0, 2); + x2("\000[\000^\000[\000^\000a\000-\000z0B0D0F\000]\000&\000&\000[\000^\000b\000c\000d\000e\000f\000g0F0H0J\000]\000g\000-\000w\000]\000\000", "\000g\000\000", 0, 2); + n("\000[\000^\000[\000^\000a\000-\000z0B0D0F\000]\000&\000&\000[\000^\000b\000c\000d\000e\000f\000g0F0H0J\000]\000g\000-\000w\000]\000\000", "\0002\000\000"); + x2("\000a\000<\000b\000>0\3200\3740\2700\3470\3630n0\3000\2460\3630\3550\3740\311\000<\000\134\000/\000b\000>\000\000", "\000a\000<\000b\000>0\3200\3740\2700\3470\3630n0\3000\2460\3630\3550\3740\311\000<\000/\000b\000>\000\000", 0, 40); + x2("\000.\000<\000b\000>0\3200\3740\2700\3470\3630n0\3000\2460\3630\3550\3740\311\000<\000\134\000/\000b\000>\000\000", "\000a\000<\000b\000>0\3200\3740\2700\3470\3630n0\3000\2460\3630\3550\3740\311\000<\000/\000b\000>\000\000", 0, 40); + fprintf(stdout, + "\nRESULT SUCC: %d, FAIL: %d, ERROR: %d (by Oniguruma %s)\n", + nsucc, nfail, nerror, onig_version()); + +#ifndef POSIX_TEST + onig_region_free(region, 1); + onig_end(); +#endif + + return ((nfail == 0 && nerror == 0) ? 0 : -1); +} diff --git a/ext/mbstring/oniguruma/win32/Makefile b/ext/mbstring/oniguruma/win32/Makefile new file mode 100644 index 0000000000000..d08722baa9c3f --- /dev/null +++ b/ext/mbstring/oniguruma/win32/Makefile @@ -0,0 +1,200 @@ +# Oniguruma Makefile for Win32 + +product_name = oniguruma + +CPPFLAGS = +CFLAGS = -O2 -nologo /W3 +LDFLAGS = +LOADLIBES = +ARLIB = lib +ARLIB_FLAGS = -nologo +ARDLL = cl +ARDLL_FLAGS = -nologo -LD $(LINKFLAGS) -dll +LINKFLAGS = -link -incremental:no -pdb:none + +INSTALL = install -c +CP = copy +CC = cl +DEFS = -DHAVE_CONFIG_H -DNOT_RUBY -DEXPORT +RUBYDIR = .. + +subdirs = + +libbase = onig +libname = $(libbase)_s.lib +dllname = $(libbase).dll +dlllib = $(libbase).lib + +onigheaders = oniguruma.h regint.h regparse.h regenc.h st.h +posixheaders = onigposix.h +headers = $(posixheaders) $(onigheaders) + +onigobjs = reggnu.obj regerror.obj regparse.obj regext.obj regcomp.obj \ + regexec.obj regenc.obj regsyntax.obj regtrav.obj \ + regversion.obj st.obj +posixobjs = regposix.obj regposerr.obj +libobjs = $(onigobjs) $(posixobjs) + +jp_objs = $(encdir)\euc_jp.obj $(encdir)\sjis.obj +iso8859_objs = $(encdir)\iso8859_1.obj $(encdir)\iso8859_2.obj \ + $(encdir)\iso8859_3.obj $(encdir)\iso8859_4.obj \ + $(encdir)\iso8859_5.obj $(encdir)\iso8859_6.obj \ + $(encdir)\iso8859_7.obj $(encdir)\iso8859_8.obj \ + $(encdir)\iso8859_9.obj $(encdir)\iso8859_10.obj \ + $(encdir)\iso8859_11.obj $(encdir)\iso8859_13.obj \ + $(encdir)\iso8859_14.obj $(encdir)\iso8859_15.obj \ + $(encdir)\iso8859_16.obj + +encobjs = $(encdir)\ascii.obj $(encdir)\utf8.obj \ + $(encdir)\unicode.obj \ + $(encdir)\utf16_be.obj $(encdir)\utf16_le.obj \ + $(encdir)\utf32_be.obj $(encdir)\utf32_le.obj \ + $(jp_objs) $(iso8859_objs) \ + $(encdir)\euc_tw.obj $(encdir)\euc_kr.obj $(encdir)\big5.obj \ + $(encdir)\gb18030.obj \ + $(encdir)\koi8_r.obj \ + $(encdir)\cp1251.obj # $(encdir)\koi8.obj + +onigsources = regerror.c regparse.c regext.c regcomp.c regexec.c regenc.c \ + regsyntax.c regtrav.c regversion.c reggnu.c st.c +posixsources = regposix.c regposerr.c +libsources = $(posixsources) $(onigsources) +rubysources = $(onigsources) + +encdir = enc +patchfiles = re.c.168.patch re.c.181.patch +distfiles = README COPYING HISTORY \ + Makefile.in configure.in config.h.in configure \ + $(headers) $(libsources) $(patchfiles) \ + test.rb testconv.rb +testc = testc +testp = testp + +makeargs = $(MFLAGS) CPPFLAGS='$(CPPFLAGS)' CFLAGS='$(CFLAGS)' CC='$(CC)' + +.SUFFIXES: +.SUFFIXES: .obj .c .h .ps .dvi .info .texinfo + +.c.obj: + $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) /I. /I.. /Fo$@ /c $< + +# targets +default: all + +setup: + $(CP) win32\config.h config.h + $(CP) win32\testc.c testc.c + + +all: $(libname) $(dllname) + +$(libname): $(libobjs) $(encobjs) + $(ARLIB) $(ARLIB_FLAGS) -out:$@ $(libobjs) $(encobjs) + +$(dllname): $(libobjs) $(encobjs) + $(ARDLL) $(libobjs) $(encobjs) -Fe$@ $(ARDLL_FLAGS) + +regparse.obj: regparse.c $(onigheaders) config.h st.h +regext.obj: regext.c $(onigheaders) config.h +regtrav.obj: regtrav.c $(onigheaders) config.h +regcomp.obj: regcomp.c $(onigheaders) config.h +regexec.obj: regexec.c regint.h regenc.h oniguruma.h config.h +reggnu.obj: reggnu.c regint.h regenc.h oniguruma.h config.h oniggnu.h +regerror.obj: regerror.c regint.h regenc.h oniguruma.h config.h +regenc.obj: regenc.c regenc.h oniguruma.h config.h +regsyntax.obj: regsyntax.c regint.h regenc.h oniguruma.h config.h +regversion.obj: regversion.c oniguruma.h config.h +regposix.obj: regposix.c $(posixheaders) oniguruma.h config.h +regposerr.obj: regposerr.c $(posixheaders) config.h +st.obj: st.c regint.h oniguruma.h config.h st.h + +$(encdir)\ascii.obj: $(encdir)\ascii.c regenc.h config.h +$(encdir)\unicode.obj: $(encdir)\unicode.c regenc.h config.h +$(encdir)\utf8.obj: $(encdir)\utf8.c regenc.h config.h +$(encdir)\utf16_be.obj: $(encdir)\utf16_be.c regenc.h config.h +$(encdir)\utf16_le.obj: $(encdir)\utf16_le.c regenc.h config.h +$(encdir)\utf32_be.obj: $(encdir)\utf32_be.c regenc.h config.h +$(encdir)\utf32_le.obj: $(encdir)\utf32_le.c regenc.h config.h +$(encdir)\euc_jp.obj: $(encdir)\euc_jp.c regenc.h config.h +$(encdir)\euc_tw.obj: $(encdir)\euc_tw.c regenc.h config.h +$(encdir)\euc_kr.obj: $(encdir)\euc_kr.c regenc.h config.h +$(encdir)\sjis.obj: $(encdir)\sjis.c regenc.h config.h +$(encdir)\iso8859_1.obj: $(encdir)\iso8859_1.c regenc.h config.h +$(encdir)\iso8859_2.obj: $(encdir)\iso8859_2.c regenc.h config.h +$(encdir)\iso8859_3.obj: $(encdir)\iso8859_3.c regenc.h config.h +$(encdir)\iso8859_4.obj: $(encdir)\iso8859_4.c regenc.h config.h +$(encdir)\iso8859_5.obj: $(encdir)\iso8859_5.c regenc.h config.h +$(encdir)\iso8859_6.obj: $(encdir)\iso8859_6.c regenc.h config.h +$(encdir)\iso8859_7.obj: $(encdir)\iso8859_7.c regenc.h config.h +$(encdir)\iso8859_8.obj: $(encdir)\iso8859_8.c regenc.h config.h +$(encdir)\iso8859_9.obj: $(encdir)\iso8859_9.c regenc.h config.h +$(encdir)\iso8859_10.obj: $(encdir)\iso8859_10.c regenc.h config.h +$(encdir)\iso8859_11.obj: $(encdir)\iso8859_11.c regenc.h config.h +$(encdir)\iso8859_13.obj: $(encdir)\iso8859_13.c regenc.h config.h +$(encdir)\iso8859_14.obj: $(encdir)\iso8859_14.c regenc.h config.h +$(encdir)\iso8859_15.obj: $(encdir)\iso8859_15.c regenc.h config.h +$(encdir)\iso8859_16.obj: $(encdir)\iso8859_16.c regenc.h config.h +$(encdir)\koi8.obj: $(encdir)\koi8.c regenc.h config.h +$(encdir)\koi8_r.obj: $(encdir)\koi8_r.c regenc.h config.h +$(encdir)\cp1251.obj: $(encdir)\cp1251.c regenc.h config.h +$(encdir)\big5.obj: $(encdir)\big5.c regenc.h config.h +$(encdir)\gb18030.obj: $(encdir)\gb18030.c regenc.h config.h + + +# Ruby test +rtest: + $(RUBYDIR)\win32\ruby -w -Ke test.rb + +# C library test +ctest: $(testc) + .\$(testc) + +# POSIX C library test +ptest: $(testp) + .\$(testp) + +$(testc): $(testc).c $(libname) + $(CC) -nologo -o $(testc) -DONIG_EXTERN=extern $(testc).c $(libname) + +$(testp): $(testc).c $(dlllib) + $(CC) -nologo -DPOSIX_TEST -o $(testp) $(testc).c $(dlllib) + +#$(testc)u.c: test.rb testconvu.rb +# ruby -Ke testconvu.rb test.rb > $@ + +$(testc)u: $(testc)u.c $(libname) + $(CC) -nologo -o $(testc)u -DONIG_EXTERN=extern $(testc)u.c $(libname) + +clean: + del *.obj $(encdir)\*.obj *.lib *.exp *.dll $(testp).exe $(testc).exe $(testc).obj + + +# backup file suffix +SORIG = ruby_orig + +# ruby 1.9 source update +19: + $(CP) regerror.c $(RUBYDIR) + $(CP) regparse.c $(RUBYDIR) + $(CP) regcomp.c $(RUBYDIR) + $(CP) regexec.c $(RUBYDIR) + $(CP) regenc.c $(RUBYDIR) + $(CP) regint.h $(RUBYDIR) + $(CP) regparse.h $(RUBYDIR) + $(CP) regenc.h $(RUBYDIR) + $(CP) oniguruma.h $(RUBYDIR) + $(CP) enc\ascii.c $(RUBYDIR) + $(CP) enc\utf8.c $(RUBYDIR) + $(CP) enc\euc_jp.c $(RUBYDIR) + $(CP) enc\sjis.c $(RUBYDIR) + $(CP) enc\unicode.c $(RUBYDIR) + + +samples: all + $(CC) $(CFLAGS) -I. -o simple sample\simple.c $(dlllib) + $(CC) $(CFLAGS) -I. -o posix sample\posix.c $(dlllib) + $(CC) $(CFLAGS) -I. -o names sample\names.c $(dlllib) + $(CC) $(CFLAGS) -I. -o listcap sample\listcap.c $(dlllib) + $(CC) $(CFLAGS) -I. -o sql sample\sql.c $(dlllib) + $(CC) $(CFLAGS) -I. -o encode sample\encode.c $(dlllib) + $(CC) $(CFLAGS) -I. -o syntax sample\syntax.c $(dlllib) diff --git a/ext/mbstring/oniguruma/win32/testc.c b/ext/mbstring/oniguruma/win32/testc.c new file mode 100644 index 0000000000000..acc13189d5a96 --- /dev/null +++ b/ext/mbstring/oniguruma/win32/testc.c @@ -0,0 +1,863 @@ +/* + * This program was generated by testconv.rb. + */ +#include "config.h" +#ifdef ONIG_ESCAPE_UCHAR_COLLISION +#undef ONIG_ESCAPE_UCHAR_COLLISION +#endif +#include + +#ifdef POSIX_TEST +#include "onigposix.h" +#else +#include "oniguruma.h" +#endif + +#ifdef HAVE_STRING_H +# include +#else +# include +#endif + +#define SLEN(s) strlen(s) + +static int nsucc = 0; +static int nfail = 0; +static int nerror = 0; + +static FILE* err_file; + +#ifndef POSIX_TEST +static OnigRegion* region; +#endif + +static void xx(char* pattern, char* str, int from, int to, int mem, int not) +{ + int r; + +#ifdef POSIX_TEST + regex_t reg; + char buf[200]; + regmatch_t pmatch[25]; + + r = regcomp(®, pattern, REG_EXTENDED | REG_NEWLINE); + if (r) { + regerror(r, ®, buf, sizeof(buf)); + fprintf(err_file, "ERROR: %s\n", buf); + nerror++; + return ; + } + + r = regexec(®, str, reg.re_nsub + 1, pmatch, 0); + if (r != 0 && r != REG_NOMATCH) { + regerror(r, ®, buf, sizeof(buf)); + fprintf(err_file, "ERROR: %s\n", buf); + nerror++; + return ; + } + + if (r == REG_NOMATCH) { + if (not) { + fprintf(stdout, "OK(N): /%s/ '%s'\n", pattern, str); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s'\n", pattern, str); + nfail++; + } + } + else { + if (not) { + fprintf(stdout, "FAIL(N): /%s/ '%s'\n", pattern, str); + nfail++; + } + else { + if (pmatch[mem].rm_so == from && pmatch[mem].rm_eo == to) { + fprintf(stdout, "OK: /%s/ '%s'\n", pattern, str); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d\n", pattern, str, + from, to, pmatch[mem].rm_so, pmatch[mem].rm_eo); + nfail++; + } + } + } + regfree(®); + +#else + regex_t* reg; + OnigErrorInfo einfo; + + r = onig_new(®, (UChar* )pattern, (UChar* )(pattern + SLEN(pattern)), + ONIG_OPTION_DEFAULT, ONIG_ENCODING_SJIS, ONIG_SYNTAX_DEFAULT, &einfo); + if (r) { + char s[ONIG_MAX_ERROR_MESSAGE_LEN]; + onig_error_code_to_str((UChar* )s, r, &einfo); + fprintf(err_file, "ERROR: %s\n", s); + nerror++; + return ; + } + + r = onig_search(reg, (UChar* )str, (UChar* )(str + SLEN(str)), + (UChar* )str, (UChar* )(str + SLEN(str)), + region, ONIG_OPTION_NONE); + if (r < ONIG_MISMATCH) { + char s[ONIG_MAX_ERROR_MESSAGE_LEN]; + onig_error_code_to_str((UChar* )s, r); + fprintf(err_file, "ERROR: %s\n", s); + nerror++; + return ; + } + + if (r == ONIG_MISMATCH) { + if (not) { + fprintf(stdout, "OK(N): /%s/ '%s'\n", pattern, str); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s'\n", pattern, str); + nfail++; + } + } + else { + if (not) { + fprintf(stdout, "FAIL(N): /%s/ '%s'\n", pattern, str); + nfail++; + } + else { + if (region->beg[mem] == from && region->end[mem] == to) { + fprintf(stdout, "OK: /%s/ '%s'\n", pattern, str); + nsucc++; + } + else { + fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d\n", pattern, str, + from, to, region->beg[mem], region->end[mem]); + nfail++; + } + } + } + onig_free(reg); +#endif +} + +static void x2(char* pattern, char* str, int from, int to) +{ + xx(pattern, str, from, to, 0, 0); +} + +static void x3(char* pattern, char* str, int from, int to, int mem) +{ + xx(pattern, str, from, to, mem, 0); +} + +static void n(char* pattern, char* str) +{ + xx(pattern, str, 0, 0, 0, 1); +} + +extern int main(int argc, char* argv[]) +{ + err_file = stdout; + +#ifdef POSIX_TEST + reg_set_encoding(REG_POSIX_ENCODING_SJIS); +#else + region = onig_region_new(); +#endif + + x2("", "", 0, 0); + x2("^", "", 0, 0); + x2("$", "", 0, 0); + x2("\\G", "", 0, 0); + x2("\\A", "", 0, 0); + x2("\\Z", "", 0, 0); + x2("\\z", "", 0, 0); + x2("^$", "", 0, 0); + x2("\\ca", "\001", 0, 1); + x2("\\C-b", "\002", 0, 1); + x2("\\c\\\\", "\034", 0, 1); + x2("q[\\c\\\\]", "q\034", 0, 2); + x2("", "a", 0, 0); + x2("a", "a", 0, 1); + x2("\\x61", "a", 0, 1); + x2("aa", "aa", 0, 2); + x2("aaa", "aaa", 0, 3); + x2("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0, 35); + x2("ab", "ab", 0, 2); + x2("b", "ab", 1, 2); + x2("bc", "abc", 1, 3); + x2("(?i:#RET#)", "#INS##RET#", 5, 10); + x2("\\17", "\017", 0, 1); + x2("\\x1f", "\x1f", 0, 1); + x2("a(?#....\\\\JJJJ)b", "ab", 0, 2); + x2("(?x) G (o O(?-x)oO) g L", "GoOoOgLe", 0, 7); + x2(".", "a", 0, 1); + n(".", ""); + x2("..", "ab", 0, 2); + x2("\\w", "e", 0, 1); + n("\\W", "e"); + x2("\\s", " ", 0, 1); + x2("\\S", "b", 0, 1); + x2("\\d", "4", 0, 1); + n("\\D", "4"); + x2("\\b", "z ", 0, 0); + x2("\\b", " z", 1, 1); + x2("\\B", "zz ", 1, 1); + x2("\\B", "z ", 2, 2); + x2("\\B", " z", 0, 0); + x2("[ab]", "b", 0, 1); + n("[ab]", "c"); + x2("[a-z]", "t", 0, 1); + n("[^a]", "a"); + x2("[^a]", "\n", 0, 1); + x2("[]]", "]", 0, 1); + n("[^]]", "]"); + x2("[\\^]+", "0^^1", 1, 3); + x2("[b-]", "b", 0, 1); + x2("[b-]", "-", 0, 1); + x2("[\\w]", "z", 0, 1); + n("[\\w]", " "); + x2("[\\W]", "b$", 1, 2); + x2("[\\d]", "5", 0, 1); + n("[\\d]", "e"); + x2("[\\D]", "t", 0, 1); + n("[\\D]", "3"); + x2("[\\s]", " ", 0, 1); + n("[\\s]", "a"); + x2("[\\S]", "b", 0, 1); + n("[\\S]", " "); + x2("[\\w\\d]", "2", 0, 1); + n("[\\w\\d]", " "); + x2("[[:upper:]]", "B", 0, 1); + x2("[*[:xdigit:]+]", "+", 0, 1); + x2("[*[:xdigit:]+]", "GHIKK-9+*", 6, 7); + x2("[*[:xdigit:]+]", "-@^+", 3, 4); + n("[[:upper]]", "A"); + x2("[[:upper]]", ":", 0, 1); + x2("[\\044-\\047]", "\046", 0, 1); + x2("[\\x5a-\\x5c]", "\x5b", 0, 1); + x2("[\\x6A-\\x6D]", "\x6c", 0, 1); + n("[\\x6A-\\x6D]", "\x6E"); + n("^[0-9A-F]+ 0+ UNDEF ", "75F 00000000 SECT14A notype () External | _rb_apply"); + x2("[\\[]", "[", 0, 1); + x2("[\\]]", "]", 0, 1); + x2("[&]", "&", 0, 1); + x2("[[ab]]", "b", 0, 1); + x2("[[ab]c]", "c", 0, 1); + n("[[^a]]", "a"); + n("[^[a]]", "a"); + x2("[[ab]&&bc]", "b", 0, 1); + n("[[ab]&&bc]", "a"); + n("[[ab]&&bc]", "c"); + x2("[a-z&&b-y&&c-x]", "w", 0, 1); + n("[^a-z&&b-y&&c-x]", "w"); + x2("[[^a&&a]&&a-z]", "b", 0, 1); + n("[[^a&&a]&&a-z]", "a"); + x2("[[^a-z&&bcdef]&&[^c-g]]", "h", 0, 1); + n("[[^a-z&&bcdef]&&[^c-g]]", "c"); + x2("[^[^abc]&&[^cde]]", "c", 0, 1); + x2("[^[^abc]&&[^cde]]", "e", 0, 1); + n("[^[^abc]&&[^cde]]", "f"); + x2("[a-&&-a]", "-", 0, 1); + n("[a\\-&&\\-a]", "&"); + n("\\wabc", " abc"); + x2("a\\Wbc", "a bc", 0, 4); + x2("a.b.c", "aabbc", 0, 5); + x2(".\\wb\\W..c", "abb bcc", 0, 7); + x2("\\s\\wzzz", " zzzz", 0, 5); + x2("aa.b", "aabb", 0, 4); + n(".a", "ab"); + x2(".a", "aa", 0, 2); + x2("^a", "a", 0, 1); + x2("^a$", "a", 0, 1); + x2("^\\w$", "a", 0, 1); + n("^\\w$", " "); + x2("^\\wab$", "zab", 0, 3); + x2("^\\wabcdef$", "zabcdef", 0, 7); + x2("^\\w...def$", "zabcdef", 0, 7); + x2("\\w\\w\\s\\Waaa\\d", "aa aaa4", 0, 8); + x2("\\A\\Z", "", 0, 0); + x2("\\Axyz", "xyz", 0, 3); + x2("xyz\\Z", "xyz", 0, 3); + x2("xyz\\z", "xyz", 0, 3); + x2("a\\Z", "a", 0, 1); + x2("\\Gaz", "az", 0, 2); + n("\\Gz", "bza"); + n("az\\G", "az"); + n("az\\A", "az"); + n("a\\Az", "az"); + x2("\\^\\$", "^$", 0, 2); + x2("^x?y", "xy", 0, 2); + x2("^(x?y)", "xy", 0, 2); + x2("\\w", "_", 0, 1); + n("\\W", "_"); + x2("(?=z)z", "z", 0, 1); + n("(?=z).", "a"); + x2("(?!z)a", "a", 0, 1); + n("(?!z)a", "z"); + x2("(?i:a)", "a", 0, 1); + x2("(?i:a)", "A", 0, 1); + x2("(?i:A)", "a", 0, 1); + n("(?i:A)", "b"); + x2("(?i:[A-Z])", "a", 0, 1); + x2("(?i:[f-m])", "H", 0, 1); + x2("(?i:[f-m])", "h", 0, 1); + n("(?i:[f-m])", "e"); + x2("(?i:[A-c])", "D", 0, 1); + n("(?i:[^a-z])", "A"); + n("(?i:[^a-z])", "a"); + x2("(?i:[!-k])", "Z", 0, 1); + x2("(?i:[!-k])", "7", 0, 1); + x2("(?i:[T-}])", "b", 0, 1); + x2("(?i:[T-}])", "{", 0, 1); + x2("(?i:\\?a)", "?A", 0, 2); + x2("(?i:\\*A)", "*a", 0, 2); + n(".", "\n"); + x2("(?m:.)", "\n", 0, 1); + x2("(?m:a.)", "a\n", 0, 2); + x2("(?m:.b)", "a\nb", 1, 3); + x2(".*abc", "dddabdd\nddabc", 8, 13); + x2("(?m:.*abc)", "dddabddabc", 0, 10); + n("(?i)(?-i)a", "A"); + n("(?i)(?-i:a)", "A"); + x2("a?", "", 0, 0); + x2("a?", "b", 0, 0); + x2("a?", "a", 0, 1); + x2("a*", "", 0, 0); + x2("a*", "a", 0, 1); + x2("a*", "aaa", 0, 3); + x2("a*", "baaaa", 0, 0); + n("a+", ""); + x2("a+", "a", 0, 1); + x2("a+", "aaaa", 0, 4); + x2("a+", "aabbb", 0, 2); + x2("a+", "baaaa", 1, 5); + x2(".?", "", 0, 0); + x2(".?", "f", 0, 1); + x2(".?", "\n", 0, 0); + x2(".*", "", 0, 0); + x2(".*", "abcde", 0, 5); + x2(".+", "z", 0, 1); + x2(".+", "zdswer\n", 0, 6); + x2("(.*)a\\1f", "babfbac", 0, 4); + x2("(.*)a\\1f", "bacbabf", 3, 7); + x2("((.*)a\\2f)", "bacbabf", 3, 7); + x2("(.*)a\\1f", "baczzzzzz\nbazz\nzzzzbabf", 19, 23); + x2("a|b", "a", 0, 1); + x2("a|b", "b", 0, 1); + x2("|a", "a", 0, 0); + x2("(|a)", "a", 0, 0); + x2("ab|bc", "ab", 0, 2); + x2("ab|bc", "bc", 0, 2); + x2("z(?:ab|bc)", "zbc", 0, 3); + x2("a(?:ab|bc)c", "aabc", 0, 4); + x2("ab|(?:ac|az)", "az", 0, 2); + x2("a|b|c", "dc", 1, 2); + x2("a|b|cd|efg|h|ijk|lmn|o|pq|rstuvwx|yz", "pqr", 0, 2); + n("a|b|cd|efg|h|ijk|lmn|o|pq|rstuvwx|yz", "mn"); + x2("a|^z", "ba", 1, 2); + x2("a|^z", "za", 0, 1); + x2("a|\\Gz", "bza", 2, 3); + x2("a|\\Gz", "za", 0, 1); + x2("a|\\Az", "bza", 2, 3); + x2("a|\\Az", "za", 0, 1); + x2("a|b\\Z", "ba", 1, 2); + x2("a|b\\Z", "b", 0, 1); + x2("a|b\\z", "ba", 1, 2); + x2("a|b\\z", "b", 0, 1); + x2("\\w|\\s", " ", 0, 1); + n("\\w|\\w", " "); + x2("\\w|%", "%", 0, 1); + x2("\\w|[&$]", "&", 0, 1); + x2("[b-d]|[^e-z]", "a", 0, 1); + x2("(?:a|[c-f])|bz", "dz", 0, 1); + x2("(?:a|[c-f])|bz", "bz", 0, 2); + x2("abc|(?=zz)..f", "zzf", 0, 3); + x2("abc|(?!zz)..f", "abf", 0, 3); + x2("(?=za)..a|(?=zz)..a", "zza", 0, 3); + n("(?>a|abd)c", "abdc"); + x2("(?>abd|a)c", "abdc", 0, 4); + x2("a?|b", "a", 0, 1); + x2("a?|b", "b", 0, 0); + x2("a?|b", "", 0, 0); + x2("a*|b", "aa", 0, 2); + x2("a*|b*", "ba", 0, 0); + x2("a*|b*", "ab", 0, 1); + x2("a+|b*", "", 0, 0); + x2("a+|b*", "bbb", 0, 3); + x2("a+|b*", "abbb", 0, 1); + n("a+|b+", ""); + x2("(a|b)?", "b", 0, 1); + x2("(a|b)*", "ba", 0, 2); + x2("(a|b)+", "bab", 0, 3); + x2("(ab|ca)+", "caabbc", 0, 4); + x2("(ab|ca)+", "aabca", 1, 5); + x2("(ab|ca)+", "abzca", 0, 2); + x2("(a|bab)+", "ababa", 0, 5); + x2("(a|bab)+", "ba", 1, 2); + x2("(a|bab)+", "baaaba", 1, 4); + x2("(?:a|b)(?:a|b)", "ab", 0, 2); + x2("(?:a*|b*)(?:a*|b*)", "aaabbb", 0, 3); + x2("(?:a*|b*)(?:a+|b+)", "aaabbb", 0, 6); + x2("(?:a+|b+){2}", "aaabbb", 0, 6); + x2("h{0,}", "hhhh", 0, 4); + x2("(?:a+|b+){1,2}", "aaabbb", 0, 6); + n("ax{2}*a", "0axxxa1"); + n("a.{0,2}a", "0aXXXa0"); + n("a.{0,2}?a", "0aXXXa0"); + n("a.{0,2}?a", "0aXXXXa0"); + x2("^a{2,}?a$", "aaa", 0, 3); + x2("^[a-z]{2,}?$", "aaa", 0, 3); + x2("(?:a+|\\Ab*)cc", "cc", 0, 2); + n("(?:a+|\\Ab*)cc", "abcc"); + x2("(?:^a+|b+)*c", "aabbbabc", 6, 8); + x2("(?:^a+|b+)*c", "aabbbbc", 0, 7); + x2("a|(?i)c", "C", 0, 1); + x2("(?i)c|a", "C", 0, 1); + x2("(?i)c|a", "A", 0, 1); + x2("(?i:c)|a", "C", 0, 1); + n("(?i:c)|a", "A"); + x2("[abc]?", "abc", 0, 1); + x2("[abc]*", "abc", 0, 3); + x2("[^abc]*", "abc", 0, 0); + n("[^abc]+", "abc"); + x2("a?\?", "aaa", 0, 0); + x2("ba?\?b", "bab", 0, 3); + x2("a*?", "aaa", 0, 0); + x2("ba*?", "baa", 0, 1); + x2("ba*?b", "baab", 0, 4); + x2("a+?", "aaa", 0, 1); + x2("ba+?", "baa", 0, 2); + x2("ba+?b", "baab", 0, 4); + x2("(?:a?)?\?", "a", 0, 0); + x2("(?:a?\?)?", "a", 0, 0); + x2("(?:a?)+?", "aaa", 0, 1); + x2("(?:a+)?\?", "aaa", 0, 0); + x2("(?:a+)?\?b", "aaab", 0, 4); + x2("(?:ab)?{2}", "", 0, 0); + x2("(?:ab)?{2}", "ababa", 0, 4); + x2("(?:ab)*{0}", "ababa", 0, 0); + x2("(?:ab){3,}", "abababab", 0, 8); + n("(?:ab){3,}", "abab"); + x2("(?:ab){2,4}", "ababab", 0, 6); + x2("(?:ab){2,4}", "ababababab", 0, 8); + x2("(?:ab){2,4}?", "ababababab", 0, 4); + x2("(?:ab){,}", "ab{,}", 0, 5); + x2("(?:abc)+?{2}", "abcabcabc", 0, 6); + x2("(?:X*)(?i:xa)", "XXXa", 0, 4); + x2("(d+)([^abc]z)", "dddz", 0, 4); + x2("([^abc]*)([^abc]z)", "dddz", 0, 4); + x2("(\\w+)(\\wz)", "dddz", 0, 4); + x3("(a)", "a", 0, 1, 1); + x3("(ab)", "ab", 0, 2, 1); + x2("((ab))", "ab", 0, 2); + x3("((ab))", "ab", 0, 2, 1); + x3("((ab))", "ab", 0, 2, 2); + x3("((((((((((((((((((((ab))))))))))))))))))))", "ab", 0, 2, 20); + x3("(ab)(cd)", "abcd", 0, 2, 1); + x3("(ab)(cd)", "abcd", 2, 4, 2); + x3("()(a)bc(def)ghijk", "abcdefghijk", 3, 6, 3); + x3("(()(a)bc(def)ghijk)", "abcdefghijk", 3, 6, 4); + x2("(^a)", "a", 0, 1); + x3("(a)|(a)", "ba", 1, 2, 1); + x3("(^a)|(a)", "ba", 1, 2, 2); + x3("(a?)", "aaa", 0, 1, 1); + x3("(a*)", "aaa", 0, 3, 1); + x3("(a*)", "", 0, 0, 1); + x3("(a+)", "aaaaaaa", 0, 7, 1); + x3("(a+|b*)", "bbbaa", 0, 3, 1); + x3("(a+|b?)", "bbbaa", 0, 1, 1); + x3("(abc)?", "abc", 0, 3, 1); + x3("(abc)*", "abc", 0, 3, 1); + x3("(abc)+", "abc", 0, 3, 1); + x3("(xyz|abc)+", "abc", 0, 3, 1); + x3("([xyz][abc]|abc)+", "abc", 0, 3, 1); + x3("((?i:abc))", "AbC", 0, 3, 1); + x2("(abc)(?i:\\1)", "abcABC", 0, 6); + x3("((?m:a.c))", "a\nc", 0, 3, 1); + x3("((?=az)a)", "azb", 0, 1, 1); + x3("abc|(.abd)", "zabd", 0, 4, 1); + x2("(?:abc)|(ABC)", "abc", 0, 3); + x3("(?i:(abc))|(zzz)", "ABC", 0, 3, 1); + x3("a*(.)", "aaaaz", 4, 5, 1); + x3("a*?(.)", "aaaaz", 0, 1, 1); + x3("a*?(c)", "aaaac", 4, 5, 1); + x3("[bcd]a*(.)", "caaaaz", 5, 6, 1); + x3("(\\Abb)cc", "bbcc", 0, 2, 1); + n("(\\Abb)cc", "zbbcc"); + x3("(^bb)cc", "bbcc", 0, 2, 1); + n("(^bb)cc", "zbbcc"); + x3("cc(bb$)", "ccbb", 2, 4, 1); + n("cc(bb$)", "ccbbb"); + n("(\\1)", ""); + n("\\1(a)", "aa"); + n("(a(b)\\1)\\2+", "ababb"); + n("(?:(?:\\1|z)(a))+$", "zaa"); + x2("(?:(?:\\1|z)(a))+$", "zaaa", 0, 4); + x2("(a)(?=\\1)", "aa", 0, 1); + n("(a)$|\\1", "az"); + x2("(a)\\1", "aa", 0, 2); + n("(a)\\1", "ab"); + x2("(a?)\\1", "aa", 0, 2); + x2("(a?\?)\\1", "aa", 0, 0); + x2("(a*)\\1", "aaaaa", 0, 4); + x3("(a*)\\1", "aaaaa", 0, 2, 1); + x2("a(b*)\\1", "abbbb", 0, 5); + x2("a(b*)\\1", "ab", 0, 1); + x2("(a*)(b*)\\1\\2", "aaabbaaabb", 0, 10); + x2("(a*)(b*)\\2", "aaabbbb", 0, 7); + x2("(((((((a*)b))))))c\\7", "aaabcaaa", 0, 8); + x3("(((((((a*)b))))))c\\7", "aaabcaaa", 0, 3, 7); + x2("(a)(b)(c)\\2\\1\\3", "abcbac", 0, 6); + x2("([a-d])\\1", "cc", 0, 2); + x2("(\\w\\d\\s)\\1", "f5 f5 ", 0, 6); + n("(\\w\\d\\s)\\1", "f5 f5"); + x2("(who|[a-c]{3})\\1", "whowho", 0, 6); + x2("...(who|[a-c]{3})\\1", "abcwhowho", 0, 9); + x2("(who|[a-c]{3})\\1", "cbccbc", 0, 6); + x2("(^a)\\1", "aa", 0, 2); + n("(^a)\\1", "baa"); + n("(a$)\\1", "aa"); + n("(ab\\Z)\\1", "ab"); + x2("(a*\\Z)\\1", "a", 1, 1); + x2(".(a*\\Z)\\1", "ba", 1, 2); + x3("(.(abc)\\2)", "zabcabc", 0, 7, 1); + x3("(.(..\\d.)\\2)", "z12341234", 0, 9, 1); + x2("((?i:az))\\1", "AzAz", 0, 4); + n("((?i:az))\\1", "Azaz"); + x2("(?<=a)b", "ab", 1, 2); + n("(?<=a)b", "bb"); + x2("(?<=a|b)b", "bb", 1, 2); + x2("(?<=a|bc)b", "bcb", 2, 3); + x2("(?<=a|bc)b", "ab", 1, 2); + x2("(?<=a|bc||defghij|klmnopq|r)z", "rz", 1, 2); + x2("(a)\\g<1>", "aa", 0, 2); + x2("(?a)", "a", 0, 1); + x2("(?ab)\\g", "abab", 0, 4); + x2("(?.zv.)\\k", "azvbazvb", 0, 8); + x2("(?<=\\g)|-\\zEND (?XyZ)", "XyZ", 3, 3); + x2("(?|a\\g)+", "", 0, 0); + x2("(?|\\(\\g\\))+$", "()(())", 0, 6); + x3("\\g(?.){0}", "X", 0, 1, 1); + x2("\\g(abc|df(?.YZ){2,8}){0}", "XYZ", 0, 3); + x2("\\A(?(a\\g)|)\\z", "aaaa", 0, 4); + x2("(?|\\g\\g)\\z|\\zEND (?a|(b)\\g)", "bbbbabba", 0, 8); + x2("(?\\w+\\sx)a+\\k", " fg xaaaaaaaafg x", 2, 18); + x3("(z)()()(?<_9>a)\\g<_9>", "zaa", 2, 3, 1); + x2("(.)(((?<_>a)))\\k<_>", "zaa", 0, 3); + x2("((?\\d)|(?\\w))(\\k|\\k)", "ff", 0, 2); + x2("(?:(?)|(?efg))\\k", "", 0, 0); + x2("(?:(?abc)|(?efg))\\k", "abcefgefg", 3, 9); + n("(?:(?abc)|(?efg))\\k", "abcefg"); + x2("(?:(?.)|(?..)|(?...)|(?....)|(?.....)|(?......)|(?.......)|(?........)|(?.........)|(?..........)|(?...........)|(?............)|(?.............)|(?..............))\\k$", "a-pyumpyum", 2, 10); + x3("(?:(?.)|(?..)|(?...)|(?....)|(?.....)|(?......)|(?.......)|(?........)|(?.........)|(?..........)|(?...........)|(?............)|(?.............)|(?..............))\\k$", "xxxxabcdefghijklmnabcdefghijklmn", 4, 18, 14); + x3("(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?)(?aaa)(?)$", "aaa", 0, 3, 16); + x2("(?a|\\(\\g\\))", "a", 0, 1); + x2("(?a|\\(\\g\\))", "((((((a))))))", 0, 13); + x3("(?a|\\(\\g\\))", "((((((((a))))))))", 0, 17, 1); + x2("\\g|\\zEND(?.*abc$)", "abcxxxabc", 0, 9); + x2("\\g<1>|\\zEND(.a.)", "bac", 0, 3); + x3("\\g<_A>\\g<_A>|\\zEND(.a.)(?<_A>.b.)", "xbxyby", 3, 6, 1); + x2("\\A(?:\\g|\\g|\\zEND (?a|c\\gc)(?b|d\\gd))$", "cdcbcdc", 0, 7); + x2("\\A(?|a\\g)\\z|\\zEND (?\\g)", "aaaa", 0, 4); + x2("(?(a|b\\gc){3,5})", "baaaaca", 1, 5); + x2("(?(a|b\\gc){3,5})", "baaaacaaaaa", 0, 10); + x2("(?\\(([^\\(\\)]++|\\g)*+\\))", "((a))", 0, 5); + x2("()*\\1", "", 0, 0); + x2("(?:()|())*\\1\\2", "", 0, 0); + x3("(?:\\1a|())*", "a", 0, 0, 1); + x2("x((.)*)*x", "0x1x2x3", 1, 6); + x2("x((.)*)*x(?i:\\1)\\Z", "0x1x2x1X2", 1, 9); + x2("(?:()|()|()|()|()|())*\\2\\5", "", 0, 0); + x2("(?:()|()|()|(x)|()|())*\\2b\\5", "b", 0, 1); + x2("\\xED\\xF2", "\xed\xf2", 0, 2); + x2("", "", 0, 0); + x2("", "", 0, 2); + n("", ""); + x2("", "", 0, 4); + x2("", "", 0, 6); + x2("", "", 0, 70); + x2("", "", 2, 4); + x2("", "", 2, 6); + x2("\\xca\\xb8", "\xca\xb8", 0, 2); + x2(".", "", 0, 2); + x2("..", "", 0, 4); + x2("\\w", "", 0, 2); + n("\\W", ""); + x2("[\\W]", "$", 2, 3); + x2("\\S", "", 0, 2); + x2("\\S", "", 0, 2); + x2("\\b", "C ", 0, 0); + x2("\\b", " ", 1, 1); + x2("\\B", " ", 2, 2); + x2("\\B", " ", 3, 3); + x2("\\B", " ", 0, 0); + x2("[]", "", 0, 2); + n("[Ȃ]", ""); + x2("[-]", "", 0, 2); + n("[^]", ""); + x2("[\\w]", "", 0, 2); + n("[\\d]", ""); + x2("[\\D]", "", 0, 2); + n("[\\s]", ""); + x2("[\\S]", "", 0, 2); + x2("[\\w\\d]", "", 0, 2); + x2("[\\w\\d]", " ", 3, 5); + n("\\wS", " S"); + x2("S\\W", "S ", 0, 5); + x2("..", "", 0, 10); + x2(".\\w\\W..", " ", 0, 13); + x2("\\s\\w", " ", 0, 9); + x2(".", "", 0, 8); + n(".", ""); + x2(".", "", 0, 4); + x2("^", "", 0, 2); + x2("^$", "", 0, 2); + x2("^\\w$", "", 0, 2); + x2("^\\w$", "z", 0, 11); + x2("^\\w...$", "z", 0, 13); + x2("\\w\\w\\s\\W\\d", "a 4", 0, 12); + x2("\\A", "", 0, 6); + x2("ނ߂\\Z", "ނ߂", 0, 6); + x2("\\z", "", 0, 6); + x2("\\Z", "\n", 0, 6); + x2("\\Gۂ", "ۂ", 0, 4); + n("\\G", ""); + n("Ƃ\\G", "Ƃ"); + n("܂\\A", "܂"); + n("\\A", "܂"); + x2("(?=)", "", 0, 2); + n("(?=).", ""); + x2("(?!)", "", 0, 2); + n("(?!)", ""); + x2("(?i:)", "", 0, 2); + x2("(?i:Ԃ)", "Ԃ", 0, 4); + n("(?i:)", ""); + x2("(?m:.)", "\n", 0, 3); + x2("(?m:.)", "\n", 2, 5); + x2("?", "", 0, 0); + x2("?", "", 0, 0); + x2("?", "", 0, 2); + x2("*", "", 0, 0); + x2("*", "", 0, 2); + x2("q*", "qqq", 0, 6); + x2("n*", "nnnn", 0, 0); + n("R+", ""); + x2("+", "", 0, 2); + x2("+", "", 0, 8); + x2("+", "", 0, 4); + x2("+", "", 2, 10); + x2(".?", "", 0, 2); + x2(".*", "ς҂Ղ", 0, 8); + x2(".+", "", 0, 2); + x2(".+", "\n", 0, 8); + x2("|", "", 0, 2); + x2("|", "", 0, 2); + x2("|", "", 0, 4); + x2("|", "", 0, 4); + x2("(?:|)", "", 0, 6); + x2("(?:|)", "", 0, 8); + x2("|(?:|)", "", 0, 4); + x2("||", "", 2, 4); + x2("|||||||||‚ĂƂȂ|ʂ", "", 0, 6); + n("|||||||||‚ĂƂȂ|ʂ", ""); + x2("|^", "Ԃ", 2, 4); + x2("|^", "", 0, 2); + x2("S|\\G", "ԋS", 4, 6); + x2("S|\\G", "ԋS", 0, 2); + x2("S|\\A", "bԋS", 3, 5); + x2("S|\\A", "", 0, 2); + x2("S|\\Z", "ԋS", 2, 4); + x2("S|\\Z", "", 0, 2); + x2("S|\\Z", "\n", 0, 2); + x2("S|\\z", "ԋS", 2, 4); + x2("S|\\z", "", 0, 2); + x2("\\w|\\s", "", 0, 2); + x2("\\w|%", "%", 0, 1); + x2("\\w|[&$]", "&", 0, 2); + x2("[-]", "", 0, 2); + x2("[-]|[^-]", "", 0, 2); + x2("[-]|[^-]", "", 0, 2); + x2("[^]", "\n", 0, 1); + x2("(?:|[-])|", "", 0, 2); + x2("(?:|[-])|", "", 0, 4); + x2("|(?=)..", "", 0, 6); + x2("|(?!)..", "", 0, 6); + x2("(?=)..|(?=)..", "", 0, 6); + x2("(?<=|)", "", 4, 6); + n("(?>|)", ""); + x2("(?>|)", "", 0, 8); + x2("?|", "", 0, 2); + x2("?|", "", 0, 0); + x2("?|", "", 0, 0); + x2("*|", "", 0, 4); + x2("*|*", "", 0, 0); + x2("*|*", "", 0, 2); + x2("[a]*|*", "a", 0, 3); + x2("+|*", "", 0, 0); + x2("+|*", "", 0, 6); + x2("+|*", "", 0, 2); + x2("+|*", "a", 0, 0); + n("+|+", ""); + x2("(|)?", "", 0, 2); + x2("(|)*", "", 0, 4); + x2("(|)+", "", 0, 6); + x2("(|)+", "", 0, 8); + x2("(|)+", "", 4, 12); + x2("(|)+", "", 2, 10); + x2("(|)+", "", 0, 4); + x2("(|)+", "$$zzzz", 6, 10); + x2("(|)+", "", 0, 10); + x2("(|)+", "", 2, 4); + x2("(|)+", "", 2, 8); + x2("(?:|)(?:|)", "", 0, 4); + x2("(?:*|*)(?:*|*)", "", 0, 6); + x2("(?:*|*)(?:+|+)", "", 0, 12); + x2("(?:+|+){2}", "", 0, 12); + x2("(?:+|+){1,2}", "", 0, 12); + x2("(?:+|\\A*)", "", 0, 4); + n("(?:+|\\A*)", ""); + x2("(?:^+|+)*", "", 12, 16); + x2("(?:^+|+)*", "", 0, 14); + x2("{0,}", "", 0, 8); + x2("|(?i)c", "C", 0, 1); + x2("(?i)c|", "C", 0, 1); + x2("(?i:)|a", "a", 0, 1); + n("(?i:)|a", "A"); + x2("[]?", "", 0, 2); + x2("[]*", "", 0, 6); + x2("[^]*", "", 0, 0); + n("[^]+", ""); + x2("?\?", "", 0, 0); + x2("?\?", "", 0, 6); + x2("*?", "", 0, 0); + x2("*?", "", 0, 2); + x2("*?", "", 0, 8); + x2("+?", "", 0, 2); + x2("+?", "", 0, 4); + x2("+?", "", 0, 8); + x2("(?:V?)?\?", "V", 0, 0); + x2("(?:V?\?)?", "V", 0, 0); + x2("(?:?)+?", "", 0, 2); + x2("(?:+)?\?", "", 0, 0); + x2("(?:+)?\?", "ᑚ", 0, 8); + x2("(?:)?{2}", "", 0, 0); + x2("(?:S)?{2}", "SԋSԋS", 0, 8); + x2("(?:S)*{0}", "SԋSԋS", 0, 0); + x2("(?:S){3,}", "SԋSԋSԋS", 0, 16); + n("(?:S){3,}", "SԋS"); + x2("(?:S){2,4}", "SԋSԋS", 0, 12); + x2("(?:S){2,4}", "SԋSԋSԋSԋS", 0, 16); + x2("(?:S){2,4}?", "SԋSԋSԋSԋS", 0, 8); + x2("(?:S){,}", "S{,}", 0, 7); + x2("(?:)+?{2}", "", 0, 12); + x3("()", "", 0, 2, 1); + x3("(ΐ)", "ΐ", 0, 4, 1); + x2("(())", "", 0, 4); + x3("(())", "", 0, 4, 1); + x3("(())", "", 0, 4, 2); + x3("((((((((((((((((((((ʎq))))))))))))))))))))", "ʎq", 0, 4, 20); + x3("()()", "", 0, 4, 1); + x3("()()", "", 4, 8, 2); + x3("()()()", "", 6, 12, 3); + x3("(()()())", "", 6, 12, 4); + x3(".*(tH)E}(()V^)C", "tHE}V^C", 10, 18, 2); + x2("(^)", "", 0, 2); + x3("()|()", "", 2, 4, 1); + x3("(^)|()", "", 2, 4, 2); + x3("(?)", "", 0, 2, 1); + x3("(*)", "܂܂", 0, 6, 1); + x3("(*)", "", 0, 0, 1); + x3("(+)", "", 0, 14, 1); + x3("(+|*)", "ӂӂӂւ", 0, 6, 1); + x3("(+|?)", "", 0, 2, 1); + x3("()?", "", 0, 6, 1); + x3("()*", "", 0, 6, 1); + x3("()+", "", 0, 6, 1); + x3("(|)+", "", 0, 6, 1); + x3("([Ȃɂ][]|)+", "", 0, 6, 1); + x3("((?i:))", "", 0, 6, 1); + x3("((?m:.))", "\n", 0, 5, 1); + x3("((?=))", "", 0, 2, 1); + x3("|(.)", "񂠂", 0, 8, 1); + x3("*(.)", "", 8, 10, 1); + x3("*?(.)", "", 0, 2, 1); + x3("*?()", "", 8, 10, 1); + x3("[]*(.)", "", 10, 12, 1); + x3("(\\A)", "", 0, 4, 1); + n("(\\A)", "񂢂"); + x3("(^)", "", 0, 4, 1); + n("(^)", "񂢂"); + x3("($)", "", 4, 8, 1); + n("($)", ""); + x2("()\\1", "", 0, 4); + n("()\\1", ""); + x2("(?)\\1", "", 0, 4); + x2("(?\?)\\1", "", 0, 0); + x2("(*)\\1", "", 0, 8); + x3("(*)\\1", "", 0, 4, 1); + x2("(*)\\1", "", 0, 10); + x2("(*)\\1", "", 0, 2); + x2("(*)(*)\\1\\2", "", 0, 20); + x2("(*)(*)\\2", "", 0, 14); + x3("(*)(*)\\2", "", 6, 10, 2); + x2("(((((((*)))))))\\7", "ۂۂۂ؂҂ۂۂ", 0, 16); + x3("(((((((*)))))))\\7", "ۂۂۂ؂҂ۂۂ", 0, 6, 7); + x2("()()()\\2\\1\\3", "͂ЂӂЂ͂", 0, 12); + x2("([-])\\1", "", 0, 4); + x2("(\\w\\d\\s)\\1", "5 5 ", 0, 8); + n("(\\w\\d\\s)\\1", "5 5"); + x2("(NH|[-]{3})\\1", "NHNH", 0, 8); + x2("...(NH|[-]{3})\\1", "aNHNH", 0, 13); + x2("(NH|[-]{3})\\1", "", 0, 12); + x2("(^)\\1", "", 0, 4); + n("(^)\\1", "߂ނ"); + n("($)\\1", ""); + n("(\\Z)\\1", ""); + x2("(*\\Z)\\1", "", 2, 2); + x2(".(*\\Z)\\1", "", 2, 4); + x3("(.(₢)\\2)", "z₢₢", 0, 13, 1); + x3("(.(..\\d.)\\2)", "12341234", 0, 10, 1); + x2("((?i:v))\\1", "vv", 0, 10); + x2("(?<>|\\(\\g<>\\))", "(((((())))))", 0, 14); + x2("\\A(?:\\g<_1>|\\g<]_2>|\\zI (?<_1>|\\g<]_2>)(?<]_2>|F\\g<_1>F))$", "FFݎFF", 0, 26); + x2("[[Ђ]]", "", 0, 2); + x2("[[]]", "", 0, 2); + n("[[^]]", ""); + n("[^[]]", ""); + x2("[^[^]]", "", 0, 2); + x2("[[]&&]", "", 0, 2); + n("[[]&&]", ""); + n("[[]&&]", ""); + x2("[-&&-&&-]", "", 0, 2); + n("[^-&&-&&-]", ""); + x2("[[^&&]&&-]", "", 0, 2); + n("[[^&&]&&-]", ""); + x2("[[^-&&]&&[^-]]", "", 0, 2); + n("[[^-&&]&&[^-]]", ""); + x2("[^[^]&&[^]]", "", 0, 2); + x2("[^[^]&&[^]]", "", 0, 2); + n("[^[^]&&[^]]", ""); + x2("[-&&-]", "-", 0, 1); + x2("[^[^a-z]&&[^bcdefg]q-w]", "", 0, 2); + x2("[^[^a-z]&&[^bcdefg]g-w]", "f", 0, 1); + x2("[^[^a-z]&&[^bcdefg]g-w]", "g", 0, 1); + n("[^[^a-z]&&[^bcdefg]g-w]", "2"); + x2("ao[W̃_E[h<\\/b>", "ao[W̃_E[h", 0, 32); + x2(".o[W̃_E[h<\\/b>", "ao[W̃_E[h", 0, 32); + fprintf(stdout, + "\nRESULT SUCC: %d, FAIL: %d, ERROR: %d (by Oniguruma %s)\n", + nsucc, nfail, nerror, onig_version()); + +#ifndef POSIX_TEST + onig_region_free(region, 1); + onig_end(); +#endif + + return ((nfail == 0 && nerror == 0) ? 0 : -1); +} diff --git a/ext/mbstring/php_mbregex.h b/ext/mbstring/php_mbregex.h index d5ae7529df4bd..276220ac110cd 100644 --- a/ext/mbstring/php_mbregex.h +++ b/ext/mbstring/php_mbregex.h @@ -34,7 +34,7 @@ PHP_FE(mb_eregi, arginfo_mb_eregi) \ PHP_FE(mb_ereg_replace, arginfo_mb_ereg_replace) \ PHP_FE(mb_eregi_replace, arginfo_mb_eregi_replace) \ - PHP_FE(mb_ereg_replace_callback, arginfo_mb_ereg_replace_callback) \ + PHP_FE(mb_ereg_replace_callback, arginfo_mb_ereg_replace_callback) \ PHP_FE(mb_split, arginfo_mb_split) \ PHP_FE(mb_ereg_match, arginfo_mb_ereg_match) \ PHP_FE(mb_ereg_search, arginfo_mb_ereg_search) \ diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index 0fcddddbd0909..07568e6c2ae19 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -238,10 +238,10 @@ ZEND_END_ARG_INFO() /* }}} */ const zend_function_entry mcrypt_functions[] = { /* {{{ */ - PHP_FE(mcrypt_ecb, arginfo_mcrypt_ecb) - PHP_FE(mcrypt_cbc, arginfo_mcrypt_cbc) - PHP_FE(mcrypt_cfb, arginfo_mcrypt_cfb) - PHP_FE(mcrypt_ofb, arginfo_mcrypt_ofb) + PHP_DEP_FE(mcrypt_ecb, arginfo_mcrypt_ecb) + PHP_DEP_FE(mcrypt_cbc, arginfo_mcrypt_cbc) + PHP_DEP_FE(mcrypt_cfb, arginfo_mcrypt_cfb) + PHP_DEP_FE(mcrypt_ofb, arginfo_mcrypt_ofb) PHP_FE(mcrypt_get_key_size, arginfo_mcrypt_get_key_size) PHP_FE(mcrypt_get_block_size, arginfo_mcrypt_get_block_size) PHP_FE(mcrypt_get_cipher_name, arginfo_mcrypt_get_cipher_name) @@ -1387,7 +1387,7 @@ PHP_FUNCTION(mcrypt_create_iv) } iv = ecalloc(size + 1, 1); - + if (source == RANDOM || source == URANDOM) { #if PHP_WIN32 /* random/urandom equivalent on Windows */ diff --git a/ext/mcrypt/tests/mcrypt_cbc.phpt b/ext/mcrypt/tests/mcrypt_cbc.phpt index f9160db011b7b..27cc5b2224404 100644 --- a/ext/mcrypt/tests/mcrypt_cbc.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc.phpt @@ -18,6 +18,12 @@ echo trim(mcrypt_cbc($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n"; mcrypt_cbc($cipher, $key, $enc_data, MCRYPT_DECRYPT); --EXPECTF-- + +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d + +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d PHP Testfest 2008 +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d + Warning: mcrypt_cbc(): Attempt to use an empty IV, which is NOT recommend in %s on line %d diff --git a/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt b/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt index 6df3079935306..67799a3fdd976 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt @@ -72,16 +72,24 @@ function special_var_dump($str) { --- testing different key lengths key length=8 + +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d string(32) "736563726574206d6573736167650000" key length=20 + +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d string(32) "736563726574206d6573736167650000" key length=24 + +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d string(32) "736563726574206d6573736167650000" key length=26 +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d + Warning: mcrypt_cbc(): Size of key is too large for this algorithm in %s on line %d string(32) "736563726574206d6573736167650000" @@ -89,14 +97,20 @@ string(32) "736563726574206d6573736167650000" iv length=4 +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d + Warning: mcrypt_cbc(): The IV parameter must be as long as the blocksize in %s on line %d string(32) "736563726574206d6573736167650000" iv length=8 + +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d string(32) "736563726574206d6573736167650000" iv length=9 +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d + Warning: mcrypt_cbc(): The IV parameter must be as long as the blocksize in %s on line %d string(32) "736563726574206d6573736167650000" ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt b/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt index 35fabd9aca770..1af094c27b04c 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt @@ -55,16 +55,24 @@ foreach ($ivs as $iv) { --- testing different key lengths key length=8 + +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d string(112) "082b437d039d09418e20dc9de1dafa7ed6da5c6335b78950968441da1faf40c1f886e04da8ca177b80b376811e138c1bf51cb48dae2e7939" key length=20 + +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d string(112) "0627351e0f8a082bf7981ae2c700a43fd3d44b270ac67b00fded1c5796eea935be0fef2a23da0b3f5e243929e62ac957bf0bf463aa90fc4f" key length=24 + +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" key length=26 +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d + Warning: mcrypt_cbc(): Size of key is too large for this algorithm in %s on line %d string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac" @@ -72,14 +80,20 @@ string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b6 iv length=4 +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d + Warning: mcrypt_cbc(): The IV parameter must be as long as the blocksize in %s on line %d string(112) "440a6f54601969b127aad3c217ce7583c7f7b29989693130645569301db0020b29a34a3dcd104b2d0e3ba19d6cbd8a33d352b9c27cc34ef1" iv length=8 + +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d string(112) "bac347506bf092c5557c4363c301745d78f047028e2953e84fd66b30aeb6005812dadbe8baa871b83278341599b0c448ddaaa52b5a378ce5" iv length=9 +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d + Warning: mcrypt_cbc(): The IV parameter must be as long as the blocksize in %s on line %d string(112) "440a6f54601969b127aad3c217ce7583c7f7b29989693130645569301db0020b29a34a3dcd104b2d0e3ba19d6cbd8a33d352b9c27cc34ef1" ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_cbc_error.phpt b/ext/mcrypt/tests/mcrypt_cbc_error.phpt index ec3912b03fc39..3c221802147e4 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_error.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_error.phpt @@ -41,11 +41,15 @@ var_dump( mcrypt_cbc($cipher, $key, $data) ); -- Testing mcrypt_cbc() function with more than expected no. of arguments -- +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d + Warning: mcrypt_cbc() expects at most 5 parameters, 6 given in %s on line %d NULL -- Testing mcrypt_cbc() function with less than expected no. of arguments -- +Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d + Warning: mcrypt_cbc() expects at least 4 parameters, 3 given in %s on line %d NULL ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation1.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation1.phpt index 5482de3e20ace..eb233e3f92e90 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation1.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation1.phpt @@ -124,106 +124,132 @@ fclose($fp); *** Testing mcrypt_cbc() : usage variation *** --int 0-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --int 1-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --int 12345-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --int -12345-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --float 10.5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --float -10.5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --float 12.3456789000e10-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --float -12.3456789000e10-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --float .5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --empty array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d) NULL --int indexed array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d) NULL --associative array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d) NULL --nested arrays-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d) NULL --uppercase NULL-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --lowercase null-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --lowercase true-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --lowercase false-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --uppercase TRUE-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --uppercase FALSE-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --empty string DQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --empty string SQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --instance of classWithToString-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --instance of classWithoutToString-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 1 to be string, object given, %s(%d) NULL --undefined var-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --unset var-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d) bool(false) --resource-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 1 to be string, resource given, %s(%d) NULL ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt index f49e80ee9379c..3d2a0614722d4 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation2.phpt @@ -124,87 +124,112 @@ fclose($fp); *** Testing mcrypt_cbc() : usage variation *** --int 0-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "bc27b3a4e33b531d5983fc7df693cd09" --int 1-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "bc27b3a4e33b531d5983fc7df693cd09" --int 12345-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "d109b7973383127002474ae731c4b3a8" --int -12345-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "3e82a931cedb03a38b91a637ff8c9f9e" --float 10.5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "de71833586c1d7132a289960ebeeca7a" --float -10.5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "7d0489dd2e99ae910ecc015573f3dd16" --float 12.3456789000e10-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "978055b42c0506a8947e3c3c8d994baf" --float -12.3456789000e10-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "4aa84ba400c2b8ef467d4d98372b4f4e" --float .5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "e731dc5059b84e0c8774ac490f77d6e6" --empty array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d) string(0) "" --int indexed array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d) string(0) "" --associative array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d) string(0) "" --nested arrays-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d) string(0) "" --uppercase NULL-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "be722a5ffc361d721fbcab1eacc6acf5" --lowercase null-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "be722a5ffc361d721fbcab1eacc6acf5" --lowercase true-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "bc27b3a4e33b531d5983fc7df693cd09" --lowercase false-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "be722a5ffc361d721fbcab1eacc6acf5" --uppercase TRUE-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "bc27b3a4e33b531d5983fc7df693cd09" --uppercase FALSE-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "be722a5ffc361d721fbcab1eacc6acf5" --empty string DQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "be722a5ffc361d721fbcab1eacc6acf5" --empty string SQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "be722a5ffc361d721fbcab1eacc6acf5" --instance of classWithToString-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "19420fa26f561ee82ed84abbcd2d284b" --instance of classWithoutToString-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 2 to be string, object given, %s(%d) string(0) "" --undefined var-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "be722a5ffc361d721fbcab1eacc6acf5" --unset var-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "be722a5ffc361d721fbcab1eacc6acf5" --resource-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 2 to be string, resource given, %s(%d) string(0) "" ===DONE=== - diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt index 5b2398ddbda2f..9a1464b1122cc 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation3.phpt @@ -124,87 +124,112 @@ fclose($fp); *** Testing mcrypt_cbc() : usage variation *** --int 0-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "ce5fcfe737859795" --int 1-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "84df495f6cd82dd9" --int 12345-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "905ab1ae27ee9991" --int -12345-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "5835174e9c67c3e7" --float 10.5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "28ff0601ad9e47fa" --float -10.5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "ce9f2b6e2fc3d9f7" --float 12.3456789000e10-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "24eb882ce9763e4018fba9b7f01b0c3e" --float -12.3456789000e10-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5eed30e428f32de1d7a7064d0ed4d3eb" --float .5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "bebf2a13676e1e30" --empty array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d) string(0) "" --int indexed array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d) string(0) "" --associative array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d) string(0) "" --nested arrays-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 3 to be string, array given, %s(%d) string(0) "" --uppercase NULL-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "206f6d3617a5ab32" --lowercase null-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "206f6d3617a5ab32" --lowercase true-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "84df495f6cd82dd9" --lowercase false-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "206f6d3617a5ab32" --uppercase TRUE-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "84df495f6cd82dd9" --uppercase FALSE-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "206f6d3617a5ab32" --empty string DQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "206f6d3617a5ab32" --empty string SQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "206f6d3617a5ab32" --instance of classWithToString-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "7c91cdf8f8c51485034a9ee528eb016b" --instance of classWithoutToString-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 3 to be string, object given, %s(%d) string(0) "" --undefined var-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "206f6d3617a5ab32" --unset var-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(16) "206f6d3617a5ab32" --resource-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 3 to be string, resource given, %s(%d) string(0) "" ===DONE=== - diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt index f9a511f390083..a3dd29ba41b05 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation4.phpt @@ -124,82 +124,108 @@ fclose($fp); *** Testing mcrypt_cbc() : usage variation *** --float 10.5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "983d5edc5f77fe42e2372a0339dc22b0" --float -10.5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "983d5edc5f77fe42e2372a0339dc22b0" --float 12.3456789000e10-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "983d5edc5f77fe42e2372a0339dc22b0" --float -12.3456789000e10-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "983d5edc5f77fe42e2372a0339dc22b0" --float .5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --empty array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --int indexed array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "983d5edc5f77fe42e2372a0339dc22b0" --associative array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "983d5edc5f77fe42e2372a0339dc22b0" --nested arrays-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "983d5edc5f77fe42e2372a0339dc22b0" --uppercase NULL-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --lowercase null-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --lowercase true-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "983d5edc5f77fe42e2372a0339dc22b0" --lowercase false-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --uppercase TRUE-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "983d5edc5f77fe42e2372a0339dc22b0" --uppercase FALSE-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --empty string DQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --empty string SQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --string DQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --string SQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --mixed case string-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --heredoc-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --instance of classWithToString-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 8 - Object of class classWithToString could not be converted to int, %s(%d) string(32) "983d5edc5f77fe42e2372a0339dc22b0" --instance of classWithoutToString-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 8 - Object of class classWithoutToString could not be converted to int, %s(%d) string(32) "983d5edc5f77fe42e2372a0339dc22b0" --undefined var-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --unset var-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) string(32) "5f781523f696d596e4b809d72197a0cc" --resource-- -string(%d) %s +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) +string(32) "983d5edc5f77fe42e2372a0339dc22b0" ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt b/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt index 7d49db853d36f..0c75c97934104 100644 --- a/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt +++ b/ext/mcrypt/tests/mcrypt_cbc_variation5.phpt @@ -124,106 +124,132 @@ fclose($fp); *** Testing mcrypt_cbc() : usage variation *** --int 0-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --int 1-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --int 12345-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --int -12345-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --float 10.5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --float -10.5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --float 12.3456789000e10-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --float -12.3456789000e10-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --float .5-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --empty array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d) string(0) "" --int indexed array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d) string(0) "" --associative array-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d) string(0) "" --nested arrays-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 5 to be string, array given, %s(%d) string(0) "" --uppercase NULL-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --lowercase null-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --lowercase true-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --lowercase false-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --uppercase TRUE-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --uppercase FALSE-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --empty string DQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --empty string SQ-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --instance of classWithToString-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --instance of classWithoutToString-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 5 to be string, object given, %s(%d) string(0) "" --undefined var-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --unset var-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc(): The IV parameter must be as long as the blocksize, %s(%d) string(32) "6438db90653c4d3080c3ceab43618c05" --resource-- +Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d) Error: 2 - mcrypt_cbc() expects parameter 5 to be string, resource given, %s(%d) string(0) "" ===DONE=== diff --git a/ext/mcrypt/tests/mcrypt_cfb.phpt b/ext/mcrypt/tests/mcrypt_cfb.phpt index 54919c858971c..11120633a5e82 100644 --- a/ext/mcrypt/tests/mcrypt_cfb.phpt +++ b/ext/mcrypt/tests/mcrypt_cfb.phpt @@ -18,6 +18,12 @@ echo trim(mcrypt_cfb($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n"; mcrypt_cfb($cipher, $key, $enc_data, MCRYPT_DECRYPT); --EXPECTF-- + +Deprecated: Function mcrypt_cfb() is deprecated in %s on line %d + +Deprecated: Function mcrypt_cfb() is deprecated in %s on line %d PHP Testfest 2008 +Deprecated: Function mcrypt_cfb() is deprecated in %s on line %d + Warning: mcrypt_cfb(): Attempt to use an empty IV, which is NOT recommend in %s on line %d diff --git a/ext/mcrypt/tests/mcrypt_ecb.phpt b/ext/mcrypt/tests/mcrypt_ecb.phpt index e75d9fa6cde2b..b6d0a227865ab 100644 --- a/ext/mcrypt/tests/mcrypt_ecb.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb.phpt @@ -18,4 +18,10 @@ echo trim(mcrypt_ecb($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n"; mcrypt_ecb($cipher, $key, $enc_data, MCRYPT_DECRYPT); --EXPECTF-- + +Deprecated: Function mcrypt_ecb() is deprecated in %s on line %d + +Deprecated: Function mcrypt_ecb() is deprecated in %s on line %d PHP Testfest 2008 + +Deprecated: Function mcrypt_ecb() is deprecated in %s on line %d diff --git a/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt b/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt index 7a5cc27f4433c..82f9608da8d1b 100644 --- a/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt +++ b/ext/mcrypt/tests/mcrypt_ecb_3des_decrypt.phpt @@ -8,6 +8,8 @@ if (!extension_loaded("mcrypt")) { ?> --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d %unicode|string%(2) "11" done! diff --git a/ext/mysql/tests/002.phpt b/ext/mysql/tests/002.phpt index 8355c5f11ea29..8f53f4d724f6a 100644 --- a/ext/mysql/tests/002.phpt +++ b/ext/mysql/tests/002.phpt @@ -37,6 +37,7 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d resource(%d) of type (mysql link) bool(true) bool(true) diff --git a/ext/mysql/tests/003.phpt b/ext/mysql/tests/003.phpt index 2d0b68b9f8c1c..365abc20e99a7 100644 --- a/ext/mysql/tests/003.phpt +++ b/ext/mysql/tests/003.phpt @@ -57,6 +57,7 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d ==stdClass== object(stdClass)#%d (1) { [%u|b%"a"]=> diff --git a/ext/mysql/tests/bug47438.phpt b/ext/mysql/tests/bug47438.phpt index 11f0ff33b8552..fa7b3e6a2bdff 100644 --- a/ext/mysql/tests/bug47438.phpt +++ b/ext/mysql/tests/bug47438.phpt @@ -46,7 +46,8 @@ if (!mysql_select_db($db, $link) || mysql_close($link); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d 0.a 1.b 2.c diff --git a/ext/mysql/tests/bug48754.phpt b/ext/mysql/tests/bug48754.phpt index fb322f4615716..b461db3320637 100644 --- a/ext/mysql/tests/bug48754.phpt +++ b/ext/mysql/tests/bug48754.phpt @@ -68,6 +68,8 @@ var_dump($link); ?> --EXPECTF-- Explicit connection on close + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d Expect same thread id for $link and default conn: bool(true) resource(%d) of type (mysql link) resource(%d) of type (Unknown) @@ -75,18 +77,24 @@ resource(%d) of type (Unknown) Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d Closing default link + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d Expect same thread id for $link and default conn but not the previous: bool(true) resource(%d) of type (mysql link) resource(%d) of type (mysql link) resource(%d) of type (Unknown) Explicit resource and pconnect + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d resource(%d) of type (mysql link persistent) resource(%d) of type (Unknown) Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d Default link and pconnect + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d resource(%d) of type (mysql link persistent) resource(%d) of type (mysql link persistent) resource(%d) of type (Unknown) diff --git a/ext/mysql/tests/bug51242.phpt b/ext/mysql/tests/bug51242.phpt index 9b62cdb4cd473..6801d3021f3dd 100644 --- a/ext/mysql/tests/bug51242.phpt +++ b/ext/mysql/tests/bug51242.phpt @@ -35,4 +35,5 @@ if ($link = my_mysql_connect($host, $user, $passwd, $db, null, $socket)) { } ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d resource(%d) of type (mysql link) diff --git a/ext/mysql/tests/bug53649.phpt b/ext/mysql/tests/bug53649.phpt index 70bf9bed3630b..7ccdf08e5f46f 100644 --- a/ext/mysql/tests/bug53649.phpt +++ b/ext/mysql/tests/bug53649.phpt @@ -67,5 +67,6 @@ mysql_close($link); unlink('bug53649.data'); ?> ---EXPECT-- -done \ No newline at end of file +--EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d +done diff --git a/ext/mysql/tests/bug55473.phpt b/ext/mysql/tests/bug55473.phpt index befecef192931..1cc2dc928251c 100644 --- a/ext/mysql/tests/bug55473.phpt +++ b/ext/mysql/tests/bug55473.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #55473 (mysql_pconnect leaks file descriptors on reconnect) +Bug #5547 (mysql_pconnect leaks file descriptors on reconnect) --SKIPIF-- --INI-- @@ -56,9 +56,9 @@ mysql.allow_persistent=1 if ($opened_files == -1) { - $opened_files = trim(exec("lsof -nwp " . getmypid() . " | wc -l")); + $opened_files = trim(exec("lsof -np " . getmypid() . " | wc -l")); printf("[005] Setting openened files...\n"); - } else if (($tmp = trim(exec("lsof -nwp " . getmypid() . " | wc -l"))) != $opened_files) { + } else if (($tmp = trim(exec("lsof -np " . getmypid() . " | wc -l"))) != $opened_files) { printf("[006] [%d] different number of opened_files : expected %d, got %d", $i, $opened_files, $tmp); } else { printf("[007] Opened files as expected\n"); @@ -68,12 +68,21 @@ mysql.allow_persistent=1 print "done!"; ?> --EXPECTF-- +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [003] reconnect 0 + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [005] Setting openened files... [003] reconnect 1 + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [007] Opened files as expected [003] reconnect 2 + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [007] Opened files as expected [003] reconnect 3 + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [007] Opened files as expected done! diff --git a/ext/mysql/tests/mysql_affected_rows.phpt b/ext/mysql/tests/mysql_affected_rows.phpt index 145e1f5c0b95a..2449ac416e2a3 100644 --- a/ext/mysql/tests/mysql_affected_rows.phpt +++ b/ext/mysql/tests/mysql_affected_rows.phpt @@ -122,4 +122,5 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_client_encoding.phpt b/ext/mysql/tests/mysql_client_encoding.phpt index 8aa67a03ac0b0..5b21765ddb29a 100644 --- a/ext/mysql/tests/mysql_client_encoding.phpt +++ b/ext/mysql/tests/mysql_client_encoding.phpt @@ -67,4 +67,5 @@ if (false !== ($tmp = @mysql_client_encoding($link))) print "done!"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_close.phpt b/ext/mysql/tests/mysql_close.phpt index 8f305ba7801a7..e676511961c25 100644 --- a/ext/mysql/tests/mysql_close.phpt +++ b/ext/mysql/tests/mysql_close.phpt @@ -36,4 +36,5 @@ if (false !== ($tmp = @mysql_query("SELECT 1", $link))) print "done!\n"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_connect.phpt b/ext/mysql/tests/mysql_connect.phpt index 715824804076d..2b73092375da8 100644 --- a/ext/mysql/tests/mysql_connect.phpt +++ b/ext/mysql/tests/mysql_connect.phpt @@ -104,5 +104,25 @@ if (!ini_get('sql.safe_mode')) { print "done!"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_connect(): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_constants.phpt b/ext/mysql/tests/mysql_constants.phpt index 1346100209553..e68774503c18e 100644 --- a/ext/mysql/tests/mysql_constants.phpt +++ b/ext/mysql/tests/mysql_constants.phpt @@ -62,4 +62,5 @@ if (!empty($expected_constants)) { print "done!"; ?> --EXPECTF-- -done! \ No newline at end of file +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d +done! diff --git a/ext/mysql/tests/mysql_create_db.phpt b/ext/mysql/tests/mysql_create_db.phpt index bc91964f5032d..0b6d58a09e745 100644 --- a/ext/mysql/tests/mysql_create_db.phpt +++ b/ext/mysql/tests/mysql_create_db.phpt @@ -53,4 +53,7 @@ if (!mysql_query("DROP DATABASE IF EXISTS mysqlcreatedb", $link)) mysql_close($link); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_data_seek.phpt b/ext/mysql/tests/mysql_data_seek.phpt index 46a0f86bdeaf7..72d3e6327405f 100644 --- a/ext/mysql/tests/mysql_data_seek.phpt +++ b/ext/mysql/tests/mysql_data_seek.phpt @@ -67,6 +67,8 @@ print "done!\n"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_data_seek(): Offset 4 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d Warning: mysql_data_seek(): Offset -1 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d diff --git a/ext/mysql/tests/mysql_db_name.phpt b/ext/mysql/tests/mysql_db_name.phpt index b7f9042209f3d..92878e994dc1c 100644 --- a/ext/mysql/tests/mysql_db_name.phpt +++ b/ext/mysql/tests/mysql_db_name.phpt @@ -58,6 +58,8 @@ mysql_close($link); print "done!\n"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_db_name(): Unable to jump to row -1 on MySQL result index %d in %s on line %d Warning: mysql_db_name(): Unable to jump to row %d on MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_db_query.phpt b/ext/mysql/tests/mysql_db_query.phpt index bb837dd6c01dc..291fbfaac61d3 100644 --- a/ext/mysql/tests/mysql_db_query.phpt +++ b/ext/mysql/tests/mysql_db_query.phpt @@ -62,4 +62,5 @@ print "done!\n"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_deprecated_api.phpt b/ext/mysql/tests/mysql_deprecated_api.phpt index d54307ca0eff5..ebf72375cf626 100644 --- a/ext/mysql/tests/mysql_deprecated_api.phpt +++ b/ext/mysql/tests/mysql_deprecated_api.phpt @@ -75,4 +75,5 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- -done! \ No newline at end of file +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d +done! diff --git a/ext/mysql/tests/mysql_drop_db.phpt b/ext/mysql/tests/mysql_drop_db.phpt index bd729e7ab85ac..3281b8a333f0f 100644 --- a/ext/mysql/tests/mysql_drop_db.phpt +++ b/ext/mysql/tests/mysql_drop_db.phpt @@ -52,4 +52,5 @@ if (!mysql_query("DROP DATABASE IF EXISTS mysqldropdb", $link)) mysql_close($link); ?> --EXPECTF-- -done! \ No newline at end of file +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d +done! diff --git a/ext/mysql/tests/mysql_errno.phpt b/ext/mysql/tests/mysql_errno.phpt index 8cfa7bd33bfd0..c9c2956290bf6 100644 --- a/ext/mysql/tests/mysql_errno.phpt +++ b/ext/mysql/tests/mysql_errno.phpt @@ -55,6 +55,7 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d int(0) int(%d) diff --git a/ext/mysql/tests/mysql_error.phpt b/ext/mysql/tests/mysql_error.phpt index aae4480174f73..a2cf7e003430a 100644 --- a/ext/mysql/tests/mysql_error.phpt +++ b/ext/mysql/tests/mysql_error.phpt @@ -62,6 +62,8 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_error(): %d is not a valid MySQL-Link resource in %s on line %d bool(false) done! diff --git a/ext/mysql/tests/mysql_fetch_array.phpt b/ext/mysql/tests/mysql_fetch_array.phpt index 362cf99ddc672..8ccefd0242694 100644 --- a/ext/mysql/tests/mysql_fetch_array.phpt +++ b/ext/mysql/tests/mysql_fetch_array.phpt @@ -281,6 +281,7 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [005] array(4) { [0]=> diff --git a/ext/mysql/tests/mysql_fetch_assoc.phpt b/ext/mysql/tests/mysql_fetch_assoc.phpt index 3c5ca79b2d93d..048613a6be402 100644 --- a/ext/mysql/tests/mysql_fetch_assoc.phpt +++ b/ext/mysql/tests/mysql_fetch_assoc.phpt @@ -63,6 +63,7 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [005] array(2) { [%u|b%"id"]=> @@ -87,6 +88,8 @@ array(5) { } Warning: mysql_fetch_assoc(): %d is not a valid MySQL result resource in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [010] array(5) { [%u|b%"id"]=> diff --git a/ext/mysql/tests/mysql_fetch_field.phpt b/ext/mysql/tests/mysql_fetch_field.phpt index ef03279087154..85c1fd6f7ef0e 100644 --- a/ext/mysql/tests/mysql_fetch_field.phpt +++ b/ext/mysql/tests/mysql_fetch_field.phpt @@ -156,6 +156,7 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d object(stdClass)#%d (13) { [%u|b%"name"]=> %unicode|string%(2) "ID" diff --git a/ext/mysql/tests/mysql_fetch_lengths.phpt b/ext/mysql/tests/mysql_fetch_lengths.phpt index 4793e2649bae0..f0fbbb7bb875f 100644 --- a/ext/mysql/tests/mysql_fetch_lengths.phpt +++ b/ext/mysql/tests/mysql_fetch_lengths.phpt @@ -39,6 +39,7 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d array(2) { [0]=> int(1) diff --git a/ext/mysql/tests/mysql_fetch_object.phpt b/ext/mysql/tests/mysql_fetch_object.phpt index c11631e04cac6..666d0ee821a0a 100644 --- a/ext/mysql/tests/mysql_fetch_object.phpt +++ b/ext/mysql/tests/mysql_fetch_object.phpt @@ -82,6 +82,7 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d object(stdClass)#%d (2) { [%u|b%"ID"]=> %unicode|string%(1) "1" diff --git a/ext/mysql/tests/mysql_fetch_row.phpt b/ext/mysql/tests/mysql_fetch_row.phpt index 8d6b9585beea2..0ed932e2c082a 100644 --- a/ext/mysql/tests/mysql_fetch_row.phpt +++ b/ext/mysql/tests/mysql_fetch_row.phpt @@ -41,6 +41,7 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [004] array(2) { [0]=> @@ -53,4 +54,4 @@ bool(false) Warning: mysql_fetch_row(): %d is not a valid MySQL result resource in %s on line %d bool(false) -done! \ No newline at end of file +done! diff --git a/ext/mysql/tests/mysql_field_flags.phpt b/ext/mysql/tests/mysql_field_flags.phpt index e07e041d2a38b..7f1b366d5cb1b 100644 --- a/ext/mysql/tests/mysql_field_flags.phpt +++ b/ext/mysql/tests/mysql_field_flags.phpt @@ -144,6 +144,8 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_field_flags() expects exactly 2 parameters, 1 given in %s on line %d Warning: mysql_field_flags(): Field -1 is invalid for MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_field_len.phpt b/ext/mysql/tests/mysql_field_len.phpt index a740c62439dd1..119d3521646c9 100644 --- a/ext/mysql/tests/mysql_field_len.phpt +++ b/ext/mysql/tests/mysql_field_len.phpt @@ -47,6 +47,8 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_field_len() expects exactly 2 parameters, 1 given in %s on line %d Warning: mysql_field_len(): Field -1 is invalid for MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_field_name.phpt b/ext/mysql/tests/mysql_field_name.phpt index c87ac188f7546..85f6c42d93aff 100644 --- a/ext/mysql/tests/mysql_field_name.phpt +++ b/ext/mysql/tests/mysql_field_name.phpt @@ -46,6 +46,8 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_field_name() expects exactly 2 parameters, 1 given in %s on line %d Warning: mysql_field_name(): Field -1 is invalid for MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_field_seek.phpt b/ext/mysql/tests/mysql_field_seek.phpt index 7e8b313c879e7..8487493a88093 100644 --- a/ext/mysql/tests/mysql_field_seek.phpt +++ b/ext/mysql/tests/mysql_field_seek.phpt @@ -44,6 +44,8 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_field_seek(): Field -1 is invalid for MySQL result index %d in %s on line %d bool(false) object(stdClass)#%d (13) { diff --git a/ext/mysql/tests/mysql_field_table.phpt b/ext/mysql/tests/mysql_field_table.phpt index 707d1df987ee2..826651a855d03 100644 --- a/ext/mysql/tests/mysql_field_table.phpt +++ b/ext/mysql/tests/mysql_field_table.phpt @@ -46,6 +46,8 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_field_table() expects exactly 2 parameters, 1 given in %s on line %d Warning: mysql_field_table(): Field -1 is invalid for MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_field_type.phpt b/ext/mysql/tests/mysql_field_type.phpt index c737b4e3f2c68..c767cab6f14bd 100644 --- a/ext/mysql/tests/mysql_field_type.phpt +++ b/ext/mysql/tests/mysql_field_type.phpt @@ -46,6 +46,8 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_field_type() expects exactly 2 parameters, 1 given in %s on line %d Warning: mysql_field_type(): Field -1 is invalid for MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_free_result.phpt b/ext/mysql/tests/mysql_free_result.phpt index fe132d8c2d3c5..90498bd59a276 100644 --- a/ext/mysql/tests/mysql_free_result.phpt +++ b/ext/mysql/tests/mysql_free_result.phpt @@ -44,6 +44,7 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d bool(true) Warning: mysql_free_result(): %d is not a valid MySQL result resource in %s on line %d diff --git a/ext/mysql/tests/mysql_get_host_info.phpt b/ext/mysql/tests/mysql_get_host_info.phpt index 443910c319041..4b21ddbb41ef9 100644 --- a/ext/mysql/tests/mysql_get_host_info.phpt +++ b/ext/mysql/tests/mysql_get_host_info.phpt @@ -41,4 +41,5 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_get_proto_info.phpt b/ext/mysql/tests/mysql_get_proto_info.phpt index 043fb62043a80..3e1481121e104 100644 --- a/ext/mysql/tests/mysql_get_proto_info.phpt +++ b/ext/mysql/tests/mysql_get_proto_info.phpt @@ -31,4 +31,5 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_get_server_info.phpt b/ext/mysql/tests/mysql_get_server_info.phpt index e806335e29c11..ad192e4722cf8 100644 --- a/ext/mysql/tests/mysql_get_server_info.phpt +++ b/ext/mysql/tests/mysql_get_server_info.phpt @@ -36,4 +36,5 @@ if (NULL !== ($tmp = @mysql_get_server_info('too many', 'just too many'))) print "done!"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_info.phpt b/ext/mysql/tests/mysql_info.phpt index 464578c8a568a..c478679042404 100644 --- a/ext/mysql/tests/mysql_info.phpt +++ b/ext/mysql/tests/mysql_info.phpt @@ -70,4 +70,5 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- -done! \ No newline at end of file +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d +done! diff --git a/ext/mysql/tests/mysql_insert_id.phpt b/ext/mysql/tests/mysql_insert_id.phpt index 460d9f3f4d6b6..b69a96ae9ba38 100644 --- a/ext/mysql/tests/mysql_insert_id.phpt +++ b/ext/mysql/tests/mysql_insert_id.phpt @@ -66,6 +66,8 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_insert_id(): %d is not a valid MySQL-Link resource in %s on line %d bool(false) done! diff --git a/ext/mysql/tests/mysql_list_dbs.phpt b/ext/mysql/tests/mysql_list_dbs.phpt index 054e02ef98066..402161aa63366 100644 --- a/ext/mysql/tests/mysql_list_dbs.phpt +++ b/ext/mysql/tests/mysql_list_dbs.phpt @@ -51,4 +51,5 @@ print "done!\n"; require_once("clean_table.inc"); ?> --EXPECTF-- -done! \ No newline at end of file +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d +done! diff --git a/ext/mysql/tests/mysql_list_fields.phpt b/ext/mysql/tests/mysql_list_fields.phpt index e0b3fd5e39368..259a94a39963e 100644 --- a/ext/mysql/tests/mysql_list_fields.phpt +++ b/ext/mysql/tests/mysql_list_fields.phpt @@ -64,6 +64,7 @@ if (!mysql_query("DROP TABLE IF EXISTS test2", $link)) mysql_close($link); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [006] [%d] %s bool(false) Field Offset 0 diff --git a/ext/mysql/tests/mysql_list_processes.phpt b/ext/mysql/tests/mysql_list_processes.phpt index b0c71ad1b41d3..7838a6f98adc9 100644 --- a/ext/mysql/tests/mysql_list_processes.phpt +++ b/ext/mysql/tests/mysql_list_processes.phpt @@ -49,4 +49,5 @@ mysql_close($link); print "done!\n"; ?> --EXPECTF-- -done! \ No newline at end of file +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d +done! diff --git a/ext/mysql/tests/mysql_list_tables.phpt b/ext/mysql/tests/mysql_list_tables.phpt index cf0b1a636d40c..3b753ae37ab44 100644 --- a/ext/mysql/tests/mysql_list_tables.phpt +++ b/ext/mysql/tests/mysql_list_tables.phpt @@ -82,4 +82,5 @@ print "done!\n"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_max_links.phpt b/ext/mysql/tests/mysql_max_links.phpt index 52ecd0ac08336..32096c426e34b 100644 --- a/ext/mysql/tests/mysql_max_links.phpt +++ b/ext/mysql/tests/mysql_max_links.phpt @@ -54,9 +54,19 @@ mysql_close($links[1]); print "done!\n"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_connect(): Too many open links (2) in %s on line %s [030] Cannot connect using host '%s', user '%s', password '****', [0] 0 +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_connect(): Too many open links (2) in %s on line %s [060] Cannot connect using host '%s', user '%s', password '****', [0] 0 array(3) { @@ -67,4 +77,4 @@ array(3) { [2]=> bool(false) } -done! \ No newline at end of file +done! diff --git a/ext/mysql/tests/mysql_max_persistent.phpt b/ext/mysql/tests/mysql_max_persistent.phpt index ac35cd178badd..36f2266665de2 100644 --- a/ext/mysql/tests/mysql_max_persistent.phpt +++ b/ext/mysql/tests/mysql_max_persistent.phpt @@ -90,10 +90,16 @@ if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { mysql_close($link); ?> --EXPECTF-- +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_pconnect(): Too many open persistent links (1) in %s on line %d [020] Cannot connect using host '%s', user '%s', password '****', [0] 0 + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d array(1) { [0]=> resource(%d) of type (mysql link persistent) } -done! \ No newline at end of file +done! diff --git a/ext/mysql/tests/mysql_mysqlnd_read_timeout_long.phpt b/ext/mysql/tests/mysql_mysqlnd_read_timeout_long.phpt index d54cb50708b01..2c67e64878d61 100644 --- a/ext/mysql/tests/mysql_mysqlnd_read_timeout_long.phpt +++ b/ext/mysql/tests/mysql_mysqlnd_read_timeout_long.phpt @@ -30,8 +30,9 @@ max_execution_time=12 print "done!"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d array(1) { [%u|b%"SLEEP(6)"]=> %unicode|string%(1) "0" } -done! \ No newline at end of file +done! diff --git a/ext/mysql/tests/mysql_num_fields.phpt b/ext/mysql/tests/mysql_num_fields.phpt index 0dad5f771d075..4621dc91f83c0 100644 --- a/ext/mysql/tests/mysql_num_fields.phpt +++ b/ext/mysql/tests/mysql_num_fields.phpt @@ -52,5 +52,7 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_num_fields(): %d is not a valid MySQL result resource in %s on line %d done! diff --git a/ext/mysql/tests/mysql_num_rows.phpt b/ext/mysql/tests/mysql_num_rows.phpt index 0f538c4a2b16d..5a803d41f9166 100644 --- a/ext/mysql/tests/mysql_num_rows.phpt +++ b/ext/mysql/tests/mysql_num_rows.phpt @@ -79,6 +79,8 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in %s on line %d Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in %s on line %d diff --git a/ext/mysql/tests/mysql_pconn_disable.phpt b/ext/mysql/tests/mysql_pconn_disable.phpt index 532e2e5788555..6997e5970f56b 100644 --- a/ext/mysql/tests/mysql_pconn_disable.phpt +++ b/ext/mysql/tests/mysql_pconn_disable.phpt @@ -49,6 +49,13 @@ mysql.max_links=2 require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [001] Can connect to the server. [002] Can fetch data using persistent connection! Data = '1' -done! \ No newline at end of file + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d +done! diff --git a/ext/mysql/tests/mysql_pconn_kill.phpt b/ext/mysql/tests/mysql_pconn_kill.phpt index efef4216045ee..eb1feb7b85622 100644 --- a/ext/mysql/tests/mysql_pconn_kill.phpt +++ b/ext/mysql/tests/mysql_pconn_kill.phpt @@ -106,5 +106,12 @@ mysql.max_persistent=2 require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d bool(true) + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_pconn_max_links.phpt b/ext/mysql/tests/mysql_pconn_max_links.phpt index 3eca0e534a833..ced94b3dbf5e8 100644 --- a/ext/mysql/tests/mysql_pconn_max_links.phpt +++ b/ext/mysql/tests/mysql_pconn_max_links.phpt @@ -191,12 +191,17 @@ $host = substr($row['_user'], strrpos($row['_user'], "@") + 1, strlen($row['_use mysql_close($link); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d array(2) { [%u|b%"id"]=> %unicode|string%(1) "1" [%u|b%"label"]=> %unicode|string%(1) "a" } + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d array(2) { [%u|b%"id"]=> %unicode|string%(1) "1" diff --git a/ext/mysql/tests/mysql_pconn_reuse.phpt b/ext/mysql/tests/mysql_pconn_reuse.phpt index ffa5f75f1ba18..26b4ca5f49dab 100644 --- a/ext/mysql/tests/mysql_pconn_reuse.phpt +++ b/ext/mysql/tests/mysql_pconn_reuse.phpt @@ -59,8 +59,17 @@ mysql.max_links=2 print "done!"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [001] Can connect to the server. [002] Can fetch data using persistent connection! Data = '1' +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_connect(): Too many open links (2) in %s on line %d -done! \ No newline at end of file +done! diff --git a/ext/mysql/tests/mysql_pconnect.phpt b/ext/mysql/tests/mysql_pconnect.phpt index 5a7db93ab3044..ec28d2ea8a27e 100644 --- a/ext/mysql/tests/mysql_pconnect.phpt +++ b/ext/mysql/tests/mysql_pconnect.phpt @@ -81,5 +81,17 @@ mysql.allow_persistent=1 print "done!"; ?> --EXPECTF-- +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_pconnect(): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_ping.phpt b/ext/mysql/tests/mysql_ping.phpt index edf18c4391a6e..0308df3396f65 100644 --- a/ext/mysql/tests/mysql_ping.phpt +++ b/ext/mysql/tests/mysql_ping.phpt @@ -42,6 +42,7 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d bool(true) bool(true) bool(true) diff --git a/ext/mysql/tests/mysql_query.phpt b/ext/mysql/tests/mysql_query.phpt index a5978a6c11817..01b14ee28452c 100644 --- a/ext/mysql/tests/mysql_query.phpt +++ b/ext/mysql/tests/mysql_query.phpt @@ -113,6 +113,7 @@ if (!mysql_query('DROP TABLE IF EXISTS test', $link)) { mysql_close($link); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d array(1) { [%u|b%"valid"]=> %unicode|string%(30) "this is sql but with semicolon" diff --git a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt index aa15f5ca12612..c2cb41e0260f0 100644 --- a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt +++ b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt @@ -111,6 +111,9 @@ unlink("./simple.csv"); print "done!"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d [006] [1148] %s [007] [0] '' [008] LOAD DATA not run? diff --git a/ext/mysql/tests/mysql_real_escape_string.phpt b/ext/mysql/tests/mysql_real_escape_string.phpt index 2789ad276c71c..4fdedf7b37389 100644 --- a/ext/mysql/tests/mysql_real_escape_string.phpt +++ b/ext/mysql/tests/mysql_real_escape_string.phpt @@ -33,6 +33,7 @@ assert($tmp === mysql_real_escape_string("foo" . chr(0) . "bar")); print "done!"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d %unicode|string%(31) "Am I a unicode string in PHP 6?" %unicode|string%(2) "\\" %unicode|string%(2) "\"" diff --git a/ext/mysql/tests/mysql_reflection_extension.phpt b/ext/mysql/tests/mysql_reflection_extension.phpt new file mode 100644 index 0000000000000..169036cd5486a --- /dev/null +++ b/ext/mysql/tests/mysql_reflection_extension.phpt @@ -0,0 +1,105 @@ +--TEST-- +ReflectionExtension basics to check API +--SKIPIF-- + +--FILE-- +name); + printf("Version: %s\n", $r->getVersion()); + $classes = $r->getClasses(); + if (!empty($classes)) { + printf("[002] Expecting no class\n"); + asort($classes); + var_dump($classes); + } + + $ignore = array(); + + $functions = $r->getFunctions(); + asort($functions); + printf("Functions:\n"); + foreach ($functions as $func) { + if (isset($ignore[$func->name])) { + unset($ignore[$func->name]); + } else { + printf(" %s\n", $func->name); + } + } + if (!empty($ignore)) { + printf("Dumping version dependent and missing functions\n"); + var_dump($ignore); + } + + + print "done!"; +?> +--EXPECTF-- +Name: mysql +Version: 1.0 +Functions: + mysql + mysql_affected_rows + mysql_client_encoding + mysql_close + mysql_connect + mysql_data_seek + mysql_db_name + mysql_db_query + mysql_dbname + mysql_errno + mysql_error + mysql_escape_string + mysql_fetch_array + mysql_fetch_assoc + mysql_fetch_field + mysql_fetch_lengths + mysql_fetch_object + mysql_fetch_row + mysql_field_flags + mysql_field_len + mysql_field_name + mysql_field_seek + mysql_field_table + mysql_field_type + mysql_fieldflags + mysql_fieldlen + mysql_fieldname + mysql_fieldtable + mysql_fieldtype + mysql_free_result + mysql_freeresult + mysql_get_client_info + mysql_get_host_info + mysql_get_proto_info + mysql_get_server_info + mysql_info + mysql_insert_id + mysql_list_dbs + mysql_list_fields + mysql_list_processes + mysql_list_tables + mysql_listdbs + mysql_listfields + mysql_listtables + mysql_num_fields + mysql_num_rows + mysql_numfields + mysql_numrows + mysql_pconnect + mysql_ping + mysql_query + mysql_real_escape_string + mysql_result + mysql_select_db + mysql_selectdb + mysql_set_charset + mysql_stat + mysql_table_name + mysql_tablename + mysql_thread_id + mysql_unbuffered_query +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_reflection_functions.phpt b/ext/mysql/tests/mysql_reflection_functions.phpt new file mode 100644 index 0000000000000..4f2710d806fab --- /dev/null +++ b/ext/mysql/tests/mysql_reflection_functions.phpt @@ -0,0 +1,387 @@ +--TEST-- +ReflectionFunction to check API +--SKIPIF-- + +--FILE-- +getFunctions(); + asort($functions); + printf("Functions:\n"); + foreach ($functions as $func) { + if (isset($ignore[$func->name])) + continue; + + printf(" %s\n", $func->name); + $rf = new ReflectionFunction($func->name); + printf(" Deprecated: %s\n", $rf->isDeprecated() ? "yes" : "no"); + printf(" Accepted parameters: %d\n", $rf->getNumberOfParameters()); + printf(" Required parameters: %d\n", $rf->getNumberOfRequiredParameters()); + foreach( $rf->getParameters() as $param ) { + printf(" %s\n", $param); + } + } + + print "done!"; +?> +--EXPECTF-- +Functions: + mysql + Deprecated: yes + Accepted parameters: 3 + Required parameters: 2 + Parameter #0 [ $database_name ] + Parameter #1 [ $query ] + Parameter #2 [ $link_identifier ] + mysql_affected_rows + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_client_encoding + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_close + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_connect + Deprecated: no + Accepted parameters: 5 + Required parameters: 0 + Parameter #0 [ $hostname ] + Parameter #1 [ $username ] + Parameter #2 [ $password ] + Parameter #3 [ $new ] + Parameter #4 [ $flags ] + mysql_data_seek + Deprecated: no + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $row_number ] + mysql_db_name + Deprecated: no + Accepted parameters: 3 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $row ] + Parameter #2 [ $field ] + mysql_db_query + Deprecated: yes + Accepted parameters: 3 + Required parameters: 2 + Parameter #0 [ $database_name ] + Parameter #1 [ $query ] + Parameter #2 [ $link_identifier ] + mysql_dbname + Deprecated: yes + Accepted parameters: 3 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $row ] + Parameter #2 [ $field ] + mysql_errno + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_error + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_escape_string + Deprecated: no + Accepted parameters: 1 + Required parameters: 1 + Parameter #0 [ $string ] + mysql_fetch_array + Deprecated: no + Accepted parameters: 2 + Required parameters: 1 + Parameter #0 [ $result ] + Parameter #1 [ $result_type ] + mysql_fetch_assoc + Deprecated: no + Accepted parameters: 1 + Required parameters: 1 + Parameter #0 [ $result ] + mysql_fetch_field + Deprecated: no + Accepted parameters: 2 + Required parameters: 1 + Parameter #0 [ $result ] + Parameter #1 [ $field_offset ] + mysql_fetch_lengths + Deprecated: no + Accepted parameters: 1 + Required parameters: 1 + Parameter #0 [ $result ] + mysql_fetch_object + Deprecated: no + Accepted parameters: 3 + Required parameters: 1 + Parameter #0 [ $result ] + Parameter #1 [ $class_name ] + Parameter #2 [ $ctor_params ] + mysql_fetch_row + Deprecated: no + Accepted parameters: 1 + Required parameters: 1 + Parameter #0 [ $result ] + mysql_field_flags + Deprecated: no + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $field_offset ] + mysql_field_len + Deprecated: no + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $field_offset ] + mysql_field_name + Deprecated: no + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $field_index ] + mysql_field_seek + Deprecated: no + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $field_offset ] + mysql_field_table + Deprecated: no + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $field_offset ] + mysql_field_type + Deprecated: no + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $field_offset ] + mysql_fieldflags + Deprecated: yes + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $field_offset ] + mysql_fieldlen + Deprecated: yes + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $field_offset ] + mysql_fieldname + Deprecated: yes + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $field_index ] + mysql_fieldtable + Deprecated: yes + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $field_offset ] + mysql_fieldtype + Deprecated: yes + Accepted parameters: 2 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $field_offset ] + mysql_free_result + Deprecated: no + Accepted parameters: 1 + Required parameters: 1 + Parameter #0 [ $result ] + mysql_freeresult + Deprecated: yes + Accepted parameters: 1 + Required parameters: 1 + Parameter #0 [ $result ] + mysql_get_client_info + Deprecated: no + Accepted parameters: 0 + Required parameters: 0 + mysql_get_host_info + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_get_proto_info + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_get_server_info + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_info + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_insert_id + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_list_dbs + Deprecated: yes + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_list_fields + Deprecated: no + Accepted parameters: 3 + Required parameters: 2 + Parameter #0 [ $database_name ] + Parameter #1 [ $table_name ] + Parameter #2 [ $link_identifier ] + mysql_list_processes + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_list_tables + Deprecated: yes + Accepted parameters: 2 + Required parameters: 1 + Parameter #0 [ $database_name ] + Parameter #1 [ $link_identifier ] + mysql_listdbs + Deprecated: yes + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_listfields + Deprecated: yes + Accepted parameters: 3 + Required parameters: 2 + Parameter #0 [ $database_name ] + Parameter #1 [ $table_name ] + Parameter #2 [ $link_identifier ] + mysql_listtables + Deprecated: yes + Accepted parameters: 2 + Required parameters: 1 + Parameter #0 [ $database_name ] + Parameter #1 [ $link_identifier ] + mysql_num_fields + Deprecated: no + Accepted parameters: 1 + Required parameters: 1 + Parameter #0 [ $result ] + mysql_num_rows + Deprecated: no + Accepted parameters: 1 + Required parameters: 1 + Parameter #0 [ $result ] + mysql_numfields + Deprecated: yes + Accepted parameters: 1 + Required parameters: 1 + Parameter #0 [ $result ] + mysql_numrows + Deprecated: yes + Accepted parameters: 1 + Required parameters: 1 + Parameter #0 [ $result ] + mysql_pconnect + Deprecated: no + Accepted parameters: 4 + Required parameters: 0 + Parameter #0 [ $hostname ] + Parameter #1 [ $username ] + Parameter #2 [ $password ] + Parameter #3 [ $flags ] + mysql_ping + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_query + Deprecated: no + Accepted parameters: 2 + Required parameters: 1 + Parameter #0 [ $query ] + Parameter #1 [ $link_identifier ] + mysql_real_escape_string + Deprecated: no + Accepted parameters: 2 + Required parameters: 1 + Parameter #0 [ $string ] + Parameter #1 [ $link_identifier ] + mysql_result + Deprecated: no + Accepted parameters: 3 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $row ] + Parameter #2 [ $field ] + mysql_select_db + Deprecated: no + Accepted parameters: 2 + Required parameters: 1 + Parameter #0 [ $database_name ] + Parameter #1 [ $link_identifier ] + mysql_selectdb + Deprecated: yes + Accepted parameters: 2 + Required parameters: 1 + Parameter #0 [ $database_name ] + Parameter #1 [ $link_identifier ] + mysql_set_charset + Deprecated: no + Accepted parameters: 2 + Required parameters: 1 + Parameter #0 [ $charset_name ] + Parameter #1 [ $link_identifier ] + mysql_stat + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_table_name + Deprecated: no + Accepted parameters: 3 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $row ] + Parameter #2 [ $field ] + mysql_tablename + Deprecated: no + Accepted parameters: 3 + Required parameters: 2 + Parameter #0 [ $result ] + Parameter #1 [ $row ] + Parameter #2 [ $field ] + mysql_thread_id + Deprecated: no + Accepted parameters: 1 + Required parameters: 0 + Parameter #0 [ $link_identifier ] + mysql_unbuffered_query + Deprecated: no + Accepted parameters: 2 + Required parameters: 1 + Parameter #0 [ $query ] + Parameter #1 [ $link_identifier ] +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_result.phpt b/ext/mysql/tests/mysql_result.phpt index 2c7c618547e66..0a58b9b88340a 100644 --- a/ext/mysql/tests/mysql_result.phpt +++ b/ext/mysql/tests/mysql_result.phpt @@ -65,6 +65,8 @@ print "done!"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_result(): Unable to jump to row -1 on MySQL result index %d in %s on line %d bool(false) diff --git a/ext/mysql/tests/mysql_select_db.phpt b/ext/mysql/tests/mysql_select_db.phpt index 211e34222ea16..e9bc99aa736d9 100644 --- a/ext/mysql/tests/mysql_select_db.phpt +++ b/ext/mysql/tests/mysql_select_db.phpt @@ -66,6 +66,7 @@ if (false !== ($tmp = mysql_select_db($db, $link))) print "done!\n"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d %unicode|string%(%d) "%s" bool(false) diff --git a/ext/mysql/tests/mysql_set_charset.phpt b/ext/mysql/tests/mysql_set_charset.phpt index 953323b49c39d..a0bccd8c31ad6 100644 --- a/ext/mysql/tests/mysql_set_charset.phpt +++ b/ext/mysql/tests/mysql_set_charset.phpt @@ -58,4 +58,5 @@ mysql_close($link); print "done!"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d done! diff --git a/ext/mysql/tests/mysql_stat.phpt b/ext/mysql/tests/mysql_stat.phpt index 30a840a2a15db..d6a34df581add 100644 --- a/ext/mysql/tests/mysql_stat.phpt +++ b/ext/mysql/tests/mysql_stat.phpt @@ -44,5 +44,7 @@ if (false !== ($tmp = mysql_stat($link))) print "done!"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_stat(): %d is not a valid MySQL-Link resource in %s on line %d done! diff --git a/ext/mysql/tests/mysql_tablename.phpt b/ext/mysql/tests/mysql_tablename.phpt index 2415e4fda0f00..4bbe54d443c3e 100644 --- a/ext/mysql/tests/mysql_tablename.phpt +++ b/ext/mysql/tests/mysql_tablename.phpt @@ -42,6 +42,8 @@ mysql_close($link); print "done!"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_tablename() expects at least 2 parameters, 1 given in %s on line %d Warning: mysql_tablename(): Unable to jump to row -1 on MySQL result index %d in %s on line %d diff --git a/ext/mysql/tests/mysql_thread_id.phpt b/ext/mysql/tests/mysql_thread_id.phpt index b05bb3ed1c01a..aa95d319449a2 100644 --- a/ext/mysql/tests/mysql_thread_id.phpt +++ b/ext/mysql/tests/mysql_thread_id.phpt @@ -35,5 +35,7 @@ if (false !== ($tmp = mysql_thread_id($link))) print "done!"; ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d + Warning: mysql_thread_id(): %d is not a valid MySQL-Link resource in %s on line %d -done! \ No newline at end of file +done! diff --git a/ext/mysql/tests/mysql_trace_mode.phpt b/ext/mysql/tests/mysql_trace_mode.phpt index 2b6c61d27bb1b..7655975d70c65 100644 --- a/ext/mysql/tests/mysql_trace_mode.phpt +++ b/ext/mysql/tests/mysql_trace_mode.phpt @@ -29,6 +29,7 @@ print "done!\n"; require_once("clean_table.inc"); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d I don\'t mind character sets, do I?\n Warning: mysql_query(): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BOGUS_SQL' at line 1 in %s on line %d done! diff --git a/ext/mysql/tests/mysql_unbuffered_query.phpt b/ext/mysql/tests/mysql_unbuffered_query.phpt index ad9b4fbc5240a..8754b58b59069 100644 --- a/ext/mysql/tests/mysql_unbuffered_query.phpt +++ b/ext/mysql/tests/mysql_unbuffered_query.phpt @@ -107,6 +107,7 @@ if (!mysql_query('DROP TABLE IF EXISTS test', $link)) { mysql_close($link); ?> --EXPECTF-- +Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d array(1) { [%u|b%"valid"]=> %unicode|string%(30) "this is sql but with semicolon" diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index a4c1b874fdcb4..1731bb70f4693 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -699,6 +699,10 @@ PHP_MINIT_FUNCTION(mysqli) REGISTER_LONG_CONSTANT("MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", MYSQL_OPT_SSL_VERIFY_SERVER_CERT, CONST_CS | CONST_PERSISTENT); #endif +#if MYSQL_VERSION_ID > 50605 || defined(MYSQLI_USE_MYSQLND) + REGISTER_LONG_CONSTANT("MYSQLI_SERVER_PUBLIC_KEY", MYSQL_SERVER_PUBLIC_KEY, CONST_CS | CONST_PERSISTENT); +#endif + /* mysqli_real_connect flags */ REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_SSL", CLIENT_SSL, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_COMPRESS",CLIENT_COMPRESS, CONST_CS | CONST_PERSISTENT); @@ -842,6 +846,16 @@ PHP_MINIT_FUNCTION(mysqli) REGISTER_LONG_CONSTANT("MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS", MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, CONST_CS | CONST_PERSISTENT); #endif + REGISTER_LONG_CONSTANT("MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT", TRANS_START_WITH_CONSISTENT_SNAPSHOT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_TRANS_START_READ_WRITE", TRANS_START_READ_WRITE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_TRANS_START_READ_ONLY", TRANS_START_READ_ONLY, CONST_CS | CONST_PERSISTENT); + + REGISTER_LONG_CONSTANT("MYSQLI_TRANS_COR_AND_CHAIN", TRANS_COR_AND_CHAIN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_TRANS_COR_AND_NO_CHAIN", TRANS_COR_AND_NO_CHAIN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_TRANS_COR_RELEASE", TRANS_COR_RELEASE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_TRANS_COR_NO_RELEASE", TRANS_COR_NO_RELEASE, CONST_CS | CONST_PERSISTENT); + + #ifdef MYSQLI_USE_MYSQLND mysqlnd_reverse_api_register_api(&mysqli_reverse_api TSRMLS_CC); #endif @@ -1324,218 +1338,6 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags } /* }}} */ - -#if !defined(MYSQLI_USE_MYSQLND) - -#define ALLOC_CALLBACK_ARGS(a, b, c)\ -if (c) {\ - a = (zval ***)safe_emalloc(c, sizeof(zval **), 0);\ - for (i = b; i < c; i++) {\ - a[i] = emalloc(sizeof(zval *));\ - MAKE_STD_ZVAL(*a[i]);\ - }\ -} - -#define FREE_CALLBACK_ARGS(a, b, c)\ -if (a) {\ - for (i=b; i < c; i++) {\ - zval_ptr_dtor(a[i]);\ - efree(a[i]);\ - }\ - efree(a);\ -} - -#define LOCAL_INFILE_ERROR_MSG(source,dest)\ - memset(source, 0, LOCAL_INFILE_ERROR_LEN);\ - memcpy(source, dest, MIN(strlen(dest), LOCAL_INFILE_ERROR_LEN-1));\ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", dest); - - -/* {{{ php_local_infile_init - */ -static int php_local_infile_init(void **ptr, const char *filename, void *userdata) -{ - mysqli_local_infile *data; - MY_MYSQL *mysql; - php_stream_context *context = NULL; - - TSRMLS_FETCH(); - - /* save pointer to MY_MYSQL structure (userdata) */ - if (!(*ptr= data= ((mysqli_local_infile *)calloc(1, sizeof(mysqli_local_infile))))) { - return 1; - } - - if (!(mysql = (MY_MYSQL *)userdata)) { - LOCAL_INFILE_ERROR_MSG(data->error_msg, ER(CR_UNKNOWN_ERROR)); - return 1; - } - - /* check open_basedir */ - if (PG(open_basedir)) { - if (php_check_open_basedir_ex(filename, 0 TSRMLS_CC) == -1) { - LOCAL_INFILE_ERROR_MSG(data->error_msg, "open_basedir restriction in effect. Unable to open file"); - return 1; - } - } - - mysql->li_stream = php_stream_open_wrapper_ex((char *)filename, "r", 0, NULL, context); - - if (mysql->li_stream == NULL) { - snprintf((char *)data->error_msg, sizeof(data->error_msg), "Can't find file '%-.64s'.", filename); - return 1; - } - - data->userdata = mysql; - - return 0; -} -/* }}} */ - -/* {{{ int php_local_infile_read */ -static int php_local_infile_read(void *ptr, char *buf, uint buf_len) -{ - mysqli_local_infile *data; - MY_MYSQL *mysql; - zval ***callback_args; - zval *retval; - zval *fp; - int argc = 4; - int i; - long rc; - - TSRMLS_FETCH(); - - data= (mysqli_local_infile *)ptr; - mysql = data->userdata; - - /* default processing */ - if (!mysql->li_read) { - int count = (int)php_stream_read(mysql->li_stream, buf, buf_len); - - if (count < 0) { - LOCAL_INFILE_ERROR_MSG(data->error_msg, ER(2)); - } - - return count; - } - - ALLOC_CALLBACK_ARGS(callback_args, 1, argc); - - /* set parameters: filepointer, buffer, buffer_len, errormsg */ - - MAKE_STD_ZVAL(fp); - php_stream_to_zval(mysql->li_stream, fp); - callback_args[0] = &fp; - ZVAL_STRING(*callback_args[1], "", 1); - ZVAL_LONG(*callback_args[2], buf_len); - ZVAL_STRING(*callback_args[3], "", 1); - - if (call_user_function_ex(EG(function_table), - NULL, - mysql->li_read, - &retval, - argc, - callback_args, - 0, - NULL TSRMLS_CC) == SUCCESS) { - - rc = Z_LVAL_P(retval); - zval_ptr_dtor(&retval); - - if (rc > 0) { - if (rc >= 0 && rc != Z_STRLEN_P(*callback_args[1])) { - LOCAL_INFILE_ERROR_MSG(data->error_msg, - "Mismatch between the return value of the callback and the content " - "length of the buffer."); - rc = -1; - } else if (rc > buf_len) { - /* check buffer overflow */ - LOCAL_INFILE_ERROR_MSG(data->error_msg, "Too much data returned"); - rc = -1; - } else { - memcpy(buf, Z_STRVAL_P(*callback_args[1]), MIN(rc, Z_STRLEN_P(*callback_args[1]))); - } - } else if (rc < 0) { - LOCAL_INFILE_ERROR_MSG(data->error_msg, Z_STRVAL_P(*callback_args[3])); - } - } else { - LOCAL_INFILE_ERROR_MSG(data->error_msg, "Can't execute load data local init callback function"); - rc = -1; - } - /* - If the (ab)user has closed the file handle we should - not try to use it anymore or even close it - */ - if (!zend_rsrc_list_get_rsrc_type(Z_LVAL_P(fp) TSRMLS_CC)) { - LOCAL_INFILE_ERROR_MSG(data->error_msg, "File handle closed"); - rc = -1; - /* Thus the end handler won't try to free already freed memory */ - mysql->li_stream = NULL; - } - - FREE_CALLBACK_ARGS(callback_args, 1, argc); - efree(fp); - return rc; -} -/* }}} */ - -/* {{{ php_local_infile_error - */ -static int php_local_infile_error(void *ptr, char *error_msg, uint error_msg_len) -{ - mysqli_local_infile *data = (mysqli_local_infile *) ptr; - - if (data) { - strlcpy(error_msg, data->error_msg, error_msg_len); - return 2000; - } - strlcpy(error_msg, ER(CR_OUT_OF_MEMORY), error_msg_len); - return CR_OUT_OF_MEMORY; -} -/* }}} */ - -/* {{{ php_local_infile_end - */ -static void php_local_infile_end(void *ptr) -{ - mysqli_local_infile *data; - MY_MYSQL *mysql; - - TSRMLS_FETCH(); - - data= (mysqli_local_infile *)ptr; - - if (!data || !(mysql = data->userdata)) { - if (data) { - free(data); - } - return; - } - - if (mysql->li_stream) { - php_stream_close(mysql->li_stream); - } - free(data); - return; -} -/* }}} */ - - -/* {{{ void php_set_local_infile_handler_default -*/ -void php_set_local_infile_handler_default(MY_MYSQL *mysql) { - /* register internal callback functions */ - mysql_set_local_infile_handler(mysql->mysql, &php_local_infile_init, &php_local_infile_read, - &php_local_infile_end, &php_local_infile_error, (void *)mysql); - if (mysql->li_read) { - zval_ptr_dtor(&mysql->li_read); - mysql->li_read = NULL; - } -} -/* }}} */ -#endif - /* * Local variables: * tab-width: 4 diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 2cda0aa903cf4..3d651fc204741 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -30,6 +30,7 @@ #include "php_ini.h" #include "php_globals.h" #include "ext/standard/info.h" +#include "ext/standard/php_smart_str.h" #include "php_mysqli_structs.h" #include "mysqli_priv.h" @@ -566,14 +567,17 @@ PHP_FUNCTION(mysqli_character_set_name) { MY_MYSQL *mysql; zval *mysql_link; + const char *cs_name; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); - - RETURN_STRING((char *)mysql_character_set_name(mysql->mysql), 1); + cs_name = mysql_character_set_name(mysql->mysql); + if (cs_name) { + RETURN_STRING(cs_name, 1); + } } /* }}} */ @@ -632,18 +636,86 @@ PHP_FUNCTION(mysqli_close) } /* }}} */ + +#if !defined(MYSQLI_USE_MYSQLND) +/* {{{ mysqli_tx_cor_options_to_string */ +static void mysqli_tx_cor_options_to_string(const MYSQL * const conn, smart_str * str, const unsigned int mode) +{ + if (mode & TRANS_COR_AND_CHAIN && !(mode & TRANS_COR_AND_NO_CHAIN)) { + if (str->len) { + smart_str_appendl(str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(str, "AND CHAIN", sizeof("AND CHAIN") - 1); + } else if (mode & TRANS_COR_AND_NO_CHAIN && !(mode & TRANS_COR_AND_CHAIN)) { + if (str->len) { + smart_str_appendl(str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(str, "AND NO CHAIN", sizeof("AND NO CHAIN") - 1); + } + + if (mode & TRANS_COR_RELEASE && !(mode & TRANS_COR_NO_RELEASE)) { + if (str->len) { + smart_str_appendl(str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(str, "RELEASE", sizeof("RELEASE") - 1); + } else if (mode & TRANS_COR_NO_RELEASE && !(mode & TRANS_COR_RELEASE)) { + if (str->len) { + smart_str_appendl(str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(str, "NO RELEASE", sizeof("NO RELEASE") - 1); + } + smart_str_0(str); +} +/* }}} */ + + +/* {{{ proto bool mysqli_commit_or_rollback_libmysql */ +static int mysqli_commit_or_rollback_libmysql(MYSQL * conn, zend_bool commit, const unsigned int mode, const char * const name) +{ + int ret; + smart_str tmp_str = {0, 0, 0}; + mysqli_tx_cor_options_to_string(conn, &tmp_str, mode); + smart_str_0(&tmp_str); + + { + char * commented_name = NULL; + unsigned int commented_name_len = name? spprintf(&commented_name, 0, " /*%s*/", name):0; + char * query; + unsigned int query_len = spprintf(&query, 0, (commit? "COMMIT%s %s":"ROLLBACK%s %s"), + commented_name? commented_name:"", tmp_str.c? tmp_str.c:""); + smart_str_free(&tmp_str); + + ret = mysql_real_query(conn, query, query_len); + efree(query); + if (commented_name) { + efree(commented_name); + } + } +} +/* }}} */ +#endif + + /* {{{ proto bool mysqli_commit(object link) Commit outstanding actions and close transaction */ PHP_FUNCTION(mysqli_commit) { MY_MYSQL *mysql; zval *mysql_link; + long flags = TRANS_COR_NO_OPT; + char * name = NULL; + int name_len = 0; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|ls", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); - if (mysql_commit(mysql->mysql)) { + +#if !defined(MYSQLI_USE_MYSQLND) + if (mysqli_commit_or_rollback_libmysql(mysql->mysql, TRUE, flags, name)) { +#else + if (FAIL == mysqlnd_commit(mysql->mysql, flags, name)) { +#endif RETURN_FALSE; } RETURN_TRUE; @@ -732,12 +804,16 @@ PHP_FUNCTION(mysqli_error) { MY_MYSQL *mysql; zval *mysql_link; + const char *err; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); - RETURN_STRING((char *)mysql_error(mysql->mysql),1); + err = mysql_error(mysql->mysql); + if (err) { + RETURN_STRING(err, 1); + } } /* }}} */ @@ -1268,7 +1344,10 @@ PHP_FUNCTION(mysqli_free_result) Get MySQL client info */ PHP_FUNCTION(mysqli_get_client_info) { - RETURN_STRING((char *)mysql_get_client_info(), 1); + const char * info = mysql_get_client_info(); + if (info) { + RETURN_STRING(info, 1); + } } /* }}} */ @@ -1320,15 +1399,18 @@ PHP_FUNCTION(mysqli_get_server_info) { MY_MYSQL *mysql; zval *mysql_link = NULL; + const char *info; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); - RETURN_STRING((char *)mysql_get_server_info(mysql->mysql), 1); + info = mysql_get_server_info(mysql->mysql); + if (info) { + RETURN_STRING(info, 1); + } } - /* }}} */ /* {{{ proto int mysqli_get_server_version(object link) @@ -1361,7 +1443,9 @@ PHP_FUNCTION(mysqli_info) MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); info = mysql_info(mysql->mysql); - RETURN_STRING((info) ? (char *)info : "", 1); + if (info) { + RETURN_STRING(info, 1); + } } /* }}} */ @@ -1456,64 +1540,6 @@ PHP_FUNCTION(mysqli_kill) } /* }}} */ -/* {{{ proto void mysqli_set_local_infile_default(object link) - unsets user defined handler for load local infile command */ -#if !defined(MYSQLI_USE_MYSQLND) -PHP_FUNCTION(mysqli_set_local_infile_default) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); - - if (mysql->li_read) { - zval_ptr_dtor(&(mysql->li_read)); - mysql->li_read = NULL; - } -} -/* }}} */ - -/* {{{ proto bool mysqli_set_local_infile_handler(object link, callback read_func) - Set callback functions for LOAD DATA LOCAL INFILE */ -PHP_FUNCTION(mysqli_set_local_infile_handler) -{ - MY_MYSQL *mysql; - zval *mysql_link; - char *callback_name; - zval *callback_func; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz", &mysql_link, mysqli_link_class_entry, - &callback_func) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); - - /* check callback function */ - if (!zend_is_callable(callback_func, 0, &callback_name TSRMLS_CC)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not a valid callback function %s", callback_name); - efree(callback_name); - RETURN_FALSE; - } - efree(callback_name); - - /* save callback function */ - if (!mysql->li_read) { - MAKE_STD_ZVAL(mysql->li_read); - } else { - zval_dtor(mysql->li_read); - } - ZVAL_ZVAL(mysql->li_read, callback_func, 1, 0); - - RETURN_TRUE; -} -#endif -/* }}} */ - /* {{{ proto bool mysqli_more_results(object link) check if there any more query results from a multi query */ PHP_FUNCTION(mysqli_more_results) @@ -1645,10 +1671,10 @@ static int mysqli_options_get_option_zval_type(int option) #endif /* MYSQLI_USE_MYSQLND */ case MYSQL_OPT_CONNECT_TIMEOUT: #ifdef MYSQL_REPORT_DATA_TRUNCATION - case MYSQL_REPORT_DATA_TRUNCATION: + case MYSQL_REPORT_DATA_TRUNCATION: #endif - case MYSQL_OPT_LOCAL_INFILE: - case MYSQL_OPT_NAMED_PIPE: + case MYSQL_OPT_LOCAL_INFILE: + case MYSQL_OPT_NAMED_PIPE: #ifdef MYSQL_OPT_PROTOCOL case MYSQL_OPT_PROTOCOL: #endif /* MySQL 4.1.0 */ @@ -1664,7 +1690,7 @@ static int mysqli_options_get_option_zval_type(int option) case MYSQL_OPT_RECONNECT: #endif /* MySQL 5.0.13 */ #ifdef MYSQL_OPT_SSL_VERIFY_SERVER_CERT - case MYSQL_OPT_SSL_VERIFY_SERVER_CERT: + case MYSQL_OPT_SSL_VERIFY_SERVER_CERT: #endif /* MySQL 5.0.23 */ #ifdef MYSQL_OPT_COMPRESS case MYSQL_OPT_COMPRESS: @@ -1688,6 +1714,9 @@ static int mysqli_options_get_option_zval_type(int option) case MYSQL_INIT_COMMAND: case MYSQL_SET_CHARSET_NAME: case MYSQL_SET_CHARSET_DIR: +#if MYSQL_VERSION_ID > 50605 || defined(MYSQLI_USE_MYSQLND) + case MYSQL_SERVER_PUBLIC_KEY: +#endif return IS_STRING; default: @@ -1912,19 +1941,27 @@ PHP_FUNCTION(mysqli_real_escape_string) { } /* }}} */ + /* {{{ proto bool mysqli_rollback(object link) Undo actions from current transaction */ PHP_FUNCTION(mysqli_rollback) { MY_MYSQL *mysql; zval *mysql_link; + long flags = TRANS_COR_NO_OPT; + char * name = NULL; + int name_len = 0; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|ls", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); - if (mysql_rollback(mysql->mysql)) { +#if !defined(MYSQLI_USE_MYSQLND) + if (mysqli_commit_or_rollback_libmysql(mysql->mysql, FALSE, flags, name)) { +#else + if (FAIL == mysqlnd_rollback(mysql->mysql, flags, name)) { +#endif RETURN_FALSE; } RETURN_TRUE; @@ -2154,12 +2191,16 @@ PHP_FUNCTION(mysqli_sqlstate) { MY_MYSQL *mysql; zval *mysql_link; + const char *state; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); - RETURN_STRING((char *)mysql_sqlstate(mysql->mysql),1); + state = mysql_sqlstate(mysql->mysql); + if (state) { + RETURN_STRING(state, 1); + } } /* }}} */ @@ -2337,13 +2378,17 @@ PHP_FUNCTION(mysqli_stmt_error) { MY_STMT *stmt; zval *mysql_stmt; + const char * err; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_INITIALIZED); - RETURN_STRING((char *)mysql_stmt_error(stmt->stmt),1); + err = mysql_stmt_error(stmt->stmt); + if (err) { + RETURN_STRING(err, 1); + } } /* }}} */ @@ -2482,13 +2527,17 @@ PHP_FUNCTION(mysqli_stmt_sqlstate) { MY_STMT *stmt; zval *mysql_stmt; + const char * state; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID); - RETURN_STRING((char *)mysql_stmt_sqlstate(stmt->stmt),1); + state = mysql_stmt_sqlstate(stmt->stmt); + if (state) { + RETURN_STRING(state, 1); + } } /* }}} */ diff --git a/ext/mysqli/mysqli_fe.c b/ext/mysqli/mysqli_fe.c index 8bcb02fdc5640..6f2e404087843 100644 --- a/ext/mysqli/mysqli_fe.c +++ b/ext/mysqli/mysqli_fe.c @@ -86,6 +86,56 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_autocommit, 0, 0, 1) ZEND_ARG_INFO(0, mode) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_begin_transaction, 0, 0, 1) + MYSQLI_ZEND_ARG_OBJ_INFO_LINK() + ZEND_ARG_INFO(0, flags) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_begin_transaction, 0, 0, 0) + ZEND_ARG_INFO(0, flags) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_savepoint, 0, 0, 2) + MYSQLI_ZEND_ARG_OBJ_INFO_LINK() + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_savepoint, 0, 0, 1) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_release_savepoint, 0, 0, 2) + MYSQLI_ZEND_ARG_OBJ_INFO_LINK() + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_release_savepoint, 0, 0, 1) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_commit, 0, 0, 1) + MYSQLI_ZEND_ARG_OBJ_INFO_LINK() + ZEND_ARG_INFO(0, flags) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_commit, 0, 0, 0) + ZEND_ARG_INFO(0, flags) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_rollback, 0, 0, 1) + MYSQLI_ZEND_ARG_OBJ_INFO_LINK() + ZEND_ARG_INFO(0, flags) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_rollback, 0, 0, 0) + ZEND_ARG_INFO(0, flags) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_change_user, 0, 0, 4) MYSQLI_ZEND_ARG_OBJ_INFO_LINK() @@ -200,16 +250,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_kill, 0, 0, 1) ZEND_ARG_INFO(0, connection_id) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_set_local_infile_handler, 0, 0, 2) - MYSQLI_ZEND_ARG_OBJ_INFO_LINK() - ZEND_ARG_INFO(0, read_callback) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_set_local_infile_handler, 0, 0, 1) - MYSQLI_ZEND_ARG_OBJ_INFO_LINK() - ZEND_ARG_INFO(0, read_callback) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_query, 0, 0, 2) MYSQLI_ZEND_ARG_OBJ_INFO_LINK() ZEND_ARG_INFO(0, query) @@ -336,10 +376,11 @@ ZEND_END_ARG_INFO() const zend_function_entry mysqli_functions[] = { PHP_FE(mysqli_affected_rows, arginfo_mysqli_only_link) PHP_FE(mysqli_autocommit, arginfo_mysqli_autocommit) + PHP_FE(mysqli_begin_transaction, arginfo_mysqli_begin_transaction) PHP_FE(mysqli_change_user, arginfo_mysqli_change_user) PHP_FE(mysqli_character_set_name, arginfo_mysqli_only_link) PHP_FE(mysqli_close, arginfo_mysqli_only_link) - PHP_FE(mysqli_commit, arginfo_mysqli_only_link) + PHP_FE(mysqli_commit, arginfo_mysqli_commit) PHP_FE(mysqli_connect, arginfo_mysqli_connect) PHP_FE(mysqli_connect_errno, arginfo_mysqli_no_params) PHP_FE(mysqli_connect_error, arginfo_mysqli_no_params) @@ -388,10 +429,6 @@ const zend_function_entry mysqli_functions[] = { PHP_FE(mysqli_info, arginfo_mysqli_only_link) PHP_FE(mysqli_insert_id, arginfo_mysqli_only_link) PHP_FE(mysqli_kill, arginfo_mysqli_kill) -#if !defined(MYSQLI_USE_MYSQLND) - PHP_FE(mysqli_set_local_infile_default, arginfo_mysqli_only_link) - PHP_FE(mysqli_set_local_infile_handler, arginfo_mysqli_set_local_infile_handler) -#endif PHP_FE(mysqli_more_results, arginfo_mysqli_only_link) PHP_FE(mysqli_multi_query, arginfo_mysqli_query) PHP_FE(mysqli_next_result, arginfo_mysqli_only_link) @@ -411,7 +448,9 @@ const zend_function_entry mysqli_functions[] = { #if defined(MYSQLI_USE_MYSQLND) PHP_FE(mysqli_reap_async_query, arginfo_mysqli_only_link) #endif - PHP_FE(mysqli_rollback, arginfo_mysqli_only_link) + PHP_FE(mysqli_release_savepoint, arginfo_mysqli_release_savepoint) + PHP_FE(mysqli_rollback, arginfo_mysqli_rollback) + PHP_FE(mysqli_savepoint, arginfo_mysqli_savepoint) PHP_FE(mysqli_select_db, arginfo_mysqli_select_db) #ifdef HAVE_MYSQLI_SET_CHARSET PHP_FE(mysqli_set_charset, arginfo_mysqli_set_charset) @@ -472,10 +511,11 @@ const zend_function_entry mysqli_functions[] = { */ const zend_function_entry mysqli_link_methods[] = { PHP_FALIAS(autocommit, mysqli_autocommit, arginfo_class_mysqli_autocommit) + PHP_FALIAS(begin_transaction, mysqli_begin_transaction, arginfo_class_mysqli_begin_transaction) PHP_FALIAS(change_user,mysqli_change_user, arginfo_class_mysqli_change_user) PHP_FALIAS(character_set_name, mysqli_character_set_name, arginfo_mysqli_no_params) PHP_FALIAS(close, mysqli_close, arginfo_mysqli_no_params) - PHP_FALIAS(commit, mysqli_commit, arginfo_mysqli_no_params) + PHP_FALIAS(commit, mysqli_commit, arginfo_class_mysqli_commit) PHP_FALIAS(connect, mysqli_connect, arginfo_mysqli_connect) PHP_FALIAS(dump_debug_info, mysqli_dump_debug_info, arginfo_mysqli_no_params) PHP_FALIAS(debug, mysqli_debug, arginfo_mysqli_debug) @@ -490,10 +530,6 @@ const zend_function_entry mysqli_link_methods[] = { PHP_FALIAS(get_warnings, mysqli_get_warnings, arginfo_mysqli_no_params) PHP_FALIAS(init,mysqli_init, arginfo_mysqli_no_params) PHP_FALIAS(kill,mysqli_kill, arginfo_class_mysqli_kill) -#if !defined(MYSQLI_USE_MYSQLND) - PHP_FALIAS(set_local_infile_default, mysqli_set_local_infile_default, arginfo_mysqli_no_params) - PHP_FALIAS(set_local_infile_handler, mysqli_set_local_infile_handler, arginfo_class_mysqli_set_local_infile_handler) -#endif PHP_FALIAS(multi_query, mysqli_multi_query, arginfo_class_mysqli_query) PHP_FALIAS(mysqli, mysqli_link_construct, arginfo_mysqli_connect) PHP_FALIAS(more_results, mysqli_more_results, arginfo_mysqli_no_params) @@ -512,7 +548,9 @@ const zend_function_entry mysqli_link_methods[] = { #endif PHP_FALIAS(escape_string, mysqli_real_escape_string, arginfo_class_mysqli_real_escape_string) PHP_FALIAS(real_query, mysqli_real_query, arginfo_class_mysqli_query) - PHP_FALIAS(rollback,mysqli_rollback, arginfo_mysqli_no_params) + PHP_FALIAS(release_savepoint, mysqli_release_savepoint, arginfo_class_mysqli_release_savepoint) + PHP_FALIAS(rollback, mysqli_rollback, arginfo_class_mysqli_rollback) + PHP_FALIAS(savepoint, mysqli_savepoint, arginfo_class_mysqli_savepoint) PHP_FALIAS(select_db,mysqli_select_db, arginfo_class_mysqli_select_db) #ifdef HAVE_MYSQLI_SET_CHARSET PHP_FALIAS(set_charset, mysqli_set_charset, arginfo_class_mysqli_set_charset) diff --git a/ext/mysqli/mysqli_fe.h b/ext/mysqli/mysqli_fe.h index d3e900003e608..7e447c63e5a48 100644 --- a/ext/mysqli/mysqli_fe.h +++ b/ext/mysqli/mysqli_fe.h @@ -25,6 +25,7 @@ PHP_FUNCTION(mysqli); PHP_FUNCTION(mysqli_affected_rows); PHP_FUNCTION(mysqli_autocommit); +PHP_FUNCTION(mysqli_begin_transaction); PHP_FUNCTION(mysqli_change_user); PHP_FUNCTION(mysqli_character_set_name); PHP_FUNCTION(mysqli_set_charset); @@ -107,6 +108,8 @@ PHP_FUNCTION(mysqli_sqlstate); PHP_FUNCTION(mysqli_ssl_set); PHP_FUNCTION(mysqli_stat); PHP_FUNCTION(mysqli_refresh); +PHP_FUNCTION(mysqli_savepoint); +PHP_FUNCTION(mysqli_release_savepoint); PHP_FUNCTION(mysqli_stmt_affected_rows); PHP_FUNCTION(mysqli_stmt_close); PHP_FUNCTION(mysqli_stmt_data_seek); @@ -136,4 +139,3 @@ PHP_METHOD(mysqli_warning,__construct); #endif /* MYSQLI_FE_H */ - diff --git a/ext/mysqli/mysqli_libmysql.h b/ext/mysqli/mysqli_libmysql.h index 3a7b91b9956fd..e10e3702ea762 100644 --- a/ext/mysqli/mysqli_libmysql.h +++ b/ext/mysqli/mysqli_libmysql.h @@ -42,6 +42,18 @@ #define mysqli_change_user_silent(c, u, p, d, p_len) mysql_change_user((c), (u), (p), (d)) +#define TRANS_START_NO_OPT 0 +#define TRANS_START_WITH_CONSISTENT_SNAPSHOT 1 +#define TRANS_START_READ_WRITE 2 +#define TRANS_START_READ_ONLY 4 + +#define TRANS_COR_NO_OPT 0 +#define TRANS_COR_AND_CHAIN 1 +#define TRANS_COR_AND_NO_CHAIN 2 +#define TRANS_COR_RELEASE 4 +#define TRANS_COR_NO_RELEASE 8 + + /* These functions also reside in ext/mysqlnd/mysqlnd_portability.h but since it is only made available if one wants to build mysqli against mysqlnd and they are useful for libmysql as diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index 2ad1a2040565d..c3a56fca39ed4 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -29,6 +29,7 @@ #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" +#include "ext/standard/php_smart_str.h" #include "php_mysqli_structs.h" #include "mysqli_priv.h" @@ -259,9 +260,6 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne #if !defined(MYSQLI_USE_MYSQLND) mysql->mysql->reconnect = MyG(reconnect); - - /* set our own local_infile handler */ - php_set_local_infile_handler_default(mysql); #endif mysql_options(mysql->mysql, MYSQL_OPT_LOCAL_INFILE, (char *)&MyG(allow_local_infile)); @@ -737,7 +735,7 @@ static int mysqlnd_dont_poll_zval_array_from_mysqlnd_array(MYSQLND **in_array, z int ret = 0; ALLOC_HASHTABLE(new_hash); - zend_hash_init(new_hash, zend_hash_num_elements(Z_ARRVAL_P(in_zval_array)), NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(new_hash, in_zval_array? zend_hash_num_elements(Z_ARRVAL_P(in_zval_array)):0, NULL, ZVAL_PTR_DTOR, 0); if (in_array) { for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(in_zval_array)); zend_hash_get_current_data(Z_ARRVAL_P(in_zval_array), (void **) &elem) == SUCCESS; @@ -1048,6 +1046,150 @@ PHP_FUNCTION(mysqli_get_charset) /* }}} */ #endif + +#if !defined(MYSQLI_USE_MYSQLND) +/* {{{ proto bool mysqli_begin_transaction_libmysql */ +static int mysqli_begin_transaction_libmysql(MYSQL * conn, const unsigned int mode, const char * const name) +{ + int ret; + smart_str tmp_str = {0, 0, 0}; + if (mode & TRANS_START_WITH_CONSISTENT_SNAPSHOT) { + if (tmp_str.len) { + smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(&tmp_str, "WITH CONSISTENT SNAPSHOT", sizeof("WITH CONSISTENT SNAPSHOT") - 1); + } + if (mode & TRANS_START_READ_WRITE) { + if (tmp_str.len) { + smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1); + } + if (mode & TRANS_START_READ_ONLY) { + if (tmp_str.len) { + smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 1); + } + smart_str_0(&tmp_str); + + { + char * commented_name = NULL; + unsigned int commented_name_len = name? spprintf(&commented_name, 0, " /*%s*/", name):0; + char * query; + unsigned int query_len = spprintf(&query, 0, "START TRANSACTION%s %s", + commented_name? commented_name:"", tmp_str.c? tmp_str.c:""); + smart_str_free(&tmp_str); + + ret = mysql_real_query(conn, query, query_len); + efree(query); + if (commented_name) { + efree(commented_name); + } + } + return ret; +} +/* }}} */ +#endif + +/* {{{ proto bool mysqli_begin_transaction(object link, [int flags [, string name]]) + Starts a transaction */ +PHP_FUNCTION(mysqli_begin_transaction) +{ + MY_MYSQL *mysql; + zval *mysql_link; + long flags = TRANS_START_NO_OPT; + char * name = NULL; + int name_len = 0; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|ls", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) { + return; + } + MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); + +#if !defined(MYSQLI_USE_MYSQLND) + if (mysqli_begin_transaction_libmysql(mysql->mysql, flags, name)) { + RETURN_FALSE; + } +#else + if (FAIL == mysqlnd_begin_transaction(mysql->mysql, flags, name)) { + RETURN_FALSE; + } +#endif + RETURN_TRUE; +} +/* }}} */ + + +#if !defined(MYSQLI_USE_MYSQLND) +/* {{{ proto bool mysqli_savepoint_libmysql */ +static int mysqli_savepoint_libmysql(MYSQL * conn, const char * const name, zend_bool release) +{ + int ret; + char * query; + unsigned int query_len = spprintf(&query, 0, release? "RELEASE SAVEPOINT `%s`":"SAVEPOINT `%s`", name); + ret = mysql_real_query(conn, query, query_len); + efree(query); + return ret; +} +/* }}} */ +#endif + + +/* {{{ proto bool mysqli_savepoint(object link, string name) + Starts a transaction */ +PHP_FUNCTION(mysqli_savepoint) +{ + MY_MYSQL *mysql; + zval *mysql_link; + char * name = NULL; + int name_len = 0; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &name, &name_len) == FAILURE) { + return; + } + MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); + +#if !defined(MYSQLI_USE_MYSQLND) + if (mysqli_savepoint_libmysql(mysql->mysql, name, FALSE)) { +#else + if (FAIL == mysqlnd_savepoint(mysql->mysql, name)) { +#endif + RETURN_FALSE; + } + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto bool mysqli_release_savepoint(object link, string name) + Starts a transaction */ +PHP_FUNCTION(mysqli_release_savepoint) +{ + MY_MYSQL *mysql; + zval *mysql_link; + char * name = NULL; + int name_len = 0; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &name, &name_len) == FAILURE) { + return; + } + MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); + if (!name || !name_len) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Savepoint name not provided"); + } +#if !defined(MYSQLI_USE_MYSQLND) + if (mysqli_savepoint_libmysql(mysql->mysql, name, TRUE)) { +#else + if (FAIL == mysqlnd_savepoint(mysql->mysql, name)) { +#endif + RETURN_FALSE; + } + RETURN_TRUE; +} +/* }}} */ + + /* * Local variables: * tab-width: 4 diff --git a/ext/mysqli/mysqli_priv.h b/ext/mysqli/mysqli_priv.h index f85f0295712cc..d823ea89eb563 100644 --- a/ext/mysqli/mysqli_priv.h +++ b/ext/mysqli/mysqli_priv.h @@ -76,7 +76,6 @@ extern void php_clear_warnings(MYSQLI_WARNING *w); extern void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type); extern void php_mysqli_report_error(const char *sqlstate, int errorno, const char *error TSRMLS_DC); extern void php_mysqli_report_index(const char *query, unsigned int status TSRMLS_DC); -extern void php_set_local_infile_handler_default(MY_MYSQL *); extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...); #ifdef HAVE_SPL diff --git a/ext/mysqli/mysqli_prop.c b/ext/mysqli/mysqli_prop.c index f50371bf0dc57..bd9cee28f1d50 100644 --- a/ext/mysqli/mysqli_prop.c +++ b/ext/mysqli/mysqli_prop.c @@ -253,8 +253,8 @@ MYSQLI_MAP_PROPERTY_FUNC_LONG(link_thread_id_read, mysql_thread_id, MYSQLI_GET_M MYSQLI_MAP_PROPERTY_FUNC_LONG(link_warning_count_read, mysql_warning_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong, "%lu") /* {{{ property link_stat_read */ -static int link_stat_read(mysqli_object *obj, zval **retval TSRMLS_DC)\ -{\ +static int link_stat_read(mysqli_object *obj, zval **retval TSRMLS_DC) +{ MY_MYSQL *mysql; MAKE_STD_ZVAL(*retval); diff --git a/ext/mysqli/mysqli_report.h b/ext/mysqli/mysqli_report.h deleted file mode 100644 index 34d0a661ff0cb..0000000000000 --- a/ext/mysqli/mysqli_report.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -#ifndef __HAVE_MYSQLI_PROFILER_H__ -#define __HAVE_MYSQLI_PROFILER_H__ - -#ifdef PHP_WIN32 -#include -#include -#include "win32/time.h" -#else -#include -#include -#include -#include -#include -#endif - -typedef struct { - struct timeval starttime, - endtime; /* execution time */ -} PR_TIME_INFO; - - -#define MYSQLI_PR_REPORT_STDERR 1 -#define MYSQLI_PR_REPORT_PORT 2 - - - -/*** PROFILER MACROS ***/ -#define MYSQLI_PROFILER_STARTTIME(ptr) if (MyG(profiler.mode)) gettimeofday(&ptr.starttime, NULL) -#define MYSQLI_PROFILER_ENDTIME(ptr) if (MyG(profiler.mode)) gettimeofday(&ptr.endtime, NULL) -#define MYSQLI_PROFILER_REPORT(_type, _time, ptr) if (MyG(profiler.mode)) php_mysqli_profiler_report(_type, _time, (void *)ptr) - - - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/package.xml b/ext/mysqli/package.xml index 6de81d7a9374b..c27316a055d08 100644 --- a/ext/mysqli/package.xml +++ b/ext/mysqli/package.xml @@ -43,7 +43,6 @@ package.xml added to support installation using pear installer - diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h index 1f7e761c400ca..8b329bb5d02f1 100644 --- a/ext/mysqli/php_mysqli_structs.h +++ b/ext/mysqli/php_mysqli_structs.h @@ -130,12 +130,6 @@ typedef struct { #endif } MY_MYSQL; -typedef struct { - int mode; - int socket; - FILE *fp; -} PROFILER; - typedef struct { void *ptr; /* resource: (mysql, result, stmt) */ void *info; /* additional buffer */ @@ -164,12 +158,6 @@ typedef struct _mysqli_property_entry { int (*w_func)(mysqli_object *obj, zval *value TSRMLS_DC); } mysqli_property_entry; -#if !defined(MYSQLI_USE_MYSQLND) -typedef struct { - char error_msg[LOCAL_INFILE_ERROR_LEN]; - void *userdata; -} mysqli_local_infile; -#endif typedef struct { zend_ptr_stack free_links; diff --git a/ext/mysqli/tests/057.phpt b/ext/mysqli/tests/057.phpt index 2cb887506aa4f..7c7e2b7568ee2 100644 --- a/ext/mysqli/tests/057.phpt +++ b/ext/mysqli/tests/057.phpt @@ -35,8 +35,8 @@ require_once('skipifconnectfailure.inc'); var_dump(mysqli_stmt_reset($stmt)); var_dump($stmt = mysqli_prepare($link, "SELECT * FROM test_store_result")); - if ($IS_MYSQLND && $stmt->affected_rows !== -1) - printf("[001] Expecting -1, got %d\n", $stmt->affected_rows); + if ($stmt->affected_rows !== 0) + printf("[001] Expecting 0, got %d\n", $stmt->affected_rows); var_dump(mysqli_stmt_execute($stmt)); var_dump($stmt = @mysqli_prepare($link, "SELECT * FROM test_store_result"), mysqli_error($link)); diff --git a/ext/mysqli/tests/connect.inc b/ext/mysqli/tests/connect.inc index 3a9d8ec258c8c..4acc20cb9195c 100644 --- a/ext/mysqli/tests/connect.inc +++ b/ext/mysqli/tests/connect.inc @@ -129,99 +129,6 @@ } } - function my_get_charsets($link) { - - /* Those tree are set by SET NAMES */ - $charsets = array( - 'client' => NULL, - 'results' => NULL, - 'connection' => NULL, - ); - - if (!($res = mysqli_query($link, "SHOW VARIABLES LIKE '%character%'"))) { - printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link)); - return $charsets; - } - - $names = array(); - while ($row = mysqli_fetch_assoc($res)) { - $names[$row['Variable_name']] = $row['Value']; - } - mysqli_free_result($res); - - if (!($res = mysqli_query($link, sprintf("SHOW CHARACTER SET LIKE '%s'", $names['character_set_client']))) || - !($details = mysqli_fetch_assoc($res))) { - printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link)); - return $charsets; - } - mysqli_free_result($res); - - $charsets['client'] = array( - 'charset' => $details['Charset'], - 'desc' => $details['Description'], - 'collation' => $details['Default collation'], - 'maxlen' => $details['Maxlen'], - 'nr' => NULL, - ); - - if (!($res = mysqli_query($link, sprintf("SHOW COLLATION LIKE '%s'", $details['Default collation']))) || - !($collation = mysqli_fetch_assoc($res))) { - printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link)); - return $charsets; - } - mysqli_free_result($res); - $charsets['client']['nr'] = $collation['Id']; - - if (!($res = mysqli_query($link, sprintf("SHOW CHARACTER SET LIKE '%s'", $names['character_set_results']))) || - !($details = mysqli_fetch_assoc($res))) { - printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link)); - return $charsets; - } - mysqli_free_result($res); - - $charsets['results'] = array( - 'charset' => $details['Charset'], - 'desc' => $details['Description'], - 'collation' => $details['Default collation'], - 'maxlen' => $details['Maxlen'], - 'nr' => NULL, - ); - - if (!($res = mysqli_query($link, sprintf("SHOW COLLATION LIKE '%s'", $details['Default collation']))) || - !($collation = mysqli_fetch_assoc($res))) { - printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link)); - return $charsets; - } - mysqli_free_result($res); - $charsets['results']['nr'] = $collation['Id']; - - - if (!($res = mysqli_query($link, sprintf("SHOW CHARACTER SET LIKE '%s'", $names['character_set_connection']))) || - !($details = mysqli_fetch_assoc($res))) { - printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link)); - return $charsets; - } - mysqli_free_result($res); - - $charsets['connection'] = array( - 'charset' => $details['Charset'], - 'desc' => $details['Description'], - 'collation' => $details['Default collation'], - 'maxlen' => $details['Maxlen'], - 'nr' => NULL, - ); - - if (!($res = mysqli_query($link, sprintf("SHOW COLLATION LIKE '%s'", $details['Default collation']))) || - !($collation = mysqli_fetch_assoc($res))) { - printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link)); - return $charsets; - } - mysqli_free_result($res); - $charsets['connection']['nr'] = $collation['Id']; - - return $charsets; - } - function have_innodb($link) { if (($res = $link->query("SHOW VARIABLES LIKE 'have_innodb'")) && ($row = $res->fetch_row()) && diff --git a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt index df7d1c6580719..ea86c198e716a 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt @@ -20,38 +20,41 @@ require_once('skipifconnectfailure.inc'); $methods = get_class_methods($mysqli); $expected_methods = array( 'autocommit' => true, + 'begin_transaction' => true, 'change_user' => true, - 'character_set_name' => true, - 'close' => true, - 'commit' => true, - 'connect' => true, + 'character_set_name' => true, + 'close' => true, + 'commit' => true, + 'connect' => true, 'dump_debug_info' => true, 'escape_string' => true, 'get_charset' => true, 'get_client_info' => true, 'get_server_info' => true, 'get_warnings' => true, - 'init' => true, - 'kill' => true, + 'init' => true, + 'kill' => true, 'more_results' => true, 'multi_query' => true, - 'mysqli' => true, + 'mysqli' => true, 'next_result' => true, - 'options' => true, - 'ping' => true, - 'prepare' => true, - 'query' => true, + 'options' => true, + 'ping' => true, + 'prepare' => true, + 'query' => true, 'real_connect' => true, - 'real_escape_string' => true, + 'real_escape_string' => true, 'real_query' => true, - 'refresh' => true, - 'rollback' => true, - 'select_db' => true, + 'refresh' => true, + 'rollback' => true, + 'release_savepoint' => true, + 'savepoint' => true, + 'select_db' => true, 'set_charset' => true, - 'set_opt' => true, - 'ssl_set' => true, - 'stat' => true, - 'stmt_init' => true, + 'set_opt' => true, + 'ssl_set' => true, + 'stat' => true, + 'stmt_init' => true, 'store_result' => true, 'thread_safe' => true, 'use_result' => true, @@ -67,12 +70,6 @@ require_once('skipifconnectfailure.inc'); $expected_methods['get_connection_stats'] = true; $expected_methods['reap_async_query'] = true; $expected_methods['poll'] = true; - } else { - // libmysql only - if (function_exists('mysqli_ssl_set')) - $expected_methods['ssl_set'] = true; - $expected_methods['set_local_infile_default'] = true; - $expected_methods['set_local_infile_handler'] = true; } /* we should add ruled when to expect them */ @@ -301,7 +298,7 @@ mysqli->insert_id = '0'/integer ('0'/integer) mysqli->sqlstate = '00000'/%unicode|string% ('00000'/%unicode|string%) mysqli->stat = 'Uptime: %d Threads: %d Questions: %d Slow queries: %d Opens: %d Flush tables: %d Open tables: %d Queries per second avg: %d.%d'/string ('Uptime: %d Threads: %d Questions: %d Slow queries: %d Opens: %d Flush tables: %d Open tables: %d Queries per second avg: %d.%d'/string) mysqli->host_info = '%s'/%unicode|string% ('%s'/%unicode|string%) -mysqli->info = ''/NULL (''/%unicode|string%) +mysqli->info = ''/NULL (''/NULL) mysqli->thread_id = '%d'/integer ('%d'/integer) mysqli->protocol_version = '%d'/integer ('%d'/integer) mysqli->server_info = '%s'/%unicode|string% ('%s'/%unicode|string%) diff --git a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt index 5fd4b6f45cd06..259fcd9ae6785 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt @@ -6,8 +6,6 @@ require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); -if (($tmp = substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.'))) && ($tmp < 5)) - die("skip Reflection not available before PHP 5 (found PHP $tmp)"); /* Let's not deal with cross-version issues in the EXPECTF/UEXPECTF. Most of the things which we test are covered by mysqli_class_*_interface.phpt. @@ -120,6 +118,36 @@ isPassedByReference: no isOptional: no isDefaultValueAvailable: no +Inspecting method 'begin_transaction' +isFinal: no +isAbstract: no +isPublic: yes +isPrivate: no +isProtected: no +isStatic: no +isConstructor: no +isDestructor: no +isInternal: yes +isUserDefined: no +returnsReference: no +Modifiers: 256 +Number of Parameters: 2 +Number of Required Parameters: 0 + +Inspecting parameter 'flags' of method 'begin_transaction' +isArray: no +allowsNull: no +isPassedByReference: no +isOptional: yes +isDefaultValueAvailable: no + +Inspecting parameter 'name' of method 'begin_transaction' +isArray: no +allowsNull: no +isPassedByReference: no +isOptional: yes +isDefaultValueAvailable: no + Inspecting method 'change_user' isFinal: no isAbstract: no @@ -202,9 +230,23 @@ isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 -Number of Parameters: 0 +Number of Parameters: 2 Number of Required Parameters: 0 +Inspecting parameter 'flags' of method 'commit' +isArray: no +allowsNull: no +isPassedByReference: no +isOptional: yes +isDefaultValueAvailable: no + +Inspecting parameter 'name' of method 'commit' +isArray: no +allowsNull: no +isPassedByReference: no +isOptional: yes +isDefaultValueAvailable: no + Inspecting method 'connect' isFinal: no isAbstract: no @@ -850,6 +892,29 @@ isPassedByReference: no isOptional: no isDefaultValueAvailable: no +Inspecting method 'release_savepoint' +isFinal: no +isAbstract: no +isPublic: yes +isPrivate: no +isProtected: no +isStatic: no +isConstructor: no +isDestructor: no +isInternal: yes +isUserDefined: no +returnsReference: no +Modifiers: 256 +Number of Parameters: 1 +Number of Required Parameters: 1 + +Inspecting parameter 'name' of method 'release_savepoint' +isArray: no +allowsNull: no +isPassedByReference: no +isOptional: no +isDefaultValueAvailable: no + Inspecting method 'rollback' isFinal: no isAbstract: no @@ -863,9 +928,46 @@ isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 -Number of Parameters: 0 +Number of Parameters: 2 Number of Required Parameters: 0 +Inspecting parameter 'flags' of method 'rollback' +isArray: no +allowsNull: no +isPassedByReference: no +isOptional: yes +isDefaultValueAvailable: no + +Inspecting parameter 'name' of method 'rollback' +isArray: no +allowsNull: no +isPassedByReference: no +isOptional: yes +isDefaultValueAvailable: no + +Inspecting method 'savepoint' +isFinal: no +isAbstract: no +isPublic: yes +isPrivate: no +isProtected: no +isStatic: no +isConstructor: no +isDestructor: no +isInternal: yes +isUserDefined: no +returnsReference: no +Modifiers: 256 +Number of Parameters: 1 +Number of Required Parameters: 1 + +Inspecting parameter 'name' of method 'savepoint' +isArray: no +allowsNull: no +isPassedByReference: no +isOptional: no +isDefaultValueAvailable: no + Inspecting method 'select_db' isFinal: no isAbstract: no diff --git a/ext/mysqli/tests/mysqli_commit_oo.phpt b/ext/mysqli/tests/mysqli_commit_oo.phpt index 34ec4bfcdca6e..e19f698e8193d 100644 --- a/ext/mysqli/tests/mysqli_commit_oo.phpt +++ b/ext/mysqli/tests/mysqli_commit_oo.phpt @@ -28,12 +28,8 @@ if (!have_innodb($link)) printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); - if (!is_null($tmp = @$mysqli->commit($link))) - printf("[002] Expecting NULL/NULL, got %s/%s, [%d] %s\n", - gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); - if (true !== ($tmp = $mysqli->commit())) - printf("[014] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); + printf("[002] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); if (true !== ($tmp = $mysqli->autocommit(false))) printf("[003] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); diff --git a/ext/mysqli/tests/mysqli_constants.phpt b/ext/mysqli/tests/mysqli_constants.phpt index 8bdc849f785fc..7c6dacd3934c5 100644 --- a/ext/mysqli/tests/mysqli_constants.phpt +++ b/ext/mysqli/tests/mysqli_constants.phpt @@ -32,7 +32,7 @@ require_once('skipifconnectfailure.inc'); "MYSQLI_ASSOC" => true, "MYSQLI_NUM" => true, "MYSQLI_BOTH" => true, - "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH" => true, + "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH"=> true, "MYSQLI_NOT_NULL_FLAG" => true, "MYSQLI_PRI_KEY_FLAG" => true, "MYSQLI_UNIQUE_KEY_FLAG" => true, @@ -86,14 +86,21 @@ require_once('skipifconnectfailure.inc'); "MYSQLI_SET_CHARSET_NAME" => true, "MYSQLI_SET_CHARSET_DIR" => true, "MYSQLI_REFRESH_GRANT" => true, - "MYSQLI_REFRESH_LOG" => true, + "MYSQLI_REFRESH_LOG" => true, "MYSQLI_REFRESH_TABLES" => true, "MYSQLI_REFRESH_HOSTS" => true, "MYSQLI_REFRESH_STATUS" => true, "MYSQLI_REFRESH_THREADS" => true, "MYSQLI_REFRESH_SLAVE" => true, "MYSQLI_REFRESH_MASTER" => true, - "MYSQLI_DEBUG_TRACE_ENABLED" => true, + "MYSQLI_DEBUG_TRACE_ENABLED" => true, + "MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT" => true, + "MYSQLI_TRANS_START_READ_WRITE" => true, + "MYSQLI_TRANS_START_READ_ONLY" => true, + "MYSQLI_TRANS_COR_AND_CHAIN" => true, + "MYSQLI_TRANS_COR_AND_NO_CHAIN" => true, + "MYSQLI_TRANS_COR_RELEASE" => true, + "MYSQLI_TRANS_COR_NO_RELEASE" => true, ); /* depends on the build - experimental */ @@ -125,6 +132,12 @@ require_once('skipifconnectfailure.inc'); $expected_constants['MYSQLI_SERVER_QUERY_WAS_SLOW'] = true; } + + /* First introduced in MySQL 6.0, backported to MySQL 5.5 */ + if ($version >= 50606 || $IS_MYSQLND) { + $expected_constants['MYSQLI_SERVER_PUBLIC_KEY'] = true; + } + if ($version > 50002) { $expected_constants = array_merge($expected_constants, array( "MYSQLI_TYPE_NEWDECIMAL" => true, diff --git a/ext/mysqli/tests/mysqli_fetch_field.phpt b/ext/mysqli/tests/mysqli_fetch_field.phpt index d1d358b342183..2b9108072b413 100644 --- a/ext/mysqli/tests/mysqli_fetch_field.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field.phpt @@ -22,7 +22,13 @@ require_once('skipifconnectfailure.inc'); require('table.inc'); - $charsets = my_get_charsets($link); + // Make sure that client, connection and result charsets are all the + // same. Not sure whether this is strictly necessary. + if (!mysqli_set_charset($link, 'utf8')) + printf("[%d] %s\n", mysqli_errno($link), mysqli_errno($link)); + + $charsetInfo = mysqli_get_charset($link); + if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } @@ -34,19 +40,17 @@ require_once('skipifconnectfailure.inc'); /* label column, result set charset */ $tmp = mysqli_fetch_field($res); var_dump($tmp); - if ($tmp->charsetnr != $charsets['results']['nr']) { + if ($tmp->charsetnr != $charsetInfo->number) { printf("[004] Expecting charset %s/%d got %d\n", - $charsets['results']['charset'], - $charsets['results']['nr'], $tmp->charsetnr); + $charsetInfo->charset, $charsetInfo->number, $tmp->charsetnr); } - if ($tmp->length != (1 * $charsets['results']['maxlen'])) { + if ($tmp->length != $charsetInfo->max_length) { printf("[005] Expecting length %d got %d\n", - $charsets['results']['maxlen'], - $tmp->max_length); + $charsetInfo->max_length, $tmp->max_length); } if ($tmp->db != $db) { printf("011] Expecting database '%s' got '%s'\n", - $db, $tmp->db); + $db, $tmp->db); } var_dump(mysqli_fetch_field($res)); @@ -174,4 +178,4 @@ object(stdClass)#%d (13) { [%u|b%"decimals"]=> int(0) } -done! \ No newline at end of file +done! diff --git a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt index 2d5ad261b1315..8c5609b163d2e 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt @@ -27,7 +27,12 @@ require_once('skipifconnectfailure.inc'); if (!is_null($tmp = @$res->fetch_field($link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - $charsets = my_get_charsets($link); + // Make sure that client, connection and result charsets are all the + // same. Not sure whether this is strictly necessary. + if (!$mysqli->set_charset('utf8')) + printf("[%d] %s\n", $mysqli->errno, $mysqli->errno); + + $charsetInfo = $mysqli->get_charset(); if (!$res = $mysqli->query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) { printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); @@ -37,18 +42,16 @@ require_once('skipifconnectfailure.inc'); $tmp = $res->fetch_field(); var_dump($tmp); - if ($tmp->charsetnr != $charsets['results']['nr']) { + if ($tmp->charsetnr != $charsetInfo->number) { printf("[005] Expecting charset %s/%d got %d\n", - $charsets['results']['charset'], - $charsets['results']['nr'], $tmp->charsetnr); + $charsetInfo->charset, $charsetInfo->number, $tmp->charsetnr); } - if ($tmp->length != (1 * $charsets['results']['maxlen'])) { + if ($tmp->length != $charsetInfo->max_length) { printf("[006] Expecting length %d got %d\n", - $charsets['results']['maxlen'], - $tmp->max_length); + $charsetInfo->max_length, $tmp->max_length); } if ($tmp->db != $db) { - printf("008] Expecting database '%s' got '%s'\n", + printf("[007] Expecting database '%s' got '%s'\n", $db, $tmp->db); } @@ -126,4 +129,4 @@ object(stdClass)#%d (13) { bool(false) Warning: mysqli_result::fetch_field(): Couldn't fetch mysqli_result in %s on line %d -done! \ No newline at end of file +done! diff --git a/ext/mysqli/tests/mysqli_fetch_fields.phpt b/ext/mysqli/tests/mysqli_fetch_fields.phpt index 479c71cbbc5a8..6b66d6f231f33 100644 --- a/ext/mysqli/tests/mysqli_fetch_fields.phpt +++ b/ext/mysqli/tests/mysqli_fetch_fields.phpt @@ -21,7 +21,13 @@ require_once('skipifconnectfailure.inc'); printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); - $charsets = my_get_charsets($link); + + // Make sure that client, connection and result charsets are all the + // same. Not sure whether this is strictly necessary. + if (!mysqli_set_charset($link, 'utf8')) + printf("[%d] %s\n", mysqli_errno($link), mysqli_errno($link)); + + $charsetInfo = mysqli_get_charset($link); if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); @@ -33,14 +39,14 @@ require_once('skipifconnectfailure.inc'); switch ($k) { case 1: /* label column, result set charset */ - if ($field->charsetnr != $charsets['results']['nr']) { + if ($field->charsetnr != $charsetInfo->number) { printf("[004] Expecting charset %s/%d got %d\n", - $charsets['results']['charset'], - $charsets['results']['nr'], $field->charsetnr); + $charsetInfo->charset, + $charsetInfo->number, $field->charsetnr); } - if ($field->length != (1 * $charsets['results']['maxlen'])) { + if ($field->length != $charsetInfo->max_length) { printf("[005] Expecting length %d got %d\n", - $charsets['results']['maxlen'], + $charsetInfo->max_length, $field->max_length); } break; @@ -118,4 +124,4 @@ object(stdClass)#%d (13) { } Warning: mysqli_fetch_fields(): Couldn't fetch mysqli_result in %s on line %d -done! \ No newline at end of file +done! diff --git a/ext/mysqli/tests/mysqli_field_seek.phpt b/ext/mysqli/tests/mysqli_field_seek.phpt index a747bdfa019a3..449d2f90d4155 100644 --- a/ext/mysqli/tests/mysqli_field_seek.phpt +++ b/ext/mysqli/tests/mysqli_field_seek.phpt @@ -66,7 +66,13 @@ require_once('skipifconnectfailure.inc'); printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); - $charsets = my_get_charsets($link); + + // Make sure that client, connection and result charsets are all the + // same. Not sure whether this is strictly necessary. + if (!mysqli_set_charset($link, 'utf8')) + printf("[%d] %s\n", mysqli_errno($link), mysqli_errno($link)); + + $charsetInfo = mysqli_get_charset($link); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1", MYSQLI_USE_RESULT)) { printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); @@ -81,15 +87,13 @@ require_once('skipifconnectfailure.inc'); $field = mysqli_fetch_field($res); var_dump($field); /* label column, result set charset */ - if ($field->charsetnr != $charsets['results']['nr']) { + if ($field->charsetnr != $charsetInfo->number) { printf("[004] Expecting charset %s/%d got %d\n", - $charsets['results']['charset'], - $charsets['results']['nr'], $field->charsetnr); + $charsetInfo->charset, $charsetInfo->number, $field->charsetnr); } - if ($field->length != (1 * $charsets['results']['maxlen'])) { + if ($field->length != $charsetInfo->max_length) { printf("[005] Expecting length %d got %d\n", - $charsets['results']['maxlen'], - $field->max_length); + $charsetInfo->max_length, $field->max_length); } var_dump(mysqli_field_tell($res)); @@ -217,7 +221,7 @@ bool(false) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d bool(false) bool(true) -object(stdClass)#3 (13) { +object(stdClass)#%d (13) { [%u|b%"name"]=> %unicode|string%(5) "_null" [%u|b%"orgname"]=> @@ -248,4 +252,4 @@ object(stdClass)#3 (13) { Warning: mysqli_field_seek(): Couldn't fetch mysqli_result in %s on line %d NULL -done! \ No newline at end of file +done! diff --git a/ext/mysqli/tests/mysqli_info.phpt b/ext/mysqli/tests/mysqli_info.phpt index 2d5004fe6e38e..6bb5d215e034e 100644 --- a/ext/mysqli/tests/mysqli_info.phpt +++ b/ext/mysqli/tests/mysqli_info.phpt @@ -21,8 +21,8 @@ require_once('skipifconnectfailure.inc'); printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // NOTE: empty string, no multiple insert syntax - if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp)) - printf("[004] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); + if (!is_null($tmp = mysqli_info($link)) || ('' != $tmp)) + printf("[004] Expecting null, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (101, 'a'), (102, 'b')")) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); @@ -54,8 +54,8 @@ require_once('skipifconnectfailure.inc'); if (!$res = mysqli_query($link, "SELECT 1")) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp)) - printf("[014] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); + if (!is_null($tmp = mysqli_info($link)) || ('' != $tmp)) + printf("[014] Expecting null, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); // NOTE: no LOAD DATA INFILE test diff --git a/ext/mysqli/tests/mysqli_pam_sha256.phpt b/ext/mysqli/tests/mysqli_pam_sha256.phpt new file mode 100644 index 0000000000000..3016e200d727b --- /dev/null +++ b/ext/mysqli/tests/mysqli_pam_sha256.phpt @@ -0,0 +1,113 @@ +--TEST-- +PAM: SHA-256 +--SKIPIF-- +query("SHOW PLUGINS"))) { + die(sprintf("skip [%d] %s\n", $link->errno, $link->error)); +} + +$found = false; +while ($row = $res->fetch_assoc()) { + if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) { + $found = true; + break; + } +} +if (!$found) + die("skip SHA-256 server plugin unavailable"); + +if (!($res = $link->query("SHOW STATUS LIKE 'Rsa_public_key'"))) { + die(sprintf("skip [%d] %s\n", $link->errno, $link->error)); +} + +if (!($row = $res->fetch_assoc())) { + die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error)); +} + +if (strlen($row['Value']) < 100) { + die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error)); +} + +if (!$link->query("SET @@session.old_passwords=2")) { + die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error)); +} + +$link->query('DROP USER shatest'); +$link->query("DROP USER shatest@localhost"); + + +if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') || + !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) { + die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error)); +} + +if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') || + !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) { + die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error)); +} + +if (!$link->query("DROP TABLE IF EXISTS test") || + !$link->query("CREATE TABLE test (id INT)") || + !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)")) + die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error)); + + +if (!$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'%%'", $db)) || + !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) { + die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link))); +} + +$link->close(); +?> +--FILE-- +query("SELECT id FROM test WHERE id = 1")) + printf("[002] [%d] %s\n", $link->errno, $link->error); + + if (!$row = mysqli_fetch_assoc($res)) { + printf("[003] [%d] %s\n", $link->errno, $link->error); + } + + if ($row['id'] != 1) { + printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']); + } + + $res->close(); + $link->close(); + } + + print "done!"; +?> +--CLEAN-- +query('DROP USER shatest'); + $link->query('DROP USER shatest@localhost'); +?> +--EXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt b/ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt new file mode 100644 index 0000000000000..27bbed138ceee --- /dev/null +++ b/ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt @@ -0,0 +1,129 @@ +--TEST-- +PAM: SHA-256, mysqlnd.sha256_server_public_key +--SKIPIF-- +query("SHOW PLUGINS"))) { + die(sprintf("skip [%d] %s\n", $link->errno, $link->error)); +} + +$found = false; +while ($row = $res->fetch_assoc()) { + if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) { + $found = true; + break; + } +} +if (!$found) + die("skip SHA-256 server plugin unavailable"); + +if (!($res = $link->query("SHOW STATUS LIKE 'Rsa_public_key'"))) { + die(sprintf("skip [%d] %s\n", $link->errno, $link->error)); +} + +if (!($row = $res->fetch_assoc())) { + die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error)); +} + +$key = $row['Value']; +if (strlen($key) < 100) { + die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error)); +} + +/* date changes may give false positive */ +$file = "test_sha256_ini"; +if ((file_exists($file) && !unlink($file)) || !($fp = @fopen($file, "w"))) { + die(sprintf("skip Cannot create RSA pub key file '%s'", $file)); +} +$key = str_replace("A", "a", $key); +$key = str_replace("M", "m", $key); +if (strlen($key) != fwrite($fp, $key)) { + die(sprintf("skip Failed to create pub key file")); +} + + +if (!$link->query("SET @@session.old_passwords=2")) { + die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error)); +} + +$link->query('DROP USER shatest'); +$link->query("DROP USER shatest@localhost"); + + +if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') || + !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) { + die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error)); +} + +if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') || + !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) { + die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error)); +} + +if (!$link->query("DROP TABLE IF EXISTS test") || + !$link->query("CREATE TABLE test (id INT)") || + !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)")) + die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error)); + + +if (!$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'%%'", $db)) || + !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) { + die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link))); +} + +$link->close(); +?> +--INI-- +mysqlnd.sha256_server_public_key="test_sha256_ini" +--FILE-- +connect_errno) { + printf("[001] [%d] %s\n", $link->connect_errno, $link->connect_error); + } else { + if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) + printf("[002] [%d] %s\n", $link->errno, $link->error); + + if (!$row = mysqli_fetch_assoc($res)) { + printf("[003] [%d] %s\n", $link->errno, $link->error); + } + + if ($row['id'] != 1) { + printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']); + } + } + print "done!"; +?> +--CLEAN-- +query('DROP USER shatest'); + $link->query('DROP USER shatest@localhost'); + $file = "test_sha256_ini"; + @unlink($file); +?> +--EXPECTF-- + +Warning: mysqli::mysqli(): (HY000/1045): %s in %s on line %d +[001] [1045] %s +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt new file mode 100644 index 0000000000000..afed773b017d0 --- /dev/null +++ b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt @@ -0,0 +1,132 @@ +--TEST-- +PAM: SHA-256, option: MYSQLI_SERVER_PUBLIC_KEY +--SKIPIF-- +query("SHOW PLUGINS"))) { + die(sprintf("skip [%d] %s\n", $link->errno, $link->error)); +} + +$found = false; +while ($row = $res->fetch_assoc()) { + if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) { + $found = true; + break; + } +} +if (!$found) + die("skip SHA-256 server plugin unavailable"); + +if (!($res = $link->query("SHOW STATUS LIKE 'Rsa_public_key'"))) { + die(sprintf("skip [%d] %s\n", $link->errno, $link->error)); +} + +if (!($row = $res->fetch_assoc())) { + die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error)); +} + +if (strlen($row['Value']) < 100) { + die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error)); +} + +/* date changes may give false positive */ +$file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd")); +if ((file_exists($file) && !unlink($file)) || !($fp = @fopen($file, "w"))) { + die(sprintf("skip Cannot create RSA pub key file '%s'", $file)); +} +if (strlen($row['Value']) != fwrite($fp, $row['Value'])) { + die(sprintf("skip Failed to create pub key file")); +} + + +if (!$link->query("SET @@session.old_passwords=2")) { + die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error)); +} + +$link->query('DROP USER shatest'); +$link->query("DROP USER shatest@localhost"); + + +if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') || + !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) { + die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error)); +} + +if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') || + !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) { + die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error)); +} + +if (!$link->query("DROP TABLE IF EXISTS test") || + !$link->query("CREATE TABLE test (id INT)") || + !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)")) + die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error)); + + +if (!$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'%%'", $db)) || + !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) { + die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link))); +} + +$link->close(); +?> +--FILE-- +options(MYSQLI_SERVER_PUBLIC_KEY, $file))) { + printf("[001] mysqli_options failed, [%d] %s\n", $link->errno, $link->error); + } + + if (!$link->real_connect($host, 'shatest', 'shatest', $db, $port, $socket)) { + printf("[002] [%d] %s\n", $link->connect_errno, $link->connect_error); + } + + if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) + printf("[003] [%d] %s\n", $link->errno, $link->error); + + if (!$row = mysqli_fetch_assoc($res)) { + printf("[004] [%d] %s\n", $link->errno, $link->error); + } + + if ($row['id'] != 1) { + printf("[005] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']); + } + + $res->close(); + $link->close(); + } + + print "done!"; +?> +--CLEAN-- +query('DROP USER shatest'); + $link->query('DROP USER shatest@localhost'); + $file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd")); + @unlink($file); +?> +--EXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt new file mode 100644 index 0000000000000..e2626240d826c --- /dev/null +++ b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt @@ -0,0 +1,188 @@ +--TEST-- +PAM: SHA-256, option: MYSQLI_SERVER_PUBLIC_KEY (invalid) +--SKIPIF-- +query("SHOW PLUGINS"))) { + die(sprintf("skip [%d] %s\n", $link->errno, $link->error)); +} + +$found = false; +while ($row = $res->fetch_assoc()) { + if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) { + $found = true; + break; + } +} +if (!$found) + die("skip SHA-256 server plugin unavailable"); + +if (!($res = $link->query("SHOW STATUS LIKE 'Rsa_public_key'"))) { + die(sprintf("skip [%d] %s\n", $link->errno, $link->error)); +} + +if (!($row = $res->fetch_assoc())) { + die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error)); +} + +if (strlen($row['Value']) < 100) { + die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error)); +} + +/* date changes may give false positive */ +$file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd")); +if ((file_exists($file) && !unlink($file)) || !($fp = @fopen($file, "w"))) { + die(sprintf("skip Cannot create RSA pub key file '%s'", $file)); +} +if (strlen($row['Value']) != fwrite($fp, $row['Value'])) { + die(sprintf("skip Failed to create pub key file")); +} + + +if (!$link->query("SET @@session.old_passwords=2")) { + die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error)); +} + +$link->query('DROP USER shatest'); +$link->query("DROP USER shatest@localhost"); + + +if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') || + !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) { + die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error)); +} + +if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') || + !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) { + die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error)); +} + +if (!$link->query("DROP TABLE IF EXISTS test") || + !$link->query("CREATE TABLE test (id INT)") || + !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)")) + die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error)); + + +if (!$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'%%'", $db)) || + !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) { + die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link))); +} + +$link->close(); +?> +--FILE-- +options(MYSQLI_SERVER_PUBLIC_KEY, $file))) { + printf("[%03d + 001] mysqli_options failed, [%d] %s\n", $offset, $link->errno, $link->error); + return false; + } + + if (!$link->real_connect($host, 'shatest', 'shatest', $db, $port, $socket)) { + printf("[%03d + 002] [%d] %s\n", $offset, $link->connect_errno, $link->connect_error); + return false; + } + + if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) + printf("[%03d + 003] [%d] %s\n", $offset, $link->errno, $link->error); + return false; + + if (!$row = mysqli_fetch_assoc($res)) { + printf("[%03d + 004] [%d] %s\n", $offset, $link->errno, $link->error); + return false; + } + + if ($row['id'] != 1) { + printf("[%03d + 005] Expecting 1 got %s/'%s'", $offset, gettype($row['id']), $row['id']); + return false; + } + + $res->close(); + $link->close(); + return true; + } + + $file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd")); + if (file_exists($file) && is_readable($file)) { + + /* valid key */ + sha_connect(100, $host, $db, $port, $socket, $file); + + /* invalid key */ + $file_wrong = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_wrong" , @date("Ymd")); + + $key = file_get_contents($file); + $key = str_replace("A", "a", $key); + $key = str_replace("M", "m", $key); + @unlink($file_wrong); + if (!($fp = fopen($file_wrong, "w"))) { + printf("[002] Can't write public key file."); + } else { + fwrite($fp, $key); + fclose($fp); + sha_connect(200, $host, $db, $port, $socket, $file_wrong); + } + + /* empty file */ + @unlink($file_wrong); + if (!($fp = fopen($file_wrong, "w"))) { + printf("[003] Can't write public key file."); + } else { + fwrite($fp, ""); + fclose($fp); + sha_connect(300, $host, $db, $port, $socket, $file_wrong); + } + + /* file does not exist */ + @unlink($file_wrong); + sha_connect(400, $host, $db, $port, $socket, $file_wrong); + + } else { + printf("[001] Cannot read public key file."); + } + + print "done!"; +?> +--CLEAN-- +query('DROP USER shatest'); + $link->query('DROP USER shatest@localhost'); + $file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd")); + @unlink($file); + $file_wrong = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_wrong" , @date("Ymd")); + @unlink($file_wrong); +?> +--EXPECTF-- +Warning: mysqli::real_connect(): (HY000/1045): %s in %s on line %d +[200 + 002] [1045] %s + +Warning: mysqli::real_connect(): (HY000/1045): %s in %s on line %d +[300 + 002] [1045] %s + +Warning: mysqli::real_connect(%sest_sha256_wrong_%d): failed to open stream: No such file or directory in %s on line %d + +Warning: mysqli::real_connect(): (HY000/1045): %s in %s on line %d +[400 + 002] [1045] %s +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_query_local_infile_large.phpt b/ext/mysqli/tests/mysqli_query_local_infile_large.phpt deleted file mode 100644 index 76bc415d8bcbf..0000000000000 --- a/ext/mysqli/tests/mysqli_query_local_infile_large.phpt +++ /dev/null @@ -1,103 +0,0 @@ ---TEST-- -mysql_query(LOAD DATA LOCAL INFILE) with large data set (10MB) ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- -') == 1)) - $bytes += fwrite($fp, (binary)(++$rowno . ";" . $data)); - else - $bytes += fwrite($fp, ++$rowno . ";" . $data); - } - fclose($fp); - printf("Filesize in bytes: %d\nRows: %d\n", $bytes, $rowno); - - require_once("connect.inc"); - if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) - printf("[002] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - - if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || - !mysqli_query($link, "CREATE TABLE test(id INT, col1 VARCHAR(255), col2 VARCHAR(255)) ENGINE = " . $engine)) - printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';'", mysqli_real_escape_string($link, $file)))) - printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if ((!is_string(mysqli_info($link))) || ('' == mysqli_info($link))) { - printf("[005] [%d] %s, mysqli_info not set \n", mysqli_errno($link), mysqli_error($link)); - } - - if (!($res = mysqli_query($link, "SELECT COUNT(*) AS _num FROM test"))) - printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - $row = mysqli_fetch_assoc($res); - if (($row["_num"] != $rowno)) - printf("[007] Expecting %d rows, found %d\n", $rowno, $row["_num"]); - - mysqli_free_result($res); - - $random = mt_rand(1, $rowno); - if (!$res = mysqli_query($link, "SELECT id, col1, col2 FROM test WHERE id = " . $random)) - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - $row = mysqli_fetch_assoc($res); - var_dump($row); - mysqli_free_result($res); - - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Filesize in bytes: %d -Rows: %d -array(3) { - [%u|b%"id"]=> - %unicode|string%(%d) "%d" - [%u|b%"col1"]=> - %unicode|string%(127) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - [%u|b%"col2"]=> - %unicode|string%(127) "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" -} -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_default.phpt b/ext/mysqli/tests/mysqli_set_local_infile_default.phpt deleted file mode 100644 index 0348b01f6af9b..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_default.phpt +++ /dev/null @@ -1,132 +0,0 @@ ---TEST-- -mysqli_set_local_infile_default() ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - 0) { - printf("[014] Test is too simple to handle a buffer of size %d that cannot hold all lines\n", $buflen); - $error = 'Parser too simple'; - } - - $buffer = ''; - foreach ($lines as $k => $line) { - if ('' === trim($line)) - continue; - - $columns = explode(';', $line); - if (empty($columns)) { - printf("[015] Cannot parse columns\n"); - $error = 'Cannot parse columns'; - } - - // increase id column value - $columns[0] += 1; - $buffer .= implode(';', $columns); - $buffer .= "\n"; - } - - return strlen($buffer); - } - - $file = create_standard_csv(4); - $expected = array( - array('id' => 98, 'label' => 'x'), - array('id' => 99, 'label' => 'y'), - array('id' => 100, 'label' => 'z'), - ); - try_handler(10, $link, $file, 'callback_simple', $expected); - - $expected = array( - array('id' => 97, 'label' => 'x'), - array('id' => 98, 'label' => 'y'), - array('id' => 99, 'label' => 'z'), - ); - try_handler(20, $link, $file, 'default', $expected); - - $expected = array( - array('id' => 98, 'label' => 'x'), - array('id' => 99, 'label' => 'y'), - array('id' => 100, 'label' => 'z'), - ); - try_handler(30, $link, $file, 'callback_simple', $expected); - - mysqli_close($link); - - if (!is_null($tmp = @mysqli_set_local_infile_default($link))) - printf("[300] Expecting NULL/NULL got %s/%s\n", $tmp, gettype($tmp)); - - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_simple' -Callback: 0 -Callback: 1 -Callback set to 'default' -Callback set to 'callback_simple' -Callback: 2 -Callback: 3 -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler.phpt deleted file mode 100644 index 58f4c70351b58..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler.phpt +++ /dev/null @@ -1,196 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - 0) { - printf("[014] Test is too simple to handle a buffer of size %d that cannot hold all lines\n", $buflen); - $error = 'Parser too simple'; - } - - $buffer = ''; - foreach ($lines as $k => $line) { - if ('' === trim($line)) - continue; - - $columns = explode(';', $line); - if (empty($columns)) { - printf("[015] Cannot parse columns\n"); - $error = 'Cannot parse columns'; - } - - // increase id column value - $columns[0] += 1; - $buffer .= implode(';', $columns); - $buffer .= "\n"; - } - - return strlen($buffer); - } - - function callback_fclose($fp, &$buffer, $buflen, &$error) { - static $invocation = 0; - - printf("Callback: %d\n", $invocation++); - - fclose($fp); - return strlen($buffer); - } - - function callback_closefile($fp, &$buffer, $buflen, &$error) { - static $invocation = 0; - - printf("Callback: %d\n", $invocation++); - flush(); - if (is_resource($fp)) - fclose($fp); - $buffer = "1;'a';\n"; - if ($invocation > 10) - return 0; - - return strlen($buffer); - } - - function callback_invalid_args($fp, &$buffer, $buflen) { - static $invocation = 0; - - printf("Callback: %d\n", $invocation++); - $buffer = fread($fp, $buflen); - - return strlen($buffer); - } - - function callback_error($fp, &$buffer, $buflen, &$error) { - static $invocation = 0; - - printf("Callback: %d\n", $invocation++); - $buffer = fread($fp, $buflen); - $error = 'How to access this error?'; - - return -1; - } - - if (!is_null($tmp = @mysqli_set_local_infile_handler())) - printf("[001] Expecting NULL/NULL got %s/%s\n", $tmp, gettype($tmp)); - - $handle = null; - if (!is_null($tmp = @mysqli_set_local_infile_handler($handle))) - printf("[002] Expecting NULL/NULL got %s/%s\n", $tmp, gettype($tmp)); - - $handle = @new mysqli(); - if (!is_null($tmp = @mysqli_set_local_infile_handler($handle, 'callback_simple'))) - printf("[003] Expecting NULL/NULL got %s/%s\n", $tmp, gettype($tmp)); - - if (false !== ($tmp = @mysqli_set_local_infile_handler($link, 'unknown'))) - printf("[004] Expecting false/boolean got %s/%s\n", $tmp, gettype($tmp)); - - $file = create_standard_csv(5); - - $expected = array( - array('id' => 98, 'label' => 'x'), - array('id' => 99, 'label' => 'y'), - array('id' => 100, 'label' => 'z'), - ); - try_handler(10, $link, $file, 'callback_simple', $expected); - - $expected = array(); - try_handler(20, $link, $file, 'callback_fclose', $expected); - - // FIXME - TODO - KLUDGE - - // IMHO this is wrong. ext/mysqli should bail as the function signature - // is not complete. That's a BC break, OK, but it makes perfectly sense. - $expected = array(); - try_handler(30, $link, $file, 'callback_invalid_args', $expected); - - $expected = array(); - try_handler(40, $link, $file, 'callback_error', $expected); - - - mysqli_close($link); - - if (!is_null($tmp = @mysqli_set_local_infile_handler($link, 'callback_simple'))) - printf("[300] Expecting NULL/NULL got %s/%s\n", $tmp, gettype($tmp)); - - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_simple' -Callback: 0 -Callback: 1 -Callback set to 'callback_fclose' -Callback: 0 -[022] LOAD DATA failed, [2000] File handle close%s -Callback set to 'callback_invalid_args' -Callback: 0 -Callback: 1 -[037] More results than expected! -array(2) { - [%u|b%"id"]=> - %unicode|string%(2) "97" - [%u|b%"label"]=> - %unicode|string%(1) "x" -} -array(2) { - [%u|b%"id"]=> - %unicode|string%(2) "98" - [%u|b%"label"]=> - %unicode|string%(1) "y" -} -array(2) { - [%u|b%"id"]=> - %unicode|string%(2) "99" - [%u|b%"label"]=> - %unicode|string%(1) "z" -} -Callback set to 'callback_error' -Callback: 0 -[042] LOAD DATA failed, [2000] How to access this error? -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt deleted file mode 100644 index b8f51c214fb75..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt +++ /dev/null @@ -1,82 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - random ASCII character including \0 ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- -') == 1) ? (floor($buflen / 2) - 10) : ($buflen - 5); - $part1 = floor($num_chars / 2); - $part2 = $num_chars - $part1; - - $buffer = ''; - for ($i = 0; $i < $part1; $i++) - $buffer .= chr(mt_rand(0, 255)); - - $buffer .= ';"'; - - for ($i = 0; $i < $part2; $i++) - $buffer .= chr(mt_rand(0, 255)); - - $buffer .= '";'; - if ($invocation > 10) - return 0; - - return strlen($buffer); - } - - $file = create_standard_csv(5); - /* we feed the handler with random data, therefore we cannot specify and expected rows */ - try_handler(20, $link, $file, 'callback_bad_character'); - - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_bad_character' -Callback: 0 -Callback: 1 -Callback: 2 -Callback: 3 -Callback: 4 -Callback: 5 -Callback: 6 -Callback: 7 -Callback: 8 -Callback: 9 -Callback: 10 -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt deleted file mode 100644 index a3c8801023866..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt +++ /dev/null @@ -1,60 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - buffer overflow ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_buffer_overflow' -Callback: 0 - -Warning: mysqli_query(): Too much data returned in %s on line %d -[022] LOAD DATA failed, [%d] Too much data returned -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt deleted file mode 100644 index 408bb29ec4106..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - close database link ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - 10) - return 0; - - return strlen($buffer); - } - - $file = create_standard_csv(1); - $expected = array(array('id' => 1, 'label' => 'a')); - try_handler(20, $link, $file, 'callback_close_link', $expected); - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_close_link' -Callback: 0 -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt deleted file mode 100644 index 168cbc1358856..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt +++ /dev/null @@ -1,70 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - do not use the file pointer ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - 10) - return 0; - - return strlen($buffer); - } - - $file = create_standard_csv(1); - $expected = array(array('id' => 1, 'label' => 'a')); - try_handler(20, $link, $file, 'callback_closefile', $expected); - - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_closefile' -Callback: 0 -Callback: 1 -Callback: 2 -Callback: 3 -Callback: 4 -Callback: 5 -Callback: 6 -Callback: 7 -Callback: 8 -Callback: 9 -Callback: 10 -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt deleted file mode 100644 index ad7ab32c1cbc4..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt +++ /dev/null @@ -1,62 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - use closures as handler ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - 10) - return 0; - - return strlen($buffer); - }; - - $file = create_standard_csv(1); - if (!try_handler(20, $link, $file, $callback_replace_buffer, null)) - printf("[008] Failure\n"); - - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'Closure object' -Callback: 0 -Callback: 1 -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt deleted file mode 100644 index b2b42a22e5de7..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - kill database link ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - 10) - return 0; - - mysqli_set_local_infile_default($link); - return strlen($buffer); - } - - $file = create_standard_csv(1); - $expected = array(array('id' => 1, 'label' => 'a')); - try_handler(20, $link, $file, 'callback_kill_link', $expected); - - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_kill_link' -Callback: 0 -[022] LOAD DATA failed, [2000] Can't execute load data local init callback function -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt deleted file mode 100644 index 16e38c5fa2759..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt +++ /dev/null @@ -1,58 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - negative return value/buflen to indicate an error ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_negative_len' -Callback: 0 -[022] LOAD DATA failed, [2000] negative length means error -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt deleted file mode 100644 index 4663fe236e4f9..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt +++ /dev/null @@ -1,107 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - nested calls ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - 0) { - printf("[014] Test is too simple to handle a buffer of size %d that cannot hold all lines\n", $buflen); - $error = 'Parser too simple'; - } - - $buffer = ''; - foreach ($lines as $k => $line) { - if ('' === trim($line)) - continue; - - $columns = explode(';', $line); - if (empty($columns)) { - printf("[015] Cannot parse columns\n"); - $error = 'Cannot parse columns'; - } - - // increase id column value - $columns[0] += 1; - $buffer .= implode(';', $columns); - $buffer .= "\n"; - } - - /* report the wrong length */ - return strlen($buffer); - } - - function callback_report_short_len($fp, &$buffer, $buflen, &$error) { - static $invocation = 0; - - printf("Callback - report_short_len(): %d\n", $invocation++); - return callback_simple($fp, $buffer, $buflen, $error); - } - - $file = create_standard_csv(1); - $expected = array( - array('id' => 98, 'label' => 'x'), - array('id' => 99, 'label' => 'y'), - array('id' => 100, 'label' => 'z'), - ); - try_handler(20, $link, $file, 'callback_report_short_len', $expected); - - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_report_short_len' -Callback - report_short_len(): 0 -Callback - callback_simple(): 0 -Callback - report_short_len(): 1 -Callback - callback_simple(): 1 -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt deleted file mode 100644 index ca06435c5ea17..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt +++ /dev/null @@ -1,71 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - run new query on db link ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - 10) - return 0; - - mysqli_set_local_infile_default($link); - return strlen($buffer); - } - - $file = create_standard_csv(1); - $expected = array(array('id' => 1, 'label' => 'a')); - try_handler(20, $link, $file, 'callback_new_query', $expected); - - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_new_query' -Callback: 0 -[Callback 001 - 001] Cannot run query, [2014] Commands out of sync; you can't run this command now -[022] LOAD DATA failed, [2000] Can't execute load data local init callback function -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt deleted file mode 100644 index 601a09e12cd9c..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt +++ /dev/null @@ -1,70 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - do not use the file pointer ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - 10) - return 0; - - return strlen($buffer); - } - - $file = create_standard_csv(1); - $expected = array(array('id' => 1, 'label' => 'a')); - try_handler(20, $link, $file, 'callback_nofileop', $expected); - - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_nofileop' -Callback: 0 -Callback: 1 -Callback: 2 -Callback: 3 -Callback: 4 -Callback: 5 -Callback: 6 -Callback: 7 -Callback: 8 -Callback: 9 -Callback: 10 -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt deleted file mode 100644 index 7163aca10dc31..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt +++ /dev/null @@ -1,115 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - open basedir restrictions ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -open_basedir="." ---FILE-- - 0) { - printf("[014] Test is too simple to handle a buffer of size %d that cannot hold all lines\n", $buflen); - $error = 'Parser too simple'; - } - - $buffer = ''; - foreach ($lines as $k => $line) { - if ('' === trim($line)) - continue; - - $columns = explode(';', $line); - if (empty($columns)) { - printf("[015] Cannot parse columns\n"); - $error = 'Cannot parse columns'; - } - - // increase id column value - $columns[0] += 1; - $buffer .= implode(';', $columns); - $buffer .= "\n"; - } - - return strlen($buffer); - } - - $file = create_standard_csv(5); - $expected = array( - array('id' => 98, 'label' => 'x'), - array('id' => 99, 'label' => 'y'), - array('id' => 100, 'label' => 'z'), - ); - try_handler(10, $link, $file, 'callback_simple', $expected); - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Warning: tempnam(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s on line %d -[005 + 1] Cannot create CVS file '' -Callback set to 'callback_simple' -[012] LOAD DATA failed, [%d] %s -[014/0] [0] '' -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt deleted file mode 100644 index 0d4024e528b70..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt +++ /dev/null @@ -1,78 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - replace buffer pointer ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- -') == 1)) ? floor($buflen / 2) : $buflen; - assert(strlen($buffer) < $num_chars); - - if ($invocation > 10) - return 0; - - return strlen($buffer); - } - - $file = create_standard_csv(1); - $expected = array(array('id' => 1, 'label' => 'a')); - if (!try_handler(20, $link, $file, 'callback_replace_buffer', $expected)) - printf("[008] Failure\n"); - - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_replace_buffer' -Callback: 0 -Callback: 1 -Callback: 2 -Callback: 3 -Callback: 4 -Callback: 5 -Callback: 6 -Callback: 7 -Callback: 8 -Callback: 9 -Callback: 10 -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt deleted file mode 100644 index b3144e430e5a5..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt +++ /dev/null @@ -1,101 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - report shorter buffer ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - 0) { - printf("[014] Test is too simple to handle a buffer of size %d that cannot hold all lines\n", $buflen); - $error = 'Parser too simple'; - } - - $buffer = ''; - foreach ($lines as $k => $line) { - if ('' === trim($line)) - continue; - - $columns = explode(';', $line); - if (empty($columns)) { - printf("[015] Cannot parse columns\n"); - $error = 'Cannot parse columns'; - } - - // increase id column value - $columns[0] += 1; - $buffer .= implode(';', $columns); - $buffer .= "\n"; - } - - /* report the wrong length */ - return strlen($buffer) - 1; - } - - $file = create_standard_csv(1); - $expected = array( - array('id' => 98, 'label' => 'x'), - array('id' => 99, 'label' => 'y'), - array('id' => 100, 'label' => 'z'), - ); - try_handler(20, $link, $file, 'callback_short_len', $expected); - - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_short_len' -Callback: 0 - -Warning: mysqli_query(): Mismatch between the return value of the callback and the content length of the buffer. in %s on line %d -[022] LOAD DATA failed, [2000] Mismatch between the return value of the callback and the content length of the buffer. -[024/0] [0] '' -done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt deleted file mode 100644 index f287f4d8741dc..0000000000000 --- a/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt +++ /dev/null @@ -1,64 +0,0 @@ ---TEST-- -mysqli_set_local_infile_handler() - do not use the file pointer ---SKIPIF-- -errno, $link->error)); - -mysqli_close($link); -?> ---INI-- -mysqli.allow_local_infile=1 ---FILE-- - 10) - return 0; - - mysqli_set_local_infile_default($link); - return strlen($buffer); - } - - $file = create_standard_csv(1); - $expected = array(array('id' => 1, 'label' => 'a')); - try_handler(20, $link, $file, 'callback_unregister', $expected); - - mysqli_close($link); - print "done!"; -?> ---CLEAN-- - ---EXPECTF-- -Callback set to 'callback_unregister' -Callback: 0 - -Warning: mysqli_query(): File handle closed in %s on line %d -[022] LOAD DATA failed, [2000] File handle closed -[024/0] [0] '' -done! diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt index afaccaf3c7a53..739bf56ea150d 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt @@ -12,7 +12,13 @@ if (!function_exists('mysqli_stmt_get_result')) --FILE-- charsetnr != $charsets['results']['nr']) { + if ($field->charsetnr != $charsetInfo->number) { printf("[004] Expecting charset %s/%d got %d\n", - $charsets['results']['charset'], - $charsets['results']['nr'], $field->charsetnr); + $charsetInfo->charset, + $charsetInfo->number, $field->charsetnr); } - if ($field->length != (1 * $charsets['results']['maxlen'])) { + if ($field->length != $charsetInfo->max_length) { printf("[005] Expecting length %d got %d\n", - $charsets['results']['maxlen'], - $field->max_length); + $charsetInfo->max_length, $field->max_length); } } } @@ -173,4 +178,4 @@ object(stdClass)#%d (13) { [%u|b%"decimals"]=> int(31) } -done! \ No newline at end of file +done! diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4 index 2c15c34e8d39c..3fc767b231d68 100644 --- a/ext/mysqlnd/config9.m4 +++ b/ext/mysqlnd/config9.m4 @@ -28,7 +28,17 @@ if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then if test "$PHP_MYSQLND_COMPRESSION_SUPPORT" != "no"; then AC_DEFINE([MYSQLND_COMPRESSION_WANTED], 1, [Enable compressed protocol support]) fi - AC_DEFINE([MYSQLND_SSL_SUPPORTED], 1, [Enable SSL support]) + + AC_DEFINE([MYSQLND_SSL_SUPPORTED], 1, [Enable core mysqlnd SSL code]) + + test -z "$PHP_OPENSSL" && PHP_OPENSSL=no + + if test "$PHP_OPENSSL" != "no" || test "$PHP_OPENSSL_DIR" != "no"; then + AC_CHECK_LIB(ssl, DSA_get_default_method, AC_DEFINE(HAVE_DSA_DEFAULT_METHOD, 1, [OpenSSL 0.9.7 or later])) + AC_CHECK_LIB(crypto, X509_free, AC_DEFINE(HAVE_DSA_DEFAULT_METHOD, 1, [OpenSSL 0.9.7 or later])) + + PHP_SETUP_OPENSSL(MYSQLND_SHARED_LIBADD, [AC_DEFINE(MYSQLND_HAVE_SSL,1,[Enable mysqlnd code that uses OpenSSL directly])]) + fi mysqlnd_sources="$mysqlnd_base_sources $mysqlnd_ps_sources" PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, $ext_shared) diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 90c2b73eaed94..ccd8af51c6db3 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -95,6 +95,11 @@ MYSQLND_METHOD(mysqlnd_conn_data, free_options)(MYSQLND_CONN_DATA * conn TSRMLS_ mnd_pefree(conn->options->cfg_section, pers); conn->options->cfg_section = NULL; } + if (conn->options->connect_attr) { + zend_hash_destroy(conn->options->connect_attr); + mnd_pefree(conn->options->connect_attr, pers); + conn->options->connect_attr = NULL; + } } /* }}} */ @@ -114,7 +119,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, free_contents)(MYSQLND_CONN_DATA * conn TSRMLS } if (conn->net) { - conn->net->m.free_contents(conn->net TSRMLS_CC); + conn->net->data->m.free_contents(conn->net TSRMLS_CC); } DBG_INF("Freeing memory of members"); @@ -303,17 +308,16 @@ MYSQLND_METHOD(mysqlnd_conn_data, simple_command_handle_response)(MYSQLND_CONN_D /* }}} */ -/* {{{ mysqlnd_conn_data::simple_command */ +/* {{{ mysqlnd_conn_data::simple_command_send_request */ static enum_func_status -MYSQLND_METHOD(mysqlnd_conn_data, simple_command)(MYSQLND_CONN_DATA * conn, enum php_mysqlnd_server_command command, - const zend_uchar * const arg, size_t arg_len, enum mysqlnd_packet_type ok_packet, zend_bool silent, - zend_bool ignore_upsert_status TSRMLS_DC) +MYSQLND_METHOD(mysqlnd_conn_data, simple_command_send_request)(MYSQLND_CONN_DATA * conn, enum php_mysqlnd_server_command command, + const zend_uchar * const arg, size_t arg_len, zend_bool silent, zend_bool ignore_upsert_status TSRMLS_DC) { enum_func_status ret = PASS; MYSQLND_PACKET_COMMAND * cmd_packet; - DBG_ENTER("mysqlnd_conn_data::simple_command"); - DBG_INF_FMT("command=%s ok_packet=%u silent=%u", mysqlnd_command_to_text[command], ok_packet, silent); + DBG_ENTER("mysqlnd_conn_data::simple_command_send_request"); + DBG_INF_FMT("command=%s silent=%u", mysqlnd_command_to_text[command], silent); switch (CONN_GET_STATE(conn)) { case CONN_READY: @@ -355,13 +359,30 @@ MYSQLND_METHOD(mysqlnd_conn_data, simple_command)(MYSQLND_CONN_DATA * conn, enum php_error(E_WARNING, "Error while sending %s packet. PID=%d", mysqlnd_command_to_text[command], getpid()); } CONN_SET_STATE(conn, CONN_QUIT_SENT); + conn->m->send_close(conn TSRMLS_CC); DBG_ERR("Server is gone"); ret = FAIL; - } else if (ok_packet != PROT_LAST) { + } + PACKET_FREE(cmd_packet); + DBG_RETURN(ret); +} +/* }}} */ + + +/* {{{ mysqlnd_conn_data::simple_command */ +static enum_func_status +MYSQLND_METHOD(mysqlnd_conn_data, simple_command)(MYSQLND_CONN_DATA * conn, enum php_mysqlnd_server_command command, + const zend_uchar * const arg, size_t arg_len, enum mysqlnd_packet_type ok_packet, zend_bool silent, + zend_bool ignore_upsert_status TSRMLS_DC) +{ + enum_func_status ret; + DBG_ENTER("mysqlnd_conn_data::simple_command"); + + ret = conn->m->simple_command_send_request(conn, command, arg, arg_len, silent, ignore_upsert_status TSRMLS_CC); + if (PASS == ret && ok_packet != PROT_LAST) { ret = conn->m->simple_command_handle_response(conn, ok_packet, silent, command, ignore_upsert_status TSRMLS_CC); } - PACKET_FREE(cmd_packet); DBG_INF(ret == PASS ? "PASS":"FAIL"); DBG_RETURN(ret); } @@ -440,11 +461,7 @@ mysqlnd_switch_to_ssl_if_needed( if (options->charset_name && (charset = mysqlnd_find_charset_name(options->charset_name))) { auth_packet->charset_no = charset->nr; } else { -#if MYSQLND_UNICODE - auth_packet->charset_no = 200;/* utf8 - swedish collation, check mysqlnd_charset.c */ -#else auth_packet->charset_no = greet_packet->charset_no; -#endif } #ifdef MYSQLND_SSL_SUPPORTED @@ -453,13 +470,14 @@ mysqlnd_switch_to_ssl_if_needed( DBG_INF("Switching to SSL"); if (!PACKET_WRITE(auth_packet, conn)) { CONN_SET_STATE(conn, CONN_QUIT_SENT); + conn->m->send_close(conn TSRMLS_CC); SET_CLIENT_ERROR(*conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); goto end; } - conn->net->m.set_client_option(conn->net, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (const char *) &verify TSRMLS_CC); + conn->net->data->m.set_client_option(conn->net, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (const char *) &verify TSRMLS_CC); - if (FAIL == conn->net->m.enable_ssl(conn->net TSRMLS_CC)) { + if (FAIL == conn->net->data->m.enable_ssl(conn->net TSRMLS_CC)) { goto end; } } @@ -472,6 +490,159 @@ mysqlnd_switch_to_ssl_if_needed( /* }}} */ +/* {{{ mysqlnd_conn_data::fetch_auth_plugin_by_name */ +static struct st_mysqlnd_authentication_plugin * +MYSQLND_METHOD(mysqlnd_conn_data, fetch_auth_plugin_by_name)(const char * const requested_protocol TSRMLS_DC) +{ + struct st_mysqlnd_authentication_plugin * auth_plugin; + char * plugin_name = NULL; + DBG_ENTER("mysqlnd_conn_data::fetch_auth_plugin_by_name"); + + mnd_sprintf(&plugin_name, 0, "auth_plugin_%s", requested_protocol); + DBG_INF_FMT("looking for %s auth plugin", plugin_name); + auth_plugin = mysqlnd_plugin_find(plugin_name); + mnd_sprintf_free(plugin_name); + + DBG_RETURN(auth_plugin); +} +/* }}} */ + + +/* {{{ mysqlnd_run_authentication */ +static enum_func_status +mysqlnd_run_authentication( + MYSQLND_CONN_DATA * conn, + const char * const user, + const char * const passwd, + const size_t passwd_len, + const char * const db, + const size_t db_len, + const zend_uchar * const auth_plugin_data, + const size_t auth_plugin_data_len, + const char * const auth_protocol, + unsigned int charset_no, + const MYSQLND_OPTIONS * const options, + unsigned long mysql_flags, + zend_bool silent, + zend_bool is_change_user + TSRMLS_DC) +{ + enum_func_status ret = FAIL; + zend_bool first_call = TRUE; + + char * switch_to_auth_protocol = NULL; + size_t switch_to_auth_protocol_len = 0; + char * requested_protocol = NULL; + zend_uchar * plugin_data; + size_t plugin_data_len; + + DBG_ENTER("mysqlnd_run_authentication"); + + plugin_data_len = auth_plugin_data_len; + plugin_data = mnd_emalloc(plugin_data_len + 1); + if (!plugin_data) { + goto end; + } + memcpy(plugin_data, auth_plugin_data, plugin_data_len); + plugin_data[plugin_data_len] = '\0'; + + requested_protocol = mnd_pestrdup(auth_protocol? auth_protocol : MYSQLND_DEFAULT_AUTH_PROTOCOL, FALSE); + if (!requested_protocol) { + goto end; + } + + do { + struct st_mysqlnd_authentication_plugin * auth_plugin = conn->m->fetch_auth_plugin_by_name(requested_protocol TSRMLS_CC); + + if (!auth_plugin) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "The server requested authentication method unknown to the client [%s]", requested_protocol); + SET_CLIENT_ERROR(*conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "The server requested authentication method umknown to the client"); + goto end; + } + DBG_INF("plugin found"); + + { + zend_uchar * switch_to_auth_protocol_data = NULL; + size_t switch_to_auth_protocol_data_len = 0; + zend_uchar * scrambled_data = NULL; + size_t scrambled_data_len = 0; + + switch_to_auth_protocol = NULL; + switch_to_auth_protocol_len = 0; + + if (conn->auth_plugin_data) { + mnd_pefree(conn->auth_plugin_data, conn->persistent); + conn->auth_plugin_data = NULL; + } + conn->auth_plugin_data_len = plugin_data_len; + conn->auth_plugin_data = mnd_pemalloc(conn->auth_plugin_data_len, conn->persistent); + if (!conn->auth_plugin_data) { + SET_OOM_ERROR(*conn->error_info); + goto end; + } + memcpy(conn->auth_plugin_data, plugin_data, plugin_data_len); + + DBG_INF_FMT("salt(%d)=[%.*s]", plugin_data_len, plugin_data_len, plugin_data); + /* The data should be allocated with malloc() */ + scrambled_data = + auth_plugin->methods.get_auth_data(NULL, &scrambled_data_len, conn, user, passwd, passwd_len, + plugin_data, plugin_data_len, options, &conn->net->data->options, mysql_flags TSRMLS_CC); + if (conn->error_info->error_no) { + goto end; + } + if (FALSE == is_change_user) { + ret = mysqlnd_auth_handshake(conn, user, passwd, passwd_len, db, db_len, options, mysql_flags, + charset_no, + first_call, + requested_protocol, + scrambled_data, scrambled_data_len, + &switch_to_auth_protocol, &switch_to_auth_protocol_len, + &switch_to_auth_protocol_data, &switch_to_auth_protocol_data_len + TSRMLS_CC); + } else { + ret = mysqlnd_auth_change_user(conn, user, strlen(user), passwd, passwd_len, db, db_len, silent, + first_call, + requested_protocol, + scrambled_data, scrambled_data_len, + &switch_to_auth_protocol, &switch_to_auth_protocol_len, + &switch_to_auth_protocol_data, &switch_to_auth_protocol_data_len + TSRMLS_CC); + } + first_call = FALSE; + free(scrambled_data); + + DBG_INF_FMT("switch_to_auth_protocol=%s", switch_to_auth_protocol? switch_to_auth_protocol:"n/a"); + if (requested_protocol && switch_to_auth_protocol) { + mnd_efree(requested_protocol); + requested_protocol = switch_to_auth_protocol; + } + + if (plugin_data) { + mnd_efree(plugin_data); + } + plugin_data_len = switch_to_auth_protocol_data_len; + plugin_data = switch_to_auth_protocol_data; + } + DBG_INF_FMT("conn->error_info->error_no = %d", conn->error_info->error_no); + } while (ret == FAIL && conn->error_info->error_no == 0 && switch_to_auth_protocol != NULL); + + if (ret == PASS) { + DBG_INF_FMT("saving requested_protocol=%s", requested_protocol); + conn->m->set_client_option(conn, MYSQLND_OPT_AUTH_PROTOCOL, requested_protocol TSRMLS_CC); + } +end: + if (plugin_data) { + mnd_efree(plugin_data); + } + if (requested_protocol) { + mnd_efree(requested_protocol); + } + + DBG_RETURN(ret); +} +/* }}} */ + + /* {{{ mysqlnd_connect_run_authentication */ static enum_func_status mysqlnd_connect_run_authentication( @@ -491,116 +662,165 @@ mysqlnd_connect_run_authentication( ret = mysqlnd_switch_to_ssl_if_needed(conn, greet_packet, options, mysql_flags TSRMLS_CC); if (PASS == ret) { - zend_bool first_call = TRUE; + ret = mysqlnd_run_authentication(conn, user, passwd, passwd_len, db, db_len, + greet_packet->auth_plugin_data, greet_packet->auth_plugin_data_len, greet_packet->auth_protocol, + greet_packet->charset_no, options, mysql_flags, FALSE /*silent*/, FALSE/*is_change*/ TSRMLS_CC); + } + DBG_RETURN(ret); +} +/* }}} */ - char * switch_to_auth_protocol = NULL; - size_t switch_to_auth_protocol_len = 0; - char * requested_protocol = NULL; - zend_uchar * plugin_data; - size_t plugin_data_len; - plugin_data_len = greet_packet->auth_plugin_data_len; - plugin_data = mnd_emalloc(plugin_data_len + 1); - if (!plugin_data) { - ret = FAIL; - goto end; - } - memcpy(plugin_data, greet_packet->auth_plugin_data, plugin_data_len); - plugin_data[plugin_data_len] = '\0'; +/* {{{ mysqlnd_conn_data::execute_init_commands */ +static enum_func_status +MYSQLND_METHOD(mysqlnd_conn_data, execute_init_commands)(MYSQLND_CONN_DATA * conn TSRMLS_DC) +{ + enum_func_status ret = PASS; - requested_protocol = mnd_pestrdup(greet_packet->auth_protocol? greet_packet->auth_protocol: "mysql_native_password", FALSE); - if (!requested_protocol) { - ret = FAIL; - goto end; + DBG_ENTER("mysqlnd_conn_data::execute_init_commands"); + if (conn->options->init_commands) { + unsigned int current_command = 0; + for (; current_command < conn->options->num_commands; ++current_command) { + const char * const command = conn->options->init_commands[current_command]; + if (command) { + MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_INIT_COMMAND_EXECUTED_COUNT); + if (PASS != conn->m->query(conn, command, strlen(command) TSRMLS_CC)) { + MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_INIT_COMMAND_FAILED_COUNT); + ret = FAIL; + break; + } + if (conn->last_query_type == QUERY_SELECT) { + MYSQLND_RES * result = conn->m->use_result(conn TSRMLS_CC); + if (result) { + result->m.free_result(result, TRUE TSRMLS_CC); + } + } + } } + } + DBG_RETURN(ret); +} +/* }}} */ - do { - struct st_mysqlnd_authentication_plugin * auth_plugin; - { - char * plugin_name = NULL; - mnd_sprintf(&plugin_name, 0, "auth_plugin_%s", requested_protocol); +/* {{{ mysqlnd_conn_data::get_updated_connect_flags */ +static unsigned int +MYSQLND_METHOD(mysqlnd_conn_data, get_updated_connect_flags)(MYSQLND_CONN_DATA * conn, unsigned int mysql_flags TSRMLS_DC) +{ + MYSQLND_NET * net = conn->net; - DBG_INF_FMT("looking for %s auth plugin", plugin_name); - auth_plugin = mysqlnd_plugin_find(plugin_name); - mnd_sprintf_free(plugin_name); + DBG_ENTER("mysqlnd_conn_data::get_updated_connect_flags"); + /* we allow load data local infile by default */ + mysql_flags |= MYSQLND_CAPABILITIES; - if (!auth_plugin) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The server requested authentication method unknown to the client [%s]", requested_protocol); - SET_CLIENT_ERROR(*conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "The server requested authentication method umknown to the client"); - break; - } - } - DBG_INF("plugin found"); + mysql_flags |= conn->options->flags; /* use the flags from set_client_option() */ - { - zend_uchar * switch_to_auth_protocol_data = NULL; - size_t switch_to_auth_protocol_data_len = 0; - zend_uchar * scrambled_data = NULL; - size_t scrambled_data_len = 0; + if (PG(open_basedir) && strlen(PG(open_basedir))) { + mysql_flags ^= CLIENT_LOCAL_FILES; + } - switch_to_auth_protocol = NULL; - switch_to_auth_protocol_len = 0; +#ifndef MYSQLND_COMPRESSION_ENABLED + if (mysql_flags & CLIENT_COMPRESS) { + mysql_flags &= ~CLIENT_COMPRESS; + } +#else + if (net && net->data->options.flags & MYSQLND_NET_FLAG_USE_COMPRESSION) { + mysql_flags |= CLIENT_COMPRESS; + } +#endif +#ifndef MYSQLND_SSL_SUPPORTED + if (mysql_flags & CLIENT_SSL) { + mysql_flags &= ~CLIENT_SSL; + } +#else + if (net && (net->data->options.ssl_key || net->data->options.ssl_cert || + net->data->options.ssl_ca || net->data->options.ssl_capath || net->data->options.ssl_cipher)) + { + mysql_flags |= CLIENT_SSL; + } +#endif - if (conn->auth_plugin_data) { - mnd_pefree(conn->auth_plugin_data, conn->persistent); - conn->auth_plugin_data = NULL; - } - conn->auth_plugin_data_len = plugin_data_len; - conn->auth_plugin_data = mnd_pemalloc(conn->auth_plugin_data_len, conn->persistent); - if (!conn->auth_plugin_data) { - SET_OOM_ERROR(*conn->error_info); - goto end; - } - memcpy(conn->auth_plugin_data, plugin_data, plugin_data_len); + DBG_RETURN(mysql_flags); +} +/* }}} */ - DBG_INF_FMT("salt=[%*s]", plugin_data_len - 1, plugin_data); - /* The data should be allocated with malloc() */ - scrambled_data = - auth_plugin->methods.get_auth_data(NULL, &scrambled_data_len, conn, user, passwd, passwd_len, - plugin_data, plugin_data_len, options, mysql_flags TSRMLS_CC); +/* {{{ mysqlnd_conn_data::connect_handshake */ +static enum_func_status +MYSQLND_METHOD(mysqlnd_conn_data, connect_handshake)(MYSQLND_CONN_DATA * conn, + const char * const host, const char * const user, + const char * const passwd, const unsigned int passwd_len, + const char * const db, const unsigned int db_len, + const unsigned int mysql_flags TSRMLS_DC) +{ + MYSQLND_PACKET_GREET * greet_packet; + MYSQLND_NET * net = conn->net; - ret = mysqlnd_auth_handshake(conn, user, passwd, passwd_len, db, db_len, options, mysql_flags, - greet_packet->charset_no, - first_call, - requested_protocol, - scrambled_data, scrambled_data_len, - &switch_to_auth_protocol, &switch_to_auth_protocol_len, - &switch_to_auth_protocol_data, &switch_to_auth_protocol_data_len - TSRMLS_CC); - first_call = FALSE; - free(scrambled_data); + DBG_ENTER("mysqlnd_conn_data::connect_handshake"); - DBG_INF_FMT("switch_to_auth_protocol=%s", switch_to_auth_protocol? switch_to_auth_protocol:"n/a"); - if (requested_protocol && switch_to_auth_protocol) { - mnd_efree(requested_protocol); - requested_protocol = switch_to_auth_protocol; - } + greet_packet = conn->protocol->m.get_greet_packet(conn->protocol, FALSE TSRMLS_CC); + if (!greet_packet) { + SET_OOM_ERROR(*conn->error_info); + DBG_RETURN(FAIL); /* OOM */ + } - if (plugin_data) { - mnd_efree(plugin_data); - } - plugin_data_len = switch_to_auth_protocol_data_len; - plugin_data = switch_to_auth_protocol_data; - } - DBG_INF_FMT("conn->error_info->error_no = %d", conn->error_info->error_no); - } while (ret == FAIL && conn->error_info->error_no == 0 && switch_to_auth_protocol != NULL); - if (plugin_data) { - mnd_efree(plugin_data); - } - - if (ret == PASS) { - DBG_INF_FMT("saving requested_protocol=%s", requested_protocol); - conn->m->set_client_option(conn, MYSQLND_OPT_AUTH_PROTOCOL, requested_protocol TSRMLS_CC); - } + if (FAIL == net->data->m.connect_ex(conn->net, conn->scheme, conn->scheme_len, conn->persistent, + conn->stats, conn->error_info TSRMLS_CC)) + { + goto err; + } - if (requested_protocol) { - mnd_efree(requested_protocol); - } + DBG_INF_FMT("stream=%p", net->data->m.get_stream(net TSRMLS_CC)); + + if (FAIL == PACKET_READ(greet_packet, conn)) { + DBG_ERR("Error while reading greeting packet"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while reading greeting packet. PID=%d", getpid()); + goto err; + } else if (greet_packet->error_no) { + DBG_ERR_FMT("errorno=%u error=%s", greet_packet->error_no, greet_packet->error); + SET_CLIENT_ERROR(*conn->error_info, greet_packet->error_no, greet_packet->sqlstate, greet_packet->error); + goto err; + } else if (greet_packet->pre41) { + DBG_ERR_FMT("Connecting to 3.22, 3.23 & 4.0 is not supported. Server is %-.32s", greet_packet->server_version); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connecting to 3.22, 3.23 & 4.0 " + " is not supported. Server is %-.32s", greet_packet->server_version); + SET_CLIENT_ERROR(*conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, + "Connecting to 3.22, 3.23 & 4.0 servers is not supported"); + goto err; } -end: - DBG_RETURN(ret); + + conn->thread_id = greet_packet->thread_id; + conn->protocol_version = greet_packet->protocol_version; + conn->server_version = mnd_pestrdup(greet_packet->server_version, conn->persistent); + + conn->greet_charset = mysqlnd_find_charset_nr(greet_packet->charset_no); + if (!conn->greet_charset) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "Server sent charset (%d) unknown to the client. Please, report to the developers", greet_packet->charset_no); + SET_CLIENT_ERROR(*conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, + "Server sent charset unknown to the client. Please, report to the developers"); + goto err; + } + + conn->client_flag = mysql_flags; + conn->server_capabilities = greet_packet->server_capabilities; + + if (FAIL == mysqlnd_connect_run_authentication(conn, user, passwd, db, db_len, (size_t) passwd_len, + greet_packet, conn->options, mysql_flags TSRMLS_CC)) + { + goto err; + } + conn->upsert_status->warning_count = 0; + conn->upsert_status->server_status = greet_packet->server_status; + conn->upsert_status->affected_rows = 0; + + PACKET_FREE(greet_packet); + DBG_RETURN(PASS); +err: + conn->client_flag = 0; + conn->server_capabilities = 0; + PACKET_FREE(greet_packet); + DBG_RETURN(FAIL); } /* }}} */ @@ -623,10 +843,10 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, zend_bool reconnect = FALSE; zend_bool saved_compression = FALSE; zend_bool local_tx_started = FALSE; - - MYSQLND_PACKET_GREET * greet_packet = NULL; + MYSQLND_NET * net = conn->net; DBG_ENTER("mysqlnd_conn_data::connect"); + DBG_INF_FMT("conn=%p", conn); if (PASS != conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { goto err; @@ -655,14 +875,17 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, MYSQLND_DEC_CONN_STATISTIC(conn->stats, STAT_OPENED_PERSISTENT_CONNECTIONS); } /* Now reconnect using the same handle */ - if (conn->net->compressed) { + if (net->data->compressed) { /* we need to save the state. As we will re-connect, net->compressed should be off, or we will look for a compression header as part of the greet message, but there will be none. */ saved_compression = TRUE; - conn->net->compressed = FALSE; + net->data->compressed = FALSE; + } + if (net->data->ssl) { + net->data->ssl = FALSE; } } else { unsigned int max_allowed_size = MYSQLND_ASSEMBLED_PACKET_MAX_SIZE; @@ -685,6 +908,8 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, DBG_INF_FMT("no db given, using empty string"); db = ""; db_len = 0; + } else { + mysql_flags |= CLIENT_CONNECT_WITH_DB; } host_len = strlen(host); @@ -695,119 +920,42 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, if (host_len == sizeof("localhost") - 1 && !strncasecmp(host, "localhost", host_len)) { DBG_INF_FMT("socket=%s", socket_or_pipe? socket_or_pipe:"n/a"); if (!socket_or_pipe) { - socket_or_pipe = "/tmp/mysql.sock"; - } - transport_len = mnd_sprintf(&transport, 0, "unix://%s", socket_or_pipe); - unix_socket = TRUE; -#else - if (host_len == sizeof(".") - 1 && host[0] == '.') { - /* named pipe in socket */ - if (!socket_or_pipe) { - socket_or_pipe = "\\\\.\\pipe\\MySQL"; - } - transport_len = mnd_sprintf(&transport, 0, "pipe://%s", socket_or_pipe); - named_pipe = TRUE; -#endif - } else { - if (!port) { - port = 3306; - } - transport_len = mnd_sprintf(&transport, 0, "tcp://%s:%u", host, port); - } - if (!transport) { - SET_OOM_ERROR(*conn->error_info); - goto err; /* OOM */ - } - DBG_INF_FMT("transport=%s conn->scheme=%s", transport, conn->scheme); - conn->scheme = mnd_pestrndup(transport, transport_len, conn->persistent); - conn->scheme_len = transport_len; - mnd_sprintf_free(transport); - transport = NULL; - if (!conn->scheme) { - goto err; /* OOM */ - } - } - - greet_packet = conn->protocol->m.get_greet_packet(conn->protocol, FALSE TSRMLS_CC); - if (!greet_packet) { - SET_OOM_ERROR(*conn->error_info); - goto err; /* OOM */ - } - - if (FAIL == conn->net->m.connect_ex(conn->net, conn->scheme, conn->scheme_len, conn->persistent, - conn->stats, conn->error_info TSRMLS_CC)) - { - goto err; - } - - DBG_INF_FMT("stream=%p", conn->net->stream); - - if (FAIL == PACKET_READ(greet_packet, conn)) { - DBG_ERR("Error while reading greeting packet"); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while reading greeting packet. PID=%d", getpid()); - goto err; - } else if (greet_packet->error_no) { - DBG_ERR_FMT("errorno=%u error=%s", greet_packet->error_no, greet_packet->error); - SET_CLIENT_ERROR(*conn->error_info, greet_packet->error_no, greet_packet->sqlstate, greet_packet->error); - goto err; - } else if (greet_packet->pre41) { - DBG_ERR_FMT("Connecting to 3.22, 3.23 & 4.0 is not supported. Server is %-.32s", greet_packet->server_version); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connecting to 3.22, 3.23 & 4.0 " - " is not supported. Server is %-.32s", greet_packet->server_version); - SET_CLIENT_ERROR(*conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, - "Connecting to 3.22, 3.23 & 4.0 servers is not supported"); - goto err; - } - - conn->thread_id = greet_packet->thread_id; - conn->protocol_version = greet_packet->protocol_version; - conn->server_version = mnd_pestrdup(greet_packet->server_version, conn->persistent); - - conn->greet_charset = mysqlnd_find_charset_nr(greet_packet->charset_no); - if (!conn->greet_charset) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "Server sent charset (%d) unknown to the client. Please, report to the developers", greet_packet->charset_no); - SET_CLIENT_ERROR(*conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, - "Server sent charset unknown to the client. Please, report to the developers"); - goto err; - } - /* we allow load data local infile by default */ - mysql_flags |= MYSQLND_CAPABILITIES; - - mysql_flags |= conn->options->flags; /* use the flags from set_client_option() */ - - if (db) { - mysql_flags |= CLIENT_CONNECT_WITH_DB; - } - - if (PG(open_basedir) && strlen(PG(open_basedir))) { - mysql_flags ^= CLIENT_LOCAL_FILES; - } - -#ifndef MYSQLND_COMPRESSION_ENABLED - if (mysql_flags & CLIENT_COMPRESS) { - mysql_flags &= ~CLIENT_COMPRESS; - } -#else - if (conn->net->options.flags & MYSQLND_NET_FLAG_USE_COMPRESSION) { - mysql_flags |= CLIENT_COMPRESS; - } -#endif -#ifndef MYSQLND_SSL_SUPPORTED - if (mysql_flags & CLIENT_SSL) { - mysql_flags &= ~CLIENT_SSL; - } + socket_or_pipe = "/tmp/mysql.sock"; + } + transport_len = mnd_sprintf(&transport, 0, "unix://%s", socket_or_pipe); + unix_socket = TRUE; #else - if (conn->net->options.ssl_key || conn->net->options.ssl_cert || - conn->net->options.ssl_ca || conn->net->options.ssl_capath || conn->net->options.ssl_cipher) - { - mysql_flags |= CLIENT_SSL; - } + if (host_len == sizeof(".") - 1 && host[0] == '.') { + /* named pipe in socket */ + if (!socket_or_pipe) { + socket_or_pipe = "\\\\.\\pipe\\MySQL"; + } + transport_len = mnd_sprintf(&transport, 0, "pipe://%s", socket_or_pipe); + named_pipe = TRUE; #endif + } else { + if (!port) { + port = 3306; + } + transport_len = mnd_sprintf(&transport, 0, "tcp://%s:%u", host, port); + } + if (!transport) { + SET_OOM_ERROR(*conn->error_info); + goto err; /* OOM */ + } + DBG_INF_FMT("transport=%s conn->scheme=%s", transport, conn->scheme); + conn->scheme = mnd_pestrndup(transport, transport_len, conn->persistent); + conn->scheme_len = transport_len; + mnd_sprintf_free(transport); + transport = NULL; + if (!conn->scheme) { + goto err; /* OOM */ + } + } - if (FAIL == mysqlnd_connect_run_authentication(conn, user, passwd, db, db_len, (size_t) passwd_len, - greet_packet, conn->options, mysql_flags TSRMLS_CC)) - { + mysql_flags = conn->m->get_updated_connect_flags(conn, mysql_flags TSRMLS_CC); + + if (FAIL == conn->m->connect_handshake(conn, host, user, passwd, passwd_len, db, db_len, mysql_flags TSRMLS_CC)) { goto err; } @@ -815,14 +963,14 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, CONN_SET_STATE(conn, CONN_READY); if (saved_compression) { - conn->net->compressed = TRUE; + net->data->compressed = TRUE; } /* If a connect on a existing handle is performed and mysql_flags is passed which doesn't CLIENT_COMPRESS, then we need to overwrite the value which we set based on saved_compression. */ - conn->net->compressed = mysql_flags & CLIENT_COMPRESS? TRUE:FALSE; + net->data->compressed = mysql_flags & CLIENT_COMPRESS? TRUE:FALSE; conn->user = mnd_pestrdup(user, conn->persistent); conn->user_len = strlen(conn->user); @@ -884,46 +1032,17 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, } conn->unix_socket_len = strlen(conn->unix_socket); } - conn->client_flag = mysql_flags; conn->max_packet_size = MYSQLND_ASSEMBLED_PACKET_MAX_SIZE; /* todo: check if charset is available */ - conn->server_capabilities = greet_packet->server_capabilities; - conn->upsert_status->warning_count = 0; - conn->upsert_status->server_status = greet_packet->server_status; - conn->upsert_status->affected_rows = 0; SET_EMPTY_ERROR(*conn->error_info); mysqlnd_local_infile_default(conn); -#if MYSQLND_UNICODE - { - unsigned int as_unicode = 1; - conn->m->set_client_option(conn, MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, (char *)&as_unicode TSRMLS_CC); - DBG_INF("unicode set"); - } -#endif - if (conn->options->init_commands) { - unsigned int current_command = 0; - for (; current_command < conn->options->num_commands; ++current_command) { - const char * const command = conn->options->init_commands[current_command]; - if (command) { - MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_INIT_COMMAND_EXECUTED_COUNT); - if (PASS != conn->m->query(conn, command, strlen(command) TSRMLS_CC)) { - MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_INIT_COMMAND_FAILED_COUNT); - goto err; - } - if (conn->last_query_type == QUERY_SELECT) { - MYSQLND_RES * result = conn->m->use_result(conn TSRMLS_CC); - if (result) { - result->m.free_result(result, TRUE TSRMLS_CC); - } - } - } - } + if (FAIL == conn->m->execute_init_commands(conn TSRMLS_CC)) { + goto err; } - MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn->stats, STAT_CONNECT_SUCCESS, 1, STAT_OPENED_CONNECTIONS, 1); if (reconnect) { MYSQLND_INC_GLOBAL_STATISTIC(STAT_RECONNECT); @@ -934,13 +1053,10 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn, DBG_INF_FMT("connection_id=%llu", conn->thread_id); - PACKET_FREE(greet_packet); - conn->m->local_tx_end(conn, this_func, PASS TSRMLS_CC); DBG_RETURN(PASS); } err: - PACKET_FREE(greet_packet); DBG_ERR_FMT("[%u] %.128s (trying to connect via %s)", conn->error_info->error_no, conn->error_info->error, conn->scheme); if (!conn->error_info->error_no) { @@ -978,6 +1094,7 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn_handle, DBG_ENTER("mysqlnd_conn::connect"); if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { + mysqlnd_options4(conn_handle, MYSQL_OPT_CONNECT_ATTR_ADD, "_client_name", "mysqlnd"); ret = conn->m->connect(conn, host, user, passwd, passwd_len, db, db_len, port, socket_or_pipe, mysql_flags TSRMLS_CC); conn->m->local_tx_end(conn, this_func, FAIL TSRMLS_CC); @@ -986,6 +1103,7 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn_handle, } /* }}} */ + /* {{{ mysqlnd_connect */ PHPAPI MYSQLND * mysqlnd_connect(MYSQLND * conn_handle, const char * host, const char * user, @@ -1038,7 +1156,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, query)(MYSQLND_CONN_DATA * conn, const char * size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, query); enum_func_status ret = FAIL; DBG_ENTER("mysqlnd_conn_data::query"); - DBG_INF_FMT("conn=%llu query=%s", conn->thread_id, query); + DBG_INF_FMT("conn=%p conn=%llu query=%s", conn, conn->thread_id, query); if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { if (PASS == conn->m->send_query(conn, query, query_len TSRMLS_CC) && @@ -1151,7 +1269,7 @@ static int mysqlnd_stream_array_to_fd_set(MYSQLND ** conn_array, fd_set * fds, p * when casting. It is only used here so that the buffered data warning * is not displayed. * */ - if (SUCCESS == php_stream_cast((*p)->data->net->stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, + if (SUCCESS == php_stream_cast((*p)->data->net->data->m.get_stream((*p)->data->net TSRMLS_CC), PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd >= 0) { PHP_SAFE_FD_SET(this_fd, fds); @@ -1176,7 +1294,7 @@ static int mysqlnd_stream_array_from_fd_set(MYSQLND ** conn_array, fd_set * fds MYSQLND **fwd = conn_array, **bckwd = conn_array; while (*fwd) { - if (SUCCESS == php_stream_cast((*fwd)->data->net->stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, + if (SUCCESS == php_stream_cast((*fwd)->data->net->data->m.get_stream((*fwd)->data->net TSRMLS_CC), PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd >= 0) { if (PHP_SAFE_FD_ISSET(this_fd, fds)) { if (disproportion) { @@ -1222,13 +1340,12 @@ _mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQLND ***dont_poll, long s DBG_RETURN(FAIL); } - *dont_poll = mysqlnd_stream_array_check_for_readiness(r_array TSRMLS_CC); - FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&efds); if (r_array != NULL) { + *dont_poll = mysqlnd_stream_array_check_for_readiness(r_array TSRMLS_CC); set_count = mysqlnd_stream_array_to_fd_set(r_array, &rfds, &max_fd TSRMLS_CC); if (set_count > max_set_count) { max_set_count = set_count; @@ -1447,14 +1564,15 @@ MYSQLND_METHOD(mysqlnd_conn_data, ssl_set)(MYSQLND_CONN_DATA * const conn, const { size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, ssl_set); enum_func_status ret = FAIL; + MYSQLND_NET * net = conn->net; DBG_ENTER("mysqlnd_conn_data::ssl_set"); if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { - ret = (PASS == conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_KEY, key TSRMLS_CC) && - PASS == conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CERT, cert TSRMLS_CC) && - PASS == conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CA, ca TSRMLS_CC) && - PASS == conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CAPATH, capath TSRMLS_CC) && - PASS == conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CIPHER, cipher TSRMLS_CC)) ? PASS : FAIL; + ret = (PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_KEY, key TSRMLS_CC) && + PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CERT, cert TSRMLS_CC) && + PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CA, ca TSRMLS_CC) && + PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CAPATH, capath TSRMLS_CC) && + PASS == net->data->m.set_client_option(net, MYSQLND_OPT_SSL_CIPHER, cipher TSRMLS_CC)) ? PASS : FAIL; conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); } @@ -1629,6 +1747,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, kill)(MYSQLND_CONN_DATA * conn, unsigned int p SET_ERROR_AFF_ROWS(conn); } else if (PASS == (ret = conn->m->simple_command(conn, COM_PROCESS_KILL, buff, 4, PROT_LAST, FALSE, TRUE TSRMLS_CC))) { CONN_SET_STATE(conn, CONN_QUIT_SENT); + conn->m->send_close(conn TSRMLS_CC); } conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); @@ -1726,10 +1845,11 @@ static enum_func_status MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn TSRMLS_DC) { enum_func_status ret = PASS; + MYSQLND_NET * net = conn->net; + php_stream * net_stream = net->data->m.get_stream(net TSRMLS_CC); DBG_ENTER("mysqlnd_send_close"); - DBG_INF_FMT("conn=%llu conn->net->stream->abstract=%p", - conn->thread_id, conn->net->stream? conn->net->stream->abstract:NULL); + DBG_INF_FMT("conn=%llu net->data->stream->abstract=%p", conn->thread_id, net_stream? net_stream->abstract:NULL); if (CONN_GET_STATE(conn) >= CONN_READY) { MYSQLND_DEC_CONN_STATISTIC(conn->stats, STAT_OPENED_CONNECTIONS); @@ -1740,10 +1860,11 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn TSR switch (CONN_GET_STATE(conn)) { case CONN_READY: DBG_INF("Connection clean, sending COM_QUIT"); - if (conn->net->stream) { + if (net_stream) { ret = conn->m->simple_command(conn, COM_QUIT, NULL, 0, PROT_LAST, TRUE, TRUE TSRMLS_CC); + net->data->m.close_stream(net, conn->stats, conn->error_info TSRMLS_CC); } - /* Do nothing */ + CONN_SET_STATE(conn, CONN_QUIT_SENT); break; case CONN_SENDING_LOAD_DATA: /* @@ -1759,6 +1880,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn TSR Do nothing, the connection will be brutally closed and the server will catch it and free close from its side. */ + /* Fall-through */ case CONN_ALLOCED: /* Allocated but not connected or there was failure when trying @@ -1766,15 +1888,13 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn TSR Fall-through */ + CONN_SET_STATE(conn, CONN_QUIT_SENT); + /* Fall-through */ case CONN_QUIT_SENT: /* The user has killed its own connection */ + net->data->m.close_stream(net, conn->stats, conn->error_info TSRMLS_CC); break; } - /* - We hold one reference, and every other object which needs the - connection does increase it by 1. - */ - CONN_SET_STATE(conn, CONN_QUIT_SENT); DBG_RETURN(ret); } @@ -1816,7 +1936,7 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, free_reference)(MYSQLND_CONN_DATA * co /* {{{ mysqlnd_conn_data::get_state */ static enum mysqlnd_connection_state -MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, get_state)(MYSQLND_CONN_DATA * const conn TSRMLS_DC) +MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, get_state)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC) { DBG_ENTER("mysqlnd_conn_data::get_state"); DBG_RETURN(conn->state); @@ -2014,6 +2134,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, next_result)(MYSQLND_CONN_DATA * const conn TS DBG_ERR_FMT("Serious error. %s::%u", __FILE__, __LINE__); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Serious error. PID=%d", getpid()); CONN_SET_STATE(conn, CONN_QUIT_SENT); + conn->m->send_close(conn TSRMLS_CC); } else { DBG_INF_FMT("Error from the server : (%u) %s", conn->error_info->error_no, conn->error_info->error); } @@ -2093,13 +2214,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, change_user)(MYSQLND_CONN_DATA * const conn, TSRMLS_DC) { size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, change_user); - /* - User could be max 16 * 3 (utf8), pass is 20 usually, db is up to 64*3 - Stack space is not that expensive, so use a bit more to be protected against - buffer overflows. - */ enum_func_status ret = FAIL; - zend_bool local_tx_started = FALSE; DBG_ENTER("mysqlnd_conn_data::change_user"); DBG_INF_FMT("conn=%llu user=%s passwd=%s db=%s silent=%u", @@ -2108,7 +2223,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, change_user)(MYSQLND_CONN_DATA * const conn, if (PASS != conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { goto end; } - local_tx_started = TRUE; SET_EMPTY_ERROR(*conn->error_info); SET_ERROR_AFF_ROWS(conn); @@ -2121,122 +2235,20 @@ MYSQLND_METHOD(mysqlnd_conn_data, change_user)(MYSQLND_CONN_DATA * const conn, } if (!db) { db = ""; - } - - { - zend_bool first_call = TRUE; - char * switch_to_auth_protocol = NULL; - size_t switch_to_auth_protocol_len = 0; - char * requested_protocol = NULL; - zend_uchar * plugin_data; - size_t plugin_data_len; - - plugin_data_len = conn->auth_plugin_data_len; - plugin_data = mnd_emalloc(plugin_data_len); - if (!plugin_data) { - ret = FAIL; - goto end; - } - memcpy(plugin_data, conn->auth_plugin_data, plugin_data_len); - - requested_protocol = mnd_pestrdup(conn->options->auth_protocol? conn->options->auth_protocol:"mysql_native_password", FALSE); - if (!requested_protocol) { - ret = FAIL; - goto end; - } - - do { - struct st_mysqlnd_authentication_plugin * auth_plugin; - { - char * plugin_name = NULL; - - mnd_sprintf(&plugin_name, 0, "auth_plugin_%s", requested_protocol); - - DBG_INF_FMT("looking for %s auth plugin", plugin_name); - auth_plugin = mysqlnd_plugin_find(plugin_name); - mnd_sprintf_free(plugin_name); - - if (!auth_plugin) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The server requested authentication method unknown to the client [%s]", requested_protocol); - SET_CLIENT_ERROR(*conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "The server requested authentication method umknown to the client"); - break; - } - } - DBG_INF("plugin found"); - - { - zend_uchar * switch_to_auth_protocol_data = NULL; - size_t switch_to_auth_protocol_data_len = 0; - zend_uchar * scrambled_data = NULL; - size_t scrambled_data_len = 0; - switch_to_auth_protocol = NULL; - switch_to_auth_protocol_len = 0; - - if (conn->auth_plugin_data) { - mnd_pefree(conn->auth_plugin_data, conn->persistent); - conn->auth_plugin_data = NULL; - } - conn->auth_plugin_data_len = plugin_data_len; - conn->auth_plugin_data = mnd_pemalloc(conn->auth_plugin_data_len, conn->persistent); - if (!conn->auth_plugin_data) { - SET_OOM_ERROR(*conn->error_info); - ret = FAIL; - goto end; - } - memcpy(conn->auth_plugin_data, plugin_data, plugin_data_len); - - DBG_INF_FMT("salt=[%*.s]", plugin_data_len - 1, plugin_data); - - /* The data should be allocated with malloc() */ - scrambled_data = - auth_plugin->methods.get_auth_data(NULL, &scrambled_data_len, conn, user, passwd, passwd_len, - plugin_data, plugin_data_len, 0, conn->server_capabilities TSRMLS_CC); - - - ret = mysqlnd_auth_change_user(conn, user, strlen(user), passwd, passwd_len, db, strlen(db), silent, - first_call, - requested_protocol, - scrambled_data, scrambled_data_len, - &switch_to_auth_protocol, &switch_to_auth_protocol_len, - &switch_to_auth_protocol_data, &switch_to_auth_protocol_data_len - TSRMLS_CC); - - first_call = FALSE; - free(scrambled_data); + } - DBG_INF_FMT("switch_to_auth_protocol=%s", switch_to_auth_protocol? switch_to_auth_protocol:"n/a"); - if (requested_protocol) { - mnd_efree(requested_protocol); - } - requested_protocol = switch_to_auth_protocol; + /* XXX: passwords that have \0 inside work during auth, but in this case won't work with change user */ + ret = mysqlnd_run_authentication(conn, user, passwd, strlen(passwd), db, strlen(db), + conn->auth_plugin_data, conn->auth_plugin_data_len, conn->options->auth_protocol, + 0 /*charset not used*/, conn->options, conn->server_capabilities, silent, TRUE/*is_change*/ TSRMLS_CC); - if (plugin_data) { - mnd_efree(plugin_data); - } - plugin_data_len = switch_to_auth_protocol_data_len; - plugin_data = switch_to_auth_protocol_data; - } - DBG_INF_FMT("conn->error_info->error_no = %d", conn->error_info->error_no); - } while (ret == FAIL && conn->error_info->error_no == 0 && switch_to_auth_protocol != NULL); - if (plugin_data) { - mnd_efree(plugin_data); - } - if (ret == PASS) { - conn->m->set_client_option(conn, MYSQLND_OPT_AUTH_PROTOCOL, requested_protocol TSRMLS_CC); - } - if (requested_protocol) { - mnd_efree(requested_protocol); - } - } /* Here we should close all statements. Unbuffered queries should not be a problem as we won't allow sending COM_CHANGE_USER. */ + conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); end: - if (TRUE == local_tx_started) { - conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); - } DBG_INF(ret == PASS? "PASS":"FAIL"); DBG_RETURN(ret); } @@ -2273,13 +2285,9 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c case MYSQL_OPT_CONNECT_TIMEOUT: case MYSQLND_OPT_NET_CMD_BUFFER_SIZE: case MYSQLND_OPT_NET_READ_BUFFER_SIZE: - ret = conn->net->m.set_client_option(conn->net, option, value TSRMLS_CC); - break; -#if MYSQLND_UNICODE - case MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE: - conn->options->numeric_and_datetime_as_unicode = *(unsigned int*) value; + case MYSQL_SERVER_PUBLIC_KEY: + ret = conn->net->data->m.set_client_option(conn->net, option, value TSRMLS_CC); break; -#endif #ifdef MYSQLND_STRING_TO_INT_CONVERSION case MYSQLND_OPT_INT_AND_FLOAT_NATIVE: conn->options->int_and_float_native = *(unsigned int*) value; @@ -2384,6 +2392,19 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c conn->options->flags &= ~CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS; } break; + case MYSQL_OPT_CONNECT_ATTR_RESET: + if (conn->options->connect_attr) { + DBG_INF_FMT("Before reset %d attribute(s)", zend_hash_num_elements(conn->options->connect_attr)); + zend_hash_clean(conn->options->connect_attr); + } + break; + case MYSQL_OPT_CONNECT_ATTR_DELETE: + if (conn->options->connect_attr && value) { + DBG_INF_FMT("Before delete %d attribute(s)", zend_hash_num_elements(conn->options->connect_attr)); + zend_hash_del(conn->options->connect_attr, value, strlen(value)); + DBG_INF_FMT("%d left", zend_hash_num_elements(conn->options->connect_attr)); + } + break; #ifdef WHEN_SUPPORTED_BY_MYSQLI case MYSQL_SHARED_MEMORY_BASE_NAME: case MYSQL_OPT_USE_RESULT: @@ -2404,6 +2425,83 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c /* }}} */ +/* {{{ connect_attr_item_edtor */ +static void +connect_attr_item_edtor(void * pDest) +{ +#ifdef ZTS + TSRMLS_FETCH(); +#endif + DBG_ENTER("connect_attr_item_edtor"); + mnd_efree(*(char **) pDest); + DBG_VOID_RETURN; +} +/* }}} */ + + +/* {{{ connect_attr_item_pdtor */ +static void +connect_attr_item_pdtor(void * pDest) +{ +#ifdef ZTS + TSRMLS_FETCH(); +#endif + DBG_ENTER("connect_attr_item_pdtor"); + mnd_pefree(*(char **) pDest, 1); + DBG_VOID_RETURN; +} +/* }}} */ + + +/* {{{ mysqlnd_conn_data::set_client_option_2d */ +static enum_func_status +MYSQLND_METHOD(mysqlnd_conn_data, set_client_option_2d)(MYSQLND_CONN_DATA * const conn, + enum mysqlnd_option option, + const char * const key, + const char * const value + TSRMLS_DC) +{ + size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, set_client_option_2d); + enum_func_status ret = PASS; + DBG_ENTER("mysqlnd_conn_data::set_client_option_2d"); + DBG_INF_FMT("conn=%llu option=%u", conn->thread_id, option); + + if (PASS != conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { + goto end; + } + switch (option) { + case MYSQL_OPT_CONNECT_ATTR_ADD: + if (!conn->options->connect_attr) { + DBG_INF("Initializing connect_attr hash"); + conn->options->connect_attr = mnd_pemalloc(sizeof(HashTable), conn->persistent); + if (!conn->options->connect_attr) { + goto oom; + } + zend_hash_init(conn->options->connect_attr, 0, NULL, conn->persistent? connect_attr_item_pdtor:connect_attr_item_edtor, conn->persistent); + } + DBG_INF_FMT("Adding [%s][%s]", key, value); + { + const char * copyv = mnd_pestrdup(value, conn->persistent); + if (!copyv) { + goto oom; + } + zend_hash_update(conn->options->connect_attr, key, strlen(key), ©v, sizeof(char *), NULL); + } + break; + default: + ret = FAIL; + } + conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); + DBG_RETURN(ret); +oom: + SET_OOM_ERROR(*conn->error_info); + conn->m->local_tx_end(conn, this_func, FAIL TSRMLS_CC); +end: + DBG_RETURN(FAIL); +} +/* }}} */ + + /* {{{ mysqlnd_conn_data::use_result */ static MYSQLND_RES * MYSQLND_METHOD(mysqlnd_conn_data, use_result)(MYSQLND_CONN_DATA * const conn TSRMLS_DC) @@ -2454,7 +2552,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, store_result)(MYSQLND_CONN_DATA * const conn T MYSQLND_RES * result = NULL; DBG_ENTER("mysqlnd_conn_data::store_result"); - DBG_INF_FMT("conn=%llu", conn->thread_id); + DBG_INF_FMT("conn=%llu conn=%p", conn->thread_id, conn); if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { do { @@ -2519,12 +2617,174 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_autocommit)(MYSQLND_CONN_DATA * conn, unsi static enum_func_status MYSQLND_METHOD(mysqlnd_conn_data, tx_commit)(MYSQLND_CONN_DATA * conn TSRMLS_DC) { - size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, tx_commit); + return conn->m->tx_commit_or_rollback(conn, TRUE, TRANS_COR_NO_OPT, NULL TSRMLS_CC); +} +/* }}} */ + + +/* {{{ mysqlnd_conn_data::tx_rollback */ +static enum_func_status +MYSQLND_METHOD(mysqlnd_conn_data, tx_rollback)(MYSQLND_CONN_DATA * conn TSRMLS_DC) +{ + return conn->m->tx_commit_or_rollback(conn, FALSE, TRANS_COR_NO_OPT, NULL TSRMLS_CC); +} +/* }}} */ + + +/* {{{ mysqlnd_tx_cor_options_to_string */ +static void +MYSQLND_METHOD(mysqlnd_conn_data, tx_cor_options_to_string)(const MYSQLND_CONN_DATA * const conn, smart_str * str, const unsigned int mode TSRMLS_DC) +{ + if (mode & TRANS_COR_AND_CHAIN && !(mode & TRANS_COR_AND_NO_CHAIN)) { + if (str->len) { + smart_str_appendl(str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(str, "AND CHAIN", sizeof("AND CHAIN") - 1); + } else if (mode & TRANS_COR_AND_NO_CHAIN && !(mode & TRANS_COR_AND_CHAIN)) { + if (str->len) { + smart_str_appendl(str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(str, "AND NO CHAIN", sizeof("AND NO CHAIN") - 1); + } + + if (mode & TRANS_COR_RELEASE && !(mode & TRANS_COR_NO_RELEASE)) { + if (str->len) { + smart_str_appendl(str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(str, "RELEASE", sizeof("RELEASE") - 1); + } else if (mode & TRANS_COR_NO_RELEASE && !(mode & TRANS_COR_RELEASE)) { + if (str->len) { + smart_str_appendl(str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(str, "NO RELEASE", sizeof("NO RELEASE") - 1); + } + smart_str_0(str); +} +/* }}} */ + + +/* {{{ mysqlnd_conn_data::tx_commit_ex */ +static enum_func_status +MYSQLND_METHOD(mysqlnd_conn_data, tx_commit_or_rollback)(MYSQLND_CONN_DATA * conn, const zend_bool commit, const unsigned int flags, const char * const name TSRMLS_DC) +{ + size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, tx_commit_or_rollback); + enum_func_status ret = FAIL; + DBG_ENTER("mysqlnd_conn_data::tx_commit_or_rollback"); + + if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { + do { + smart_str tmp_str = {0, 0, 0}; + conn->m->tx_cor_options_to_string(conn, &tmp_str, flags TSRMLS_CC); + smart_str_0(&tmp_str); + + { + char * commented_name = NULL; + unsigned int commented_name_len = name? mnd_sprintf(&commented_name, 0, " /*%s*/", name):0; + char * query; + unsigned int query_len = mnd_sprintf(&query, 0, (commit? "COMMIT%s %s":"ROLLBACK%s %s"), + commented_name? commented_name:"", tmp_str.c? tmp_str.c:""); + smart_str_free(&tmp_str); + + if (!query) { + SET_OOM_ERROR(*conn->error_info); + break; + } + ret = conn->m->query(conn, query, query_len TSRMLS_CC); + mnd_sprintf_free(query); + if (commented_name) { + mnd_sprintf_free(commented_name); + } + } + } while (0); + conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); + } + + DBG_RETURN(ret); +} +/* }}} */ + + +/* {{{ mysqlnd_conn_data::tx_begin */ +static enum_func_status +MYSQLND_METHOD(mysqlnd_conn_data, tx_begin)(MYSQLND_CONN_DATA * conn, const unsigned int mode, const char * const name TSRMLS_DC) +{ + size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, tx_begin); + enum_func_status ret = FAIL; + DBG_ENTER("mysqlnd_conn_data::tx_begin"); + + if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { + do { + smart_str tmp_str = {0, 0, 0}; + if (mode & TRANS_START_WITH_CONSISTENT_SNAPSHOT) { + if (tmp_str.len) { + smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(&tmp_str, "WITH CONSISTENT SNAPSHOT", sizeof("WITH CONSISTENT SNAPSHOT") - 1); + } + if (mode & TRANS_START_READ_WRITE) { + if (tmp_str.len) { + smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1); + } + if (mode & TRANS_START_READ_ONLY) { + if (tmp_str.len) { + smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1); + } + smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 1); + } + smart_str_0(&tmp_str); + + { + char * commented_name = NULL; + unsigned int commented_name_len = name? mnd_sprintf(&commented_name, 0, " /*%s*/", name):0; + char * query; + unsigned int query_len = mnd_sprintf(&query, 0, "START TRANSACTION%s %s", commented_name? commented_name:"", tmp_str.c? tmp_str.c:""); + smart_str_free(&tmp_str); + + if (!query) { + SET_OOM_ERROR(*conn->error_info); + break; + } + ret = conn->m->query(conn, query, query_len TSRMLS_CC); + mnd_sprintf_free(query); + if (commented_name) { + mnd_sprintf_free(commented_name); + } + } + } while (0); + conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); + } + + DBG_RETURN(ret); +} +/* }}} */ + + +/* {{{ mysqlnd_conn_data::tx_savepoint */ +static enum_func_status +MYSQLND_METHOD(mysqlnd_conn_data, tx_savepoint)(MYSQLND_CONN_DATA * conn, const char * const name TSRMLS_DC) +{ + size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, tx_savepoint); enum_func_status ret = FAIL; - DBG_ENTER("mysqlnd_conn_data::tx_commit"); + DBG_ENTER("mysqlnd_conn_data::tx_savepoint"); if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { - ret = conn->m->query(conn, "COMMIT", sizeof("COMMIT") - 1 TSRMLS_CC); + do { + char * query; + unsigned int query_len; + if (!name) { + SET_CLIENT_ERROR(*conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "Savepoint name not provided"); + break; + } + query_len = mnd_sprintf(&query, 0, "SAVEPOINT `%s`", name); + if (!query) { + SET_OOM_ERROR(*conn->error_info); + break; + } + ret = conn->m->query(conn, query, query_len TSRMLS_CC); + mnd_sprintf_free(query); + } while (0); conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); } @@ -2533,16 +2793,30 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_commit)(MYSQLND_CONN_DATA * conn TSRMLS_DC) /* }}} */ -/* {{{ mysqlnd_conn_data::tx_rollback */ +/* {{{ mysqlnd_conn_data::tx_savepoint_release */ static enum_func_status -MYSQLND_METHOD(mysqlnd_conn_data, tx_rollback)(MYSQLND_CONN_DATA * conn TSRMLS_DC) +MYSQLND_METHOD(mysqlnd_conn_data, tx_savepoint_release)(MYSQLND_CONN_DATA * conn, const char * const name TSRMLS_DC) { - size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, tx_rollback); + size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, tx_savepoint_release); enum_func_status ret = FAIL; - DBG_ENTER("mysqlnd_conn_data::tx_rollback"); + DBG_ENTER("mysqlnd_conn_data::tx_savepoint_release"); if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { - ret = conn->m->query(conn, "ROLLBACK", sizeof("ROLLBACK") - 1 TSRMLS_CC); + do { + char * query; + unsigned int query_len; + if (!name) { + SET_CLIENT_ERROR(*conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "Savepoint name not provided"); + break; + } + query_len = mnd_sprintf(&query, 0, "RELEASE SAVEPOINT `%s`", name); + if (!query) { + SET_OOM_ERROR(*conn->error_info); + break; + } + ret = conn->m->query(conn, query, query_len TSRMLS_CC); + mnd_sprintf_free(query); + } while (0); conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); } @@ -2665,8 +2939,21 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_conn_data) MYSQLND_METHOD(mysqlnd_conn_data, set_autocommit), MYSQLND_METHOD(mysqlnd_conn_data, tx_commit), MYSQLND_METHOD(mysqlnd_conn_data, tx_rollback), + MYSQLND_METHOD(mysqlnd_conn_data, tx_begin), + MYSQLND_METHOD(mysqlnd_conn_data, tx_commit_or_rollback), + MYSQLND_METHOD(mysqlnd_conn_data, tx_cor_options_to_string), + MYSQLND_METHOD(mysqlnd_conn_data, tx_savepoint), + MYSQLND_METHOD(mysqlnd_conn_data, tx_savepoint_release), + MYSQLND_METHOD(mysqlnd_conn_data, local_tx_start), - MYSQLND_METHOD(mysqlnd_conn_data, local_tx_end) + MYSQLND_METHOD(mysqlnd_conn_data, local_tx_end), + MYSQLND_METHOD(mysqlnd_conn_data, execute_init_commands), + MYSQLND_METHOD(mysqlnd_conn_data, get_updated_connect_flags), + MYSQLND_METHOD(mysqlnd_conn_data, connect_handshake), + MYSQLND_METHOD(mysqlnd_conn_data, simple_command_send_request), + MYSQLND_METHOD(mysqlnd_conn_data, fetch_auth_plugin_by_name), + + MYSQLND_METHOD(mysqlnd_conn_data, set_client_option_2d) MYSQLND_CLASS_METHODS_END; diff --git a/ext/mysqlnd/mysqlnd.h b/ext/mysqlnd/mysqlnd.h index e707c415db320..40933630edef5 100644 --- a/ext/mysqlnd/mysqlnd.h +++ b/ext/mysqlnd/mysqlnd.h @@ -22,10 +22,10 @@ #ifndef MYSQLND_H #define MYSQLND_H -#define MYSQLND_VERSION "mysqlnd 5.0.10 - 20111026 - $Id$" -#define MYSQLND_VERSION_ID 50010 +#define MYSQLND_VERSION "mysqlnd 5.0.11-dev - 20120503 - $Id$" +#define MYSQLND_VERSION_ID 50011 -#define MYSQLND_PLUGIN_API_VERSION 1 +#define MYSQLND_PLUGIN_API_VERSION 2 #define MYSQLND_STRING_TO_INT_CONVERSION /* @@ -192,8 +192,11 @@ PHPAPI void mysqlnd_set_local_infile_handler(MYSQLND_CONN_DATA * const conn, con /* Simple commands */ #define mysqlnd_autocommit(conn, mode) ((conn)->data)->m->set_autocommit((conn)->data, (mode) TSRMLS_CC) -#define mysqlnd_commit(conn) ((conn)->data)->m->tx_commit((conn)->data TSRMLS_CC) -#define mysqlnd_rollback(conn) ((conn)->data)->m->tx_rollback((conn)->data TSRMLS_CC) +#define mysqlnd_begin_transaction(conn,flags,name) ((conn)->data)->m->tx_begin((conn)->data, (flags), (name) TSRMLS_CC) +#define mysqlnd_commit(conn, flags, name) ((conn)->data)->m->tx_commit_or_rollback((conn)->data, TRUE, (flags), (name) TSRMLS_CC) +#define mysqlnd_rollback(conn, flags, name) ((conn)->data)->m->tx_commit_or_rollback((conn)->data, FALSE, (flags), (name) TSRMLS_CC) +#define mysqlnd_savepoint(conn, name) ((conn)->data)->m->tx_savepoint((conn)->data, (name) TSRMLS_CC) +#define mysqlnd_release_savepoint(conn, name) ((conn)->data)->m->tx_savepoint_release((conn)->data, (name) TSRMLS_CC) #define mysqlnd_list_dbs(conn, wild) ((conn)->data)->m->list_method((conn)->data, wild? "SHOW DATABASES LIKE %s":"SHOW DATABASES", (wild), NULL TSRMLS_CC) #define mysqlnd_list_fields(conn, tab,wild) ((conn)->data)->m->list_fields((conn)->data, (tab), (wild) TSRMLS_CC) #define mysqlnd_list_processes(conn) ((conn)->data)->m->list_method((conn)->data, "SHOW PROCESSLIST", NULL, NULL TSRMLS_CC) @@ -207,6 +210,7 @@ PHPAPI void mysqlnd_set_local_infile_handler(MYSQLND_CONN_DATA * const conn, con #define mysqlnd_set_character_set(conn, cs) ((conn)->data)->m->set_charset((conn)->data, (cs) TSRMLS_CC) #define mysqlnd_stat(conn, msg, msg_len) ((conn)->data)->m->get_server_statistics(((conn)->data), (msg), (msg_len) TSRMLS_CC) #define mysqlnd_options(conn, opt, value) ((conn)->data)->m->set_client_option((conn)->data, (opt), (value) TSRMLS_CC) +#define mysqlnd_options4(conn, opt, k, v) ((conn)->data)->m->set_client_option_2d((conn)->data, (opt), (k), (v) TSRMLS_CC) #define mysqlnd_set_server_option(conn, op) ((conn)->data)->m->set_server_option((conn)->data, (op) TSRMLS_CC) /* Escaping */ @@ -262,8 +266,10 @@ PHPAPI void _mysqlnd_get_client_stats(zval *return_value TSRMLS_DC ZEND_FILE_L ZEND_BEGIN_MODULE_GLOBALS(mysqlnd) zend_bool collect_statistics; zend_bool collect_memory_statistics; - char* debug; /* The actual string */ - MYSQLND_DEBUG *dbg; /* The DBG object */ + char * debug; /* The actual string */ + char * trace_alloc_settings; /* The actual string */ + MYSQLND_DEBUG * dbg; /* The DBG object for standard tracing */ + MYSQLND_DEBUG * trace_alloc; /* The DBG object for allocation tracing */ long net_cmd_buffer_size; long net_read_buffer_size; long log_mask; @@ -275,6 +281,7 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqlnd) long debug_malloc_fail_threshold; long debug_calloc_fail_threshold; long debug_realloc_fail_threshold; + char * sha256_server_public_key; ZEND_END_MODULE_GLOBALS(mysqlnd) PHPAPI ZEND_EXTERN_MODULE_GLOBALS(mysqlnd) diff --git a/ext/mysqlnd/mysqlnd_alloc.c b/ext/mysqlnd/mysqlnd_alloc.c index 380a0fbaa061b..325444cdc4bfa 100644 --- a/ext/mysqlnd/mysqlnd_alloc.c +++ b/ext/mysqlnd/mysqlnd_alloc.c @@ -65,8 +65,8 @@ const char * mysqlnd_debug_std_no_trace_funcs[] = #if ZEND_DEBUG #else -#define __zend_filename "/unknown/unknown" -#define __zend_lineno 0 +#define __zend_orig_filename "/unknown/unknown" +#define __zend_orig_lineno 0 #endif #define REAL_SIZE(s) (collect_memory_statistics? (s) + sizeof(size_t) : (s)) @@ -81,12 +81,12 @@ void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D) #if PHP_DEBUG long * threshold = &MYSQLND_G(debug_emalloc_fail_threshold); #endif - DBG_ENTER(mysqlnd_emalloc_name); + TRACE_ALLOC_ENTER(mysqlnd_emalloc_name); #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif @@ -94,7 +94,7 @@ void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D) /* -1 is also "true" */ if (*threshold) { #endif - ret = emalloc(REAL_SIZE(size)); + ret = _emalloc(REAL_SIZE(size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC); #if PHP_DEBUG --*threshold; } else if (*threshold == 0) { @@ -102,13 +102,13 @@ void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D) } #endif - DBG_INF_FMT("size=%lu ptr=%p", size, ret); + TRACE_ALLOC_INF_FMT("size=%lu ptr=%p", size, ret); if (ret && collect_memory_statistics) { *(size_t *) ret = size; MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_EMALLOC_COUNT, 1, STAT_MEM_EMALLOC_AMOUNT, size); } - DBG_RETURN(FAKE_PTR(ret)); + TRACE_ALLOC_RETURN(FAKE_PTR(ret)); } /* }}} */ @@ -121,11 +121,12 @@ void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D) #if PHP_DEBUG long * threshold = persistent? &MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold); #endif - DBG_ENTER(mysqlnd_pemalloc_name); + TRACE_ALLOC_ENTER(mysqlnd_pemalloc_name); + #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif @@ -133,7 +134,7 @@ void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D) /* -1 is also "true" */ if (*threshold) { #endif - ret = pemalloc(REAL_SIZE(size), persistent); + ret = (persistent) ? __zend_malloc(REAL_SIZE(size)) : _emalloc(REAL_SIZE(size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC); #if PHP_DEBUG --*threshold; } else if (*threshold == 0) { @@ -141,7 +142,7 @@ void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D) } #endif - DBG_INF_FMT("size=%lu ptr=%p persistent=%u", size, ret, persistent); + TRACE_ALLOC_INF_FMT("size=%lu ptr=%p persistent=%u", size, ret, persistent); if (ret && collect_memory_statistics) { enum mysqlnd_collected_stats s1 = persistent? STAT_MEM_MALLOC_COUNT:STAT_MEM_EMALLOC_COUNT; @@ -150,7 +151,7 @@ void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D) MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(s1, 1, s2, size); } - DBG_RETURN(FAKE_PTR(ret)); + TRACE_ALLOC_RETURN(FAKE_PTR(ret)); } /* }}} */ @@ -163,20 +164,21 @@ void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D) #if PHP_DEBUG long * threshold = &MYSQLND_G(debug_ecalloc_fail_threshold); #endif - DBG_ENTER(mysqlnd_ecalloc_name); + TRACE_ALLOC_ENTER(mysqlnd_ecalloc_name); + #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif - DBG_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC)); + TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC)); #if PHP_DEBUG /* -1 is also "true" */ if (*threshold) { #endif - ret = ecalloc(nmemb, REAL_SIZE(size)); + ret = _ecalloc(nmemb, REAL_SIZE(size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC); #if PHP_DEBUG --*threshold; } else if (*threshold == 0) { @@ -184,13 +186,13 @@ void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D) } #endif - DBG_INF_FMT("after : %lu", zend_memory_usage(FALSE TSRMLS_CC)); - DBG_INF_FMT("size=%lu ptr=%p", size, ret); + TRACE_ALLOC_INF_FMT("after : %lu", zend_memory_usage(FALSE TSRMLS_CC)); + TRACE_ALLOC_INF_FMT("size=%lu ptr=%p", size, ret); if (ret && collect_memory_statistics) { *(size_t *) ret = size; MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_ECALLOC_COUNT, 1, STAT_MEM_ECALLOC_AMOUNT, size); } - DBG_RETURN(FAKE_PTR(ret)); + TRACE_ALLOC_RETURN(FAKE_PTR(ret)); } /* }}} */ @@ -203,11 +205,11 @@ void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent M #if PHP_DEBUG long * threshold = persistent? &MYSQLND_G(debug_calloc_fail_threshold):&MYSQLND_G(debug_ecalloc_fail_threshold); #endif - DBG_ENTER(mysqlnd_pecalloc_name); + TRACE_ALLOC_ENTER(mysqlnd_pecalloc_name); #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif @@ -215,7 +217,7 @@ void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent M /* -1 is also "true" */ if (*threshold) { #endif - ret = pecalloc(nmemb, REAL_SIZE(size), persistent); + ret = (persistent) ? __zend_calloc(nmemb, REAL_SIZE(size)) : _ecalloc(nmemb, REAL_SIZE(size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC); #if PHP_DEBUG --*threshold; } else if (*threshold == 0) { @@ -223,7 +225,7 @@ void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent M } #endif - DBG_INF_FMT("size=%lu ptr=%p", size, ret); + TRACE_ALLOC_INF_FMT("size=%lu ptr=%p", size, ret); if (ret && collect_memory_statistics) { enum mysqlnd_collected_stats s1 = persistent? STAT_MEM_CALLOC_COUNT:STAT_MEM_ECALLOC_COUNT; @@ -232,7 +234,7 @@ void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent M MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(s1, 1, s2, size); } - DBG_RETURN(FAKE_PTR(ret)); + TRACE_ALLOC_RETURN(FAKE_PTR(ret)); } /* }}} */ @@ -246,20 +248,21 @@ void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D) #if PHP_DEBUG long * threshold = &MYSQLND_G(debug_erealloc_fail_threshold); #endif - DBG_ENTER(mysqlnd_erealloc_name); + TRACE_ALLOC_ENTER(mysqlnd_erealloc_name); + #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif - DBG_INF_FMT("ptr=%p old_size=%lu, new_size=%lu", ptr, old_size, new_size); + TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu, new_size=%lu", ptr, old_size, new_size); #if PHP_DEBUG /* -1 is also "true" */ if (*threshold) { #endif - ret = erealloc(REAL_PTR(ptr), REAL_SIZE(new_size)); + ret = _erealloc(REAL_PTR(ptr), REAL_SIZE(new_size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC); #if PHP_DEBUG --*threshold; } else if (*threshold == 0) { @@ -267,12 +270,12 @@ void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D) } #endif - DBG_INF_FMT("new_ptr=%p", (char*)ret); + TRACE_ALLOC_INF_FMT("new_ptr=%p", (char*)ret); if (ret && collect_memory_statistics) { *(size_t *) ret = new_size; MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_EREALLOC_COUNT, 1, STAT_MEM_EREALLOC_AMOUNT, new_size); } - DBG_RETURN(FAKE_PTR(ret)); + TRACE_ALLOC_RETURN(FAKE_PTR(ret)); } /* }}} */ @@ -286,14 +289,15 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL #if PHP_DEBUG long * threshold = persistent? &MYSQLND_G(debug_realloc_fail_threshold):&MYSQLND_G(debug_erealloc_fail_threshold); #endif - DBG_ENTER(mysqlnd_perealloc_name); + TRACE_ALLOC_ENTER(mysqlnd_perealloc_name); + #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif - DBG_INF_FMT("ptr=%p old_size=%lu new_size=%lu persistent=%u", ptr, old_size, new_size, persistent); + TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu new_size=%lu persistent=%u", ptr, old_size, new_size, persistent); #if PHP_DEBUG /* -1 is also "true" */ @@ -307,7 +311,7 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL } #endif - DBG_INF_FMT("new_ptr=%p", (char*)ret); + TRACE_ALLOC_INF_FMT("new_ptr=%p", (char*)ret); if (ret && collect_memory_statistics) { enum mysqlnd_collected_stats s1 = persistent? STAT_MEM_REALLOC_COUNT:STAT_MEM_EREALLOC_COUNT; @@ -315,7 +319,7 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL *(size_t *) ret = new_size; MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(s1, 1, s2, new_size); } - DBG_RETURN(FAKE_PTR(ret)); + TRACE_ALLOC_RETURN(FAKE_PTR(ret)); } /* }}} */ @@ -325,27 +329,28 @@ void _mysqlnd_efree(void *ptr MYSQLND_MEM_D) { size_t free_amount = 0; zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics); - DBG_ENTER(mysqlnd_efree_name); + TRACE_ALLOC_ENTER(mysqlnd_efree_name); + #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif - DBG_INF_FMT("ptr=%p", ptr); + TRACE_ALLOC_INF_FMT("ptr=%p", ptr); if (ptr) { if (collect_memory_statistics) { free_amount = *(size_t *)(((char*)ptr) - sizeof(size_t)); - DBG_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount); + TRACE_ALLOC_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount); } - efree(REAL_PTR(ptr)); + _efree(REAL_PTR(ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC); } if (collect_memory_statistics) { MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_EFREE_COUNT, 1, STAT_MEM_EFREE_AMOUNT, free_amount); } - DBG_VOID_RETURN; + TRACE_ALLOC_VOID_RETURN; } /* }}} */ @@ -355,29 +360,31 @@ void _mysqlnd_pefree(void *ptr, zend_bool persistent MYSQLND_MEM_D) { size_t free_amount = 0; zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics); - DBG_ENTER(mysqlnd_pefree_name); + TRACE_ALLOC_ENTER(mysqlnd_pefree_name); + #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif - DBG_INF_FMT("ptr=%p persistent=%u", ptr, persistent); + TRACE_ALLOC_INF_FMT("ptr=%p persistent=%u", ptr, persistent); if (ptr) { if (collect_memory_statistics) { free_amount = *(size_t *)(((char*)ptr) - sizeof(size_t)); - DBG_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount); + TRACE_ALLOC_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount); } - pefree(REAL_PTR(ptr), persistent); + (persistent) ? free(REAL_PTR(ptr)) : _efree(REAL_PTR(ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC); } if (collect_memory_statistics) { MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(persistent? STAT_MEM_FREE_COUNT:STAT_MEM_EFREE_COUNT, 1, persistent? STAT_MEM_FREE_AMOUNT:STAT_MEM_EFREE_AMOUNT, free_amount); } - DBG_VOID_RETURN; + TRACE_ALLOC_VOID_RETURN; } +/* }}} */ /* {{{ _mysqlnd_malloc */ @@ -388,11 +395,12 @@ void * _mysqlnd_malloc(size_t size MYSQLND_MEM_D) #if PHP_DEBUG long * threshold = &MYSQLND_G(debug_malloc_fail_threshold); #endif - DBG_ENTER(mysqlnd_malloc_name); + TRACE_ALLOC_ENTER(mysqlnd_malloc_name); + #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif @@ -408,12 +416,12 @@ void * _mysqlnd_malloc(size_t size MYSQLND_MEM_D) } #endif - DBG_INF_FMT("size=%lu ptr=%p", size, ret); + TRACE_ALLOC_INF_FMT("size=%lu ptr=%p", size, ret); if (ret && collect_memory_statistics) { *(size_t *) ret = size; MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_MALLOC_COUNT, 1, STAT_MEM_MALLOC_AMOUNT, size); } - DBG_RETURN(FAKE_PTR(ret)); + TRACE_ALLOC_RETURN(FAKE_PTR(ret)); } /* }}} */ @@ -426,11 +434,12 @@ void * _mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D) #if PHP_DEBUG long * threshold = &MYSQLND_G(debug_calloc_fail_threshold); #endif - DBG_ENTER(mysqlnd_calloc_name); + TRACE_ALLOC_ENTER(mysqlnd_calloc_name); + #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif @@ -446,12 +455,12 @@ void * _mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D) } #endif - DBG_INF_FMT("size=%lu ptr=%p", size, ret); + TRACE_ALLOC_INF_FMT("size=%lu ptr=%p", size, ret); if (ret && collect_memory_statistics) { *(size_t *) ret = size; MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_CALLOC_COUNT, 1, STAT_MEM_CALLOC_AMOUNT, size); } - DBG_RETURN(FAKE_PTR(ret)); + TRACE_ALLOC_RETURN(FAKE_PTR(ret)); } /* }}} */ @@ -464,15 +473,16 @@ void * _mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D) #if PHP_DEBUG long * threshold = &MYSQLND_G(debug_realloc_fail_threshold); #endif - DBG_ENTER(mysqlnd_realloc_name); + TRACE_ALLOC_ENTER(mysqlnd_realloc_name); + #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif - DBG_INF_FMT("ptr=%p new_size=%lu ", new_size, ptr); - DBG_INF_FMT("before: %lu", zend_memory_usage(TRUE TSRMLS_CC)); + TRACE_ALLOC_INF_FMT("ptr=%p new_size=%lu ", new_size, ptr); + TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(TRUE TSRMLS_CC)); #if PHP_DEBUG /* -1 is also "true" */ @@ -486,13 +496,13 @@ void * _mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D) } #endif - DBG_INF_FMT("new_ptr=%p", (char*)ret); + TRACE_ALLOC_INF_FMT("new_ptr=%p", (char*)ret); if (ret && collect_memory_statistics) { *(size_t *) ret = new_size; MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_REALLOC_COUNT, 1, STAT_MEM_REALLOC_AMOUNT, new_size); } - DBG_RETURN(FAKE_PTR(ret)); + TRACE_ALLOC_RETURN(FAKE_PTR(ret)); } /* }}} */ @@ -502,19 +512,20 @@ void _mysqlnd_free(void *ptr MYSQLND_MEM_D) { size_t free_amount = 0; zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics); - DBG_ENTER(mysqlnd_free_name); + TRACE_ALLOC_ENTER(mysqlnd_free_name); + #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif - DBG_INF_FMT("ptr=%p", ptr); + TRACE_ALLOC_INF_FMT("ptr=%p", ptr); if (ptr) { if (collect_memory_statistics) { free_amount = *(size_t *)(((char*)ptr) - sizeof(size_t)); - DBG_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount); + TRACE_ALLOC_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount); } free(REAL_PTR(ptr)); } @@ -522,7 +533,7 @@ void _mysqlnd_free(void *ptr MYSQLND_MEM_D) if (collect_memory_statistics) { MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_FREE_COUNT, 1, STAT_MEM_FREE_AMOUNT, free_amount); } - DBG_VOID_RETURN; + TRACE_ALLOC_VOID_RETURN; } /* }}} */ @@ -536,16 +547,17 @@ char * _mysqlnd_pestrndup(const char * const ptr, size_t length, zend_bool persi { char * ret; zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics); - DBG_ENTER(mysqlnd_pestrndup_name); + TRACE_ALLOC_ENTER(mysqlnd_pestrndup_name); + #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif - DBG_INF_FMT("ptr=%p", ptr); + TRACE_ALLOC_INF_FMT("ptr=%p", ptr); - ret = pemalloc(REAL_SIZE(length) + 1, persistent); + ret = (persistent) ? __zend_malloc(REAL_SIZE(length + 1)) : _emalloc(REAL_SIZE(length + 1) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC); { size_t l = length; char * p = (char *) ptr; @@ -561,7 +573,7 @@ char * _mysqlnd_pestrndup(const char * const ptr, size_t length, zend_bool persi MYSQLND_INC_GLOBAL_STATISTIC(persistent? STAT_MEM_STRNDUP_COUNT : STAT_MEM_ESTRNDUP_COUNT); } - DBG_RETURN(FAKE_PTR(ret)); + TRACE_ALLOC_RETURN(FAKE_PTR(ret)); } /* }}} */ @@ -573,19 +585,19 @@ char * _mysqlnd_pestrdup(const char * const ptr, zend_bool persistent MYSQLND_ME smart_str tmp_str = {0, 0, 0}; const char * p = ptr; zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics); - DBG_ENTER(mysqlnd_pestrdup_name); + TRACE_ALLOC_ENTER(mysqlnd_pestrdup_name); #if PHP_DEBUG { - char * fn = strrchr(__zend_filename, PHP_DIR_SEPARATOR); - DBG_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_filename, __zend_lineno); + char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR); + TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno); } #endif - DBG_INF_FMT("ptr=%p", ptr); + TRACE_ALLOC_INF_FMT("ptr=%p", ptr); do { smart_str_appendc(&tmp_str, *p); } while (*p++); - ret = pemalloc(tmp_str.len + sizeof(size_t), persistent); + ret = (persistent) ? __zend_malloc(tmp_str.len + sizeof(size_t)) : _emalloc(REAL_SIZE(tmp_str.len + sizeof(size_t)) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC); memcpy(FAKE_PTR(ret), tmp_str.c, tmp_str.len); if (ret && collect_memory_statistics) { @@ -594,7 +606,7 @@ char * _mysqlnd_pestrdup(const char * const ptr, zend_bool persistent MYSQLND_ME } smart_str_free(&tmp_str); - DBG_RETURN(FAKE_PTR(ret)); + TRACE_ALLOC_RETURN(FAKE_PTR(ret)); } /* }}} */ @@ -619,7 +631,7 @@ PHPAPI void _mysqlnd_sprintf_free(char * p) } /* }}} */ - +/* {{{ _mysqlnd_vsprintf */ PHPAPI int _mysqlnd_vsprintf(char ** pbuf, size_t max_len, const char * format, va_list ap) { return vspprintf(pbuf, max_len, format, ap); diff --git a/ext/mysqlnd/mysqlnd_alloc.h b/ext/mysqlnd/mysqlnd_alloc.h index 6bd4385e616ca..c8f1bc4cf1521 100644 --- a/ext/mysqlnd/mysqlnd_alloc.h +++ b/ext/mysqlnd/mysqlnd_alloc.h @@ -26,8 +26,8 @@ extern const char * mysqlnd_debug_std_no_trace_funcs[]; -#define MYSQLND_MEM_D TSRMLS_DC ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC -#define MYSQLND_MEM_C TSRMLS_CC ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC +#define MYSQLND_MEM_D TSRMLS_DC ZEND_FILE_LINE_ORIG_DC +#define MYSQLND_MEM_C TSRMLS_CC ZEND_FILE_LINE_CC struct st_mysqlnd_allocator_methods { diff --git a/ext/mysqlnd/mysqlnd_auth.c b/ext/mysqlnd/mysqlnd_auth.c index 918697a5f52d4..8611d998647fa 100644 --- a/ext/mysqlnd/mysqlnd_auth.c +++ b/ext/mysqlnd/mysqlnd_auth.c @@ -28,7 +28,6 @@ #include "mysqlnd_charset.h" #include "mysqlnd_debug.h" - /* {{{ mysqlnd_auth_handshake */ enum_func_status mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn, @@ -88,11 +87,7 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn, if (options->charset_name && (charset = mysqlnd_find_charset_name(options->charset_name))) { auth_packet->charset_no = charset->nr; } else { -#if MYSQLND_UNICODE - auth_packet->charset_no = 200;/* utf8 - swedish collation, check mysqlnd_charset.c */ -#else auth_packet->charset_no = server_charset_no; -#endif } auth_packet->send_auth_data = TRUE; @@ -103,6 +98,10 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn, auth_packet->auth_data = auth_plugin_data; auth_packet->auth_data_len = auth_plugin_data_len; auth_packet->auth_plugin_name = auth_protocol; + + if (conn->server_capabilities & CLIENT_CONNECT_ATTRS) { + auth_packet->connect_attr = conn->options->connect_attr; + } if (!PACKET_WRITE(auth_packet, conn)) { goto end; @@ -360,7 +359,9 @@ mysqlnd_native_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self size_t * auth_data_len, MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len, - const MYSQLND_OPTIONS * const options, unsigned long mysql_flags + const MYSQLND_OPTIONS * const options, + const MYSQLND_NET_OPTIONS * const net_options, + unsigned long mysql_flags TSRMLS_DC) { zend_uchar * ret = NULL; @@ -418,7 +419,9 @@ mysqlnd_pam_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self, size_t * auth_data_len, MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len, - const MYSQLND_OPTIONS * const options, unsigned long mysql_flags + const MYSQLND_OPTIONS * const options, + const MYSQLND_NET_OPTIONS * const net_options, + unsigned long mysql_flags TSRMLS_DC) { zend_uchar * ret = NULL; @@ -442,7 +445,7 @@ static struct st_mysqlnd_authentication_plugin mysqlnd_pam_authentication_plugin MYSQLND_VERSION_ID, MYSQLND_VERSION, "PHP License 3.01", - "Andrey Hristov , Ulf Wendel , Georg Richter ", + "Andrey Hristov , Ulf Wendel , Georg Richter ", { NULL, /* no statistics , will be filled later if there are some */ NULL, /* no statistics */ @@ -457,12 +460,202 @@ static struct st_mysqlnd_authentication_plugin mysqlnd_pam_authentication_plugin }; +/******************************************* SHA256 Password ***********************************/ +#ifdef MYSQLND_HAVE_SSL +static void +mysqlnd_xor_string(char * dst, const size_t dst_len, const char * xor_str, const size_t xor_str_len) +{ + unsigned int i; + for (i = 0; i <= dst_len; ++i) { + dst[i] ^= xor_str[i % xor_str_len]; + } +} + + +#include +#include +#include + + +/* {{{ mysqlnd_sha256_get_rsa_key */ +static RSA * +mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn, + const MYSQLND_OPTIONS * const options, + const MYSQLND_NET_OPTIONS * const net_options + TSRMLS_DC) +{ + RSA * ret = NULL; + int len; + const char * fname = (net_options->sha256_server_public_key && net_options->sha256_server_public_key[0] != '\0')? + net_options->sha256_server_public_key: + MYSQLND_G(sha256_server_public_key); + php_stream * stream; + DBG_ENTER("mysqlnd_sha256_get_rsa_key"); + DBG_INF_FMT("options_s256_pk=[%s] MYSQLND_G(sha256_server_public_key)=[%s]", + net_options->sha256_server_public_key? net_options->sha256_server_public_key:"n/a", + MYSQLND_G(sha256_server_public_key)? MYSQLND_G(sha256_server_public_key):"n/a"); + if (!fname || fname[0] == '\0') { + MYSQLND_PACKET_SHA256_PK_REQUEST * pk_req_packet = NULL; + MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE * pk_resp_packet = NULL; + + do { + DBG_INF("requesting the public key from the server"); + pk_req_packet = conn->protocol->m.get_sha256_pk_request_packet(conn->protocol, FALSE TSRMLS_CC); + if (!pk_req_packet) { + SET_OOM_ERROR(*conn->error_info); + break; + } + pk_resp_packet = conn->protocol->m.get_sha256_pk_request_response_packet(conn->protocol, FALSE TSRMLS_CC); + if (!pk_resp_packet) { + SET_OOM_ERROR(*conn->error_info); + PACKET_FREE(pk_req_packet); + break; + } + + if (! PACKET_WRITE(pk_req_packet, conn)) { + DBG_ERR_FMT("Error while sending public key request packet"); + php_error(E_WARNING, "Error while sending public key request packet. PID=%d", getpid()); + CONN_SET_STATE(conn, CONN_QUIT_SENT); + break; + } + if (FAIL == PACKET_READ(pk_resp_packet, conn) || NULL == pk_resp_packet->public_key) { + DBG_ERR_FMT("Error while receiving public key"); + php_error(E_WARNING, "Error while receiving public key. PID=%d", getpid()); + CONN_SET_STATE(conn, CONN_QUIT_SENT); + break; + } + DBG_INF_FMT("Public key(%d):\n%s", pk_resp_packet->public_key_len, pk_resp_packet->public_key); + /* now extract the public key */ + { + BIO * bio = BIO_new_mem_buf(pk_resp_packet->public_key, pk_resp_packet->public_key_len); + ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL); + BIO_free(bio); + } + } while (0); + PACKET_FREE(pk_req_packet); + PACKET_FREE(pk_resp_packet); + + DBG_INF_FMT("ret=%p", ret); + DBG_RETURN(ret); + + SET_CLIENT_ERROR(*conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, + "sha256_server_public_key is not set for the connection or as mysqlnd.sha256_server_public_key"); + DBG_ERR("server_public_key is not set"); + DBG_RETURN(NULL); + } else { + char * key_str = NULL; + DBG_INF_FMT("Key in a file. [%s]", fname); + stream = php_stream_open_wrapper((char *) fname, "rb", REPORT_ERRORS, NULL); + + if (stream) { + if ((len = php_stream_copy_to_mem(stream, &key_str, PHP_STREAM_COPY_ALL, 0)) >= 0 ) { + BIO * bio = BIO_new_mem_buf(key_str, len); + ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL); + BIO_free(bio); + DBG_INF("Successfully loaded"); + } + if (key_str) { + DBG_INF_FMT("Public key:%*.s", len, key_str); + efree(key_str); + } + php_stream_free(stream, PHP_STREAM_FREE_CLOSE); + } + } + DBG_RETURN(ret); +} +/* }}} */ + + +/* {{{ mysqlnd_sha256_auth_get_auth_data */ +static zend_uchar * +mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self, + size_t * auth_data_len, + MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, + const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len, + const MYSQLND_OPTIONS * const options, + const MYSQLND_NET_OPTIONS * const net_options, + unsigned long mysql_flags + TSRMLS_DC) +{ + RSA * server_public_key; + zend_uchar * ret = NULL; + DBG_ENTER("mysqlnd_sha256_auth_get_auth_data"); + DBG_INF_FMT("salt(%d)=[%.*s]", auth_plugin_data_len, auth_plugin_data_len, auth_plugin_data); + + + if (conn->net->data->ssl) { + DBG_INF("simple clear text under SSL"); + /* clear text under SSL */ + *auth_data_len = passwd_len; + ret = malloc(passwd_len); + memcpy(ret, passwd, passwd_len); + } else { + *auth_data_len = 0; + server_public_key = mysqlnd_sha256_get_rsa_key(conn, options, net_options TSRMLS_CC); + + if (server_public_key) { + int server_public_key_len; + char xor_str[passwd_len + 1]; + memcpy(xor_str, passwd, passwd_len); + xor_str[passwd_len] = '\0'; + mysqlnd_xor_string(xor_str, passwd_len, (char *) auth_plugin_data, auth_plugin_data_len); + + server_public_key_len = RSA_size(server_public_key); + /* + Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len. + RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here: + http://www.openssl.org/docs/crypto/RSA_public_encrypt.html + */ + if ((size_t) server_public_key_len - 41 <= passwd_len) { + /* password message is to long */ + SET_CLIENT_ERROR(*conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long"); + DBG_ERR("password is too long"); + DBG_RETURN(NULL); + } + + *auth_data_len = server_public_key_len; + ret = malloc(*auth_data_len); + RSA_public_encrypt(passwd_len + 1, (zend_uchar *) xor_str, ret, server_public_key, RSA_PKCS1_OAEP_PADDING); + } + } + + DBG_RETURN(ret); +} +/* }}} */ + + +static struct st_mysqlnd_authentication_plugin mysqlnd_sha256_authentication_plugin = +{ + { + MYSQLND_PLUGIN_API_VERSION, + "auth_plugin_sha256_password", + MYSQLND_VERSION_ID, + MYSQLND_VERSION, + "PHP License 3.01", + "Andrey Hristov , Ulf Wendel ", + { + NULL, /* no statistics , will be filled later if there are some */ + NULL, /* no statistics */ + }, + { + NULL /* plugin shutdown */ + } + }, + {/* methods */ + mysqlnd_sha256_auth_get_auth_data + } +}; +#endif + /* {{{ mysqlnd_register_builtin_authentication_plugins */ void mysqlnd_register_builtin_authentication_plugins(TSRMLS_D) { mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_native_auth_plugin TSRMLS_CC); mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_pam_authentication_plugin TSRMLS_CC); +#ifdef MYSQLND_HAVE_SSL + mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_sha256_authentication_plugin TSRMLS_CC); +#endif } /* }}} */ diff --git a/ext/mysqlnd/mysqlnd_bt.c b/ext/mysqlnd/mysqlnd_bt.c index 3aeb8f2bb13c9..9ed109b7dc57b 100644 --- a/ext/mysqlnd/mysqlnd_bt.c +++ b/ext/mysqlnd/mysqlnd_bt.c @@ -25,252 +25,6 @@ /* Follows code borrowed from zend_builtin_functions.c because the functions there are static */ -#if MYSQLND_UNICODE -/* {{{ gettraceasstring() macros */ -#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_USTRL(val, vallen) \ - { \ - zval tmp, copy; \ - int use_copy; \ - ZVAL_UNICODEL(&tmp, val, vallen, 1); \ - zend_make_printable_zval(&tmp, ©, &use_copy); \ - TRACE_APPEND_STRL(Z_STRVAL(copy), Z_STRLEN(copy)); \ - zval_dtor(©); \ - zval_dtor(&tmp); \ - } - -#define TRACE_APPEND_ZVAL(zv) \ - if (Z_TYPE_P((zv)) == IS_UNICODE) { \ - zval copy; \ - int use_copy; \ - zend_make_printable_zval((zv), ©, &use_copy); \ - TRACE_APPEND_STRL(Z_STRVAL(copy), Z_STRLEN(copy)); \ - zval_dtor(©); \ - } else { \ - TRACE_APPEND_STRL(Z_STRVAL_P((zv)), Z_STRLEN_P((zv))); \ - } - -#define TRACE_APPEND_STR(val) \ - TRACE_APPEND_STRL(val, sizeof(val)-1) - -#define TRACE_APPEND_KEY(key) \ - if (zend_ascii_hash_find(ht, key, sizeof(key), (void**)&tmp) == SUCCESS) { \ - if (Z_TYPE_PP(tmp) == IS_UNICODE) { \ - zval copy; \ - int use_copy; \ - zend_make_printable_zval(*tmp, ©, &use_copy); \ - TRACE_APPEND_STRL(Z_STRVAL(copy), Z_STRLEN(copy)); \ - zval_dtor(©); \ - } else { \ - TRACE_APPEND_STRL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); \ - } \ - } -/* }}} */ - - -/* {{{ mysqlnd_build_trace_args */ -static int mysqlnd_build_trace_args(zval **arg TSRMLS_DC, 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 ((unsigned char)(*str)[*len - l_added] < 32) { - (*str)[*len - l_added] = '?'; - } - } - break; - } - case IS_UNICODE: { - int l_added; - - /* - * We do not want to apply current error mode here, since - * zend_make_printable_zval() uses output encoding converter. - * Temporarily set output encoding converter to escape offending - * chars with \uXXXX notation. - */ - zend_set_converter_error_mode(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_FROM_UNICODE, ZEND_CONV_ERROR_ESCAPE_JAVA); - TRACE_APPEND_CHR('\''); - if (Z_USTRLEN_PP(arg) > 15) { - TRACE_APPEND_USTRL(Z_USTRVAL_PP(arg), 15); - TRACE_APPEND_STR("...', "); - l_added = 15 + 6 + 1; /* +1 because of while (--l_added) */ - } else { - l_added = Z_USTRLEN_PP(arg); - TRACE_APPEND_USTRL(Z_USTRVAL_PP(arg), l_added); - TRACE_APPEND_STR("', "); - l_added += 3 + 1; - } - /* - * Reset output encoding converter error mode. - */ - zend_set_converter_error_mode(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_FROM_UNICODE, UG(from_error_mode)); - while (--l_added) { - if ((unsigned char)(*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; - - 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: { - zval tmp; - zstr class_name; - zend_uint class_name_len; - int dup; - - TRACE_APPEND_STR("Object("); - - dup = zend_get_object_classname(*arg, &class_name, &class_name_len TSRMLS_CC); - - ZVAL_UNICODEL(&tmp, class_name.u, class_name_len, 1); - convert_to_string_with_converter(&tmp, ZEND_U_CONVERTER(UG(output_encoding_conv))); - TRACE_APPEND_STRL(Z_STRVAL(tmp), Z_STRLEN(tmp)); - zval_dtor(&tmp); - - if(!dup) { - efree(class_name.v); - } - - TRACE_APPEND_STR("), "); - break; - } - default: - break; - } - return ZEND_HASH_APPLY_KEEP; -} -/* }}} */ - - -static int mysqlnd_build_trace_string(zval **frame TSRMLS_DC, 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; - uint * level; - - level = va_arg(args, uint *); - str = va_arg(args, char**); - len = va_arg(args, int*); - num = va_arg(args, int*); - - if (!*level) { - return ZEND_HASH_APPLY_KEEP; - } - --*level; - - 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_ascii_hash_find(ht, "file", sizeof("file"), (void**)&file) == SUCCESS) { - if (zend_ascii_hash_find(ht, "line", sizeof("line"), (void**)&tmp) == SUCCESS) { - line = Z_LVAL_PP(tmp); - } else { - line = 0; - } - TRACE_APPEND_ZVAL(*file); - s_tmp = emalloc(MAX_LENGTH_OF_LONG + 2 + 1); - sprintf(s_tmp, "(%ld): ", 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_ascii_hash_find(ht, "args", sizeof("args"), (void**)&tmp) == SUCCESS) { - int last_len = *len; - zend_hash_apply_with_arguments(Z_ARRVAL_PP(tmp) TSRMLS_CC, (apply_func_args_t)mysqlnd_build_trace_args, 2, str, len); - if (last_len != *len) { - *len -= 2; /* remove last ', ' */ - } - } - TRACE_APPEND_STR(")\n"); - return ZEND_HASH_APPLY_KEEP; -} -/* }}} */ - - -#else /* PHP 5*/ - - /* {{{ gettraceasstring() macros */ #define TRACE_APPEND_CHR(chr) \ *str = (char*)erealloc(*str, *len + 1 + 1); \ @@ -295,7 +49,8 @@ static int mysqlnd_build_trace_string(zval **frame TSRMLS_DC, int num_args, va_l /* }}} */ -static int mysqlnd_build_trace_args(zval **arg TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ +static int +mysqlnd_build_trace_args(zval **arg TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { char **str; int *len; @@ -391,7 +146,8 @@ static int mysqlnd_build_trace_args(zval **arg TSRMLS_DC, int num_args, va_list } /* }}} */ -static int mysqlnd_build_trace_string(zval **frame TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ +static int +mysqlnd_build_trace_string(zval **frame TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { char *s_tmp, **str; int *len, *num; @@ -442,10 +198,10 @@ static int mysqlnd_build_trace_string(zval **frame TSRMLS_DC, int num_args, va_l return ZEND_HASH_APPLY_KEEP; } /* }}} */ -#endif -PHPAPI char * mysqlnd_get_backtrace(uint max_levels, size_t * length TSRMLS_DC) +PHPAPI char * +mysqlnd_get_backtrace(uint max_levels, size_t * length TSRMLS_DC) { zval *trace; char *res = estrdup(""), **str = &res, *s_tmp; diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c index fb8a3602401c3..5e617f5b2b4dc 100644 --- a/ext/mysqlnd/mysqlnd_debug.c +++ b/ext/mysqlnd/mysqlnd_debug.c @@ -747,21 +747,26 @@ mysqlnd_debug_init(const char * skip_functions[] TSRMLS_DC) PHPAPI void _mysqlnd_debug(const char * mode TSRMLS_DC) { #if PHP_DEBUG - MYSQLND_DEBUG *dbg = MYSQLND_G(dbg); + MYSQLND_DEBUG * dbg = MYSQLND_G(dbg); if (!dbg) { - MYSQLND_G(dbg) = dbg = mysqlnd_debug_init(mysqlnd_debug_std_no_trace_funcs TSRMLS_CC); - if (!dbg) { - return; + struct st_mysqlnd_plugin_trace_log * trace_log_plugin = mysqlnd_plugin_find("debug_trace"); + if (trace_log_plugin) { + dbg = trace_log_plugin->methods.trace_instance_init(mysqlnd_debug_std_no_trace_funcs TSRMLS_CC); + if (!dbg) { + return; + } + MYSQLND_G(dbg) = dbg; } } - - dbg->m->close(dbg); - dbg->m->set_mode(dbg, mode); - while (zend_stack_count(&dbg->call_stack)) { - zend_stack_del_top(&dbg->call_stack); - } - while (zend_stack_count(&dbg->call_time_stack)) { - zend_stack_del_top(&dbg->call_time_stack); + if (dbg) { + dbg->m->close(dbg); + dbg->m->set_mode(dbg, mode); + while (zend_stack_count(&dbg->call_stack)) { + zend_stack_del_top(&dbg->call_stack); + } + while (zend_stack_count(&dbg->call_time_stack)) { + zend_stack_del_top(&dbg->call_time_stack); + } } #endif } diff --git a/ext/mysqlnd/mysqlnd_debug.h b/ext/mysqlnd/mysqlnd_debug.h index f98c163e74db3..4bc72783832b8 100644 --- a/ext/mysqlnd/mysqlnd_debug.h +++ b/ext/mysqlnd/mysqlnd_debug.h @@ -96,52 +96,72 @@ PHPAPI char * mysqlnd_get_backtrace(uint max_levels, size_t * length TSRMLS_DC); #define DBG_PROFILE_END_TIME(duration) #endif -#define DBG_INF_EX(dbg_obj, msg) do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "info : ", (msg)); } while (0) -#define DBG_ERR_EX(dbg_obj, msg) do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "error: ", (msg)); } while (0) -#define DBG_INF_FMT_EX(dbg_obj, ...) do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "info : ", __VA_ARGS__); } while (0) -#define DBG_ERR_FMT_EX(dbg_obj, ...) do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "error: ", __VA_ARGS__); } while (0) +#define DBG_INF_EX(dbg_obj, msg) do { if (dbg_skip_trace == FALSE && (dbg_obj)) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "info : ", (msg)); } while (0) +#define DBG_ERR_EX(dbg_obj, msg) do { if (dbg_skip_trace == FALSE && (dbg_obj)) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "error: ", (msg)); } while (0) +#define DBG_INF_FMT_EX(dbg_obj, ...) do { if (dbg_skip_trace == FALSE && (dbg_obj)) (dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "info : ", __VA_ARGS__); } while (0) +#define DBG_ERR_FMT_EX(dbg_obj, ...) do { if (dbg_skip_trace == FALSE && (dbg_obj)) (dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "error: ", __VA_ARGS__); } while (0) -#define DBG_BLOCK_ENTER_EX(dbg_obj, block_name) \ +#define DBG_BLOCK_ENTER_EX(dbg_obj, block_name) DBG_BLOCK_ENTER_EX2((dbg_obj), NULL, (block_name)) +#define DBG_BLOCK_LEAVE_EX(dbg_obj) DBG_BLOCK_LEAVE_EX2((dbg_obj)) + +#define DBG_BLOCK_ENTER_EX2(dbg_obj1, dbg_obj2, block_name) \ { \ - DBG_ENTER_EX(dbg_obj, (block_name)); + DBG_ENTER_EX2((dbg_obj1), (db_obj2), (block_name)); -#define DBG_BLOCK_LEAVE_EX(dbg_obj) \ - DBG_LEAVE_EX((dbg_obj), ;) \ +#define DBG_BLOCK_LEAVE_EX2(dbg_obj1, dbg_obj2) \ + DBG_LEAVE_EX2((dbg_obj1), (dbg_obj2), ;) \ } \ -#define DBG_ENTER_EX(dbg_obj, func_name) \ +#define DBG_ENTER_EX(dbg_obj, func_name) DBG_ENTER_EX2((dbg_obj), (MYSQLND_DEBUG *) NULL, (func_name)) +#define DBG_LEAVE_EX(dbg_obj, leave) DBG_LEAVE_EX2((dbg_obj), (MYSQLND_DEBUG *) NULL, leave) + +#define DBG_ENTER_EX2(dbg_obj1, dbg_obj2, func_name) \ struct timeval __dbg_prof_tp = {0}; \ uint64_t __dbg_prof_start = 0; /* initialization is needed */ \ zend_bool dbg_skip_trace = TRUE; \ - if ((dbg_obj)) { \ - dbg_skip_trace = !(dbg_obj)->m->func_enter((dbg_obj), __LINE__, __FILE__, func_name, strlen(func_name)); \ + if ((dbg_obj1)) { \ + dbg_skip_trace = !(dbg_obj1)->m->func_enter((dbg_obj1), __LINE__, __FILE__, func_name, strlen(func_name)); \ } \ + if ((dbg_obj2)) { \ + dbg_skip_trace |= !(dbg_obj2)->m->func_enter((dbg_obj2), __LINE__, __FILE__, func_name, strlen(func_name)); \ + } \ + if (dbg_skip_trace); /* shut compiler's mouth */\ do { \ - if ((dbg_obj) && (dbg_obj)->flags & MYSQLND_DEBUG_PROFILE_CALLS) { \ + if (((dbg_obj1) && (dbg_obj1)->flags & MYSQLND_DEBUG_PROFILE_CALLS) || \ + ((dbg_obj2) && (dbg_obj2)->flags & MYSQLND_DEBUG_PROFILE_CALLS)) \ + { \ DBG_PROFILE_START_TIME(); \ } \ } while (0); -#define DBG_LEAVE_EX(dbg_obj, leave) \ +#define DBG_LEAVE_EX2(dbg_obj1, dbg_obj2, leave) \ do {\ - if ((dbg_obj)) { \ - uint64_t this_call_duration = 0; \ - if ((dbg_obj)->flags & MYSQLND_DEBUG_PROFILE_CALLS) { \ - DBG_PROFILE_END_TIME(this_call_duration); \ - } \ - (dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__, this_call_duration); \ + uint64_t this_call_duration = 0; \ + if (((dbg_obj1) && (dbg_obj1)->flags & MYSQLND_DEBUG_PROFILE_CALLS) || \ + ((dbg_obj2) && (dbg_obj2)->flags & MYSQLND_DEBUG_PROFILE_CALLS)) \ + { \ + DBG_PROFILE_END_TIME(this_call_duration); \ + } \ + if ((dbg_obj1)) { \ + (dbg_obj1)->m->func_leave((dbg_obj1), __LINE__, __FILE__, this_call_duration); \ + } \ + if ((dbg_obj2)) { \ + (dbg_obj2)->m->func_leave((dbg_obj2), __LINE__, __FILE__, this_call_duration); \ } \ leave \ } while (0); -#define DBG_RETURN_EX(dbg_obj, value) DBG_LEAVE_EX(dbg_obj, return (value);) -#define DBG_VOID_RETURN_EX(dbg_obj) DBG_LEAVE_EX(dbg_obj, return;) +#define DBG_RETURN_EX(dbg_obj, value) DBG_LEAVE_EX((dbg_obj), return (value);) +#define DBG_VOID_RETURN_EX(dbg_obj) DBG_LEAVE_EX((dbg_obj), return;) +#define DBG_RETURN_EX2(dbg_obj1, dbg_obj2, value) DBG_LEAVE_EX2((dbg_obj1), (dbg_obj2), return (value);) +#define DBG_VOID_RETURN_EX2(dbg_obj1, dbg_obj2) DBG_LEAVE_EX2((dbg_obj1), (dbg_obj2), return;) -#else + +#else /* defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1400)) */ static inline void DBG_INF_EX(MYSQLND_DEBUG * dbg_obj, const char * const msg) {} static inline void DBG_ERR_EX(MYSQLND_DEBUG * dbg_obj, const char * const msg) {} static inline void DBG_INF_FMT_EX(MYSQLND_DEBUG * dbg_obj, ...) {} @@ -167,6 +187,18 @@ static inline void DBG_ENTER_EX(MYSQLND_DEBUG * dbg_obj, const char * const func #define DBG_VOID_RETURN DBG_VOID_RETURN_EX(MYSQLND_G(dbg)) #define DBG_BLOCK_LEAVE DBG_BLOCK_LEAVE_EX(MYSQLND_G(dbg)) + +#define TRACE_ALLOC_INF(msg) DBG_INF_EX(MYSQLND_G(trace_alloc), (msg)) +#define TRACE_ALLOC_ERR(msg) DBG_ERR_EX(MYSQLND_G(trace_alloc), (msg)) +#define TRACE_ALLOC_INF_FMT(...) DBG_INF_FMT_EX(MYSQLND_G(trace_alloc), __VA_ARGS__) +#define TRACE_ALLOC_ERR_FMT(...) DBG_ERR_FMT_EX(MYSQLND_G(trace_alloc), __VA_ARGS__) + +#define TRACE_ALLOC_ENTER(func_name) DBG_ENTER_EX2(MYSQLND_G(dbg), MYSQLND_G(trace_alloc), (func_name)) +#define TRACE_ALLOC_BLOCK_ENTER(bname) DBG_BLOCK_ENTER_EX2(MYSQLND_G(dbg), MYSQLND_G(trace_alloc), (bname)) +#define TRACE_ALLOC_RETURN(value) DBG_RETURN_EX2(MYSQLND_G(dbg), MYSQLND_G(trace_alloc), (value)) +#define TRACE_ALLOC_VOID_RETURN DBG_VOID_RETURN_EX2(MYSQLND_G(dbg), MYSQLND_G(trace_alloc)) +#define TRACE_ALLOC_BLOCK_LEAVE DBG_BLOCK_LEAVE_EX2(MYSQLND_G(dbg), MYSQLND_G(trace_alloc)) + #elif MYSQLND_DBG_ENABLED == 0 static inline void DBG_INF(const char * const msg) {} @@ -175,10 +207,21 @@ static inline void DBG_INF_FMT(const char * const format, ...) {} static inline void DBG_ERR_FMT(const char * const format, ...) {} static inline void DBG_ENTER(const char * const func_name) {} #define DBG_BLOCK_ENTER(bname) { -#define DBG_RETURN(value) return (value) -#define DBG_VOID_RETURN return +#define DBG_RETURN(value) return (value) +#define DBG_VOID_RETURN return #define DBG_BLOCK_LEAVE } + +static inline void TRACE_ALLOC_INF(const char * const msg) {} +static inline void TRACE_ALLOC_ERR(const char * const msg) {} +static inline void TRACE_ALLOC_INF_FMT(const char * const format, ...) {} +static inline void TRACE_ALLOC_ERR_FMT(const char * const format, ...) {} +static inline void TRACE_ALLOC_ENTER(const char * const func_name) {} +#define TRACE_ALLOC_BLOCK_ENTER(bname) { +#define TRACE_ALLOC_RETURN(value) return (value) +#define TRACE_ALLOC_VOID_RETURN return +#define TRACE_ALLOC_BLOCK_LEAVE } + #endif #endif /* MYSQLND_DEBUG_H */ diff --git a/ext/mysqlnd/mysqlnd_driver.c b/ext/mysqlnd/mysqlnd_driver.c index e209a71b49113..699346c99900f 100644 --- a/ext/mysqlnd/mysqlnd_driver.c +++ b/ext/mysqlnd/mysqlnd_driver.c @@ -81,7 +81,9 @@ PHPAPI void mysqlnd_library_init(TSRMLS_D) mysqlnd_plugin_core.plugin_header.plugin_stats.values = mysqlnd_global_stats; mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_plugin_core TSRMLS_CC); } +#if defined(MYSQLND_DBG_ENABLED) && MYSQLND_DBG_ENABLED == 1 mysqlnd_example_plugin_register(TSRMLS_C); +#endif mysqlnd_debug_trace_plugin_register(TSRMLS_C); mysqlnd_register_builtin_authentication_plugins(TSRMLS_C); @@ -91,6 +93,7 @@ PHPAPI void mysqlnd_library_init(TSRMLS_D) /* }}} */ + /* {{{ mysqlnd_error_list_pdtor */ static void mysqlnd_error_list_pdtor(void * pDest) @@ -250,17 +253,29 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA PHPAPI MYSQLND_NET * MYSQLND_METHOD(mysqlnd_object_factory, get_io_channel)(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info TSRMLS_DC) { - size_t alloc_size = sizeof(MYSQLND_NET) + mysqlnd_plugin_count() * sizeof(void *); - MYSQLND_NET * net = mnd_pecalloc(1, alloc_size, persistent); + size_t net_alloc_size = sizeof(MYSQLND_NET) + mysqlnd_plugin_count() * sizeof(void *); + size_t net_data_alloc_size = sizeof(MYSQLND_NET_DATA) + mysqlnd_plugin_count() * sizeof(void *); + MYSQLND_NET * net = mnd_pecalloc(1, net_alloc_size, persistent); + MYSQLND_NET_DATA * net_data = mnd_pecalloc(1, net_data_alloc_size, persistent); DBG_ENTER("mysqlnd_object_factory::get_io_channel"); DBG_INF_FMT("persistent=%u", persistent); - if (net) { - net->persistent = persistent; - net->m = *mysqlnd_net_get_methods(); + if (net && net_data) { + net->data = net_data; + net->persistent = net->data->persistent = persistent; + net->data->m = *mysqlnd_net_get_methods(); - if (PASS != net->m.init(net, stats, error_info TSRMLS_CC)) { - net->m.dtor(net, stats, error_info TSRMLS_CC); + if (PASS != net->data->m.init(net, stats, error_info TSRMLS_CC)) { + net->data->m.dtor(net, stats, error_info TSRMLS_CC); + net = NULL; + } + } else { + if (net_data) { + mnd_pefree(net_data, persistent); + net_data = NULL; + } + if (net) { + mnd_pefree(net, persistent); net = NULL; } } @@ -270,7 +285,7 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_io_channel)(zend_bool persistent, MYS /* {{{ mysqlnd_object_factory::get_protocol_decoder */ -PHPAPI MYSQLND_PROTOCOL * +static MYSQLND_PROTOCOL * MYSQLND_METHOD(mysqlnd_object_factory, get_protocol_decoder)(zend_bool persistent TSRMLS_DC) { size_t alloc_size = sizeof(MYSQLND_PROTOCOL) + mysqlnd_plugin_count() * sizeof(void *); @@ -288,7 +303,7 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_protocol_decoder)(zend_bool persisten /* }}} */ -MYSQLND_CLASS_METHODS_START(mysqlnd_object_factory) +PHPAPI MYSQLND_CLASS_METHODS_START(mysqlnd_object_factory) MYSQLND_METHOD(mysqlnd_object_factory, get_connection), MYSQLND_METHOD(mysqlnd_object_factory, clone_connection_object), MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement), diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h index 92f6cb3e28292..1d645a8d75c65 100644 --- a/ext/mysqlnd/mysqlnd_enum_n_def.h +++ b/ext/mysqlnd/mysqlnd_enum_n_def.h @@ -37,6 +37,8 @@ #define MYSQLND_ASSEMBLED_PACKET_MAX_SIZE 3UL*1024UL*1024UL*1024UL +#define MYSQLND_DEFAULT_AUTH_PROTOCOL "mysql_native_password" + #define MYSQLND_ERRMSG_SIZE 512 #define MYSQLND_SQLSTATE_LENGTH 5 #define MYSQLND_SQLSTATE_NULL "00000" @@ -106,6 +108,18 @@ #define MYSQLND_NET_FLAG_USE_COMPRESSION 1 + +#define TRANS_START_NO_OPT 0 +#define TRANS_START_WITH_CONSISTENT_SNAPSHOT 1 +#define TRANS_START_READ_WRITE 2 +#define TRANS_START_READ_ONLY 4 + +#define TRANS_COR_NO_OPT 0 +#define TRANS_COR_AND_CHAIN 1 +#define TRANS_COR_AND_NO_CHAIN 2 +#define TRANS_COR_RELEASE 4 +#define TRANS_COR_NO_RELEASE 8 + typedef enum mysqlnd_extension { MYSQLND_MYSQL = 0, @@ -166,12 +180,13 @@ typedef enum mysqlnd_option MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH, + MYSQL_OPT_CONNECT_ATTR_RESET, + MYSQL_OPT_CONNECT_ATTR_ADD, + MYSQL_OPT_CONNECT_ATTR_DELETE, MYSQL_SERVER_PUBLIC_KEY, MYSQL_ENABLE_CLEARTEXT_PLUGIN, MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, -#if MYSQLND_UNICODE - MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE = 200, -#endif + MYSQLND_DEPRECATED_ENUM1 = 200, #ifdef MYSQLND_STRING_TO_INT_CONVERSION MYSQLND_OPT_INT_AND_FLOAT_NATIVE = 201, #endif @@ -540,6 +555,8 @@ enum mysqlnd_packet_type PROT_STATS_PACKET, PROT_PREPARE_RESP_PACKET, PROT_CHG_USER_RESP_PACKET, + PROT_SHA256_PK_REQUEST_PACKET, + PROT_SHA256_PK_REQUEST_RESPONSE_PACKET, PROT_LAST /* should always be last */ }; diff --git a/ext/mysqlnd/mysqlnd_ext_plugin.c b/ext/mysqlnd/mysqlnd_ext_plugin.c index 21be3fd37bb9e..7116943cd5878 100644 --- a/ext/mysqlnd/mysqlnd_ext_plugin.c +++ b/ext/mysqlnd/mysqlnd_ext_plugin.c @@ -215,7 +215,6 @@ mysqlnd_net_set_methods(struct st_mysqlnd_net_methods * methods) /* }}} */ - /* * Local variables: * tab-width: 4 diff --git a/ext/mysqlnd/mysqlnd_libmysql_compat.h b/ext/mysqlnd/mysqlnd_libmysql_compat.h index c967fb3a9f037..516200e0d507f 100644 --- a/ext/mysqlnd/mysqlnd_libmysql_compat.h +++ b/ext/mysqlnd/mysqlnd_libmysql_compat.h @@ -44,7 +44,7 @@ #define mysql_change_user(r,a,b,c) mysqlnd_change_user((r), (a), (b), (c), FALSE) #define mysql_character_set_name(c) mysqlnd_character_set_name((c)) #define mysql_close(r) mysqlnd_close((r), MYSQLND_CLOSE_EXPLICIT) -#define mysql_commit(r) mysqlnd_commit((r)) +#define mysql_commit(r) mysqlnd_commit((r), TRANS_COR_NO_OPT, NULL) #define mysql_data_seek(r,o) mysqlnd_data_seek((r),(o)) #define mysql_debug(x) mysqlnd_debug((x)) #define mysql_dump_debug_info(r) mysqlnd_dump_debug_info((r)) @@ -74,7 +74,7 @@ #define mysql_real_escape_string(r,a,b,c) mysqlnd_real_escape_string((r), (a), (b), (c)) #define mysql_real_query(r,a,b) mysqlnd_query((r), (a), (b)) #define mysql_refresh(conn, options) mysqlnd_refresh((conn), (options)) -#define mysql_rollback(r) mysqlnd_rollback((r)) +#define mysql_rollback(r) mysqlnd_rollback((r), TRANS_COR_NO_OPT, NULL) #define mysql_select_db(r,a) mysqlnd_select_db((r), (a) ,strlen((a))) #define mysql_set_server_option(r,o) mysqlnd_set_server_option((r), (o)) #define mysql_set_character_set(r,a) mysqlnd_set_character_set((r), (a)) @@ -106,7 +106,8 @@ #define mysql_stmt_more_results(s) mysqlnd_stmt_more_results((s)) #define mysql_thread_safe() mysqlnd_thread_safe() #define mysql_info(r) mysqlnd_info((r)) -#define mysql_options(r,a,b) mysqlnd_options((r), (a), (b)) +#define mysql_options(c,a,v) mysqlnd_options((c), (a), (v)) +#define mysql_options4(c,a,k,v) mysqlnd_options4((c), (a), (k), (v)) #define mysql_stmt_init(r) mysqlnd_stmt_init((r)) #define mysql_free_result(r) mysqlnd_free_result((r), FALSE) #define mysql_store_result(r) mysqlnd_store_result((r)) diff --git a/ext/mysqlnd/mysqlnd_loaddata.c b/ext/mysqlnd/mysqlnd_loaddata.c index 40de45b06f1ac..a1c589a8b726e 100644 --- a/ext/mysqlnd/mysqlnd_loaddata.c +++ b/ext/mysqlnd/mysqlnd_loaddata.c @@ -172,7 +172,7 @@ mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * filename, zen if (!(conn->options->flags & CLIENT_LOCAL_FILES)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "LOAD DATA LOCAL INFILE forbidden"); /* write empty packet to server */ - ret = net->m.send_ex(net, empty_packet, 0, conn->stats, conn->error_info TSRMLS_CC); + ret = net->data->m.send_ex(net, empty_packet, 0, conn->stats, conn->error_info TSRMLS_CC); *is_warning = TRUE; goto infile_error; } @@ -192,13 +192,13 @@ mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * filename, zen tmp_error_no = infile.local_infile_error(info, tmp_buf, sizeof(tmp_buf) TSRMLS_CC); SET_CLIENT_ERROR(*conn->error_info, tmp_error_no, UNKNOWN_SQLSTATE, tmp_buf); /* write empty packet to server */ - ret = net->m.send_ex(net, empty_packet, 0, conn->stats, conn->error_info TSRMLS_CC); + ret = net->data->m.send_ex(net, empty_packet, 0, conn->stats, conn->error_info TSRMLS_CC); goto infile_error; } /* read data */ while ((bufsize = infile.local_infile_read (info, buf + MYSQLND_HEADER_SIZE, buflen - MYSQLND_HEADER_SIZE TSRMLS_CC)) > 0) { - if ((ret = net->m.send_ex(net, buf, bufsize, conn->stats, conn->error_info TSRMLS_CC)) == 0) { + if ((ret = net->data->m.send_ex(net, buf, bufsize, conn->stats, conn->error_info TSRMLS_CC)) == 0) { DBG_ERR_FMT("Error during read : %d %s %s", CR_SERVER_LOST, UNKNOWN_SQLSTATE, lost_conn); SET_CLIENT_ERROR(*conn->error_info, CR_SERVER_LOST, UNKNOWN_SQLSTATE, lost_conn); goto infile_error; @@ -206,7 +206,7 @@ mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * filename, zen } /* send empty packet for eof */ - if ((ret = net->m.send_ex(net, empty_packet, 0, conn->stats, conn->error_info TSRMLS_CC)) == 0) { + if ((ret = net->data->m.send_ex(net, empty_packet, 0, conn->stats, conn->error_info TSRMLS_CC)) == 0) { SET_CLIENT_ERROR(*conn->error_info, CR_SERVER_LOST, UNKNOWN_SQLSTATE, lost_conn); goto infile_error; } diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c index 21241b3ef5065..ba2b1745ef490 100644 --- a/ext/mysqlnd/mysqlnd_net.c +++ b/ext/mysqlnd/mysqlnd_net.c @@ -67,16 +67,17 @@ MYSQLND_METHOD(mysqlnd_net, network_read_ex)(MYSQLND_NET * const net, zend_uchar MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC) { enum_func_status return_value = PASS; + php_stream * net_stream = net->data->m.get_stream(net TSRMLS_CC); + size_t old_chunk_size = net_stream->chunk_size; size_t to_read = count, ret; - size_t old_chunk_size = net->stream->chunk_size; zend_uchar * p = buffer; DBG_ENTER("mysqlnd_net::network_read_ex"); DBG_INF_FMT("count="MYSQLND_SZ_T_SPEC, count); - net->stream->chunk_size = MIN(to_read, net->options.net_read_buffer_size); + net_stream->chunk_size = MIN(to_read, net->data->options.net_read_buffer_size); while (to_read) { - if (!(ret = php_stream_read(net->stream, (char *) p, to_read))) { + if (!(ret = php_stream_read(net_stream, (char *) p, to_read))) { DBG_ERR_FMT("Error while reading header from socket"); return_value = FAIL; break; @@ -85,7 +86,7 @@ MYSQLND_METHOD(mysqlnd_net, network_read_ex)(MYSQLND_NET * const net, zend_uchar to_read -= ret; } MYSQLND_INC_CONN_STATISTIC_W_VALUE(stats, STAT_BYTES_RECEIVED, count - to_read); - net->stream->chunk_size = old_chunk_size; + net_stream->chunk_size = old_chunk_size; DBG_RETURN(return_value); } /* }}} */ @@ -98,13 +99,13 @@ MYSQLND_METHOD(mysqlnd_net, network_write_ex)(MYSQLND_NET * const net, const zen { size_t ret; DBG_ENTER("mysqlnd_net::network_write_ex"); - ret = php_stream_write(net->stream, (char *)buffer, count); + ret = php_stream_write(net->data->m.get_stream(net TSRMLS_CC), (char *)buffer, count); DBG_RETURN(ret); } /* }}} */ /* {{{ mysqlnd_net::open_pipe */ -static enum_func_status +static php_stream * MYSQLND_METHOD(mysqlnd_net, open_pipe)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC) @@ -114,32 +115,35 @@ MYSQLND_METHOD(mysqlnd_net, open_pipe)(MYSQLND_NET * const net, const char * con #else unsigned int streams_options = 0; #endif + php_stream * net_stream = NULL; + DBG_ENTER("mysqlnd_net::open_pipe"); if (persistent) { streams_options |= STREAM_OPEN_PERSISTENT; } streams_options |= IGNORE_URL; - net->stream = php_stream_open_wrapper((char*) scheme + sizeof("pipe://") - 1, "r+", streams_options, NULL); - if (!net->stream) { + net_stream = php_stream_open_wrapper((char*) scheme + sizeof("pipe://") - 1, "r+", streams_options, NULL); + if (!net_stream) { SET_CLIENT_ERROR(*error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, "Unknown errror while connecting"); - DBG_RETURN(FAIL); + DBG_RETURN(NULL); } /* Streams are not meant for C extensions! Thus we need a hack. Every connected stream will be registered as resource (in EG(regular_list). So far, so good. However, it won't be unregistered yntil the script ends. So, we need to take care of that. */ - net->stream->in_free = 1; - zend_hash_index_del(&EG(regular_list), net->stream->rsrc_id); - net->stream->in_free = 0; + net_stream->in_free = 1; + zend_hash_index_del(&EG(regular_list), net_stream->rsrc_id); + net_stream->in_free = 0; - DBG_RETURN(PASS); + + DBG_RETURN(net_stream); } /* }}} */ /* {{{ mysqlnd_net::open_tcp_or_unix */ -static enum_func_status +static php_stream * MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC) @@ -155,24 +159,27 @@ MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const cha char * errstr = NULL; int errcode = 0; struct timeval tv; + php_stream * net_stream = NULL; DBG_ENTER("mysqlnd_net::open_tcp_or_unix"); + net->data->stream = NULL; + if (persistent) { hashed_details_len = mnd_sprintf(&hashed_details, 0, "%p", net); DBG_INF_FMT("hashed_details=%s", hashed_details); } - if (net->options.timeout_connect) { - tv.tv_sec = net->options.timeout_connect; + if (net->data->options.timeout_connect) { + tv.tv_sec = net->data->options.timeout_connect; tv.tv_usec = 0; } DBG_INF_FMT("calling php_stream_xport_create"); - net->stream = php_stream_xport_create(scheme, scheme_len, streams_options, streams_flags, - hashed_details, (net->options.timeout_connect) ? &tv : NULL, + net_stream = php_stream_xport_create(scheme, scheme_len, streams_options, streams_flags, + hashed_details, (net->data->options.timeout_connect) ? &tv : NULL, NULL /*ctx*/, &errstr, &errcode); - if (errstr || !net->stream) { + if (errstr || !net_stream) { DBG_ERR("Error"); if (hashed_details) { mnd_sprintf_free(hashed_details); @@ -183,7 +190,7 @@ MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const cha /* no mnd_ since we don't allocate it */ efree(errstr); } - DBG_RETURN(FAIL); + DBG_RETURN(NULL); } if (hashed_details) { /* @@ -199,13 +206,13 @@ MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const cha but STREAMS suck big time regarding persistent streams. Just not compatible for extensions that need persistency. */ - net->stream->in_free = 1; + net_stream->in_free = 1; zend_hash_del(&EG(persistent_list), hashed_details, hashed_details_len + 1); - net->stream->in_free = 0; + net_stream->in_free = 0; } #if ZEND_DEBUG /* Shut-up the streams, they don't know what they are doing */ - net->stream->__exposed = 1; + net_stream->__exposed = 1; #endif mnd_sprintf_free(hashed_details); } @@ -215,33 +222,36 @@ MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const cha be registered as resource (in EG(regular_list). So far, so good. However, it won't be unregistered yntil the script ends. So, we need to take care of that. */ - net->stream->in_free = 1; - zend_hash_index_del(&EG(regular_list), net->stream->rsrc_id); - net->stream->in_free = 0; + net_stream->in_free = 1; + zend_hash_index_del(&EG(regular_list), net_stream->rsrc_id); + net_stream->in_free = 0; - DBG_RETURN(PASS); + DBG_RETURN(net_stream); } /* }}} */ -/* {{{ mysqlnd_net::connect_ex */ +/* {{{ mysqlnd_net::post_connect_set_opt */ static void MYSQLND_METHOD(mysqlnd_net, post_connect_set_opt)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC) { + php_stream * net_stream = net->data->m.get_stream(net TSRMLS_CC); DBG_ENTER("mysqlnd_net::post_connect_set_opt"); - if (net->options.timeout_read) { - struct timeval tv; - DBG_INF_FMT("setting %u as PHP_STREAM_OPTION_READ_TIMEOUT", net->options.timeout_read); - tv.tv_sec = net->options.timeout_read; - tv.tv_usec = 0; - php_stream_set_option(net->stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv); - } + if (net_stream) { + if (net->data->options.timeout_read) { + struct timeval tv; + DBG_INF_FMT("setting %u as PHP_STREAM_OPTION_READ_TIMEOUT", net->data->options.timeout_read); + tv.tv_sec = net->data->options.timeout_read; + tv.tv_usec = 0; + php_stream_set_option(net_stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv); + } - if (!memcmp(scheme, "tcp://", sizeof("tcp://") - 1)) { - /* TCP -> Set TCP_NODELAY */ - mysqlnd_set_sock_no_delay(net->stream TSRMLS_CC); + if (!memcmp(scheme, "tcp://", sizeof("tcp://") - 1)) { + /* TCP -> Set TCP_NODELAY */ + mysqlnd_set_sock_no_delay(net_stream TSRMLS_CC); + } } DBG_VOID_RETURN; @@ -249,6 +259,31 @@ MYSQLND_METHOD(mysqlnd_net, post_connect_set_opt)(MYSQLND_NET * const net, /* }}} */ +/* {{{ mysqlnd_net::get_open_stream */ +static func_mysqlnd_net__open_stream +MYSQLND_METHOD(mysqlnd_net, get_open_stream)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, + MYSQLND_ERROR_INFO * const error_info TSRMLS_DC) +{ + func_mysqlnd_net__open_stream ret = NULL; + DBG_ENTER("mysqlnd_net::get_open_stream"); + if (scheme_len > (sizeof("pipe://") - 1) && !memcmp(scheme, "pipe://", sizeof("pipe://") - 1)) { + ret = net->data->m.open_pipe; + } else if ((scheme_len > (sizeof("tcp://") - 1) && !memcmp(scheme, "tcp://", sizeof("tcp://") - 1)) + || + (scheme_len > (sizeof("unix://") - 1) && !memcmp(scheme, "unix://", sizeof("unix://") - 1))) + { + ret = net->data->m.open_tcp_or_unix; + } + + if (!ret) { + SET_CLIENT_ERROR(*error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, "No handler for this scheme"); + } + + DBG_RETURN(ret); +} +/* }}} */ + + /* {{{ mysqlnd_net::connect_ex */ static enum_func_status MYSQLND_METHOD(mysqlnd_net, connect_ex)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, @@ -261,13 +296,16 @@ MYSQLND_METHOD(mysqlnd_net, connect_ex)(MYSQLND_NET * const net, const char * co net->packet_no = net->compressed_envelope_packet_no = 0; - net->m.close_stream(net, conn_stats, error_info TSRMLS_CC); + net->data->m.close_stream(net, conn_stats, error_info TSRMLS_CC); - open_stream = (scheme_len > (sizeof("pipe://") - 1) && !memcmp(scheme, "pipe://", sizeof("pipe://") - 1))? net->m.open_pipe: - net->m.open_tcp_or_unix; - - if (PASS == (ret = open_stream(net, scheme, scheme_len, persistent, conn_stats, error_info TSRMLS_CC))) { - net->m.post_connect_set_opt(net, scheme, scheme_len, conn_stats, error_info TSRMLS_CC); + open_stream = net->data->m.get_open_stream(net, scheme, scheme_len, error_info TSRMLS_CC); + if (open_stream) { + php_stream * net_stream = open_stream(net, scheme, scheme_len, persistent, conn_stats, error_info TSRMLS_CC); + if (net_stream) { + (void) net->data->m.set_stream(net, net_stream TSRMLS_CC); + net->data->m.post_connect_set_opt(net, scheme, scheme_len, conn_stats, error_info TSRMLS_CC); + ret = PASS; + } } DBG_RETURN(ret); @@ -309,9 +347,9 @@ MYSQLND_METHOD(mysqlnd_net, send_ex)(MYSQLND_NET * const net, zend_uchar * const size_t to_be_sent; DBG_ENTER("mysqlnd_net::send_ex"); - DBG_INF_FMT("count=" MYSQLND_SZ_T_SPEC " compression=%u", count, net->compressed); + DBG_INF_FMT("count=" MYSQLND_SZ_T_SPEC " compression=%u", count, net->data->compressed); - if (net->compressed == TRUE) { + if (net->data->compressed == TRUE) { size_t comp_buf_size = MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE + MIN(left, MYSQLND_MAX_PACKET_SIZE); DBG_INF_FMT("compress_buf_size="MYSQLND_SZ_T_SPEC, comp_buf_size); compress_buf = mnd_emalloc(comp_buf_size); @@ -320,7 +358,7 @@ MYSQLND_METHOD(mysqlnd_net, send_ex)(MYSQLND_NET * const net, zend_uchar * const do { to_be_sent = MIN(left, MYSQLND_MAX_PACKET_SIZE); #ifdef MYSQLND_COMPRESSION_ENABLED - if (net->compressed == TRUE) { + if (net->data->compressed == TRUE) { /* here we need to compress the data and then write it, first comes the compressed header */ size_t tmp_complen = to_be_sent; size_t payload_size; @@ -329,7 +367,7 @@ MYSQLND_METHOD(mysqlnd_net, send_ex)(MYSQLND_NET * const net, zend_uchar * const STORE_HEADER_SIZE(safe_storage, uncompressed_payload); int3store(uncompressed_payload, to_be_sent); int1store(uncompressed_payload + 3, net->packet_no); - if (PASS == net->m.encode((compress_buf + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE), &tmp_complen, + if (PASS == net->data->m.encode((compress_buf + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE), &tmp_complen, uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE TSRMLS_CC)) { int3store(compress_buf + MYSQLND_HEADER_SIZE, to_be_sent + MYSQLND_HEADER_SIZE); @@ -344,14 +382,14 @@ MYSQLND_METHOD(mysqlnd_net, send_ex)(MYSQLND_NET * const net, zend_uchar * const int3store(compress_buf, payload_size); int1store(compress_buf + 3, net->packet_no); DBG_INF_FMT("writing "MYSQLND_SZ_T_SPEC" bytes to the network", payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE); - bytes_sent = net->m.network_write_ex(net, compress_buf, payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, + bytes_sent = net->data->m.network_write_ex(net, compress_buf, payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, conn_stats, error_info TSRMLS_CC); net->compressed_envelope_packet_no++; #if WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY if (res == Z_OK) { size_t decompressed_size = left + MYSQLND_HEADER_SIZE; zend_uchar * decompressed_data = mnd_malloc(decompressed_size); - int error = net->m.decode(decompressed_data, decompressed_size, + int error = net->data->m.decode(decompressed_data, decompressed_size, compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, payload_size); if (error == Z_OK) { int i; @@ -376,7 +414,7 @@ MYSQLND_METHOD(mysqlnd_net, send_ex)(MYSQLND_NET * const net, zend_uchar * const STORE_HEADER_SIZE(safe_storage, p); int3store(p, to_be_sent); int1store(p + 3, net->packet_no); - bytes_sent = net->m.network_write_ex(net, p, to_be_sent + MYSQLND_HEADER_SIZE, conn_stats, error_info TSRMLS_CC); + bytes_sent = net->data->m.network_write_ex(net, p, to_be_sent + MYSQLND_HEADER_SIZE, conn_stats, error_info TSRMLS_CC); RESTORE_HEADER_SIZE(p, safe_storage); net->compressed_envelope_packet_no++; } @@ -486,13 +524,13 @@ MYSQLND_METHOD(mysqlnd_net, read_compressed_packet_from_stream_and_fill_read_buf (MYSQLND_NET * net, size_t net_payload_size, MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info TSRMLS_DC) { size_t decompressed_size; - enum_func_status ret = PASS; + enum_func_status retval = PASS; zend_uchar * compressed_data = NULL; zend_uchar comp_header[COMPRESSED_HEADER_SIZE]; - DBG_ENTER("mysqlnd_net::read_compressed_packet_from_stream_and_fill_read_buffe"); + DBG_ENTER("mysqlnd_net::read_compressed_packet_from_stream_and_fill_read_buffer"); /* Read the compressed header */ - if (FAIL == net->m.network_read_ex(net, comp_header, COMPRESSED_HEADER_SIZE, conn_stats, error_info TSRMLS_CC)) { + if (FAIL == net->data->m.network_read_ex(net, comp_header, COMPRESSED_HEADER_SIZE, conn_stats, error_info TSRMLS_CC)) { DBG_RETURN(FAIL); } decompressed_size = uint3korr(comp_header); @@ -502,20 +540,20 @@ MYSQLND_METHOD(mysqlnd_net, read_compressed_packet_from_stream_and_fill_read_buf if (decompressed_size) { compressed_data = mnd_emalloc(net_payload_size); - if (FAIL == net->m.network_read_ex(net, compressed_data, net_payload_size, conn_stats, error_info TSRMLS_CC)) { - ret = FAIL; + if (FAIL == net->data->m.network_read_ex(net, compressed_data, net_payload_size, conn_stats, error_info TSRMLS_CC)) { + retval = FAIL; goto end; } net->uncompressed_data = mysqlnd_create_read_buffer(decompressed_size TSRMLS_CC); - ret = net->m.decode(net->uncompressed_data->data, decompressed_size, compressed_data, net_payload_size TSRMLS_CC); - if (ret == FAIL) { + retval = net->data->m.decode(net->uncompressed_data->data, decompressed_size, compressed_data, net_payload_size TSRMLS_CC); + if (FAIL == retval) { goto end; } } else { DBG_INF_FMT("The server decided not to compress the data. Our job is easy. Copying %u bytes", net_payload_size); net->uncompressed_data = mysqlnd_create_read_buffer(net_payload_size TSRMLS_CC); - if (FAIL == net->m.network_read_ex(net, net->uncompressed_data->data, net_payload_size, conn_stats, error_info TSRMLS_CC)) { - ret = FAIL; + if (FAIL == net->data->m.network_read_ex(net, net->uncompressed_data->data, net_payload_size, conn_stats, error_info TSRMLS_CC)) { + retval = FAIL; goto end; } } @@ -523,7 +561,7 @@ MYSQLND_METHOD(mysqlnd_net, read_compressed_packet_from_stream_and_fill_read_buf if (compressed_data) { mnd_efree(compressed_data); } - DBG_RETURN(ret); + DBG_RETURN(retval); } /* }}} */ #endif /* MYSQLND_COMPRESSION_ENABLED */ @@ -590,16 +628,16 @@ MYSQLND_METHOD(mysqlnd_net, receive_ex)(MYSQLND_NET * const net, zend_uchar * co DBG_ENTER("mysqlnd_net::receive_ex"); #ifdef MYSQLND_COMPRESSION_ENABLED - if (net->compressed) { + if (net->data->compressed) { if (net->uncompressed_data) { size_t to_read_from_buffer = MIN(net->uncompressed_data->bytes_left(net->uncompressed_data), to_read); - DBG_INF_FMT("reading %u from uncompressed_data buffer", to_read_from_buffer); + DBG_INF_FMT("reading "MYSQLND_SZ_T_SPEC" from uncompressed_data buffer", to_read_from_buffer); if (to_read_from_buffer) { net->uncompressed_data->read(net->uncompressed_data, to_read_from_buffer, (zend_uchar *) p); p += to_read_from_buffer; to_read -= to_read_from_buffer; } - DBG_INF_FMT("left %u to read", to_read); + DBG_INF_FMT("left "MYSQLND_SZ_T_SPEC" to read", to_read); if (TRUE == net->uncompressed_data->is_empty(net->uncompressed_data)) { /* Everything was consumed. This should never happen here, but for security */ net->uncompressed_data->free_buffer(&net->uncompressed_data TSRMLS_CC); @@ -610,7 +648,7 @@ MYSQLND_METHOD(mysqlnd_net, receive_ex)(MYSQLND_NET * const net, zend_uchar * co size_t net_payload_size; zend_uchar packet_no; - if (FAIL == net->m.network_read_ex(net, net_header, MYSQLND_HEADER_SIZE, conn_stats, error_info TSRMLS_CC)) { + if (FAIL == net->data->m.network_read_ex(net, net_header, MYSQLND_HEADER_SIZE, conn_stats, error_info TSRMLS_CC)) { DBG_RETURN(FAIL); } net_payload_size = uint3korr(net_header); @@ -628,7 +666,7 @@ MYSQLND_METHOD(mysqlnd_net, receive_ex)(MYSQLND_NET * const net, zend_uchar * co DBG_INF_FMT("HEADER: hwd_packet_no=%u size=%3u", packet_no, (unsigned long) net_payload_size); #endif /* Now let's read from the wire, decompress it and fill the read buffer */ - net->m.read_compressed_packet_from_stream_and_fill_read_buffer(net, net_payload_size, conn_stats, error_info TSRMLS_CC); + net->data->m.read_compressed_packet_from_stream_and_fill_read_buffer(net, net_payload_size, conn_stats, error_info TSRMLS_CC); /* Now a bit of recursion - read from the read buffer, @@ -636,12 +674,12 @@ MYSQLND_METHOD(mysqlnd_net, receive_ex)(MYSQLND_NET * const net, zend_uchar * co is not enough, then the recursive call will try to satisfy it until it is satisfied. */ - DBG_RETURN(net->m.receive_ex(net, p, to_read, conn_stats, error_info TSRMLS_CC)); + DBG_RETURN(net->data->m.receive_ex(net, p, to_read, conn_stats, error_info TSRMLS_CC)); } DBG_RETURN(PASS); } #endif /* MYSQLND_COMPRESSION_ENABLED */ - DBG_RETURN(net->m.network_read_ex(net, p, to_read, conn_stats, error_info TSRMLS_CC)); + DBG_RETURN(net->data->m.network_read_ex(net, p, to_read, conn_stats, error_info TSRMLS_CC)); } /* }}} */ @@ -659,7 +697,7 @@ MYSQLND_METHOD(mysqlnd_net, set_client_option)(MYSQLND_NET * const net, enum mys DBG_RETURN(FAIL); } net->cmd_buffer.length = *(unsigned int*) value; - DBG_INF_FMT("new_length=%u", net->cmd_buffer.length); + DBG_INF_FMT("new_length="MYSQLND_SZ_T_SPEC, net->cmd_buffer.length); if (!net->cmd_buffer.buffer) { net->cmd_buffer.buffer = mnd_pemalloc(net->cmd_buffer.length, net->persistent); } else { @@ -668,81 +706,90 @@ MYSQLND_METHOD(mysqlnd_net, set_client_option)(MYSQLND_NET * const net, enum mys break; case MYSQLND_OPT_NET_READ_BUFFER_SIZE: DBG_INF("MYSQLND_OPT_NET_READ_BUFFER_SIZE"); - net->options.net_read_buffer_size = *(unsigned int*) value; - DBG_INF_FMT("new_length=%u", net->options.net_read_buffer_size); + net->data->options.net_read_buffer_size = *(unsigned int*) value; + DBG_INF_FMT("new_length="MYSQLND_SZ_T_SPEC, net->data->options.net_read_buffer_size); break; case MYSQL_OPT_CONNECT_TIMEOUT: DBG_INF("MYSQL_OPT_CONNECT_TIMEOUT"); - net->options.timeout_connect = *(unsigned int*) value; + net->data->options.timeout_connect = *(unsigned int*) value; break; case MYSQLND_OPT_SSL_KEY: { zend_bool pers = net->persistent; - if (net->options.ssl_key) { - mnd_pefree(net->options.ssl_key, pers); + if (net->data->options.ssl_key) { + mnd_pefree(net->data->options.ssl_key, pers); } - net->options.ssl_key = value? mnd_pestrdup(value, pers) : NULL; + net->data->options.ssl_key = value? mnd_pestrdup(value, pers) : NULL; break; } case MYSQLND_OPT_SSL_CERT: { zend_bool pers = net->persistent; - if (net->options.ssl_cert) { - mnd_pefree(net->options.ssl_cert, pers); + if (net->data->options.ssl_cert) { + mnd_pefree(net->data->options.ssl_cert, pers); } - net->options.ssl_cert = value? mnd_pestrdup(value, pers) : NULL; + net->data->options.ssl_cert = value? mnd_pestrdup(value, pers) : NULL; break; } case MYSQLND_OPT_SSL_CA: { zend_bool pers = net->persistent; - if (net->options.ssl_ca) { - mnd_pefree(net->options.ssl_ca, pers); + if (net->data->options.ssl_ca) { + mnd_pefree(net->data->options.ssl_ca, pers); } - net->options.ssl_ca = value? mnd_pestrdup(value, pers) : NULL; + net->data->options.ssl_ca = value? mnd_pestrdup(value, pers) : NULL; break; } case MYSQLND_OPT_SSL_CAPATH: { zend_bool pers = net->persistent; - if (net->options.ssl_capath) { - mnd_pefree(net->options.ssl_capath, pers); + if (net->data->options.ssl_capath) { + mnd_pefree(net->data->options.ssl_capath, pers); } - net->options.ssl_capath = value? mnd_pestrdup(value, pers) : NULL; + net->data->options.ssl_capath = value? mnd_pestrdup(value, pers) : NULL; break; } case MYSQLND_OPT_SSL_CIPHER: { zend_bool pers = net->persistent; - if (net->options.ssl_cipher) { - mnd_pefree(net->options.ssl_cipher, pers); + if (net->data->options.ssl_cipher) { + mnd_pefree(net->data->options.ssl_cipher, pers); } - net->options.ssl_cipher = value? mnd_pestrdup(value, pers) : NULL; + net->data->options.ssl_cipher = value? mnd_pestrdup(value, pers) : NULL; break; } case MYSQLND_OPT_SSL_PASSPHRASE: { zend_bool pers = net->persistent; - if (net->options.ssl_passphrase) { - mnd_pefree(net->options.ssl_passphrase, pers); + if (net->data->options.ssl_passphrase) { + mnd_pefree(net->data->options.ssl_passphrase, pers); } - net->options.ssl_passphrase = value? mnd_pestrdup(value, pers) : NULL; + net->data->options.ssl_passphrase = value? mnd_pestrdup(value, pers) : NULL; break; } case MYSQL_OPT_SSL_VERIFY_SERVER_CERT: - net->options.ssl_verify_peer = value? ((*(zend_bool *)value)? TRUE:FALSE): FALSE; + net->data->options.ssl_verify_peer = value? ((*(zend_bool *)value)? TRUE:FALSE): FALSE; break; case MYSQL_OPT_READ_TIMEOUT: - net->options.timeout_read = *(unsigned int*) value; + net->data->options.timeout_read = *(unsigned int*) value; break; #ifdef WHEN_SUPPORTED_BY_MYSQLI case MYSQL_OPT_WRITE_TIMEOUT: - net->options.timeout_write = *(unsigned int*) value; + net->data->options.timeout_write = *(unsigned int*) value; break; #endif case MYSQL_OPT_COMPRESS: - net->options.flags |= MYSQLND_NET_FLAG_USE_COMPRESSION; + net->data->options.flags |= MYSQLND_NET_FLAG_USE_COMPRESSION; break; + case MYSQL_SERVER_PUBLIC_KEY: + { + zend_bool pers = net->persistent; + if (net->data->options.sha256_server_public_key) { + mnd_pefree(net->data->options.sha256_server_public_key, pers); + } + net->data->options.sha256_server_public_key = value? mnd_pestrdup(value, pers) : NULL; + break; + } default: DBG_RETURN(FAIL); } @@ -765,7 +812,8 @@ MYSQLND_METHOD(mysqlnd_net, consume_uneaten_data)(MYSQLND_NET * const net, enum char tmp_buf[256]; size_t skipped_bytes = 0; int opt = PHP_STREAM_OPTION_BLOCKING; - int was_blocked = net->stream->ops->set_option(net->stream, opt, 0, NULL TSRMLS_CC); + php_stream * net_stream = net->data->get_stream(net TSRMLS_CC); + int was_blocked = net_stream->ops->set_option(net_stream, opt, 0, NULL TSRMLS_CC); DBG_ENTER("mysqlnd_net::consume_uneaten_data"); @@ -774,11 +822,11 @@ MYSQLND_METHOD(mysqlnd_net, consume_uneaten_data)(MYSQLND_NET * const net, enum int bytes_consumed; do { - skipped_bytes += (bytes_consumed = php_stream_read(net->stream, tmp_buf, sizeof(tmp_buf))); + skipped_bytes += (bytes_consumed = php_stream_read(net_stream, tmp_buf, sizeof(tmp_buf))); } while (bytes_consumed == sizeof(tmp_buf)); if (was_blocked) { - net->stream->ops->set_option(net->stream, opt, 1, NULL TSRMLS_CC); + net_stream->ops->set_option(net_stream, opt, 1, NULL TSRMLS_CC); } if (bytes_consumed) { @@ -806,58 +854,61 @@ static enum_func_status MYSQLND_METHOD(mysqlnd_net, enable_ssl)(MYSQLND_NET * const net TSRMLS_DC) { #ifdef MYSQLND_SSL_SUPPORTED - php_stream_context *context = php_stream_context_alloc(TSRMLS_C); + php_stream_context * context = php_stream_context_alloc(TSRMLS_C); + php_stream * net_stream = net->data->m.get_stream(net TSRMLS_CC); + DBG_ENTER("mysqlnd_net::enable_ssl"); if (!context) { DBG_RETURN(FAIL); } - if (net->options.ssl_key) { + if (net->data->options.ssl_key) { zval key_zval; - ZVAL_STRING(&key_zval, net->options.ssl_key, 0); + ZVAL_STRING(&key_zval, net->data->options.ssl_key, 0); php_stream_context_set_option(context, "ssl", "local_pk", &key_zval); } - if (net->options.ssl_verify_peer) { + if (net->data->options.ssl_verify_peer) { zval verify_peer_zval; ZVAL_TRUE(&verify_peer_zval); php_stream_context_set_option(context, "ssl", "verify_peer", &verify_peer_zval); } - if (net->options.ssl_cert) { + if (net->data->options.ssl_cert) { zval cert_zval; - ZVAL_STRING(&cert_zval, net->options.ssl_cert, 0); + ZVAL_STRING(&cert_zval, net->data->options.ssl_cert, 0); php_stream_context_set_option(context, "ssl", "local_cert", &cert_zval); - if (!net->options.ssl_key) { + if (!net->data->options.ssl_key) { php_stream_context_set_option(context, "ssl", "local_pk", &cert_zval); } } - if (net->options.ssl_ca) { + if (net->data->options.ssl_ca) { zval cafile_zval; - ZVAL_STRING(&cafile_zval, net->options.ssl_ca, 0); + ZVAL_STRING(&cafile_zval, net->data->options.ssl_ca, 0); php_stream_context_set_option(context, "ssl", "cafile", &cafile_zval); } - if (net->options.ssl_capath) { + if (net->data->options.ssl_capath) { zval capath_zval; - ZVAL_STRING(&capath_zval, net->options.ssl_capath, 0); + ZVAL_STRING(&capath_zval, net->data->options.ssl_capath, 0); php_stream_context_set_option(context, "ssl", "cafile", &capath_zval); } - if (net->options.ssl_passphrase) { + if (net->data->options.ssl_passphrase) { zval passphrase_zval; - ZVAL_STRING(&passphrase_zval, net->options.ssl_passphrase, 0); + ZVAL_STRING(&passphrase_zval, net->data->options.ssl_passphrase, 0); php_stream_context_set_option(context, "ssl", "passphrase", &passphrase_zval); } - if (net->options.ssl_cipher) { + if (net->data->options.ssl_cipher) { zval cipher_zval; - ZVAL_STRING(&cipher_zval, net->options.ssl_cipher, 0); + ZVAL_STRING(&cipher_zval, net->data->options.ssl_cipher, 0); php_stream_context_set_option(context, "ssl", "ciphers", &cipher_zval); } - php_stream_context_set(net->stream, context); - if (php_stream_xport_crypto_setup(net->stream, STREAM_CRYPTO_METHOD_TLS_CLIENT, NULL TSRMLS_CC) < 0 || - php_stream_xport_crypto_enable(net->stream, 1 TSRMLS_CC) < 0) + php_stream_context_set(net_stream, context); + if (php_stream_xport_crypto_setup(net_stream, STREAM_CRYPTO_METHOD_TLS_CLIENT, NULL TSRMLS_CC) < 0 || + php_stream_xport_crypto_enable(net_stream, 1 TSRMLS_CC) < 0) { DBG_ERR("Cannot connect to MySQL by using SSL"); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot connect to MySQL by using SSL"); DBG_RETURN(FAIL); } + net->data->ssl = TRUE; /* get rid of the context. we are persistent and if this is a real pconn used by mysql/mysqli, then the context would not survive cleaning of EG(regular_list), where it is registered, as a @@ -865,19 +916,20 @@ MYSQLND_METHOD(mysqlnd_net, enable_ssl)(MYSQLND_NET * const net TSRMLS_DC) of the context, which means usage of already freed memory, bad. Actually we don't need this context anymore after we have enabled SSL on the connection. Thus it is very simple, we remove it. */ - php_stream_context_set(net->stream, NULL); + php_stream_context_set(net_stream, NULL); - if (net->options.timeout_read) { + if (net->data->options.timeout_read) { struct timeval tv; - DBG_INF_FMT("setting %u as PHP_STREAM_OPTION_READ_TIMEOUT", net->options.timeout_read); - tv.tv_sec = net->options.timeout_read; + DBG_INF_FMT("setting %u as PHP_STREAM_OPTION_READ_TIMEOUT", net->data->options.timeout_read); + tv.tv_sec = net->data->options.timeout_read; tv.tv_usec = 0; - php_stream_set_option(net->stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv); + php_stream_set_option(net_stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv); } DBG_RETURN(PASS); #else DBG_ENTER("mysqlnd_net::enable_ssl"); + DBG_INFO("MYSQLND_SSL_SUPPORTED is not defined"); DBG_RETURN(PASS); #endif } @@ -906,25 +958,29 @@ MYSQLND_METHOD(mysqlnd_net, free_contents)(MYSQLND_NET * net TSRMLS_DC) net->uncompressed_data->free_buffer(&net->uncompressed_data TSRMLS_CC); } #endif - if (net->options.ssl_key) { - mnd_pefree(net->options.ssl_key, pers); - net->options.ssl_key = NULL; + if (net->data->options.ssl_key) { + mnd_pefree(net->data->options.ssl_key, pers); + net->data->options.ssl_key = NULL; + } + if (net->data->options.ssl_cert) { + mnd_pefree(net->data->options.ssl_cert, pers); + net->data->options.ssl_cert = NULL; } - if (net->options.ssl_cert) { - mnd_pefree(net->options.ssl_cert, pers); - net->options.ssl_cert = NULL; + if (net->data->options.ssl_ca) { + mnd_pefree(net->data->options.ssl_ca, pers); + net->data->options.ssl_ca = NULL; } - if (net->options.ssl_ca) { - mnd_pefree(net->options.ssl_ca, pers); - net->options.ssl_ca = NULL; + if (net->data->options.ssl_capath) { + mnd_pefree(net->data->options.ssl_capath, pers); + net->data->options.ssl_capath = NULL; } - if (net->options.ssl_capath) { - mnd_pefree(net->options.ssl_capath, pers); - net->options.ssl_capath = NULL; + if (net->data->options.ssl_cipher) { + mnd_pefree(net->data->options.ssl_cipher, pers); + net->data->options.ssl_cipher = NULL; } - if (net->options.ssl_cipher) { - mnd_pefree(net->options.ssl_cipher, pers); - net->options.ssl_cipher = NULL; + if (net->data->options.sha256_server_public_key) { + mnd_pefree(net->data->options.sha256_server_public_key, pers); + net->data->options.sha256_server_public_key = NULL; } DBG_VOID_RETURN; @@ -936,24 +992,25 @@ MYSQLND_METHOD(mysqlnd_net, free_contents)(MYSQLND_NET * net TSRMLS_DC) static void MYSQLND_METHOD(mysqlnd_net, close_stream)(MYSQLND_NET * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC) { + php_stream * net_stream; DBG_ENTER("mysqlnd_net::close_stream"); - if (net && net->stream) { + if (net && (net_stream = net->data->m.get_stream(net TSRMLS_CC))) { zend_bool pers = net->persistent; - DBG_INF_FMT("Freeing stream. abstract=%p", net->stream->abstract); + DBG_INF_FMT("Freeing stream. abstract=%p", net_stream->abstract); if (pers) { if (EG(active)) { - php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR); + php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR); } else { /* otherwise we will crash because the EG(persistent_list) has been freed already, before the modules are shut down */ - php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_RSRC_DTOR); + php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_RSRC_DTOR); } } else { - php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE); + php_stream_free(net_stream, PHP_STREAM_FREE_CLOSE); } - net->stream = NULL; + (void) net->data->m.set_stream(net, NULL TSRMLS_CC); } DBG_VOID_RETURN; @@ -969,13 +1026,13 @@ MYSQLND_METHOD(mysqlnd_net, init)(MYSQLND_NET * const net, MYSQLND_STATS * const DBG_ENTER("mysqlnd_net::init"); buf_size = MYSQLND_G(net_cmd_buffer_size); /* this is long, cast to unsigned int*/ - net->m.set_client_option(net, MYSQLND_OPT_NET_CMD_BUFFER_SIZE, (char *) &buf_size TSRMLS_CC); + net->data->m.set_client_option(net, MYSQLND_OPT_NET_CMD_BUFFER_SIZE, (char *) &buf_size TSRMLS_CC); buf_size = MYSQLND_G(net_read_buffer_size); /* this is long, cast to unsigned int*/ - net->m.set_client_option(net, MYSQLND_OPT_NET_READ_BUFFER_SIZE, (char *)&buf_size TSRMLS_CC); + net->data->m.set_client_option(net, MYSQLND_OPT_NET_READ_BUFFER_SIZE, (char *)&buf_size TSRMLS_CC); buf_size = MYSQLND_G(net_read_timeout); /* this is long, cast to unsigned int*/ - net->m.set_client_option(net, MYSQL_OPT_READ_TIMEOUT, (char *)&buf_size TSRMLS_CC); + net->data->m.set_client_option(net, MYSQL_OPT_READ_TIMEOUT, (char *)&buf_size TSRMLS_CC); DBG_RETURN(PASS); } @@ -988,22 +1045,49 @@ MYSQLND_METHOD(mysqlnd_net, dtor)(MYSQLND_NET * const net, MYSQLND_STATS * const { DBG_ENTER("mysqlnd_net::dtor"); if (net) { - zend_bool pers = net->persistent; - - net->m.free_contents(net TSRMLS_CC); - net->m.close_stream(net, stats, error_info TSRMLS_CC); + net->data->m.free_contents(net TSRMLS_CC); + net->data->m.close_stream(net, stats, error_info TSRMLS_CC); + if (net->cmd_buffer.buffer) { DBG_INF("Freeing cmd buffer"); - mnd_pefree(net->cmd_buffer.buffer, pers); + mnd_pefree(net->cmd_buffer.buffer, net->persistent); net->cmd_buffer.buffer = NULL; } - mnd_pefree(net, pers); + + mnd_pefree(net->data, net->data->persistent); + mnd_pefree(net, net->persistent); } DBG_VOID_RETURN; } /* }}} */ +/* {{{ mysqlnd_net::get_stream */ +static php_stream * +MYSQLND_METHOD(mysqlnd_net, get_stream)(const MYSQLND_NET * const net TSRMLS_DC) +{ + DBG_ENTER("mysqlnd_net::get_stream"); + DBG_INF_FMT("%p", net? net->data->stream:NULL); + DBG_RETURN(net? net->data->stream:NULL); +} +/* }}} */ + + +/* {{{ mysqlnd_net::set_stream */ +static php_stream * +MYSQLND_METHOD(mysqlnd_net, set_stream)(MYSQLND_NET * const net, php_stream * net_stream TSRMLS_DC) +{ + php_stream * ret = NULL; + DBG_ENTER("mysqlnd_net::set_stream"); + if (net) { + net->data->stream = net_stream; + ret = net->data->stream; + } + DBG_RETURN(ret); +} +/* }}} */ + + MYSQLND_CLASS_METHODS_START(mysqlnd_net) MYSQLND_METHOD(mysqlnd_net, init), MYSQLND_METHOD(mysqlnd_net, dtor), @@ -1011,8 +1095,9 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_net) MYSQLND_METHOD(mysqlnd_net, close_stream), MYSQLND_METHOD(mysqlnd_net, open_pipe), MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix), - NULL, /* unused 1 */ - NULL, /* unused 2 */ + MYSQLND_METHOD(mysqlnd_net, get_stream), + MYSQLND_METHOD(mysqlnd_net, set_stream), + MYSQLND_METHOD(mysqlnd_net, get_open_stream), MYSQLND_METHOD(mysqlnd_net, post_connect_set_opt), MYSQLND_METHOD(mysqlnd_net, set_client_option), MYSQLND_METHOD(mysqlnd_net, decode), @@ -1026,10 +1111,15 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_net) MYSQLND_METHOD(mysqlnd_net, send_ex), MYSQLND_METHOD(mysqlnd_net, receive_ex), #ifdef MYSQLND_COMPRESSION_ENABLED - MYSQLND_METHOD(mysqlnd_net, read_compressed_packet_from_stream_and_fill_read_buffer) + MYSQLND_METHOD(mysqlnd_net, read_compressed_packet_from_stream_and_fill_read_buffer), #else - NULL + NULL, #endif + NULL, /* unused 1 */ + NULL, /* unused 2 */ + NULL, /* unused 3 */ + NULL, /* unused 4 */ + NULL /* unused 5 */ MYSQLND_CLASS_METHODS_END; @@ -1051,7 +1141,7 @@ mysqlnd_net_free(MYSQLND_NET * const net, MYSQLND_STATS * stats, MYSQLND_ERROR_I { DBG_ENTER("mysqlnd_net_free"); if (net) { - net->m.dtor(net, stats, error_info TSRMLS_CC); + net->data->m.dtor(net, stats, error_info TSRMLS_CC); } DBG_VOID_RETURN; } diff --git a/ext/mysqlnd/mysqlnd_plugin.c b/ext/mysqlnd/mysqlnd_plugin.c index f32fe4afdc9ff..aa914061d6674 100644 --- a/ext/mysqlnd/mysqlnd_plugin.c +++ b/ext/mysqlnd/mysqlnd_plugin.c @@ -26,7 +26,7 @@ #include "mysqlnd_debug.h" /*--------------------------------------------------------------------*/ - +#if defined(MYSQLND_DBG_ENABLED) && MYSQLND_DBG_ENABLED == 1 static enum_func_status mysqlnd_example_plugin_end(void * p TSRMLS_DC); static MYSQLND_STATS * mysqlnd_plugin_example_stats = NULL; @@ -87,7 +87,7 @@ mysqlnd_example_plugin_register(TSRMLS_D) mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_example_plugin TSRMLS_CC); } /* }}} */ - +#endif /* defined(MYSQLND_DBG_ENABLED) && MYSQLND_DBG_ENABLED == 1 */ /*--------------------------------------------------------------------*/ static HashTable mysqlnd_registered_plugins; diff --git a/ext/mysqlnd/mysqlnd_priv.h b/ext/mysqlnd/mysqlnd_priv.h index 190ed697b64c5..38ef6cc855586 100644 --- a/ext/mysqlnd/mysqlnd_priv.h +++ b/ext/mysqlnd/mysqlnd_priv.h @@ -33,12 +33,6 @@ #define Z_DELREF_PP(ppz) Z_DELREF_P(*(ppz)) #endif -#if PHP_MAJOR_VERSION >= 6 -#define MYSQLND_UNICODE 1 -#else -#define MYSQLND_UNICODE 0 -#endif - #ifdef ZTS #include "TSRM.h" #endif @@ -47,21 +41,12 @@ #define pestrndup(s, length, persistent) ((persistent)?zend_strndup((s),(length)):estrndup((s),(length))) #endif -#if MYSQLND_UNICODE -#define mysqlnd_array_init(arg, field_count) \ -{ \ - ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg));\ - zend_u_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0, 0);\ - Z_TYPE_P(arg) = IS_ARRAY;\ -} -#else #define mysqlnd_array_init(arg, field_count) \ { \ ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg));\ zend_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0); \ Z_TYPE_P(arg) = IS_ARRAY;\ } -#endif #define MYSQLND_STR_W_LEN(str) str, (sizeof(str) - 1) @@ -174,9 +159,7 @@ #define CONN_SET_STATE(c, s) (c)->m->set_state((c), (s) TSRMLS_CC) /* PS stuff */ -typedef void (*ps_field_fetch_func)(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool everything_as_unicode TSRMLS_DC); +typedef void (*ps_field_fetch_func)(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC); struct st_mysqlnd_perm_bind { ps_field_fetch_func func; /* should be signed int */ @@ -193,23 +176,21 @@ PHPAPI extern const char * const mysqlnd_out_of_sync; PHPAPI extern const char * const mysqlnd_server_gone; PHPAPI extern const char * const mysqlnd_out_of_memory; -extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_object_factory); -extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_conn); -extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_conn_data); -extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_res); -extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_protocol); -extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_net); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_object_factory); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_conn); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_conn_data); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_res); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_protocol); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_net); -enum_func_status mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char *filename, zend_bool *is_warning TSRMLS_DC); +enum_func_status mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * filename, zend_bool * is_warning TSRMLS_DC); void _mysqlnd_init_ps_subsystem();/* This one is private, mysqlnd_library_init() will call it */ void _mysqlnd_init_ps_fetch_subsystem(); -void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, zend_bool as_unicode, - unsigned int byte_count TSRMLS_DC); +void ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row, unsigned int byte_count TSRMLS_DC); void mysqlnd_plugin_subsystem_init(TSRMLS_D); void mysqlnd_plugin_subsystem_end(TSRMLS_D); diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index 99bd021593e90..4916c0650d7b7 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -307,6 +307,7 @@ mysqlnd_stmt_read_prepare_response(MYSQLND_STMT * s TSRMLS_DC) stmt->warning_count = stmt->conn->upsert_status->warning_count = prepare_resp->warning_count; stmt->field_count = stmt->conn->field_count = prepare_resp->field_count; stmt->param_count = prepare_resp->param_count; + stmt->upsert_status->affected_rows = 0; /* be like libmysql */ done: PACKET_FREE(prepare_resp); @@ -734,7 +735,6 @@ mysqlnd_stmt_fetch_row_buffered(MYSQLND_RES *result, void *param, unsigned int f current_row, meta->field_count, meta->fields, - result->conn->options->numeric_and_datetime_as_unicode, result->conn->options->int_and_float_native, result->conn->stats TSRMLS_CC); if (PASS != rc) { @@ -853,7 +853,6 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int result->unbuf->last_row_data, row_packet->field_count, row_packet->fields_metadata, - result->conn->options->numeric_and_datetime_as_unicode, result->conn->options->int_and_float_native, result->conn->stats TSRMLS_CC)) { @@ -871,14 +870,7 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int zval_dtor(stmt->result_bind[i].zv); #endif if (IS_NULL != (Z_TYPE_P(stmt->result_bind[i].zv) = Z_TYPE_P(data)) ) { - if ( - (Z_TYPE_P(data) == IS_STRING -#if MYSQLND_UNICODE - || Z_TYPE_P(data) == IS_UNICODE -#endif - ) - && (result->meta->fields[i].max_length < (unsigned long) Z_STRLEN_P(data))) - { + if ((Z_TYPE_P(data) == IS_STRING) && (result->meta->fields[i].max_length < (unsigned long) Z_STRLEN_P(data))) { result->meta->fields[i].max_length = Z_STRLEN_P(data); } stmt->result_bind[i].zv->value = data->value; @@ -1037,7 +1029,6 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla result->unbuf->last_row_data, row_packet->field_count, row_packet->fields_metadata, - result->conn->options->numeric_and_datetime_as_unicode, result->conn->options->int_and_float_native, result->conn->stats TSRMLS_CC)) { @@ -1058,13 +1049,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla DBG_INF_FMT("i=%u bound_var=%p type=%u refc=%u", i, stmt->result_bind[i].zv, Z_TYPE_P(data), Z_REFCOUNT_P(stmt->result_bind[i].zv)); if (IS_NULL != (Z_TYPE_P(stmt->result_bind[i].zv) = Z_TYPE_P(data))) { - if ((Z_TYPE_P(data) == IS_STRING -#if MYSQLND_UNICODE - || Z_TYPE_P(data) == IS_UNICODE -#endif - ) - && (result->meta->fields[i].max_length < (unsigned long) Z_STRLEN_P(data))) - { + if ((Z_TYPE_P(data) == IS_STRING) && (result->meta->fields[i].max_length < (unsigned long) Z_STRLEN_P(data))) { result->meta->fields[i].max_length = Z_STRLEN_P(data); } stmt->result_bind[i].zv->value = data->value; diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c index 5ead1b0bcced2..9961d68e43834 100644 --- a/ext/mysqlnd/mysqlnd_ps_codec.c +++ b/ext/mysqlnd/mysqlnd_ps_codec.c @@ -53,9 +53,9 @@ struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST + 1]; #define MYSQLND_PS_SKIP_RESULT_STR -2 /* {{{ ps_fetch_from_1_to_8_bytes */ -void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, zend_bool as_unicode, - unsigned int byte_count TSRMLS_DC) +void +ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, + zend_uchar ** row, unsigned int byte_count TSRMLS_DC) { char tmp[22]; size_t tmp_len = 0; @@ -117,16 +117,7 @@ void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field, } if (tmp_len) { -#if MYSQLND_UNICODE - if (as_unicode) { - DBG_INF("stringify"); - ZVAL_UTF8_STRINGL(zv, tmp, tmp_len, ZSTR_DUPLICATE); - } else -#endif - { - DBG_INF("stringify"); - ZVAL_STRINGL(zv, tmp, tmp_len, 1); - } + ZVAL_STRINGL(zv, tmp, tmp_len, 1); } (*row)+= byte_count; DBG_VOID_RETURN; @@ -135,10 +126,8 @@ void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field, /* {{{ ps_fetch_null */ -static -void ps_fetch_null(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_null(zval *zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { ZVAL_NULL(zv); } @@ -146,54 +135,44 @@ void ps_fetch_null(zval *zv, const MYSQLND_FIELD * const field, /* {{{ ps_fetch_int8 */ -static -void ps_fetch_int8(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_int8(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { - ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, as_unicode, 1 TSRMLS_CC); + ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, 1 TSRMLS_CC); } /* }}} */ /* {{{ ps_fetch_int16 */ -static -void ps_fetch_int16(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_int16(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { - ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, as_unicode, 2 TSRMLS_CC); + ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, 2 TSRMLS_CC); } /* }}} */ /* {{{ ps_fetch_int32 */ -static -void ps_fetch_int32(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_int32(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { - ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, as_unicode, 4 TSRMLS_CC); + ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, 4 TSRMLS_CC); } /* }}} */ /* {{{ ps_fetch_int64 */ -static -void ps_fetch_int64(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_int64(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { - ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, as_unicode, 8 TSRMLS_CC); + ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, 8 TSRMLS_CC); } /* }}} */ /* {{{ ps_fetch_float */ -static -void ps_fetch_float(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_float(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { float value; DBG_ENTER("ps_fetch_float"); @@ -207,10 +186,8 @@ void ps_fetch_float(zval *zv, const MYSQLND_FIELD * const field, /* {{{ ps_fetch_double */ -static -void ps_fetch_double(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_double(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { double value; DBG_ENTER("ps_fetch_double"); @@ -224,18 +201,16 @@ void ps_fetch_double(zval *zv, const MYSQLND_FIELD * const field, /* {{{ ps_fetch_time */ -static -void ps_fetch_time(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_time(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { struct st_mysqlnd_time t; - unsigned int length; /* First byte encodes the length*/ + unsigned long length; /* First byte encodes the length*/ char * value; DBG_ENTER("ps_fetch_time"); if ((length = php_mysqlnd_net_field_length(row))) { - zend_uchar *to= *row; + zend_uchar * to= *row; t.time_type = MYSQLND_TIMESTAMP_TIME; t.neg = (zend_bool) to[0]; @@ -261,29 +236,19 @@ void ps_fetch_time(zval *zv, const MYSQLND_FIELD * const field, length = mnd_sprintf(&value, 0, "%s%02u:%02u:%02u", (t.neg ? "-" : ""), t.hour, t.minute, t.second); DBG_INF_FMT("%s", value); -#if MYSQLND_UNICODE - if (!as_unicode) { -#endif - ZVAL_STRINGL(zv, value, length, 1); - mnd_sprintf_free(value); -#if MYSQLND_UNICODE - } else { - ZVAL_UTF8_STRINGL(zv, value, length, ZSTR_AUTOFREE); - } -#endif + ZVAL_STRINGL(zv, value, length, 1); + mnd_sprintf_free(value); DBG_VOID_RETURN; } /* }}} */ /* {{{ ps_fetch_date */ -static -void ps_fetch_date(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_date(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { struct st_mysqlnd_time t = {0}; - unsigned int length; /* First byte encodes the length*/ + unsigned long length; /* First byte encodes the length*/ char * value; DBG_ENTER("ps_fetch_date"); @@ -308,34 +273,24 @@ void ps_fetch_date(zval *zv, const MYSQLND_FIELD * const field, length = mnd_sprintf(&value, 0, "%04u-%02u-%02u", t.year, t.month, t.day); DBG_INF_FMT("%s", value); -#if MYSQLND_UNICODE - if (!as_unicode) { -#endif - ZVAL_STRINGL(zv, value, length, 1); - mnd_sprintf_free(value); -#if MYSQLND_UNICODE - } else { - ZVAL_UTF8_STRINGL(zv, value, length, ZSTR_AUTOFREE); - } -#endif + ZVAL_STRINGL(zv, value, length, 1); + mnd_sprintf_free(value); DBG_VOID_RETURN; } /* }}} */ /* {{{ ps_fetch_datetime */ -static -void ps_fetch_datetime(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_datetime(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { struct st_mysqlnd_time t; - unsigned int length; /* First byte encodes the length*/ + unsigned long length; /* First byte encodes the length*/ char * value; DBG_ENTER("ps_fetch_datetime"); if ((length = php_mysqlnd_net_field_length(row))) { - zend_uchar *to= *row; + zend_uchar * to = *row; t.time_type = MYSQLND_TIMESTAMP_DATETIME; t.neg = 0; @@ -362,46 +317,26 @@ void ps_fetch_datetime(zval *zv, const MYSQLND_FIELD * const field, length = mnd_sprintf(&value, 0, "%04u-%02u-%02u %02u:%02u:%02u", t.year, t.month, t.day, t.hour, t.minute, t.second); DBG_INF_FMT("%s", value); -#if MYSQLND_UNICODE - if (!as_unicode) { -#endif - ZVAL_STRINGL(zv, value, length, 1); - mnd_sprintf_free(value); -#if MYSQLND_UNICODE - } else { - ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_AUTOFREE); - } -#endif + ZVAL_STRINGL(zv, value, length, 1); + mnd_sprintf_free(value); DBG_VOID_RETURN; } /* }}} */ /* {{{ ps_fetch_string */ -static -void ps_fetch_string(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_string(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { /* For now just copy, before we make it possible to write \0 to the row buffer */ - unsigned long length = php_mysqlnd_net_field_length(row); + const unsigned long length = php_mysqlnd_net_field_length(row); DBG_ENTER("ps_fetch_string"); DBG_INF_FMT("len = %lu", length); -#if MYSQLND_UNICODE - if (field->charsetnr == MYSQLND_BINARY_CHARSET_NR) { - DBG_INF("Binary charset"); - ZVAL_STRINGL(zv, (char *)*row, length, 1); - } else { - DBG_INF_FMT("copying from the row buffer"); - ZVAL_UTF8_STRINGL(zv, (char*)*row, length, ZSTR_DUPLICATE); - } -#else DBG_INF("copying from the row buffer"); ZVAL_STRINGL(zv, (char *)*row, length, 1); -#endif (*row) += length; DBG_VOID_RETURN; @@ -410,13 +345,11 @@ void ps_fetch_string(zval *zv, const MYSQLND_FIELD * const field, /* {{{ ps_fetch_bit */ -static -void ps_fetch_bit(zval *zv, const MYSQLND_FIELD * const field, - unsigned int pack_len, zend_uchar **row, - zend_bool as_unicode TSRMLS_DC) +static void +ps_fetch_bit(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC) { - unsigned long length= php_mysqlnd_net_field_length(row); - ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, as_unicode, length TSRMLS_CC); + unsigned long length = php_mysqlnd_net_field_length(row); + ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, length TSRMLS_CC); } /* }}} */ @@ -566,7 +499,7 @@ void _mysqlnd_init_ps_fetch_subsystem() /* {{{ mysqlnd_stmt_copy_it */ static enum_func_status -mysqlnd_stmt_copy_it(zval *** copies, zval *original, unsigned int param_count, unsigned int current TSRMLS_DC) +mysqlnd_stmt_copy_it(zval *** copies, zval * original, unsigned int param_count, unsigned int current TSRMLS_DC) { if (!*copies) { *copies = mnd_ecalloc(param_count, sizeof(zval *)); @@ -786,12 +719,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar case MYSQL_TYPE_VAR_STRING: use_string: data_size += 8; /* max 8 bytes for size */ -#if MYSQLND_UNICODE - if (Z_TYPE_P(the_var) != IS_STRING || Z_TYPE_P(the_var) == IS_UNICODE) -#else - if (Z_TYPE_P(the_var) != IS_STRING) -#endif - { + if (Z_TYPE_P(the_var) != IS_STRING) { if (!copies || !copies[i]) { if (PASS != mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC)) { SET_OOM_ERROR(*stmt->error_info); @@ -799,11 +727,6 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar } } the_var = copies[i]; -#if MYSQLND_UNICODE - if (Z_TYPE_P(the_var) == IS_UNICODE) { - zval_unicode_to_string_ex(the_var, UG(utf8_conv) TSRMLS_CC); - } -#endif } convert_to_string_ex(&the_var); data_size += Z_STRLEN_P(the_var); diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index 2e289062a93f9..7ab7d001619eb 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -55,7 +55,6 @@ MYSQLND_METHOD(mysqlnd_res, initialize_result_set_rest)(MYSQLND_RES * const resu data_cursor, result->meta->field_count, result->meta->fields, - result->conn->options->numeric_and_datetime_as_unicode, result->conn->options->int_and_float_native, result->conn->stats TSRMLS_CC); if (rc != PASS) { @@ -106,16 +105,6 @@ mysqlnd_rset_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, zend_bool * co /* Not a prepared statement, then we have to call copy_ctor and then zval_ptr_dtor() - - In Unicode mode the destruction of the zvals should not call - zval_copy_ctor() because then we will leak. - I suppose we can use UG(unicode) in mysqlnd.c when freeing a result set - to check if we need to call copy_ctor(). - - If the type is IS_UNICODE, which can happen with PHP6, then we don't - need to copy_ctor, as the data doesn't point to our internal buffers. - If it's string (in PHP5 always) and in PHP6 if data is binary, then - it still points to internal buffers and has to be copied. */ if (Z_TYPE_PP(zv) == IS_STRING) { zval_copy_ctor(*zv); @@ -669,7 +658,6 @@ mysqlnd_fetch_row_unbuffered_c(MYSQLND_RES * result TSRMLS_DC) result->unbuf->last_row_data, row_packet->field_count, row_packet->fields_metadata, - result->conn->options->numeric_and_datetime_as_unicode, result->conn->options->int_and_float_native, result->conn->stats TSRMLS_CC); if (PASS != rc) { @@ -784,7 +772,6 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES * result, void *param, unsigned int fla result->unbuf->last_row_data, field_count, row_packet->fields_metadata, - result->conn->options->numeric_and_datetime_as_unicode, result->conn->options->int_and_float_native, result->conn->stats TSRMLS_CC); if (PASS != rc) { @@ -812,19 +799,11 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES * result, void *param, unsigned int fla */ Z_ADDREF_P(data); if (hash_key->is_numeric == FALSE) { -#if MYSQLND_UNICODE - zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE, - hash_key->ustr, - hash_key->ulen + 1, - hash_key->key, - (void *) &data, sizeof(zval *), NULL); -#else zend_hash_quick_update(Z_ARRVAL_P(row), field->name, field->name_length + 1, hash_key->key, (void *) &data, sizeof(zval *), NULL); -#endif } else { zend_hash_index_update(Z_ARRVAL_P(row), hash_key->key, @@ -950,7 +929,6 @@ mysqlnd_fetch_row_buffered_c(MYSQLND_RES * result TSRMLS_DC) current_row, result->meta->field_count, result->meta->fields, - result->conn->options->numeric_and_datetime_as_unicode, result->conn->options->int_and_float_native, result->conn->stats TSRMLS_CC); if (rc != PASS) { @@ -1023,7 +1001,6 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES * result, void *param, unsigned int flags current_row, result->meta->field_count, result->meta->fields, - result->conn->options->numeric_and_datetime_as_unicode, result->conn->options->int_and_float_native, result->conn->stats TSRMLS_CC); if (rc != PASS) { @@ -1062,19 +1039,11 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES * result, void *param, unsigned int flags */ Z_ADDREF_P(data); if (hash_key->is_numeric == FALSE) { -#if MYSQLND_UNICODE - zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE, - hash_key->ustr, - hash_key->ulen + 1, - hash_key->key, - (void *) &data, sizeof(zval *), NULL); -#else zend_hash_quick_update(Z_ARRVAL_P(row), field->name, field->name_length + 1, hash_key->key, (void *) &data, sizeof(zval *), NULL); -#endif } else { zend_hash_index_update(Z_ARRVAL_P(row), hash_key->key, diff --git a/ext/mysqlnd/mysqlnd_result_meta.c b/ext/mysqlnd/mysqlnd_result_meta.c index 1d22e6cc05cd6..989781d665f80 100644 --- a/ext/mysqlnd/mysqlnd_result_meta.c +++ b/ext/mysqlnd/mysqlnd_result_meta.c @@ -92,60 +92,12 @@ mysqlnd_is_key_numeric(const char * key, size_t length, long *idx) /* }}} */ -#if MYSQLND_UNICODE -/* {{{ mysqlnd_unicode_is_key_numeric */ -static zend_bool -mysqlnd_unicode_is_key_numeric(UChar *key, size_t length, long *idx) -{ - register UChar * tmp=key; - - if (*tmp==0x2D /*'-'*/) { - tmp++; - } - if ((*tmp>=0x30 /*'0'*/ && *tmp<=0x39 /*'9'*/)) { /* possibly a numeric index */ - do { - UChar *end=key+length-1; - - if (*tmp++==0x30 && length>2) { /* don't accept numbers with leading zeros */ - break; - } - while (tmp=0x30 /*'0'*/ && *tmp<=0x39 /*'9'*/)) { - break; - } - tmp++; - } - if (tmp==end && *tmp==0) { /* a numeric index */ - if (*key==0x2D /*'-'*/) { - *idx = zend_u_strtol(key, NULL, 10); - if (*idx!=LONG_MIN) { - return TRUE; - } - } else { - *idx = zend_u_strtol(key, NULL, 10); - if (*idx!=LONG_MAX) { - return TRUE; - } - } - } - } while (0); - } - return FALSE; -} -/* }}} */ -#endif - - /* {{{ mysqlnd_res_meta::read_metadata */ static enum_func_status MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const meta, MYSQLND_CONN_DATA * conn TSRMLS_DC) { unsigned int i = 0; MYSQLND_PACKET_RES_FIELD * field_packet; -#if MYSQLND_UNICODE - UChar *ustr; - int ulen; -#endif DBG_ENTER("mysqlnd_res_meta::read_metadata"); @@ -226,21 +178,6 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met } } -#if MYSQLND_UNICODE - zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, - meta->fields[i].name, - meta->fields[i].name_length TSRMLS_CC); - if ((meta->zend_hash_keys[i].is_numeric = - mysqlnd_unicode_is_key_numeric(ustr, ulen + 1, &idx))) - { - meta->zend_hash_keys[i].key = idx; - mnd_efree(ustr); - } else { - meta->zend_hash_keys[i].ustr.u = ustr; - meta->zend_hash_keys[i].ulen = ulen; - meta->zend_hash_keys[i].key = zend_u_get_hash_value(IS_UNICODE, ZSTR(ustr), ulen + 1); - } -#else /* For BC we have to check whether the key is numeric and use it like this */ if ((meta->zend_hash_keys[i].is_numeric = mysqlnd_is_key_numeric(field_packet->metadata->name, @@ -253,7 +190,6 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met zend_get_hash_value(field_packet->metadata->name, field_packet->metadata->name_length + 1); } -#endif } PACKET_FREE(field_packet); @@ -283,15 +219,6 @@ MYSQLND_METHOD(mysqlnd_res_meta, free)(MYSQLND_RES_METADATA * meta TSRMLS_DC) if (meta->zend_hash_keys) { DBG_INF("Freeing zend_hash_keys"); -#if MYSQLND_UNICODE - if (UG(unicode)) { - for (i = 0; i < meta->field_count; i++) { - if (meta->zend_hash_keys[i].ustr.v) { - mnd_pefree(meta->zend_hash_keys[i].ustr.v, meta->persistent); - } - } - } -#endif mnd_pefree(meta->zend_hash_keys, meta->persistent); meta->zend_hash_keys = NULL; } @@ -379,15 +306,6 @@ MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * co /* copy the trailing \0 too */ memcpy(new_fields[i].def, orig_fields[i].def, orig_fields[i].def_length + 1); } -#if MYSQLND_UNICODE - if (new_meta->zend_hash_keys[i].ustr.u) { - new_meta->zend_hash_keys[i].ustr.u = - eustrndup(new_meta->zend_hash_keys[i].ustr.u, new_meta->zend_hash_keys[i].ulen); - if (!new_meta->zend_hash_keys[i].ustr.u) { - goto oom; - } - } -#endif } new_meta->current_field = 0; new_meta->field_count = meta->field_count; diff --git a/ext/mysqlnd/mysqlnd_reverse_api.h b/ext/mysqlnd/mysqlnd_reverse_api.h index dd23555b9435c..ae07bb7b51145 100644 --- a/ext/mysqlnd/mysqlnd_reverse_api.h +++ b/ext/mysqlnd/mysqlnd_reverse_api.h @@ -47,4 +47,3 @@ PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv TSRMLS_DC); * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ - diff --git a/ext/mysqlnd/mysqlnd_statistics.c b/ext/mysqlnd/mysqlnd_statistics.c index 271cb29717468..f52eb65b06917 100644 --- a/ext/mysqlnd/mysqlnd_statistics.c +++ b/ext/mysqlnd/mysqlnd_statistics.c @@ -203,22 +203,10 @@ mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, const MYSQLND_STRING mysqlnd_array_init(return_value, stats->count); for (i = 0; i < stats->count; i++) { -#if MYSQLND_UNICODE - UChar *ustr, *tstr; - int ulen, tlen; -#endif char tmp[25]; sprintf((char *)&tmp, MYSQLND_LLU_SPEC, stats->values[i]); -#if MYSQLND_UNICODE - zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, names[i].s, names[i].l + 1 TSRMLS_CC); - zend_string_to_unicode(UG(utf8_conv), &tstr, &tlen, tmp, strlen(tmp) + 1 TSRMLS_CC); - add_u_assoc_unicode_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen, tstr, 1); - efree(ustr); - efree(tstr); -#else add_assoc_string_ex(return_value, names[i].s, names[i].l + 1, tmp, 1); -#endif } } /* }}} */ diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h index 5c07a3c3c9b70..55775d97e18f5 100644 --- a/ext/mysqlnd/mysqlnd_structs.h +++ b/ext/mysqlnd/mysqlnd_structs.h @@ -23,6 +23,8 @@ #ifndef MYSQLND_STRUCTS_H #define MYSQLND_STRUCTS_H +#include "ext/standard/php_smart_str.h" + #define MYSQLND_TYPEDEFED_METHODS #define MYSQLND_CLASS_METHOD_TABLE_NAME(class) mysqlnd_##class##_methods @@ -31,6 +33,7 @@ #define MYSQLND_CLASS_METHODS_START(class) MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(class) = { #define MYSQLND_CLASS_METHODS_END } + typedef struct st_mysqlnd_memory_pool MYSQLND_MEMORY_POOL; typedef struct st_mysqlnd_memory_pool_chunk MYSQLND_MEMORY_POOL_CHUNK; typedef struct st_mysqlnd_memory_pool_chunk_llist MYSQLND_MEMORY_POOL_CHUNK_LLIST; @@ -172,7 +175,7 @@ typedef struct st_mysqlnd_options The ABI will be broken and the methods structure will be somewhere else in the memory which can crash external code. Feel free to reuse these. */ - char * unused2; + HashTable * connect_attr; char * unused3; char * unused4; char * unused5; @@ -183,7 +186,6 @@ typedef struct st_mysqlnd_options /* maximum allowed packet size for communication */ ulong max_allowed_packet; - zend_bool numeric_and_datetime_as_unicode; #ifdef MYSQLND_STRING_TO_INT_CONVERSION zend_bool int_and_float_native; #endif @@ -196,7 +198,7 @@ typedef struct st_mysqlnd_net_options unsigned int timeout_read; unsigned int timeout_write; - unsigned int net_read_buffer_size; + size_t net_read_buffer_size; /* SSL information */ char *ssl_key; @@ -207,12 +209,20 @@ typedef struct st_mysqlnd_net_options char *ssl_passphrase; zend_bool ssl_verify_peer; uint64_t flags; + + char * sha256_server_public_key; + + char * unused1; + char * unused2; + char * unused3; + char * unused4; } MYSQLND_NET_OPTIONS; typedef struct st_mysqlnd_connection MYSQLND; typedef struct st_mysqlnd_connection_data MYSQLND_CONN_DATA; typedef struct st_mysqlnd_net MYSQLND_NET; +typedef struct st_mysqlnd_net_data MYSQLND_NET_DATA; typedef struct st_mysqlnd_protocol MYSQLND_PROTOCOL; typedef struct st_mysqlnd_res MYSQLND_RES; typedef char** MYSQLND_ROW_C; /* return data as array of strings */ @@ -282,7 +292,10 @@ typedef enum_func_status (*func_mysqlnd_net__init)(MYSQLND_NET * const net, MYSQ typedef void (*func_mysqlnd_net__dtor)(MYSQLND_NET * const net, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC); typedef enum_func_status (*func_mysqlnd_net__connect_ex)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC); typedef void (*func_mysqlnd_net__close_stream)(MYSQLND_NET * const net, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC); -typedef enum_func_status (*func_mysqlnd_net__open_stream)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC); +typedef php_stream * (*func_mysqlnd_net__open_stream)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC); +typedef php_stream * (*func_mysqlnd_net__get_stream)(const MYSQLND_NET * const net TSRMLS_DC); +typedef php_stream * (*func_mysqlnd_net__set_stream)(MYSQLND_NET * const net, php_stream * net_stream TSRMLS_DC); +typedef func_mysqlnd_net__open_stream (*func_mysqlnd_net__get_open_stream)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC); typedef void (*func_mysqlnd_net__post_connect_set_opt)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC); typedef enum_func_status (*func_mysqlnd_net__read_compressed_packet_from_stream_and_fill_read_buffer)(MYSQLND_NET * net, size_t net_payload_size, MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info TSRMLS_DC); @@ -295,8 +308,10 @@ struct st_mysqlnd_net_methods func_mysqlnd_net__open_stream open_pipe; func_mysqlnd_net__open_stream open_tcp_or_unix; - void * unused1; - void * unused2; + func_mysqlnd_net__get_stream get_stream; + func_mysqlnd_net__set_stream set_stream; + func_mysqlnd_net__get_open_stream get_open_stream; + func_mysqlnd_net__post_connect_set_opt post_connect_set_opt; func_mysqlnd_net__set_client_option set_client_option; @@ -314,11 +329,11 @@ struct st_mysqlnd_net_methods func_mysqlnd_net__read_compressed_packet_from_stream_and_fill_read_buffer read_compressed_packet_from_stream_and_fill_read_buffer; + void * unused1; + void * unused2; void * unused3; void * unused4; void * unused5; - void * unused6; - void * unused7; }; @@ -335,6 +350,8 @@ struct st_mysqlnd_packet_stats; struct st_mysqlnd_packet_prepare_response; struct st_mysqlnd_packet_chg_user_resp; struct st_mysqlnd_packet_auth_pam; +struct st_mysqlnd_packet_sha256_pk_request; +struct st_mysqlnd_packet_sha256_pk_request_response; typedef struct st_mysqlnd_packet_greet * (*func_mysqlnd_protocol__get_greet_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC); typedef struct st_mysqlnd_packet_auth * (*func_mysqlnd_protocol__get_auth_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC); @@ -349,6 +366,8 @@ typedef struct st_mysqlnd_packet_row * (*func_mysqlnd_protocol__get_row_packet typedef struct st_mysqlnd_packet_stats * (*func_mysqlnd_protocol__get_stats_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC); typedef struct st_mysqlnd_packet_prepare_response *(*func_mysqlnd_protocol__get_prepare_response_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC); typedef struct st_mysqlnd_packet_chg_user_resp*(*func_mysqlnd_protocol__get_change_user_response_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC); +typedef struct st_mysqlnd_packet_sha256_pk_request *(*func_mysqlnd_protocol__get_sha256_pk_request_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC); +typedef struct st_mysqlnd_packet_sha256_pk_request_response *(*func_mysqlnd_protocol__get_sha256_pk_request_response_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC); struct st_mysqlnd_protocol_methods { @@ -365,12 +384,12 @@ struct st_mysqlnd_protocol_methods func_mysqlnd_protocol__get_stats_packet get_stats_packet; func_mysqlnd_protocol__get_prepare_response_packet get_prepare_response_packet; func_mysqlnd_protocol__get_change_user_response_packet get_change_user_response_packet; + func_mysqlnd_protocol__get_sha256_pk_request_packet get_sha256_pk_request_packet; + func_mysqlnd_protocol__get_sha256_pk_request_response_packet get_sha256_pk_request_response_packet; void * unused1; void * unused2; void * unused3; - void * unused4; - void * unused5; }; @@ -447,7 +466,7 @@ typedef enum_func_status (*func_mysqlnd_conn_data__query_read_result_set_header) typedef MYSQLND_CONN_DATA * (*func_mysqlnd_conn_data__get_reference)(MYSQLND_CONN_DATA * const conn TSRMLS_DC); typedef enum_func_status (*func_mysqlnd_conn_data__free_reference)(MYSQLND_CONN_DATA * const conn TSRMLS_DC); -typedef enum mysqlnd_connection_state (*func_mysqlnd_conn_data__get_state)(MYSQLND_CONN_DATA * const conn TSRMLS_DC); +typedef enum mysqlnd_connection_state (*func_mysqlnd_conn_data__get_state)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC); typedef void (*func_mysqlnd_conn_data__set_state)(MYSQLND_CONN_DATA * const conn, enum mysqlnd_connection_state new_state TSRMLS_DC); typedef enum_func_status (*func_mysqlnd_conn_data__simple_command)(MYSQLND_CONN_DATA * conn, enum php_mysqlnd_server_command command, const zend_uchar * const arg, size_t arg_len, enum mysqlnd_packet_type ok_packet, zend_bool silent, zend_bool ignore_upsert_status TSRMLS_DC); @@ -464,10 +483,21 @@ typedef MYSQLND_RES * (*func_mysqlnd_conn_data__result_init)(unsigned int fiel typedef enum_func_status (*func_mysqlnd_conn_data__set_autocommit)(MYSQLND_CONN_DATA * conn, unsigned int mode TSRMLS_DC); typedef enum_func_status (*func_mysqlnd_conn_data__tx_commit)(MYSQLND_CONN_DATA * conn TSRMLS_DC); typedef enum_func_status (*func_mysqlnd_conn_data__tx_rollback)(MYSQLND_CONN_DATA * conn TSRMLS_DC); +typedef enum_func_status (*func_mysqlnd_conn_data__tx_begin)(MYSQLND_CONN_DATA * conn, const unsigned int mode, const char * const name TSRMLS_DC); +typedef enum_func_status (*func_mysqlnd_conn_data__tx_commit_or_rollback)(MYSQLND_CONN_DATA * conn, const zend_bool commit, const unsigned int flags, const char * const name TSRMLS_DC); +typedef void (*func_mysqlnd_conn_data__tx_cor_options_to_string)(const MYSQLND_CONN_DATA * const conn, smart_str * tmp_str, const unsigned int mode TSRMLS_DC); +typedef enum_func_status (*func_mysqlnd_conn_data__tx_savepoint)(MYSQLND_CONN_DATA * conn, const char * const name TSRMLS_DC); +typedef enum_func_status (*func_mysqlnd_conn_data__tx_savepoint_release)(MYSQLND_CONN_DATA * conn, const char * const name TSRMLS_DC); typedef enum_func_status (*func_mysqlnd_conn_data__local_tx_start)(MYSQLND_CONN_DATA * conn, size_t this_func TSRMLS_DC); typedef enum_func_status (*func_mysqlnd_conn_data__local_tx_end)(MYSQLND_CONN_DATA * conn, size_t this_func, enum_func_status status TSRMLS_DC); +typedef enum_func_status (*func_mysqlnd_conn_data__execute_init_commands)(MYSQLND_CONN_DATA * conn TSRMLS_DC); +typedef unsigned int (*func_mysqlnd_conn_data__get_updated_connect_flags)(MYSQLND_CONN_DATA * conn, unsigned int mysql_flags TSRMLS_DC); +typedef enum_func_status (*func_mysqlnd_conn_data__connect_handshake)(MYSQLND_CONN_DATA * conn, const char * const host, const char * const user, const char * const passwd, const unsigned int passwd_len, const char * const db, const unsigned int db_len, const unsigned int mysql_flags TSRMLS_DC); +typedef enum_func_status (*func_mysqlnd_conn_data__simple_command_send_request)(MYSQLND_CONN_DATA * conn, enum php_mysqlnd_server_command command, const zend_uchar * const arg, size_t arg_len, zend_bool silent, zend_bool ignore_upsert_status TSRMLS_DC); +typedef struct st_mysqlnd_authentication_plugin * (*func_mysqlnd_conn_data__fetch_auth_plugin_by_name)(const char * const requested_protocol TSRMLS_DC); +typedef enum_func_status (*func_mysqlnd_conn_data__set_client_option_2d)(MYSQLND_CONN_DATA * const conn, enum mysqlnd_option option, const char * const key, const char * const value TSRMLS_DC); struct st_mysqlnd_conn_data_methods { @@ -544,9 +574,22 @@ struct st_mysqlnd_conn_data_methods func_mysqlnd_conn_data__set_autocommit set_autocommit; func_mysqlnd_conn_data__tx_commit tx_commit; func_mysqlnd_conn_data__tx_rollback tx_rollback; + func_mysqlnd_conn_data__tx_begin tx_begin; + func_mysqlnd_conn_data__tx_commit_or_rollback tx_commit_or_rollback; + func_mysqlnd_conn_data__tx_cor_options_to_string tx_cor_options_to_string; + func_mysqlnd_conn_data__tx_savepoint tx_savepoint; + func_mysqlnd_conn_data__tx_savepoint_release tx_savepoint_release; func_mysqlnd_conn_data__local_tx_start local_tx_start; func_mysqlnd_conn_data__local_tx_end local_tx_end; + + func_mysqlnd_conn_data__execute_init_commands execute_init_commands; + func_mysqlnd_conn_data__get_updated_connect_flags get_updated_connect_flags; + func_mysqlnd_conn_data__connect_handshake connect_handshake; + func_mysqlnd_conn_data__simple_command_send_request simple_command_send_request; + func_mysqlnd_conn_data__fetch_auth_plugin_by_name fetch_auth_plugin_by_name; + + func_mysqlnd_conn_data__set_client_option_2d set_client_option_2d; }; @@ -598,9 +641,8 @@ typedef void (*func_mysqlnd_res__unbuffered_free_last_data)(MYSQLND_RES *resu /* for decoding - binary or text protocol */ typedef enum_func_status (*func_mysqlnd_res__row_decoder)(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields, - unsigned int field_count, MYSQLND_FIELD *fields_metadata, - zend_bool as_unicode, zend_bool as_int_or_float, - MYSQLND_STATS * stats TSRMLS_DC); + unsigned int field_count, const MYSQLND_FIELD * fields_metadata, + zend_bool as_int_or_float, MYSQLND_STATS * stats TSRMLS_DC); typedef MYSQLND_RES_METADATA * (*func_mysqlnd_res__result_meta_init)(unsigned int field_count, zend_bool persistent TSRMLS_DC); @@ -768,31 +810,44 @@ struct st_mysqlnd_stmt_methods }; -struct st_mysqlnd_net +struct st_mysqlnd_net_data { php_stream *stream; + zend_bool compressed; + zend_bool ssl; +#ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND + zend_uchar last_command; +#else + zend_uchar unused_pad1; +#endif + MYSQLND_NET_OPTIONS options; + + unsigned int refcount; + + zend_bool persistent; + + struct st_mysqlnd_net_methods m; +}; + + +struct st_mysqlnd_net +{ + struct st_mysqlnd_net_data * data; + /* sequence for simple checking of correct packets */ zend_uchar packet_no; - zend_bool compressed; zend_uchar compressed_envelope_packet_no; + #ifdef MYSQLND_COMPRESSION_ENABLED MYSQLND_READ_BUFFER * uncompressed_data; #else void * unused_pad1; #endif -#ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND - zend_uchar last_command; -#else - zend_uchar unused_pad2; -#endif + /* cmd buffer */ MYSQLND_CMD_BUFFER cmd_buffer; - MYSQLND_NET_OPTIONS options; - - zend_bool persistent; - - struct st_mysqlnd_net_methods m; + zend_bool persistent; }; @@ -893,10 +948,6 @@ struct mysqlnd_field_hash_key { zend_bool is_numeric; unsigned long key; -#if MYSQLND_UNICODE - zstr ustr; - unsigned int ulen; -#endif }; @@ -1070,7 +1121,8 @@ typedef zend_uchar * (*func_auth_plugin__get_auth_data)(struct st_mysqlnd_authen size_t * auth_data_len, MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len, - const MYSQLND_OPTIONS * const options, unsigned long mysql_flags + const MYSQLND_OPTIONS * const options, + const MYSQLND_NET_OPTIONS * const net_options, unsigned long mysql_flags TSRMLS_DC); struct st_mysqlnd_authentication_plugin diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index d0ab9fe7312e3..669970789bac5 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -47,7 +47,7 @@ (buf_size), (packet)->header.size, (packet)->header.size - (buf_size)); \ DBG_RETURN(FAIL); \ }\ - if (FAIL == conn->net->m.receive_ex((conn)->net, (buf), (packet)->header.size, (conn)->stats, ((conn)->error_info) TSRMLS_CC)) { \ + if (FAIL == conn->net->data->m.receive_ex((conn)->net, (buf), (packet)->header.size, (conn)->stats, ((conn)->error_info) TSRMLS_CC)) { \ CONN_SET_STATE(conn, CONN_QUIT_SENT); \ SET_CLIENT_ERROR(*conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);\ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", mysqlnd_server_gone); \ @@ -212,6 +212,24 @@ php_mysqlnd_net_store_length(zend_uchar *packet, uint64_t length) /* }}} */ +/* {{{ php_mysqlnd_net_store_length_size */ +size_t +php_mysqlnd_net_store_length_size(uint64_t length) +{ + if (length < (uint64_t) L64(251)) { + return 1; + } + if (length < (uint64_t) L64(65536)) { + return 3; + } + if (length < (uint64_t) L64(16777216)) { + return 4; + } + return 8; +} +/* }}} */ + + /* {{{ php_mysqlnd_read_error_from_line */ static enum_func_status php_mysqlnd_read_error_from_line(zend_uchar *buf, size_t buf_len, @@ -264,8 +282,8 @@ mysqlnd_read_header(MYSQLND_NET * net, MYSQLND_PACKET_HEADER * header, zend_uchar buffer[MYSQLND_HEADER_SIZE]; DBG_ENTER(mysqlnd_read_header_name); - DBG_INF_FMT("compressed=%u", net->compressed); - if (FAIL == net->m.receive_ex(net, buffer, MYSQLND_HEADER_SIZE, conn_stats, error_info TSRMLS_CC)) { + DBG_INF_FMT("compressed=%u", net->data->compressed); + if (FAIL == net->data->m.receive_ex(net, buffer, MYSQLND_HEADER_SIZE, conn_stats, error_info TSRMLS_CC)) { DBG_RETURN(FAIL); } @@ -279,7 +297,7 @@ mysqlnd_read_header(MYSQLND_NET * net, MYSQLND_PACKET_HEADER * header, STAT_PROTOCOL_OVERHEAD_IN, MYSQLND_HEADER_SIZE, STAT_PACKETS_RECEIVED, 1); - if (net->compressed || net->packet_no == header->packet_no) { + if (net->data->compressed || net->packet_no == header->packet_no) { /* Have to increase the number, so we can send correct number back. It will round at 255 as this is unsigned char. The server needs this for simple @@ -459,7 +477,7 @@ void php_mysqlnd_greet_free_mem(void * _packet, zend_bool stack_allocation TSRML /* }}} */ -#define AUTH_WRITE_BUFFER_LEN (MYSQLND_HEADER_SIZE + MYSQLND_MAX_ALLOWED_USER_LEN + SCRAMBLE_LENGTH + MYSQLND_MAX_ALLOWED_DB_LEN + 1 + 1024) +#define AUTH_WRITE_BUFFER_LEN (MYSQLND_HEADER_SIZE + MYSQLND_MAX_ALLOWED_USER_LEN + SCRAMBLE_LENGTH + MYSQLND_MAX_ALLOWED_DB_LEN + 1 + 4096) /* {{{ php_mysqlnd_auth_write */ static @@ -540,6 +558,52 @@ size_t php_mysqlnd_auth_write(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC p+= len; *p++= '\0'; } + + if (packet->connect_attr && zend_hash_num_elements(packet->connect_attr)) { + HashPosition pos_value; + const char ** entry_value; + size_t ca_payload_len = 0; + zend_hash_internal_pointer_reset_ex(packet->connect_attr, &pos_value); + while (SUCCESS == zend_hash_get_current_data_ex(packet->connect_attr, (void **)&entry_value, &pos_value)) { + char *s_key; + unsigned int s_len; + unsigned long num_key; + size_t value_len = strlen(*entry_value); + + if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(packet->connect_attr, &s_key, &s_len, &num_key, 0, &pos_value)) { + ca_payload_len += php_mysqlnd_net_store_length_size(s_len); + ca_payload_len += s_len; + ca_payload_len += php_mysqlnd_net_store_length_size(value_len); + ca_payload_len += value_len; + } + zend_hash_move_forward_ex(conn->options->connect_attr, &pos_value); + } + + if ((sizeof(buffer) - (p - buffer)) >= (ca_payload_len + php_mysqlnd_net_store_length_size(ca_payload_len))) { + p = php_mysqlnd_net_store_length(p, ca_payload_len); + + zend_hash_internal_pointer_reset_ex(packet->connect_attr, &pos_value); + while (SUCCESS == zend_hash_get_current_data_ex(packet->connect_attr, (void **)&entry_value, &pos_value)) { + char *s_key; + unsigned int s_len; + unsigned long num_key; + size_t value_len = strlen(*entry_value); + if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(packet->connect_attr, &s_key, &s_len, &num_key, 0, &pos_value)) { + /* copy key */ + p = php_mysqlnd_net_store_length(p, s_len); + memcpy(p, s_key, s_len); + p+= s_len; + /* copy value */ + p = php_mysqlnd_net_store_length(p, value_len); + memcpy(p, *entry_value, value_len); + p+= value_len; + } + zend_hash_move_forward_ex(conn->options->connect_attr, &pos_value); + } + } else { + /* cannot put the data - skip */ + } + } } if (packet->is_change_user_packet) { if (PASS != conn->m->simple_command(conn, COM_CHANGE_USER, buffer + MYSQLND_HEADER_SIZE, p - buffer - MYSQLND_HEADER_SIZE, @@ -549,7 +613,7 @@ size_t php_mysqlnd_auth_write(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC } DBG_RETURN(p - buffer - MYSQLND_HEADER_SIZE); } else { - size_t sent = conn->net->m.send_ex(conn->net, buffer, p - buffer - MYSQLND_HEADER_SIZE, conn->stats, conn->error_info TSRMLS_CC); + size_t sent = conn->net->data->m.send_ex(conn->net, buffer, p - buffer - MYSQLND_HEADER_SIZE, conn->stats, conn->error_info TSRMLS_CC); if (!sent) { CONN_SET_STATE(conn, CONN_QUIT_SENT); } @@ -623,7 +687,7 @@ php_mysqlnd_auth_response_read(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_D memcpy(packet->new_auth_protocol_data, p, packet->new_auth_protocol_data_len); } DBG_INF_FMT("The server requested switching auth plugin to : %s", packet->new_auth_protocol); - DBG_INF_FMT("Server salt : [%*s]", packet->new_auth_protocol_data_len, packet->new_auth_protocol_data); + DBG_INF_FMT("Server salt : [%d][%.*s]", packet->new_auth_protocol_data_len, packet->new_auth_protocol_data_len, packet->new_auth_protocol_data); } } else { /* Everything was fine! */ @@ -709,7 +773,7 @@ php_mysqlnd_change_auth_response_write(void * _packet, MYSQLND_CONN_DATA * conn } { - size_t sent = conn->net->m.send_ex(conn->net, buffer, p - buffer - MYSQLND_HEADER_SIZE, conn->stats, conn->error_info TSRMLS_CC); + size_t sent = conn->net->data->m.send_ex(conn->net, buffer, p - buffer - MYSQLND_HEADER_SIZE, conn->stats, conn->error_info TSRMLS_CC); if (buffer != conn->net->cmd_buffer.buffer) { mnd_efree(buffer); } @@ -923,14 +987,14 @@ size_t php_mysqlnd_cmd_write(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC) MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_PACKETS_SENT_CMD); #ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND - net->m.consume_uneaten_data(net, packet->command TSRMLS_CC); + net->data->m.consume_uneaten_data(net, packet->command TSRMLS_CC); #endif if (!packet->argument || !packet->arg_len) { zend_uchar buffer[MYSQLND_HEADER_SIZE + 1]; int1store(buffer + MYSQLND_HEADER_SIZE, packet->command); - sent = net->m.send_ex(net, buffer, 1, conn->stats, conn->error_info TSRMLS_CC); + sent = net->data->m.send_ex(net, buffer, 1, conn->stats, conn->error_info TSRMLS_CC); } else { size_t tmp_len = packet->arg_len + 1 + MYSQLND_HEADER_SIZE; zend_uchar *tmp, *p; @@ -945,7 +1009,7 @@ size_t php_mysqlnd_cmd_write(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC) memcpy(p, packet->argument, packet->arg_len); - sent = net->m.send_ex(net, tmp, tmp_len - MYSQLND_HEADER_SIZE, conn->stats, conn->error_info TSRMLS_CC); + sent = net->data->m.send_ex(net, tmp, tmp_len - MYSQLND_HEADER_SIZE, conn->stats, conn->error_info TSRMLS_CC); if (tmp != net->cmd_buffer.buffer) { MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_CMD_BUFFER_TOO_SMALL); mnd_efree(tmp); @@ -1388,7 +1452,7 @@ php_mysqlnd_read_row_ex(MYSQLND_CONN_DATA * conn, MYSQLND_MEMORY_POOL * result_s p = (*buffer)->ptr + (*data_size - header.size); } - if (PASS != (ret = conn->net->m.receive_ex(conn->net, p, header.size, conn->stats, conn->error_info TSRMLS_CC))) { + if (PASS != (ret = conn->net->data->m.receive_ex(conn->net, p, header.size, conn->stats, conn->error_info TSRMLS_CC))) { DBG_ERR("Empty row packet body"); php_error(E_WARNING, "Empty row packet body"); break; @@ -1411,9 +1475,8 @@ php_mysqlnd_read_row_ex(MYSQLND_CONN_DATA * conn, MYSQLND_MEMORY_POOL * result_s /* {{{ php_mysqlnd_rowp_read_binary_protocol */ enum_func_status php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields, - unsigned int field_count, MYSQLND_FIELD *fields_metadata, - zend_bool as_unicode, zend_bool as_int_or_float, - MYSQLND_STATS * stats TSRMLS_DC) + unsigned int field_count, const MYSQLND_FIELD * fields_metadata, + zend_bool as_int_or_float, MYSQLND_STATS * stats TSRMLS_DC) { unsigned int i; zend_uchar * p = row_buffer->ptr; @@ -1446,17 +1509,17 @@ php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zv enum_mysqlnd_collected_stats statistic; zend_uchar * orig_p = p; - DBG_INF_FMT("Into zval=%p decoding column %u [%s.%s.%s] type=%u field->flags&unsigned=%u flags=%u is_bit=%u as_unicode=%u", + DBG_INF_FMT("Into zval=%p decoding column %u [%s.%s.%s] type=%u field->flags&unsigned=%u flags=%u is_bit=%u", *current_field, i, fields_metadata[i].db, fields_metadata[i].table, fields_metadata[i].name, fields_metadata[i].type, - fields_metadata[i].flags & UNSIGNED_FLAG, fields_metadata[i].flags, fields_metadata[i].type == MYSQL_TYPE_BIT, as_unicode); + fields_metadata[i].flags & UNSIGNED_FLAG, fields_metadata[i].flags, fields_metadata[i].type == MYSQL_TYPE_BIT); if (*null_ptr & bit) { DBG_INF("It's null"); ZVAL_NULL(*current_field); statistic = STAT_BINARY_TYPE_FETCHED_NULL; } else { enum_mysqlnd_field_types type = fields_metadata[i].type; - mysqlnd_ps_fetch_functions[type].func(*current_field, &fields_metadata[i], 0, &p, as_unicode TSRMLS_CC); + mysqlnd_ps_fetch_functions[type].func(*current_field, &fields_metadata[i], 0, &p TSRMLS_CC); if (MYSQLND_G(collect_statistics)) { switch (fields_metadata[i].type) { @@ -1510,9 +1573,8 @@ php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zv /* {{{ php_mysqlnd_rowp_read_text_protocol */ enum_func_status php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields, - unsigned int field_count, MYSQLND_FIELD *fields_metadata, - zend_bool as_unicode, zend_bool as_int_or_float, - MYSQLND_STATS * stats TSRMLS_DC) + unsigned int field_count, const MYSQLND_FIELD * fields_metadata, + zend_bool as_int_or_float, MYSQLND_STATS * stats TSRMLS_DC) { unsigned int i; zend_bool last_field_was_string = FALSE; @@ -1564,7 +1626,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ZVAL_NULL(*current_field); last_field_was_string = FALSE; } else { -#if MYSQLND_UNICODE || defined(MYSQLND_STRING_TO_INT_CONVERSION) +#if defined(MYSQLND_STRING_TO_INT_CONVERSION) struct st_mysqlnd_perm_bind perm_bind = mysqlnd_ps_fetch_functions[fields_metadata[i].type]; #endif @@ -1660,7 +1722,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval Definitely not nice, _hackish_ :(, but works. */ zend_uchar *start = bit_area; - ps_fetch_from_1_to_8_bytes(*current_field, &(fields_metadata[i]), 0, &p, as_unicode, len TSRMLS_CC); + ps_fetch_from_1_to_8_bytes(*current_field, &(fields_metadata[i]), 0, &p, len TSRMLS_CC); /* We have advanced in ps_fetch_from_1_to_8_bytes. We should go back because later in this function there will be an advancement. @@ -1668,60 +1730,16 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval p -= len; if (Z_TYPE_PP(current_field) == IS_LONG) { bit_area += 1 + sprintf((char *)start, "%ld", Z_LVAL_PP(current_field)); -#if MYSQLND_UNICODE - if (as_unicode) { - ZVAL_UTF8_STRINGL(*current_field, start, bit_area - start - 1, 0); - } else -#endif - { - ZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, 0); - } + ZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, 0); } else if (Z_TYPE_PP(current_field) == IS_STRING){ memcpy(bit_area, Z_STRVAL_PP(current_field), Z_STRLEN_PP(current_field)); bit_area += Z_STRLEN_PP(current_field); *bit_area++ = '\0'; zval_dtor(*current_field); -#if MYSQLND_UNICODE - if (as_unicode) { - ZVAL_UTF8_STRINGL(*current_field, start, bit_area - start - 1, 0); - } else -#endif - { - ZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, 0); - } + ZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, 0); } - /* - IS_UNICODE should not be specially handled. In unicode mode - the buffers are not referenced - everything is copied. - */ } else -#if MYSQLND_UNICODE == 0 - { - ZVAL_STRINGL(*current_field, (char *)p, len, 0); - } -#else - /* - Here we have to convert to UTF16, which means not reusing the buffer. - Which in turn means that we can free the buffers once we have - stored the result set, if we use store_result(). - - Also the destruction of the zvals should not call zval_copy_ctor() - because then we will leak. - - XXX: Keep in mind that up there there is an open `else` in - #ifdef MYSQLND_STRING_TO_INT_CONVERSION - which will make with this `if` an `else if`. - */ - if ((perm_bind.is_possibly_blob == TRUE && - fields_metadata[i].charsetnr == MYSQLND_BINARY_CHARSET_NR) || - (!as_unicode && perm_bind.can_ret_as_str_in_uni == TRUE)) - { - /* BLOB - no conversion please */ - ZVAL_STRINGL(*current_field, (char *)p, len, 0); - } else { - ZVAL_UTF8_STRINGL(*current_field, (char *)p, len, 0); - } -#endif + ZVAL_STRINGL(*current_field, (char *)p, len, 0); p += len; last_field_was_string = TRUE; } @@ -1744,10 +1762,8 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval static enum_func_status php_mysqlnd_rowp_read(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC) { - MYSQLND_NET * net = conn->net; zend_uchar *p; enum_func_status ret = PASS; - size_t old_chunk_size = net->stream->chunk_size; MYSQLND_PACKET_ROW *packet= (MYSQLND_PACKET_ROW *) _packet; size_t post_alloc_for_bit_fields = 0; size_t data_size = 0; @@ -1829,7 +1845,6 @@ php_mysqlnd_rowp_read(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC) } end: - net->stream->chunk_size = old_chunk_size; DBG_RETURN(ret); } /* }}} */ @@ -2081,6 +2096,89 @@ php_mysqlnd_chg_user_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_ /* }}} */ +/* {{{ php_mysqlnd_sha256_pk_request_write */ +static +size_t php_mysqlnd_sha256_pk_request_write(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC) +{ + zend_uchar buffer[MYSQLND_HEADER_SIZE + 1]; + size_t sent; + + DBG_ENTER("php_mysqlnd_sha256_pk_request_write"); + + int1store(buffer + MYSQLND_HEADER_SIZE, '\1'); + sent = conn->net->data->m.send_ex(conn->net, buffer, 1, conn->stats, conn->error_info TSRMLS_CC); + + DBG_RETURN(sent); +} +/* }}} */ + + +/* {{{ php_mysqlnd_sha256_pk_request_free_mem */ +static +void php_mysqlnd_sha256_pk_request_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC) +{ + if (!stack_allocation) { + MYSQLND_PACKET_SHA256_PK_REQUEST * p = (MYSQLND_PACKET_SHA256_PK_REQUEST *) _packet; + mnd_pefree(p, p->header.persistent); + } +} +/* }}} */ + + +#define SHA256_PK_REQUEST_RESP_BUFFER_SIZE 2048 + +/* {{{ php_mysqlnd_sha256_pk_request_response_read */ +static enum_func_status +php_mysqlnd_sha256_pk_request_response_read(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC) +{ + zend_uchar buf[SHA256_PK_REQUEST_RESP_BUFFER_SIZE]; + zend_uchar *p = buf; + zend_uchar *begin = buf; + MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE * packet= (MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE *) _packet; + + DBG_ENTER("php_mysqlnd_sha256_pk_request_response_read"); + + /* leave space for terminating safety \0 */ + PACKET_READ_HEADER_AND_BODY(packet, conn, buf, sizeof(buf), "SHA256_PK_REQUEST_RESPONSE", PROT_SHA256_PK_REQUEST_RESPONSE_PACKET); + BAIL_IF_NO_MORE_DATA; + + p++; + BAIL_IF_NO_MORE_DATA; + + packet->public_key_len = packet->header.size - (p - buf); + packet->public_key = mnd_emalloc(packet->public_key_len + 1); + memcpy(packet->public_key, p, packet->public_key_len); + packet->public_key[packet->public_key_len] = '\0'; + + DBG_RETURN(PASS); + +premature_end: + DBG_ERR_FMT("OK packet %d bytes shorter than expected", p - begin - packet->header.size); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SHA256_PK_REQUEST_RESPONSE packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", + p - begin - packet->header.size); + DBG_RETURN(FAIL); +} +/* }}} */ + + +/* {{{ php_mysqlnd_sha256_pk_request_response_free_mem */ +static void +php_mysqlnd_sha256_pk_request_response_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC) +{ + MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE * p = (MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE *) _packet; + if (p->public_key) { + mnd_efree(p->public_key); + p->public_key = NULL; + } + p->public_key_len = 0; + + if (!stack_allocation) { + mnd_pefree(p, p->header.persistent); + } +} +/* }}} */ + + /* {{{ packet_methods */ static mysqlnd_packet_methods packet_methods[PROT_LAST] = @@ -2162,7 +2260,19 @@ mysqlnd_packet_methods packet_methods[PROT_LAST] = php_mysqlnd_chg_user_read, /* read */ NULL, /* write */ php_mysqlnd_chg_user_free_mem, - } /* PROT_CHG_USER_RESP_PACKET */ + }, /* PROT_CHG_USER_RESP_PACKET */ + { + sizeof(MYSQLND_PACKET_SHA256_PK_REQUEST), + NULL, /* read */ + php_mysqlnd_sha256_pk_request_write, + php_mysqlnd_sha256_pk_request_free_mem, + }, /* PROT_SHA256_PK_REQUEST_PACKET */ + { + sizeof(MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE), + php_mysqlnd_sha256_pk_request_response_read, + NULL, /* write */ + php_mysqlnd_sha256_pk_request_response_free_mem, + } /* PROT_SHA256_PK_REQUEST_RESPONSE_PACKET */ }; /* }}} */ @@ -2362,6 +2472,37 @@ MYSQLND_METHOD(mysqlnd_protocol, get_change_user_response_packet)(MYSQLND_PROTOC /* }}} */ +/* {{{ mysqlnd_protocol::get_sha256_pk_request_packet */ +static struct st_mysqlnd_packet_sha256_pk_request * +MYSQLND_METHOD(mysqlnd_protocol, get_sha256_pk_request_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC) +{ + struct st_mysqlnd_packet_sha256_pk_request * packet = mnd_pecalloc(1, packet_methods[PROT_SHA256_PK_REQUEST_PACKET].struct_size, persistent); + DBG_ENTER("mysqlnd_protocol::get_sha256_pk_request_packet"); + if (packet) { + packet->header.m = &packet_methods[PROT_SHA256_PK_REQUEST_PACKET]; + packet->header.persistent = persistent; + } + DBG_RETURN(packet); +} +/* }}} */ + + +/* {{{ mysqlnd_protocol::get_sha256_pk_request_response_packet */ +static struct st_mysqlnd_packet_sha256_pk_request_response * +MYSQLND_METHOD(mysqlnd_protocol, get_sha256_pk_request_response_packet)(MYSQLND_PROTOCOL * const protocol, zend_bool persistent TSRMLS_DC) +{ + struct st_mysqlnd_packet_sha256_pk_request_response * packet = mnd_pecalloc(1, packet_methods[PROT_SHA256_PK_REQUEST_RESPONSE_PACKET].struct_size, persistent); + DBG_ENTER("mysqlnd_protocol::get_sha256_pk_request_response_packet"); + if (packet) { + packet->header.m = &packet_methods[PROT_SHA256_PK_REQUEST_RESPONSE_PACKET]; + packet->header.persistent = persistent; + } + DBG_RETURN(packet); +} +/* }}} */ + + + MYSQLND_CLASS_METHODS_START(mysqlnd_protocol) MYSQLND_METHOD(mysqlnd_protocol, get_greet_packet), MYSQLND_METHOD(mysqlnd_protocol, get_auth_packet), @@ -2375,7 +2516,9 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_protocol) MYSQLND_METHOD(mysqlnd_protocol, get_row_packet), MYSQLND_METHOD(mysqlnd_protocol, get_stats_packet), MYSQLND_METHOD(mysqlnd_protocol, get_prepare_response_packet), - MYSQLND_METHOD(mysqlnd_protocol, get_change_user_response_packet) + MYSQLND_METHOD(mysqlnd_protocol, get_change_user_response_packet), + MYSQLND_METHOD(mysqlnd_protocol, get_sha256_pk_request_packet), + MYSQLND_METHOD(mysqlnd_protocol, get_sha256_pk_request_response_packet) MYSQLND_CLASS_METHODS_END; diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.h b/ext/mysqlnd/mysqlnd_wireprotocol.h index 253784c364b5a..26dd4c65aecd8 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.h +++ b/ext/mysqlnd/mysqlnd_wireprotocol.h @@ -103,7 +103,7 @@ typedef struct st_mysqlnd_packet_auth { zend_bool send_auth_data; zend_bool is_change_user_packet; zend_bool silent; - + HashTable *connect_attr; } MYSQLND_PACKET_AUTH; /* Auth response packet */ @@ -286,6 +286,18 @@ typedef struct st_mysqlnd_packet_chg_user_resp { } MYSQLND_PACKET_CHG_USER_RESPONSE; +/* Command packet */ +typedef struct st_mysqlnd_packet_sha256_pk_request { + MYSQLND_PACKET_HEADER header; +} MYSQLND_PACKET_SHA256_PK_REQUEST; + +typedef struct st_mysqlnd_packet_sha256_pk_request_response { + MYSQLND_PACKET_HEADER header; + zend_uchar *public_key; + size_t public_key_len; +} MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE; + + PHPAPI void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const pass, size_t pass_len); unsigned long php_mysqlnd_net_field_length(zend_uchar **packet); @@ -295,15 +307,13 @@ PHPAPI const extern char * const mysqlnd_empty_string; enum_func_status php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields, - unsigned int field_count, MYSQLND_FIELD *fields_metadata, - zend_bool as_unicode, zend_bool as_int_or_float, - MYSQLND_STATS * stats TSRMLS_DC); + unsigned int field_count, const MYSQLND_FIELD * fields_metadata, + zend_bool as_int_or_float, MYSQLND_STATS * stats TSRMLS_DC); enum_func_status php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields, - unsigned int field_count, MYSQLND_FIELD *fields_metadata, - zend_bool as_unicode, zend_bool as_int_or_float, - MYSQLND_STATS * stats TSRMLS_DC); + unsigned int field_count, const MYSQLND_FIELD * fields_metadata, + zend_bool as_int_or_float, MYSQLND_STATS * stats TSRMLS_DC); PHPAPI MYSQLND_PROTOCOL * mysqlnd_protocol_init(zend_bool persistent TSRMLS_DC); diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c index 002135566c3c2..016840cf04f25 100644 --- a/ext/mysqlnd/php_mysqlnd.c +++ b/ext/mysqlnd/php_mysqlnd.c @@ -40,39 +40,8 @@ static zend_function_entry mysqlnd_functions[] = { /* {{{ mysqlnd_minfo_print_hash */ -#if MYSQLND_UNICODE -PHPAPI void mysqlnd_minfo_print_hash(zval *values) -{ - zval **values_entry; - HashPosition pos_values; - - zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values); - while (zend_hash_get_current_data_ex(Z_ARRVAL_P(values), - (void **)&values_entry, &pos_values) == SUCCESS) { - zstr string_key; - uint string_key_len; - ulong num_key; - int s_len; - char *s = NULL; - - TSRMLS_FETCH(); - zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, &string_key_len, &num_key, 0, &pos_values); - - convert_to_string(*values_entry); - - if (zend_unicode_to_string(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), - &s, &s_len, string_key.u, string_key_len TSRMLS_CC) == SUCCESS) { - php_info_print_table_row(2, s, Z_STRVAL_PP(values_entry)); - } - if (s) { - mnd_efree(s); - } - - zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos_values); - } -} -#else -PHPAPI void mysqlnd_minfo_print_hash(zval *values) +PHPAPI void +mysqlnd_minfo_print_hash(zval *values) { zval **values_entry; HashPosition pos_values; @@ -91,7 +60,6 @@ PHPAPI void mysqlnd_minfo_print_hash(zval *values) zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos_values); } } -#endif /* }}} */ @@ -170,11 +138,17 @@ PHP_MINFO_FUNCTION(mysqlnd) #else "not supported"); #endif - php_info_print_table_row(2, "SSL", + php_info_print_table_row(2, "core SSL", #ifdef MYSQLND_SSL_SUPPORTED "supported"); #else "not supported"); +#endif + php_info_print_table_row(2, "extended SSL", +#ifdef MYSQLND_HAVE_SSL + "supported"); +#else + "not supported"); #endif snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_cmd_buffer_size)); php_info_print_table_row(2, "Command buffer size", buf); @@ -221,6 +195,8 @@ static PHP_GINIT_FUNCTION(mysqlnd) mysqlnd_globals->collect_memory_statistics = FALSE; mysqlnd_globals->debug = NULL; /* The actual string */ mysqlnd_globals->dbg = NULL; /* The DBG object*/ + mysqlnd_globals->trace_alloc_settings = NULL; + mysqlnd_globals->trace_alloc = NULL; mysqlnd_globals->net_cmd_buffer_size = MYSQLND_NET_CMD_BUFFER_MIN_SIZE; mysqlnd_globals->net_read_buffer_size = 32768; mysqlnd_globals->net_read_timeout = 31536000; @@ -232,6 +208,7 @@ static PHP_GINIT_FUNCTION(mysqlnd) mysqlnd_globals->debug_malloc_fail_threshold = -1; mysqlnd_globals->debug_calloc_fail_threshold = -1; mysqlnd_globals->debug_realloc_fail_threshold = -1; + mysqlnd_globals->sha256_server_public_key = NULL; } /* }}} */ @@ -253,11 +230,13 @@ PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN("mysqlnd.collect_statistics", "1", PHP_INI_ALL, OnUpdateBool, collect_statistics, zend_mysqlnd_globals, mysqlnd_globals) STD_PHP_INI_BOOLEAN("mysqlnd.collect_memory_statistics", "0", PHP_INI_SYSTEM, OnUpdateBool, collect_memory_statistics, zend_mysqlnd_globals, mysqlnd_globals) STD_PHP_INI_ENTRY("mysqlnd.debug", NULL, PHP_INI_SYSTEM, OnUpdateString, debug, zend_mysqlnd_globals, mysqlnd_globals) + STD_PHP_INI_ENTRY("mysqlnd.trace_alloc", NULL, PHP_INI_SYSTEM, OnUpdateString, trace_alloc_settings, zend_mysqlnd_globals, mysqlnd_globals) STD_PHP_INI_ENTRY("mysqlnd.net_cmd_buffer_size", MYSQLND_NET_CMD_BUFFER_MIN_SIZE_STR, PHP_INI_ALL, OnUpdateNetCmdBufferSize, net_cmd_buffer_size, zend_mysqlnd_globals, mysqlnd_globals) STD_PHP_INI_ENTRY("mysqlnd.net_read_buffer_size", "32768",PHP_INI_ALL, OnUpdateLong, net_read_buffer_size, zend_mysqlnd_globals, mysqlnd_globals) STD_PHP_INI_ENTRY("mysqlnd.net_read_timeout", "31536000", PHP_INI_SYSTEM, OnUpdateLong, net_read_timeout, zend_mysqlnd_globals, mysqlnd_globals) STD_PHP_INI_ENTRY("mysqlnd.log_mask", "0", PHP_INI_ALL, OnUpdateLong, log_mask, zend_mysqlnd_globals, mysqlnd_globals) STD_PHP_INI_ENTRY("mysqlnd.mempool_default_size","16000", PHP_INI_ALL, OnUpdateLong, mempool_default_size, zend_mysqlnd_globals, mysqlnd_globals) + STD_PHP_INI_ENTRY("mysqlnd.sha256_server_public_key",NULL, PHP_INI_PERDIR, OnUpdateString, sha256_server_public_key, zend_mysqlnd_globals, mysqlnd_globals) #if PHP_DEBUG STD_PHP_INI_ENTRY("mysqlnd.debug_emalloc_fail_threshold","-1", PHP_INI_SYSTEM, OnUpdateLong, debug_emalloc_fail_threshold, zend_mysqlnd_globals, mysqlnd_globals) @@ -306,11 +285,14 @@ static PHP_RINIT_FUNCTION(mysqlnd) MYSQLND_G(dbg) = NULL; if (trace_log_plugin) { MYSQLND_DEBUG * dbg = trace_log_plugin->methods.trace_instance_init(mysqlnd_debug_std_no_trace_funcs TSRMLS_CC); - if (!dbg) { + MYSQLND_DEBUG * trace_alloc = trace_log_plugin->methods.trace_instance_init(NULL TSRMLS_CC); + if (!dbg || !trace_alloc) { return FAILURE; } dbg->m->set_mode(dbg, MYSQLND_G(debug)); + trace_alloc->m->set_mode(trace_alloc, MYSQLND_G(trace_alloc_settings)); MYSQLND_G(dbg) = dbg; + MYSQLND_G(trace_alloc) = trace_alloc; } } return SUCCESS; @@ -324,13 +306,19 @@ static PHP_RINIT_FUNCTION(mysqlnd) */ static PHP_RSHUTDOWN_FUNCTION(mysqlnd) { - MYSQLND_DEBUG *dbg = MYSQLND_G(dbg); + MYSQLND_DEBUG * dbg = MYSQLND_G(dbg); + MYSQLND_DEBUG * trace_alloc = MYSQLND_G(trace_alloc); DBG_ENTER("RSHUTDOWN"); if (dbg) { dbg->m->close(dbg); dbg->m->free_handle(dbg); MYSQLND_G(dbg) = NULL; } + if (trace_alloc) { + trace_alloc->m->close(trace_alloc); + trace_alloc->m->free_handle(trace_alloc); + MYSQLND_G(trace_alloc) = NULL; + } return SUCCESS; } /* }}} */ diff --git a/ext/openssl/CREDITS b/ext/openssl/CREDITS index c2f50d63089ef..b685ce13e5cbf 100644 --- a/ext/openssl/CREDITS +++ b/ext/openssl/CREDITS @@ -1,2 +1,2 @@ OpenSSL -Stig Venaas, Wez Furlong, Sascha Kettler +Stig Venaas, Wez Furlong, Sascha Kettler, Scott MacVicar diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 328c1ee9378a8..fd8d7deb6214c 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -16,7 +16,7 @@ | Wez Furlong | | Sascha Kettler | | Pierre-Alain Joye | - | Marc Delling (PKCS12 functions) | + | Marc Delling (PKCS12 functions) | +----------------------------------------------------------------------+ */ @@ -36,10 +36,6 @@ #include "ext/standard/md5.h" #include "ext/standard/base64.h" -#if PHP_WIN32 -# include "win32/winutil.h" -#endif - /* OpenSSL includes */ #include #include @@ -248,6 +244,16 @@ ZEND_BEGIN_ARG_INFO(arginfo_openssl_pkey_get_details, 0) ZEND_ARG_INFO(0, key) ZEND_END_ARG_INFO() +#if OPENSSL_VERSION_NUMBER >= 0x10000000L +ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_pbkdf2, 0, 0, 4) + ZEND_ARG_INFO(0, password) + ZEND_ARG_INFO(0, salt) + ZEND_ARG_INFO(0, key_length) + ZEND_ARG_INFO(0, iterations) + ZEND_ARG_INFO(0, digest_algorithm) +ZEND_END_ARG_INFO() +#endif + ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_pkcs7_verify, 0, 0, 2) ZEND_ARG_INFO(0, filename) ZEND_ARG_INFO(0, flags) @@ -434,6 +440,10 @@ const zend_function_entry openssl_functions[] = { PHP_FE(openssl_seal, arginfo_openssl_seal) PHP_FE(openssl_open, arginfo_openssl_open) +#if OPENSSL_VERSION_NUMBER >= 0x10000000L + PHP_FE(openssl_pbkdf2, arginfo_openssl_pbkdf2) +#endif + /* for S/MIME handling */ PHP_FE(openssl_pkcs7_verify, arginfo_openssl_pkcs7_verify) PHP_FE(openssl_pkcs7_decrypt, arginfo_openssl_pkcs7_decrypt) @@ -516,7 +526,7 @@ inline static int php_openssl_open_base_dir_chk(char *filename TSRMLS_DC) if (php_check_open_basedir(filename TSRMLS_CC)) { return -1; } - + return 0; } /* }}} */ @@ -575,7 +585,7 @@ static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int s } else { subitem = val; } - + for (i = 0; i < X509_NAME_entry_count(name); i++) { unsigned char *to_add; int to_add_len; @@ -618,7 +628,7 @@ static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int s last = j; } i = last; - + if (obj_cnt > 1) { add_assoc_zval_ex(subitem, sname, strlen(sname) + 1, subentries); } else { @@ -718,7 +728,7 @@ static inline int php_openssl_config_check_syntax(const char * section_label, co #endif { X509V3_CTX ctx; - + X509V3_set_ctx_test(&ctx); X509V3_set_conf_lhash(&ctx, config); if (!X509V3_EXT_add_conf(config, &ctx, (char *)section, NULL)) { @@ -846,7 +856,7 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option } - + /* digest alg */ if (req->digest_name == NULL) { req->digest_name = CONF_get_string(req->req_config, req->section_name, "default_md"); @@ -868,7 +878,7 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option } PHP_SSL_CONFIG_SYNTAX_CHECK(request_extensions_section); - + return SUCCESS; } /* }}} */ @@ -1048,10 +1058,10 @@ PHP_MINIT_FUNCTION(openssl) /* register a resource id number with OpenSSL so that we can map SSL -> stream structures in * OpenSSL callbacks */ ssl_stream_data_index = SSL_get_ex_new_index(0, "PHP stream index", NULL, NULL, NULL); - + REGISTER_STRING_CONSTANT("OPENSSL_VERSION_TEXT", OPENSSL_VERSION_TEXT, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OPENSSL_VERSION_NUMBER", OPENSSL_VERSION_NUMBER, CONST_CS|CONST_PERSISTENT); - + /* purposes for cert purpose checking */ REGISTER_LONG_CONSTANT("X509_PURPOSE_SSL_CLIENT", X509_PURPOSE_SSL_CLIENT, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("X509_PURPOSE_SSL_SERVER", X509_PURPOSE_SSL_SERVER, CONST_CS|CONST_PERSISTENT); @@ -1110,7 +1120,7 @@ PHP_MINIT_FUNCTION(openssl) REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_AES_192_CBC", PHP_OPENSSL_CIPHER_AES_192_CBC, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_AES_256_CBC", PHP_OPENSSL_CIPHER_AES_256_CBC, CONST_CS|CONST_PERSISTENT); #endif - + /* Values for key types */ REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_RSA", OPENSSL_KEYTYPE_RSA, CONST_CS|CONST_PERSISTENT); #ifndef NO_DSA @@ -1156,7 +1166,7 @@ PHP_MINIT_FUNCTION(openssl) php_register_url_stream_wrapper("https", &php_stream_http_wrapper TSRMLS_CC); php_register_url_stream_wrapper("ftps", &php_stream_ftp_wrapper TSRMLS_CC); - + return SUCCESS; } /* }}} */ @@ -1376,14 +1386,14 @@ PHP_FUNCTION(openssl_x509_check_private_key) long certresource = -1, keyresource = -1; RETVAL_FALSE; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &zcert, &zkey) == FAILURE) { return; } cert = php_openssl_x509_from_zval(zcert, 0, &certresource TSRMLS_CC); if (cert == NULL) { RETURN_FALSE; - } + } key = php_openssl_evp_from_zval(zkey, 0, "", 1, &keyresource TSRMLS_CC); if (key) { RETVAL_BOOL(X509_check_private_key(cert, key)); @@ -1436,11 +1446,11 @@ PHP_FUNCTION(openssl_x509_parse) snprintf(buf, sizeof(buf), "%08lx", X509_subject_name_hash(cert)); add_assoc_string(return_value, "hash", buf, 1); } - + add_assoc_name_entry(return_value, "issuer", X509_get_issuer_name(cert), useshortnames TSRMLS_CC); add_assoc_long(return_value, "version", X509_get_version(cert)); - add_assoc_string(return_value, "serialNumber", i2s_ASN1_INTEGER(NULL, X509_get_serialNumber(cert)), 1); + add_assoc_string(return_value, "serialNumber", i2s_ASN1_INTEGER(NULL, X509_get_serialNumber(cert)), 1); add_assoc_asn1_string(return_value, "validFrom", X509_get_notBefore(cert)); add_assoc_asn1_string(return_value, "validTo", X509_get_notAfter(cert)); @@ -1642,8 +1652,8 @@ PHP_FUNCTION(openssl_x509_checkpurpose) if (certresource == 1 && cert) { X509_free(cert); } - if (cainfo) { - X509_STORE_free(cainfo); + if (cainfo) { + X509_STORE_free(cainfo); } if (untrustedchain) { sk_X509_pop_free(untrustedchain, X509_free); @@ -1696,7 +1706,7 @@ static X509_STORE * setup_verify(zval * calist TSRMLS_DC) dir_lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir()); if (dir_lookup == NULL || !X509_LOOKUP_add_dir(dir_lookup, Z_STRVAL_PP(item), X509_FILETYPE_PEM)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "error loading directory %s", Z_STRVAL_PP(item)); - } else { + } else { ndirs++; } dir_lookup = NULL; @@ -1790,11 +1800,11 @@ static STACK_OF(X509) * php_array_to_X509_sk(zval ** zcerts TSRMLS_DC) /* {{{ */ if (certresource != -1) { cert = X509_dup(cert); - + if (cert == NULL) { goto clean_exit; } - + } sk_X509_push(sk, cert); @@ -1803,7 +1813,7 @@ static STACK_OF(X509) * php_array_to_X509_sk(zval ** zcerts TSRMLS_DC) /* {{{ */ } else { /* a single certificate */ cert = php_openssl_x509_from_zval(zcerts, 0, &certresource TSRMLS_CC); - + if (cert == NULL) { goto clean_exit; } @@ -1844,7 +1854,7 @@ PHP_FUNCTION(openssl_pkcs12_export_to_file) return; RETVAL_FALSE; - + cert = php_openssl_x509_from_zval(zcert, 0, &certresource TSRMLS_CC); if (cert == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get cert from parameter 1"); @@ -1880,9 +1890,9 @@ PHP_FUNCTION(openssl_pkcs12_export_to_file) p12 = PKCS12_create(pass, friendly_name, priv_key, cert, ca, 0, 0, 0, 0, 0); - bio_out = BIO_new_file(filename, "w"); + bio_out = BIO_new_file(filename, "w"); if (bio_out) { - + i2d_PKCS12_bio(bio_out, p12); RETVAL_TRUE; @@ -1893,13 +1903,13 @@ PHP_FUNCTION(openssl_pkcs12_export_to_file) BIO_free(bio_out); PKCS12_free(p12); php_sk_X509_free(ca); - + cleanup: if (keyresource == -1 && priv_key) { EVP_PKEY_free(priv_key); } - if (certresource == -1 && cert) { + if (certresource == -1 && cert) { X509_free(cert); } } @@ -1925,7 +1935,7 @@ PHP_FUNCTION(openssl_pkcs12_export) return; RETVAL_FALSE; - + cert = php_openssl_x509_from_zval(&zcert, 0, &certresource TSRMLS_CC); if (cert == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get cert from parameter 1"); @@ -1948,7 +1958,7 @@ PHP_FUNCTION(openssl_pkcs12_export) if (args && zend_hash_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts"), (void**)&item) == SUCCESS) ca = php_array_to_X509_sk(item TSRMLS_CC); /* end parse extra config */ - + p12 = PKCS12_create(pass, friendly_name, priv_key, cert, ca, 0, 0, 0, 0, 0); bio_out = BIO_new(BIO_s_mem()); @@ -1965,13 +1975,13 @@ PHP_FUNCTION(openssl_pkcs12_export) BIO_free(bio_out); PKCS12_free(p12); php_sk_X509_free(ca); - + cleanup: if (keyresource == -1 && priv_key) { EVP_PKEY_free(priv_key); } - if (certresource == -1 && cert) { + if (certresource == -1 && cert) { X509_free(cert); } } @@ -1995,12 +2005,12 @@ PHP_FUNCTION(openssl_pkcs12_read) return; RETVAL_FALSE; - + bio_in = BIO_new(BIO_s_mem()); - + if(!BIO_write(bio_in, zp12, zp12_len)) goto cleanup; - + if(d2i_PKCS12_bio(bio_in, &p12)) { if(PKCS12_parse(p12, pass, &pkey, &cert, &ca)) { BIO * bio_out; @@ -2030,12 +2040,12 @@ PHP_FUNCTION(openssl_pkcs12_read) MAKE_STD_ZVAL(zextracerts); array_init(zextracerts); - + for (i=0;;i++) { zval * zextracert; X509* aCA = sk_X509_pop(ca); if (!aCA) break; - + bio_out = BIO_new(BIO_s_mem()); if (PEM_write_bio_X509(bio_out, aCA)) { BUF_MEM *bio_buf; @@ -2043,7 +2053,7 @@ PHP_FUNCTION(openssl_pkcs12_read) MAKE_STD_ZVAL(zextracert); ZVAL_STRINGL(zextracert, bio_buf->data, bio_buf->length, 1); add_index_zval(zextracerts, i, zextracert); - + } BIO_free(bio_out); @@ -2055,13 +2065,13 @@ PHP_FUNCTION(openssl_pkcs12_read) } else { zval_dtor(zextracerts); } - + RETVAL_TRUE; - + PKCS12_free(p12); } } - + cleanup: if (bio_in) { BIO_free(bio_in); @@ -2069,7 +2079,7 @@ PHP_FUNCTION(openssl_pkcs12_read) if (pkey) { EVP_PKEY_free(pkey); } - if (cert) { + if (cert) { X509_free(cert); } } @@ -2088,7 +2098,7 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z return FAILURE; } dn_sk = CONF_get_section(req->req_config, dn_sect); - if (dn_sk == NULL) { + if (dn_sk == NULL) { return FAILURE; } attr_sect = CONF_get_string(req->req_config, req->section_name, "attributes"); @@ -2108,15 +2118,15 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z X509_NAME * subj; HashPosition hpos; zval ** item; - + subj = X509_REQ_get_subject_name(csr); /* apply values from the dn hash */ zend_hash_internal_pointer_reset_ex(HASH_OF(dn), &hpos); while(zend_hash_get_current_data_ex(HASH_OF(dn), (void**)&item, &hpos) == SUCCESS) { - char * strindex = NULL; + char * strindex = NULL; uint strindexlen = 0; ulong intindex; - + zend_hash_get_current_key_ex(HASH_OF(dn), &strindex, &strindexlen, &intindex, 0, &hpos); convert_to_string_ex(item); @@ -2126,7 +2136,7 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z nid = OBJ_txt2nid(strindex); if (nid != NID_undef) { - if (!X509_NAME_add_entry_by_NID(subj, nid, MBSTRING_UTF8, + if (!X509_NAME_add_entry_by_NID(subj, nid, MBSTRING_UTF8, (unsigned char*)Z_STRVAL_PP(item), -1, -1, 0)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, @@ -2147,10 +2157,10 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z for(i = 0; i < sk_CONF_VALUE_num(dn_sk); i++) { int len; char buffer[200 + 1]; /*200 + \0 !*/ - + v = sk_CONF_VALUE_value(dn_sk, i); type = v->name; - + len = strlen(type); if (len < sizeof("_default")) { continue; @@ -2165,7 +2175,7 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z memcpy(buffer, type, len); buffer[len] = '\0'; type = buffer; - + /* Skip past any leading X. X: X, etc to allow for multiple * instances */ for (str = type; *str; str++) { @@ -2246,7 +2256,7 @@ static X509_REQ * php_openssl_csr_from_zval(zval ** val, int makeresource, long X509_REQ * csr = NULL; char * filename = NULL; BIO * in; - + if (resourceval) { *resourceval = -1; } @@ -2387,13 +2397,13 @@ PHP_FUNCTION(openssl_csr_sign) long csr_resource, certresource = 0, keyresource = -1; int i; struct php_x509_request req; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ!Zl|a!l", &zcsr, &zcert, &zpkey, &num_days, &args, &serial) == FAILURE) return; RETVAL_FALSE; PHP_SSL_REQ_INIT(&req); - + csr = php_openssl_csr_from_zval(zcsr, 0, &csr_resource TSRMLS_CC); if (csr == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get CSR from parameter 1"); @@ -2415,7 +2425,7 @@ PHP_FUNCTION(openssl_csr_sign) php_error_docref(NULL TSRMLS_CC, E_WARNING, "private key does not correspond to signing cert"); goto cleanup; } - + if (PHP_SSL_REQ_PARSE(&req, args) == FAILURE) { goto cleanup; } @@ -2435,9 +2445,9 @@ PHP_FUNCTION(openssl_csr_sign) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Signature did not match the certificate request"); goto cleanup; } - + /* Now we can get on with it */ - + new_cert = X509_new(); if (new_cert == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "No memory"); @@ -2448,7 +2458,7 @@ PHP_FUNCTION(openssl_csr_sign) goto cleanup; ASN1_INTEGER_set(X509_get_serialNumber(new_cert), serial); - + X509_set_subject_name(new_cert, X509_REQ_get_subject_name(csr)); if (cert == NULL) { @@ -2465,7 +2475,7 @@ PHP_FUNCTION(openssl_csr_sign) } if (req.extensions_section) { X509V3_CTX ctx; - + X509V3_set_ctx(&ctx, cert, new_cert, csr, NULL, 0); X509V3_set_conf_lhash(&ctx, req.req_config); if (!X509V3_EXT_add_conf(req.req_config, &ctx, req.extensions_section, new_cert)) { @@ -2478,11 +2488,11 @@ PHP_FUNCTION(openssl_csr_sign) php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to sign it"); goto cleanup; } - + /* Succeeded; lets return the cert */ RETVAL_RESOURCE(zend_list_insert(new_cert, le_x509 TSRMLS_CC)); new_cert = NULL; - + cleanup: if (cert == new_cert) { @@ -2499,7 +2509,7 @@ PHP_FUNCTION(openssl_csr_sign) if (csr_resource == -1 && csr) { X509_REQ_free(csr); } - if (certresource == -1 && cert) { + if (certresource == -1 && cert) { X509_free(cert); } if (new_cert) { @@ -2518,12 +2528,12 @@ PHP_FUNCTION(openssl_csr_new) X509_REQ * csr = NULL; int we_made_the_key = 1; long key_resource; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "az|a!a!", &dn, &out_pkey, &args, &attribs) == FAILURE) { return; } RETVAL_FALSE; - + PHP_SSL_REQ_INIT(&req); if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { @@ -2555,10 +2565,10 @@ PHP_FUNCTION(openssl_csr_new) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error loading extension section %s", req.request_extensions_section); } else { RETVAL_TRUE; - + if (X509_REQ_sign(csr, req.priv_key, req.digest)) { RETVAL_RESOURCE(zend_list_insert(csr, le_csr TSRMLS_CC)); - csr = NULL; + csr = NULL; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error signing request"); } @@ -2683,14 +2693,14 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval ** val, int public_key, char * } if (Z_TYPE_PP(val) == IS_ARRAY) { zval ** zphrase; - + /* get passphrase */ if (zend_hash_index_find(HASH_OF(*val), 1, (void **)&zphrase) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "key array must be of the form array(0 => key, 1 => phrase)"); return NULL; } - + if (Z_TYPE_PP(zphrase) == IS_STRING) { passphrase = Z_STRVAL_PP(zphrase); } else { @@ -2715,7 +2725,7 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval ** val, int public_key, char * if (!what) { TMP_CLEAN; } - if (resourceval) { + if (resourceval) { *resourceval = Z_LVAL_PP(val); } if (type == le_x509) { @@ -2749,8 +2759,8 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval ** val, int public_key, char * } } else { /* force it to be a string and check if it refers to a file */ - /* passing non string values leaks, object uses toString, it returns NULL - * See bug38255.phpt + /* passing non string values leaks, object uses toString, it returns NULL + * See bug38255.phpt */ if (!(Z_TYPE_PP(val) == IS_STRING || Z_TYPE_PP(val) == IS_OBJECT)) { TMP_CLEAN; @@ -2824,7 +2834,7 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req char * randfile = NULL; int egdsocket, seeded; EVP_PKEY * return_val = NULL; - + if (req->priv_key_bits < MIN_KEY_LENGTH) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "private key length is too short; it needs to be at least %d bits, not %d", MIN_KEY_LENGTH, req->priv_key_bits); @@ -2833,7 +2843,7 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req randfile = CONF_get_string(req->req_config, req->section_name, "RANDFILE"); php_openssl_load_rand_file(randfile, &egdsocket, &seeded TSRMLS_CC); - + if ((req->priv_key = EVP_PKEY_new()) != NULL) { switch(req->priv_key_type) { case OPENSSL_KEYTYPE_RSA: @@ -2883,13 +2893,13 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req } php_openssl_write_rand_file(randfile, egdsocket, seeded); - + if (return_val == NULL) { EVP_PKEY_free(req->priv_key); req->priv_key = NULL; return NULL; } - + return return_val; } /* }}} */ @@ -2918,7 +2928,7 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey TSRMLS_DC) case EVP_PKEY_DSA4: assert(pkey->pkey.dsa != NULL); - if (NULL == pkey->pkey.dsa->p || NULL == pkey->pkey.dsa->q || NULL == pkey->pkey.dsa->priv_key){ + if (NULL == pkey->pkey.dsa->p || NULL == pkey->pkey.dsa->q || NULL == pkey->pkey.dsa->priv_key){ return 0; } break; @@ -3049,7 +3059,7 @@ PHP_FUNCTION(openssl_pkey_new) } RETURN_FALSE; } - } + } PHP_SSL_REQ_INIT(&req); @@ -3078,7 +3088,7 @@ PHP_FUNCTION(openssl_pkey_export_to_file) EVP_PKEY * key; BIO * bio_out = NULL; const EVP_CIPHER * cipher; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zp|s!a!", &zpkey, &filename, &filename_len, &passphrase, &passphrase_len, &args) == FAILURE) { return; } @@ -3090,11 +3100,11 @@ PHP_FUNCTION(openssl_pkey_export_to_file) php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get key from parameter 1"); RETURN_FALSE; } - + if (php_openssl_open_base_dir_chk(filename TSRMLS_CC)) { RETURN_FALSE; } - + PHP_SSL_REQ_INIT(&req); if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { @@ -3137,7 +3147,7 @@ PHP_FUNCTION(openssl_pkey_export) EVP_PKEY * key; BIO * bio_out = NULL; const EVP_CIPHER * cipher; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zz|s!a!", &zpkey, &out, &passphrase, &passphrase_len, &args) == FAILURE) { return; } @@ -3149,7 +3159,7 @@ PHP_FUNCTION(openssl_pkey_export) php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get key from parameter 1"); RETURN_FALSE; } - + PHP_SSL_REQ_INIT(&req); if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { @@ -3269,7 +3279,7 @@ PHP_FUNCTION(openssl_pkey_get_details) array_init(return_value); add_assoc_long(return_value, "bits", EVP_PKEY_bits(pkey)); add_assoc_stringl(return_value, "key", pbio, pbio_len, 1); - /*TODO: Use the real values once the openssl constants are used + /*TODO: Use the real values once the openssl constants are used * See the enum at the top of this file */ switch (EVP_PKEY_type(pkey->type)) { @@ -3293,7 +3303,7 @@ PHP_FUNCTION(openssl_pkey_get_details) add_assoc_zval(return_value, "rsa", rsa); } - break; + break; case EVP_PKEY_DSA: case EVP_PKEY_DSA2: case EVP_PKEY_DSA3: @@ -3314,7 +3324,7 @@ PHP_FUNCTION(openssl_pkey_get_details) } break; case EVP_PKEY_DH: - + ktype = OPENSSL_KEYTYPE_DH; if (pkey->pkey.dh != NULL) { @@ -3330,7 +3340,7 @@ PHP_FUNCTION(openssl_pkey_get_details) } break; -#ifdef EVP_PKEY_EC +#ifdef EVP_PKEY_EC case EVP_PKEY_EC: ktype = OPENSSL_KEYTYPE_EC; break; @@ -3347,6 +3357,57 @@ PHP_FUNCTION(openssl_pkey_get_details) /* }}} */ +#if OPENSSL_VERSION_NUMBER >= 0x10000000L + +/* {{{ proto string openssl_pbkdf2(string password, string salt, long key_length, long iterations [, string digest_method = "sha1"]) + Generates a PKCS5 v2 PBKDF2 string, defaults to sha1 */ +PHP_FUNCTION(openssl_pbkdf2) +{ + long key_length = 0, iterations = 0; + char *password; int password_len; + char *salt; int salt_len; + char *method; int method_len = 0; + unsigned char *out_buffer; + + const EVP_MD *digest; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssll|s", + &password, &password_len, + &salt, &salt_len, + &key_length, &iterations, + &method, &method_len) == FAILURE) { + return; + } + + if (key_length <= 0) { + RETURN_FALSE; + } + + if (method_len) { + digest = EVP_get_digestbyname(method); + } else { + digest = EVP_sha1(); + } + + if (!digest) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown signature algorithm"); + RETURN_FALSE; + } + + out_buffer = emalloc(key_length + 1); + out_buffer[key_length] = '\0'; + + if (PKCS5_PBKDF2_HMAC(password, password_len, (unsigned char *)salt, salt_len, iterations, digest, key_length, out_buffer) == 1) { + RETVAL_STRINGL((char *)out_buffer, key_length, 0); + } else { + efree(out_buffer); + RETURN_FALSE; + } +} +/* }}} */ + +#endif + /* {{{ PKCS7 S/MIME functions */ /* {{{ proto bool openssl_pkcs7_verify(string filename, long flags [, string signerscerts [, array cainfo [, string extracerts [, string content]]]]) @@ -3364,7 +3425,7 @@ PHP_FUNCTION(openssl_pkcs7_verify) char * extracerts = NULL; int extracerts_len = 0; char * signersfilename = NULL; int signersfilename_len = 0; char * datafilename = NULL; int datafilename_len = 0; - + RETVAL_LONG(-1); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pl|papp", &filename, &filename_len, @@ -3372,7 +3433,7 @@ PHP_FUNCTION(openssl_pkcs7_verify) &extracerts, &extracerts_len, &datafilename, &datafilename_len) == FAILURE) { return; } - + if (extracerts) { others = load_all_certs_from_file(extracerts); if (others == NULL) { @@ -3424,11 +3485,11 @@ PHP_FUNCTION(openssl_pkcs7_verify) if (signersfilename) { BIO *certout; - + if (php_openssl_open_base_dir_chk(signersfilename TSRMLS_CC)) { goto clean_exit; } - + certout = BIO_new_file(signersfilename, "w"); if (certout) { int i; @@ -3477,14 +3538,14 @@ PHP_FUNCTION(openssl_pkcs7_encrypt) char * strindex; char * infilename = NULL; int infilename_len; char * outfilename = NULL; int outfilename_len; - + RETVAL_FALSE; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ppZa!|ll", &infilename, &infilename_len, &outfilename, &outfilename_len, &zrecipcerts, &zheaders, &flags, &cipherid) == FAILURE) return; - + if (php_openssl_open_base_dir_chk(infilename TSRMLS_CC) || php_openssl_open_base_dir_chk(outfilename TSRMLS_CC)) { return; } @@ -3495,7 +3556,7 @@ PHP_FUNCTION(openssl_pkcs7_encrypt) } outfile = BIO_new_file(outfilename, "w"); - if (outfile == NULL) { + if (outfile == NULL) { goto clean_exit; } @@ -3622,12 +3683,12 @@ PHP_FUNCTION(openssl_pkcs7_sign) &extracertsfilename_len) == FAILURE) { return; } - + RETVAL_FALSE; if (extracertsfilename) { others = load_all_certs_from_file(extracertsfilename); - if (others == NULL) { + if (others == NULL) { goto clean_exit; } } @@ -3738,7 +3799,7 @@ PHP_FUNCTION(openssl_pkcs7_decrypt) php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to get private key"); goto clean_exit; } - + if (php_openssl_open_base_dir_chk(infilename TSRMLS_CC) || php_openssl_open_base_dir_chk(outfilename TSRMLS_CC)) { goto clean_exit; } @@ -3757,7 +3818,7 @@ PHP_FUNCTION(openssl_pkcs7_decrypt) if (p7 == NULL) { goto clean_exit; } - if (PKCS7_decrypt(p7, key, cert, out, PKCS7_DETACHED)) { + if (PKCS7_decrypt(p7, key, cert, out, PKCS7_DETACHED)) { RETVAL_TRUE; } clean_exit: @@ -3790,7 +3851,7 @@ PHP_FUNCTION(openssl_private_encrypt) int data_len; long padding = RSA_PKCS1_PADDING; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szZ|l", &data, &data_len, &crypted, &key, &padding) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szZ|l", &data, &data_len, &crypted, &key, &padding) == FAILURE) { return; } RETVAL_FALSE; @@ -3808,10 +3869,10 @@ PHP_FUNCTION(openssl_private_encrypt) switch (pkey->type) { case EVP_PKEY_RSA: case EVP_PKEY_RSA2: - successful = (RSA_private_encrypt(data_len, - (unsigned char *)data, - cryptedbuf, - pkey->pkey.rsa, + successful = (RSA_private_encrypt(data_len, + (unsigned char *)data, + cryptedbuf, + pkey->pkey.rsa, padding) == cryptedlen); break; default: @@ -3828,7 +3889,7 @@ PHP_FUNCTION(openssl_private_encrypt) if (cryptedbuf) { efree(cryptedbuf); } - if (keyresource == -1) { + if (keyresource == -1) { EVP_PKEY_free(pkey); } } @@ -3866,10 +3927,10 @@ PHP_FUNCTION(openssl_private_decrypt) switch (pkey->type) { case EVP_PKEY_RSA: case EVP_PKEY_RSA2: - cryptedlen = RSA_private_decrypt(data_len, - (unsigned char *)data, - crypttemp, - pkey->pkey.rsa, + cryptedlen = RSA_private_decrypt(data_len, + (unsigned char *)data, + crypttemp, + pkey->pkey.rsa, padding); if (cryptedlen != -1) { cryptedbuf = emalloc(cryptedlen + 1); @@ -3894,7 +3955,7 @@ PHP_FUNCTION(openssl_private_decrypt) if (keyresource == -1) { EVP_PKEY_free(pkey); } - if (cryptedbuf) { + if (cryptedbuf) { efree(cryptedbuf); } } @@ -3918,7 +3979,7 @@ PHP_FUNCTION(openssl_public_encrypt) return; RETVAL_FALSE; - + pkey = php_openssl_evp_from_zval(key, 1, NULL, 0, &keyresource TSRMLS_CC); if (pkey == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "key parameter is not a valid public key"); @@ -3931,10 +3992,10 @@ PHP_FUNCTION(openssl_public_encrypt) switch (pkey->type) { case EVP_PKEY_RSA: case EVP_PKEY_RSA2: - successful = (RSA_public_encrypt(data_len, - (unsigned char *)data, - cryptedbuf, - pkey->pkey.rsa, + successful = (RSA_public_encrypt(data_len, + (unsigned char *)data, + cryptedbuf, + pkey->pkey.rsa, padding) == cryptedlen); break; default: @@ -3977,7 +4038,7 @@ PHP_FUNCTION(openssl_public_decrypt) return; } RETVAL_FALSE; - + pkey = php_openssl_evp_from_zval(key, 1, NULL, 0, &keyresource TSRMLS_CC); if (pkey == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "key parameter is not a valid public key"); @@ -3990,10 +4051,10 @@ PHP_FUNCTION(openssl_public_decrypt) switch (pkey->type) { case EVP_PKEY_RSA: case EVP_PKEY_RSA2: - cryptedlen = RSA_public_decrypt(data_len, - (unsigned char *)data, - crypttemp, - pkey->pkey.rsa, + cryptedlen = RSA_public_decrypt(data_len, + (unsigned char *)data, + crypttemp, + pkey->pkey.rsa, padding); if (cryptedlen != -1) { cryptedbuf = emalloc(cryptedlen + 1); @@ -4001,10 +4062,10 @@ PHP_FUNCTION(openssl_public_decrypt) successful = 1; } break; - + default: php_error_docref(NULL TSRMLS_CC, E_WARNING, "key type not supported in this PHP build!"); - + } efree(crypttemp); @@ -4122,7 +4183,7 @@ PHP_FUNCTION(openssl_verify) char * signature; int signature_len; zval *method = NULL; long signature_algo = OPENSSL_ALGO_SHA1; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssZ|z", &data, &data_len, &signature, &signature_len, &key, &method) == FAILURE) { return; } @@ -4181,7 +4242,7 @@ PHP_FUNCTION(openssl_seal) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szza/|s", &data, &data_len, &sealdata, &ekeys, &pubkeys, &method, &method_len) == FAILURE) { return; } - + pubkeysht = HASH_OF(pubkeys); nkeys = pubkeysht ? zend_hash_num_elements(pubkeysht) : 0; if (!nkeys) { @@ -4276,7 +4337,7 @@ PHP_FUNCTION(openssl_seal) if (key_resources[i] == -1) { EVP_PKEY_free(pkeys[i]); } - if (eks[i]) { + if (eks[i]) { efree(eks[i]); } } @@ -4322,13 +4383,13 @@ PHP_FUNCTION(openssl_open) } else { cipher = EVP_rc4(); } - + buf = emalloc(data_len + 1); if (EVP_OpenInit(&ctx, cipher, (unsigned char *)ekey, ekey_len, NULL, pkey) && EVP_OpenUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len)) { if (!EVP_OpenFinal(&ctx, buf + len1, &len2) || (len1 + len2 == 0)) { efree(buf); - if (keyresource == -1) { + if (keyresource == -1) { EVP_PKEY_free(pkey); } RETURN_FALSE; @@ -4565,7 +4626,7 @@ SSL *php_SSL_new_from_context(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{ if (SSL_CTX_use_PrivateKey_file(ctx, resolved_path_buff, SSL_FILETYPE_PEM) != 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set private key file `%s'", resolved_path_buff); return NULL; - } + } } tmpssl = SSL_new(ctx); @@ -4622,7 +4683,7 @@ PHP_FUNCTION(openssl_get_md_methods) } array_init(return_value); OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH, - aliases ? openssl_add_method_or_alias: openssl_add_method, + aliases ? openssl_add_method_or_alias: openssl_add_method, return_value); } /* }}} */ @@ -4638,7 +4699,7 @@ PHP_FUNCTION(openssl_get_cipher_methods) } array_init(return_value); OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, - aliases ? openssl_add_method_or_alias: openssl_add_method, + aliases ? openssl_add_method_or_alias: openssl_add_method, return_value); } /* }}} */ @@ -4977,7 +5038,7 @@ PHP_FUNCTION(openssl_random_pseudo_bytes) #ifdef PHP_WIN32 strong_result = 1; /* random/urandom equivalent on Windows */ - if (php_win32_get_random_bytes(buffer, (size_t) buffer_length) == FAILURE) { + if (php_win32_get_random_bytes(buffer, (size_t) buffer_length) == FAILURE){ efree(buffer); if (zstrong_result_returned) { ZVAL_BOOL(zstrong_result_returned, 0); diff --git a/ext/openssl/php_openssl.h b/ext/openssl/php_openssl.h index 427a643bf94b8..e6b064a277e68 100644 --- a/ext/openssl/php_openssl.h +++ b/ext/openssl/php_openssl.h @@ -52,6 +52,8 @@ PHP_FUNCTION(openssl_private_decrypt); PHP_FUNCTION(openssl_public_encrypt); PHP_FUNCTION(openssl_public_decrypt); +PHP_FUNCTION(openssl_pbkdf2); + PHP_FUNCTION(openssl_pkcs7_verify); PHP_FUNCTION(openssl_pkcs7_decrypt); PHP_FUNCTION(openssl_pkcs7_sign); diff --git a/ext/openssl/tests/openssl_pbkdf2.phpt b/ext/openssl/tests/openssl_pbkdf2.phpt new file mode 100644 index 0000000000000..3ec4dce23636c --- /dev/null +++ b/ext/openssl/tests/openssl_pbkdf2.phpt @@ -0,0 +1,26 @@ +--TEST-- +openssl_pbkdf2() tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(40) "0c60c80f961f0e71f3a9b524af6012062fe037a6" +string(40) "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957" +string(40) "4b007901b765489abead49d926f721d065a429c1" +string(50) "3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038" +string(32) "56fa6aa75548099dcc37d7f03425e0c3" diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 0e1523853a50c..ff8a22e14f9b1 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -422,8 +422,8 @@ static inline int php_openssl_setup_crypto(php_stream *stream, if (cparam->inputs.session) { if (cparam->inputs.session->ops != &php_openssl_socket_ops) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "supplied session stream must be an SSL enabled stream"); - } else if (((php_openssl_netstream_data_t*)cparam->inputs.session->abstract)->ssl_handle == NULL) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "supplied SSL session stream is not initialized"); + } else if (((php_openssl_netstream_data_t*)cparam->inputs.session->abstract)->ssl_handle == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "supplied SSL session stream is not initialized"); } else { SSL_copy_session_id(sslsock->ssl_handle, ((php_openssl_netstream_data_t*)cparam->inputs.session->abstract)->ssl_handle); } diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 47d58f51e179d..abe6b64aca528 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -868,7 +868,7 @@ PHP_FUNCTION(pcntl_signal) } /* Special long value case for SIG_DFL and SIG_IGN */ - if (Z_TYPE_P(handle)==IS_LONG) { + if (Z_TYPE_P(handle) == IS_LONG) { if (Z_LVAL_P(handle) != (long) SIG_DFL && Z_LVAL_P(handle) != (long) SIG_IGN) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for handle argument specified"); RETURN_FALSE; diff --git a/ext/pcntl/php_signal.c b/ext/pcntl/php_signal.c index 7e123a1ac6fc6..abdee832235c9 100644 --- a/ext/pcntl/php_signal.c +++ b/ext/pcntl/php_signal.c @@ -32,7 +32,6 @@ Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all) TSRMLS_FETCH(); #endif act.sa_handler = func; - if (mask_all) { sigfillset(&act.sa_mask); } else { @@ -56,7 +55,7 @@ Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all) { return SIG_ERR; } - + return oact.sa_handler; } diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index b74b81276c2c7..2ca0d5e168d92 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1045,6 +1045,10 @@ PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int sub replace_end = replace + replace_len; } + if (eval) { + php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The /e modifier is deprecated, use preg_replace_callback instead"); + } + /* Calculate the size of the offsets array, and allocate memory for it. */ rc = pcre_fullinfo(pce->re, extra, PCRE_INFO_CAPTURECOUNT, &num_subpats); if (rc < 0) { diff --git a/ext/pcre/tests/002.phpt b/ext/pcre/tests/002.phpt index 00f68f365104c..fd245633d3487 100644 --- a/ext/pcre/tests/002.phpt +++ b/ext/pcre/tests/002.phpt @@ -34,6 +34,8 @@ string(12) "a${1b${1c${1" Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 8 in %s002.php on line 11 NULL +Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in %s on line 12 + Parse error: %s in %s002.php(12) : regexp code on line 1 Fatal error: preg_replace(): Failed evaluating code: diff --git a/ext/pcre/tests/004.phpt b/ext/pcre/tests/004.phpt index b1e95866268a3..1fae406b16b31 100644 --- a/ext/pcre/tests/004.phpt +++ b/ext/pcre/tests/004.phpt @@ -16,7 +16,7 @@ var_dump(preg_replace(array('@//.*@S', '@/\*.*\*/@SsUe'), array('', 'preg_replac var_dump(preg_split('/PHP_(?:NAMED_)?(?:FUNCTION|METHOD)\s*\((\w+(?:,\s*\w+)?)\)/S', "PHP_FUNCTION(s, preg_match)\n{\nlalala", -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE)); ?> ---EXPECT-- +--EXPECTF-- int(2) array(2) { [0]=> @@ -117,6 +117,8 @@ array(1) { } } } + +Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in %s on line %d string(9) "hello diff --git a/ext/pdo/Makefile.frag b/ext/pdo/Makefile.frag index 98f5c5f2ad7dd..5ba5f80840ec6 100644 --- a/ext/pdo/Makefile.frag +++ b/ext/pdo/Makefile.frag @@ -6,7 +6,7 @@ PDO_HEADER_FILES= \ $(srcdir)/pdo_sql_parser.c: $(srcdir)/pdo_sql_parser.re - (cd $(top_srcdir); $(RE2C) -o ext/pdo/pdo_sql_parser.c ext/pdo/pdo_sql_parser.re) + (cd $(top_srcdir); $(RE2C) --no-generation-date -o ext/pdo/pdo_sql_parser.c ext/pdo/pdo_sql_parser.re) install-pdo-headers: @echo "Installing PDO headers: $(INSTALL_ROOT)$(phpincludedir)/ext/pdo/" diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c index 4219762a4b53c..ec488e053f021 100644 --- a/ext/pdo/pdo_sql_parser.c +++ b/ext/pdo/pdo_sql_parser.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Thu Apr 19 12:42:11 2012 */ +/* Generated by re2c 0.13.5 */ #line 1 "ext/pdo/pdo_sql_parser.re" /* +----------------------------------------------------------------------+ diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index a469d09fc2e34..5dc445ff8deb5 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2733,6 +2733,7 @@ static union _zend_function *row_get_ctor(zval *object TSRMLS_DC) ctor.function_name = "__construct"; ctor.scope = pdo_row_ce; ctor.handler = ZEND_FN(dbstmt_constructor); + ctor.fn_flags = ZEND_ACC_PUBLIC; return (union _zend_function*)&ctor; } diff --git a/ext/pdo/php_pdo_int.h b/ext/pdo/php_pdo_int.h index 57c683ab0fce0..91d0bf0412f77 100644 --- a/ext/pdo/php_pdo_int.h +++ b/ext/pdo/php_pdo_int.h @@ -58,7 +58,7 @@ extern pdo_driver_t *pdo_find_driver(const char *name, int namelen); extern void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC); #define PDO_DBH_CLEAR_ERR() do { \ - strncpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \ + strlcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \ if (dbh->query_stmt) { \ dbh->query_stmt = NULL; \ zend_objects_store_del_ref(&dbh->query_stmt_zval TSRMLS_CC); \ diff --git a/ext/pdo/tests/pdo_036.phpt b/ext/pdo/tests/pdo_036.phpt index 94006c9e808b6..55c88762ba3ea 100644 --- a/ext/pdo/tests/pdo_036.phpt +++ b/ext/pdo/tests/pdo_036.phpt @@ -5,19 +5,19 @@ Testing PDORow and PDOStatement instances with Reflection --FILE-- newInstance(); var_dump($x); -$instance = new reflectionclass('pdostatement'); +$instance = new reflectionclass('pdorow'); $x = $instance->newInstance(); var_dump($x); ?> --EXPECTF-- -object(PDORow)#%d (0) { -} object(PDOStatement)#%d (1) { [%u|b%"queryString"]=> NULL } + +Fatal error: PDORow::__construct(): You should not create a PDOStatement manually in %spdo_036.php on line %d diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index a703f93e7cf01..54c2e8dd84870 100644 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -709,6 +709,20 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ efree(ssl_cipher); } } + +#if MYSQL_VERSION_ID > 50605 || defined(MYSQLI_USE_MYSQLND) + { + char *public_key = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY, NULL TSRMLS_CC); + if (public_key) { + if (mysql_options(H->server, MYSQL_SERVER_PUBLIC_KEY, public_key)) { + pdo_mysql_error(dbh); + efree(public_key); + goto cleanup; + } + efree(public_key); + } + } +#endif } #ifdef PDO_MYSQL_HAS_CHARSET diff --git a/ext/pdo_mysql/pdo_mysql.c b/ext/pdo_mysql/pdo_mysql.c index 1dbb30f278924..ed51e947cd79b 100644 --- a/ext/pdo_mysql/pdo_mysql.c +++ b/ext/pdo_mysql/pdo_mysql.c @@ -118,6 +118,10 @@ static PHP_MINIT_FUNCTION(pdo_mysql) REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CA", (long)PDO_MYSQL_ATTR_SSL_CA); REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CAPATH", (long)PDO_MYSQL_ATTR_SSL_CAPATH); REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CIPHER", (long)PDO_MYSQL_ATTR_SSL_CIPHER); +#if MYSQL_VERSION_ID > 50605 || defined(MYSQLI_USE_MYSQLND) + REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SERVER_PUBLIC_KEY", (long)PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY); +#endif + #ifdef PDO_USE_MYSQLND mysqlnd_reverse_api_register_api(&pdo_mysql_reverse_api TSRMLS_CC); diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h index 65d7435a73a36..42debf07e9336 100644 --- a/ext/pdo_mysql/php_pdo_mysql_int.h +++ b/ext/pdo_mysql/php_pdo_mysql_int.h @@ -170,7 +170,10 @@ enum { PDO_MYSQL_ATTR_SSL_CERT, PDO_MYSQL_ATTR_SSL_CA, PDO_MYSQL_ATTR_SSL_CAPATH, - PDO_MYSQL_ATTR_SSL_CIPHER + PDO_MYSQL_ATTR_SSL_CIPHER, +#if MYSQL_VERSION_ID > 50605 || defined(MYSQLI_USE_MYSQLND) + PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY +#endif }; #endif diff --git a/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt b/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt index 17fa5d6059353..ee0f12358d0ba 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt @@ -3,6 +3,11 @@ PDO MySQL specific class constants --SKIPIF-- --FILE-- 50605) { + $expected['MYSQL_ATTR_SERVER_PUBLIC_KEY'] = true; + } + } else if (MySQLPDOTest::getClientVersion(MySQLPDOTest::factory()) > 50605) { + /* XXX the MySQL client library version isn't exposed with any + constants, the single possibility is to use the PDO::getAttribute(). + This however will fail with no connection. */ + $expected['MYSQL_ATTR_SERVER_PUBLIC_KEY'] = true; + } + /* TODO diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index d01dda6037f20..7ee838a9fa34d 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -1736,7 +1736,7 @@ PHP_FUNCTION(pg_query_params) } else { zval tmp_val = **tmp; zval_copy_ctor(&tmp_val); - convert_to_string(&tmp_val); + convert_to_cstring(&tmp_val); if (Z_TYPE(tmp_val) != IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter"); zval_dtor(&tmp_val); diff --git a/ext/pgsql/tests/bug46408.phpt b/ext/pgsql/tests/bug46408.phpt new file mode 100644 index 0000000000000..8c72ba5f3eb80 --- /dev/null +++ b/ext/pgsql/tests/bug46408.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #46408 (Locale number format settings can cause pg_query_params to break with numerics) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +3,5 +Done diff --git a/ext/phar/Makefile.frag b/ext/phar/Makefile.frag index b1c820f276faa..e2b016d846ffb 100644 --- a/ext/phar/Makefile.frag +++ b/ext/phar/Makefile.frag @@ -1,5 +1,5 @@ $(srcdir)/phar_path_check.c: $(srcdir)/phar_path_check.re - @(cd $(top_srcdir); $(RE2C) -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re) + @(cd $(top_srcdir); $(RE2C) --no-generation-date -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re) pharcmd: $(builddir)/phar.php $(builddir)/phar.phar diff --git a/ext/phar/phar_path_check.c b/ext/phar/phar_path_check.c index 8275c9c994c2a..d3a3aab6b946e 100644 --- a/ext/phar/phar_path_check.c +++ b/ext/phar/phar_path_check.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Fri Feb 25 04:35:39 2011 */ +/* Generated by re2c 0.13.5 */ #line 1 "ext/phar/phar_path_check.re" /* +----------------------------------------------------------------------+ diff --git a/ext/phar/tests/phar_commitwrite.phpt b/ext/phar/tests/phar_commitwrite.phpt index 8e366813380e1..36d473e5c21a1 100644 --- a/ext/phar/tests/phar_commitwrite.phpt +++ b/ext/phar/tests/phar_commitwrite.phpt @@ -39,4 +39,4 @@ Phar::mapPhar('brandnewphar.phar'); include 'phar://brandnewphar.phar/startup.php'; __HALT_COMPILER(); ?> " -===DONE=== +===DONE=== \ No newline at end of file diff --git a/ext/phar/tests/phar_create_in_cwd.phpt b/ext/phar/tests/phar_create_in_cwd.phpt index 1828fe745f872..4b0e6594fb14d 100644 --- a/ext/phar/tests/phar_create_in_cwd.phpt +++ b/ext/phar/tests/phar_create_in_cwd.phpt @@ -42,4 +42,4 @@ Phar::mapPhar('brandnewphar.phar'); include 'phar://brandnewphar.phar/startup.php'; __HALT_COMPILER(); ?> " -===DONE=== +===DONE=== \ No newline at end of file diff --git a/ext/phar/tests/phar_gobyebye.phpt b/ext/phar/tests/phar_gobyebye.phpt index 93e153bdf2c98..608e95076895f 100644 --- a/ext/phar/tests/phar_gobyebye.phpt +++ b/ext/phar/tests/phar_gobyebye.phpt @@ -44,4 +44,4 @@ bool(false) bool(false) Warning: opendir(foo/hi): failed to open dir: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d -===DONE=== +===DONE=== \ No newline at end of file diff --git a/ext/phar/tests/phar_mount.phpt b/ext/phar/tests/phar_mount.phpt index 73bd489a2ddbc..80f8cda38943e 100644 --- a/ext/phar/tests/phar_mount.phpt +++ b/ext/phar/tests/phar_mount.phpt @@ -60,4 +60,4 @@ Mounting of testit to %sphar_mount.php within phar %sphar_mount.phar.tar failed Mounting of /oops to /home/oops/../../etc/passwd: within phar %sphar_mount.phar.php failed get_constructor(return_value TSRMLS_CC); + EG(scope) = old_scope; + /* Run the constructor if there is one */ - if (ce->constructor) { + if (constructor) { zval ***params = NULL; int num_args = 0; zend_fcall_info fci; zend_fcall_info_cache fcc; - if (!(ce->constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { + if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name); - return; + zval_dtor(return_value); + RETURN_NULL(); } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "*", ¶ms, &num_args) == FAILURE) { if (params) { efree(params); } + zval_dtor(return_value); RETURN_FALSE; } - object_init_ex(return_value, ce); - fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = NULL; @@ -4221,7 +4237,7 @@ ZEND_METHOD(reflection_class, newInstance) fci.no_separation = 1; fcc.initialized = 1; - fcc.function_handler = ce->constructor; + fcc.function_handler = constructor; fcc.calling_scope = EG(scope); fcc.called_scope = Z_OBJCE_P(return_value); fcc.object_ptr = return_value; @@ -4234,6 +4250,7 @@ ZEND_METHOD(reflection_class, newInstance) zval_ptr_dtor(&retval_ptr); } php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invocation of %s's constructor failed", ce->name); + zval_dtor(return_value); RETURN_NULL(); } if (retval_ptr) { @@ -4242,9 +4259,7 @@ ZEND_METHOD(reflection_class, newInstance) if (params) { efree(params); } - } else if (!ZEND_NUM_ARGS()) { - object_init_ex(return_value, ce); - } else { + } else if (ZEND_NUM_ARGS()) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name); } } @@ -4274,9 +4289,10 @@ ZEND_METHOD(reflection_class, newInstanceArgs) { zval *retval_ptr = NULL; reflection_object *intern; - zend_class_entry *ce; + zend_class_entry *ce, *old_scope; int argc = 0; HashTable *args; + zend_function *constructor; METHOD_NOTSTATIC(reflection_class_ptr); @@ -4285,19 +4301,28 @@ ZEND_METHOD(reflection_class, newInstanceArgs) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|h", &args) == FAILURE) { return; } + if (ZEND_NUM_ARGS() > 0) { argc = args->nNumOfElements; } + object_init_ex(return_value, ce); + + old_scope = EG(scope); + EG(scope) = ce; + constructor = Z_OBJ_HT_P(return_value)->get_constructor(return_value TSRMLS_CC); + EG(scope) = old_scope; + /* Run the constructor if there is one */ - if (ce->constructor) { + if (constructor) { zval ***params = NULL; zend_fcall_info fci; zend_fcall_info_cache fcc; - if (!(ce->constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { + if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name); - return; + zval_dtor(return_value); + RETURN_NULL(); } if (argc) { @@ -4306,8 +4331,6 @@ ZEND_METHOD(reflection_class, newInstanceArgs) params -= argc; } - object_init_ex(return_value, ce); - fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = NULL; @@ -4319,7 +4342,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs) fci.no_separation = 1; fcc.initialized = 1; - fcc.function_handler = ce->constructor; + fcc.function_handler = constructor; fcc.calling_scope = EG(scope); fcc.called_scope = Z_OBJCE_P(return_value); fcc.object_ptr = return_value; @@ -4332,6 +4355,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs) zval_ptr_dtor(&retval_ptr); } php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invocation of %s's constructor failed", ce->name); + zval_dtor(return_value); RETURN_NULL(); } if (retval_ptr) { @@ -4340,9 +4364,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs) if (params) { efree(params); } - } else if (!ZEND_NUM_ARGS() || !argc) { - object_init_ex(return_value, ce); - } else { + } else if (argc) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name); } } @@ -5696,6 +5718,7 @@ static const zend_function_entry reflection_function_abstract_functions[] = { ZEND_ME(reflection_function, isDeprecated, arginfo_reflection__void, 0) ZEND_ME(reflection_function, isInternal, arginfo_reflection__void, 0) ZEND_ME(reflection_function, isUserDefined, arginfo_reflection__void, 0) + ZEND_ME(reflection_function, isGenerator, arginfo_reflection__void, 0) ZEND_ME(reflection_function, getClosureThis, arginfo_reflection__void, 0) ZEND_ME(reflection_function, getClosureScopeClass, arginfo_reflection__void, 0) ZEND_ME(reflection_function, getDocComment, arginfo_reflection__void, 0) diff --git a/ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt b/ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt new file mode 100644 index 0000000000000..c4889b12bc59a --- /dev/null +++ b/ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt @@ -0,0 +1,52 @@ +--TEST-- +ReflectionFunction::isGenerator() +--FILE-- +isGenerator()); + +$rf2 = new ReflectionFunction($closure2); +var_dump($rf2->isGenerator()); + +function func1() { + return 'func1'; +} + +function func2() { + yield 'func2'; +} + +$rf1 = new ReflectionFunction('func1'); +var_dump($rf1->isGenerator()); + +$rf2 = new ReflectionFunction('func2'); +var_dump($rf2->isGenerator()); + + +class Foo { + public function f1() { + } + + public function f2() { + yield; + } +} + +$rc = new ReflectionClass('Foo'); +foreach($rc->getMethods() as $m) { + var_dump($m->isGenerator()); +} +?> +--EXPECTF-- +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) diff --git a/ext/reflection/tests/bug64007.phpt b/ext/reflection/tests/bug64007.phpt new file mode 100644 index 0000000000000..32ec6a561078f --- /dev/null +++ b/ext/reflection/tests/bug64007.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #64007 (There is an ability to create instance of Generator by hand) +--FILE-- +newInstanceWithoutConstructor(); + var_dump($generator); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +$generator = $reflection->newInstance(); +var_dump($generator); +?> +--EXPECTF-- +string(97) "Class Generator is an internal class that cannot be instantiated without invoking its constructor" + +Catchable fatal error: The "Generator" class is reserved for internal use and cannot be manually instantiated in %sbug64007.php on line %d diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 1665ba53aa439..053c617dec232 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -266,7 +266,7 @@ PS_OPEN_FUNC(files) if (*save_path == '\0') { /* if save path is an empty string, determine the temporary dir */ - save_path = php_get_temporary_directory(); + save_path = php_get_temporary_directory(TSRMLS_C); if (php_check_open_basedir(save_path TSRMLS_CC)) { return FAILURE; diff --git a/ext/session/session.c b/ext/session/session.c index a3be9a78c2004..54bc6436adecb 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1154,6 +1154,7 @@ static int php_session_cache_limiter(TSRMLS_D) /* {{{ */ #define COOKIE_SET_COOKIE "Set-Cookie: " #define COOKIE_EXPIRES "; expires=" +#define COOKIE_MAX_AGE "; Max-Age=" #define COOKIE_PATH "; path=" #define COOKIE_DOMAIN "; domain=" #define COOKIE_SECURE "; secure" @@ -1201,6 +1202,9 @@ static void php_session_send_cookie(TSRMLS_D) /* {{{ */ smart_str_appends(&ncookie, COOKIE_EXPIRES); smart_str_appends(&ncookie, date_fmt); efree(date_fmt); + + smart_str_appends(&ncookie, COOKIE_MAX_AGE); + smart_str_append_long(&ncookie, PS(cookie_lifetime)); } } diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index a3bd44c27b6f1..6f2f070f21c1a 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -80,6 +80,14 @@ #include #include +#if PHP_VERSION_ID < 50300 +#define Z_ADDREF_P(pz) pz->refcount++ +#define Z_ISREF_PP(oid) (PZVAL_IS_REF(*(oid))) +#define Z_REFCOUNT_P(pz) pz->refcount +#define Z_SET_REFCOUNT_P(pz, rc) pz->refcount = rc +#define zend_parse_parameters_none() zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") +#endif + /* For net-snmp prior to 5.4 */ #ifndef HAVE_SHUTDOWN_SNMP_LOGGING extern netsnmp_log_handler *logh_head; @@ -489,6 +497,9 @@ static void php_snmp_object_free_storage(void *object TSRMLS_DC) static zend_object_value php_snmp_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { +#if PHP_VERSION_ID < 50399 + zval *tmp; +#endif zend_object_value retval; php_snmp_object *intern; @@ -497,7 +508,11 @@ static zend_object_value php_snmp_object_new(zend_class_entry *class_type TSRMLS memset(&intern->zo, 0, sizeof(php_snmp_object)); zend_object_std_init(&intern->zo, class_type TSRMLS_CC); +#if PHP_VERSION_ID < 50399 + zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *)); +#else object_properties_init(&intern->zo, class_type); +#endif retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) php_snmp_object_free_storage, NULL TSRMLS_CC); retval.handlers = (zend_object_handlers *) &php_snmp_object_handlers; @@ -1760,7 +1775,11 @@ PHP_FUNCTION(snmp_read_mib) char *filename; int filename_len; +#if PHP_VERSION_ID < 50399 + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { +#else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) { +#endif RETURN_FALSE; } @@ -1785,17 +1804,31 @@ PHP_METHOD(snmp, __construct) long retries = SNMP_DEFAULT_RETRIES; long version = SNMP_DEFAULT_VERSION; int argc = ZEND_NUM_ARGS(); +#if PHP_VERSION_ID > 50300 zend_error_handling error_handling; +#endif snmp_object = (php_snmp_object *)zend_object_store_get_object(object TSRMLS_CC); +#if PHP_VERSION_ID > 50300 zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); +#else + php_set_error_handling(EH_THROW, zend_exception_get_default(TSRMLS_C) TSRMLS_CC); +#endif if (zend_parse_parameters(argc TSRMLS_CC, "lss|ll", &version, &a1, &a1_len, &a2, &a2_len, &timeout, &retries) == FAILURE) { +#if PHP_VERSION_ID > 50300 zend_restore_error_handling(&error_handling TSRMLS_CC); +#else + php_std_error_handling(); +#endif return; } +#if PHP_VERSION_ID > 50300 zend_restore_error_handling(&error_handling TSRMLS_CC); +#else + php_std_error_handling(); +#endif switch(version) { case SNMP_VERSION_1: @@ -1943,7 +1976,11 @@ void php_snmp_add_property(HashTable *h, const char *name, size_t name_length, p /* {{{ php_snmp_read_property(zval *object, zval *member, int type[, const zend_literal *key]) Generic object property reader */ +#if PHP_VERSION_ID < 50399 +zval *php_snmp_read_property(zval *object, zval *member, int type TSRMLS_DC) +#else zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) +#endif { zval tmp_member; zval *retval; @@ -1973,7 +2010,11 @@ zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_li } } else { zend_object_handlers * std_hnd = zend_get_std_object_handlers(); +#if PHP_VERSION_ID < 50399 + retval = std_hnd->read_property(object, member, type TSRMLS_CC); +#else retval = std_hnd->read_property(object, member, type, key TSRMLS_CC); +#endif } if (member == &tmp_member) { @@ -1985,7 +2026,11 @@ zval *php_snmp_read_property(zval *object, zval *member, int type, const zend_li /* {{{ php_snmp_write_property(zval *object, zval *member, zval *value[, const zend_literal *key]) Generic object property writer */ +#if PHP_VERSION_ID < 50399 +void php_snmp_write_property(zval *object, zval *member, zval *value TSRMLS_DC) +#else void php_snmp_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) +#endif { zval tmp_member; php_snmp_object *obj; @@ -2012,7 +2057,11 @@ void php_snmp_write_property(zval *object, zval *member, zval *value, const zend } } else { zend_object_handlers * std_hnd = zend_get_std_object_handlers(); +#if PHP_VERSION_ID < 50399 + std_hnd->write_property(object, member, value TSRMLS_CC); +#else std_hnd->write_property(object, member, value, key TSRMLS_CC); +#endif } if (member == &tmp_member) { @@ -2023,7 +2072,11 @@ void php_snmp_write_property(zval *object, zval *member, zval *value, const zend /* {{{ php_snmp_has_property(zval *object, zval *member, int has_set_exists[, const zend_literal *key]) Generic object property checker */ +#if PHP_VERSION_ID < 50399 +static int php_snmp_has_property(zval *object, zval *member, int has_set_exists TSRMLS_DC) +#else static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, const zend_literal *key TSRMLS_DC) +#endif { php_snmp_prop_handler *hnd; int ret = 0; @@ -2034,7 +2087,11 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, ret = 1; break; case 0: { +#if PHP_VERSION_ID < 50399 + zval *value = php_snmp_read_property(object, member, BP_VAR_IS TSRMLS_CC); +#else zval *value = php_snmp_read_property(object, member, BP_VAR_IS, key TSRMLS_CC); +#endif if (value != EG(uninitialized_zval_ptr)) { ret = Z_TYPE_P(value) != IS_NULL? 1:0; /* refcount is 0 */ @@ -2044,7 +2101,11 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, break; } default: { +#if PHP_VERSION_ID < 50399 + zval *value = php_snmp_read_property(object, member, BP_VAR_IS TSRMLS_CC); +#else zval *value = php_snmp_read_property(object, member, BP_VAR_IS, key TSRMLS_CC); +#endif if (value != EG(uninitialized_zval_ptr)) { convert_to_boolean(value); ret = Z_BVAL_P(value)? 1:0; @@ -2057,7 +2118,11 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, } } else { zend_object_handlers * std_hnd = zend_get_std_object_handlers(); +#if PHP_VERSION_ID < 50399 + ret = std_hnd->has_property(object, member, has_set_exists TSRMLS_CC); +#else ret = std_hnd->has_property(object, member, has_set_exists, key TSRMLS_CC); +#endif } return ret; } @@ -2077,7 +2142,11 @@ static HashTable *php_snmp_get_properties(zval *object TSRMLS_DC) ulong num_key; obj = (php_snmp_object *)zend_objects_get_address(object TSRMLS_CC); +#if PHP_VERSION_ID < 50399 + props = obj->zo.properties; +#else props = zend_std_get_properties(object TSRMLS_CC); +#endif zend_hash_internal_pointer_reset_ex(&php_snmp_properties, &pos); @@ -2456,20 +2525,26 @@ PHP_MINFO_FUNCTION(snmp) /* {{{ snmp_module_deps[] */ +#if ZEND_MODULE_API_NO >= 20050922 static const zend_module_dep snmp_module_deps[] = { #ifdef HAVE_SPL ZEND_MOD_REQUIRED("spl") #endif ZEND_MOD_END }; +#endif /* }}} */ /* {{{ snmp_module_entry */ zend_module_entry snmp_module_entry = { +#if ZEND_MODULE_API_NO >= 20050922 STANDARD_MODULE_HEADER_EX, NULL, snmp_module_deps, +#else + STANDARD_MODULE_HEADER, +#endif "snmp", snmp_functions, PHP_MINIT(snmp), diff --git a/ext/soap/tests/bugs/bug47273.phpt b/ext/soap/tests/bugs/bug47273.phpt index 174948f59f988..1cfb0f3cd96a3 100644 --- a/ext/soap/tests/bugs/bug47273.phpt +++ b/ext/soap/tests/bugs/bug47273.phpt @@ -2,9 +2,6 @@ Bug #47273 (Encoding bug in SoapServer->fault) --SKIPIF-- ---INI-- -unicode.script_encoding=ISO-8859-1 -unicode.output_encoding=ISO-8859-1 --FILE-- +#include + +#ifndef PHP_WIN32 +# include +# include +# include +# include +# include +# include +# include +#else +# include +#endif + +#include +#include +#include + +#ifdef PHP_WIN32 +typedef unsigned short sa_family_t; +# define msghdr _WSAMSG +/* +struct _WSAMSG { + LPSOCKADDR name; //void *msg_name + INT namelen; //socklen_t msg_namelen + LPWSABUF lpBuffers; //struct iovec *msg_iov + ULONG dwBufferCount; //size_t msg_iovlen + WSABUF Control; //void *msg_control, size_t msg_controllen + DWORD dwFlags; //int msg_flags +} +struct __WSABUF { + u_long len; //size_t iov_len (2nd member) + char FAR *buf; //void *iov_base (1st member) +} +struct _WSACMSGHDR { + UINT cmsg_len; //socklen_t cmsg_len + INT cmsg_level; //int cmsg_level + INT cmsg_type; //int cmsg_type; + followed by UCHAR cmsg_data[] +} +*/ +# define msg_name name +# define msg_namelen namelen +# define msg_iov lpBuffers +# define msg_iovlen dwBufferCount +# define msg_control Control.buf +# define msg_controllen Control.len +# define msg_flags dwFlags +# define iov_base buf +# define iov_len len + +# define cmsghdr _WSACMSGHDR +# ifdef CMSG_DATA +# undef CMSG_DATA +# endif +# define CMSG_DATA WSA_CMSG_DATA +#endif + +#define MAX_USER_BUFF_SIZE ((size_t)(100*1024*1024)) +#define DEFAULT_BUFF_SIZE 8192 + +struct _ser_context { + HashTable params; /* stores pointers; has to be first */ + struct err_s err; + zend_llist keys, + /* common part to res_context ends here */ + allocations; + php_socket *sock; +}; +struct _res_context { + HashTable params; /* stores pointers; has to be first */ + struct err_s err; + zend_llist keys; +}; + +typedef struct { + /* zval info */ + const char *name; + unsigned name_size; + int required; + + /* structure info */ + size_t field_offset; /* 0 to pass full structure, e.g. when more than + one field is to be changed; in that case the + callbacks need to know the name of the fields */ + + /* callbacks */ + from_zval_write_field *from_zval; + to_zval_read_field *to_zval; +} field_descriptor; + +#define KEY_FILL_SOCKADDR "fill_sockaddr" +#define KEY_RECVMSG_RET "recvmsg_ret" +#define KEY_CMSG_LEN "cmsg_len" + +const struct key_value empty_key_value_list[] = {{0}}; + +/* PARAMETERS */ +static int param_get_bool(void *ctx, const char *key, int def) +{ + int **elem; + if (zend_hash_find(ctx, key, strlen(key) + 1, (void**)&elem) == SUCCESS) { + return **elem; + } else { + return def; + } +} + +/* MEMORY */ +static inline void *accounted_emalloc(size_t alloc_size, ser_context *ctx) +{ + void *ret = emalloc(alloc_size); + zend_llist_add_element(&ctx->allocations, &ret); + return ret; +} +static inline void *accounted_ecalloc(size_t nmemb, size_t alloc_size, ser_context *ctx) +{ + void *ret = ecalloc(nmemb, alloc_size); + zend_llist_add_element(&ctx->allocations, &ret); + return ret; +} +static inline void *accounted_safe_ecalloc(size_t nmemb, size_t alloc_size, size_t offset, ser_context *ctx) +{ + void *ret = safe_emalloc(nmemb, alloc_size, offset); + memset(ret, '\0', nmemb * alloc_size + offset); + zend_llist_add_element(&ctx->allocations, &ret); + return ret; +} + +/* ERRORS */ +static void do_from_to_zval_err(struct err_s *err, + zend_llist *keys, + const char *what_conv, + const char *fmt, + va_list ap) +{ + smart_str path = {0}; + const char **node; + char *user_msg; + int user_msg_size; + zend_llist_position pos; + + if (err->has_error) { + return; + } + + for (node = zend_llist_get_first_ex(keys, &pos); + node != NULL; + node = zend_llist_get_next_ex(keys, &pos)) { + smart_str_appends(&path, *node); + smart_str_appends(&path, " > "); + } + + if (path.len > 3) { + path.len -= 3; + } + smart_str_0(&path); + + user_msg_size = vspprintf(&user_msg, 0, fmt, ap); + + err->has_error = 1; + err->level = E_WARNING; + spprintf(&err->msg, 0, "error converting %s data (path: %s): %.*s", + what_conv, + path.c && path.c != '\0' ? path.c : "unavailable", + user_msg_size, user_msg); + err->should_free = 1; + + efree(user_msg); + smart_str_free_ex(&path, 0); +} +ZEND_ATTRIBUTE_FORMAT(printf, 2 ,3) +static void do_from_zval_err(ser_context *ctx, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + do_from_to_zval_err(&ctx->err, &ctx->keys, "user", fmt, ap); + va_end(ap); +} +ZEND_ATTRIBUTE_FORMAT(printf, 2 ,3) +static void do_to_zval_err(res_context *ctx, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + do_from_to_zval_err(&ctx->err, &ctx->keys, "native", fmt, ap); + va_end(ap); +} + +void err_msg_dispose(struct err_s *err TSRMLS_DC) +{ + if (err->msg != NULL) { + php_error_docref0(NULL TSRMLS_CC, err->level, "%s", err->msg); + if (err->should_free) { + efree(err->msg); + } + } +} +void allocations_dispose(zend_llist **allocations) +{ + zend_llist_destroy(*allocations); + efree(*allocations); + *allocations = NULL; +} + +static unsigned from_array_iterate(const zval *arr, + void (*func)(zval **elem, unsigned i, void **args, ser_context *ctx), + void **args, + ser_context *ctx) +{ + HashPosition pos; + unsigned i; + zval **elem; + char buf[sizeof("element #4294967295")]; + char *bufp = buf; + + for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos), i = 1; + !ctx->err.has_error + && zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **)&elem, &pos) == SUCCESS; + zend_hash_move_forward_ex(Z_ARRVAL_P(arr), &pos), i++) { + if (snprintf(buf, sizeof(buf), "element #%u", i) >= sizeof(buf)) { + memcpy(buf, "element", sizeof("element")); + } + zend_llist_add_element(&ctx->keys, &bufp); + + func(elem, i, args, ctx); + + zend_llist_remove_tail(&ctx->keys); + } + + return i -1; +} + +/* Generic Aggregated conversions */ +static void from_zval_write_aggregation(const zval *container, + char *structure, + const field_descriptor *descriptors, + ser_context *ctx) +{ + const field_descriptor *descr; + zval **elem; + + if (Z_TYPE_P(container) != IS_ARRAY) { + do_from_zval_err(ctx, "%s", "expected an array here"); + } + + for (descr = descriptors; descr->name != NULL && !ctx->err.has_error; descr++) { + if (zend_hash_find(Z_ARRVAL_P(container), + descr->name, descr->name_size, (void**)&elem) == SUCCESS) { + + if (descr->from_zval == NULL) { + do_from_zval_err(ctx, "No information on how to convert value " + "of key '%s'", descr->name); + break; + } + + zend_llist_add_element(&ctx->keys, (void*)&descr->name); + descr->from_zval(*elem, ((char*)structure) + descr->field_offset, ctx); + zend_llist_remove_tail(&ctx->keys); + + } else if (descr->required) { + do_from_zval_err(ctx, "The key '%s' is required", descr->name); + break; + } + } +} +static void to_zval_read_aggregation(const char *structure, + zval *zarr, /* initialized array */ + const field_descriptor *descriptors, + res_context *ctx) +{ + const field_descriptor *descr; + + assert(Z_TYPE_P(zarr) == IS_ARRAY); + assert(Z_ARRVAL_P(zarr) != NULL); + + for (descr = descriptors; descr->name != NULL && !ctx->err.has_error; descr++) { + zval *new_zv; + + if (descr->to_zval == NULL) { + do_to_zval_err(ctx, "No information on how to convert native " + "field into value for key '%s'", descr->name); + break; + } + + ALLOC_INIT_ZVAL(new_zv); + add_assoc_zval_ex(zarr, descr->name, descr->name_size, new_zv); + + zend_llist_add_element(&ctx->keys, (void*)&descr->name); + descr->to_zval(structure + descr->field_offset, new_zv, ctx); + zend_llist_remove_tail(&ctx->keys); + } +} + +/* CONVERSIONS for integers */ +static long from_zval_integer_common(const zval *arr_value, ser_context *ctx) +{ + long ret = 0; + zval lzval = zval_used_for_init; + + if (Z_TYPE_P(arr_value) != IS_LONG) { + ZVAL_COPY_VALUE(&lzval, arr_value); + zval_copy_ctor(&lzval); + arr_value = &lzval; + } + + switch (Z_TYPE_P(arr_value)) { + case IS_LONG: +long_case: + ret = Z_LVAL_P(arr_value); + break; + + /* if not long we're operating on lzval */ + case IS_DOUBLE: +double_case: + convert_to_long(&lzval); + goto long_case; + + case IS_OBJECT: + case IS_STRING: { + long lval; + double dval; + + convert_to_string(&lzval); + + switch (is_numeric_string(Z_STRVAL(lzval), Z_STRLEN(lzval), &lval, &dval, 0)) { + case IS_DOUBLE: + zval_dtor(&lzval); + Z_TYPE(lzval) = IS_DOUBLE; + Z_DVAL(lzval) = dval; + goto double_case; + + case IS_LONG: + zval_dtor(&lzval); + Z_TYPE(lzval) = IS_LONG; + Z_LVAL(lzval) = lval; + goto long_case; + } + + /* if we get here, we don't have a numeric string */ + do_from_zval_err(ctx, "expected an integer, but got a non numeric " + "string (possibly from a converted object): '%s'", Z_STRVAL_P(arr_value)); + break; + } + + default: + do_from_zval_err(ctx, "%s", "expected an integer, either of a PHP " + "integer type or of a convertible type"); + break; + } + + zval_dtor(&lzval); + + return ret; +} +void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx) +{ + long lval; + int ival; + + lval = from_zval_integer_common(arr_value, ctx); + if (ctx->err.has_error) { + return; + } + + if (lval > INT_MAX || lval < INT_MIN) { + do_from_zval_err(ctx, "%s", "given PHP integer is out of bounds " + "for a native int"); + return; + } + + ival = (int)lval; + memcpy(field, &ival, sizeof(ival)); +} +static void from_zval_write_uint32(const zval *arr_value, char *field, ser_context *ctx) +{ + long lval; + uint32_t ival; + + lval = from_zval_integer_common(arr_value, ctx); + if (ctx->err.has_error) { + return; + } + + if (sizeof(long) > sizeof(uint32_t) && (lval < 0 || lval > 0xFFFFFFFF)) { + do_from_zval_err(ctx, "%s", "given PHP integer is out of bounds " + "for an unsigned 32-bit integer"); + return; + } + + ival = (uint32_t)lval; + memcpy(field, &ival, sizeof(ival)); +} +static void from_zval_write_net_uint16(const zval *arr_value, char *field, ser_context *ctx) +{ + long lval; + uint16_t ival; + + lval = from_zval_integer_common(arr_value, ctx); + if (ctx->err.has_error) { + return; + } + + if (lval < 0 || lval > 0xFFFF) { + do_from_zval_err(ctx, "%s", "given PHP integer is out of bounds " + "for an unsigned 16-bit integer"); + return; + } + + ival = htons((uint16_t)lval); + memcpy(field, &ival, sizeof(ival)); +} +static void from_zval_write_sa_family(const zval *arr_value, char *field, ser_context *ctx) +{ + long lval; + sa_family_t ival; + + lval = from_zval_integer_common(arr_value, ctx); + if (ctx->err.has_error) { + return; + } + + if (lval < 0 || lval > (sa_family_t)-1) { /* sa_family_t is unsigned */ + do_from_zval_err(ctx, "%s", "given PHP integer is out of bounds " + "for a sa_family_t value"); + return; + } + + ival = (sa_family_t)lval; + memcpy(field, &ival, sizeof(ival)); +} +static void from_zval_write_pid_t(const zval *arr_value, char *field, ser_context *ctx) +{ + long lval; + pid_t ival; + + lval = from_zval_integer_common(arr_value, ctx); + if (ctx->err.has_error) { + return; + } + + if (lval < 0 || (pid_t)lval != lval) { /* pid_t is signed */ + do_from_zval_err(ctx, "%s", "given PHP integer is out of bounds " + "for a pid_t value"); + return; + } + + ival = (pid_t)lval; + memcpy(field, &ival, sizeof(ival)); +} +static void from_zval_write_uid_t(const zval *arr_value, char *field, ser_context *ctx) +{ + long lval; + uid_t ival; + + lval = from_zval_integer_common(arr_value, ctx); + if (ctx->err.has_error) { + return; + } + + /* uid_t can be signed or unsigned (generally unsigned) */ + if ((uid_t)-1 > (uid_t)0) { + if (sizeof(long) > sizeof(uid_t) && (lval < 0 || (uid_t)lval != lval)) { + do_from_zval_err(ctx, "%s", "given PHP integer is out of bounds " + "for a uid_t value"); + return; + } + } else { + if (sizeof(long) > sizeof(uid_t) && (uid_t)lval != lval) { + do_from_zval_err(ctx, "%s", "given PHP integer is out of bounds " + "for a uid_t value"); + return; + } + } + + ival = (uid_t)lval; + memcpy(field, &ival, sizeof(ival)); +} + +void to_zval_read_int(const char *data, zval *zv, res_context *ctx) +{ + int ival; + memcpy(&ival, data, sizeof(ival)); + + ZVAL_LONG(zv, (long)ival); +} +static void to_zval_read_unsigned(const char *data, zval *zv, res_context *ctx) +{ + unsigned ival; + memcpy(&ival, data, sizeof(ival)); + + ZVAL_LONG(zv, (long)ival); +} +static void to_zval_read_net_uint16(const char *data, zval *zv, res_context *ctx) +{ + uint16_t ival; + memcpy(&ival, data, sizeof(ival)); + + ZVAL_LONG(zv, (long)ntohs(ival)); +} +static void to_zval_read_uint32(const char *data, zval *zv, res_context *ctx) +{ + uint32_t ival; + memcpy(&ival, data, sizeof(ival)); + + ZVAL_LONG(zv, (long)ival); +} +static void to_zval_read_sa_family(const char *data, zval *zv, res_context *ctx) +{ + sa_family_t ival; + memcpy(&ival, data, sizeof(ival)); + + ZVAL_LONG(zv, (long)ival); +} +static void to_zval_read_pid_t(const char *data, zval *zv, res_context *ctx) +{ + pid_t ival; + memcpy(&ival, data, sizeof(ival)); + + ZVAL_LONG(zv, (long)ival); +} +static void to_zval_read_uid_t(const char *data, zval *zv, res_context *ctx) +{ + uid_t ival; + memcpy(&ival, data, sizeof(ival)); + + ZVAL_LONG(zv, (long)ival); +} + +/* CONVERSIONS for sockaddr */ +static void from_zval_write_sin_addr(const zval *zaddr_str, char *inaddr, ser_context *ctx) +{ + int res; + struct sockaddr_in saddr = {0}; + zval lzval = zval_used_for_init; + TSRMLS_FETCH(); + + if (Z_TYPE_P(zaddr_str) != IS_STRING) { + ZVAL_COPY_VALUE(&lzval, zaddr_str); + zval_copy_ctor(&lzval); + convert_to_string(&lzval); + zaddr_str = &lzval; + } + + res = php_set_inet_addr(&saddr, Z_STRVAL_P(zaddr_str), ctx->sock TSRMLS_CC); + if (res) { + memcpy(inaddr, &saddr.sin_addr, sizeof saddr.sin_addr); + } else { + /* error already emitted, but let's emit another more relevant */ + do_from_zval_err(ctx, "could not resolve address '%s' to get an AF_INET " + "address", Z_STRVAL_P(zaddr_str)); + } + + zval_dtor(&lzval); +} +static void to_zval_read_sin_addr(const char *data, zval *zv, res_context *ctx) +{ + const struct in_addr *addr = (const struct in_addr *)data; + socklen_t size = INET_ADDRSTRLEN; + + Z_TYPE_P(zv) = IS_STRING; + Z_STRVAL_P(zv) = ecalloc(1, size); + Z_STRLEN_P(zv) = 0; + + if (inet_ntop(AF_INET, addr, Z_STRVAL_P(zv), size) == NULL) { + do_to_zval_err(ctx, "could not convert IPv4 address to string " + "(errno %d)", errno); + return; + } + + Z_STRLEN_P(zv) = strlen(Z_STRVAL_P(zv)); +} +static const field_descriptor descriptors_sockaddr_in[] = { + {"family", sizeof("family"), 0, offsetof(struct sockaddr_in, sin_family), from_zval_write_sa_family, to_zval_read_sa_family}, + {"addr", sizeof("addr"), 0, offsetof(struct sockaddr_in, sin_addr), from_zval_write_sin_addr, to_zval_read_sin_addr}, + {"port", sizeof("port"), 0, offsetof(struct sockaddr_in, sin_port), from_zval_write_net_uint16, to_zval_read_net_uint16}, + {0} +}; +static void from_zval_write_sockaddr_in(const zval *container, char *sockaddr, ser_context *ctx) +{ + from_zval_write_aggregation(container, sockaddr, descriptors_sockaddr_in, ctx); +} +static void to_zval_read_sockaddr_in(const char *data, zval *zv, res_context *ctx) +{ + to_zval_read_aggregation(data, zv, descriptors_sockaddr_in, ctx); +} +static void from_zval_write_sin6_addr(const zval *zaddr_str, char *addr6, ser_context *ctx) +{ + int res; + struct sockaddr_in6 saddr6 = {0}; + zval lzval = zval_used_for_init; + TSRMLS_FETCH(); + + if (Z_TYPE_P(zaddr_str) != IS_STRING) { + ZVAL_COPY_VALUE(&lzval, zaddr_str); + zval_copy_ctor(&lzval); + convert_to_string(&lzval); + zaddr_str = &lzval; + } + + res = php_set_inet6_addr(&saddr6, + Z_STRVAL_P(zaddr_str), ctx->sock TSRMLS_CC); + if (res) { + memcpy(addr6, &saddr6.sin6_addr, sizeof saddr6.sin6_addr); + } else { + /* error already emitted, but let's emit another more relevant */ + do_from_zval_err(ctx, "could not resolve address '%s' to get an AF_INET6 " + "address", Z_STRVAL_P(zaddr_str)); + } + + zval_dtor(&lzval); +} +static void to_zval_read_sin6_addr(const char *data, zval *zv, res_context *ctx) +{ + const struct in6_addr *addr = (const struct in6_addr *)data; + socklen_t size = INET6_ADDRSTRLEN; + + Z_TYPE_P(zv) = IS_STRING; + Z_STRVAL_P(zv) = ecalloc(1, size); + Z_STRLEN_P(zv) = 0; + + if (inet_ntop(AF_INET6, addr, Z_STRVAL_P(zv), size) == NULL) { + do_to_zval_err(ctx, "could not convert IPv6 address to string " + "(errno %d)", errno); + return; + } + + Z_STRLEN_P(zv) = strlen(Z_STRVAL_P(zv)); +} +static const field_descriptor descriptors_sockaddr_in6[] = { + {"family", sizeof("family"), 0, offsetof(struct sockaddr_in6, sin6_family), from_zval_write_sa_family, to_zval_read_sa_family}, + {"addr", sizeof("addr"), 0, offsetof(struct sockaddr_in6, sin6_addr), from_zval_write_sin6_addr, to_zval_read_sin6_addr}, + {"port", sizeof("port"), 0, offsetof(struct sockaddr_in6, sin6_port), from_zval_write_net_uint16, to_zval_read_net_uint16}, + {"flowinfo", sizeof("flowinfo"), 0, offsetof(struct sockaddr_in6, sin6_flowinfo), from_zval_write_uint32, to_zval_read_uint32}, + {"scope_id", sizeof("scope_id"), 0, offsetof(struct sockaddr_in6, sin6_scope_id), from_zval_write_uint32, to_zval_read_uint32}, + {0} +}; +static void from_zval_write_sockaddr_in6(const zval *container, char *sockaddr6, ser_context *ctx) +{ + from_zval_write_aggregation(container, sockaddr6, descriptors_sockaddr_in6, ctx); +} +static void to_zval_read_sockaddr_in6(const char *data, zval *zv, res_context *ctx) +{ + to_zval_read_aggregation(data, zv, descriptors_sockaddr_in6, ctx); +} +static void from_zval_write_sun_path(const zval *path, char *sockaddr_un_c, ser_context *ctx) +{ + zval lzval = zval_used_for_init; + struct sockaddr_un *saddr = (struct sockaddr_un*)sockaddr_un_c; + + if (Z_TYPE_P(path) != IS_STRING) { + ZVAL_COPY_VALUE(&lzval, path); + zval_copy_ctor(&lzval); + convert_to_string(&lzval); + path = &lzval; + } + + if (Z_STRLEN_P(path) >= sizeof(saddr->sun_path)) { + do_from_zval_err(ctx, "the path is too long, the maximum permitted " + "length is %ld", sizeof(saddr->sun_path) - 1); + return; + } + + memcpy(&saddr->sun_path, Z_STRVAL_P(path), Z_STRLEN_P(path)); + saddr->sun_path[Z_STRLEN_P(path)] = '\0'; + + zval_dtor(&lzval); +} +static void to_zval_read_sun_path(const char *data, zval *zv, res_context *ctx) { + struct sockaddr_un *saddr = (struct sockaddr_un*)data; + char *nul_pos; + + nul_pos = memchr(&saddr->sun_path, '\0', sizeof(saddr->sun_path)); + if (nul_pos == NULL) { + do_to_zval_err(ctx, "could not find a NUL in the path"); + return; + } + + ZVAL_STRINGL(zv, saddr->sun_path, nul_pos - (char*)&saddr->sun_path, 1); +} +static const field_descriptor descriptors_sockaddr_un[] = { + {"family", sizeof("family"), 0, offsetof(struct sockaddr_un, sun_family), from_zval_write_sa_family, to_zval_read_sa_family}, + {"path", sizeof("path"), 0, 0, from_zval_write_sun_path, to_zval_read_sun_path}, + {0} +}; +static void from_zval_write_sockaddr_un(const zval *container, char *sockaddr, ser_context *ctx) +{ + from_zval_write_aggregation(container, sockaddr, descriptors_sockaddr_un, ctx); +} +static void to_zval_read_sockaddr_un(const char *data, zval *zv, res_context *ctx) +{ + to_zval_read_aggregation(data, zv, descriptors_sockaddr_un, ctx); +} +static void from_zval_write_sockaddr_aux(const zval *container, + struct sockaddr **sockaddr_ptr, + socklen_t *sockaddr_len, + ser_context *ctx) +{ + int family; + zval **elem; + int fill_sockaddr; + + if (Z_TYPE_P(container) != IS_ARRAY) { + do_from_zval_err(ctx, "%s", "expected an array here"); + return; + } + + fill_sockaddr = param_get_bool(ctx, KEY_FILL_SOCKADDR, 1); + + if (zend_hash_find(Z_ARRVAL_P(container), "family", sizeof("family"), (void**)&elem) == SUCCESS + && Z_TYPE_PP(elem) != IS_NULL) { + const char *node = "family"; + zend_llist_add_element(&ctx->keys, &node); + from_zval_write_int(*elem, (char*)&family, ctx); + zend_llist_remove_tail(&ctx->keys); + } else { + family = ctx->sock->type; + } + + switch (family) { + case AF_INET: + /* though not all OSes support sockaddr_in used in IPv6 sockets */ + if (ctx->sock->type != AF_INET && ctx->sock->type != AF_INET6) { + do_from_zval_err(ctx, "the specified family (number %d) is not " + "supported on this socket", family); + return; + } + *sockaddr_ptr = accounted_ecalloc(1, sizeof(struct sockaddr_in), ctx); + *sockaddr_len = sizeof(struct sockaddr_in); + if (fill_sockaddr) { + from_zval_write_sockaddr_in(container, (char*)*sockaddr_ptr, ctx); + (*sockaddr_ptr)->sa_family = AF_INET; + } + break; + + case AF_INET6: + if (ctx->sock->type != AF_INET6) { + do_from_zval_err(ctx, "the specified family (AF_INET6) is not " + "supported on this socket"); + return; + } + *sockaddr_ptr = accounted_ecalloc(1, sizeof(struct sockaddr_in6), ctx); + *sockaddr_len = sizeof(struct sockaddr_in6); + if (fill_sockaddr) { + from_zval_write_sockaddr_in6(container, (char*)*sockaddr_ptr, ctx); + (*sockaddr_ptr)->sa_family = AF_INET6; + } + break; + + case AF_UNIX: + if (ctx->sock->type != AF_UNIX) { + do_from_zval_err(ctx, "the specified family (AF_UNIX) is not " + "supported on this socket"); + return; + } + *sockaddr_ptr = accounted_ecalloc(1, sizeof(struct sockaddr_un), ctx); + *sockaddr_len = sizeof(struct sockaddr_un); + if (fill_sockaddr) { + from_zval_write_sockaddr_un(container, (char*)*sockaddr_ptr, ctx); + (*sockaddr_ptr)->sa_family = AF_UNIX; + } + break; + + default: + do_from_zval_err(ctx, "%s", "the only families currently supported are " + "AF_INET, AF_INET6 and AF_UNIX"); + break; + } +} +static void to_zval_read_sockaddr_aux(const char *sockaddr_c, zval *zv, res_context *ctx) +{ + const struct sockaddr *saddr = (struct sockaddr *)sockaddr_c; + + if (saddr->sa_family == 0) { + ZVAL_NULL(zv); + return; + } + + array_init(zv); + + switch (saddr->sa_family) { + case AF_INET: + to_zval_read_sockaddr_in(sockaddr_c, zv, ctx); + break; + + case AF_INET6: + to_zval_read_sockaddr_in6(sockaddr_c, zv, ctx); + break; + + case AF_UNIX: + to_zval_read_sockaddr_un(sockaddr_c, zv, ctx); + break; + + default: + do_to_zval_err(ctx, "cannot read struct sockaddr with family %d; " + "not supported", + (int)saddr->sa_family); + break; + } +} + +/* CONVERSIONS for cmsghdr */ +/* + * [ level => , type => , data => [],] + * struct cmsghdr { + * socklen_t cmsg_len; // data byte count, including header + * int cmsg_level; // originating protocol + * int cmsg_type; // protocol-specific type + * // followed by unsigned char cmsg_data[]; + * }; + */ +static void from_zval_write_control(const zval *arr, + void **control_buf, + zend_llist_element *alloc, + size_t *control_len, + size_t *offset, + ser_context *ctx) +{ + struct cmsghdr *cmsghdr; + int level, + type; + size_t data_len, + req_space, + space_left; + ancillary_reg_entry *entry; + + static const field_descriptor descriptor_level[] = { + {"level", sizeof("level"), 0, 0, from_zval_write_int, 0}, + {0} + }; + static const field_descriptor descriptor_type[] = { + {"type", sizeof("type"), 0, 0, from_zval_write_int, 0}, + {0} + }; + field_descriptor descriptor_data[] = { + {"data", sizeof("data"), 0, 0, 0, 0}, + {0} + }; + + from_zval_write_aggregation(arr, (char *)&level, descriptor_level, ctx); + if (ctx->err.has_error) { + return; + } + from_zval_write_aggregation(arr, (char *)&type, descriptor_type, ctx); + if (ctx->err.has_error) { + return; + } + + entry = get_ancillary_reg_entry(level, type); + if (entry == NULL) { + do_from_zval_err(ctx, "cmsghdr with level %d and type %d not supported", + level, type); + return; + } + + if (entry->calc_space) { + data_len = entry->calc_space(arr, ctx); + if (ctx->err.has_error) { + return; + } + } else { + data_len = entry->size; + } + req_space = CMSG_SPACE(data_len); + space_left = *control_len - *offset; + assert(*control_len >= *offset); + + if (space_left < req_space) { + *control_buf = safe_erealloc(*control_buf, 2, req_space, *control_len); + *control_len += 2 * req_space; + memset(*control_buf, '\0', *control_len - *offset); + memcpy(&alloc->data, *control_buf, sizeof *control_buf); + } + + cmsghdr = (struct cmsghdr*)(((char*)*control_buf) + *offset); + cmsghdr->cmsg_level = level; + cmsghdr->cmsg_type = type; + cmsghdr->cmsg_len = CMSG_LEN(data_len); + + descriptor_data[0].from_zval = entry->from_array; + from_zval_write_aggregation(arr, (char*)CMSG_DATA(cmsghdr), descriptor_data, ctx); + + *offset += req_space; +} +static void from_zval_write_control_array(const zval *arr, char *msghdr_c, ser_context *ctx) +{ + HashPosition pos; + char buf[sizeof("element #4294967295")]; + char *bufp = buf; + zval **elem; + uint32_t i; + int num_elems; + void *control_buf; + zend_llist_element *alloc; + size_t control_len, + cur_offset; + struct msghdr *msg = (struct msghdr*)msghdr_c; + + if (Z_TYPE_P(arr) != IS_ARRAY) { + do_from_zval_err(ctx, "%s", "expected an array here"); + return; + } + + num_elems = zend_hash_num_elements(Z_ARRVAL_P(arr)); + if (num_elems == 0) { + return; + } + + /* estimate each message at 20 bytes */ + control_buf = accounted_safe_ecalloc(num_elems, CMSG_SPACE(20), 0, ctx); + alloc = ctx->allocations.tail; + control_len = (size_t)num_elems * CMSG_SPACE(20); + cur_offset = 0; + + for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos), i = 0; + !ctx->err.has_error + && zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **)&elem, &pos) == SUCCESS; + zend_hash_move_forward_ex(Z_ARRVAL_P(arr), &pos)) { + + if (snprintf(buf, sizeof(buf), "element #%u", (unsigned)i++) >= sizeof(buf)) { + memcpy(buf, "element", sizeof("element")); + } + zend_llist_add_element(&ctx->keys, &bufp); + + from_zval_write_control(*elem, &control_buf, alloc, &control_len, + &cur_offset, ctx); + + zend_llist_remove_tail(&ctx->keys); + } + + msg->msg_control = control_buf; + msg->msg_controllen = cur_offset; /* not control_len, which may be larger */ +} +static void to_zval_read_cmsg_data(const char *cmsghdr_c, zval *zv, res_context *ctx) +{ + const struct cmsghdr *cmsg = (const struct cmsghdr *)cmsghdr_c; + ancillary_reg_entry *entry; + size_t len, + *len_p = &len; + + entry = get_ancillary_reg_entry(cmsg->cmsg_level, cmsg->cmsg_type); + if (entry == NULL) { + do_to_zval_err(ctx, "cmsghdr with level %d and type %d not supported", + cmsg->cmsg_level, cmsg->cmsg_type); + return; + } + if (CMSG_LEN(entry->size) > cmsg->cmsg_len) { + do_to_zval_err(ctx, "the cmsghdr structure is unexpectedly small; " + "expected a length of at least %ld, but got %ld", + (long)CMSG_LEN(entry->size), (long)cmsg->cmsg_len); + return; + } + + len = (size_t)cmsg->cmsg_len; /* use another var because type of cmsg_len varies */ + if (zend_hash_add(&ctx->params, KEY_CMSG_LEN, sizeof(KEY_CMSG_LEN), + &len_p, sizeof(len_p), NULL) == FAILURE) { + do_to_zval_err(ctx, "%s", "could not set parameter " KEY_CMSG_LEN); + return; + } + + entry->to_array((const char *)CMSG_DATA(cmsg), zv, ctx); + + zend_hash_del(&ctx->params, KEY_CMSG_LEN, sizeof(KEY_CMSG_LEN)); +} +static void to_zval_read_control(const char *cmsghdr_c, zval *zv, res_context *ctx) +{ + /* takes a cmsghdr, not a msghdr like from_zval_write_control */ + static const field_descriptor descriptors[] = { + {"level", sizeof("level"), 0, offsetof(struct cmsghdr, cmsg_level), 0, to_zval_read_int}, + {"type", sizeof("type"), 0, offsetof(struct cmsghdr, cmsg_type), 0, to_zval_read_int}, + {"data", sizeof("data"), 0, 0 /* cmsghdr passed */, 0, to_zval_read_cmsg_data}, + {0} + }; + + array_init_size(zv, 3); + to_zval_read_aggregation(cmsghdr_c, zv, descriptors, ctx); +} +static void to_zval_read_control_array(const char *msghdr_c, zval *zv, res_context *ctx) +{ + struct msghdr *msg = (struct msghdr *)msghdr_c; + struct cmsghdr *cmsg; + char buf[sizeof("element #4294967295")]; + char *bufp = buf; + uint32_t i = 1; + + /*if (msg->msg_flags & MSG_CTRUNC) { + php_error_docref0(NULL, E_WARNING, "The MSG_CTRUNC flag is present; will not " + "attempt to read control messages"); + ZVAL_FALSE(zv); + return; + }*/ + + array_init(zv); + + for (cmsg = CMSG_FIRSTHDR(msg); + cmsg != NULL && !ctx->err.has_error; + cmsg = CMSG_NXTHDR(msg, cmsg)) { + zval *elem; + + ALLOC_INIT_ZVAL(elem); + add_next_index_zval(zv, elem); + + if (snprintf(buf, sizeof(buf), "element #%u", (unsigned)i++) >= sizeof(buf)) { + memcpy(buf, "element", sizeof("element")); + } + zend_llist_add_element(&ctx->keys, &bufp); + + to_zval_read_control((const char *)cmsg, elem, ctx); + + zend_llist_remove_tail(&ctx->keys); + } +} + +/* CONVERSIONS for msghdr */ +static void from_zval_write_name(const zval *zname_arr, char *msghdr_c, ser_context *ctx) +{ + struct sockaddr *sockaddr; + socklen_t sockaddr_len; + struct msghdr *msghdr = (struct msghdr *)msghdr_c; + + from_zval_write_sockaddr_aux(zname_arr, &sockaddr, &sockaddr_len, ctx); + + msghdr->msg_name = sockaddr; + msghdr->msg_namelen = sockaddr_len; +} +static void to_zval_read_name(const char *sockaddr_p, zval *zv, res_context *ctx) +{ + void *name = (void*)*(void**)sockaddr_p; + if (name == NULL) { + ZVAL_NULL(zv); + } else { + to_zval_read_sockaddr_aux(name, zv, ctx); + } +} +static void from_zval_write_msghdr_buffer_size(const zval *elem, char *msghdr_c, ser_context *ctx) +{ + long lval; + struct msghdr *msghdr = (struct msghdr *)msghdr_c; + + lval = from_zval_integer_common(elem, ctx); + if (ctx->err.has_error) { + return; + } + + if (lval < 0 || lval > MAX_USER_BUFF_SIZE) { + do_from_zval_err(ctx, "the buffer size must be between 1 and %ld; " + "given %ld", (long)MAX_USER_BUFF_SIZE, lval); + return; + } + + msghdr->msg_iovlen = 1; + msghdr->msg_iov = accounted_emalloc(sizeof(*msghdr->msg_iov) * 1, ctx); + msghdr->msg_iov[0].iov_base = accounted_emalloc((size_t)lval, ctx); + msghdr->msg_iov[0].iov_len = (size_t)lval; +} +static void from_zval_write_iov_array_aux(zval **elem, unsigned i, void **args, ser_context *ctx) +{ + struct msghdr *msg = args[0]; + size_t len; + + zval_add_ref(elem); + convert_to_string_ex(elem); + + len = Z_STRLEN_PP(elem); + msg->msg_iov[i - 1].iov_base = accounted_emalloc(len, ctx); + msg->msg_iov[i - 1].iov_len = len; + memcpy(msg->msg_iov[i - 1].iov_base, Z_STRVAL_PP(elem), len); + + zval_ptr_dtor(elem); +} +static void from_zval_write_iov_array(const zval *arr, char *msghdr_c, ser_context *ctx) +{ + int num_elem; + struct msghdr *msg = (struct msghdr*)msghdr_c; + + if (Z_TYPE_P(arr) != IS_ARRAY) { + do_from_zval_err(ctx, "%s", "expected an array here"); + return; + } + + num_elem = zend_hash_num_elements(Z_ARRVAL_P(arr)); + if (num_elem == 0) { + return; + } + + msg->msg_iov = accounted_safe_ecalloc(num_elem, sizeof *msg->msg_iov, 0, ctx); + msg->msg_iovlen = (size_t)num_elem; + + from_array_iterate(arr, from_zval_write_iov_array_aux, (void**)&msg, ctx); +} +static void from_zval_write_controllen(const zval *elem, char *msghdr_c, ser_context *ctx) +{ + struct msghdr *msghdr = (struct msghdr *)msghdr_c; + uint32_t len; + + /* controllen should be an unsigned with at least 32-bit. Let's assume + * this least common denominator + */ + from_zval_write_uint32(elem, (char*)&len, ctx); + if (!ctx->err.has_error && len == 0) { + do_from_zval_err(ctx, "controllen cannot be 0"); + return; + } + msghdr->msg_control = accounted_emalloc(len, ctx); + msghdr->msg_controllen = len; +} +void from_zval_write_msghdr_send(const zval *container, char *msghdr_c, ser_context *ctx) +{ + static const field_descriptor descriptors[] = { + {"name", sizeof("name"), 0, 0, from_zval_write_name, 0}, + {"iov", sizeof("iov"), 0, 0, from_zval_write_iov_array, 0}, + {"control", sizeof("control"), 0, 0, from_zval_write_control_array, 0}, + {0} + }; + + from_zval_write_aggregation(container, msghdr_c, descriptors, ctx); +} +void from_zval_write_msghdr_recv(const zval *container, char *msghdr_c, ser_context *ctx) +{ + /* zval to struct msghdr, version for recvmsg(). It differs from the version + * for sendmsg() in that it: + * - has a buffer_size instead of an iov array; + * - has no control element; has a controllen element instead + * struct msghdr { + * void *msg_name; + * socklen_t msg_namelen; + * struct iovec *msg_iov; + * size_t msg_iovlen; + * void *msg_control; + * size_t msg_controllen; //can also be socklen_t + * int msg_flags; + * }; + */ + static const field_descriptor descriptors[] = { + {"name", sizeof("name"), 0, 0, from_zval_write_name, 0}, + {"buffer_size", sizeof("buffer_size"), 0, 0, from_zval_write_msghdr_buffer_size, 0}, + {"controllen", sizeof("controllen"), 1, 0, from_zval_write_controllen, 0}, + {0} + }; + struct msghdr *msghdr = (struct msghdr *)msghdr_c; + const int falsev = 0, + *falsevp = &falsev; + + if (zend_hash_add(&ctx->params, KEY_FILL_SOCKADDR, sizeof(KEY_FILL_SOCKADDR), + (void*)&falsevp, sizeof(falsevp), NULL) == FAILURE) { + do_from_zval_err(ctx, "could not add fill_sockaddr; this is a bug"); + return; + } + + from_zval_write_aggregation(container, msghdr_c, descriptors, ctx); + + zend_hash_del(&ctx->params, KEY_FILL_SOCKADDR, sizeof(KEY_FILL_SOCKADDR)); + if (ctx->err.has_error) { + return; + } + + if (msghdr->msg_iovlen == 0) { + msghdr->msg_iovlen = 1; + msghdr->msg_iov = accounted_emalloc(sizeof(*msghdr->msg_iov) * 1, ctx); + msghdr->msg_iov[0].iov_base = accounted_emalloc((size_t)DEFAULT_BUFF_SIZE, ctx); + msghdr->msg_iov[0].iov_len = (size_t)DEFAULT_BUFF_SIZE; + } +} + +static void to_zval_read_iov(const char *msghdr_c, zval *zv, res_context *ctx) +{ + const struct msghdr *msghdr = (const struct msghdr *)msghdr_c; + size_t iovlen = msghdr->msg_iovlen; + ssize_t **recvmsg_ret, + bytes_left; + uint i; + + if (iovlen > UINT_MAX) { + do_to_zval_err(ctx, "unexpectedly large value for iov_len: %lu", + (unsigned long)iovlen); + } + array_init_size(zv, (uint)iovlen); + + if (zend_hash_find(&ctx->params, KEY_RECVMSG_RET, sizeof(KEY_RECVMSG_RET), + (void**)&recvmsg_ret) == FAILURE) { + do_to_zval_err(ctx, "recvmsg_ret not found in params. This is a bug"); + return; + } + bytes_left = **recvmsg_ret; + + for (i = 0; bytes_left > 0 && i < (uint)iovlen; i++) { + zval *elem; + size_t len = MIN(msghdr->msg_iov[i].iov_len, (size_t)bytes_left); + char *buf = safe_emalloc(1, len, 1); + + MAKE_STD_ZVAL(elem); + memcpy(buf, msghdr->msg_iov[i].iov_base, len); + buf[len] = '\0'; + + ZVAL_STRINGL(elem, buf, len, 0); + add_next_index_zval(zv, elem); + bytes_left -= len; + } +} +void to_zval_read_msghdr(const char *msghdr_c, zval *zv, res_context *ctx) +{ + static const field_descriptor descriptors[] = { + {"name", sizeof("name"), 0, offsetof(struct msghdr, msg_name), 0, to_zval_read_name}, + {"control", sizeof("control"), 0, 0, 0, to_zval_read_control_array}, + {"iov", sizeof("iov"), 0, 0, 0, to_zval_read_iov}, + {"flags", sizeof("flags"), 0, offsetof(struct msghdr, msg_flags), 0, to_zval_read_int}, + {0} + }; + + array_init_size(zv, 4); + + to_zval_read_aggregation(msghdr_c, zv, descriptors, ctx); +} + +/* CONVERSIONS for if_index */ +static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context *ctx) +{ + unsigned ret; + zval lzval = zval_used_for_init; + + if (Z_TYPE_P(zv) == IS_LONG) { + if (Z_LVAL_P(zv) < 0 || Z_LVAL_P(zv) > UINT_MAX) { /* allow 0 (unspecified interface) */ + do_from_zval_err(ctx, "the interface index cannot be negative or " + "larger than %u; given %ld", UINT_MAX, Z_LVAL_P(zv)); + } else { + ret = (unsigned)Z_LVAL_P(zv); + } + } else { + if (Z_TYPE_P(zv) != IS_STRING) { + ZVAL_COPY_VALUE(&lzval, zv); + zval_copy_ctor(&lzval); + convert_to_string(&lzval); + zv = &lzval; + } + +#if HAVE_IF_NAMETOINDEX + ret = if_nametoindex(Z_STRVAL_P(zv)); + if (ret == 0) { + do_from_zval_err(ctx, "no interface with name \"%s\" could be " + "found", Z_STRVAL_P(zv)); + } +#elif defined(SIOCGIFINDEX) + { + struct ifreq ifr; + if (strlcpy(ifr.ifr_name, Z_STRVAL_P(zv), sizeof(ifr.ifr_name)) + >= sizeof(ifr.ifr_name)) { + do_from_zval_err(ctx, "the interface name \"%s\" is too large ", + Z_STRVAL_P(zv)); + } else if (ioctl(ctx->sock->bsd_socket, SIOCGIFINDEX, &ifr) < 0) { + if (errno == ENODEV) { + do_from_zval_err(ctx, "no interface with name \"%s\" could be " + "found", Z_STRVAL_P(zv)); + } else { + do_from_zval_err(ctx, "error fetching interface index for " + "interface with name \"%s\" (errno %d)", + Z_STRVAL_P(zv), errno); + } + } else { + ret = (unsigned)ifr.ifr_ifindex; + } + } +#else + do_from_zval_err(ctx, + "this platform does not support looking up an interface by " + "name, an integer interface index must be supplied instead"); +#endif + } + + if (!ctx->err.has_error) { + memcpy(uinteger, &ret, sizeof(ret)); + } + + zval_dtor(&lzval); +} + +/* CONVERSIONS for struct in6_pktinfo */ +#ifdef IPV6_PKTINFO +static const field_descriptor descriptors_in6_pktinfo[] = { + {"addr", sizeof("addr"), 1, offsetof(struct in6_pktinfo, ipi6_addr), from_zval_write_sin6_addr, to_zval_read_sin6_addr}, + {"ifindex", sizeof("ifindex"), 1, offsetof(struct in6_pktinfo, ipi6_ifindex), from_zval_write_ifindex, to_zval_read_unsigned}, + {0} +}; +void from_zval_write_in6_pktinfo(const zval *container, char *in6_pktinfo_c, ser_context *ctx) +{ + from_zval_write_aggregation(container, in6_pktinfo_c, descriptors_in6_pktinfo, ctx); +} +void to_zval_read_in6_pktinfo(const char *data, zval *zv, res_context *ctx) +{ + array_init_size(zv, 2); + + to_zval_read_aggregation(data, zv, descriptors_in6_pktinfo, ctx); +} +#endif + +/* CONVERSIONS for struct ucred */ +#ifdef SO_PASSCRED +static const field_descriptor descriptors_ucred[] = { + {"pid", sizeof("pid"), 1, offsetof(struct ucred, pid), from_zval_write_pid_t, to_zval_read_pid_t}, + {"uid", sizeof("uid"), 1, offsetof(struct ucred, uid), from_zval_write_uid_t, to_zval_read_uid_t}, + /* assume the type gid_t is the same as uid_t: */ + {"gid", sizeof("gid"), 1, offsetof(struct ucred, gid), from_zval_write_uid_t, to_zval_read_uid_t}, + {0} +}; +void from_zval_write_ucred(const zval *container, char *ucred_c, ser_context *ctx) +{ + from_zval_write_aggregation(container, ucred_c, descriptors_ucred, ctx); +} +void to_zval_read_ucred(const char *data, zval *zv, res_context *ctx) +{ + array_init_size(zv, 3); + + to_zval_read_aggregation(data, zv, descriptors_ucred, ctx); +} +#endif + +/* CONVERSIONS for SCM_RIGHTS */ +#ifdef SCM_RIGHTS +size_t calculate_scm_rights_space(const zval *arr, ser_context *ctx) +{ + int num_elems; + + if (Z_TYPE_P(arr) != IS_ARRAY) { + do_from_zval_err(ctx, "%s", "expected an array here"); + return (size_t)-1; + } + + num_elems = zend_hash_num_elements(Z_ARRVAL_P(arr)); + if (num_elems == 0) { + do_from_zval_err(ctx, "%s", "expected at least one element in this array"); + return (size_t)-1; + } + + return zend_hash_num_elements(Z_ARRVAL_P(arr)) * sizeof(int); +} +static void from_zval_write_fd_array_aux(zval **elem, unsigned i, void **args, ser_context *ctx) +{ + int *iarr = args[0]; + TSRMLS_FETCH(); + + if (Z_TYPE_PP(elem) == IS_RESOURCE) { + php_stream *stream; + php_socket *sock; + + ZEND_FETCH_RESOURCE_NO_RETURN(sock, php_socket *, elem, -1, + NULL, php_sockets_le_socket()); + if (sock) { + iarr[i] = sock->bsd_socket; + return; + } + + ZEND_FETCH_RESOURCE2_NO_RETURN(stream, php_stream *, elem, -1, + NULL, php_file_le_stream(), php_file_le_pstream()); + if (stream == NULL) { + do_from_zval_err(ctx, "resource is not a stream or a socket"); + return; + } + + if (php_stream_cast(stream, PHP_STREAM_AS_FD, (void **)&iarr[i], + REPORT_ERRORS) == FAILURE) { + do_from_zval_err(ctx, "cast stream to file descriptor failed"); + return; + } + } else { + do_from_zval_err(ctx, "expected a resource variable"); + } +} +void from_zval_write_fd_array(const zval *arr, char *int_arr, ser_context *ctx) +{ + if (Z_TYPE_P(arr) != IS_ARRAY) { + do_from_zval_err(ctx, "%s", "expected an array here"); + return; + } + + from_array_iterate(arr, &from_zval_write_fd_array_aux, (void**)&int_arr, ctx); +} +void to_zval_read_fd_array(const char *data, zval *zv, res_context *ctx) +{ + size_t **cmsg_len; + int num_elems, + i; + struct cmsghdr *dummy_cmsg = 0; + size_t data_offset; + TSRMLS_FETCH(); + + data_offset = (unsigned char *)CMSG_DATA(dummy_cmsg) + - (unsigned char *)dummy_cmsg; + + if (zend_hash_find(&ctx->params, KEY_CMSG_LEN, sizeof(KEY_CMSG_LEN), + (void **)&cmsg_len) == FAILURE) { + do_to_zval_err(ctx, "could not get value of parameter " KEY_CMSG_LEN); + return; + } + + if (**cmsg_len < data_offset) { + do_to_zval_err(ctx, "length of cmsg is smaller than its data member " + "offset (%ld vs %ld)", (long)**cmsg_len, (long)data_offset); + return; + } + num_elems = (**cmsg_len - data_offset) / sizeof(int); + + array_init_size(zv, num_elems); + + for (i = 0; i < num_elems; i++) { + zval *elem; + int fd; + struct stat statbuf; + + MAKE_STD_ZVAL(elem); + + fd = *((int *)data + i); + + /* determine whether we have a socket */ + if (fstat(fd, &statbuf) == -1) { + do_to_zval_err(ctx, "error creating resource for received file " + "descriptor %d: fstat() call failed with errno %d", fd, errno); + efree(elem); + return; + } + if (S_ISSOCK(statbuf.st_mode)) { + php_socket *sock = socket_import_file_descriptor(fd TSRMLS_CC); + zend_register_resource(elem, sock, php_sockets_le_socket() TSRMLS_CC); + } else { + php_stream *stream = php_stream_fopen_from_fd(fd, "rw", NULL); + php_stream_to_zval(stream, elem); + } + + add_next_index_zval(zv, elem); + } +} +#endif + +/* ENTRY POINT for conversions */ +static void free_from_zval_allocation(void *alloc_ptr_ptr) +{ + efree(*(void**)alloc_ptr_ptr); +} +void *from_zval_run_conversions(const zval *container, + php_socket *sock, + from_zval_write_field *writer, + size_t struct_size, + const char *top_name, + zend_llist **allocations /* out */, + struct err_s *err /* in/out */) +{ + ser_context ctx = {{0}}; + char *structure = NULL; + + *allocations = NULL; + + if (err->has_error) { + return NULL; + } + + zend_hash_init(&ctx.params, 8, NULL, NULL, 0); + zend_llist_init(&ctx.keys, sizeof(const char *), NULL, 0); + zend_llist_init(&ctx.allocations, sizeof(void *), &free_from_zval_allocation, 0); + ctx.sock = sock; + + structure = ecalloc(1, struct_size); + + zend_llist_add_element(&ctx.keys, &top_name); + zend_llist_add_element(&ctx.allocations, &structure); + + /* main call */ + writer(container, structure, &ctx); + + if (ctx.err.has_error) { + zend_llist_destroy(&ctx.allocations); /* deallocates structure as well */ + structure = NULL; + *err = ctx.err; + } else { + *allocations = emalloc(sizeof **allocations); + **allocations = ctx.allocations; + } + + zend_llist_destroy(&ctx.keys); + zend_hash_destroy(&ctx.params); + + return structure; +} +zval *to_zval_run_conversions(const char *structure, + to_zval_read_field *reader, + const char *top_name, + const struct key_value *key_value_pairs, + struct err_s *err) +{ + res_context ctx = {{0}, {0}}; + const struct key_value *kv; + zval *zv = NULL; + + if (err->has_error) { + return NULL; + } + + ALLOC_INIT_ZVAL(zv); + + zend_llist_init(&ctx.keys, sizeof(const char *), NULL, 0); + zend_llist_add_element(&ctx.keys, &top_name); + + zend_hash_init(&ctx.params, 8, NULL, NULL, 0); + for (kv = key_value_pairs; kv->key != NULL; kv++) { + zend_hash_update(&ctx.params, kv->key, kv->key_size, + (void*)&kv->value, sizeof(kv->value), NULL); + } + + /* main call */ + reader(structure, zv, &ctx); + + if (ctx.err.has_error) { + zval_ptr_dtor(&zv); + zv = NULL; + *err = ctx.err; + } + + zend_llist_destroy(&ctx.keys); + zend_hash_destroy(&ctx.params); + + return zv; +} diff --git a/ext/sockets/conversions.h b/ext/sockets/conversions.h new file mode 100644 index 0000000000000..7d515246a0bc6 --- /dev/null +++ b/ext/sockets/conversions.h @@ -0,0 +1,84 @@ +#ifndef PHP_SOCK_CONVERSIONS_H +#define PHP_SOCK_CONVERSIONS_H 1 + +#include + +#ifndef PHP_WIN32 +# include +# include +#else +# include +#endif + +#include "php_sockets.h" + +/* TYPE DEFINITIONS */ +struct err_s { + int has_error; + char *msg; + int level; + int should_free; +}; + +struct key_value { + const char *key; + unsigned key_size; + void *value; +}; + +/* the complete types of these two are not relevant to the outside */ +typedef struct _ser_context ser_context; +typedef struct _res_context res_context; + +#define KEY_RECVMSG_RET "recvmsg_ret" + +typedef void (from_zval_write_field)(const zval *arr_value, char *field, ser_context *ctx); +typedef void (to_zval_read_field)(const char *data, zval *zv, res_context *ctx); + +/* VARIABLE DECLARATIONS */ +extern const struct key_value empty_key_value_list[]; + +/* AUX FUNCTIONS */ +void err_msg_dispose(struct err_s *err TSRMLS_DC); +void allocations_dispose(zend_llist **allocations); + +/* CONVERSION FUNCTIONS */ +void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx); +void to_zval_read_int(const char *data, zval *zv, res_context *ctx); + +#ifdef IPV6_PKTINFO +void from_zval_write_in6_pktinfo(const zval *container, char *in6_pktinfo_c, ser_context *ctx); +void to_zval_read_in6_pktinfo(const char *data, zval *zv, res_context *ctx); +#endif + +#ifdef SO_PASSCRED +void from_zval_write_ucred(const zval *container, char *ucred_c, ser_context *ctx); +void to_zval_read_ucred(const char *data, zval *zv, res_context *ctx); +#endif + +#ifdef SCM_RIGHTS +size_t calculate_scm_rights_space(const zval *arr, ser_context *ctx); +void from_zval_write_fd_array(const zval *arr, char *int_arr, ser_context *ctx); +void to_zval_read_fd_array(const char *data, zval *zv, res_context *ctx); +#endif + +void from_zval_write_msghdr_send(const zval *container, char *msghdr_c, ser_context *ctx); +void from_zval_write_msghdr_recv(const zval *container, char *msghdr_c, ser_context *ctx); +void to_zval_read_msghdr(const char *msghdr_c, zval *zv, res_context *ctx); + +/* ENTRY POINTS FOR CONVERSIONS */ +void *from_zval_run_conversions(const zval *container, + php_socket *sock, + from_zval_write_field *writer, + size_t struct_size, + const char *top_name, + zend_llist **allocations /* out */, + struct err_s *err /* in/out */); + +zval *to_zval_run_conversions(const char *structure, + to_zval_read_field *reader, + const char *top_name, + const struct key_value *key_value_pairs, + struct err_s *err); + +#endif diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c index 43b6f7dddf4b4..c6de3198e4658 100644 --- a/ext/sockets/multicast.c +++ b/ext/sockets/multicast.c @@ -28,16 +28,7 @@ #include "php_network.h" #ifdef PHP_WIN32 -# include "win32/inet.h" -# include -# include -# include -# include -# include "php_sockets.h" -# include "win32/sockets.h" -# define NTDDI_XP NTDDI_WINXP /* bug in SDK */ -# include -# undef NTDDI_XP +# include "windows_common.h" #else #include #include @@ -51,6 +42,7 @@ #include "php_sockets.h" #include "multicast.h" +#include "sockaddr_conv.h" #include "main/php_network.h" @@ -73,6 +65,309 @@ static const char *_php_source_op_to_string(enum source_op sop); static int _php_source_op_to_ipv4_op(enum source_op sop); #endif +static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC) +{ + int ret; + + if (Z_TYPE_P(val) == IS_LONG) { + if (Z_LVAL_P(val) < 0 || Z_LVAL_P(val) > UINT_MAX) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "the interface index cannot be negative or larger than %u;" + " given %ld", UINT_MAX, Z_LVAL_P(val)); + ret = FAILURE; + } else { + *out = Z_LVAL_P(val); + ret = SUCCESS; + } + } else { +#if HAVE_IF_NAMETOINDEX + unsigned int ind; + zval_add_ref(&val); + convert_to_string_ex(&val); + ind = if_nametoindex(Z_STRVAL_P(val)); + if (ind == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "no interface with name \"%s\" could be found", Z_STRVAL_P(val)); + ret = FAILURE; + } else { + *out = ind; + ret = SUCCESS; + } + zval_ptr_dtor(&val); +#else + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "this platform does not support looking up an interface by " + "name, an integer interface index must be supplied instead"); + ret = FAILURE; +#endif + } + + return ret; +} + +static int php_get_if_index_from_array(const HashTable *ht, const char *key, + php_socket *sock, unsigned int *if_index TSRMLS_DC) +{ + zval **val; + + if (zend_hash_find(ht, key, strlen(key) + 1, (void **)&val) == FAILURE) { + *if_index = 0; /* default: 0 */ + return SUCCESS; + } + + return php_get_if_index_from_zval(*val, if_index TSRMLS_CC); +} + +static int php_get_address_from_array(const HashTable *ht, const char *key, + php_socket *sock, php_sockaddr_storage *ss, socklen_t *ss_len TSRMLS_DC) +{ + zval **val, + *valcp; + + if (zend_hash_find(ht, key, strlen(key) + 1, (void **)&val) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "no key \"%s\" passed in optval", key); + return FAILURE; + } + valcp = *val; + zval_add_ref(&valcp); + convert_to_string_ex(val); + if (!php_set_inet46_addr(ss, ss_len, Z_STRVAL_P(valcp), sock TSRMLS_CC)) { + zval_ptr_dtor(&valcp); + return FAILURE; + } + zval_ptr_dtor(&valcp); + return SUCCESS; +} + +static int php_do_mcast_opt(php_socket *php_sock, int level, int optname, zval **arg4 TSRMLS_DC) +{ + HashTable *opt_ht; + unsigned int if_index; + int retval; + int (*mcast_req_fun)(php_socket *, int, struct sockaddr *, socklen_t, + unsigned TSRMLS_DC); +#ifdef HAS_MCAST_EXT + int (*mcast_sreq_fun)(php_socket *, int, struct sockaddr *, socklen_t, + struct sockaddr *, socklen_t, unsigned TSRMLS_DC); +#endif + + switch (optname) { + case MCAST_JOIN_GROUP: + mcast_req_fun = &php_mcast_join; + goto mcast_req_fun; + case MCAST_LEAVE_GROUP: + { + php_sockaddr_storage group = {0}; + socklen_t glen; + + mcast_req_fun = &php_mcast_leave; +mcast_req_fun: + convert_to_array_ex(arg4); + opt_ht = HASH_OF(*arg4); + + if (php_get_address_from_array(opt_ht, "group", php_sock, &group, + &glen TSRMLS_CC) == FAILURE) { + return FAILURE; + } + if (php_get_if_index_from_array(opt_ht, "interface", php_sock, + &if_index TSRMLS_CC) == FAILURE) { + return FAILURE; + } + + retval = mcast_req_fun(php_sock, level, (struct sockaddr*)&group, + glen, if_index TSRMLS_CC); + break; + } + +#ifdef HAS_MCAST_EXT + case MCAST_BLOCK_SOURCE: + mcast_sreq_fun = &php_mcast_block_source; + goto mcast_sreq_fun; + case MCAST_UNBLOCK_SOURCE: + mcast_sreq_fun = &php_mcast_unblock_source; + goto mcast_sreq_fun; + case MCAST_JOIN_SOURCE_GROUP: + mcast_sreq_fun = &php_mcast_join_source; + goto mcast_sreq_fun; + case MCAST_LEAVE_SOURCE_GROUP: + { + php_sockaddr_storage group = {0}, + source = {0}; + socklen_t glen, + slen; + + mcast_sreq_fun = &php_mcast_leave_source; + mcast_sreq_fun: + convert_to_array_ex(arg4); + opt_ht = HASH_OF(*arg4); + + if (php_get_address_from_array(opt_ht, "group", php_sock, &group, + &glen TSRMLS_CC) == FAILURE) { + return FAILURE; + } + if (php_get_address_from_array(opt_ht, "source", php_sock, &source, + &slen TSRMLS_CC) == FAILURE) { + return FAILURE; + } + if (php_get_if_index_from_array(opt_ht, "interface", php_sock, + &if_index TSRMLS_CC) == FAILURE) { + return FAILURE; + } + + retval = mcast_sreq_fun(php_sock, level, (struct sockaddr*)&group, + glen, (struct sockaddr*)&source, slen, if_index TSRMLS_CC); + break; + } +#endif + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "unexpected option in php_do_mcast_opt (level %d, option %d). " + "This is a bug.", level, optname); + return FAILURE; + } + + if (retval != 0) { + if (retval != -2) { /* error, but message already emitted */ + PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno); + } + return FAILURE; + } + return SUCCESS; +} + +int php_do_setsockopt_ip_mcast(php_socket *php_sock, + int level, + int optname, + zval **arg4 TSRMLS_DC) +{ + unsigned int if_index; + struct in_addr if_addr; + void *opt_ptr; + socklen_t optlen; + unsigned char ipv4_mcast_ttl_lback; + int retval; + + switch (optname) { + case MCAST_JOIN_GROUP: + case MCAST_LEAVE_GROUP: +#ifdef HAS_MCAST_EXT + case MCAST_BLOCK_SOURCE: + case MCAST_UNBLOCK_SOURCE: + case MCAST_JOIN_SOURCE_GROUP: + case MCAST_LEAVE_SOURCE_GROUP: +#endif + if (php_do_mcast_opt(php_sock, level, optname, arg4 TSRMLS_CC) == FAILURE) { + return FAILURE; + } else { + return SUCCESS; + } + + case IP_MULTICAST_IF: + if (php_get_if_index_from_zval(*arg4, &if_index TSRMLS_CC) == FAILURE) { + return FAILURE; + } + + if (php_if_index_to_addr4(if_index, php_sock, &if_addr TSRMLS_CC) == FAILURE) { + return FAILURE; + } + opt_ptr = &if_addr; + optlen = sizeof(if_addr); + goto dosockopt; + + case IP_MULTICAST_LOOP: + convert_to_boolean_ex(arg4); + goto ipv4_loop_ttl; + + case IP_MULTICAST_TTL: + convert_to_long_ex(arg4); + if (Z_LVAL_PP(arg4) < 0L || Z_LVAL_PP(arg4) > 255L) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "Expected a value between 0 and 255"); + return FAILURE; + } +ipv4_loop_ttl: + ipv4_mcast_ttl_lback = (unsigned char) Z_LVAL_PP(arg4); + opt_ptr = &ipv4_mcast_ttl_lback; + optlen = sizeof(ipv4_mcast_ttl_lback); + goto dosockopt; + } + + return 1; + +dosockopt: + retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen); + if (retval != 0) { + PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno); + return FAILURE; + } + + return SUCCESS; +} + +int php_do_setsockopt_ipv6_mcast(php_socket *php_sock, + int level, + int optname, + zval **arg4 TSRMLS_DC) +{ + unsigned int if_index; + void *opt_ptr; + socklen_t optlen; + int ov; + int retval; + + switch (optname) { + case MCAST_JOIN_GROUP: + case MCAST_LEAVE_GROUP: +#ifdef HAS_MCAST_EXT + case MCAST_BLOCK_SOURCE: + case MCAST_UNBLOCK_SOURCE: + case MCAST_JOIN_SOURCE_GROUP: + case MCAST_LEAVE_SOURCE_GROUP: +#endif + if (php_do_mcast_opt(php_sock, level, optname, arg4 TSRMLS_CC) == FAILURE) { + return FAILURE; + } else { + return SUCCESS; + } + + case IPV6_MULTICAST_IF: + if (php_get_if_index_from_zval(*arg4, &if_index TSRMLS_CC) == FAILURE) { + return FAILURE; + } + + opt_ptr = &if_index; + optlen = sizeof(if_index); + goto dosockopt; + + case IPV6_MULTICAST_LOOP: + convert_to_boolean_ex(arg4); + goto ipv6_loop_hops; + case IPV6_MULTICAST_HOPS: + convert_to_long_ex(arg4); + if (Z_LVAL_PP(arg4) < -1L || Z_LVAL_PP(arg4) > 255L) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "Expected a value between -1 and 255"); + return FAILURE; + } +ipv6_loop_hops: + ov = (int) Z_LVAL_PP(arg4); + opt_ptr = &ov; + optlen = sizeof(ov); + goto dosockopt; + } + + return 1; /* not handled */ + +dosockopt: + retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen); + if (retval != 0) { + PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno); + return FAILURE; + } + + return SUCCESS; +} + int php_mcast_join( php_socket *sock, int level, @@ -154,21 +449,21 @@ static int _php_mcast_join_leave( { #ifdef RFC3678_API struct group_req greq = {0}; - + memcpy(&greq.gr_group, group, group_len); assert(greq.gr_group.ss_family != 0); /* the caller has set this */ greq.gr_interface = if_index; return setsockopt(sock->bsd_socket, level, join ? MCAST_JOIN_GROUP : MCAST_LEAVE_GROUP, (char*)&greq, - sizeof(greq)); + sizeof(greq)); #else if (sock->type == AF_INET) { struct ip_mreq mreq = {0}; struct in_addr addr; - + assert(group_len == sizeof(struct sockaddr_in)); - + if (if_index != 0) { if (php_if_index_to_addr4(if_index, sock, &addr TSRMLS_CC) == FAILURE) @@ -185,12 +480,12 @@ static int _php_mcast_join_leave( #if HAVE_IPV6 else if (sock->type == AF_INET6) { struct ipv6_mreq mreq = {0}; - + assert(group_len == sizeof(struct sockaddr_in6)); mreq.ipv6mr_multiaddr = ((struct sockaddr_in6*)group)->sin6_addr; mreq.ipv6mr_interface = if_index; - + return setsockopt(sock->bsd_socket, level, join ? IPV6_JOIN_GROUP : IPV6_LEAVE_GROUP, (char*)&mreq, sizeof(mreq)); @@ -218,26 +513,26 @@ static int _php_mcast_source_op( { #ifdef RFC3678_API struct group_source_req gsreq = {0}; - + memcpy(&gsreq.gsr_group, group, group_len); assert(gsreq.gsr_group.ss_family != 0); memcpy(&gsreq.gsr_source, source, source_len); assert(gsreq.gsr_source.ss_family != 0); gsreq.gsr_interface = if_index; - + return setsockopt(sock->bsd_socket, level, _php_source_op_to_rfc3678_op(sop), (char*)&gsreq, sizeof(gsreq)); #else if (sock->type == AF_INET) { struct ip_mreq_source mreqs = {0}; struct in_addr addr; - + mreqs.imr_multiaddr = ((struct sockaddr_in*)group)->sin_addr; mreqs.imr_sourceaddr = ((struct sockaddr_in*)source)->sin_addr; - + assert(group_len == sizeof(struct sockaddr_in)); assert(source_len == sizeof(struct sockaddr_in)); - + if (if_index != 0) { if (php_if_index_to_addr4(if_index, sock, &addr TSRMLS_CC) == FAILURE) @@ -246,7 +541,7 @@ static int _php_mcast_source_op( } else { mreqs.imr_interface.s_addr = htonl(INADDR_ANY); } - + return setsockopt(sock->bsd_socket, level, _php_source_op_to_ipv4_op(sop), (char*)&mreqs, sizeof(mreqs)); } @@ -280,7 +575,7 @@ static int _php_source_op_to_rfc3678_op(enum source_op sop) case UNBLOCK_SOURCE: return MCAST_UNBLOCK_SOURCE; } - + assert(0); return 0; } @@ -297,7 +592,7 @@ static const char *_php_source_op_to_string(enum source_op sop) case UNBLOCK_SOURCE: return "MCAST_UNBLOCK_SOURCE"; } - + assert(0); return ""; } @@ -314,7 +609,7 @@ static int _php_source_op_to_ipv4_op(enum source_op sop) case UNBLOCK_SOURCE: return IP_UNBLOCK_SOURCE; } - + assert(0); return 0; } @@ -413,16 +708,16 @@ int php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *i int php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_addr *out_addr TSRMLS_DC) { struct ifreq if_req; - + if (if_index == 0) { out_addr->s_addr = INADDR_ANY; return SUCCESS; } - + #if !defined(ifr_ifindex) && defined(ifr_index) #define ifr_ifindex ifr_index #endif - + #if defined(SIOCGIFNAME) if_req.ifr_ifindex = if_index; if (ioctl(php_sock->bsd_socket, SIOCGIFNAME, &if_req) == -1) { @@ -435,13 +730,13 @@ int php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_add "Failed obtaining address for interface %u: error %d", if_index, errno); return FAILURE; } - + if (ioctl(php_sock->bsd_socket, SIOCGIFADDR, &if_req) == -1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed obtaining address for interface %u: error %d", if_index, errno); return FAILURE; } - + memcpy(out_addr, &((struct sockaddr_in *) &if_req.ifr_addr)->sin_addr, sizeof *out_addr); return SUCCESS; @@ -455,25 +750,25 @@ int php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *i int size = 0, lastsize = 0; size_t entry_len; - + if (addr->s_addr == INADDR_ANY) { *if_index = 0; return SUCCESS; } - + for(;;) { size += 5 * sizeof(struct ifreq); buf = ecalloc(size, 1); if_conf.ifc_len = size; if_conf.ifc_buf = buf; - + if (ioctl(php_sock->bsd_socket, SIOCGIFCONF, (char*)&if_conf) == -1 && (errno != EINVAL || lastsize != 0)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed obtaining interfaces list: error %d", errno); goto err; } - + if (if_conf.ifc_len == lastsize) /* not increasing anymore */ break; @@ -483,15 +778,15 @@ int php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *i buf = NULL; } } - + for (p = if_conf.ifc_buf; p < if_conf.ifc_buf + if_conf.ifc_len; p += entry_len) { struct ifreq *cur_req; - + /* let's hope the pointer is aligned */ cur_req = (struct ifreq*) p; - + #ifdef HAVE_SOCKADDR_SA_LEN entry_len = cur_req->ifr_addr.sa_len + sizeof(cur_req->ifr_name); #else @@ -499,7 +794,7 @@ int php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *i entry_len = sizeof(struct sockaddr) + sizeof(cur_req->ifr_name); #endif entry_len = MAX(entry_len, sizeof(*cur_req)); - + if ((((struct sockaddr*)&cur_req->ifr_addr)->sa_family == AF_INET) && (((struct sockaddr_in*)&cur_req->ifr_addr)->sin_addr.s_addr == addr->s_addr)) { @@ -534,7 +829,7 @@ int php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *i php_error_docref(NULL TSRMLS_CC, E_WARNING, "The interface with IP address %s was not found", addr_str); } - + err: if (buf != NULL) efree(buf); diff --git a/ext/sockets/multicast.h b/ext/sockets/multicast.h index f46a6a8f61b7d..1ad4673feb719 100644 --- a/ext/sockets/multicast.h +++ b/ext/sockets/multicast.h @@ -18,9 +18,7 @@ /* $Id$ */ -#if defined(MCAST_JOIN_GROUP) && \ - (!defined(PHP_WIN32) || (_WIN32_WINNT >= 0x600 && SOCKETS_ENABLE_VISTA_API)) && \ - !defined(__APPLE__) +#if defined(MCAST_JOIN_GROUP) && !defined(__APPLE__) #define RFC3678_API 1 /* has block/unblock and source membership, in this case for both IPv4 and IPv6 */ #define HAS_MCAST_EXT 1 @@ -29,6 +27,16 @@ #define HAS_MCAST_EXT 1 #endif +int php_do_setsockopt_ip_mcast(php_socket *php_sock, + int level, + int optname, + zval **arg4 TSRMLS_DC); + +int php_do_setsockopt_ipv6_mcast(php_socket *php_sock, + int level, + int optname, + zval **arg4 TSRMLS_DC); + int php_if_index_to_addr4( unsigned if_index, php_socket *php_sock, diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index fabc9c4c3e74a..dd2b9933f6e8b 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -26,11 +26,16 @@ #if HAVE_SOCKETS +#include +#ifdef PHP_WIN32 +# include "windows_common.h" +#endif + extern zend_module_entry sockets_module_entry; #define phpext_sockets_ptr &sockets_module_entry #ifdef PHP_WIN32 -#include +#include #else #if HAVE_SYS_SOCKET_H #include @@ -64,6 +69,16 @@ PHP_SOCKETS_API int php_sockets_le_socket(void); #define php_sockets_le_socket_name "Socket" +#define PHP_SOCKET_ERROR(socket, msg, errn) \ + do { \ + int _err = (errn); /* save value to avoid repeated calls to WSAGetLastError() on Windows */ \ + (socket)->error = _err; \ + SOCKETS_G(last_error) = _err; \ + if (_err != EAGAIN && _err != EWOULDBLOCK && _err != EINPROGRESS) { \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s [%d]: %s", msg, _err, sockets_strerror(_err TSRMLS_CC)); \ + } \ + } while (0) + ZEND_BEGIN_MODULE_GLOBALS(sockets) int last_error; char *strerror_buf; @@ -75,6 +90,17 @@ ZEND_END_MODULE_GLOBALS(sockets) #define SOCKETS_G(v) (sockets_globals.v) #endif +ZEND_EXTERN_MODULE_GLOBALS(sockets); + +enum sockopt_return { + SOCKOPT_ERROR, + SOCKOPT_CONTINUE, + SOCKOPT_SUCCESS +}; + +char *sockets_strerror(int error TSRMLS_DC); +php_socket *socket_import_file_descriptor(PHP_SOCKET sock TSRMLS_DC); + #else #define phpext_sockets_ptr NULL #endif diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c new file mode 100644 index 0000000000000..50b43ec38a514 --- /dev/null +++ b/ext/sockets/sendrecvmsg.c @@ -0,0 +1,452 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2012 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Gustavo Lopes | + +----------------------------------------------------------------------+ + */ + +#include +#include "php_sockets.h" +#include "sendrecvmsg.h" +#include "conversions.h" +#include +#include +#ifdef ZTS +#include +#endif + +#define MAX_USER_BUFF_SIZE ((size_t)(100*1024*1024)) +#define DEFAULT_BUFF_SIZE 8192 +#define MAX_ARRAY_KEY_SIZE 128 + +#ifdef PHP_WIN32 +#include "windows_common.h" +#include +#define IPV6_RECVPKTINFO IPV6_PKTINFO +#define IPV6_RECVHOPLIMIT IPV6_HOPLIMIT +#define msghdr _WSAMSG + +static GUID WSARecvMsg_GUID = WSAID_WSARECVMSG; +static __declspec(thread) LPFN_WSARECVMSG WSARecvMsg = NULL; +inline ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags) +{ + DWORD recvd = 0, + bytesReturned; + + if (WSARecvMsg == NULL) { + int res = WSAIoctl((SOCKET) sockfd, SIO_GET_EXTENSION_FUNCTION_POINTER, + &WSARecvMsg_GUID, sizeof(WSARecvMsg_GUID), + &WSARecvMsg, sizeof(WSARecvMsg), + &bytesReturned, NULL, NULL); + if (res != 0) { + return -1; + } + } + + msg->dwFlags = (DWORD)flags; + return WSARecvMsg((SOCKET)sockfd, msg, &recvd, NULL, NULL) == 0 + ? (ssize_t)recvd + : -1; +} +inline ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags) +{ + DWORD sent = 0; + return WSASendMsg((SOCKET)sockfd, (struct msghdr*)msg, (DWORD)flags, &sent, NULL, NULL) == 0 + ? (ssize_t)sent + : -1; +} +#endif + +#define LONG_CHECK_VALID_INT(l) \ + do { \ + if ((l) < INT_MIN && (l) > INT_MAX) { \ + php_error_docref0(NULL TSRMLS_CC, E_WARNING, "The value %ld does not fit inside " \ + "the boundaries of a native integer", (l)); \ + return; \ + } \ + } while (0) + +static struct { + int initialized; + HashTable ht; +} ancillary_registry; + + +#ifdef ZTS +static MUTEX_T ancillary_mutex; +#endif +static void init_ancillary_registry(void) +{ + ancillary_reg_entry entry; + anc_reg_key key; + ancillary_registry.initialized = 1; + + zend_hash_init(&ancillary_registry.ht, 32, NULL, NULL, 1); + +#define PUT_ENTRY(sizev, var_size, calc, from, to, level, type) \ + entry.size = sizev; \ + entry.var_el_size = var_size; \ + entry.calc_space = calc; \ + entry.from_array = from; \ + entry.to_array = to; \ + key.cmsg_level = level; \ + key.cmsg_type = type; \ + zend_hash_update(&ancillary_registry.ht, (char*)&key, sizeof(key), \ + (void*)&entry, sizeof(entry), NULL) + +#ifdef IPV6_PKTINFO + PUT_ENTRY(sizeof(struct in6_pktinfo), 0, 0, from_zval_write_in6_pktinfo, + to_zval_read_in6_pktinfo, IPPROTO_IPV6, IPV6_PKTINFO); +#endif + +#ifdef IPV6_HOPLIMIT + PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int, + to_zval_read_int, IPPROTO_IPV6, IPV6_HOPLIMIT); +#endif + +#ifdef IPV6_TCLASS + PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int, + to_zval_read_int, IPPROTO_IPV6, IPV6_TCLASS); +#endif + +#ifdef SO_PASSCRED + PUT_ENTRY(sizeof(struct ucred), 0, 0, from_zval_write_ucred, + to_zval_read_ucred, SOL_SOCKET, SCM_CREDENTIALS); +#endif + +#ifdef SCM_RIGHTS + PUT_ENTRY(0, sizeof(int), calculate_scm_rights_space, from_zval_write_fd_array, + to_zval_read_fd_array, SOL_SOCKET, SCM_RIGHTS); +#endif + +} +static void destroy_ancillary_registry(void) +{ + if (ancillary_registry.initialized) { + zend_hash_destroy(&ancillary_registry.ht); + ancillary_registry.initialized = 0; + } +} +ancillary_reg_entry *get_ancillary_reg_entry(int cmsg_level, int msg_type) +{ + anc_reg_key key = { cmsg_level, msg_type }; + ancillary_reg_entry *entry; + +#ifdef ZTS + tsrm_mutex_lock(ancillary_mutex); +#endif + if (!ancillary_registry.initialized) { + init_ancillary_registry(); + } +#ifdef ZTS + tsrm_mutex_unlock(ancillary_mutex); +#endif + + if (zend_hash_find(&ancillary_registry.ht, (char*)&key, sizeof(key), + (void**)&entry) == SUCCESS) { + return entry; + } else { + return NULL; + } +} + +PHP_FUNCTION(socket_sendmsg) +{ + zval *zsocket, + *zmsg; + long flags = 0; + php_socket *php_sock; + struct msghdr *msghdr; + zend_llist *allocations; + struct err_s err = {0}; + ssize_t res; + + /* zmsg should be passed by ref */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra|l", &zsocket, &zmsg, &flags) == FAILURE) { + return; + } + + LONG_CHECK_VALID_INT(flags); + + ZEND_FETCH_RESOURCE(php_sock, php_socket *, &zsocket, -1, + php_sockets_le_socket_name, php_sockets_le_socket()); + + msghdr = from_zval_run_conversions(zmsg, php_sock, from_zval_write_msghdr_send, + sizeof(*msghdr), "msghdr", &allocations, &err); + + if (err.has_error) { + err_msg_dispose(&err TSRMLS_CC); + RETURN_FALSE; + } + + res = sendmsg(php_sock->bsd_socket, msghdr, (int)flags); + + if (res != -1) { + zend_llist_destroy(allocations); + efree(allocations); + + RETURN_LONG((long)res); + } else { + PHP_SOCKET_ERROR(php_sock, "error in sendmsg", errno); + RETURN_FALSE; + } +} + +PHP_FUNCTION(socket_recvmsg) +{ + zval *zsocket, + *zmsg; + long flags = 0; + php_socket *php_sock; + ssize_t res; + struct msghdr *msghdr; + zend_llist *allocations; + struct err_s err = {0}; + + //ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra|l", + &zsocket, &zmsg, &flags) == FAILURE) { + return; + } + + LONG_CHECK_VALID_INT(flags); + + ZEND_FETCH_RESOURCE(php_sock, php_socket *, &zsocket, -1, + php_sockets_le_socket_name, php_sockets_le_socket()); + + msghdr = from_zval_run_conversions(zmsg, php_sock, from_zval_write_msghdr_recv, + sizeof(*msghdr), "msghdr", &allocations, &err); + + if (err.has_error) { + err_msg_dispose(&err TSRMLS_CC); + RETURN_FALSE; + } + + res = recvmsg(php_sock->bsd_socket, msghdr, (int)flags); + + if (res != -1) { + zval *zres; + struct key_value kv[] = { + {KEY_RECVMSG_RET, sizeof(KEY_RECVMSG_RET), &res}, + {0} + }; + + + zres = to_zval_run_conversions((char *)msghdr, to_zval_read_msghdr, + "msghdr", kv, &err); + + /* we don;t need msghdr anymore; free it */ + msghdr = NULL; + allocations_dispose(&allocations); + + zval_dtor(zmsg); + if (!err.has_error) { + ZVAL_COPY_VALUE(zmsg, zres); + efree(zres); /* only shallow destruction */ + } else { + err_msg_dispose(&err TSRMLS_CC); + ZVAL_FALSE(zmsg); + /* no need to destroy/free zres -- it's NULL in this circumstance */ + assert(zres == NULL); + } + } else { + SOCKETS_G(last_error) = errno; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "error in recvmsg [%d]: %s", + errno, sockets_strerror(errno TSRMLS_CC)); + RETURN_FALSE; + } + + RETURN_LONG((long)res); +} + +PHP_FUNCTION(socket_cmsg_space) +{ + long level, + type, + n = 0; + ancillary_reg_entry *entry; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|l", + &level, &type, &n) == FAILURE) { + return; + } + + LONG_CHECK_VALID_INT(level); + LONG_CHECK_VALID_INT(type); + LONG_CHECK_VALID_INT(n); + + if (n < 0) { + php_error_docref0(NULL TSRMLS_CC, E_WARNING, "The third argument " + "cannot be negative"); + return; + } + + entry = get_ancillary_reg_entry(level, type); + if (entry == NULL) { + php_error_docref0(NULL TSRMLS_CC, E_WARNING, "The pair level %ld/type %ld is " + "not supported by PHP", level, type); + return; + } + + if (entry->var_el_size > 0 && n > (LONG_MAX - (long)entry->size - + (long)CMSG_SPACE(0) - 15L) / entry->var_el_size) { + /* the -15 is to account for any padding CMSG_SPACE may add after the data */ + php_error_docref0(NULL TSRMLS_CC, E_WARNING, "The value for the " + "third argument (%ld) is too large", n); + return; + } + + RETURN_LONG((long)CMSG_SPACE(entry->size + n * entry->var_el_size)); +} + +int php_do_setsockopt_ipv6_rfc3542(php_socket *php_sock, int level, int optname, zval **arg4 TSRMLS_DC) +{ + struct err_s err = {0}; + zend_llist *allocations = NULL; + void *opt_ptr; + socklen_t optlen; + int retval; + + assert(level == IPPROTO_IPV6); + + switch (optname) { +#ifdef IPV6_PKTINFO + case IPV6_PKTINFO: +#ifdef PHP_WIN32 + if (Z_TYPE_PP(arg4) == IS_ARRAY) { + php_error_docref0(NULL TSRMLS_CC, E_WARNING, "Windows does not " + "support sticky IPV6_PKTINFO"); + return FAILURE; + } else { + /* windows has no IPV6_RECVPKTINFO, and uses IPV6_PKTINFO + * for the same effect. We define IPV6_RECVPKTINFO to be + * IPV6_PKTINFO, so assume the assume user used IPV6_RECVPKTINFO */ + return 1; + } +#endif + opt_ptr = from_zval_run_conversions(*arg4, php_sock, from_zval_write_in6_pktinfo, + sizeof(struct in6_pktinfo), "in6_pktinfo", &allocations, &err); + if (err.has_error) { + err_msg_dispose(&err TSRMLS_CC); + return FAILURE; + } + + optlen = sizeof(struct in6_pktinfo); + goto dosockopt; +#endif + } + + /* we also support IPV6_TCLASS, but that can be handled by the default + * integer optval handling in the caller */ + return 1; + +dosockopt: + retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen); + if (retval != 0) { + PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno); + } + allocations_dispose(&allocations); + + return retval != 0 ? FAILURE : SUCCESS; +} + +int php_do_getsockopt_ipv6_rfc3542(php_socket *php_sock, int level, int optname, zval *result TSRMLS_DC) +{ + struct err_s err = {0}; + void *buffer; + socklen_t size; + int res; + to_zval_read_field *reader; + + assert(level == IPPROTO_IPV6); + + switch (optname) { +#ifdef IPV6_PKTINFO + case IPV6_PKTINFO: + size = sizeof(struct in6_pktinfo); + reader = &to_zval_read_in6_pktinfo; + break; +#endif + default: + return 1; + } + + buffer = ecalloc(1, size); + res = getsockopt(php_sock->bsd_socket, level, optname, buffer, &size); + if (res != 0) { + PHP_SOCKET_ERROR(php_sock, "unable to get socket option", errno); + } else { + zval *zv = to_zval_run_conversions(buffer, reader, "in6_pktinfo", + empty_key_value_list, &err); + if (err.has_error) { + err_msg_dispose(&err TSRMLS_CC); + res = -1; + } else { + ZVAL_COPY_VALUE(result, zv); + efree(zv); + } + } + efree(buffer); + + return res == 0 ? SUCCESS : FAILURE; +} + +void php_socket_sendrecvmsg_init(INIT_FUNC_ARGS) +{ + /* IPv6 ancillary data */ +#ifdef IPV6_RECVPKTINFO + REGISTER_LONG_CONSTANT("IPV6_RECVPKTINFO", IPV6_RECVPKTINFO, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("IPV6_PKTINFO", IPV6_PKTINFO, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef IPV6_RECVHOPLIMIT + REGISTER_LONG_CONSTANT("IPV6_RECVHOPLIMIT", IPV6_RECVHOPLIMIT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("IPV6_HOPLIMIT", IPV6_HOPLIMIT, CONST_CS | CONST_PERSISTENT); +#endif + /* would require some effort: + REGISTER_LONG_CONSTANT("IPV6_RECVRTHDR", IPV6_RECVRTHDR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("IPV6_RECVHOPOPTS", IPV6_RECVHOPOPTS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("IPV6_RECVDSTOPTS", IPV6_RECVDSTOPTS, CONST_CS | CONST_PERSISTENT); + */ +#ifdef IPV6_RECVTCLASS + REGISTER_LONG_CONSTANT("IPV6_RECVTCLASS", IPV6_RECVTCLASS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("IPV6_TCLASS", IPV6_TCLASS, CONST_CS | CONST_PERSISTENT); +#endif + + /* + REGISTER_LONG_CONSTANT("IPV6_RTHDR", IPV6_RTHDR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("IPV6_HOPOPTS", IPV6_HOPOPTS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("IPV6_DSTOPTS", IPV6_DSTOPTS, CONST_CS | CONST_PERSISTENT); + */ + +#ifdef SCM_RIGHTS + REGISTER_LONG_CONSTANT("SCM_RIGHTS", SCM_RIGHTS, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef SO_PASSCRED + REGISTER_LONG_CONSTANT("SCM_CREDENTIALS", SCM_CREDENTIALS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SO_PASSCRED", SO_PASSCRED, CONST_CS | CONST_PERSISTENT); +#endif + +#ifdef ZTS + ancillary_mutex = tsrm_mutex_alloc(); +#endif +} + +void php_socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS) +{ +#ifdef ZTS + tsrm_mutex_free(ancillary_mutex); +#endif + + destroy_ancillary_registry(); +} diff --git a/ext/sockets/sendrecvmsg.h b/ext/sockets/sendrecvmsg.h new file mode 100644 index 0000000000000..5a3798274fd7e --- /dev/null +++ b/ext/sockets/sendrecvmsg.h @@ -0,0 +1,36 @@ +#ifndef PHP_SENDRECVMSG_H +#define PHP_SENDRECVMSG_H 1 + +#include +#include "conversions.h" + +/* for sockets.c */ +PHP_FUNCTION(socket_sendmsg); +PHP_FUNCTION(socket_recvmsg); +PHP_FUNCTION(socket_cmsg_space); + +void php_socket_sendrecvmsg_init(INIT_FUNC_ARGS); +void php_socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS); + +int php_do_setsockopt_ipv6_rfc3542(php_socket *php_sock, int level, int optname, zval **arg4 TSRMLS_DC); +int php_do_getsockopt_ipv6_rfc3542(php_socket *php_sock, int level, int optname, zval *result TSRMLS_DC); + +/* for conversions.c */ +typedef struct { + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol-specific type */ +} anc_reg_key; + +typedef size_t (calculate_req_space)(const zval *value, ser_context *ctx); + +typedef struct { + socklen_t size; /* size of native structure */ + socklen_t var_el_size; /* size of repeatable component */ + calculate_req_space *calc_space; + from_zval_write_field *from_array; + to_zval_read_field *to_array; +} ancillary_reg_entry; + +ancillary_reg_entry *get_ancillary_reg_entry(int cmsg_level, int msg_type); + +#endif diff --git a/ext/sockets/sockaddr_conv.c b/ext/sockets/sockaddr_conv.c new file mode 100644 index 0000000000000..a40b6b4936cbb --- /dev/null +++ b/ext/sockets/sockaddr_conv.c @@ -0,0 +1,119 @@ +#include +#include +#include "php_sockets.h" + +#ifdef PHP_WIN32 +#include "windows_common.h" +#else +#include +#include +#endif + +#if HAVE_IPV6 +/* Sets addr by hostname, or by ip in string form (AF_INET6) */ +int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_sock TSRMLS_DC) /* {{{ */ +{ + struct in6_addr tmp; +#if HAVE_GETADDRINFO + struct addrinfo hints; + struct addrinfo *addrinfo = NULL; +#endif + + if (inet_pton(AF_INET6, string, &tmp)) { + memcpy(&(sin6->sin6_addr.s6_addr), &(tmp.s6_addr), sizeof(struct in6_addr)); + } else { +#if HAVE_GETADDRINFO + + memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = AF_INET6; + hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG; + getaddrinfo(string, NULL, &hints, &addrinfo); + if (!addrinfo) { +#ifdef PHP_WIN32 + PHP_SOCKET_ERROR(php_sock, "Host lookup failed", WSAGetLastError()); +#else + PHP_SOCKET_ERROR(php_sock, "Host lookup failed", (-10000 - h_errno)); +#endif + return 0; + } + if (addrinfo->ai_family != PF_INET6 || addrinfo->ai_addrlen != sizeof(struct sockaddr_in6)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host lookup failed: Non AF_INET6 domain returned on AF_INET6 socket"); + freeaddrinfo(addrinfo); + return 0; + } + + memcpy(&(sin6->sin6_addr.s6_addr), ((struct sockaddr_in6*)(addrinfo->ai_addr))->sin6_addr.s6_addr, sizeof(struct in6_addr)); + freeaddrinfo(addrinfo); + +#else + /* No IPv6 specific hostname resolution is available on this system? */ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host lookup failed: getaddrinfo() not available on this system"); + return 0; +#endif + + } + + return 1; +} +/* }}} */ +#endif + +/* Sets addr by hostname, or by ip in string form (AF_INET) */ +int php_set_inet_addr(struct sockaddr_in *sin, char *string, php_socket *php_sock TSRMLS_DC) /* {{{ */ +{ + struct in_addr tmp; + struct hostent *host_entry; + + if (inet_aton(string, &tmp)) { + sin->sin_addr.s_addr = tmp.s_addr; + } else { + if (! (host_entry = gethostbyname(string))) { + /* Note: < -10000 indicates a host lookup error */ +#ifdef PHP_WIN32 + PHP_SOCKET_ERROR(php_sock, "Host lookup failed", WSAGetLastError()); +#else + PHP_SOCKET_ERROR(php_sock, "Host lookup failed", (-10000 - h_errno)); +#endif + return 0; + } + if (host_entry->h_addrtype != AF_INET) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host lookup failed: Non AF_INET domain returned on AF_INET socket"); + return 0; + } + memcpy(&(sin->sin_addr.s_addr), host_entry->h_addr_list[0], host_entry->h_length); + } + + return 1; +} +/* }}} */ + +/* Sets addr by hostname or by ip in string form (AF_INET or AF_INET6, + * depending on the socket) */ +int php_set_inet46_addr(php_sockaddr_storage *ss, socklen_t *ss_len, char *string, php_socket *php_sock TSRMLS_DC) /* {{{ */ +{ + if (php_sock->type == AF_INET) { + struct sockaddr_in t = {0}; + if (php_set_inet_addr(&t, string, php_sock TSRMLS_CC)) { + memcpy(ss, &t, sizeof t); + ss->ss_family = AF_INET; + *ss_len = sizeof(t); + return 1; + } + } +#if HAVE_IPV6 + else if (php_sock->type == AF_INET6) { + struct sockaddr_in6 t = {0}; + if (php_set_inet6_addr(&t, string, php_sock TSRMLS_CC)) { + memcpy(ss, &t, sizeof t); + ss->ss_family = AF_INET6; + *ss_len = sizeof(t); + return 1; + } + } +#endif + else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "IP address used in the context of an unexpected type of socket"); + } + return 0; +} diff --git a/ext/sockets/sockaddr_conv.h b/ext/sockets/sockaddr_conv.h new file mode 100644 index 0000000000000..8e51edac8f874 --- /dev/null +++ b/ext/sockets/sockaddr_conv.h @@ -0,0 +1,31 @@ +#ifndef PHP_SOCKADR_CONV_H +#define PHP_SOCKADR_CONV_H + +#include +#include "php_sockets.h" /* php_socket */ + +#ifndef PHP_WIN32 +# include +#else +# include +#endif + + +/* + * Convert an IPv6 literal or a hostname info a sockaddr_in6. + * The IPv6 literal can be a IPv4 mapped address (like ::ffff:127.0.0.1). + * If the hostname yields no IPv6 addresses, a mapped IPv4 address may be returned (AI_V4MAPPED) + */ +int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_sock TSRMLS_DC); + +/* + * Convert an IPv4 literal or a hostname into a sockaddr_in. + */ +int php_set_inet_addr(struct sockaddr_in *sin, char *string, php_socket *php_sock TSRMLS_DC); + +/* + * Calls either php_set_inet6_addr() or php_set_inet_addr(), depending on the type of the socket. + */ +int php_set_inet46_addr(php_sockaddr_storage *ss, socklen_t *ss_len, char *string, php_socket *php_sock TSRMLS_DC); + +#endif diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 06bd0ec6b4fec..5636cd3cdc9d1 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -35,31 +35,12 @@ #include "ext/standard/info.h" #include "php_ini.h" #ifdef PHP_WIN32 -# include "win32/inet.h" -# include +# include "windows_common.h" +# include # include # include # include "php_sockets.h" -# include "win32/sockets.h" -# define IS_INVALID_SOCKET(a) (a->bsd_socket == INVALID_SOCKET) -# ifdef EPROTONOSUPPORT -# undef EPROTONOSUPPORT -# endif -# ifdef ECONNRESET -# undef ECONNRESET -# endif -# define EPROTONOSUPPORT WSAEPROTONOSUPPORT -# define ECONNRESET WSAECONNRESET -# ifdef errno -# undef errno -# endif -# define errno WSAGetLastError() -# define h_errno WSAGetLastError() -# define set_errno(a) WSASetLastError(a) -# define close(a) closesocket(a) -# if _WIN32_WINNT >= 0x0600 && SOCKETS_ENABLE_VISTA_API -# define HAVE_IF_NAMETOINDEX 1 -# endif +# include #else # include # include @@ -85,7 +66,9 @@ # endif #endif +#include "sockaddr_conv.h" #include "multicast.h" +#include "sendrecvmsg.h" ZEND_DECLARE_MODULE_GLOBALS(sockets) static PHP_GINIT_FUNCTION(sockets); @@ -112,16 +95,6 @@ static PHP_GINIT_FUNCTION(sockets); #define PF_INET AF_INET #endif -static char *php_strerror(int error TSRMLS_DC); - -#define PHP_SOCKET_ERROR(socket, msg, errn) \ - do { \ - int _err = (errn); /* save value to avoid repeated calls to WSAGetLastError() on Windows */ \ - (socket)->error = _err; \ - SOCKETS_G(last_error) = _err; \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s [%d]: %s", msg, _err, php_strerror(_err TSRMLS_CC)); \ - } while (0) - #define PHP_NORMAL_READ 0x0001 #define PHP_BINARY_READ 0x0002 @@ -277,10 +250,27 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_clear_error, 0, 0, 0) ZEND_ARG_INFO(0, socket) ZEND_END_ARG_INFO() - + ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_import_stream, 0, 0, 1) ZEND_ARG_INFO(0, stream) ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_sendmsg, 0, 0, 3) + ZEND_ARG_INFO(0, socket) + ZEND_ARG_INFO(0, msghdr) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_recvmsg, 0, 0, 3) + ZEND_ARG_INFO(0, socket) + ZEND_ARG_INFO(1, msghdr) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_cmsg_space, 0, 0, 2) + ZEND_ARG_INFO(0, level) + ZEND_ARG_INFO(0, type) +ZEND_END_ARG_INFO() /* }}} */ PHP_MINIT_FUNCTION(sockets); @@ -351,6 +341,9 @@ const zend_function_entry sockets_functions[] = { PHP_FE(socket_last_error, arginfo_socket_last_error) PHP_FE(socket_clear_error, arginfo_socket_clear_error) PHP_FE(socket_import_stream, arginfo_socket_import_stream) + PHP_FE(socket_sendmsg, arginfo_socket_sendmsg) + PHP_FE(socket_recvmsg, arginfo_socket_recvmsg) + PHP_FE(socket_cmsg_space, arginfo_socket_cmsg_space) /* for downwards compatability */ PHP_FALIAS(socket_getopt, socket_get_option, arginfo_socket_get_option) @@ -396,13 +389,13 @@ PHP_SOCKETS_API int php_sockets_le_socket(void) /* {{{ */ static php_socket *php_create_socket(void) /* {{{ */ { php_socket *php_sock = emalloc(sizeof *php_sock); - + php_sock->bsd_socket = -1; /* invalid socket */ php_sock->type = PF_UNSPEC; php_sock->error = 0; php_sock->blocking = 1; php_sock->zstream = NULL; - + return php_sock; } /* }}} */ @@ -559,7 +552,7 @@ static int php_read(php_socket *sock, void *buf, size_t maxlen, int flags) } /* }}} */ -static char *php_strerror(int error TSRMLS_DC) /* {{{ */ +char *sockets_strerror(int error TSRMLS_DC) /* {{{ */ { const char *buf; @@ -606,188 +599,6 @@ static char *php_strerror(int error TSRMLS_DC) /* {{{ */ } /* }}} */ -#if HAVE_IPV6 -/* Sets addr by hostname, or by ip in string form (AF_INET6) */ -static int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_sock TSRMLS_DC) /* {{{ */ -{ - struct in6_addr tmp; -#if HAVE_GETADDRINFO - struct addrinfo hints; - struct addrinfo *addrinfo = NULL; -#endif - - if (inet_pton(AF_INET6, string, &tmp)) { - memcpy(&(sin6->sin6_addr.s6_addr), &(tmp.s6_addr), sizeof(struct in6_addr)); - } else { -#if HAVE_GETADDRINFO - - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = PF_INET6; - getaddrinfo(string, NULL, &hints, &addrinfo); - if (!addrinfo) { -#ifdef PHP_WIN32 - PHP_SOCKET_ERROR(php_sock, "Host lookup failed", WSAGetLastError()); -#else - PHP_SOCKET_ERROR(php_sock, "Host lookup failed", (-10000 - h_errno)); -#endif - return 0; - } - if (addrinfo->ai_family != PF_INET6 || addrinfo->ai_addrlen != sizeof(struct sockaddr_in6)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host lookup failed: Non AF_INET6 domain returned on AF_INET6 socket"); - freeaddrinfo(addrinfo); - return 0; - } - - memcpy(&(sin6->sin6_addr.s6_addr), ((struct sockaddr_in6*)(addrinfo->ai_addr))->sin6_addr.s6_addr, sizeof(struct in6_addr)); - freeaddrinfo(addrinfo); - -#else - /* No IPv6 specific hostname resolution is available on this system? */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host lookup failed: getaddrinfo() not available on this system"); - return 0; -#endif - - } - - return 1; -} -/* }}} */ -#endif - -/* Sets addr by hostname, or by ip in string form (AF_INET) */ -static int php_set_inet_addr(struct sockaddr_in *sin, char *string, php_socket *php_sock TSRMLS_DC) /* {{{ */ -{ - struct in_addr tmp; - struct hostent *host_entry; - - if (inet_aton(string, &tmp)) { - sin->sin_addr.s_addr = tmp.s_addr; - } else { - if (! (host_entry = gethostbyname(string))) { - /* Note: < -10000 indicates a host lookup error */ -#ifdef PHP_WIN32 - PHP_SOCKET_ERROR(php_sock, "Host lookup failed", WSAGetLastError()); -#else - PHP_SOCKET_ERROR(php_sock, "Host lookup failed", (-10000 - h_errno)); -#endif - return 0; - } - if (host_entry->h_addrtype != AF_INET) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host lookup failed: Non AF_INET domain returned on AF_INET socket"); - return 0; - } - memcpy(&(sin->sin_addr.s_addr), host_entry->h_addr_list[0], host_entry->h_length); - } - - return 1; -} -/* }}} */ - -/* Sets addr by hostname or by ip in string form (AF_INET or AF_INET6, - * depending on the socket) */ -static int php_set_inet46_addr(php_sockaddr_storage *ss, socklen_t *ss_len, char *string, php_socket *php_sock TSRMLS_DC) /* {{{ */ -{ - if (php_sock->type == AF_INET) { - struct sockaddr_in t = {0}; - if (php_set_inet_addr(&t, string, php_sock TSRMLS_CC)) { - memcpy(ss, &t, sizeof t); - ss->ss_family = AF_INET; - *ss_len = sizeof(t); - return 1; - } - } -#if HAVE_IPV6 - else if (php_sock->type == AF_INET6) { - struct sockaddr_in6 t = {0}; - if (php_set_inet6_addr(&t, string, php_sock TSRMLS_CC)) { - memcpy(ss, &t, sizeof t); - ss->ss_family = AF_INET6; - *ss_len = sizeof(t); - return 1; - } - } -#endif - else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "IP address used in the context of an unexpected type of socket"); - } - return 0; -} - -static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC) -{ - int ret; - - if (Z_TYPE_P(val) == IS_LONG) { - if (Z_LVAL_P(val) < 0 || Z_LVAL_P(val) > UINT_MAX) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "the interface index cannot be negative or larger than %u;" - " given %ld", UINT_MAX, Z_LVAL_P(val)); - ret = FAILURE; - } else { - *out = Z_LVAL_P(val); - ret = SUCCESS; - } - } else { -#if HAVE_IF_NAMETOINDEX - unsigned int ind; - zval_add_ref(&val); - convert_to_string_ex(&val); - ind = if_nametoindex(Z_STRVAL_P(val)); - if (ind == 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "no interface with name \"%s\" could be found", Z_STRVAL_P(val)); - ret = FAILURE; - } else { - *out = ind; - ret = SUCCESS; - } - zval_ptr_dtor(&val); -#else - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "this platform does not support looking up an interface by " - "name, an integer interface index must be supplied instead"); - ret = FAILURE; -#endif - } - - return ret; -} - -static int php_get_if_index_from_array(const HashTable *ht, const char *key, - php_socket *sock, unsigned int *if_index TSRMLS_DC) -{ - zval **val; - - if (zend_hash_find(ht, key, strlen(key) + 1, (void **)&val) == FAILURE) { - *if_index = 0; /* default: 0 */ - return SUCCESS; - } - - return php_get_if_index_from_zval(*val, if_index TSRMLS_CC); -} - -static int php_get_address_from_array(const HashTable *ht, const char *key, - php_socket *sock, php_sockaddr_storage *ss, socklen_t *ss_len TSRMLS_DC) -{ - zval **val, - *valcp; - - if (zend_hash_find(ht, key, strlen(key) + 1, (void **)&val) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "no key \"%s\" passed in optval", key); - return FAILURE; - } - valcp = *val; - zval_add_ref(&valcp); - convert_to_string_ex(val); - if (!php_set_inet46_addr(ss, ss_len, Z_STRVAL_P(valcp), sock TSRMLS_CC)) { - zval_ptr_dtor(&valcp); - return FAILURE; - } - zval_ptr_dtor(&valcp); - return SUCCESS; -} - /* {{{ PHP_GINIT_FUNCTION */ static PHP_GINIT_FUNCTION(sockets) { @@ -812,11 +623,11 @@ PHP_MINIT_FUNCTION(sockets) REGISTER_LONG_CONSTANT("SOCK_RAW", SOCK_RAW, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOCK_SEQPACKET",SOCK_SEQPACKET, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOCK_RDM", SOCK_RDM, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MSG_OOB", MSG_OOB, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MSG_WAITALL", MSG_WAITALL, CONST_CS | CONST_PERSISTENT); -#ifdef MSG_DONTWAIT - REGISTER_LONG_CONSTANT("MSG_DONTWAIT", MSG_DONTWAIT, CONST_CS | CONST_PERSISTENT); -#endif + REGISTER_LONG_CONSTANT("MSG_CTRUNC", MSG_CTRUNC, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MSG_TRUNC", MSG_TRUNC, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MSG_PEEK", MSG_PEEK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MSG_DONTROUTE", MSG_DONTROUTE, CONST_CS | CONST_PERSISTENT); #ifdef MSG_EOR @@ -825,6 +636,29 @@ PHP_MINIT_FUNCTION(sockets) #ifdef MSG_EOF REGISTER_LONG_CONSTANT("MSG_EOF", MSG_EOF, CONST_CS | CONST_PERSISTENT); #endif + +#ifdef MSG_CONFIRM + REGISTER_LONG_CONSTANT("MSG_CONFIRM", MSG_CONFIRM, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_ERRQUEUE + REGISTER_LONG_CONSTANT("MSG_ERRQUEUE", MSG_ERRQUEUE, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_NOSIGNAL + REGISTER_LONG_CONSTANT("MSG_NOSIGNAL", MSG_NOSIGNAL, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_DONTWAIT + REGISTER_LONG_CONSTANT("MSG_DONTWAIT", MSG_DONTWAIT, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_MORE + REGISTER_LONG_CONSTANT("MSG_MORE", MSG_MORE, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_WAITFORONE + REGISTER_LONG_CONSTANT("MSG_WAITFORONE",MSG_WAITFORONE, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_CMSG_CLOEXEC + REGISTER_LONG_CONSTANT("MSG_CMSG_CLOEXEC",MSG_CMSG_CLOEXEC,CONST_CS | CONST_PERSISTENT); +#endif + REGISTER_LONG_CONSTANT("SO_DEBUG", SO_DEBUG, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SO_REUSEADDR", SO_REUSEADDR, CONST_CS | CONST_PERSISTENT); #ifdef SO_REUSEPORT @@ -842,6 +676,9 @@ PHP_MINIT_FUNCTION(sockets) REGISTER_LONG_CONSTANT("SO_SNDTIMEO", SO_SNDTIMEO, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SO_RCVTIMEO", SO_RCVTIMEO, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SO_TYPE", SO_TYPE, CONST_CS | CONST_PERSISTENT); +#ifdef SO_FAMILY + REGISTER_LONG_CONSTANT("SO_FAMILY", SO_FAMILY, CONST_CS | CONST_PERSISTENT); +#endif REGISTER_LONG_CONSTANT("SO_ERROR", SO_ERROR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOL_SOCKET", SOL_SOCKET, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOMAXCONN", SOMAXCONN, CONST_CS | CONST_PERSISTENT); @@ -861,7 +698,7 @@ PHP_MINIT_FUNCTION(sockets) #define MCAST_LEAVE_SOURCE_GROUP IP_DROP_SOURCE_MEMBERSHIP #endif #endif - + REGISTER_LONG_CONSTANT("MCAST_JOIN_GROUP", MCAST_JOIN_GROUP, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MCAST_LEAVE_GROUP", MCAST_LEAVE_GROUP, CONST_CS | CONST_PERSISTENT); #ifdef HAS_MCAST_EXT @@ -894,6 +731,12 @@ PHP_MINIT_FUNCTION(sockets) REGISTER_LONG_CONSTANT("SOL_TCP", IPPROTO_TCP, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOL_UDP", IPPROTO_UDP, CONST_CS | CONST_PERSISTENT); +#if HAVE_IPV6 + REGISTER_LONG_CONSTANT("IPV6_UNICAST_HOPS", IPV6_UNICAST_HOPS, CONST_CS | CONST_PERSISTENT); +#endif + + php_socket_sendrecvmsg_init(INIT_FUNC_ARGS_PASSTHRU); + return SUCCESS; } /* }}} */ @@ -915,6 +758,7 @@ PHP_RSHUTDOWN_FUNCTION(sockets) efree(SOCKETS_G(strerror_buf)); SOCKETS_G(strerror_buf) = NULL; } + php_socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS_PASSTHRU); return SUCCESS; } @@ -1056,7 +900,7 @@ PHP_FUNCTION(socket_select) if (retval == -1) { SOCKETS_G(last_error) = errno; - php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to select [%d]: %s", errno, php_strerror(errno TSRMLS_CC)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to select [%d]: %s", errno, sockets_strerror(errno TSRMLS_CC)); RETURN_FALSE; } @@ -1125,7 +969,7 @@ PHP_FUNCTION(socket_set_nonblock) } ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket); - + if (php_sock->zstream != NULL) { php_stream *stream; /* omit notice if resource doesn't exist anymore */ @@ -1162,7 +1006,7 @@ PHP_FUNCTION(socket_set_block) } ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket); - + /* if socket was created from a stream, give the stream a chance to take * care of the operation itself, thereby allowing it to update its internal * state */ @@ -1516,7 +1360,7 @@ PHP_FUNCTION(socket_create) if (IS_INVALID_SOCKET(php_sock)) { SOCKETS_G(last_error) = errno; - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create socket [%d]: %s", errno, php_strerror(errno TSRMLS_CC)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create socket [%d]: %s", errno, sockets_strerror(errno TSRMLS_CC)); efree(php_sock); RETURN_FALSE; } @@ -1549,7 +1393,7 @@ PHP_FUNCTION(socket_connect) #if HAVE_IPV6 case AF_INET6: { struct sockaddr_in6 sin6 = {0}; - + if (argc != 3) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Socket of type AF_INET6 requires 3 arguments"); RETURN_FALSE; @@ -1570,7 +1414,7 @@ PHP_FUNCTION(socket_connect) #endif case AF_INET: { struct sockaddr_in sin = {0}; - + if (argc != 3) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Socket of type AF_INET requires 3 arguments"); RETURN_FALSE; @@ -1589,7 +1433,7 @@ PHP_FUNCTION(socket_connect) case AF_UNIX: { struct sockaddr_un s_un = {0}; - + if (addr_len >= sizeof(s_un.sun_path)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Path too long"); RETURN_FALSE; @@ -1626,7 +1470,7 @@ PHP_FUNCTION(socket_strerror) return; } - RETURN_STRING(php_strerror(arg1 TSRMLS_CC), 1); + RETURN_STRING(sockets_strerror(arg1 TSRMLS_CC), 1); } /* }}} */ @@ -2017,8 +1861,15 @@ PHP_FUNCTION(socket_get_option) } } } + } else if (level == IPPROTO_IPV6) { + int ret = php_do_getsockopt_ipv6_rfc3542(php_sock, level, optname, return_value TSRMLS_CC); + if (ret == SUCCESS) { + return; + } else if (ret == FAILURE) { + RETURN_FALSE; + } /* else continue */ } - + /* sol_socket options and general case */ switch(optname) { case SO_LINGER: @@ -2060,7 +1911,7 @@ PHP_FUNCTION(socket_get_option) add_assoc_long(return_value, "sec", tv.tv_sec); add_assoc_long(return_value, "usec", tv.tv_usec); break; - + default: optlen = sizeof(other_val); @@ -2077,102 +1928,6 @@ PHP_FUNCTION(socket_get_option) } /* }}} */ -static int php_do_mcast_opt(php_socket *php_sock, int level, int optname, zval **arg4 TSRMLS_DC) -{ - HashTable *opt_ht; - unsigned int if_index; - int retval; - int (*mcast_req_fun)(php_socket *, int, struct sockaddr *, socklen_t, - unsigned TSRMLS_DC); -#ifdef HAS_MCAST_EXT - int (*mcast_sreq_fun)(php_socket *, int, struct sockaddr *, socklen_t, - struct sockaddr *, socklen_t, unsigned TSRMLS_DC); -#endif - - switch (optname) { - case MCAST_JOIN_GROUP: - mcast_req_fun = &php_mcast_join; - goto mcast_req_fun; - case MCAST_LEAVE_GROUP: - { - php_sockaddr_storage group = {0}; - socklen_t glen; - - mcast_req_fun = &php_mcast_leave; -mcast_req_fun: - convert_to_array_ex(arg4); - opt_ht = HASH_OF(*arg4); - - if (php_get_address_from_array(opt_ht, "group", php_sock, &group, - &glen TSRMLS_CC) == FAILURE) { - return FAILURE; - } - if (php_get_if_index_from_array(opt_ht, "interface", php_sock, - &if_index TSRMLS_CC) == FAILURE) { - return FAILURE; - } - - retval = mcast_req_fun(php_sock, level, (struct sockaddr*)&group, - glen, if_index TSRMLS_CC); - break; - } - -#ifdef HAS_MCAST_EXT - case MCAST_BLOCK_SOURCE: - mcast_sreq_fun = &php_mcast_block_source; - goto mcast_sreq_fun; - case MCAST_UNBLOCK_SOURCE: - mcast_sreq_fun = &php_mcast_unblock_source; - goto mcast_sreq_fun; - case MCAST_JOIN_SOURCE_GROUP: - mcast_sreq_fun = &php_mcast_join_source; - goto mcast_sreq_fun; - case MCAST_LEAVE_SOURCE_GROUP: - { - php_sockaddr_storage group = {0}, - source = {0}; - socklen_t glen, - slen; - - mcast_sreq_fun = &php_mcast_leave_source; - mcast_sreq_fun: - convert_to_array_ex(arg4); - opt_ht = HASH_OF(*arg4); - - if (php_get_address_from_array(opt_ht, "group", php_sock, &group, - &glen TSRMLS_CC) == FAILURE) { - return FAILURE; - } - if (php_get_address_from_array(opt_ht, "source", php_sock, &source, - &slen TSRMLS_CC) == FAILURE) { - return FAILURE; - } - if (php_get_if_index_from_array(opt_ht, "interface", php_sock, - &if_index TSRMLS_CC) == FAILURE) { - return FAILURE; - } - - retval = mcast_sreq_fun(php_sock, level, (struct sockaddr*)&group, - glen, (struct sockaddr*)&source, slen, if_index TSRMLS_CC); - break; - } -#endif - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "unexpected option in php_do_mcast_opt (level %d, option %d). " - "This is a bug.", level, optname); - return FAILURE; - } - - if (retval != 0) { - if (retval != -2) { /* error, but message already emitted */ - PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno); - } - return FAILURE; - } - return SUCCESS; -} - /* {{{ proto bool socket_set_option(resource socket, int level, int optname, int|array optval) Sets socket options for the socket */ PHP_FUNCTION(socket_set_option) @@ -2191,12 +1946,8 @@ PHP_FUNCTION(socket_set_option) HashTable *opt_ht; zval **l_onoff, **l_linger; zval **sec, **usec; - - /* Multicast */ - unsigned int if_index; - struct in_addr if_addr; - unsigned char ipv4_mcast_ttl_lback; - + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllZ", &arg1, &level, &optname, &arg4) == FAILURE) { return; } @@ -2205,94 +1956,26 @@ PHP_FUNCTION(socket_set_option) set_errno(0); - if (level == IPPROTO_IP) { - switch (optname) { - case MCAST_JOIN_GROUP: - case MCAST_LEAVE_GROUP: -#ifdef HAS_MCAST_EXT - case MCAST_BLOCK_SOURCE: - case MCAST_UNBLOCK_SOURCE: - case MCAST_JOIN_SOURCE_GROUP: - case MCAST_LEAVE_SOURCE_GROUP: -#endif - if (php_do_mcast_opt(php_sock, level, optname, arg4 TSRMLS_CC) == FAILURE) { - RETURN_FALSE; - } else { - RETURN_TRUE; - } +#define HANDLE_SUBCALL(res) \ + do { \ + if (res == 1) { goto default_case; } \ + else if (res == SUCCESS) { RETURN_TRUE; } \ + else { RETURN_FALSE; } \ + } while (0) - case IP_MULTICAST_IF: - if (php_get_if_index_from_zval(*arg4, &if_index TSRMLS_CC) == FAILURE) { - RETURN_FALSE; - } - if (php_if_index_to_addr4(if_index, php_sock, &if_addr TSRMLS_CC) == FAILURE) { - RETURN_FALSE; - } - opt_ptr = &if_addr; - optlen = sizeof(if_addr); - goto dosockopt; - - case IP_MULTICAST_LOOP: - convert_to_boolean_ex(arg4); - goto ipv4_loop_ttl; - case IP_MULTICAST_TTL: - convert_to_long_ex(arg4); - if (Z_LVAL_PP(arg4) < 0L || Z_LVAL_PP(arg4) > 255L) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "Expected a value between 0 and 255"); - RETURN_FALSE; - } -ipv4_loop_ttl: - ipv4_mcast_ttl_lback = (unsigned char) Z_LVAL_PP(arg4); - opt_ptr = &ipv4_mcast_ttl_lback; - optlen = sizeof(ipv4_mcast_ttl_lback); - goto dosockopt; - } + if (level == IPPROTO_IP) { + int res = php_do_setsockopt_ip_mcast(php_sock, level, optname, arg4 TSRMLS_CC); + HANDLE_SUBCALL(res); } #if HAVE_IPV6 else if (level == IPPROTO_IPV6) { - switch (optname) { - case MCAST_JOIN_GROUP: - case MCAST_LEAVE_GROUP: -#ifdef HAS_MCAST_EXT - case MCAST_BLOCK_SOURCE: - case MCAST_UNBLOCK_SOURCE: - case MCAST_JOIN_SOURCE_GROUP: - case MCAST_LEAVE_SOURCE_GROUP: -#endif - if (php_do_mcast_opt(php_sock, level, optname, arg4 TSRMLS_CC) == FAILURE) { - RETURN_FALSE; - } else { - RETURN_TRUE; - } - - case IPV6_MULTICAST_IF: - if (php_get_if_index_from_zval(*arg4, &if_index TSRMLS_CC) == FAILURE) { - RETURN_FALSE; - } - - opt_ptr = &if_index; - optlen = sizeof(if_index); - goto dosockopt; - - case IPV6_MULTICAST_LOOP: - convert_to_boolean_ex(arg4); - goto ipv6_loop_hops; - case IPV6_MULTICAST_HOPS: - convert_to_long_ex(arg4); - if (Z_LVAL_PP(arg4) < -1L || Z_LVAL_PP(arg4) > 255L) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "Expected a value between -1 and 255"); - RETURN_FALSE; - } -ipv6_loop_hops: - ov = (int) Z_LVAL_PP(arg4); - opt_ptr = &ov; - optlen = sizeof(ov); - goto dosockopt; + int res = php_do_setsockopt_ipv6_mcast(php_sock, level, optname, arg4 TSRMLS_CC); + if (res == 1) { + res = php_do_setsockopt_ipv6_rfc3542(php_sock, level, optname, arg4 TSRMLS_CC); } + HANDLE_SUBCALL(res); } #endif @@ -2355,8 +2038,9 @@ PHP_FUNCTION(socket_set_option) #endif break; } - + default: +default_case: convert_to_long_ex(arg4); ov = Z_LVAL_PP(arg4); @@ -2365,12 +2049,9 @@ PHP_FUNCTION(socket_set_option) break; } -dosockopt: retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen); if (retval != 0) { - if (retval != -2) { /* error, but message already emitted */ - PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno); - } + PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno); RETURN_FALSE; } @@ -2411,7 +2092,7 @@ PHP_FUNCTION(socket_create_pair) if (socketpair(domain, type, protocol, fds_array) != 0) { SOCKETS_G(last_error) = errno; - php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to create socket pair [%d]: %s", errno, php_strerror(errno TSRMLS_CC)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to create socket pair [%d]: %s", errno, sockets_strerror(errno TSRMLS_CC)); efree(php_sock[0]); efree(php_sock[1]); RETURN_FALSE; @@ -2510,6 +2191,53 @@ PHP_FUNCTION(socket_clear_error) } /* }}} */ +php_socket *socket_import_file_descriptor(PHP_SOCKET socket TSRMLS_DC) +{ +#ifdef SO_DOMAIN + int type; + socklen_t type_len = sizeof(type); +#endif + php_socket *retsock; + php_sockaddr_storage addr; + socklen_t addr_len = sizeof(addr); +#ifndef PHP_WIN32 + int t; +#endif + + retsock = php_create_socket(); + retsock->bsd_socket = socket; + + /* determine family */ +#ifdef SO_DOMAIN + if (getsockopt(socket, SOL_SOCKET, SO_DOMAIN, &type, &type_len) == 0) { + retsock->type = type; + } else +#endif + if (getsockname(socket, (struct sockaddr*)&addr, &addr_len) == 0) { + retsock->type = addr.ss_family; + } else { + PHP_SOCKET_ERROR(retsock, "unable to obtain socket family", errno); + goto error; + } + + /* determine blocking mode */ +#ifndef PHP_WIN32 + t = fcntl(socket, F_GETFL); + if (t == -1) { + PHP_SOCKET_ERROR(retsock, "unable to obtain blocking state", errno); + goto error; + } else { + retsock->blocking = !(t & O_NONBLOCK); + } +#endif + + return retsock; + +error: + efree(retsock); + return NULL; +} + /* {{{ proto void socket_import_stream(resource stream) Imports a stream that encapsulates a socket into a socket extension resource. */ PHP_FUNCTION(socket_import_stream) @@ -2518,44 +2246,23 @@ PHP_FUNCTION(socket_import_stream) php_stream *stream; php_socket *retsock = NULL; PHP_SOCKET socket; /* fd */ - php_sockaddr_storage addr; - socklen_t addr_len = sizeof(addr); -#ifndef PHP_WIN32 - int t; -#endif if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) { return; } php_stream_from_zval(stream, &zstream); - + if (php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void**)&socket, 1)) { /* error supposedly already shown */ RETURN_FALSE; } - - retsock = php_create_socket(); - - retsock->bsd_socket = socket; - - /* determine family */ - if (getsockname(socket, (struct sockaddr*)&addr, &addr_len) == 0) { - retsock->type = addr.ss_family; - } else { - PHP_SOCKET_ERROR(retsock, "unable to obtain socket family", errno); - goto error; - } - - /* determine blocking mode */ -#ifndef PHP_WIN32 - t = fcntl(socket, F_GETFL); - if(t == -1) { - PHP_SOCKET_ERROR(retsock, "unable to obtain blocking state", errno); - goto error; - } else { - retsock->blocking = !(t & O_NONBLOCK); + + retsock = socket_import_file_descriptor(socket TSRMLS_CC); + if (retsock == NULL) { + RETURN_FALSE; } -#else + +#ifdef PHP_WIN32 /* on windows, check if the stream is a socket stream and read its * private data; otherwise assume it's in non-blocking mode */ if (php_stream_is(stream, PHP_STREAM_IS_SOCKET)) { @@ -2565,7 +2272,7 @@ PHP_FUNCTION(socket_import_stream) retsock->blocking = 1; } #endif - + /* hold a zval reference to the stream (holding a php_stream* directly could * also be done, but this might be slightly better if in the future we want * to provide a socket_export_stream) */ @@ -2574,16 +2281,11 @@ PHP_FUNCTION(socket_import_stream) zval_copy_ctor(retsock->zstream); Z_UNSET_ISREF_P(retsock->zstream); Z_SET_REFCOUNT_P(retsock->zstream, 1); - + php_stream_set_option(stream, PHP_STREAM_OPTION_READ_BUFFER, PHP_STREAM_BUFFER_NONE, NULL); - + ZEND_REGISTER_RESOURCE(return_value, retsock, le_socket); - return; -error: - if (retsock != NULL) - efree(retsock); - RETURN_FALSE; } /* }}} */ diff --git a/ext/sockets/tests/mcast_ipv6_send.phpt b/ext/sockets/tests/mcast_ipv6_send.phpt index b8d38bf68f44e..f75bb09903cf9 100644 --- a/ext/sockets/tests/mcast_ipv6_send.phpt +++ b/ext/sockets/tests/mcast_ipv6_send.phpt @@ -9,8 +9,8 @@ if (!defined('IPPROTO_IPV6')) { die('skip IPv6 not available.'); } $level = IPPROTO_IPV6; -$s = socket_create($domain, SOCK_DGRAM, SOL_UDP) or die("skip Can not create socket"); -if (socket_set_option($s, $level, IP_MULTICAST_IF, 1) === false) { +$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP) or die("skip Can not create socket"); +if (socket_set_option($s, $level, IPV6_MULTICAST_IF, 1) === false) { die("skip interface 1 either doesn't exist or has no ipv6 address"); } --FILE-- diff --git a/ext/sockets/tests/socket_cmsg_credentials.phpt b/ext/sockets/tests/socket_cmsg_credentials.phpt new file mode 100644 index 0000000000000..6a1c23fa8c56f --- /dev/null +++ b/ext/sockets/tests/socket_cmsg_credentials.phpt @@ -0,0 +1,89 @@ +--TEST-- +recvmsg(): receive SCM_CREDENTIALS messages +--SKIPIF-- + ["test ", "thing", "\n"], +//], 0); +$r = socket_sendto($sends1, $msg = "dread", strlen($msg), 0, $path); +var_dump($r); +checktimeout($s, 500); + +$data = [ + "name" => [], + "buffer_size" => 2000, + "controllen" => socket_cmsg_space(SOL_SOCKET, SCM_CREDENTIALS) +]; +if (!socket_recvmsg($s, $data, 0)) die("recvmsg"); +print_r($data); + +$pid = getmypid(); +var_dump($data['control'][0]['data']['pid'] === $pid); + +--EXPECTF-- +creating send socket +resource(%d) of type (Socket) +creating receive socket +resource(%d) of type (Socket) +bool(true) +int(5) +Array +( + [name] => + [control] => Array + ( + [0] => Array + ( + [level] => %d + [type] => %d + [data] => Array + ( + [pid] => %d + [uid] => %d + [gid] => %d + ) + + ) + + ) + + [iov] => Array + ( + [0] => dread + ) + + [flags] => 0 +) +bool(true) diff --git a/ext/sockets/tests/socket_cmsg_rights.phpt b/ext/sockets/tests/socket_cmsg_rights.phpt new file mode 100644 index 0000000000000..8290f03880c4b --- /dev/null +++ b/ext/sockets/tests/socket_cmsg_rights.phpt @@ -0,0 +1,100 @@ +--TEST-- +recvmsg(): receive SCM_CREDENTIALS messages +--SKIPIF-- + [ "path" => $path ], + "iov" => ["test ", "thing", "\n"], + "control" => [ + [ + "level" => SOL_SOCKET, + "type" => SCM_RIGHTS, + "data" => [$sends1, STDIN, STDOUT, STDERR], + ] + ] +], 0); +var_dump($r); +checktimeout($s, 500); + +$data = [ + "name" => [], + "buffer_size" => 2000, + "controllen" => socket_cmsg_space(SOL_SOCKET, SCM_RIGHTS, 3) +]; +var_dump($data); +if (!socket_recvmsg($s, $data, 0)) die("recvmsg"); +print_r($data); +--EXPECTF-- +creating send socket +resource(%d) of type (Socket) +creating receive socket +resource(%d) of type (Socket) +bool(true) +int(11) +array(3) { + ["name"]=> + array(0) { + } + ["buffer_size"]=> + int(2000) + ["controllen"]=> + int(32) +} +Array +( + [name] => + [control] => Array + ( + [0] => Array + ( + [level] => %d + [type] => %d + [data] => Array + ( + [0] => Resource id #%d + [1] => Resource id #%d + [2] => Resource id #%d + ) + + ) + + ) + + [iov] => Array + ( + [0] => test thing + + ) + + [flags] => 0 +) diff --git a/ext/sockets/tests/socket_recvmsg.phpt b/ext/sockets/tests/socket_recvmsg.phpt new file mode 100644 index 0000000000000..30263a4fbd05e --- /dev/null +++ b/ext/sockets/tests/socket_recvmsg.phpt @@ -0,0 +1,86 @@ +--TEST-- +recvmsg(): basic test +--SKIPIF-- + ["family" => AF_INET6, "addr" => "::1"], + "buffer_size" => 2000, + "controllen" => socket_cmsg_space(IPPROTO_IPV6, IPV6_PKTINFO), +]; +if (!socket_recvmsg($s, $data, 0)) die("recvmsg"); +print_r($data); + +--EXPECTF-- +creating send socket +resource(%d) of type (Socket) +bool(true) +creating receive socket +resource(%d) of type (Socket) +bool(true) +int(14) +Array +( + [name] => Array + ( + [family] => %d + [addr] => ::1 + [port] => 7001 + [flowinfo] => 0 + [scope_id] => 0 + ) + + [control] => Array + ( + [0] => Array + ( + [level] => %d + [type] => %d + [data] => Array + ( + [addr] => ::1 + [ifindex] => %d + ) + + ) + + ) + + [iov] => Array + ( + [0] => testing packet + ) + + [flags] => 0 +) diff --git a/ext/sockets/tests/socket_sendrecvmsg_multi_msg-win32.phpt b/ext/sockets/tests/socket_sendrecvmsg_multi_msg-win32.phpt new file mode 100644 index 0000000000000..3aba012726f7b --- /dev/null +++ b/ext/sockets/tests/socket_sendrecvmsg_multi_msg-win32.phpt @@ -0,0 +1,110 @@ +--TEST-- +sendmsg()/recvmsg(): test ability to receive multiple messages (WIN32) +--SKIPIF-- + [ "addr" => "::1", "port" => 3000], + "iov" => ["test ", "thing", "\n"], + "control" => [[ + "level" => IPPROTO_IPV6, + "type" => IPV6_PKTINFO, + "data" => [ + 'addr' => '::1', + 'ifindex' => 1 /* we're assuming loopback is 1. Is this a safe assumption? */ + ], + ]] +], 0); +var_dump($r); +checktimeout($s, 500); + +$data = [ + "name" => ["family" => AF_INET6, "addr" => "::1"], + "buffer_size" => 2000, + "controllen" => socket_cmsg_space(IPPROTO_IPV6, IPV6_PKTINFO) + + socket_cmsg_space(IPPROTO_IPV6, IPV6_TCLASS), +]; +if (!socket_recvmsg($s, $data, 0)) die("recvmsg"); +print_r($data); + +--EXPECTF-- +creating send socket +resource(5) of type (Socket) +bool(true) +creating receive socket +resource(6) of type (Socket) +bool(true) +int(11) +Array +( + [name] => Array + ( + [family] => %d + [addr] => ::1 + [port] => 7001 + [flowinfo] => 0 + [scope_id] => 0 + ) + + [control] => Array + ( + [0] => Array + ( + [level] => %d + [type] => %d + [data] => Array + ( + [addr] => ::1 + [ifindex] => %d + ) + + ) + + [1] => Array + ( + [level] => %d + [type] => %d + [data] => 0 + ) + + ) + + [iov] => Array + ( + [0] => test thing + + ) + + [flags] => 0 +) diff --git a/ext/sockets/tests/socket_sendrecvmsg_multi_msg.phpt b/ext/sockets/tests/socket_sendrecvmsg_multi_msg.phpt new file mode 100644 index 0000000000000..212f7e186f216 --- /dev/null +++ b/ext/sockets/tests/socket_sendrecvmsg_multi_msg.phpt @@ -0,0 +1,106 @@ +--TEST-- +sendmsg()/recvmsg(): test ability to receive multiple messages +--SKIPIF-- + [ "addr" => "::1", "port" => 3000], + "iov" => ["test ", "thing", "\n"], + "control" => [[ + "level" => IPPROTO_IPV6, + "type" => IPV6_TCLASS, + "data" => 40, + ]] +], 0); +var_dump($r); +checktimeout($s, 500); + +$data = [ + "name" => ["family" => AF_INET6, "addr" => "::1"], + "buffer_size" => 2000, + "controllen" => socket_cmsg_space(IPPROTO_IPV6, IPV6_PKTINFO) + + socket_cmsg_space(IPPROTO_IPV6, IPV6_TCLASS), +]; +if (!socket_recvmsg($s, $data, 0)) die("recvmsg"); +print_r($data); + +--EXPECTF-- +creating send socket +resource(5) of type (Socket) +bool(true) +creating receive socket +resource(6) of type (Socket) +bool(true) +int(11) +Array +( + [name] => Array + ( + [family] => %d + [addr] => ::1 + [port] => 7001 + [flowinfo] => 0 + [scope_id] => 0 + ) + + [control] => Array + ( + [0] => Array + ( + [level] => %d + [type] => %d + [data] => Array + ( + [addr] => ::1 + [ifindex] => %d + ) + + ) + + [1] => Array + ( + [level] => %d + [type] => %d + [data] => 40 + ) + + ) + + [iov] => Array + ( + [0] => test thing + + ) + + [flags] => 0 +) diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt index bf95044d48a87..5aeaa0824fa10 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt @@ -14,12 +14,14 @@ if (!extension_loaded('sockets')) { if (!socket_set_nonblock($socket)) { die('Unable to set nonblocking mode for socket'); } - socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning + $address = '127.0.0.1'; socket_sendto($socket, '', 1, 0, $address); // cause warning if (!socket_bind($socket, $address, 1223)) { die("Unable to bind to $address:1223"); } + + var_dump(socket_recvfrom($socket, $buf, 12, 0, $from, $port)); //false (EAGAIN - no warning) $msg = "Ping!"; $len = strlen($msg); @@ -44,9 +46,9 @@ if (!extension_loaded('sockets')) { socket_close($socket); --EXPECTF-- -Warning: socket_recvfrom(): unable to recvfrom [%d]: %a in %s on line %d Warning: Wrong parameter count for socket_sendto() in %s on line %d +bool(false) Warning: socket_recvfrom() expects at least 5 parameters, 4 given in %s on line %d diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt index 2beb8080cdb56..bd0790427773b 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt @@ -18,7 +18,7 @@ require 'ipv6_skipif.inc'; if (!socket_set_nonblock($socket)) { die('Unable to set nonblocking mode for socket'); } - socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning + var_dump(socket_recvfrom($socket, $buf, 12, 0, $from, $port)); // false (EAGAIN, no warning) $address = '::1'; socket_sendto($socket, '', 1, 0, $address); // cause warning if (!socket_bind($socket, $address, 1223)) { @@ -48,7 +48,7 @@ require 'ipv6_skipif.inc'; socket_close($socket); --EXPECTF-- -Warning: socket_recvfrom(): unable to recvfrom [11]: Resource temporarily unavailable in %s on line %d +bool(false) Warning: Wrong parameter count for socket_sendto() in %s on line %d diff --git a/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt b/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt index 55ad75c65e430..e25bf4df1a547 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt @@ -18,7 +18,7 @@ if (!extension_loaded('sockets')) { if (!socket_set_nonblock($socket)) { die('Unable to set nonblocking mode for socket'); } - socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning + var_dump(socket_recvfrom($socket, $buf, 12, 0, $from, $port)); //false (EAGAIN, no warning) $address = sprintf("/tmp/%s.sock", uniqid()); if (!socket_bind($socket, $address)) { die("Unable to bind to $address"); @@ -53,8 +53,7 @@ if (!extension_loaded('sockets')) { ?> --EXPECTF-- Warning: socket_create(): Unable to create socket [%d]: Protocol not supported in %s on line %d - -Warning: socket_recvfrom(): unable to recvfrom [%d]: Resource temporarily unavailable in %s on line %d +bool(false) Warning: socket_sendto() expects at least 5 parameters, 4 given in %s on line %d bool(false) diff --git a/ext/sockets/tests/socket_set_option_in6_pktinfo.phpt b/ext/sockets/tests/socket_set_option_in6_pktinfo.phpt new file mode 100644 index 0000000000000..27b6ae59c5d12 --- /dev/null +++ b/ext/sockets/tests/socket_set_option_in6_pktinfo.phpt @@ -0,0 +1,32 @@ +--TEST-- +socket_set_option() with IPV6_PKTINFO +--SKIPIF-- + '::1', + "ifindex" => 0 +])); +//Oddly, Linux does not support IPV6_PKTINFO in sockgetopt(). +//See do_ipv6_getsockopt() on the kernel sources +//A work-around with is sort-of possible (with IPV6_2292PKTOPTIONS), +//but not worth it +//var_dump(socket_get_option($s, IPPROTO_IPV6, IPV6_PKTINFO)); + +--EXPECTF-- +Warning: socket_set_option(): error converting user data (path: in6_pktinfo): The key 'addr' is required in %s on line %d +bool(false) +bool(true) + diff --git a/ext/sockets/windows_common.h b/ext/sockets/windows_common.h new file mode 100644 index 0000000000000..3a9cb59129284 --- /dev/null +++ b/ext/sockets/windows_common.h @@ -0,0 +1,120 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2012 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + */ +#ifndef WINDOWS_COMMON_H +#define WINDOWS_COMMON_H + +#include +#define NTDDI_XP NTDDI_WINXP /* bug in SDK */ +#include /* conflicting definition of CMSG_DATA */ +#undef NTDDI_XP + +#define HAVE_IF_NAMETOINDEX 1 + +#define IS_INVALID_SOCKET(a) (a->bsd_socket == INVALID_SOCKET) + +#ifdef errno +# undef errno +#endif +#define errno WSAGetLastError() +#define h_errno WSAGetLastError() +#define set_errno(a) WSASetLastError(a) +#define close(a) closesocket(a) + +#ifdef ENETUNREACH /* errno.h probably included */ +# undef EWOULDBLOCK +# undef EINPROGRESS +# undef EALREADY +# undef ENOTSOCK +# undef EDESTADDRREQ +# undef EMSGSIZE +# undef EPROTOTYPE +# undef ENOPROTOOPT +# undef EPROTONOSUPPORT +# undef ESOCKTNOSUPPORT +# undef EOPNOTSUPP +# undef EPFNOSUPPORT +# undef EAFNOSUPPORT +# undef EADDRINUSE +# undef EADDRNOTAVAIL +# undef ENETDOWN +# undef ENETUNREACH +# undef ENETRESET +# undef ECONNABORTED +# undef ECONNRESET +# undef ENOBUFS +# undef EISCONN +# undef ENOTCONN +# undef ESHUTDOWN +# undef ETOOMANYREFS +# undef ETIMEDOUT +# undef ECONNREFUSED +# undef ELOOP +# undef ENAMETOOLONG +# undef EHOSTDOWN +# undef EHOSTUNREACH +# undef ENOTEMPTY +# undef EPROCLIM +# undef EUSERS +# undef EDQUOT +# undef ESTALE +# undef EREMOTE + +# undef EAGAIN +#endif + +/* section disabled in WinSock2.h */ +#define EWOULDBLOCK WSAEWOULDBLOCK +#define EINPROGRESS WSAEINPROGRESS +#define EALREADY WSAEALREADY +#define ENOTSOCK WSAENOTSOCK +#define EDESTADDRREQ WSAEDESTADDRREQ +#define EMSGSIZE WSAEMSGSIZE +#define EPROTOTYPE WSAEPROTOTYPE +#define ENOPROTOOPT WSAENOPROTOOPT +#define EPROTONOSUPPORT WSAEPROTONOSUPPORT +#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT +#define EOPNOTSUPP WSAEOPNOTSUPP +#define EPFNOSUPPORT WSAEPFNOSUPPORT +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#define EADDRINUSE WSAEADDRINUSE +#define EADDRNOTAVAIL WSAEADDRNOTAVAIL +#define ENETDOWN WSAENETDOWN +#define ENETUNREACH WSAENETUNREACH +#define ENETRESET WSAENETRESET +#define ECONNABORTED WSAECONNABORTED +#define ECONNRESET WSAECONNRESET +#define ENOBUFS WSAENOBUFS +#define EISCONN WSAEISCONN +#define ENOTCONN WSAENOTCONN +#define ESHUTDOWN WSAESHUTDOWN +#define ETOOMANYREFS WSAETOOMANYREFS +#define ETIMEDOUT WSAETIMEDOUT +#define ECONNREFUSED WSAECONNREFUSED +#define ELOOP WSAELOOP +#define ENAMETOOLONG WSAENAMETOOLONG +#define EHOSTDOWN WSAEHOSTDOWN +#define EHOSTUNREACH WSAEHOSTUNREACH +#define ENOTEMPTY WSAENOTEMPTY +#define EPROCLIM WSAEPROCLIM +#define EUSERS WSAEUSERS +#define EDQUOT WSAEDQUOT +#define ESTALE WSAESTALE +#define EREMOTE WSAEREMOTE + +/* and an extra one */ +#define EAGAIN WSAEWOULDBLOCK + +#endif diff --git a/ext/spl/doxygen.cfg b/ext/spl/doxygen.cfg index 4b71787238795..5c7025a9ad31f 100755 --- a/ext/spl/doxygen.cfg +++ b/ext/spl/doxygen.cfg @@ -111,7 +111,7 @@ HTML_STYLESHEET = HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = YES CHM_FILE = ../spl.chm -HHC_LOCATION = hhc.exe +#HHC_LOCATION = hhc.exe GENERATE_CHI = NO BINARY_TOC = NO TOC_EXPAND = NO @@ -210,7 +210,7 @@ MAX_DOT_GRAPH_WIDTH = 1200 MAX_DOT_GRAPH_HEIGHT = 1024 MAX_DOT_GRAPH_DEPTH = 0 GENERATE_LEGEND = YES -DOT_CLEANUP = YES +DOT_CLEANUP = NO #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index c0d5a35a23693..c9aec753c80a2 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -604,6 +604,38 @@ SPL_METHOD(SplFixedArray, __construct) } /* }}} */ +/* {{{ proto void SplFixedArray::__wakeup() +*/ +SPL_METHOD(SplFixedArray, __wakeup) +{ + spl_fixedarray_object *intern = (spl_fixedarray_object *) zend_object_store_get_object(getThis() TSRMLS_CC); + HashPosition ptr; + HashTable *intern_ht = zend_std_get_properties(getThis() TSRMLS_CC); + zval **data; + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "")) { + return; + } + + if (!intern->array) { + int index = 0; + int size = zend_hash_num_elements(intern_ht); + + intern->array = emalloc(sizeof(spl_fixedarray)); + spl_fixedarray_init(intern->array, size TSRMLS_CC); + + for (zend_hash_internal_pointer_reset_ex(intern_ht, &ptr); zend_hash_get_current_data_ex(intern_ht, (void **) &data, &ptr) == SUCCESS; zend_hash_move_forward_ex(intern_ht, &ptr)) { + Z_ADDREF_PP(data); + intern->array->elements[index++] = *data; + } + + /* Remove the unserialised properties, since we now have the elements + * within the spl_fixedarray_object structure. */ + zend_hash_clean(intern_ht); + } +} +/* }}} */ + /* {{{ proto int SplFixedArray::count(void) */ SPL_METHOD(SplFixedArray, count) @@ -1081,6 +1113,7 @@ ZEND_END_ARG_INFO() static zend_function_entry spl_funcs_SplFixedArray[] = { /* {{{ */ SPL_ME(SplFixedArray, __construct, arginfo_splfixedarray_construct,ZEND_ACC_PUBLIC) + SPL_ME(SplFixedArray, __wakeup, arginfo_splfixedarray_void, ZEND_ACC_PUBLIC) SPL_ME(SplFixedArray, count, arginfo_splfixedarray_void, ZEND_ACC_PUBLIC) SPL_ME(SplFixedArray, toArray, arginfo_splfixedarray_void, ZEND_ACC_PUBLIC) SPL_ME(SplFixedArray, fromArray, arginfo_fixedarray_fromArray, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index e6cd155a8a1b1..87b3763cfd7f8 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -230,7 +230,7 @@ static void spl_recursive_it_move_forward_ex(spl_recursive_it_object *object, zv if (iterator->funcs->valid(iterator TSRMLS_CC) == FAILURE) { break; } - object->iterators[object->level].state = RS_TEST; + object->iterators[object->level].state = RS_TEST; /* break; */ case RS_TEST: ce = object->iterators[object->level].ce; diff --git a/ext/spl/tests/SplFixedArray_serialize.phpt b/ext/spl/tests/SplFixedArray_serialize.phpt new file mode 100644 index 0000000000000..f99812ecceb70 --- /dev/null +++ b/ext/spl/tests/SplFixedArray_serialize.phpt @@ -0,0 +1,52 @@ +--TEST-- +SplFixedArray serialisation +--FILE-- +prop = 'value'; + +$array[0] = 'foo'; +$array[2] = 42; +$array[3] = $obj; +$array[4] = range(1, 5); + +$ser = serialize($array); +echo "$ser\n"; +$unser = unserialize($ser); + +printf("count: %d\n", count($unser)); +printf("getSize(): %d\n", $unser->getSize()); + +var_dump($unser[0], $unser[1], $unser[2], $unser[3], $unser[4]); + +$unser[4] = 'quux'; +var_dump($unser[4]); + +?> +--EXPECT-- +O:13:"SplFixedArray":5:{i:0;s:3:"foo";i:1;N;i:2;i:42;i:3;O:8:"stdClass":1:{s:4:"prop";s:5:"value";}i:4;a:5:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:4;i:5;}} +count: 5 +getSize(): 5 +string(3) "foo" +NULL +int(42) +object(stdClass)#4 (1) { + ["prop"]=> + string(5) "value" +} +array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) +} +string(4) "quux" diff --git a/ext/spl/tests/bug61697.phpt b/ext/spl/tests/bug61697.phpt new file mode 100644 index 0000000000000..d95caef978595 --- /dev/null +++ b/ext/spl/tests/bug61697.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #61697 (spl_autoload_functions returns lambda functions incorrectly) +--XFAIL-- +Bug #61697 not fixed yet +--FILE-- + +--EXPECTF-- +Array +( +) diff --git a/ext/sqlite3/libsqlite/sqlite3.c b/ext/sqlite3/libsqlite/sqlite3.c index d96367e2120f1..f3c06d49b1b00 100644 --- a/ext/sqlite3/libsqlite/sqlite3.c +++ b/ext/sqlite3/libsqlite/sqlite3.c @@ -18139,7 +18139,7 @@ SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){ sqlite3_int64 priorLimit; sqlite3_int64 excess; #ifndef SQLITE_OMIT_AUTOINIT - sqlite3_initialize(); + if( sqlite3_initialize() ) return 0; #endif sqlite3_mutex_enter(mem0.mutex); priorLimit = mem0.alarmThreshold; diff --git a/ext/sqlite3/php_sqlite3.h b/ext/sqlite3/php_sqlite3.h index 131e70102c294..b558f70340522 100644 --- a/ext/sqlite3/php_sqlite3.h +++ b/ext/sqlite3/php_sqlite3.h @@ -21,7 +21,7 @@ #ifndef PHP_SQLITE3_H #define PHP_SQLITE3_H -#define PHP_SQLITE3_VERSION "0.7" +#define PHP_SQLITE3_VERSION "0.7-dev" extern zend_module_entry sqlite3_module_entry; #define phpext_sqlite3_ptr &sqlite3_module_entry diff --git a/ext/sqlite3/tests/bug53463.phpt b/ext/sqlite3/tests/bug53463.phpt index 744a21461259a..dcfc13d5ba1b4 100644 --- a/ext/sqlite3/tests/bug53463.phpt +++ b/ext/sqlite3/tests/bug53463.phpt @@ -27,4 +27,4 @@ echo "Done\n"; --EXPECT-- string(8) "whatever" bool(false) -Done +Done \ No newline at end of file diff --git a/ext/standard/Makefile.frag b/ext/standard/Makefile.frag index 4e949621838b6..8b6e3e233ab17 100644 --- a/ext/standard/Makefile.frag +++ b/ext/standard/Makefile.frag @@ -1,9 +1,9 @@ $(srcdir)/var_unserializer.c: $(srcdir)/var_unserializer.re - @(cd $(top_srcdir); $(RE2C) -b -o ext/standard/var_unserializer.c ext/standard/var_unserializer.re) + @(cd $(top_srcdir); $(RE2C) --no-generation-date -b -o ext/standard/var_unserializer.c ext/standard/var_unserializer.re) $(srcdir)/url_scanner_ex.c: $(srcdir)/url_scanner_ex.re - @(cd $(top_srcdir); $(RE2C) -b -o ext/standard/url_scanner_ex.c ext/standard/url_scanner_ex.re) + @(cd $(top_srcdir); $(RE2C) --no-generation-date -b -o ext/standard/url_scanner_ex.c ext/standard/url_scanner_ex.re) $(builddir)/info.lo: $(builddir)/../../main/build-defs.h diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index a9ce7deefdeea..a40fdd23979f1 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -128,6 +128,8 @@ typedef struct _user_tick_function_entry { static void user_shutdown_function_dtor(php_shutdown_function_entry *shutdown_function_entry); static void user_tick_function_dtor(user_tick_function_entry *tick_function_entry); +static HashTable basic_submodules; + #undef sprintf /* {{{ arginfo */ @@ -1548,18 +1550,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phpcredits, 0, 0, 0) ZEND_ARG_INFO(0, flag) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_php_logo_guid, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_php_real_logo_guid, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_php_egg_logo_guid, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_zend_logo_guid, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO(arginfo_php_sapi_name, 0) ZEND_END_ARG_INFO() @@ -1864,6 +1854,25 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_getlastmod, 0) ZEND_END_ARG_INFO() /* }}} */ +/* {{{ password.c */ +ZEND_BEGIN_ARG_INFO_EX(arginfo_password_hash, 0, 0, 2) + ZEND_ARG_INFO(0, password) + ZEND_ARG_INFO(0, algo) + ZEND_ARG_INFO(0, options) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_password_get_info, 0, 0, 1) + ZEND_ARG_INFO(0, hash) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_password_needs_rehash, 0, 0, 2) + ZEND_ARG_INFO(0, hash) + ZEND_ARG_INFO(0, algo) + ZEND_ARG_INFO(0, options) +ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_password_verify, 0, 0, 2) + ZEND_ARG_INFO(0, password) + ZEND_ARG_INFO(0, hash) +ZEND_END_ARG_INFO() +/* }}} */ /* {{{ proc_open.c */ #ifdef PHP_CAN_SUPPORT_PROC_OPEN ZEND_BEGIN_ARG_INFO_EX(arginfo_proc_terminate, 0, 0, 1) @@ -2520,6 +2529,10 @@ ZEND_BEGIN_ARG_INFO(arginfo_strval, 0) ZEND_ARG_INFO(0, var) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_boolval, 0) + ZEND_ARG_INFO(0, var) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO(arginfo_is_null, 0) ZEND_ARG_INFO(0, var) ZEND_END_ARG_INFO() @@ -2717,10 +2730,6 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(phpinfo, arginfo_phpinfo) PHP_FE(phpversion, arginfo_phpversion) PHP_FE(phpcredits, arginfo_phpcredits) - PHP_FE(php_logo_guid, arginfo_php_logo_guid) - PHP_FE(php_real_logo_guid, arginfo_php_real_logo_guid) - PHP_FE(php_egg_logo_guid, arginfo_php_egg_logo_guid) - PHP_FE(zend_logo_guid, arginfo_zend_logo_guid) PHP_FE(php_sapi_name, arginfo_php_sapi_name) PHP_FE(php_uname, arginfo_php_uname) PHP_FE(php_ini_scanned_files, arginfo_php_ini_scanned_files) @@ -2874,6 +2883,10 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(base64_decode, arginfo_base64_decode) PHP_FE(base64_encode, arginfo_base64_encode) + PHP_FE(password_hash, arginfo_password_hash) + PHP_FE(password_get_info, arginfo_password_get_info) + PHP_FE(password_needs_rehash, arginfo_password_needs_rehash) + PHP_FE(password_verify, arginfo_password_verify) PHP_FE(convert_uuencode, arginfo_convert_uuencode) PHP_FE(convert_uudecode, arginfo_convert_uudecode) @@ -3043,6 +3056,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(floatval, arginfo_floatval) PHP_FALIAS(doubleval, floatval, arginfo_floatval) PHP_FE(strval, arginfo_strval) + PHP_FE(boolval, arginfo_boolval) PHP_FE(gettype, arginfo_gettype) PHP_FE(settype, arginfo_settype) PHP_FE(is_null, arginfo_is_null) @@ -3513,6 +3527,34 @@ PHPAPI double php_get_inf(void) /* {{{ */ } /* }}} */ +#define BASIC_MINIT_SUBMODULE(module) \ + if (PHP_MINIT(module)(INIT_FUNC_ARGS_PASSTHRU) == SUCCESS) {\ + BASIC_ADD_SUBMODULE(module); \ + } + +#define BASIC_ADD_SUBMODULE(module) \ + zend_hash_add_empty_element(&basic_submodules, #module, strlen(#module)); + +#define BASIC_RINIT_SUBMODULE(module) \ + if (zend_hash_exists(&basic_submodules, #module, strlen(#module))) { \ + PHP_RINIT(module)(INIT_FUNC_ARGS_PASSTHRU); \ + } + +#define BASIC_MINFO_SUBMODULE(module) \ + if (zend_hash_exists(&basic_submodules, #module, strlen(#module))) { \ + PHP_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); \ + } + +#define BASIC_RSHUTDOWN_SUBMODULE(module) \ + if (zend_hash_exists(&basic_submodules, #module, strlen(#module))) { \ + PHP_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS_PASSTHRU); \ + } + +#define BASIC_MSHUTDOWN_SUBMODULE(module) \ + if (zend_hash_exists(&basic_submodules, #module, strlen(#module))) { \ + PHP_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS_PASSTHRU); \ + } + PHP_MINIT_FUNCTION(basic) /* {{{ */ { #ifdef ZTS @@ -3527,6 +3569,8 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */ #endif #endif + zend_hash_init(&basic_submodules, 0, NULL, NULL, 1); + BG(incomplete_class) = incomplete_class_entry = php_create_incomplete_class(TSRMLS_C); REGISTER_LONG_CONSTANT("CONNECTION_ABORTED", PHP_CONNECTION_ABORTED, CONST_CS | CONST_PERSISTENT); @@ -3586,39 +3630,42 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */ register_html_constants(INIT_FUNC_ARGS_PASSTHRU); register_string_constants(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(file)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(pack)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(browscap)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(standard_filters)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(user_filters)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_ADD_SUBMODULE(dl) + BASIC_ADD_SUBMODULE(mail) + BASIC_MINIT_SUBMODULE(file) + BASIC_MINIT_SUBMODULE(pack) + BASIC_MINIT_SUBMODULE(browscap) + BASIC_MINIT_SUBMODULE(standard_filters) + BASIC_MINIT_SUBMODULE(user_filters) + BASIC_MINIT_SUBMODULE(password) #if defined(HAVE_LOCALECONV) && defined(ZTS) - PHP_MINIT(localeconv)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(localeconv) #endif #if defined(HAVE_NL_LANGINFO) - PHP_MINIT(nl_langinfo)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(nl_langinfo) #endif #if HAVE_CRYPT - PHP_MINIT(crypt)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(crypt) #endif - PHP_MINIT(lcg)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(lcg) - PHP_MINIT(dir)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(dir) #ifdef HAVE_SYSLOG_H - PHP_MINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(syslog) #endif - PHP_MINIT(array)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(assert)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(array) + BASIC_MINIT_SUBMODULE(assert) + BASIC_MINIT_SUBMODULE(url_scanner_ex) #ifdef PHP_CAN_SUPPORT_PROC_OPEN - PHP_MINIT(proc_open)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(proc_open) #endif - PHP_MINIT(user_streams)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(imagetypes)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(user_streams) + BASIC_MINIT_SUBMODULE(imagetypes) php_register_url_stream_wrapper("php", &php_stream_php_wrapper TSRMLS_CC); php_register_url_stream_wrapper("file", &php_plain_files_wrapper TSRMLS_CC); @@ -3633,7 +3680,7 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */ #if defined(PHP_WIN32) || (HAVE_DNS_SEARCH_FUNC && !(defined(__BEOS__) || defined(NETWARE))) # if defined(PHP_WIN32) || HAVE_FULL_DNS_FUNCS - PHP_MINIT(dns)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_MINIT_SUBMODULE(dns) # endif #endif @@ -3664,19 +3711,20 @@ PHP_MSHUTDOWN_FUNCTION(basic) /* {{{ */ php_unregister_url_stream_wrapper("ftp" TSRMLS_CC); #endif - PHP_MSHUTDOWN(browscap)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_MSHUTDOWN(array)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_MSHUTDOWN(assert)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_MSHUTDOWN(url_scanner_ex)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_MSHUTDOWN(file)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_MSHUTDOWN(standard_filters)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_MSHUTDOWN_SUBMODULE(browscap) + BASIC_MSHUTDOWN_SUBMODULE(array) + BASIC_MSHUTDOWN_SUBMODULE(assert) + BASIC_MSHUTDOWN_SUBMODULE(url_scanner_ex) + BASIC_MSHUTDOWN_SUBMODULE(file) + BASIC_MSHUTDOWN_SUBMODULE(standard_filters) #if defined(HAVE_LOCALECONV) && defined(ZTS) - PHP_MSHUTDOWN(localeconv)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_MSHUTDOWN_SUBMODULE(localeconv) #endif #if HAVE_CRYPT - PHP_MSHUTDOWN(crypt)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_MSHUTDOWN_SUBMODULE(crypt) #endif + zend_hash_destroy(&basic_submodules); return SUCCESS; } /* }}} */ @@ -3710,10 +3758,10 @@ PHP_RINIT_FUNCTION(basic) /* {{{ */ PHP_RINIT(filestat)(INIT_FUNC_ARGS_PASSTHRU); #ifdef HAVE_SYSLOG_H - PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_RINIT_SUBMODULE(syslog) #endif - PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU); - PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU); + BASIC_RINIT_SUBMODULE(dir) + BASIC_RINIT_SUBMODULE(url_scanner_ex) /* Setup default context */ FG(default_context) = NULL; @@ -3759,14 +3807,14 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */ PHP_RSHUTDOWN(filestat)(SHUTDOWN_FUNC_ARGS_PASSTHRU); #ifdef HAVE_SYSLOG_H #ifdef PHP_WIN32 - PHP_RSHUTDOWN(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_RSHUTDOWN_SUBMODULE(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU); #endif #endif - PHP_RSHUTDOWN(assert)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_RSHUTDOWN(url_scanner_ex)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_RSHUTDOWN(streams)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_RSHUTDOWN_SUBMODULE(assert) + BASIC_RSHUTDOWN_SUBMODULE(url_scanner_ex) + BASIC_RSHUTDOWN_SUBMODULE(streams) #ifdef PHP_WIN32 - PHP_RSHUTDOWN(win32_core_globals)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_RSHUTDOWN_SUBMODULE(win32_core_globals) #endif if (BG(user_tick_functions)) { @@ -3775,8 +3823,8 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */ BG(user_tick_functions) = NULL; } - PHP_RSHUTDOWN(user_filters)(SHUTDOWN_FUNC_ARGS_PASSTHRU); - PHP_RSHUTDOWN(browscap)(SHUTDOWN_FUNC_ARGS_PASSTHRU); + BASIC_RSHUTDOWN_SUBMODULE(user_filters) + BASIC_RSHUTDOWN_SUBMODULE(browscap) BG(page_uid) = -1; BG(page_gid) = -1; @@ -3787,10 +3835,10 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */ PHP_MINFO_FUNCTION(basic) /* {{{ */ { php_info_print_table_start(); - PHP_MINFO(dl)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); - PHP_MINFO(mail)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); + BASIC_MINFO_SUBMODULE(dl) + BASIC_MINFO_SUBMODULE(mail) php_info_print_table_end(); - PHP_MINFO(assert)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); + BASIC_MINFO_SUBMODULE(assert) } /* }}} */ @@ -5056,12 +5104,12 @@ void php_free_shutdown_functions(TSRMLS_D) /* {{{ */ } /* }}} */ -/* {{{ proto void register_shutdown_function(string function_name) U +/* {{{ proto void register_shutdown_function(callback function) U Register a user-level function to be called on request termination */ PHP_FUNCTION(register_shutdown_function) { php_shutdown_function_entry shutdown_function_entry; - char *function_name = NULL; + char *callback_name = NULL; int i; shutdown_function_entry.arg_count = ZEND_NUM_ARGS(); @@ -5078,8 +5126,8 @@ PHP_FUNCTION(register_shutdown_function) } /* Prevent entering of anything but valid callback (syntax check only!) */ - if (!zend_is_callable(shutdown_function_entry.arguments[0], 0, &function_name TSRMLS_CC)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid shutdown callback '%s' passed", function_name); + if (!zend_is_callable(shutdown_function_entry.arguments[0], 0, &callback_name TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid shutdown callback '%s' passed", callback_name); efree(shutdown_function_entry.arguments); RETVAL_FALSE; } else { @@ -5093,8 +5141,8 @@ PHP_FUNCTION(register_shutdown_function) } zend_hash_next_index_insert(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry), NULL); } - if (function_name) { - efree(function_name); + if (callback_name) { + efree(callback_name); } } /* }}} */ diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index c33ae1e05c897..fba423b19195a 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -580,7 +580,7 @@ PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32. incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \ http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \ var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \ - filters.c proc_open.c streamsfuncs.c http.c) + filters.c proc_open.c streamsfuncs.c http.c password.c) PHP_ADD_MAKEFILE_FRAGMENT PHP_INSTALL_HEADERS([ext/standard/]) diff --git a/ext/standard/config.w32 b/ext/standard/config.w32 index d14b859e9db99..5f24641b4d33a 100644 --- a/ext/standard/config.w32 +++ b/ext/standard/config.w32 @@ -19,7 +19,7 @@ EXTENSION("standard", "array.c base64.c basic_functions.c browscap.c \ versioning.c assert.c strnatcmp.c levenshtein.c incomplete_class.c \ url_scanner_ex.c ftp_fopen_wrapper.c http_fopen_wrapper.c \ php_fopen_wrapper.c credits.c css.c var_unserializer.c ftok.c sha1.c \ - user_filters.c uuencode.c filters.c proc_open.c \ + user_filters.c uuencode.c filters.c proc_open.c password.c \ streamsfuncs.c http.c flock_compat.c", false /* never shared */); PHP_INSTALL_HEADERS("", "ext/standard"); if (PHP_MBREGEX != "no") { diff --git a/ext/standard/credits.c b/ext/standard/credits.c index 7ce08194914c9..530c8d0e63b45 100644 --- a/ext/standard/credits.c +++ b/ext/standard/credits.c @@ -105,7 +105,7 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) /* {{{ */ if (flag & PHP_CREDITS_QA) { php_info_print_table_start(); php_info_print_table_header(1, "PHP Quality Assurance Team"); - php_info_print_table_row(1, "Ilia Alshanetsky, Joerg Behrens, Antony Dovgal, Stefan Esser, Moriyoshi Koizumi, Magnus Maatta, Sebastian Nohn, Derick Rethans, Melvyn Sopacua, Jani Taskinen, Pierre-Alain Joye, Dmitry Stogov, Felipe Pena"); + php_info_print_table_row(1, "Ilia Alshanetsky, Joerg Behrens, Antony Dovgal, Stefan Esser, Moriyoshi Koizumi, Magnus Maatta, Sebastian Nohn, Derick Rethans, Melvyn Sopacua, Jani Taskinen, Pierre-Alain Joye, Dmitry Stogov, Felipe Pena, David Soria Parra"); php_info_print_table_end(); } diff --git a/ext/standard/credits_ext.h b/ext/standard/credits_ext.h index 7bdb41e608857..382e70e7d7fc3 100644 --- a/ext/standard/credits_ext.h +++ b/ext/standard/credits_ext.h @@ -17,8 +17,8 @@ CREDIT_LINE("COM and .Net", "Wez Furlong"); CREDIT_LINE("ctype", "Hartmut Holzgraefe"); CREDIT_LINE("cURL", "Sterling Hughes"); CREDIT_LINE("Date/Time Support", "Derick Rethans"); -CREDIT_LINE("DB-LIB (MS SQL, Sybase)", "Wez Furlong, Frank M. Kromann"); CREDIT_LINE("DBA", "Sascha Schumann, Marcus Boerger"); +CREDIT_LINE("DB-LIB (MS SQL, Sybase)", "Wez Furlong, Frank M. Kromann"); CREDIT_LINE("DOM", "Christian Stocker, Rob Richards, Marcus Boerger"); CREDIT_LINE("enchant", "Pierre-Alain Joye, Ilia Alshanetsky"); CREDIT_LINE("ereg", "Rasmus Lerdorf, Jim Winstead, Jaakko Hyvätti"); @@ -41,13 +41,13 @@ CREDIT_LINE("mcrypt", "Sascha Schumann, Derick Rethans"); CREDIT_LINE("MS SQL", "Frank M. Kromann"); CREDIT_LINE("Multibyte String Functions", "Tsukada Takuya, Rui Hirokawa"); CREDIT_LINE("MySQL driver for PDO", "George Schlossnagle, Wez Furlong, Ilia Alshanetsky, Johannes Schlueter"); -CREDIT_LINE("MySQL", "Zeev Suraski, Zak Greant, Georg Richter"); CREDIT_LINE("MySQLi", "Zak Greant, Georg Richter, Andrey Hristov, Ulf Wendel"); CREDIT_LINE("MySQLnd", "Andrey Hristov, Ulf Wendel, Georg Richter"); +CREDIT_LINE("MySQL", "Zeev Suraski, Zak Greant, Georg Richter"); CREDIT_LINE("OCI8", "Stig Bakken, Thies C. Arntzen, Andy Sautins, David Benson, Maxim Maletsky, Harald Radi, Antony Dovgal, Andi Gutmans, Wez Furlong, Christopher Jones, Oracle Corporation"); CREDIT_LINE("ODBC driver for PDO", "Wez Furlong"); CREDIT_LINE("ODBC", "Stig Bakken, Andreas Karajannis, Frank M. Kromann, Daniel R. Kalowsky"); -CREDIT_LINE("OpenSSL", "Stig Venaas, Wez Furlong, Sascha Kettler"); +CREDIT_LINE("OpenSSL", "Stig Venaas, Wez Furlong, Sascha Kettler, Scott MacVicar"); CREDIT_LINE("Oracle (OCI) driver for PDO", "Wez Furlong"); CREDIT_LINE("pcntl", "Jason Greene, Arnaud Le Blanc"); CREDIT_LINE("Perl Compatible Regexps", "Andrei Zmievski"); @@ -68,8 +68,8 @@ CREDIT_LINE("SNMP", "Rasmus Lerdorf, Harrie Hazewinkel, Mike Jackson, Steven Law CREDIT_LINE("SOAP", "Brad Lafountain, Shane Caraveo, Dmitry Stogov"); CREDIT_LINE("Sockets", "Chris Vandomelen, Sterling Hughes, Daniel Beulshausen, Jason Greene"); CREDIT_LINE("SPL", "Marcus Boerger, Etienne Kneuss"); -CREDIT_LINE("SQLite 3.x driver for PDO", "Wez Furlong"); CREDIT_LINE("SQLite3", "Scott MacVicar, Ilia Alshanetsky, Brad Dewar"); +CREDIT_LINE("SQLite 3.x driver for PDO", "Wez Furlong"); CREDIT_LINE("Sybase-CT", "Zeev Suraski, Tom May, Timm Friebe"); CREDIT_LINE("System V Message based IPC", "Wez Furlong"); CREDIT_LINE("System V Semaphores", "Tom May"); @@ -77,9 +77,9 @@ CREDIT_LINE("System V Shared Memory", "Christian Cartus"); CREDIT_LINE("tidy", "John Coggeshall, Ilia Alshanetsky"); CREDIT_LINE("tokenizer", "Andrei Zmievski, Johannes Schlueter"); CREDIT_LINE("WDDX", "Andrei Zmievski"); -CREDIT_LINE("XML", "Stig Bakken, Thies C. Arntzen, Sterling Hughes"); CREDIT_LINE("XMLReader", "Rob Richards"); CREDIT_LINE("xmlrpc", "Dan Libby"); +CREDIT_LINE("XML", "Stig Bakken, Thies C. Arntzen, Sterling Hughes"); CREDIT_LINE("XMLWriter", "Rob Richards, Pierre-Alain Joye"); CREDIT_LINE("XSL", "Christian Stocker, Rob Richards"); CREDIT_LINE("Zip", "Pierre-Alain Joye"); diff --git a/ext/standard/credits_sapi.h b/ext/standard/credits_sapi.h index 9cc7e6e224f2d..d147d8deae221 100644 --- a/ext/standard/credits_sapi.h +++ b/ext/standard/credits_sapi.h @@ -17,7 +17,7 @@ CREDIT_LINE("Apache 2.0 Filter", "Sascha Schumann, Aaron Bannert"); CREDIT_LINE("Apache 2.0 Handler", "Ian Holsman, Justin Erenkrantz (based on Apache 2.0 Filter code)"); CREDIT_LINE("Caudium / Roxen", "David Hedbor"); CREDIT_LINE("CGI / FastCGI", "Rasmus Lerdorf, Stig Bakken, Shane Caraveo, Dmitry Stogov"); -CREDIT_LINE("CLI", "Edin Kadribasic, Marcus Boerger, Johannes Schlueter"); +CREDIT_LINE("CLI", "Edin Kadribasic, Marcus Boerger, Johannes Schlueter, Moriyoshi Koizumi, Xinchen Hui"); CREDIT_LINE("Continuity", "Alex Leigh (based on nsapi code)"); CREDIT_LINE("Embed", "Edin Kadribasic"); CREDIT_LINE("FastCGI Process Manager", "Andrei Nigmatulin, dreamcat4, Antony Dovgal, Jerome Loyet"); diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c index c6e0351af2cd5..113a5bd0f516c 100644 --- a/ext/standard/crypt.c +++ b/ext/standard/crypt.c @@ -145,44 +145,9 @@ static void php_to64(char *s, long v, int n) /* {{{ */ } /* }}} */ -/* {{{ proto string crypt(string str [, string salt]) - Hash a string */ -PHP_FUNCTION(crypt) +PHPAPI int php_crypt(const char *password, const int pass_len, const char *salt, int salt_len, char **result) { - char salt[PHP_MAX_SALT_LEN + 1]; - char *str, *salt_in = NULL; - int str_len, salt_in_len = 0; char *crypt_res; - salt[0] = salt[PHP_MAX_SALT_LEN] = '\0'; - - /* This will produce suitable results if people depend on DES-encryption - * available (passing always 2-character salt). At least for glibc6.1 */ - memset(&salt[1], '$', PHP_MAX_SALT_LEN - 1); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &salt_in, &salt_in_len) == FAILURE) { - return; - } - - if (salt_in) { - memcpy(salt, salt_in, MIN(PHP_MAX_SALT_LEN, salt_in_len)); - } - - /* The automatic salt generation covers standard DES, md5-crypt and Blowfish (simple) */ - if (!*salt) { -#if PHP_MD5_CRYPT - strncpy(salt, "$1$", PHP_MAX_SALT_LEN); - php_to64(&salt[3], PHP_CRYPT_RAND, 4); - php_to64(&salt[7], PHP_CRYPT_RAND, 4); - strncpy(&salt[11], "$", PHP_MAX_SALT_LEN - 11); -#elif PHP_STD_DES_CRYPT - php_to64(&salt[0], PHP_CRYPT_RAND, 2); - salt[2] = '\0'; -#endif - salt_in_len = strlen(salt); - } else { - salt_in_len = MIN(PHP_MAX_SALT_LEN, salt_in_len); - } - /* Windows (win32/crypt) has a stripped down version of libxcrypt and a CryptoApi md5_crypt implementation */ #if PHP_USE_PHP_CRYPT_R @@ -190,55 +155,44 @@ PHP_FUNCTION(crypt) struct php_crypt_extended_data buffer; if (salt[0]=='$' && salt[1]=='1' && salt[2]=='$') { - char output[MD5_HASH_MAX_LEN]; + char output[MD5_HASH_MAX_LEN], *out; - RETURN_STRING(php_md5_crypt_r(str, salt, output), 1); + out = php_md5_crypt_r(password, salt, output); + if (out) { + *result = estrdup(out); + return SUCCESS; + } + return FAILURE; } else if (salt[0]=='$' && salt[1]=='6' && salt[2]=='$') { - const char sha512_salt_prefix[] = "$6$"; - const char sha512_rounds_prefix[] = "rounds="; char *output; - int needed = (sizeof(sha512_salt_prefix) - 1 - + sizeof(sha512_rounds_prefix) + 9 + 1 - + salt_in_len + 1 + 86 + 1); - output = emalloc(needed); - salt[salt_in_len] = '\0'; + output = emalloc(PHP_MAX_SALT_LEN); - crypt_res = php_sha512_crypt_r(str, salt, output, needed); + crypt_res = php_sha512_crypt_r(password, salt, output, PHP_MAX_SALT_LEN); if (!crypt_res) { - if (salt[0]=='*' && salt[1]=='0') { - RETVAL_STRING("*1", 1); - } else { - RETVAL_STRING("*0", 1); - } + memset(output, 0, PHP_MAX_SALT_LEN); + efree(output); + return FAILURE; } else { - RETVAL_STRING(output, 1); + *result = estrdup(output); + memset(output, 0, PHP_MAX_SALT_LEN); + efree(output); + return SUCCESS; } - - memset(output, 0, needed); - efree(output); } else if (salt[0]=='$' && salt[1]=='5' && salt[2]=='$') { - const char sha256_salt_prefix[] = "$5$"; - const char sha256_rounds_prefix[] = "rounds="; char *output; - int needed = (sizeof(sha256_salt_prefix) - 1 - + sizeof(sha256_rounds_prefix) + 9 + 1 - + salt_in_len + 1 + 43 + 1); - output = emalloc(needed); - salt[salt_in_len] = '\0'; + output = emalloc(PHP_MAX_SALT_LEN); - crypt_res = php_sha256_crypt_r(str, salt, output, needed); + crypt_res = php_sha256_crypt_r(password, salt, output, PHP_MAX_SALT_LEN); if (!crypt_res) { - if (salt[0]=='*' && salt[1]=='0') { - RETVAL_STRING("*1", 1); - } else { - RETVAL_STRING("*0", 1); - } + memset(output, 0, PHP_MAX_SALT_LEN); + efree(output); + return FAILURE; } else { - RETVAL_STRING(output, 1); + *result = estrdup(output); + memset(output, 0, PHP_MAX_SALT_LEN); + efree(output); + return SUCCESS; } - - memset(output, 0, needed); - efree(output); } else if ( salt[0] == '$' && salt[1] == '2' && @@ -251,31 +205,25 @@ PHP_FUNCTION(crypt) memset(output, 0, PHP_MAX_SALT_LEN + 1); - crypt_res = php_crypt_blowfish_rn(str, salt, output, sizeof(output)); + crypt_res = php_crypt_blowfish_rn(password, salt, output, sizeof(output)); if (!crypt_res) { - if (salt[0]=='*' && salt[1]=='0') { - RETVAL_STRING("*1", 1); - } else { - RETVAL_STRING("*0", 1); - } + memset(output, 0, PHP_MAX_SALT_LEN + 1); + return FAILURE; } else { - RETVAL_STRING(output, 1); + *result = estrdup(output); + memset(output, 0, PHP_MAX_SALT_LEN + 1); + return SUCCESS; } - - memset(output, 0, PHP_MAX_SALT_LEN + 1); } else { memset(&buffer, 0, sizeof(buffer)); _crypt_extended_init_r(); - crypt_res = _crypt_extended_r(str, salt, &buffer); + crypt_res = _crypt_extended_r(password, salt, &buffer); if (!crypt_res) { - if (salt[0]=='*' && salt[1]=='0') { - RETURN_STRING("*1", 1); - } else { - RETURN_STRING("*0", 1); - } + return FAILURE; } else { - RETURN_STRING(crypt_res, 1); + *result = estrdup(crypt_res); + return SUCCESS; } } } @@ -291,21 +239,68 @@ PHP_FUNCTION(crypt) # else # error Data struct used by crypt_r() is unknown. Please report. # endif - crypt_res = crypt_r(str, salt, &buffer); + crypt_res = crypt_r(password, salt, &buffer); if (!crypt_res) { - if (salt[0]=='*' && salt[1]=='0') { - RETURN_STRING("*1", 1); - } else { - RETURN_STRING("*0", 1); - } + return FAILURE; } else { - RETURN_STRING(crypt_res, 1); + *result = estrdup(crypt_res); + return SUCCESS; } } # endif #endif } /* }}} */ + + +/* {{{ proto string crypt(string str [, string salt]) + Hash a string */ +PHP_FUNCTION(crypt) +{ + char salt[PHP_MAX_SALT_LEN + 1]; + char *str, *salt_in = NULL, *result = NULL; + int str_len, salt_in_len = 0; + salt[0] = salt[PHP_MAX_SALT_LEN] = '\0'; + + /* This will produce suitable results if people depend on DES-encryption + * available (passing always 2-character salt). At least for glibc6.1 */ + memset(&salt[1], '$', PHP_MAX_SALT_LEN - 1); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &salt_in, &salt_in_len) == FAILURE) { + return; + } + + if (salt_in) { + memcpy(salt, salt_in, MIN(PHP_MAX_SALT_LEN, salt_in_len)); + } + + /* The automatic salt generation covers standard DES, md5-crypt and Blowfish (simple) */ + if (!*salt) { +#if PHP_MD5_CRYPT + strncpy(salt, "$1$", PHP_MAX_SALT_LEN); + php_to64(&salt[3], PHP_CRYPT_RAND, 4); + php_to64(&salt[7], PHP_CRYPT_RAND, 4); + strncpy(&salt[11], "$", PHP_MAX_SALT_LEN - 11); +#elif PHP_STD_DES_CRYPT + php_to64(&salt[0], PHP_CRYPT_RAND, 2); + salt[2] = '\0'; +#endif + salt_in_len = strlen(salt); + } else { + salt_in_len = MIN(PHP_MAX_SALT_LEN, salt_in_len); + } + salt[salt_in_len] = '\0'; + + if (php_crypt(str, str_len, salt, salt_in_len, &result) == FAILURE) { + if (salt[0] == '*' && salt[1] == '0') { + RETURN_STRING("*1", 1); + } else { + RETURN_STRING("*0", 1); + } + } + RETURN_STRING(result, 0); +} +/* }}} */ #endif /* diff --git a/ext/standard/dir.c b/ext/standard/dir.c index ef28e9feafbc6..55326dbdd3c33 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -492,9 +492,7 @@ PHP_FUNCTION(glob) if (!globbuf.gl_pathc || !globbuf.gl_pathv) { no_results: if (PG(open_basedir) && *PG(open_basedir)) { - struct stat s; - - if (0 != VCWD_STAT(pattern, &s) || S_IFDIR != (s.st_mode & S_IFMT)) { + if (php_check_open_basedir_ex(pattern, 0 TSRMLS_CC)) { RETURN_FALSE; } } diff --git a/ext/standard/dl.c b/ext/standard/dl.c index 4d6a94766a8b1..1960e2ce07e38 100644 --- a/ext/standard/dl.c +++ b/ext/standard/dl.c @@ -97,9 +97,9 @@ PHPAPI PHP_FUNCTION(dl) #define USING_ZTS 0 #endif -/* {{{ php_dl +/* {{{ php_load_extension */ -PHPAPI int php_load_extension(char *filename, int type, int start_now TSRMLS_DC) /* {{{ */ +PHPAPI int php_load_extension(char *filename, int type, int start_now TSRMLS_DC) { void *handle; char *libpath; diff --git a/ext/standard/file.c b/ext/standard/file.c index f7af63bcf44eb..106f5c1004ec9 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -159,6 +159,7 @@ static ZEND_RSRC_DTOR_FUNC(file_context_dtor) static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC) { FG(pclose_ret) = 0; + FG(pclose_wait) = 0; FG(user_stream_current_filename) = NULL; FG(def_chunk_size) = PHP_SOCK_CHUNK_SIZE; FG(wrapper_errors) = NULL; @@ -960,7 +961,9 @@ PHP_FUNCTION(pclose) PHP_STREAM_TO_ZVAL(stream, &arg1); + FG(pclose_wait) = 1; zend_list_delete(stream->rsrc_id); + FG(pclose_wait) = 0; RETURN_LONG(FG(pclose_ret)); } /* }}} */ @@ -2054,11 +2057,11 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char char *tmp = bptr; while ((*tmp != delimiter) && isspace((int)*(unsigned char *)tmp)) { tmp++; - } + } if (*tmp == enclosure) { bptr = tmp; } - } + } if (first_field && bptr == line_end) { add_next_index_null(return_value); @@ -2445,7 +2448,7 @@ PHP_FUNCTION(sys_get_temp_dir) if (zend_parse_parameters_none() == FAILURE) { return; } - RETURN_STRING((char *)php_get_temporary_directory(), 1); + RETURN_STRING((char *)php_get_temporary_directory(TSRMLS_C), 1); } /* }}} */ diff --git a/ext/standard/file.h b/ext/standard/file.h index 0a4512ecd4ac8..2bcdfd64bf5e6 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -115,7 +115,7 @@ typedef struct _php_meta_tags_data { php_meta_tags_token php_next_meta_token(php_meta_tags_data * TSRMLS_DC); typedef struct { - int pclose_ret; + int pclose_ret; size_t def_chunk_size; long auto_detect_line_endings; long default_socket_timeout; @@ -126,6 +126,7 @@ typedef struct { HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */ HashTable *stream_filters; /* per-request copy of stream_filters_hash */ HashTable *wrapper_errors; /* key: wrapper address; value: linked list of char* */ + int pclose_wait; } php_file_globals; #ifdef ZTS diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index ce2987bfc93be..8e88a8508095c 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -803,7 +803,7 @@ PHP_FUNCTION(touch) PHPAPI void php_clear_stat_cache(zend_bool clear_realpath_cache, const char *filename, int filename_len TSRMLS_DC) { /* always clear CurrentStatFile and CurrentLStatFile even if filename is not NULL - * as it may contains outdated data (e.g. "nlink" for a directory when deleting a file + * as it may contain outdated data (e.g. "nlink" for a directory when deleting a file * in this directory, as shown by lstat_stat_variation9.phpt) */ if (BG(CurrentStatFile)) { efree(BG(CurrentStatFile)); diff --git a/ext/standard/head.c b/ext/standard/head.c index 97f61f2bef128..fa578175b1932 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -40,11 +40,11 @@ PHP_FUNCTION(header) { zend_bool rep = 1; sapi_header_line ctr = {0}; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bl", &ctr.line, &ctr.line_len, &rep, &ctr.response_code) == FAILURE) return; - + sapi_header_op(rep ? SAPI_HEADER_REPLACE:SAPI_HEADER_ADD, &ctr TSRMLS_CC); } /* }}} */ @@ -80,7 +80,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t char *dt; sapi_header_line ctr = {0}; int result; - + if (name && strpbrk(name, "=,; \t\r\n\013\014") != NULL) { /* man isspace for \013 and \014 */ zend_error( E_WARNING, "Cookie names cannot contain any of the following '=,; \\t\\r\\n\\013\\014'" ); return FAILURE; @@ -111,18 +111,19 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t cookie = emalloc(len + 100); if (value && value_len == 0) { - /* + /* * MSIE doesn't delete a cookie when you set it to a null value * so in order to force cookies to be deleted, even on MSIE, we * pick an expiry date in the past */ dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, 1, 0 TSRMLS_CC); - snprintf(cookie, len + 100, "Set-Cookie: %s=deleted; expires=%s", name, dt); + snprintf(cookie, len + 100, "Set-Cookie: %s=deleted; expires=%s; Max-Age=0", name, dt); efree(dt); } else { snprintf(cookie, len + 100, "Set-Cookie: %s=%s", name, value ? encoded_value : ""); if (expires > 0) { const char *p; + char tsdelta[13]; strlcat(cookie, "; expires=", len + 100); dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, expires, 0 TSRMLS_CC); /* check to make sure that the year does not exceed 4 digits in length */ @@ -136,6 +137,10 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t } strlcat(cookie, dt, len + 100); efree(dt); + + snprintf(tsdelta, sizeof(tsdelta), "%li", (long) difftime(expires, time(NULL))); + strlcat(cookie, "; Max-Age=", len + 100); + strlcat(cookie, tsdelta, len + 100); } } @@ -237,11 +242,11 @@ PHP_FUNCTION(headers_sent) ZVAL_LONG(arg2, line); case 1: zval_dtor(arg1); - if (file) { + if (file) { ZVAL_STRING(arg1, file, 1); } else { ZVAL_STRING(arg1, "", 1); - } + } break; } diff --git a/ext/standard/http.c b/ext/standard/http.c index 3e5073591e4ab..547df52186959 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -69,12 +69,11 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, const char *tmp; zend_object *zobj = zend_objects_get_address(type TSRMLS_CC); - if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) != SUCCESS) { + if (zend_check_property_access(zobj, key, key_len TSRMLS_CC) != SUCCESS) { /* private or protected property access outside of the class */ continue; } - zend_unmangle_property_name(key, key_len-1, &tmp, (const char**)&key); - key_len = strlen(key); + zend_unmangle_property_name_ex(key, key_len, &tmp, (const char**)&key, &key_len); } if (zend_hash_get_current_data_ex(ht, (void **)&zdata, NULL) == FAILURE || !zdata || !(*zdata)) { diff --git a/ext/standard/info.c b/ext/standard/info.c index e171f72b573bf..20e6b0c4a21fd 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -92,14 +92,6 @@ static int php_info_printf(const char *fmt, ...) /* {{{ */ } /* }}} */ -static void php_info_print_request_uri(TSRMLS_D) /* {{{ */ -{ - if (SG(request_info).request_uri) { - php_info_print_html_esc(SG(request_info).request_uri, strlen(SG(request_info).request_uri)); - } -} -/* }}} */ - static int php_info_print(const char *str) /* {{{ */ { TSRMLS_FETCH(); @@ -660,7 +652,6 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) { char **env, *tmp1, *tmp2; char *php_uname; - int expose_php = INI_INT("expose_php"); if (!sapi_module.phpinfo_as_text) { php_print_info_htmlhead(TSRMLS_C); @@ -671,7 +662,6 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) if (flag & PHP_INFO_GENERAL) { char *zend_version = get_zend_version(); char temp_api[10]; - char *logo_guid; php_uname = php_get_uname('a'); @@ -679,14 +669,19 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) php_info_print_box_start(1); } - if (expose_php && !sapi_module.phpinfo_as_text) { - php_info_print("\"PHP"); + if (!sapi_module.phpinfo_as_text) { + time_t the_time; + struct tm *ta, tmbuf; + + the_time = time(NULL); + ta = php_localtime_r(&the_time, &tmbuf); + + php_info_print("tm_mon==3) && (ta->tm_mday==1)) { + php_info_print(PHP_EGG_LOGO_DATA_URI "\" alt=\"PHP logo\" />"); + } else { + php_info_print(PHP_LOGO_DATA_URI "\" alt=\"PHP logo\" />"); + } } if (!sapi_module.phpinfo_as_text) { @@ -787,10 +782,9 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) /* Zend Engine */ php_info_print_box_start(0); - if (expose_php && !sapi_module.phpinfo_as_text) { + if (!sapi_module.phpinfo_as_text) { php_info_print("\"Zend\n"); + php_info_print(ZEND_LOGO_DATA_URI "\" alt=\"Zend logo\" />\n"); } php_info_print("This program makes use of the Zend Scripting Language Engine:"); php_info_print(!sapi_module.phpinfo_as_text?"
":"\n"); @@ -803,15 +797,6 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) efree(php_uname); } - if ((flag & PHP_INFO_CREDITS) && expose_php && !sapi_module.phpinfo_as_text) { - php_info_print_hr(); - php_info_print("

"); - php_info_print("PHP Credits"); - php_info_print("

\n"); - } - zend_ini_sort_entries(TSRMLS_C); if (flag & PHP_INFO_CONFIGURATION) { @@ -893,6 +878,12 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) php_info_print_table_end(); } + + if ((flag & PHP_INFO_CREDITS) && !sapi_module.phpinfo_as_text) { + php_info_print_hr(); + php_print_credits(PHP_CREDITS_ALL & ~PHP_CREDITS_FULLPAGE TSRMLS_CC); + } + if (flag & PHP_INFO_LICENSE) { if (!sapi_module.phpinfo_as_text) { SECTION("PHP License"); @@ -926,6 +917,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) php_info_print("questions about PHP licensing, please contact license@php.net.\n"); } } + if (!sapi_module.phpinfo_as_text) { php_info_print(""); } @@ -1191,77 +1183,6 @@ PHP_FUNCTION(phpcredits) } /* }}} */ -/* {{{ php_logo_guid - */ -PHPAPI char *php_logo_guid(void) -{ - char *logo_guid; - - time_t the_time; - struct tm *ta, tmbuf; - - the_time = time(NULL); - ta = php_localtime_r(&the_time, &tmbuf); - - if (ta && (ta->tm_mon==3) && (ta->tm_mday==1)) { - logo_guid = PHP_EGG_LOGO_GUID; - } else { - logo_guid = PHP_LOGO_GUID; - } - - return estrdup(logo_guid); - -} -/* }}} */ - -/* {{{ proto string php_logo_guid(void) - Return the special ID used to request the PHP logo in phpinfo screens*/ -PHP_FUNCTION(php_logo_guid) -{ - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - RETURN_STRING(php_logo_guid(), 0); -} -/* }}} */ - -/* {{{ proto string php_real_logo_guid(void) - Return the special ID used to request the PHP logo in phpinfo screens*/ -PHP_FUNCTION(php_real_logo_guid) -{ - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - RETURN_STRINGL(PHP_LOGO_GUID, sizeof(PHP_LOGO_GUID)-1, 1); -} -/* }}} */ - -/* {{{ proto string php_egg_logo_guid(void) - Return the special ID used to request the PHP logo in phpinfo screens*/ -PHP_FUNCTION(php_egg_logo_guid) -{ - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - RETURN_STRINGL(PHP_EGG_LOGO_GUID, sizeof(PHP_EGG_LOGO_GUID)-1, 1); -} -/* }}} */ - -/* {{{ proto string zend_logo_guid(void) - Return the special ID used to request the Zend logo in phpinfo screens*/ -PHP_FUNCTION(zend_logo_guid) -{ - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - RETURN_STRINGL(ZEND_LOGO_GUID, sizeof(ZEND_LOGO_GUID)-1, 1); -} -/* }}} */ - /* {{{ proto string php_sapi_name(void) Return the current SAPI module name */ PHP_FUNCTION(php_sapi_name) diff --git a/ext/standard/info.h b/ext/standard/info.h index aca20796fc4ff..46a0dfc24080d 100644 --- a/ext/standard/info.h +++ b/ext/standard/info.h @@ -50,19 +50,14 @@ #endif /* HAVE_CREDITS_DEFS */ -#define PHP_LOGO_GUID "PHPE9568F34-D428-11d2-A769-00AA001ACF42" -#define PHP_EGG_LOGO_GUID "PHPE9568F36-D428-11d2-A769-00AA001ACF42" -#define ZEND_LOGO_GUID "PHPE9568F35-D428-11d2-A769-00AA001ACF42" -#define PHP_CREDITS_GUID "PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000" +#define PHP_LOGO_DATA_URI "data:image/gif;base64,R0lGODlheABDAOZqAH+CuDk3RyglKszN4qGky9PV57K01ENCWIOGuYKDs1JScpCSwsLE3qqs0ExLY1tcg93e7Ds4PG5xpWptnWFjjXV5sXt+teXm8JmcxoyNwbm62Wtrkk5Oa3F0qXp6o4iLvXJ0o3RzmI6QwVpbfuLj73t9raSl0G1wonJ2rJWWyLu92XR4roWIu5KVw9jZ6pKSxGRmkmtun6WozpSWxS4rL1NRaLO012xqjFxbdoqNv2ZolmhqmpyfyDEuOa6w05yczVVWeJ6hypaZxYGCr2dplz89ULy+2l5giZiZyIyOv4mKuldYfLa319XX6CIeIGxvns7Q5L/A3Hd7tHZ4p19efZmZzG5vmHN3riIeH////5COj1lWV8fGx+7u9dXU1fb2+oKAgayqq3Ryc/Hw8Z6cnePi40tISbm4uWdkZYmJtgD/AEdGX9/g7ZuczGlrnG9zp4yMuri52bi615qbzKeqz9vc65qcyWZkhGhniaeo0m5woIuLucbH4MfJ4WlsnJeYyyH5BAEAAGoALAAAAAB4AEMAAAf/gGqCg4SFhoeIiYqLjI2Oj5CRkpOUlZaXlm0/bXOYnp+gP3l5Nj4acUwaGkwGPj4NMgRBPBhCLQtJIjkfGTkiLymgwqENGgx9TQVQUAN9fAxRUSpyrK90sbNCMy26HwgAFhYVVyglFgkZwcPrjCZxfC5sbBAQdS7JA9QysyIf/iwAEQgEQLDgN4LhpKxA8UbCCT87nkwZkoSdRTVBbAxgQ+KCRxIk8jUQskCKyZMoU6pceXJcBwkTduiAQeEIBStDRFzEFIQJFI4eL7gwQqcFy6NIk6K88iYGjCNHHoxYcsSDzp2Qfmh0AYEjBCMEWCgdSzbplRM6HiwBokDBiCkz/7AuMqGhQBMXdQoYSFK2r1+kHWAsUcCBgwM8CeQayhNlAJQCA3zk+LtyAYbLmDF8oJz0DQUFDtasUeBBsZo8Rvj0GcBkBueVH7JwmU2bS5fXSt0sWXPggIMQO91FYcCgAQLcKzFwwcK8uZnbyJN22F2kyJrSw374kGNEBQ8L0VeqINO8uZgC4ZVeeXAgQAAOcECZMMBEDgEA6VcWEFOeORkV+Sn1hgLu9XAHJnPQ4YMBMhwXoEpdmNEfFlwQ8KBSMazRQw8H7FHJDzI00EBJF6YEQBYTYpHFZiUm9UAAGwInSRsE7ONgiycpN6EZX+ColB9F0EADFZHYEQQBM4CH1P8HmTXZJItHqRDGhGJc0CSJLDHp5Jb4jYWCAzQIUMMjSGAQBJRHffBFFmy26eabWXRRQANdolQAGBOSAWebFwxg4UkL7Ckom10M0IBSQAgggAONzCAEBmIpRcByKVZqBhhcfAEgSl1sUWmKNGyhRRldkGjAlJ9OuAUYXnRxKFIjCOAEo4psI8SNSY2X6qdbeAFBlyfu+ikYY2AgxQB4CqtqGQMkNYITTuCQSAoitIBmUhDwp2yKYUBgEgZebJsiGrdd4Km45dHgRbNIrQEtdoX84ctkZX0hIbr9eQGglPjm2wCK/TZHQxl/HhWAEwIsYEg/9JIVW8DlbdHjnRAzp8X/BeFWjIUY0B3VgaxjEpICAh/UOdakO8I5xhnaTugFAZ1OyMWbY3CBRopaZIFqxHCWcca5E5aBJUsKQJsGId7gOpau/YnhLUoLNNAFeRNqwQDA/a2IEgYNfBFB1VloUTW7gBrwRbL9hWGAUjTMOsgfACCgZFnZ5rmpiVl83XQWGZfH40oQAN1czoIzd8baKn0wBs53H7UEtAqrIYIFJpNlr8wFpxS4qjpT+XRKMfd3RhY0BG3sSqGXp0XjLHUA7Q2CsJBQXw9POMa1J23eHxpZoN3cfyoFG3QZE9KQxVGpD846S0W4rUY4c5OFcn8R9MjS5f0RjrlK4BafxRmqXnAU/9blAa8UB070IEgFlDFdHhqfp1R72uQ3d7tK/Pa3Rdhjs4QB8dtTCgWgJYgVUKZu2VueSQwAvqD1rTnV04/vmAOGLBQOC4djCQOo1p/7CZCAKbgC+/yCvfJUiCXJY04EOre7+J0khVgIA+lMtxIAeG1C5CLLAJ0gCBQYsC/C6yDujkWp7PWuassLYnm8AMB0HU8/HCxPGBS4kh0KogMoGCFZdES9J6LkAwXwQun6Q4MxfOGCJ0xJ9yb0vfBxDwJinFD1KncUK6phIVpcWhSZQy4V+FEFEOjCGLQwRtENoH7M8SBK8sczsWWvC38EZBfK4EiZUXEl6FPf8zpwhb7sR/9VWghlKMVwrxSJ4QsEeKAKvWinCWKhghcUlSi1QMphia8szaPVB97Qgb5ESGNo+MICToVDF5rEXBOSYSEDdsqhSed1gkiBBN7wQ6UosV/NPJYrrbYSRGKBiRoDgzD78jgnRO55EujlWNbYLxqcYZxSQGZ/uPCqramSOW0MWATOcAFnss15gnjBCSTQSaUwUlxmIMMYBlCnGXbQn8TUH//wZQYZMoCOSSmaE45GiCGc4A1joZj+ZjlLMnBhDIVCU6BIGkpWnkQFXGDp6C4oBpaG0qQoZcAQpQMyQ6TgBCdQJ1JgyIUL0IMeBfgjAfxpEkAe9aiZA9QAnkqPQy6TOV7/MOpRk+pHAux0LAdL2CGSEIMToAAp10wkU30khQU0sTxZwChy3OUEeBkiAWUtaHLuuUK2sqQBDYxYx/JTTmkpogR5ZclB+WhMv0qBAZVsDhjQE6By0moRiDWrBKvGAMeqRHdSvCRlNHpZRpRgAjHoQB6lQNR6etYkeXPZ6aLTgQNAq7SNSABqJaDFtGJhDGv10QIWx0a5+oUIPYCWYSOhhCdMQLNS+N8Wpktd3r3WntSlLhgG+xoFyEoAMprEC0DghxjwFgAFoCo9EHddKaBXvRBwLWWIcDAnRICjlkiAG1D7htW2168nsK1yQfGCKfgBtar9r19RwAFZOaEI+AWF/xL04IYD91fBJTrBGhzcg/CygwUUPrAEzorh8BzhAIoSQA9gpxgWgGAHbnBDDKhZYsr4gQMBCJMAAsBi0wgiCSUgwg5gPAEa1zgpEyBQD4QkJrv6eBApSIAedEAEIbshqP7F8BuOgOMNLbkIeHjBkxfxAinr4Mxn3sFHSXzdHRxBAe2B0YYOcAMPjfkRL0DAFIgAgz77mQh++KhQ8zMBIjwANNVxj6JxEAI735kSIhjCnilA6UpT+gh9rnCg38BpTkvg058GKlCJcGm2iKY3B6hOEQJwABxsIDGPFkYKPlACEFgBKlB5gK53PZUlrAUIbGkLYQpjmNCcujdFUAAVbjgwBDHHWjEpUAICPOCBDWwgLb4GdrDbQmzDcIAKIxiBFaxQgmY/+9yLEEEaEHAVdLv73fCOd7wDAQA7AA==" +#define PHP_EGG_LOGO_DATA_URI "data:image/gif;base64,R0lGODlheABDAOf/ABIZISAeIhwhLA8jRwYlVSUoLyIpNSkoKwkvbR4tRBUwVDMuNysxOx87Yg89gDo3RTI5SgBCkDg6PDY7RyBCcTxBQz9BVD9ETxxPkQ9SoktIYkROVkpNWDJSeilVhkxObEZTZQVevgBfxVZQZRxcn1BUYFNTc1FXWRZht1ZYVQBm0ghlzBhksVVafyNlqSpkn1hcZwBr2EVfhABs0lRdcF5adRJpyWBcaVlgYl5dh15efh5q0gdw3iFsxhBy2Rtxxhhx0Ttsn2BkigB45SxwtDFwq0dslGNoc1pqfRtz6GRmkypzwFZuiQl772psaWlpiiF25Ax94zB10BB+3iV44BR96yN71TJ5vit7zih73GluoDt6tk53nix66QOG+nBwl0l7r3F2cjOAzSKB9guI9SKC8HF1lW90pm93jTCC3SaE6zWC12F8knR6fHV5gzaC5SmH6ESC3y6H9kGGyiqJ8UuDzXx5oWV9v1aA0nl6qWmAnXl6tHJ8tV6AyVGGuS6K/EyHwyKO/D6J5T+K2SGQ9zqL3ziN9jaP6jmP8WaHwYGCsHqIkC6U/C2V9naFv0GS50mS2IGFuYeHnEWU4iyZ/16P2ISIr1iSz4mLiF2SxV+TvImLlmiSsnqPrIeLvzmc/kOa9Uaa74aNtHWRyXiSvk+a6YyNvIGQwo6OsImTnFib3lKd5l2d2kKi/WSd0k2h9zeo/1Gi8ZSUw5GVyn+czE2m/46bsY2ZyHugwUmr/12n8GCn6pieoGWn5Hekzpueq26n25yby1ms/ICk25ejrlGy/56iymav+V2y+2yv7Wex9KaopWG2/1e5/5Wu2H216265/HW3/qus0aavxWe+/66wvYy33YC4+Hi7+bO0uHPB/aq3wa6112vF/4e/9pfA27u31YDF/XnK/5PG77y/25TI/MDBxYbN/qvH7LfH2qPP+47V/57T/cPN2abT9c3M5Jna/77S7LrU57HV+KLg/7zd+tbb3dbb6a7l/sbh99Hi+Lrp++Pm7+Hx/P3//P///yH5BAEKAP8ALAAAAAB4AEMAAAj+AP8JHEiwoMGDCBMqXMiwocOHECNKnEixosWLFoNpDIaxo8ePwaRJ4yaNHDhw5EySFCnNmEtjt2TJMmXKk01PpmbN+sgTZEly7+7de0eUaMqj4FaKfBlzps1IkfZI3cMnzx5Fnnb23MrQGLig/PgJHTvUZEtjNZ9CXcu2bVSpfPicOaOlrpY8ikxx3fvPGLd3YQOHfUdOWkw+jkaNEjVtquPHkCNLnVtXieUcSr7k5YvRK2DB9wrLctSnUi9dxYpRo6atEy/JsGM7pqskh+0WLXLY0csZYrC/QsOGNubplrNkxWq1Wp6rObNu53y5kU2dupbaLUxob5FHVu+Fxsj+kb3HzdTUc/TonWtWrLnqXMWaiQvnC031+7LPKMn+4YOGJ4p8Z1BJRA0ljSeQ1XMOPOt00wx7xYhDjWrinDNOEFzQwgd+HEamnwkahGiCHQL+QyBR4MgSWzjw0CNOM+4xKN868FhjhB/PqIMON844c8spp6zlSSSexIXYUx06pkULGlhggQZfcObVUdK8FRs70NCzDnvNUeNgN+vQ4w4XfvSizDHIQAMNM8LooosyaWqDDTbhhOPNnc9g88www/RIHH5nMOmkBiT2FNJRxuBXjzAMTghLK/IVAyY843TgAhaHIKIpIXDQgUgjhwjySCijllLKKrqssssuqaqaTDL+e57CYQ4WPPDAB7x15BdKxlgp2zi9JBPLOetQkwsssBTTYDPwwMMOBSRYgQghdMhRxrVl0AHHG9xuO0UWghRSyCOlTCJuIZNAoq4qwMh63xkm2LrAExiFNFKV96GzyyOICPNIOfRQs9wnucCjTTf07OMOBREAQQcZZXhRxcTYUmExFVFEkUUWaXTscRqhlDuIGGJA0ssoHGqhwQILWJCrRPZKo+J9z5xpCBnUNtrKJwTjc4426bHTQQQzVHFtFU00AUUXEw8BxRBUDBHFtnAIksYUVpOLzDGpTjLIIJA40mEOD7AcJczGtORrbJ48E8orn8jhhRyv4AMPMrBQAkv+M14ijI/QRHeBLdJdMA3F0jzwAIUPb2iKCBwbTwHHI6PqEoub6c6xYcoWHHCADhEF49LM1UWyCyigEMIIIYY0EY56xeycCzO5NAP0PoDPEDG2XSR9eBeHQ8GDD3CUk4862AgD+cZZwAHHIY/EEssqkGjeIR8aeD7CQ6L/eZ8jlWg6hxVkQFxFi8bunOze4tCDzzgNOFB0E9c2UcUYSRd++BA++JCFPm5wwjLKcQjnZcEHQJjcuB6BKl2oQmwdMoHnNNAQWdyiV/iJRB2yoAY1vOEFVbBWFegBD3HkYjmtaI+X4PG++PmgfnKIobXKEDWnDWF4abgHBwzgBG/AQXL+kANCGg6RBitYAQtrgMQqVgFBDrXgAAGgoEJkcou1xeYWdZjCFKKghiqQQAr4o0N61hG7T+gtF+IQBz7wYQ0FEG0M12IEz0DBM001QlNU8EEa2nEBA7QBG5ATxLeAgMRChGINP0jkD7AghkQ08T4tCEAAapCQWZhCFgi6zyjWIAhr2MIFQ5DaD4bQBUS4Dx7NeJQZYQGdfdDjGQOIQAzo14h5yCMf+ahHPfIhj3ZsQx7QgMMg2jEBAbQBecd4xSOIuIZmkguJWFDkJWiRJA1IslAFmQVOMkmdSFxiDYfQhz/8gYQodMFpwAsFPlzZjJ0xohVoPMc+4OEKAkSACnL+IMQxsnGBC3DgnyXgwAYusIFslGMV1SjmAU6AAzfwIh3YCMUkelEKcj0CXWuI5hzmYA0ryuYBATiAdwqSlvvwQRVYyMI8xumPVKTBaEgrwzHWCI/YMeKdxdBG+9jBBQJkoAqBQAQ2NlECGJSABjCgwVEDygBzeGMTEyiAAUrQTwYUIAzeCIUtiPGNZ+jCVI9Iww/EcAlX+OIWHDoDFLdHkFkQyaORuURKB5GCaoxTD4gog7WaMAZvjJE9rUjWg9JTKQKggAyMaEQ53FDUauAyl/r4RQkY0AZ+HOECASBGNX7BWAEAYBGlYAJBcRAGTGBiG8oQK1kzwQpSbK46JpD+5MuGBFfI3AELQKBCEAxQgHbYwwWNKB+22JEeF7WHldQIEzy8kQAEZOETO5sHDU5Qgm08QxiNgEMhzFGCAlTgHiWYgATycad52KKYJ3gGCATAgA1woJ8GwEQpevCDQQACEHMwqzPuA0Up/sOttX0MH3oAhBn4wAPTOAANNpEFMuyVfuxoETy6cSxJSXgdroglHGbXCnnQwA1HSIcyJhaFQqSjuwzYBgcYcIRywCENkPhFAQBwAmJ+Nh7TIAYaeAsMIPRADHPwwxKuAAhXkOIUpJNMJAMwUvMEeCoDtsEKVjADEhQgAAIggRrIUIXCNYEM7KARPNIHC3Gs48zhkIH+YUEhDIGlgwM3cIMtjlEFKrzhEe1Y8QIka4BFxEINgngGGjy7iGp4Fhe64Fo8DAAATkyhB1iYQxBcsAQiXGELW8iENcwjmTNIkl7/ePJUPLEEKatABTsAAgUSgAE43OxavVMDO85h5mZANxfJPbM3GoCANLyiGMyAxDQ4AINNWEMYhEDEIdTxiwsU4AhouIAAqoEINWTBGRAAAAC2MWgGJEOZj7hEAgDAhTSgAAtXeIELWMBuEpCACJl2RqIiY4EoCsSkgOjBCmIQgx34GwiF4CAhhHutRqwjjetABnRhQawzZ2IAGXiFMNqjilT8MxvooAYzoMGObBxhAgywBxL++oiODmahE4xmQDuyvQFtvCIUhfCDZzlxiB8sYQ5bIAG7WeBuF5CgCGDwAy6SLJUPBGAB967OKbBggx3wIAYq4PcOfBAFOljdwVXwAjPCcY5uSCgXyulGs8rRAQLUgRlsyoU30MCBEpjjHubYBjGcQGwIpOIeMJjABp5BBzVYAQmePcI0ZkwMbQgjFpDoxKHhIIYrXKEIL3gBEdTtbgz8HNOcgIwSJCmQ18LGE3MAwgpUwIMh8LvfPqBCsgcOMTLQ6WDnmBB75lOODDsgFhpnRivmAYK2X4AGE7hA8IvqhnhUY8Vt8IYa6FAHC2h7G0gAwAbkMQ49pYMGAJAAKwT+MYgrECEIHog8vOHt7hcUYQuZf8zmA/Df6owCC1OOOg/KUIWnx2AIjYCbIT5BBkNwHRoVcg7MkFPUcA7eUHZigAy0Iwy5IA8QAGdHAGJHAAMw4AbbMA+PIAkcMAG8UA5UoAaJwGgXkA7ZJgG8cIK8AAOYlQrmMgiWFgQyAAZbQAQu4AKRB35BEARbgAvqx3n/EBeyUQdSIAKoFgM+MARkoAZPFwWH8AqtMC37Bw3noCZmdg51Uid+AHG6gAwMWAu5sA0TcAMlwA+5VA/zEA/qcAyIUArtQAzEcA/XQAVwgAsW0Ge2IAEAwADvBVAX0AbPUAhgA29GgAZ2wARgAHn+JPACYLAhlsAFXOAr6ycQZ+B5kDEKPzADoxcDw/OBZaAGqfcKyAAKzNEKwhAOycMiB5cM4QAMCuAAk6ANtOOF0PALxOYG/XAMn9B3VmcI1vYK0VAO0QAKQwAH4xAP98APSMBb9rANqbAIbpAK1gU9I+MCWyADViEVXAAGL+ABMiAKsBGJP0iJjnEKYtB0UcdvPEAFj1MGQ6AGsRAO0KANasIMyKAM2nAMUpgMu6AKl0ABCPADCrgzlNAKi1UCJbAJ/SAMhlAG+1M+VJAtjUAIVMADnggEVkAKHCAAOOANwrAL3lAOyhAKhyAujQdvLeAYkZAJWwAGRgAGcGV0SPf+D3twBrBBCz+wbzvQb5rYjocACogQCsKgDcmgDXUiDtCADLrQC7twCYDgARRAAAhgA8sBC59wU69QDzTQdsSQD7kgQkNQBWRAB1FTOFUwAxTpAzbQA53AAABADNAACj8EB8o2koUwB5dABGBwkpDhB2DABeIoFfUmRZ4wF5FhCnNgAyIweudYenCgBqUQC6FwDMpwCZcQDuIgj/QoBhjgAAiAABGAAoeAQq1ACYxACbnQD8SQCr/AD+wACnJgOF0gB0l4Q1BABTuAhFQABGswaAXwDcIACm8ABEAgOWmALqswB98nBJEBhJ32aQIxC3MhjqfwAzbgA5mYOFDzBnD+AIqxIAzQoApqgg0AGA7FgJRr0ANWIIrKwTNVeVOtcA7lwA7qUA6toFdlADwhlIRwIDw8MAO46QOq4EvtgA1PSAVU9i1TAIjdRwQyQJMdsmQjJZOE+RiJgJgr4G85eYRcBAehoAxvogtzIJnHsHU/U570CAqUMJDtGQgsGghyEAipwQgLKTiFwwP0Y3VUUAVQwG/0wz9AEAq6IAwF6gMxMAPDmQZYMDLw9gFJsgf91VZa4KCOIQYhMGX+dkOpJwiv0ITSswu9sAXKoAxrwnVT2Aq0U5Us6gVj4AV/4AVuOgayWQZKMzFQwJD2Uwaf0nemN0sMOQPVyYSgoAZRMAT+MzADWWBESep9QWACSRJbAfAy/6AIUeoYjrAEISACiTkDVAAFHVQ1QJoqqpAJXHAJpRCPxGKFDLgzaKqmY7Cmc+OirZo099llWVcGhNAIPlkFQ5CTE8MDK2ADUfAKjaAGX9mffmoDRyQGRFAEMpAkahUAbAWlkyoVpmCpU9ZviVMFzgMKoTA9quAHIAABMgAJukAnVmh4yqGqjOCmavoHbeqmMeQFhuAFSUM/clAFt5o6N6QCsUkGUGCkbNYKXMY/MxACBktfiiql+AFSInUQplAXm3MLV2ChM8BvnKpsoCA9q8AKIBB8MNAJvYCU0BAOsEg7N0WagcCmf7CmcqP+pl4AMU3AA0nQBHNDBqCAq4SgBjwKMTxgA3Bws2QQCOwIBDZgsCGAAijAAkSgBNV0TQkhqVowFXOgb5m4A3KIOofQravgCv2EBlFxCqzwJtigDfIopGj6B4HgroHACHLQpoaAPxGTOE0gm4QgiohQBToLBS/bBf0JBy5KCOzoA/SFAkeLtCwQBEmyZJSkEHlQF1LhCjeZiUaoBoggCC9WCKWgCRNgBo7BB6OwC8rAdfLoTmzrru46BmjLqknjBUkws0GLq69QbVRQNLLZBLs6BNlSBVNjBT2AtL7LAi7AtE4kSf7FuHWRB7TAdIrJb4VKdVlwCLqgCRcQGZ+rU/D+eEJoOgaBsKauCqdkUK/1ijOgkAtwmUcvVD4xW3p0ADxRAASYerRLkAEZcLgRRLwP0bhaUK02UKinJzwW8wbQK72SMQracK4Tdyw8Q7ot6qJyUK9dVgafAAqxCwdRcIQvS69OYzQ8oAJWWqg2sAQukAFXcI3VcQb1Zm8QIamKMLGYuJMTmXocmgycML2S8QxXCA0a1x7tWQvIgAyyA13r6gVlkITQlSkV/JDcGzx1+nSh5KOEdAUukAj4oQQLIEmLGxGm8AWQ0AP7u2+lJ4eI8AqSKcCScQrnYIXUIAxww6JoGwitADe31go3VZVPyK2QY2CqI1zAMwR0QH+h9IH+U1CckxBk3ghbUHQAZzMRwcAKkXuhBna1r/AmmUDDNUyy2oAMuVCVbfsHhCAHhvAHMbS2awu7W3oIUmADWYAIrdAImlwGjdAIgWAIA2d1zyNRG8uD1KEEIBUAEgCpEjEOa4CJ+5Z6VysM9QgMG/CXUvEM2kANOCwMtcAIaXtT0iw3oMyilEAwuRAKoVBEaTC+ckzNN5VPrEctcNAIo7IKyYDLsKEFJzxJHjEIUubFX6nKbaIMwEADlgAbySMMbCIM0tyiN+WibhrL7vnGsaAMkDAIsXAMwgCUzQE30izN5UMHyQYqDJQMvgAbfPABUBQALvMRqmAFhXqbH6jKDo3+DL2ABJIgGXygDasskC1qCIbwogu8ttCVQuWpDZegCvdYCkRZtlXpYMJl0VGgbJfTC8DwGKjAByrz0QuQyB6RDGlQqM2rBuf8CpezC5xwBPy8xmRwzS4a0HLzou7phWhXjy/ACspQCshAlOGgxmgaCLOJt3J4CKai1L5CK55zAPPCFX/opzPgb1RXy6WwC5oAA9z0GL0Qzg7WtgtsCGlr0+8kDJYdJx6wBazQCw7NDNpQC+tJCSwqm4aAMbU8CaowCuahBR/wAH39AKC2F5NAtBc6dVQXBYJwKq4AA5bwl6uQOgHNrnJQzaBs1gMZ0bmgDcrQAAPgAZcgppg5MIb+cFMQcy1yuAZ9cAd7oAXxsgB9PQLYxBeQUGAVW7H9EwVTcNjAUAJfYBdS6gmlgAhBG7RuSgij3bY2nc21wIC58ArQoAsNoAAYAAbQIJ7Q0B7qKt9VkAXYLRc50Nos490W8ARa8R2qQJ3XqpPEk9DJgARmYBkgXheTeAd9sAZxoAbWPDdqet9yBE8nlAv/TQEUcAWqMLbNDM2fQDl4kN3bnQMmUCtlwzIT7su9AbnzvLw+MAXKgA3JwAZu4FZ5AOJSrgQifgYk3gd4YOLc4jgRLJqX45R2yQp8MgqOsCHX4eNNAuS28gA18AVEXiLleKmJqQIGlgXlus4wQBCmoAjAUT7lII4ZVO7eczHohG4X13EZ2hEiTrLotWIBbR4gJaIQl0C4mBp/SV4KSQkMOIAQ2pQHefAFthHqop4DuIEb2nHq2tEf/REirM7oJqADAFLhkc4QlI6pdH6kupAMu+0QlhQJdmAHX/AF2JEdqJ7qqq4BH6ADuBHseCHrs/4QkEu4iJlqFrkGk8AKrrABPEETkfDmz94RgEC4IWCkVpAG4eKlmiAB377uFeEKS4ACNvADQpQG5LILwMAE7J7vAhEQADs=" +#define ZEND_LOGO_DATA_URI "data:image/gif;base64,R0lGODlhcQBIANUAAA0NDgEDBgIFCS5EXhUdJwUPGgQKER0rOgABAgkZKiZpqxhDbQ0kOwobLQkZKSNgnSBXjh1PghpGchQ2Vx1NfAoaKiJYjQoYJgsaKQECAzdQaS0/UTE1OQUPGAkaKh5ViiFclRpJdQocLSBZjh5UhhpIcw8qQxc+YwwgMwcVIQkaKQgXIwcZJTM6PwIEBRkaGjEyMv9mAP///8zMzMfHx7+/v6urq5KSknNzc1VVVTw8PDc3NyYmJgcHBwMDAwAAACwAAAAAcQBIAAAG/8CZcEgsGo/IpHJ5/DGf0KiU+Ks6p9Kr0KrFer9GbReM7IrJ6O95Zt262durUy5uD8/rtL58h7vlf3+AcHlsdoR7iU12eIhzbXVVfpOTgGOKiWNrkpKUhZ99iJijl4d5kFSdXKmdb6OvsFOXsbS1oba4ubq7vL1DNjg6ODW+xVg3OTw/AisCOMbQSsA6AD8FDAsjIwwv0d5DNcnLIhMU2uclPzbf3jwC2Ofx585MwTfssD8n8vwjKDpLcggo8OMZPkw8GPSTN6HKCxg5hhHJ8WOCv4IHFeEwsDAeiQULJjBYUQXGM4oWtTU0mDGNjR/mOi48gcJKynMrW+oBcFNmP/8SJnri/JFDJ5kaL0T4XLqwYVGjWGy8MFCCqVWGRKFKsQGgAImrYIc+1bqEq9ewaEc0vEc2CdKzacOmY9vWxjoiMAx81Sajr9+/MhaE2Iu2hAAexPraJUbGxo3HkB/f/XKjCgBhwH5kOwcYsAoU5dKSMIBYSN8cOSZvxRGjtevXOnREZDwFhogSE1AYqKIwXl8VBlKoUNHXgAEUJwhfJVGgtGkZsek+Afa6uvUY0bFUjEdhgnJtIUwwmLDAb4cU3tM2pz2jb/YnN67Lr/4eSuWYPkmEGDyiL4MODITgm1+CkdBZgSh00xkMOkiHRHzWxSahDvNJyN4SG6HV1wSfJcf/GWAMdObfCQv8IOILDUoj34QTrhgbS0zAgEJYfqGgQnp8yXACA8N9NkFfHQRX4wl+6cADDH2h6KBdz7jIYosRShjFdmD5B6CAH/JIHkgh9JUCeuXJAOBpPDTYF4MO4mDCAU5KmMMNxNDAWpSx2QdTlTJwiNxeIhbYnwzDZeMlcTLAAAOc7qVIxAsVsrjkdRNCkeFVNd5ImIgqmCDgbyoICiihZd5gQ189KDoDDTcYcN1lE+JAgxE2QCrlEzLi+V+Af+4XpnHCafpnoL8SWugNOwD5gqg4oMbDCtahkAGD9RUBIX2xjbUElUyJ6BcDJoQJ2AldfuppoCJe0IEOB5hw/wIEKFRQnQgesJrDhUTI+iJ8d2arbXGdjhDub6BxOm6nJvzVwMEMSCDBAw+AwIAHr3kgQgdl5vAqEjXYq4NqSeAgAFjd2djjyL7qJ9JwDCQXnq/+mqBpCQXsWIEHKVPwQcMgOOyAaw4k0EAKGCmhsbVKVLbCBFUtte+GC+ylH5df6cffCFIbKAMJJ5A4GARcdz2BA2CH3YAIDABA7y8aO1g0NeOEttDSgLJMowwuh9D13VwDFTbYCZjQMEBIDO3FNACY0NFvwY3M72ZoLWCACRTgLfnXYTPwAQgKmFAUDjjQ1SbHtfXWz29gggSSSHKHRcIKJkAAguR4R/C1CJFD8P+AAiykABoCQrQJoxc4FHC4uPLod+DUfxI4mF8O/AhYgXj/JdjNEUSgwAMY1ECDxjpcDEZl330IrDzapvyViCn7FUD5yXXdWcqXg3D7CdPCNqHaWNSA7YDPIw+kkH1BTo3OA6QA9UUAIvhfCoZEAgj0ZUdhA03tRvAAEvhuDzpQCj8wJTcvgamAVgqYDIQTpgIkcIQfFFOAHCgDBjTPdFvj2gPaRDQy4CBf5JMBr4bTQeINinTe+U0BCiYDBzSgL2BbAAtT4IA+xbBrIODe2cDwghltEIVb8p8PPyWwPxlAAERsgAeQ6AAlklFEDtAUFKNIp9iADlXJQs2bbuA9Jdz/ED/i69eHwgUsTvkFPVb7QQUk0BcPNLGIZWRhEsPFqzTazXUzbKOphBCrNnaujkUwS/jgFqItkqszCKDdGRFpRlJa7VuDiaQliVBJ7t0LVl0JX/K0ZYAuCuyUfrEGBUaZREUmEgL/KiJoIqBKagljCPUz5pN+N4MaxLIj4RmZNINSN/BUE2s86gsADBABEJSgbit7ZDjzFgKRgC1lEJgPdiw2g2Ta70lvOkINeACXhTzNdPgUDAX24zR+asN4MjiSAS73AX5WjZxPhMA9Q/ABdbYGVY1aJuiGsBFZxqUjhhFGDlwgP4aN4HWwC2nXLOjQiLJIInbUy0Wt4pQa2IUH/ydQwARmKr8RiDSkJW3T/TCJMXpadKX/ZEBWKEqAFgDgBjCYgAJAetO75VSZjuKpEuYpgKQBlR8lYqZdhsCBhTG1qSR96pMkREcvUNWq/CBPXOixBA5QIGdN5dpTsTPWBkk1CmftR0N+YACkhUUEgJOGD0jwVa7l7LCvy2ld33TXKeQ1HiuxQQ5eUIUVoEBdS5kAAJ7gghM84G45Y9jtSgCCCHjAA2PzwGHqOqF4KuKxagkaJTmngxcIzycU+AH+iFADFCwVtCAgTwRQEIALQEAEIlBBB15QJtbKZrdpqAEMqhrbGiIThx0pgHWJgAMJ/NawDxhADzj3DBioSwQGAIfADpyLUloIpCbbHQJPlsIAGCxhBxa4HcM6at865qCcRFlsWXORA5MwIYMyWQADBBBfIdzgBRpAwVtvpzkjhCM1lHQMZKb4DY/xozsiEMAPeNDeJNDAMT/YwAkkwICJcpgsL9mMgglyGRxMlAmiAoCN2zIFeoZ4xK6NLo+nYIMX3XjISNZKEAAAOw==" BEGIN_EXTERN_C() PHP_FUNCTION(phpversion); PHP_FUNCTION(phpinfo); PHP_FUNCTION(phpcredits); -PHP_FUNCTION(php_logo_guid); -PHP_FUNCTION(php_real_logo_guid); -PHP_FUNCTION(zend_logo_guid); -PHP_FUNCTION(php_egg_logo_guid); PHP_FUNCTION(php_sapi_name); PHP_FUNCTION(php_uname); PHP_FUNCTION(php_ini_scanned_files); @@ -83,7 +78,6 @@ PHPAPI void php_info_print_box_start(int bg); PHPAPI void php_info_print_box_end(void); PHPAPI void php_info_print_hr(void); PHPAPI void php_info_print_module(zend_module_entry *module TSRMLS_DC); -PHPAPI char *php_logo_guid(void); PHPAPI char *php_get_uname(char mode); void register_phpinfo_constants(INIT_FUNC_ARGS); diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 25766818f6b50..4c243f778f17f 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -21,10 +21,12 @@ #include #include #include +#include #include "php.h" #include "ext/standard/info.h" #include "ext/standard/php_string.h" #include "ext/standard/basic_functions.h" +#include "ext/date/php_date.h" #if HAVE_SYSEXITS_H #include @@ -246,8 +248,16 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char return val; \ if (mail_log && *mail_log) { - char *tmp; - int l = spprintf(&tmp, 0, "mail() on [%s:%d]: To: %s -- Headers: %s\n", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : ""); + char *tmp, *date_str; + time_t curtime; + int l; + + time(&curtime); + date_str = php_format_date("d-M-Y H:i:s e", 13, curtime, 1 TSRMLS_CC); + + l = spprintf(&tmp, 0, "[%s] mail() on [%s:%d]: To: %s -- Headers: %s\n", date_str, zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : ""); + + efree(date_str); if (hdr) { php_mail_log_crlf_to_spaces(tmp); diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 29419d211f2f2..672c0652219b0 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -99,7 +99,7 @@ static void php_pack(zval **val, int size, int *map, char *output) /* }}} */ /* pack() idea stolen from Perl (implemented formats behave the same as there) - * Implemented formats are A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @. + * Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @. */ /* {{{ proto string pack(string format, mixed arg1 [, mixed arg2 [, mixed ...]]) Takes one or more arguments and packs them into a binary string according to the format argument */ @@ -170,6 +170,7 @@ PHP_FUNCTION(pack) /* Always uses one arg */ case 'a': case 'A': + case 'Z': case 'h': case 'H': if (currentarg >= num_args) { @@ -186,6 +187,12 @@ PHP_FUNCTION(pack) } convert_to_string_ex(argv[currentarg]); arg = Z_STRLEN_PP(argv[currentarg]); + if (code == 'Z') { + /* add one because Z is always NUL-terminated: + * pack("Z*", "aa") === "aa\0" + * pack("Z2", "aa") === "a\0" */ + arg++; + } } currentarg++; @@ -250,6 +257,7 @@ PHP_FUNCTION(pack) case 'a': case 'A': + case 'Z': case 'c': case 'C': case 'x': @@ -315,16 +323,19 @@ PHP_FUNCTION(pack) switch ((int) code) { case 'a': case 'A': - memset(&output[outputpos], (code == 'a') ? '\0' : ' ', arg); + case 'Z': { + int arg_cp = (code != 'Z') ? arg : MAX(0, arg - 1); + memset(&output[outputpos], (code == 'a' || code == 'Z') ? '\0' : ' ', arg); val = argv[currentarg++]; if (Z_ISREF_PP(val)) { SEPARATE_ZVAL(val); } convert_to_string_ex(val); memcpy(&output[outputpos], Z_STRVAL_PP(val), - (Z_STRLEN_PP(val) < arg) ? Z_STRLEN_PP(val) : arg); + (Z_STRLEN_PP(val) < arg_cp) ? Z_STRLEN_PP(val) : arg_cp); outputpos += arg; break; + } case 'h': case 'H': { @@ -511,7 +522,7 @@ static long php_unpack(char *data, int size, int issigned, int *map) * chars1, chars2, and ints. * Numeric pack types will return numbers, a and A will return strings, * f and d will return doubles. - * Implemented formats are A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @. + * Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @. */ /* {{{ proto array unpack(string format, string input) Unpack binary string into named array elements according to format argument */ @@ -586,6 +597,7 @@ PHP_FUNCTION(unpack) case 'a': case 'A': + case 'Z': size = arg; arg = 1; break; @@ -662,9 +674,23 @@ PHP_FUNCTION(unpack) if ((inputpos + size) <= inputlen) { switch ((int) type) { - case 'a': + case 'a': { + /* a will not strip any trailing whitespace or null padding */ + int len = inputlen - inputpos; /* Remaining string */ + + /* If size was given take minimum of len and size */ + if ((size >= 0) && (len > size)) { + len = size; + } + + size = len; + + add_assoc_stringl(return_value, n, &input[inputpos], len, 1); + break; + } case 'A': { - char pad = (type == 'a') ? '\0' : ' '; + /* A will strip any trailing whitespace */ + char padn = '\0'; char pads = ' '; char padt = '\t'; char padc = '\r'; char padl = '\n'; int len = inputlen - inputpos; /* Remaining string */ /* If size was given take minimum of len and size */ @@ -674,15 +700,45 @@ PHP_FUNCTION(unpack) size = len; - /* Remove padding chars from unpacked data */ + /* Remove trailing white space and nulls chars from unpacked data */ while (--len >= 0) { - if (input[inputpos + len] != pad) + if (input[inputpos + len] != padn + && input[inputpos + len] != pads + && input[inputpos + len] != padt + && input[inputpos + len] != padc + && input[inputpos + len] != padl + ) break; } add_assoc_stringl(return_value, n, &input[inputpos], len + 1, 1); break; } + /* New option added for Z to remain in-line with the Perl implementation */ + case 'Z': { + /* Z will strip everything after the first null character */ + char pad = '\0'; + int s, + len = inputlen - inputpos; /* Remaining string */ + + /* If size was given take minimum of len and size */ + if ((size >= 0) && (len > size)) { + len = size; + } + + size = len; + + /* Remove everything after the first null */ + for (s=0 ; s < len ; s++) { + if (input[inputpos + s] == pad) + break; + } + len = s; + + add_assoc_stringl(return_value, n, &input[inputpos], len, 1); + break; + } + case 'h': case 'H': { diff --git a/ext/standard/password.c b/ext/standard/password.c new file mode 100644 index 0000000000000..212799100c303 --- /dev/null +++ b/ext/standard/password.c @@ -0,0 +1,460 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Anthony Ferrara | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#include + +#include "php.h" +#if HAVE_CRYPT + +#include "fcntl.h" +#include "php_password.h" +#include "php_rand.h" +#include "php_crypt.h" +#include "base64.h" +#include "zend_interfaces.h" +#include "info.h" + +#if PHP_WIN32 +#include "win32/winutil.h" +#endif + +PHP_MINIT_FUNCTION(password) /* {{{ */ +{ + REGISTER_LONG_CONSTANT("PASSWORD_DEFAULT", PHP_PASSWORD_DEFAULT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PASSWORD_BCRYPT", PHP_PASSWORD_BCRYPT, CONST_CS | CONST_PERSISTENT); + + REGISTER_LONG_CONSTANT("PASSWORD_BCRYPT_DEFAULT_COST", PHP_PASSWORD_BCRYPT_COST, CONST_CS | CONST_PERSISTENT); + + return SUCCESS; +} +/* }}} */ + +static char* php_password_get_algo_name(const php_password_algo algo) +{ + switch (algo) { + case PHP_PASSWORD_BCRYPT: + return "bcrypt"; + case PHP_PASSWORD_UNKNOWN: + default: + return "unknown"; + } +} + +static php_password_algo php_password_determine_algo(const char *hash, const size_t len) +{ + if (len > 3 && hash[0] == '$' && hash[1] == '2' && hash[2] == 'y' && len == 60) { + return PHP_PASSWORD_BCRYPT; + } + + return PHP_PASSWORD_UNKNOWN; +} + +static zend_bool php_password_salt_is_alphabet(const char *str, const size_t len) /* {{{ */ +{ + size_t i = 0; + + for (i = 0; i < len; i++) { + if (!((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= 'a' && str[i] <= 'z') || (str[i] >= '0' && str[i] <= '9') || str[i] == '.' || str[i] == '/')) { + return 0; + } + } + return 1; +} +/* }}} */ + +static zend_bool php_password_salt_to64(const char *str, const size_t str_len, const size_t out_len, char *ret) /* {{{ */ +{ + size_t pos = 0; + size_t ret_len = 0; + unsigned char *buffer; + if ((int) str_len < 0) { + return FAILURE; + } + buffer = php_base64_encode((unsigned char*) str, (int) str_len, (int*) &ret_len); + if (ret_len < out_len) { + /* Too short of an encoded string generated */ + efree(buffer); + return FAILURE; + } + for (pos = 0; pos < out_len; pos++) { + if (buffer[pos] == '+') { + ret[pos] = '.'; + } else if (buffer[pos] == '=') { + efree(buffer); + return FAILURE; + } else { + ret[pos] = buffer[pos]; + } + } + efree(buffer); + return SUCCESS; +} +/* }}} */ + +static zend_bool php_password_make_salt(size_t length, char *ret TSRMLS_DC) /* {{{ */ +{ + int buffer_valid = 0; + size_t i, raw_length; + char *buffer; + char *result; + + if (length > (INT_MAX / 3)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length is too large to safely generate"); + return FAILURE; + } + + raw_length = length * 3 / 4 + 1; + + buffer = (char *) safe_emalloc(raw_length, 1, 1); + +#if PHP_WIN32 + { + BYTE *iv_b = (BYTE *) buffer; + if (php_win32_get_random_bytes(iv_b, raw_length) == SUCCESS) { + buffer_valid = 1; + } + } +#else + { + int fd, n; + size_t read_bytes = 0; + fd = open("/dev/urandom", O_RDONLY); + if (fd >= 0) { + while (read_bytes < raw_length) { + n = read(fd, buffer + read_bytes, raw_length - read_bytes); + if (n < 0) { + break; + } + read_bytes += (size_t) n; + } + close(fd); + } + if (read_bytes >= raw_length) { + buffer_valid = 1; + } + } +#endif + if (!buffer_valid) { + for (i = 0; i < raw_length; i++) { + buffer[i] ^= (char) (255.0 * php_rand(TSRMLS_C) / RAND_MAX); + } + } + + result = safe_emalloc(length, 1, 1); + if (php_password_salt_to64(buffer, raw_length, length, result) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Generated salt too short"); + efree(buffer); + efree(result); + return FAILURE; + } + memcpy(ret, result, (int) length); + efree(result); + efree(buffer); + ret[length] = 0; + return SUCCESS; +} +/* }}} */ + +PHP_FUNCTION(password_get_info) +{ + php_password_algo algo; + int hash_len; + char *hash, *algo_name; + zval *options; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hash, &hash_len) == FAILURE) { + return; + } + + if (hash_len < 0 || (size_t) hash_len < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied password hash too long to safely identify"); + RETURN_FALSE; + } + + ALLOC_INIT_ZVAL(options); + array_init(options); + + algo = php_password_determine_algo(hash, (size_t) hash_len); + algo_name = php_password_get_algo_name(algo); + + switch (algo) { + case PHP_PASSWORD_BCRYPT: + { + long cost = PHP_PASSWORD_BCRYPT_COST; + sscanf(hash, "$2y$%ld$", &cost); + add_assoc_long(options, "cost", cost); + } + break; + case PHP_PASSWORD_UNKNOWN: + default: + break; + } + + array_init(return_value); + + add_assoc_long(return_value, "algo", algo); + add_assoc_string(return_value, "algoName", algo_name, 1); + add_assoc_zval(return_value, "options", options); +} + +PHP_FUNCTION(password_needs_rehash) +{ + long new_algo = 0; + php_password_algo algo; + int hash_len; + char *hash; + HashTable *options = 0; + zval **option_buffer; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|H", &hash, &hash_len, &new_algo, &options) == FAILURE) { + return; + } + + if (hash_len < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied password hash too long to safely identify"); + RETURN_FALSE; + } + + algo = php_password_determine_algo(hash, (size_t) hash_len); + + if (algo != new_algo) { + RETURN_TRUE; + } + + switch (algo) { + case PHP_PASSWORD_BCRYPT: + { + long new_cost = PHP_PASSWORD_BCRYPT_COST, cost = 0; + + if (options && zend_symtable_find(options, "cost", sizeof("cost"), (void **) &option_buffer) == SUCCESS) { + if (Z_TYPE_PP(option_buffer) != IS_LONG) { + zval cast_option_buffer; + MAKE_COPY_ZVAL(option_buffer, &cast_option_buffer); + convert_to_long(&cast_option_buffer); + new_cost = Z_LVAL(cast_option_buffer); + zval_dtor(&cast_option_buffer); + } else { + new_cost = Z_LVAL_PP(option_buffer); + } + } + + sscanf(hash, "$2y$%ld$", &cost); + if (cost != new_cost) { + RETURN_TRUE; + } + } + break; + case PHP_PASSWORD_UNKNOWN: + default: + break; + } + RETURN_FALSE; +} + +/* {{{ proto boolean password_make_salt(string password, string hash) +Verify a hash created using crypt() or password_hash() */ +PHP_FUNCTION(password_verify) +{ + int status = 0, i; + int password_len, hash_len; + char *ret, *password, *hash; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &password, &password_len, &hash, &hash_len) == FAILURE) { + RETURN_FALSE; + } + if (php_crypt(password, password_len, hash, hash_len, &ret) == FAILURE) { + RETURN_FALSE; + } + + if (strlen(ret) != hash_len || hash_len < 13) { + efree(ret); + RETURN_FALSE; + } + + /* We're using this method instead of == in order to provide + * resistence towards timing attacks. This is a constant time + * equality check that will always check every byte of both + * values. */ + for (i = 0; i < hash_len; i++) { + status |= (ret[i] ^ hash[i]); + } + + efree(ret); + + RETURN_BOOL(status == 0); + +} +/* }}} */ + +/* {{{ proto string password_hash(string password, int algo, array options = array()) +Hash a password */ +PHP_FUNCTION(password_hash) +{ + char *hash_format, *hash, *salt, *password, *result; + long algo = 0; + int password_len = 0, hash_len; + size_t salt_len = 0, required_salt_len = 0, hash_format_len; + HashTable *options = 0; + zval **option_buffer; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|H", &password, &password_len, &algo, &options) == FAILURE) { + return; + } + + switch (algo) { + case PHP_PASSWORD_BCRYPT: + { + long cost = PHP_PASSWORD_BCRYPT_COST; + + if (options && zend_symtable_find(options, "cost", 5, (void **) &option_buffer) == SUCCESS) { + if (Z_TYPE_PP(option_buffer) != IS_LONG) { + zval cast_option_buffer; + MAKE_COPY_ZVAL(option_buffer, &cast_option_buffer); + convert_to_long(&cast_option_buffer); + cost = Z_LVAL(cast_option_buffer); + zval_dtor(&cast_option_buffer); + } else { + cost = Z_LVAL_PP(option_buffer); + } + } + + if (cost < 4 || cost > 31) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid bcrypt cost parameter specified: %ld", cost); + RETURN_NULL(); + } + + required_salt_len = 22; + hash_format = emalloc(8); + sprintf(hash_format, "$2y$%02ld$", cost); + hash_format_len = 7; + } + break; + case PHP_PASSWORD_UNKNOWN: + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown password hashing algorithm: %ld", algo); + RETURN_NULL(); + } + + if (options && zend_symtable_find(options, "salt", 5, (void**) &option_buffer) == SUCCESS) { + char *buffer; + int buffer_len_int = 0; + size_t buffer_len; + switch (Z_TYPE_PP(option_buffer)) { + case IS_STRING: + buffer = estrndup(Z_STRVAL_PP(option_buffer), Z_STRLEN_PP(option_buffer)); + buffer_len_int = Z_STRLEN_PP(option_buffer); + break; + case IS_LONG: + case IS_DOUBLE: + case IS_OBJECT: { + zval cast_option_buffer; + MAKE_COPY_ZVAL(option_buffer, &cast_option_buffer); + convert_to_string(&cast_option_buffer); + if (Z_TYPE(cast_option_buffer) == IS_STRING) { + buffer = estrndup(Z_STRVAL(cast_option_buffer), Z_STRLEN(cast_option_buffer)); + buffer_len_int = Z_STRLEN(cast_option_buffer); + zval_dtor(&cast_option_buffer); + break; + } + zval_dtor(&cast_option_buffer); + } + case IS_BOOL: + case IS_NULL: + case IS_RESOURCE: + case IS_ARRAY: + default: + efree(hash_format); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-string salt parameter supplied"); + RETURN_NULL(); + } + if (buffer_len_int < 0) { + efree(hash_format); + efree(buffer); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Supplied salt is too long"); + } + buffer_len = (size_t) buffer_len_int; + if (buffer_len < required_salt_len) { + efree(hash_format); + efree(buffer); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided salt is too short: %lu expecting %lu", (unsigned long) buffer_len, (unsigned long) required_salt_len); + RETURN_NULL(); + } else if (0 == php_password_salt_is_alphabet(buffer, buffer_len)) { + salt = safe_emalloc(required_salt_len, 1, 1); + if (php_password_salt_to64(buffer, buffer_len, required_salt_len, salt) == FAILURE) { + efree(hash_format); + efree(buffer); + efree(salt); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided salt is too short: %lu", (unsigned long) buffer_len); + RETURN_NULL(); + } + salt_len = required_salt_len; + } else { + salt = safe_emalloc(required_salt_len, 1, 1); + memcpy(salt, buffer, (int) required_salt_len); + salt_len = required_salt_len; + } + efree(buffer); + } else { + salt = safe_emalloc(required_salt_len, 1, 1); + if (php_password_make_salt(required_salt_len, salt TSRMLS_CC) == FAILURE) { + efree(hash_format); + efree(salt); + RETURN_FALSE; + } + salt_len = required_salt_len; + } + + salt[salt_len] = 0; + + hash = safe_emalloc(salt_len + hash_format_len, 1, 1); + sprintf(hash, "%s%s", hash_format, salt); + hash[hash_format_len + salt_len] = 0; + + efree(hash_format); + efree(salt); + + /* This cast is safe, since both values are defined here in code and cannot overflow */ + hash_len = (int) (hash_format_len + salt_len); + + if (php_crypt(password, password_len, hash, hash_len, &result) == FAILURE) { + efree(hash); + RETURN_FALSE; + } + + efree(hash); + + if (strlen(result) < 13) { + efree(result); + RETURN_FALSE; + } + + RETURN_STRING(result, 0); +} +/* }}} */ + +#endif /* HAVE_CRYPT */ +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: sw=4 ts=4 fdm=marker + * vim<600: sw=4 ts=4 + */ diff --git a/ext/standard/php_crypt.h b/ext/standard/php_crypt.h index 47d78377c5d35..6025685539809 100644 --- a/ext/standard/php_crypt.h +++ b/ext/standard/php_crypt.h @@ -23,6 +23,7 @@ #ifndef PHP_CRYPT_H #define PHP_CRYPT_H +PHPAPI int php_crypt(const char *password, const int pass_len, const char *salt, int salt_len, char **result); PHP_FUNCTION(crypt); #if HAVE_CRYPT PHP_MINIT_FUNCTION(crypt); diff --git a/ext/standard/php_password.h b/ext/standard/php_password.h new file mode 100644 index 0000000000000..abc343d66efd2 --- /dev/null +++ b/ext/standard/php_password.h @@ -0,0 +1,48 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Anthony Ferrara | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef PHP_PASSWORD_H +#define PHP_PASSWORD_H + +PHP_FUNCTION(password_hash); +PHP_FUNCTION(password_verify); +PHP_FUNCTION(password_needs_rehash); +PHP_FUNCTION(password_get_info); + +PHP_MINIT_FUNCTION(password); + +#define PHP_PASSWORD_DEFAULT PHP_PASSWORD_BCRYPT + +#define PHP_PASSWORD_BCRYPT_COST 10 + +typedef enum { + PHP_PASSWORD_UNKNOWN, + PHP_PASSWORD_BCRYPT +} php_password_algo; + +#endif + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + */ diff --git a/ext/standard/php_standard.h b/ext/standard/php_standard.h index 2ec851632e5f1..3c7535da1ff13 100644 --- a/ext/standard/php_standard.h +++ b/ext/standard/php_standard.h @@ -58,6 +58,7 @@ #include "php_versioning.h" #include "php_ftok.h" #include "php_type.h" +#include "php_password.h" #define phpext_standard_ptr basic_functions_module_ptr PHP_MINIT_FUNCTION(standard_filters); diff --git a/ext/standard/php_type.h b/ext/standard/php_type.h index 292b66710f138..e434ae05f4b26 100644 --- a/ext/standard/php_type.h +++ b/ext/standard/php_type.h @@ -24,6 +24,7 @@ PHP_FUNCTION(intval); PHP_FUNCTION(floatval); PHP_FUNCTION(strval); +PHP_FUNCTION(boolval); PHP_FUNCTION(gettype); PHP_FUNCTION(settype); PHP_FUNCTION(is_null); diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 6373751107189..4e39a40be4ebf 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -208,6 +208,7 @@ static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) DWORD wstatus; #elif HAVE_SYS_WAIT_H int wstatus; + int waitpid_options = 0; pid_t wait_pid; #endif @@ -220,18 +221,27 @@ static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) } #ifdef PHP_WIN32 - WaitForSingleObject(proc->childHandle, INFINITE); + if (FG(pclose_wait)) { + WaitForSingleObject(proc->childHandle, INFINITE); + } GetExitCodeProcess(proc->childHandle, &wstatus); - FG(pclose_ret) = wstatus; + if (wstatus == STILL_ACTIVE) { + FG(pclose_ret) = -1; + } else { + FG(pclose_ret) = wstatus; + } CloseHandle(proc->childHandle); #elif HAVE_SYS_WAIT_H + if (!FG(pclose_wait)) { + waitpid_options = WNOHANG; + } do { - wait_pid = waitpid(proc->child, &wstatus, 0); + wait_pid = waitpid(proc->child, &wstatus, waitpid_options); } while (wait_pid == -1 && errno == EINTR); - if (wait_pid == -1) { + if (wait_pid <= 0) { FG(pclose_ret) = -1; } else { if (WIFEXITED(wstatus)) @@ -300,7 +310,9 @@ PHP_FUNCTION(proc_close) ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1, "process", le_proc_open); + FG(pclose_wait) = 1; zend_list_delete(Z_LVAL_P(zproc)); + FG(pclose_wait) = 0; RETURN_LONG(FG(pclose_ret)); } /* }}} */ @@ -438,6 +450,7 @@ PHP_FUNCTION(proc_open) DWORD dwCreateFlags = 0; char *command_with_cmd; UINT old_error_mode; + char cur_cwd[MAXPATHLEN]; #endif #ifdef NETWARE char** child_argv = NULL; @@ -676,13 +689,13 @@ PHP_FUNCTION(proc_open) #ifdef PHP_WIN32 if (cwd == NULL) { - char cur_cwd[MAXPATHLEN]; char *getcwd_result; getcwd_result = VCWD_GETCWD(cur_cwd, MAXPATHLEN); if (!getcwd_result) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot get current directory"); goto exit_fail; } + cwd = cur_cwd; } memset(&si, 0, sizeof(si)); diff --git a/ext/standard/string.c b/ext/standard/string.c index 42bf198175c2f..e245ce3fb6dda 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2851,7 +2851,7 @@ static inline void php_strtr_populate_shift(PATNREPL *patterns, int patnum, int } /* }}} */ /* {{{ php_strtr_compare_hash_suffix */ -static int php_strtr_compare_hash_suffix(const void *a, const void *b, void *ctx_g) +static int php_strtr_compare_hash_suffix(const void *a, const void *b TSRMLS_DC, void *ctx_g) { const PPRES *res = ctx_g; const PATNREPL *pnr_a = a, @@ -2877,62 +2877,6 @@ static int php_strtr_compare_hash_suffix(const void *a, const void *b, void *ctx } } /* }}} */ -/* {{{ Sorting (no zend_qsort_r in this PHP version) */ -#define HS_LEFT(i) ((i) * 2 + 1) -#define HS_RIGHT(i) ((i) * 2 + 2) -#define HS_PARENT(i) (((i) - 1) / 2); -#define HS_OFF(data, i) ((void *)(&((data)->arr)[i])) -#define HS_CMP_CALL(data, i1, i2) \ - (php_strtr_compare_hash_suffix(HS_OFF((data), (i1)), HS_OFF((data), (i2)), (data)->res)) -struct hs_data { - PATNREPL *arr; - size_t nel; - size_t heapel; - PPRES *res; -}; -static inline void php_strtr_swap(PATNREPL *a, PATNREPL *b) -{ - PATNREPL tmp = *a; - *a = *b; - *b = tmp; -} -static inline void php_strtr_fix_heap(struct hs_data *data, size_t i) -{ - size_t li = HS_LEFT(i), - ri = HS_RIGHT(i), - largei; - if (li < data->heapel && HS_CMP_CALL(data, li, i) > 0) { - largei = li; - } else { - largei = i; - } - if (ri < data->heapel && HS_CMP_CALL(data, ri, largei) > 0) { - largei = ri; - } - if (largei != i) { - php_strtr_swap(HS_OFF(data, i), HS_OFF(data, largei)); - php_strtr_fix_heap(data, largei); - } -} -static inline void php_strtr_build_heap(struct hs_data *data) -{ - size_t i; - for (i = data->nel / 2; i > 0; i--) { - php_strtr_fix_heap(data, i - 1); - } -} -static inline void php_strtr_heapsort(PATNREPL *arr, size_t nel, PPRES *res) -{ - struct hs_data data = { arr, nel, nel, res }; - size_t i; - php_strtr_build_heap(&data); - for (i = nel; i > 1; i--) { - php_strtr_swap(arr, HS_OFF(&data, i - 1)); - data.heapel--; - php_strtr_fix_heap(&data, 0); - } -} -/* }}} */ /* {{{ php_strtr_free_strp */ static void php_strtr_free_strp(void *strp) { @@ -3030,7 +2974,13 @@ static PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum, res->patterns = safe_emalloc(patnum, sizeof(*res->patterns), 0); memcpy(res->patterns, patterns, sizeof(*patterns) * patnum); - php_strtr_heapsort(res->patterns, patnum, res); +#ifdef ZTS + zend_qsort_r(res->patterns, patnum, sizeof(*res->patterns), + php_strtr_compare_hash_suffix, res, NULL); /* tsrmls not needed */ +#else + zend_qsort_r(res->patterns, patnum, sizeof(*res->patterns), + php_strtr_compare_hash_suffix, res); +#endif res->prefix = safe_emalloc(patnum, sizeof(*res->prefix), 0); for (i = 0; i < patnum; i++) { @@ -5652,7 +5602,7 @@ PHP_FUNCTION(substr_compare) if (!cs) { RETURN_LONG(zend_binary_strncmp(s1 + offset, (s1_len - offset), s2, s2_len, cmp_len)); } else { - RETURN_LONG(zend_binary_strncasecmp(s1 + offset, (s1_len - offset), s2, s2_len, cmp_len)); + RETURN_LONG(zend_binary_strncasecmp_l(s1 + offset, (s1_len - offset), s2, s2_len, cmp_len)); } } /* }}} */ diff --git a/ext/standard/tests/array/compact.phpt b/ext/standard/tests/array/compact.phpt index 4b4bfbb7321e0..02df44ebd88c8 100644 --- a/ext/standard/tests/array/compact.phpt +++ b/ext/standard/tests/array/compact.phpt @@ -1,8 +1,5 @@ --TEST-- compact() ---INI-- -unicode.script_encoding=UTF-8 -unicode.output_encoding=UTF-8 --FILE-- ---INI-- -unicode.script_encoding=ISO8859-1 -unicode.output_encoding=ISO8859-1 --FILE-- ---FILE-- -var = 10; - } -} - -// get a resource variable -$fp = fopen(__FILE__, "r"); // get a file handle -$dfp = opendir( dirname(__FILE__) ); // get a dir handle - -// unexpected values to be passed to $directory argument -$unexpected_values = array ( - - // array data -/*1*/ array(), - array(0), - array(1), - array(1, 2), - array('color' => 'red', 'item' => 'pen'), - - // null data -/*6*/ NULL, - null, - - // boolean data -/*8*/ true, - false, - TRUE, - FALSE, - - // empty data -/*12*/ "", - '', - - // undefined data -/*14*/ @$undefined_var, - - // unset data -/*15*/ @$unset_var, - - // resource variable(dir and file handle) -/*16*/ $fp, - $dfp, - - // object data -/*18*/ new A() -); - -// loop through various elements of $unexpected_values to check the behavior of dir() -$iterator = 1; -foreach( $unexpected_values as $unexpected_value ) { - echo "\n-- Iteration $iterator --\n"; - var_dump( dir($unexpected_value) ); - $iterator++; -} - -fclose($fp); -closedir($dfp); -echo "Done"; -?> ---EXPECTF-- -*** Testing dir() : unexpected values for $directory argument *** - --- Iteration 1 -- - -Warning: dir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 2 -- - -Warning: dir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 3 -- - -Warning: dir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 4 -- - -Warning: dir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 5 -- - -Warning: dir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 6 -- -bool(false) - --- Iteration 7 -- -bool(false) - --- Iteration 8 -- - -Warning: dir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: dir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 9 -- -bool(false) - --- Iteration 10 -- - -Warning: dir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: dir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 11 -- -bool(false) - --- Iteration 12 -- -bool(false) - --- Iteration 13 -- -bool(false) - --- Iteration 14 -- -bool(false) - --- Iteration 15 -- -bool(false) - --- Iteration 16 -- - -Warning: dir() expects parameter 1 to be string, resource given in %s on line %d -NULL - --- Iteration 17 -- - -Warning: dir() expects parameter 1 to be string, resource given in %s on line %d -NULL - --- Iteration 18 -- - -Warning: dir() expects parameter 1 to be string, object given in %s on line %d -NULL -Done \ No newline at end of file diff --git a/ext/standard/tests/dir/dir_variation5-win32.phpt b/ext/standard/tests/dir/dir_variation5-win32.phpt deleted file mode 100644 index e70b9d35337a4..0000000000000 --- a/ext/standard/tests/dir/dir_variation5-win32.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -Test dir() function : usage variations - open a file instead of directory ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -*** Testing dir() : open a file instead of a directory *** - -Warning: dir(%s): The directory name is invalid. (code: %d) in %s on line %d - -Warning: dir(%s): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/dir_variation6-win32.phpt b/ext/standard/tests/dir/dir_variation6-win32.phpt deleted file mode 100644 index e0e474980924d..0000000000000 --- a/ext/standard/tests/dir/dir_variation6-win32.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -Test dir() function : usage variations - non-existent directory ---SKIPIF-- - ---FILE-- -close(); //close the dir - -// remove directory and try to open the same(non-existent) directory again -rmdir($dir_path); -clearstatcache(); - -echo "-- opening previously removed directory --\n"; -var_dump( dir($dir_path) ); - -// point to a non-existent directory -$non_existent_dir = $file_path."/non_existent_dir"; -echo "-- opening non-existent directory --\n"; -$d = dir($non_existent_dir); -var_dump( $d ); - -echo "Done"; -?> ---EXPECTF-- -*** Testing dir() : open a non-existent directory *** --- opening previously removed directory -- - -Warning: dir(%s): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: dir(%s): failed to open dir: %s in %s on line %d -bool(false) --- opening non-existent directory -- - -Warning: dir(%s): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: dir(%s): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/dir_variation8-win32.phpt b/ext/standard/tests/dir/dir_variation8-win32.phpt deleted file mode 100644 index a56c98b880989..0000000000000 --- a/ext/standard/tests/dir/dir_variation8-win32.phpt +++ /dev/null @@ -1,68 +0,0 @@ ---TEST-- -Test dir() function : usage variations - checking with wildcard characters ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -*** Testing dir() : checking with wildcard characters *** --- wildcard = '*' -- - -Warning: dir(%s/dir_var*,%s/dir_var*): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/dir_var*): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%s/*,%s/*): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/*): failed to open dir: %s in %s on line %d -bool(false) --- wildcard = '?' -- - -Warning: dir(%s/dir_variation81/sub_dir?,%s/dir_variation81/sub_dir?): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/dir_variation81/sub_dir?): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%s/dir_variation81/sub?dir1,%s/dir_variation81/sub?dir1): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/dir_variation81/sub?dir1): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/dir_variation9-win32.phpt b/ext/standard/tests/dir/dir_variation9-win32.phpt deleted file mode 100644 index 32b0bd946b053..0000000000000 --- a/ext/standard/tests/dir/dir_variation9-win32.phpt +++ /dev/null @@ -1,125 +0,0 @@ ---TEST-- -Test dir() function : usage variations - relative valid and invalid paths ---SKIPIF-- - ---FILE-- - ---CLEAN-- - ---EXPECTF-- -*** Testing dir() : checking with valid and invalid paths *** - --- With valid paths -- -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/.." - ["handle"]=> - resource(%d) of type (stream) -} -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91" - ["handle"]=> - resource(%d) of type (stream) -} -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir11/.." - ["handle"]=> - resource(%d) of type (stream) -} -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/../../../dir_variation92/sub_dir21/.." - ["handle"]=> - resource(%d) of type (stream) -} - --- With invalid paths -- - -Warning: dir(%sdir_variation91/sub_dir12/sub_dir111/..,%sdir_variation91/sub_dir12/sub_dir111/..): The system cannot find the path specified. (code: 3) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation91/sub_dir12/sub_dir111/..): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%sdir_variation92/sub_dir21/../dir_variation91,%sdir_variation92/sub_dir21/../dir_variation91): The system cannot find the file specified. (code: 2) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation92/sub_dir21/../dir_variation91): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%sdir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..,%sdir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..): The system cannot find the file specified. (code: 2) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%sdir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..,%sdir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..): The system cannot find the path specified. (code: 3) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/opendir_error2-win32.phpt b/ext/standard/tests/dir/opendir_error2-win32.phpt deleted file mode 100644 index c3ecd353496a7..0000000000000 --- a/ext/standard/tests/dir/opendir_error2-win32.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Test opendir() function : error conditions - Non-existent directory ---SKIPIF-- - ---FILE-- - -===DONE=== ---EXPECTF-- -*** Testing opendir() : error conditions *** - --- Pass a non-existent absolute path: -- - -Warning: opendir(%s/idonotexist,%s/idonotexist): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: opendir(%s/idonotexist): failed to open dir: %s in %s on line %d -bool(false) - --- Pass a non-existent relative path: -- - -Warning: opendir(idonotexist,idonotexist): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: opendir(idonotexist): failed to open dir: %s in %s on line %d -bool(false) -===DONE=== diff --git a/ext/standard/tests/dir/opendir_variation1-win32.phpt b/ext/standard/tests/dir/opendir_variation1-win32.phpt deleted file mode 100644 index 9a75a5b6a7f57..0000000000000 --- a/ext/standard/tests/dir/opendir_variation1-win32.phpt +++ /dev/null @@ -1,248 +0,0 @@ ---TEST-- -Test opendir() function : usage variations - different data types as $path arg ---SKIPIF-- - ---FILE-- -path = $path; - } - public function __toString() { - return $this->path; - } -} - -// heredoc string -$heredoc = << -===DONE=== ---CLEAN-- - ---EXPECTF-- -*** Testing opendir() : usage variations *** - --- Iteration 1 -- - -Warning: opendir(0,0): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(0): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 2 -- - -Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 3 -- - -Warning: opendir(12345,12345): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(12345): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 4 -- - -Warning: opendir(-2345,-2345): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(-2345): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 5 -- - -Warning: opendir(10.5,10.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(10.5): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 6 -- - -Warning: opendir(-10.5,-10.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(-10.5): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 7 -- - -Warning: opendir(123456789000,123456789000): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(123456789000): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 8 -- - -Warning: opendir(1.23456789E-9,1.23456789E-9): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(1.23456789E-9): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 9 -- - -Warning: opendir(0.5,0.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(0.5): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 10 -- -bool(false) - --- Iteration 11 -- -bool(false) - --- Iteration 12 -- - -Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 13 -- -bool(false) - --- Iteration 14 -- - -Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 15 -- -bool(false) - --- Iteration 16 -- -bool(false) - --- Iteration 17 -- -bool(false) - --- Iteration 18 -- - -Warning: opendir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 19 -- -resource(%d) of type (stream) - --- Iteration 20 -- - -Warning: opendir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: opendir(string): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 21 -- -resource(%d) of type (stream) - --- Iteration 22 -- -resource(%d) of type (stream) - --- Iteration 23 -- -bool(false) - --- Iteration 24 -- -bool(false) - --- Iteration 25 -- - -Warning: opendir() expects parameter 1 to be string, resource given in %s on line %d -NULL -===DONE=== diff --git a/ext/standard/tests/dir/scandir_error2-win32.phpt b/ext/standard/tests/dir/scandir_error2-win32.phpt deleted file mode 100644 index 9920be747ddb5..0000000000000 --- a/ext/standard/tests/dir/scandir_error2-win32.phpt +++ /dev/null @@ -1,51 +0,0 @@ ---TEST-- -Test scandir() function : error conditions - Non-existent directory ---SKIPIF-- - ---FILE-- - -===DONE=== ---EXPECTF-- -*** Testing scandir() : error conditions *** - --- Pass scandir() an absolute path that does not exist -- - -Warning: scandir(%s/idonotexist,%s/idonotexist): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(%s/idonotexist): failed to open dir: %s in %s on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Pass scandir() a relative path that does not exist -- - -Warning: scandir(/idonotexist,/idonotexist): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(/idonotexist): failed to open dir: %s in %s on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) -===DONE=== diff --git a/ext/standard/tests/dir/scandir_variation1-win32.phpt b/ext/standard/tests/dir/scandir_variation1-win32.phpt deleted file mode 100644 index a2b5bd4672479..0000000000000 --- a/ext/standard/tests/dir/scandir_variation1-win32.phpt +++ /dev/null @@ -1,289 +0,0 @@ ---TEST-- -Test scandir() function : usage variations - different data types as $dir arg ---SKIPIF-- - ---FILE-- - -===DONE=== ---EXPECTF-- -*** Testing scandir() : usage variations *** - --- Iteration 1 -- - -Warning: scandir(0,0): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(0): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 2 -- - -Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 3 -- - -Warning: scandir(12345,12345): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(12345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 4 -- - -Warning: scandir(-2345,-2345): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(-2345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 5 -- - -Warning: scandir(10.5,10.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 6 -- - -Warning: scandir(-10.5,-10.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(-10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 7 -- - -Warning: scandir(123456789000,123456789000): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(123456789000): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 8 -- - -Warning: scandir(1.23456789E-9,1.23456789E-9): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1.23456789E-9): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 9 -- - -Warning: scandir(0.5,0.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(0.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 10 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 11 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 12 -- - -Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 13 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 14 -- - -Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 15 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 16 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 17 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 18 -- - -Warning: scandir() expects parameter 1 to be a valid path, array given in %s on line %d -NULL - --- Iteration 19 -- - -Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 20 -- - -Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 21 -- - -Warning: scandir(hello world,hello world): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(hello world): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 22 -- - -Warning: scandir(Class A object,Class A object): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(Class A object): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 23 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 24 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 25 -- - -Warning: scandir() expects parameter 1 to be a valid path, resource given in %s on line %d -NULL -===DONE=== diff --git a/ext/standard/tests/dir/scandir_variation6-win32.phpt b/ext/standard/tests/dir/scandir_variation6-win32.phpt deleted file mode 100644 index 040dc787cc4aa..0000000000000 --- a/ext/standard/tests/dir/scandir_variation6-win32.phpt +++ /dev/null @@ -1,84 +0,0 @@ ---TEST-- -Test scandir() function : usage variations - Wildcards in directory path ---SKIPIF-- - ---FILE-- - -===DONE=== ---CLEAN-- - ---EXPECTF-- -*** Testing scandir() : usage variations *** - --- Wildcard = '*' -- - -Warning: scandir(%s/scandir_var*,%s/scandir_var*): No such file or directory in %s on line %d - -Warning: scandir(%s/scandir_var*): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - -Warning: scandir(%s/*,%s/*): No such file or directory in %s on line %d - -Warning: scandir(%s/*): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Wildcard = '?' -- - -Warning: scandir(%s/scandir_variation6/sub_dir?,%s/scandir_variation6/sub_dir?): No such file or directory in %s on line %d - -Warning: scandir(%s/scandir_variation6/sub_dir?): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - -Warning: scandir(%s/scandir_variation6/sub?dir1,%s/scandir_variation6/sub?dir1): No such file or directory in %s on line %d - -Warning: scandir(%s/scandir_variation6/sub?dir1): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) -===DONE=== diff --git a/ext/standard/tests/file/bug22414.phpt b/ext/standard/tests/file/bug22414.phpt index 9538c8ede8d33..fcd85489f32a0 100644 --- a/ext/standard/tests/file/bug22414.phpt +++ b/ext/standard/tests/file/bug22414.phpt @@ -7,7 +7,7 @@ output_handler= $php = getenv('TEST_PHP_EXECUTABLE'); $tmpfile = tempnam(__DIR__, 'phpt'); - $args = ' -n '; + $args = ' -n -dsafe_mode=off '; /* Regular Data Test */ passthru($php . $args . ' -r " echo \"HELLO\"; "'); diff --git a/ext/standard/tests/general_functions/boolval.phpt b/ext/standard/tests/general_functions/boolval.phpt new file mode 100644 index 0000000000000..9d0eac4ebd09c --- /dev/null +++ b/ext/standard/tests/general_functions/boolval.phpt @@ -0,0 +1,29 @@ +--TEST-- +Testing boolval() +--FILE-- + +--EXPECTF-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/standard/tests/mail/mail_log.phpt b/ext/standard/tests/mail/mail_log.phpt new file mode 100644 index 0000000000000..86346ec307efe --- /dev/null +++ b/ext/standard/tests/mail/mail_log.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test mail() function : mail.log ini setting +--INI-- +sendmail_path=tee /tmp/mail.out >/dev/null +mail.log = /tmp/mail.log +--SKIPIF-- + +--FILE-- + 0); +clearstatcache(); + +echo file_get_contents($logfile); +?> +Done +--CLEAN-- + +--EXPECTF-- +bool(true) +bool(true) +bool(true) +[%d-%s-%d %d:%d:%d UTC] mail() on [%smail_log.php:%d]: To: test@example.com -- Headers: X-Test: 1 +Done diff --git a/ext/standard/tests/network/ip2long_variation1.phpt b/ext/standard/tests/network/ip2long_variation1.phpt index f87282ae75167..ca67aa41a8e24 100644 --- a/ext/standard/tests/network/ip2long_variation1.phpt +++ b/ext/standard/tests/network/ip2long_variation1.phpt @@ -201,4 +201,4 @@ bool(false) --resource-- Error: 2 - ip2long() expects parameter 1 to be string, resource given, %s(%d) NULL -===DONE=== +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/network/setcookie.phpt b/ext/standard/tests/network/setcookie.phpt new file mode 100644 index 0000000000000..bf04ec78de13c --- /dev/null +++ b/ext/standard/tests/network/setcookie.phpt @@ -0,0 +1,70 @@ +--TEST-- +setcookie() tests +--DESCRIPTION-- +--INI-- +date.timezone=UTC +--FILE-- + count($headers)) +{ + echo "Less headers are being sent than expected - aborting"; + return; +} + +do +{ + if (strncmp(current($headers), 'Set-Cookie:', 11) !== 0) + { + continue; + } + + if (current($headers) === current($expected)) + { + $i--; + } + else + { + echo "Header mismatch:\n\tExpected: " + .current($expected) + ."\n\tReceived: ".current($headers)."\n"; + } + + next($expected); +} +while (next($headers) !== FALSE); + +echo ($i === 0) + ? 'OK' + : 'A total of '.$i.' errors found.'; +--EXPECTHEADERS-- + +--EXPECT-- +OK \ No newline at end of file diff --git a/ext/standard/tests/password/password_bcrypt_errors.phpt b/ext/standard/tests/password/password_bcrypt_errors.phpt new file mode 100644 index 0000000000000..2548c9accb805 --- /dev/null +++ b/ext/standard/tests/password/password_bcrypt_errors.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test error operation of password_hash() with bcrypt hashing +--FILE-- + 3))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("cost" => 32))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("salt" => "foo"))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("salt" => "123456789012345678901"))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("salt" => 123))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("cost" => "foo"))); + +?> +--EXPECTF-- +Warning: password_hash(): Invalid bcrypt cost parameter specified: 3 in %s on line %d +NULL + +Warning: password_hash(): Invalid bcrypt cost parameter specified: 32 in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 3 expecting 22 in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 21 expecting 22 in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 3 expecting 22 in %s on line %d +NULL + +Warning: password_hash(): Invalid bcrypt cost parameter specified: 0 in %s on line %d +NULL + + diff --git a/ext/standard/tests/password/password_get_info.phpt b/ext/standard/tests/password/password_get_info.phpt new file mode 100644 index 0000000000000..4c8dc04ff802e --- /dev/null +++ b/ext/standard/tests/password/password_get_info.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test normal operation of password_get_info() +--FILE-- + +--EXPECT-- +array(3) { + ["algo"]=> + int(1) + ["algoName"]=> + string(6) "bcrypt" + ["options"]=> + array(1) { + ["cost"]=> + int(10) + } +} +array(3) { + ["algo"]=> + int(1) + ["algoName"]=> + string(6) "bcrypt" + ["options"]=> + array(1) { + ["cost"]=> + int(11) + } +} +array(3) { + ["algo"]=> + int(0) + ["algoName"]=> + string(7) "unknown" + ["options"]=> + array(0) { + } +} +array(3) { + ["algo"]=> + int(0) + ["algoName"]=> + string(7) "unknown" + ["options"]=> + array(0) { + } +} +OK! diff --git a/ext/standard/tests/password/password_get_info_error.phpt b/ext/standard/tests/password/password_get_info_error.phpt new file mode 100644 index 0000000000000..af676744c8b30 --- /dev/null +++ b/ext/standard/tests/password/password_get_info_error.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test error operation of password_get_info() +--FILE-- + +--EXPECTF-- +Warning: password_get_info() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: password_get_info() expects parameter 1 to be string, array given in %s on line %d +NULL +OK! diff --git a/ext/standard/tests/password/password_hash.phpt b/ext/standard/tests/password/password_hash.phpt new file mode 100644 index 0000000000000..f59d3d5e488ab --- /dev/null +++ b/ext/standard/tests/password/password_hash.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test normal operation of password_hash() +--FILE-- + 7, "salt" => "usesomesillystringforsalt"))); + +var_dump(password_hash("test", PASSWORD_BCRYPT, array("salt" => "123456789012345678901" . chr(0)))); + +echo "OK!"; +?> +--EXPECT-- +int(60) +bool(true) +string(60) "$2y$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi" +string(60) "$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y" +OK! + diff --git a/ext/standard/tests/password/password_hash_error.phpt b/ext/standard/tests/password/password_hash_error.phpt new file mode 100644 index 0000000000000..952250cb309b0 --- /dev/null +++ b/ext/standard/tests/password/password_hash_error.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test error operation of password_hash() +--FILE-- + array()))); + +/* Non-string salt, checking for memory leaks */ +var_dump(password_hash('123', PASSWORD_BCRYPT, array('salt' => 1234))); + +?> +--EXPECTF-- +Warning: password_hash() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: password_hash() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Warning: password_hash() expects parameter 2 to be long, array given in %s on line %d +NULL + +Warning: password_hash(): Unknown password hashing algorithm: 19 in %s on line %d +NULL + +Warning: password_hash() expects parameter 3 to be array, string given in %s on line %d +NULL + +Warning: password_hash() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: password_hash(): Non-string salt parameter supplied in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 4 expecting 22 in %s on line %d +NULL diff --git a/ext/standard/tests/password/password_needs_rehash.phpt b/ext/standard/tests/password/password_needs_rehash.phpt new file mode 100644 index 0000000000000..734729e63d705 --- /dev/null +++ b/ext/standard/tests/password/password_needs_rehash.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test normal operation of password_needs_rehash() +--FILE-- + 10))); + +// Valid with cost the same, additional params +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 10, 'foo' => 3))); + +// Invalid, different (lower) cost +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 09))); + +// Invalid, different (higher) cost +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 11))); + +// Valid with cost the default +$cost = str_pad(PASSWORD_BCRYPT_DEFAULT_COST, 2, '0', STR_PAD_LEFT); +var_dump(password_needs_rehash('$2y$'.$cost.'$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT)); + +// Should Issue Needs Rehash, Since Foo is cast to 0... +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 'foo'))); + + + +echo "OK!"; +?> +--EXPECT-- +bool(true) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) +OK! diff --git a/ext/standard/tests/password/password_needs_rehash_error.phpt b/ext/standard/tests/password/password_needs_rehash_error.phpt new file mode 100644 index 0000000000000..e25ef8db3f4dd --- /dev/null +++ b/ext/standard/tests/password/password_needs_rehash_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test error operation of password_needs_rehash() +--FILE-- + +--EXPECTF-- +Warning: password_needs_rehash() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: password_needs_rehash() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Warning: password_needs_rehash() expects parameter 2 to be long, string given in %s on line %d +NULL + +Warning: password_needs_rehash() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: password_needs_rehash() expects parameter 3 to be array, string given in %s on line %d +NULL +OK! diff --git a/ext/standard/tests/password/password_verify.phpt b/ext/standard/tests/password/password_verify.phpt new file mode 100644 index 0000000000000..e7ecc7edd3086 --- /dev/null +++ b/ext/standard/tests/password/password_verify.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test normal operation of password_verify) +--FILE-- + +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(true) +OK! diff --git a/ext/standard/tests/password/password_verify_error.phpt b/ext/standard/tests/password/password_verify_error.phpt new file mode 100644 index 0000000000000..3e653fa04e475 --- /dev/null +++ b/ext/standard/tests/password/password_verify_error.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test error operation of password_verify() +--FILE-- + +--EXPECTF-- +Warning: password_verify() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +Warning: password_verify() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) + diff --git a/ext/standard/tests/php_ini_loaded_file.phpt b/ext/standard/tests/php_ini_loaded_file.phpt index 747e0196f19f4..7d441582eeb17 100644 --- a/ext/standard/tests/php_ini_loaded_file.phpt +++ b/ext/standard/tests/php_ini_loaded_file.phpt @@ -10,5 +10,5 @@ precision=12 ---EXPECTF-- -string(%d) "%sphp.ini" +--EXPECTREGEX-- +string\(\d+\) ".*php\.ini"|bool\(false\) diff --git a/ext/standard/tests/php_logo_guid.phpt b/ext/standard/tests/php_logo_guid.phpt deleted file mode 100644 index c644b2893bb89..0000000000000 --- a/ext/standard/tests/php_logo_guid.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Check the output of the php_logo_guid() function ---CREDITS-- -Sebastian Schürmann -sschuermann@chip.de -Testfest 2009 Munich ---FILE-- - ---EXPECT-- -PHPE9568F34-D428-11d2-A769-00AA001ACF42 - diff --git a/ext/standard/tests/php_real_logo_guid.phpt b/ext/standard/tests/php_real_logo_guid.phpt deleted file mode 100644 index a9fa7d35d51a8..0000000000000 --- a/ext/standard/tests/php_real_logo_guid.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Testing the undocumented function php_real_logo_guid() ---CREDITS-- -Sebastian Schürmann -sschuermann@chip.de -Testfest 2009 Munich ---FILE-- - ---EXPECT-- -PHPE9568F34-D428-11d2-A769-00AA001ACF42 diff --git a/ext/standard/tests/strings/bug61038.phpt b/ext/standard/tests/strings/bug61038.phpt new file mode 100644 index 0000000000000..7130804fa415c --- /dev/null +++ b/ext/standard/tests/strings/bug61038.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #61038: unpack("a5", "str\0\0") does not work as expected +--FILE-- + +--EXPECTF-- +array(1) { + [1]=> + string(4) "str%c" +} +array(1) { + [1]=> + string(5) "str%c%c" +} + +Warning: unpack(): Type a: not enough input, need 6, have 5 in %s on line %d +bool(false) +array(1) { + [1]=> + string(5) "str%c%c" +} + diff --git a/ext/standard/tests/strings/bug63874.phpt b/ext/standard/tests/strings/bug63874.phpt new file mode 100644 index 0000000000000..066cc155df960 --- /dev/null +++ b/ext/standard/tests/strings/bug63874.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #63874 (Segfault if php_strip_whitespace has heredoc) +--FILE-- + +--EXPECT-- + diff --git a/ext/standard/tests/strings/pack_A.phpt b/ext/standard/tests/strings/pack_A.phpt new file mode 100644 index 0000000000000..59fc22e122241 --- /dev/null +++ b/ext/standard/tests/strings/pack_A.phpt @@ -0,0 +1,25 @@ +--TEST-- +pack()/unpack(): "A" modifier +--FILE-- + +--EXPECTF-- +string(5) "foo " +string(4) "fooo" +string(4) "foo " +array(1) { + [1]=> + string(8) "foo%c%cbar" +} +array(1) { + [1]=> + string(3) "foo" +} + diff --git a/ext/standard/tests/strings/pack_Z.phpt b/ext/standard/tests/strings/pack_Z.phpt new file mode 100644 index 0000000000000..4fd007ae0f6ab --- /dev/null +++ b/ext/standard/tests/strings/pack_Z.phpt @@ -0,0 +1,50 @@ +--TEST-- +pack()/unpack(): "Z" format +--FILE-- + + string(3) "foo" +} +array(1) { + [1]=> + string(3) "foo" +} +bool(false) +array(1) { + [1]=> + string(0) "" +} +array(1) { + [1]=> + string(1) "A" +} +array(1) { + [1]=> + string(2) "AB" +} +array(1) { + [1]=> + string(2) "AB" +} diff --git a/ext/standard/tests/strings/parse_str_basic3.phpt b/ext/standard/tests/strings/parse_str_basic3.phpt index 619b1476ab5d0..84f6a53bb19fb 100644 Binary files a/ext/standard/tests/strings/parse_str_basic3.phpt and b/ext/standard/tests/strings/parse_str_basic3.phpt differ diff --git a/ext/standard/tests/strings/unpack_error.phpt b/ext/standard/tests/strings/unpack_error.phpt index 43b2df1c0a12d..1ef97ccbaf829 100644 --- a/ext/standard/tests/strings/unpack_error.phpt +++ b/ext/standard/tests/strings/unpack_error.phpt @@ -19,7 +19,7 @@ var_dump(unpack("I", pack("I", 65534), $extra_arg)); echo "\n-- Testing unpack() function with invalid format character --\n"; $extra_arg = 10; -var_dump(unpack("Z", pack("I", 65534))); +var_dump(unpack("G", pack("I", 65534))); ?> ===DONE=== --EXPECTF-- @@ -37,6 +37,6 @@ NULL -- Testing unpack() function with invalid format character -- -Warning: unpack(): Invalid format type Z in %s on line %d +Warning: unpack(): Invalid format type G in %s on line %d bool(false) ===DONE=== diff --git a/ext/standard/tests/zend_logo_guid.phpt b/ext/standard/tests/zend_logo_guid.phpt deleted file mode 100644 index 44e213b25d3a2..0000000000000 --- a/ext/standard/tests/zend_logo_guid.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Checking the zend_logo_guid() function ---CREDITS-- -Sebastian Schürmann -sschuermann@chip.de -Testfest 2009 Munich ---FILE-- - ---EXPECT-- -PHPE9568F35-D428-11d2-A769-00AA001ACF42 diff --git a/ext/standard/type.c b/ext/standard/type.c index 5c4085a28ae4d..5d93f66f5b725 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -176,6 +176,20 @@ PHP_FUNCTION(floatval) } /* }}} */ +/* {{{ proto bool boolval(mixed var) + Get the boolean value of a variable */ +PHP_FUNCTION(boolval) +{ + zval **val; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &val) == FAILURE) { + return; + } + + RETURN_BOOL(zend_is_true(*val)); +} +/* }}} */ + /* {{{ proto string strval(mixed var) Get the string value of a variable */ PHP_FUNCTION(strval) diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index 9aff2cb61ec8e..cb5983f685d52 100644 --- a/ext/standard/url_scanner_ex.c +++ b/ext/standard/url_scanner_ex.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Tue Jan 1 16:28:14 2013 */ +/* Generated by re2c 0.13.5 */ #line 1 "ext/standard/url_scanner_ex.re" /* +----------------------------------------------------------------------+ diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index bd0b2f66958c8..3730ff8e81343 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Mon Jan 21 11:34:03 2013 */ +/* Generated by re2c 0.13.5 on Mon Jan 21 11:41:53 2013 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ diff --git a/ext/tokenizer/tests/bug60097.phpt b/ext/tokenizer/tests/bug60097.phpt new file mode 100644 index 0000000000000..2116866c93434 --- /dev/null +++ b/ext/tokenizer/tests/bug60097.phpt @@ -0,0 +1,121 @@ +--TEST-- +Bug 60097: token_get_all fails to lex nested heredoc +--FILE-- + +--EXPECT-- +array(14) { + [0]=> + array(3) { + [0]=> + int(374) + [1]=> + string(6) " + int(1) + } + [1]=> + array(3) { + [0]=> + int(378) + [1]=> + string(8) "<< + int(2) + } + [2]=> + array(3) { + [0]=> + int(381) + [1]=> + string(1) "{" + [2]=> + int(3) + } + [3]=> + array(3) { + [0]=> + int(310) + [1]=> + string(2) "$s" + [2]=> + int(3) + } + [4]=> + string(1) "(" + [5]=> + array(3) { + [0]=> + int(378) + [1]=> + string(8) "<< + int(3) + } + [6]=> + array(3) { + [0]=> + int(379) + [1]=> + string(4) "DOC2" + [2]=> + int(4) + } + [7]=> + array(3) { + [0]=> + int(377) + [1]=> + string(1) " +" + [2]=> + int(4) + } + [8]=> + string(1) ")" + [9]=> + string(1) "}" + [10]=> + array(3) { + [0]=> + int(315) + [1]=> + string(1) " +" + [2]=> + int(5) + } + [11]=> + array(3) { + [0]=> + int(379) + [1]=> + string(4) "DOC1" + [2]=> + int(6) + } + [12]=> + string(1) ";" + [13]=> + array(3) { + [0]=> + int(377) + [1]=> + string(1) " +" + [2]=> + int(6) + } +} diff --git a/ext/tokenizer/tests/token_get_all_variation11.phpt b/ext/tokenizer/tests/token_get_all_variation11.phpt index ecc86177a4dfb..98d89961b77bd 100644 --- a/ext/tokenizer/tests/token_get_all_variation11.phpt +++ b/ext/tokenizer/tests/token_get_all_variation11.phpt @@ -130,7 +130,7 @@ array(49) { [6]=> array(3) { [0]=> - int(283) + int(%d) [1]=> string(2) "==" [2]=> @@ -273,7 +273,7 @@ array(49) { [27]=> array(3) { [0]=> - int(283) + int(%d) [1]=> string(2) "==" [2]=> diff --git a/ext/tokenizer/tests/token_get_all_variation13.phpt b/ext/tokenizer/tests/token_get_all_variation13.phpt index 9b2f3bc94fb61..6f85492a99a7f 100644 --- a/ext/tokenizer/tests/token_get_all_variation13.phpt +++ b/ext/tokenizer/tests/token_get_all_variation13.phpt @@ -1005,7 +1005,7 @@ array(145) { [122]=> array(3) { [0]=> - int(288) + int(%d) [1]=> string(10) "instanceof" [2]=> diff --git a/ext/tokenizer/tests/token_get_all_variation17.phpt b/ext/tokenizer/tests/token_get_all_variation17.phpt index dccc4c9c23dd9..f71444bc1e84d 100644 --- a/ext/tokenizer/tests/token_get_all_variation17.phpt +++ b/ext/tokenizer/tests/token_get_all_variation17.phpt @@ -145,7 +145,7 @@ array(81) { [14]=> array(3) { [0]=> - int(283) + int(%d) [1]=> string(2) "==" [2]=> diff --git a/ext/tokenizer/tests/token_get_all_variation4.phpt b/ext/tokenizer/tests/token_get_all_variation4.phpt index 45e6f8afbdefe..6bc111efbac25 100644 --- a/ext/tokenizer/tests/token_get_all_variation4.phpt +++ b/ext/tokenizer/tests/token_get_all_variation4.phpt @@ -339,7 +339,7 @@ array(89) { [38]=> array(3) { [0]=> - int(279) + int(%d) [1]=> string(2) "&&" [2]=> @@ -518,7 +518,7 @@ array(89) { [60]=> array(3) { [0]=> - int(278) + int(%d) [1]=> string(2) "||" [2]=> diff --git a/ext/tokenizer/tests/token_get_all_variation5.phpt b/ext/tokenizer/tests/token_get_all_variation5.phpt index 0068f2866fb36..681fb48e573ff 100644 --- a/ext/tokenizer/tests/token_get_all_variation5.phpt +++ b/ext/tokenizer/tests/token_get_all_variation5.phpt @@ -181,7 +181,7 @@ array(94) { [18]=> array(3) { [0]=> - int(277) + int(%d) [1]=> string(2) "+=" [2]=> @@ -238,7 +238,7 @@ array(94) { [25]=> array(3) { [0]=> - int(276) + int(%d) [1]=> string(2) "-=" [2]=> @@ -295,7 +295,7 @@ array(94) { [32]=> array(3) { [0]=> - int(275) + int(%d) [1]=> string(2) "*=" [2]=> @@ -352,7 +352,7 @@ array(94) { [39]=> array(3) { [0]=> - int(274) + int(%d) [1]=> string(2) "/=" [2]=> @@ -409,7 +409,7 @@ array(94) { [46]=> array(3) { [0]=> - int(272) + int(%d) [1]=> string(2) "%=" [2]=> @@ -466,7 +466,7 @@ array(94) { [53]=> array(3) { [0]=> - int(271) + int(%d) [1]=> string(2) "&=" [2]=> @@ -523,7 +523,7 @@ array(94) { [60]=> array(3) { [0]=> - int(270) + int(%d) [1]=> string(2) "|=" [2]=> @@ -580,7 +580,7 @@ array(94) { [67]=> array(3) { [0]=> - int(269) + int(%d) [1]=> string(2) "^=" [2]=> @@ -637,7 +637,7 @@ array(94) { [74]=> array(3) { [0]=> - int(267) + int(%d) [1]=> string(3) ">>=" [2]=> @@ -694,7 +694,7 @@ array(94) { [81]=> array(3) { [0]=> - int(268) + int(%d) [1]=> string(3) "<<=" [2]=> @@ -751,7 +751,7 @@ array(94) { [88]=> array(3) { [0]=> - int(273) + int(%d) [1]=> string(2) ".=" [2]=> diff --git a/ext/tokenizer/tests/token_get_all_variation6.phpt b/ext/tokenizer/tests/token_get_all_variation6.phpt index 54936d0c89ac3..6213dab9d0522 100644 --- a/ext/tokenizer/tests/token_get_all_variation6.phpt +++ b/ext/tokenizer/tests/token_get_all_variation6.phpt @@ -191,7 +191,7 @@ array(50) { [21]=> array(3) { [0]=> - int(287) + int(%d) [1]=> string(2) "<<" [2]=> @@ -277,7 +277,7 @@ array(50) { [32]=> array(3) { [0]=> - int(286) + int(%d) [1]=> string(2) ">>" [2]=> diff --git a/ext/tokenizer/tests/token_get_all_variation8.phpt b/ext/tokenizer/tests/token_get_all_variation8.phpt index 0cf1d63471127..c80a5d0f04d5a 100644 --- a/ext/tokenizer/tests/token_get_all_variation8.phpt +++ b/ext/tokenizer/tests/token_get_all_variation8.phpt @@ -794,7 +794,7 @@ array(108) { [103]=> array(3) { [0]=> - int(289) + int(%d) [1]=> string(7) "(unset)" [2]=> diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c index 132a7f299f582..ee96e2eaa11e1 100644 --- a/ext/tokenizer/tokenizer.c +++ b/ext/tokenizer/tokenizer.c @@ -138,11 +138,8 @@ static void tokenize(zval *return_value TSRMLS_DC) token_line = ++CG(zend_lineno); CG(increment_lineno) = 0; } - add_next_index_stringl(keyword, Z_STRVAL(token), Z_STRLEN(token), 1); - efree(Z_STRVAL(token)); - } else { - add_next_index_stringl(keyword, (char *)zendtext, zendleng, 1); } + add_next_index_stringl(keyword, (char *)zendtext, zendleng, 1); add_next_index_long(keyword, token_line); add_next_index_zval(return_value, keyword); } else { diff --git a/ext/tokenizer/tokenizer_data.c b/ext/tokenizer/tokenizer_data.c index 1f563da6b599a..57b29e1dd7006 100644 --- a/ext/tokenizer/tokenizer_data.c +++ b/ext/tokenizer/tokenizer_data.c @@ -21,7 +21,7 @@ /* DO NOT EDIT THIS FILE! This file is generated using tokenizer_data_gen.sh -*/ +*/ #include "php.h" #include "zend.h" @@ -108,8 +108,10 @@ void tokenizer_register_constants(INIT_FUNC_ARGS) { REGISTER_LONG_CONSTANT("T_FUNCTION", T_FUNCTION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_CONST", T_CONST, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_RETURN", T_RETURN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("T_YIELD", T_YIELD, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_TRY", T_TRY, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_CATCH", T_CATCH, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("T_FINALLY", T_FINALLY, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_THROW", T_THROW, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_USE", T_USE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("T_INSTEADOF", T_INSTEADOF, CONST_CS | CONST_PERSISTENT); @@ -242,8 +244,10 @@ char *get_token_type_name(int token_type) case T_FUNCTION: return "T_FUNCTION"; case T_CONST: return "T_CONST"; case T_RETURN: return "T_RETURN"; + case T_YIELD: return "T_YIELD"; case T_TRY: return "T_TRY"; case T_CATCH: return "T_CATCH"; + case T_FINALLY: return "T_FINALLY"; case T_THROW: return "T_THROW"; case T_USE: return "T_USE"; case T_INSTEADOF: return "T_INSTEADOF"; diff --git a/ext/xsl/php_xsl.c b/ext/xsl/php_xsl.c index 6cbd91a7973b3..41e1b9fa236bb 100644 --- a/ext/xsl/php_xsl.c +++ b/ext/xsl/php_xsl.c @@ -182,7 +182,7 @@ PHP_MINIT_FUNCTION(xsl) REGISTER_LONG_CONSTANT("XSL_SECPREF_READ_NETWORK", XSL_SECPREF_READ_NETWORK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XSL_SECPREF_WRITE_NETWORK", XSL_SECPREF_WRITE_NETWORK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XSL_SECPREF_DEFAULT", XSL_SECPREF_DEFAULT, CONST_CS | CONST_PERSISTENT); - + REGISTER_LONG_CONSTANT("LIBXSLT_VERSION", LIBXSLT_VERSION, CONST_CS | CONST_PERSISTENT); REGISTER_STRING_CONSTANT("LIBXSLT_DOTTED_VERSION", LIBXSLT_DOTTED_VERSION, CONST_CS | CONST_PERSISTENT); diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 727cc853ca1ae..5fd470a105ec4 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -410,7 +410,7 @@ static int php_zip_parse_options(zval *options, long *remove_all_path, ze_zip_object *obj = (ze_zip_object*) zend_object_store_get_object(object TSRMLS_CC); \ intern = obj->za; \ if (!intern) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or unitialized Zip object"); \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or uninitialized Zip object"); \ RETURN_FALSE; \ } \ } diff --git a/ext/zlib/tests/001.phpt b/ext/zlib/tests/001.phpt index 0c2ca28c78eb7..4850a65a5a03b 100644 --- a/ext/zlib/tests/001.phpt +++ b/ext/zlib/tests/001.phpt @@ -29,4 +29,4 @@ Strings are equal 100 36864 Strings are equal 5 15 -Strings are equal +Strings are equal \ No newline at end of file diff --git a/ext/zlib/tests/data.inc b/ext/zlib/tests/data.inc index fb20f0bcdf2e9..441199ff08a72 100644 --- a/ext/zlib/tests/data.inc +++ b/ext/zlib/tests/data.inc @@ -85,4 +85,4 @@ That summons thee to heaven or to hell. QUOTE; -?> +?> \ No newline at end of file diff --git a/ext/zlib/tests/gzfile_basic.phpt b/ext/zlib/tests/gzfile_basic.phpt index fd7ba180589b2..1fceea5b90eb2 100644 --- a/ext/zlib/tests/gzfile_basic.phpt +++ b/ext/zlib/tests/gzfile_basic.phpt @@ -36,4 +36,4 @@ array(3) { [2]=> string(17) "for all languages" } -===DONE=== +===DONE=== \ No newline at end of file diff --git a/ext/zlib/tests/gzfile_basic2.phpt b/ext/zlib/tests/gzfile_basic2.phpt index 9124d336b00cc..9f31eb0f87380 100644 --- a/ext/zlib/tests/gzfile_basic2.phpt +++ b/ext/zlib/tests/gzfile_basic2.phpt @@ -36,4 +36,4 @@ array(3) { [2]=> string(17) "for all languages" } -===DONE=== +===DONE=== \ No newline at end of file diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c index 5f276ad7889d9..8ccd9e161c5bc 100644 --- a/ext/zlib/zlib_filter.c +++ b/ext/zlib/zlib_filter.c @@ -62,10 +62,9 @@ static php_stream_filter_status_t php_zlib_inflate_filter( { php_zlib_filter_data *data; php_stream_bucket *bucket; - size_t consumed = 0, original_out, original_in; + size_t consumed = 0; int status; php_stream_filter_status_t exit_status = PSFS_FEED_ME; - z_stream *streamp; if (!thisfilter || !thisfilter->abstract) { /* Should never happen */ @@ -73,9 +72,6 @@ static php_stream_filter_status_t php_zlib_inflate_filter( } data = (php_zlib_filter_data *)(thisfilter->abstract); - streamp = &(data->strm); - original_in = data->strm.total_in; - original_out = data->strm.total_out; while (buckets_in->head) { size_t bin = 0, desired; @@ -191,10 +187,9 @@ static php_stream_filter_status_t php_zlib_deflate_filter( { php_zlib_filter_data *data; php_stream_bucket *bucket; - size_t consumed = 0, original_out, original_in; + size_t consumed = 0; int status; php_stream_filter_status_t exit_status = PSFS_FEED_ME; - z_stream *streamp; if (!thisfilter || !thisfilter->abstract) { /* Should never happen */ @@ -202,9 +197,6 @@ static php_stream_filter_status_t php_zlib_deflate_filter( } data = (php_zlib_filter_data *)(thisfilter->abstract); - streamp = &(data->strm); - original_in = data->strm.total_in; - original_out = data->strm.total_out; while (buckets_in->head) { size_t bin = 0, desired; diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h index ae0001f4836a8..ee96eef313a8c 100644 --- a/main/fopen_wrappers.h +++ b/main/fopen_wrappers.h @@ -28,7 +28,7 @@ BEGIN_EXTERN_C() PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC); PHPAPI char *expand_filepath(const char *filepath, char *real_path TSRMLS_DC); PHPAPI char *expand_filepath_ex(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len TSRMLS_DC); -PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len, int realpath_mode TSRMLS_DC); +PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len, int use_realpath TSRMLS_DC); PHPAPI int php_check_open_basedir(const char *path TSRMLS_DC); PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC); diff --git a/main/logos.h b/main/logos.h deleted file mode 100644 index eb2810712d29f..0000000000000 --- a/main/logos.h +++ /dev/null @@ -1,1080 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#define CONTEXT_TYPE_IMAGE_GIF "Content-Type: image/gif" - -static const unsigned char zend_logo[] = { - 71, 73, 70, 56, 57, 97, 113, 0, 72, 0, - 213, 0, 0, 13, 13, 14, 1, 3, 6, 2, - 5, 9, 46, 68, 94, 21, 29, 39, 5, 15, - 26, 4, 10, 17, 29, 43, 58, 0, 1, 2, - 9, 25, 42, 38, 105, 171, 24, 67, 109, 13, - 36, 59, 10, 27, 45, 9, 25, 41, 35, 96, - 157, 32, 87, 142, 29, 79, 130, 26, 70, 114, - 20, 54, 87, 29, 77, 124, 10, 26, 42, 34, - 88, 141, 10, 24, 38, 11, 26, 41, 1, 2, - 3, 55, 80, 105, 45, 63, 81, 49, 53, 57, - 5, 15, 24, 9, 26, 42, 30, 85, 138, 33, - 92, 149, 26, 73, 117, 10, 28, 45, 32, 89, - 142, 30, 84, 134, 26, 72, 115, 15, 42, 67, - 23, 62, 99, 12, 32, 51, 7, 21, 33, 9, - 26, 41, 8, 23, 35, 7, 25, 37, 51, 58, - 63, 2, 4, 5, 25, 26, 26, 49, 50, 50, - 255, 102, 0, 255, 255, 255, 204, 204, 204, 199, - 199, 199, 191, 191, 191, 171, 171, 171, 146, 146, - 146, 115, 115, 115, 85, 85, 85, 60, 60, 60, - 55, 55, 55, 38, 38, 38, 7, 7, 7, 3, - 3, 3, 0, 0, 0, 44, 0, 0, 0, 0, - 113, 0, 72, 0, 0, 6, 255, 192, 153, 112, - 72, 44, 26, 143, 200, 164, 114, 121, 252, 49, - 159, 208, 168, 148, 248, 171, 58, 167, 210, 171, - 208, 170, 197, 122, 191, 70, 109, 23, 140, 236, - 138, 201, 232, 239, 121, 102, 221, 186, 217, 219, - 171, 83, 46, 110, 15, 207, 235, 180, 190, 124, - 135, 187, 229, 127, 127, 128, 112, 121, 108, 118, - 132, 123, 137, 77, 118, 120, 136, 115, 109, 117, - 85, 126, 147, 147, 128, 99, 138, 137, 99, 107, - 146, 146, 148, 133, 159, 125, 136, 152, 163, 151, - 135, 121, 144, 84, 157, 92, 169, 157, 111, 163, - 175, 176, 83, 151, 177, 180, 181, 161, 182, 184, - 185, 186, 187, 188, 189, 67, 54, 56, 58, 56, - 53, 190, 197, 88, 55, 57, 60, 63, 2, 43, - 2, 56, 198, 208, 74, 192, 58, 0, 63, 5, - 12, 11, 35, 35, 12, 47, 209, 222, 67, 53, - 201, 203, 34, 19, 20, 218, 231, 37, 63, 54, - 223, 222, 60, 2, 216, 231, 241, 231, 206, 76, - 193, 55, 236, 176, 63, 39, 242, 252, 35, 40, - 58, 75, 114, 8, 40, 240, 227, 25, 62, 76, - 60, 24, 244, 147, 55, 161, 202, 11, 24, 57, - 134, 17, 201, 241, 99, 130, 191, 130, 7, 21, - 225, 48, 176, 48, 30, 137, 5, 11, 38, 48, - 88, 81, 5, 198, 51, 138, 22, 181, 53, 52, - 152, 49, 141, 141, 31, 230, 58, 46, 60, 129, - 194, 74, 202, 115, 43, 91, 234, 1, 112, 83, - 102, 63, 255, 18, 38, 122, 226, 252, 145, 67, - 39, 153, 26, 47, 68, 248, 92, 186, 176, 97, - 81, 163, 88, 108, 188, 48, 80, 130, 169, 85, - 134, 68, 161, 74, 177, 1, 160, 0, 137, 171, - 96, 135, 62, 213, 186, 132, 171, 215, 176, 104, - 71, 52, 188, 71, 54, 9, 210, 179, 105, 195, - 166, 99, 219, 214, 198, 58, 34, 48, 12, 124, - 213, 38, 163, 175, 223, 191, 50, 22, 132, 216, - 139, 182, 132, 0, 30, 196, 250, 218, 37, 70, - 198, 198, 141, 199, 144, 31, 223, 253, 114, 163, - 10, 0, 97, 192, 126, 100, 59, 7, 24, 176, - 10, 20, 229, 210, 146, 48, 128, 88, 72, 223, - 28, 57, 38, 111, 197, 17, 163, 181, 235, 215, - 58, 116, 68, 100, 60, 5, 134, 136, 18, 19, - 80, 24, 168, 162, 48, 94, 95, 21, 6, 82, - 168, 80, 209, 215, 128, 1, 20, 39, 8, 95, - 37, 81, 160, 180, 105, 25, 177, 233, 62, 1, - 246, 186, 186, 245, 24, 209, 177, 84, 140, 71, - 97, 130, 114, 109, 33, 76, 48, 152, 176, 192, - 111, 135, 20, 222, 211, 54, 167, 61, 163, 111, - 246, 39, 55, 174, 203, 175, 254, 30, 74, 229, - 152, 62, 73, 132, 24, 60, 162, 47, 131, 14, - 12, 132, 224, 155, 95, 130, 145, 208, 89, 129, - 40, 116, 211, 25, 12, 58, 72, 135, 68, 124, - 214, 197, 38, 161, 14, 243, 73, 200, 222, 18, - 27, 161, 213, 215, 4, 159, 37, 199, 255, 25, - 96, 12, 116, 230, 223, 9, 11, 252, 32, 226, - 11, 13, 74, 35, 223, 132, 19, 174, 24, 27, - 75, 76, 192, 128, 66, 88, 126, 161, 160, 66, - 122, 124, 201, 112, 2, 3, 195, 125, 54, 65, - 95, 29, 4, 87, 227, 9, 126, 233, 192, 3, - 12, 125, 161, 232, 160, 93, 207, 184, 200, 98, - 139, 17, 74, 24, 197, 118, 96, 249, 7, 160, - 128, 31, 242, 72, 30, 72, 33, 244, 149, 2, - 122, 229, 201, 0, 224, 105, 60, 52, 216, 23, - 131, 14, 226, 96, 194, 1, 78, 74, 152, 195, - 13, 196, 208, 192, 90, 148, 177, 217, 7, 83, - 149, 50, 112, 136, 220, 94, 34, 22, 216, 159, - 12, 195, 101, 227, 37, 113, 50, 192, 0, 3, - 156, 238, 165, 72, 196, 11, 21, 178, 184, 228, - 117, 19, 66, 145, 225, 85, 53, 222, 72, 152, - 136, 42, 152, 32, 224, 111, 42, 8, 10, 40, - 161, 101, 222, 96, 67, 95, 61, 40, 58, 3, - 13, 55, 24, 112, 221, 101, 19, 226, 64, 131, - 17, 54, 64, 42, 229, 19, 50, 226, 249, 95, - 128, 127, 238, 23, 166, 113, 194, 105, 250, 103, - 160, 191, 18, 90, 232, 13, 59, 0, 249, 130, - 168, 56, 160, 198, 195, 10, 214, 161, 144, 1, - 131, 245, 21, 1, 33, 125, 177, 141, 181, 4, - 149, 76, 137, 232, 23, 3, 38, 132, 9, 216, - 9, 93, 126, 234, 105, 160, 34, 94, 208, 129, - 14, 7, 152, 112, 255, 2, 4, 40, 84, 80, - 157, 8, 30, 176, 154, 195, 133, 68, 200, 250, - 34, 124, 119, 102, 171, 109, 113, 157, 142, 16, - 238, 111, 160, 113, 58, 110, 167, 38, 252, 213, - 192, 193, 12, 72, 32, 193, 3, 15, 128, 192, - 128, 7, 175, 121, 32, 66, 7, 101, 230, 240, - 42, 18, 53, 216, 171, 131, 106, 73, 224, 32, - 0, 88, 221, 217, 216, 227, 200, 190, 234, 39, - 210, 112, 12, 36, 23, 158, 175, 254, 154, 160, - 105, 9, 5, 236, 88, 129, 7, 41, 83, 240, - 65, 195, 32, 56, 236, 128, 107, 14, 36, 208, - 64, 10, 24, 41, 161, 177, 181, 74, 84, 182, - 194, 4, 85, 45, 181, 239, 134, 11, 236, 165, - 31, 151, 95, 233, 199, 223, 8, 82, 27, 40, - 3, 9, 39, 144, 56, 24, 4, 92, 119, 61, - 129, 3, 96, 135, 221, 128, 8, 12, 0, 64, - 239, 47, 26, 59, 88, 52, 53, 227, 132, 182, - 208, 210, 128, 178, 76, 163, 12, 46, 135, 208, - 245, 221, 92, 3, 21, 54, 216, 9, 152, 208, - 48, 64, 72, 12, 237, 197, 52, 0, 152, 208, - 209, 111, 193, 141, 204, 239, 102, 104, 45, 96, - 128, 9, 20, 224, 45, 249, 215, 97, 51, 240, - 1, 8, 10, 152, 80, 20, 14, 56, 208, 213, - 38, 199, 181, 245, 214, 207, 111, 96, 130, 4, - 146, 72, 114, 135, 69, 194, 10, 38, 64, 0, - 130, 228, 120, 71, 240, 181, 8, 145, 67, 240, - 255, 128, 2, 44, 164, 0, 26, 2, 66, 180, - 9, 163, 23, 56, 20, 112, 184, 184, 242, 232, - 119, 224, 212, 127, 18, 56, 152, 95, 14, 252, - 8, 88, 129, 120, 255, 37, 216, 205, 17, 68, - 160, 192, 3, 24, 212, 64, 131, 198, 58, 92, - 12, 70, 101, 223, 125, 8, 172, 60, 218, 166, - 252, 149, 136, 41, 251, 21, 64, 249, 201, 117, - 221, 89, 202, 151, 131, 112, 251, 9, 211, 194, - 54, 161, 218, 88, 212, 128, 237, 128, 207, 35, - 15, 164, 144, 125, 65, 78, 141, 206, 3, 164, - 0, 245, 69, 0, 34, 248, 95, 10, 134, 68, - 2, 8, 244, 101, 71, 97, 3, 77, 237, 70, - 240, 0, 18, 248, 110, 15, 58, 80, 10, 63, - 48, 37, 55, 47, 129, 169, 128, 86, 10, 152, - 12, 132, 19, 166, 2, 36, 112, 132, 31, 20, - 83, 128, 28, 40, 3, 6, 52, 207, 116, 91, - 227, 218, 3, 218, 68, 52, 50, 224, 32, 95, - 228, 147, 1, 175, 134, 211, 65, 226, 13, 138, - 116, 222, 249, 77, 1, 10, 38, 3, 7, 52, - 160, 47, 96, 91, 0, 11, 83, 224, 128, 62, - 197, 176, 107, 32, 224, 222, 217, 192, 240, 130, - 25, 109, 16, 133, 91, 242, 159, 15, 63, 37, - 176, 63, 25, 64, 0, 68, 108, 128, 7, 144, - 232, 0, 37, 146, 81, 68, 14, 208, 20, 20, - 163, 72, 167, 216, 128, 14, 85, 201, 66, 205, - 155, 110, 224, 61, 37, 220, 255, 16, 63, 226, - 235, 215, 135, 194, 5, 44, 78, 249, 5, 61, - 86, 251, 65, 5, 36, 208, 23, 15, 52, 177, - 136, 101, 100, 97, 18, 195, 197, 171, 52, 218, - 205, 117, 51, 108, 163, 169, 132, 16, 171, 54, - 118, 174, 142, 69, 48, 75, 248, 224, 22, 162, - 45, 146, 171, 51, 8, 160, 221, 25, 17, 105, - 70, 82, 90, 237, 91, 131, 137, 164, 37, 137, - 80, 73, 238, 221, 11, 86, 93, 9, 95, 242, - 180, 101, 128, 46, 10, 236, 148, 126, 177, 6, - 5, 70, 153, 68, 69, 38, 18, 2, 255, 42, - 34, 104, 34, 160, 74, 106, 9, 99, 8, 245, - 51, 230, 147, 126, 55, 131, 26, 196, 178, 35, - 225, 25, 153, 52, 131, 82, 55, 240, 84, 19, - 107, 60, 234, 11, 0, 12, 16, 1, 16, 148, - 160, 110, 43, 123, 100, 56, 243, 22, 2, 145, - 128, 45, 101, 16, 152, 15, 118, 44, 54, 131, - 100, 218, 239, 73, 111, 58, 66, 13, 120, 0, - 151, 133, 60, 205, 116, 248, 20, 12, 5, 246, - 227, 52, 126, 106, 195, 120, 50, 56, 146, 1, - 46, 247, 1, 126, 86, 141, 156, 79, 132, 192, - 61, 67, 240, 1, 117, 182, 6, 85, 141, 90, - 38, 232, 134, 176, 17, 89, 198, 165, 35, 134, - 17, 70, 14, 92, 32, 63, 134, 141, 224, 117, - 176, 11, 105, 215, 44, 232, 208, 136, 178, 72, - 34, 118, 212, 203, 69, 173, 226, 148, 26, 216, - 133, 7, 255, 39, 80, 192, 4, 102, 42, 191, - 17, 136, 52, 164, 37, 109, 211, 253, 48, 137, - 49, 122, 90, 116, 165, 255, 100, 64, 86, 40, - 74, 128, 22, 0, 224, 6, 48, 152, 128, 2, - 64, 122, 211, 187, 229, 84, 153, 142, 226, 169, - 18, 230, 41, 128, 164, 1, 149, 31, 37, 98, - 166, 93, 134, 192, 129, 133, 49, 181, 169, 36, - 125, 234, 147, 36, 68, 71, 47, 80, 213, 170, - 252, 32, 79, 92, 232, 177, 4, 14, 80, 32, - 103, 77, 229, 218, 83, 177, 51, 214, 6, 73, - 53, 10, 103, 237, 71, 67, 126, 96, 0, 164, - 133, 69, 4, 128, 147, 134, 15, 72, 240, 85, - 174, 229, 236, 176, 175, 203, 105, 93, 223, 116, - 215, 41, 228, 53, 30, 43, 177, 65, 14, 94, - 80, 133, 21, 160, 64, 93, 75, 153, 0, 0, - 158, 224, 130, 19, 60, 224, 110, 57, 99, 216, - 237, 74, 0, 130, 8, 120, 192, 3, 99, 243, - 192, 97, 234, 58, 161, 120, 42, 226, 177, 106, - 9, 26, 37, 57, 167, 131, 23, 8, 207, 39, - 20, 248, 1, 254, 136, 80, 3, 20, 44, 21, - 180, 32, 32, 79, 4, 80, 16, 128, 11, 64, - 64, 4, 34, 80, 65, 7, 94, 80, 38, 214, - 202, 102, 183, 105, 168, 1, 12, 170, 26, 219, - 26, 34, 19, 135, 29, 41, 128, 117, 137, 128, - 3, 9, 252, 214, 176, 15, 24, 64, 15, 56, - 247, 12, 24, 168, 75, 4, 6, 0, 135, 192, - 14, 156, 139, 82, 90, 8, 164, 38, 219, 29, - 2, 79, 150, 194, 0, 24, 44, 97, 7, 22, - 184, 29, 195, 58, 106, 223, 58, 230, 160, 156, - 68, 89, 108, 89, 115, 145, 3, 147, 48, 33, - 131, 50, 89, 0, 3, 4, 16, 95, 33, 220, - 224, 5, 26, 64, 193, 91, 111, 167, 57, 35, - 132, 35, 53, 148, 116, 12, 100, 166, 248, 13, - 143, 241, 163, 59, 34, 16, 192, 15, 120, 208, - 222, 36, 208, 192, 49, 63, 216, 192, 9, 36, - 192, 128, 137, 114, 152, 44, 47, 217, 140, 130, - 9, 114, 25, 28, 76, 148, 9, 162, 2, 128, - 141, 219, 50, 5, 122, 134, 120, 196, 174, 141, - 46, 143, 167, 96, 131, 23, 221, 120, 200, 72, - 214, 74, 16, 0, 0, 59 }; - -static const unsigned char php_logo[] = { - 71, 73, 70, 56, 57, 97, 120, 0, 67, 0, - 230, 106, 0, 127, 130, 184, 57, 55, 71, 40, - 37, 42, 204, 205, 226, 161, 164, 203, 211, 213, - 231, 178, 180, 212, 67, 66, 88, 131, 134, 185, - 130, 131, 179, 82, 82, 114, 144, 146, 194, 194, - 196, 222, 170, 172, 208, 76, 75, 99, 91, 92, - 131, 221, 222, 236, 59, 56, 60, 110, 113, 165, - 106, 109, 157, 97, 99, 141, 117, 121, 177, 123, - 126, 181, 229, 230, 240, 153, 156, 198, 140, 141, - 193, 185, 186, 217, 107, 107, 146, 78, 78, 107, - 113, 116, 169, 122, 122, 163, 136, 139, 189, 114, - 116, 163, 116, 115, 152, 142, 144, 193, 90, 91, - 126, 226, 227, 239, 123, 125, 173, 164, 165, 208, - 109, 112, 162, 114, 118, 172, 149, 150, 200, 187, - 189, 217, 116, 120, 174, 133, 136, 187, 146, 149, - 195, 216, 217, 234, 146, 146, 196, 100, 102, 146, - 107, 110, 159, 165, 168, 206, 148, 150, 197, 46, - 43, 47, 83, 81, 104, 179, 180, 215, 108, 106, - 140, 92, 91, 118, 138, 141, 191, 102, 104, 150, - 104, 106, 154, 156, 159, 200, 49, 46, 57, 174, - 176, 211, 156, 156, 205, 85, 86, 120, 158, 161, - 202, 150, 153, 197, 129, 130, 175, 103, 105, 151, - 63, 61, 80, 188, 190, 218, 94, 96, 137, 152, - 153, 200, 140, 142, 191, 137, 138, 186, 87, 88, - 124, 182, 183, 215, 213, 215, 232, 34, 30, 32, - 108, 111, 158, 206, 208, 228, 191, 192, 220, 119, - 123, 180, 118, 120, 167, 95, 94, 125, 153, 153, - 204, 110, 111, 152, 115, 119, 174, 34, 30, 31, - 255, 255, 255, 144, 142, 143, 89, 86, 87, 199, - 198, 199, 238, 238, 245, 213, 212, 213, 246, 246, - 250, 130, 128, 129, 172, 170, 171, 116, 114, 115, - 241, 240, 241, 158, 156, 157, 227, 226, 227, 75, - 72, 73, 185, 184, 185, 103, 100, 101, 137, 137, - 182, 0, 255, 0, 71, 70, 95, 223, 224, 237, - 155, 156, 204, 105, 107, 156, 111, 115, 167, 140, - 140, 186, 184, 185, 217, 184, 186, 215, 154, 155, - 204, 167, 170, 207, 219, 220, 235, 154, 156, 201, - 102, 100, 132, 104, 103, 137, 167, 168, 210, 110, - 112, 160, 139, 139, 185, 198, 199, 224, 199, 201, - 225, 105, 108, 156, 151, 152, 203, 33, 249, 4, - 1, 0, 0, 106, 0, 44, 0, 0, 0, 0, - 120, 0, 67, 0, 0, 7, 255, 128, 106, 130, - 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, - 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, - 151, 150, 109, 63, 109, 115, 152, 158, 159, 160, - 63, 121, 121, 54, 62, 26, 113, 76, 26, 26, - 76, 6, 62, 62, 13, 50, 4, 65, 60, 24, - 66, 45, 11, 73, 34, 57, 31, 25, 57, 34, - 47, 41, 160, 194, 161, 13, 26, 12, 125, 77, - 5, 80, 80, 3, 125, 124, 12, 81, 81, 42, - 114, 172, 175, 116, 177, 179, 66, 51, 45, 186, - 31, 8, 0, 22, 22, 21, 87, 40, 37, 22, - 9, 25, 193, 195, 235, 140, 38, 113, 124, 46, - 108, 108, 16, 16, 117, 46, 201, 3, 212, 50, - 179, 34, 31, 254, 44, 0, 17, 8, 4, 64, - 176, 224, 55, 130, 225, 164, 172, 64, 241, 70, - 194, 9, 63, 59, 158, 76, 25, 146, 132, 157, - 69, 53, 65, 108, 12, 96, 67, 226, 130, 71, - 18, 36, 242, 53, 16, 178, 64, 138, 201, 147, - 40, 83, 170, 92, 121, 114, 92, 7, 9, 19, - 118, 232, 128, 65, 225, 8, 5, 43, 67, 68, - 92, 196, 20, 132, 9, 20, 142, 30, 47, 184, - 48, 66, 167, 5, 203, 163, 72, 147, 162, 188, - 242, 38, 6, 140, 35, 71, 30, 140, 88, 114, - 196, 131, 206, 157, 144, 126, 104, 116, 1, 129, - 35, 4, 35, 4, 88, 40, 29, 75, 54, 233, - 149, 19, 58, 30, 44, 1, 162, 64, 193, 136, - 41, 51, 255, 176, 46, 50, 161, 161, 64, 19, - 23, 117, 10, 24, 72, 82, 182, 175, 95, 164, - 29, 96, 44, 81, 192, 129, 131, 3, 60, 9, - 228, 26, 202, 19, 101, 0, 148, 2, 3, 124, - 228, 248, 187, 114, 1, 134, 203, 152, 49, 124, - 160, 156, 244, 13, 5, 5, 14, 214, 172, 81, - 224, 65, 177, 154, 60, 70, 248, 244, 25, 192, - 100, 6, 231, 149, 31, 178, 112, 153, 77, 155, - 75, 151, 215, 74, 221, 44, 89, 115, 224, 128, - 131, 16, 59, 221, 69, 97, 192, 160, 1, 2, - 220, 43, 49, 112, 193, 194, 188, 185, 153, 219, - 200, 147, 118, 216, 93, 164, 200, 154, 210, 195, - 126, 248, 144, 99, 68, 5, 15, 11, 209, 87, - 170, 32, 211, 188, 185, 152, 2, 225, 149, 94, - 121, 112, 32, 64, 0, 14, 112, 64, 153, 48, - 192, 68, 14, 1, 0, 233, 87, 22, 16, 83, - 158, 57, 25, 21, 249, 41, 245, 134, 2, 238, - 245, 112, 7, 38, 115, 208, 225, 131, 1, 50, - 28, 23, 160, 74, 93, 152, 209, 31, 22, 92, - 16, 240, 160, 82, 49, 172, 209, 67, 15, 7, - 236, 81, 201, 15, 50, 52, 208, 64, 73, 23, - 166, 4, 64, 22, 19, 98, 145, 197, 102, 37, - 38, 245, 64, 0, 27, 2, 39, 73, 27, 4, - 236, 227, 96, 139, 39, 41, 55, 161, 25, 95, - 224, 168, 148, 31, 69, 208, 64, 3, 21, 145, - 216, 17, 4, 1, 51, 128, 135, 212, 255, 7, - 153, 53, 217, 36, 139, 71, 169, 16, 198, 132, - 98, 92, 208, 36, 137, 44, 49, 233, 228, 150, - 248, 141, 133, 130, 3, 52, 8, 80, 195, 35, - 72, 96, 16, 4, 148, 71, 125, 240, 69, 22, - 108, 182, 233, 230, 155, 89, 116, 81, 64, 3, - 93, 162, 84, 0, 24, 19, 146, 1, 103, 155, - 23, 12, 96, 225, 73, 11, 236, 41, 40, 155, - 93, 12, 208, 128, 82, 64, 8, 32, 128, 3, - 141, 204, 32, 4, 6, 98, 41, 69, 192, 114, - 41, 86, 106, 6, 24, 92, 124, 1, 32, 74, - 93, 108, 81, 105, 138, 52, 108, 161, 69, 25, - 93, 144, 104, 192, 148, 159, 78, 184, 5, 24, - 94, 116, 113, 40, 82, 35, 8, 224, 4, 163, - 138, 108, 35, 196, 141, 73, 141, 151, 234, 167, - 91, 120, 1, 65, 151, 39, 238, 250, 41, 24, - 99, 96, 32, 197, 0, 120, 10, 171, 106, 25, - 3, 36, 53, 130, 19, 78, 224, 144, 72, 10, - 34, 180, 128, 102, 82, 16, 240, 167, 108, 138, - 97, 64, 96, 18, 6, 94, 108, 155, 34, 26, - 183, 93, 224, 169, 184, 229, 209, 224, 69, 179, - 72, 173, 1, 45, 118, 133, 252, 225, 203, 100, - 101, 125, 33, 33, 186, 253, 121, 1, 160, 148, - 248, 230, 219, 0, 138, 253, 54, 71, 67, 25, - 127, 30, 21, 128, 19, 2, 44, 96, 72, 63, - 244, 146, 21, 91, 192, 229, 109, 209, 227, 157, - 16, 51, 167, 197, 255, 5, 225, 86, 140, 133, - 24, 208, 29, 213, 129, 172, 99, 18, 146, 2, - 2, 31, 212, 57, 214, 164, 59, 194, 57, 198, - 25, 218, 78, 232, 5, 1, 157, 78, 200, 197, - 155, 99, 112, 129, 70, 138, 90, 100, 129, 106, - 196, 112, 150, 113, 198, 185, 19, 150, 129, 37, - 75, 10, 64, 155, 6, 33, 222, 224, 58, 150, - 174, 253, 137, 225, 45, 74, 11, 52, 208, 5, - 121, 19, 106, 193, 0, 192, 253, 173, 136, 18, - 6, 13, 124, 17, 65, 213, 89, 104, 81, 53, - 187, 128, 26, 240, 69, 178, 253, 133, 97, 128, - 82, 52, 204, 58, 200, 31, 0, 32, 160, 100, - 89, 217, 230, 185, 169, 137, 89, 124, 221, 116, - 22, 25, 151, 199, 227, 74, 16, 0, 221, 92, - 206, 130, 51, 119, 198, 218, 42, 125, 48, 6, - 206, 119, 31, 181, 4, 180, 10, 171, 33, 130, - 5, 38, 147, 101, 175, 204, 5, 167, 20, 184, - 170, 58, 83, 249, 116, 74, 49, 247, 119, 70, - 22, 52, 4, 109, 236, 74, 161, 151, 167, 69, - 227, 44, 117, 0, 237, 13, 130, 176, 144, 80, - 95, 15, 79, 56, 198, 181, 39, 109, 222, 31, - 26, 89, 160, 221, 220, 127, 42, 5, 27, 116, - 25, 19, 210, 144, 197, 81, 169, 15, 206, 58, - 75, 69, 184, 173, 70, 56, 115, 147, 133, 114, - 127, 17, 244, 200, 210, 229, 253, 17, 142, 185, - 74, 224, 22, 159, 197, 25, 170, 94, 112, 20, - 255, 214, 229, 1, 175, 20, 7, 78, 244, 32, - 72, 5, 148, 49, 93, 30, 26, 159, 167, 84, - 123, 218, 228, 55, 119, 187, 74, 252, 246, 183, - 69, 216, 99, 179, 132, 1, 241, 219, 83, 10, - 5, 160, 37, 136, 21, 80, 166, 110, 217, 91, - 158, 73, 12, 0, 190, 160, 245, 173, 57, 213, - 211, 143, 239, 152, 3, 134, 44, 20, 14, 11, - 135, 99, 9, 3, 168, 214, 159, 251, 9, 144, - 128, 41, 184, 2, 251, 252, 130, 189, 242, 84, - 136, 37, 201, 99, 78, 4, 58, 183, 187, 248, - 157, 36, 133, 88, 8, 3, 233, 76, 183, 18, - 0, 120, 109, 66, 228, 34, 203, 0, 157, 32, - 8, 20, 24, 176, 47, 194, 235, 32, 238, 142, - 69, 169, 236, 245, 174, 106, 203, 11, 98, 121, - 188, 0, 192, 116, 29, 79, 63, 28, 44, 79, - 24, 20, 184, 146, 29, 10, 162, 3, 40, 24, - 33, 89, 116, 68, 189, 39, 162, 228, 3, 5, - 240, 66, 233, 250, 67, 131, 49, 124, 225, 130, - 39, 76, 73, 247, 38, 244, 189, 240, 113, 15, - 2, 98, 156, 80, 245, 42, 119, 20, 43, 170, - 97, 33, 90, 92, 90, 20, 153, 67, 46, 21, - 248, 81, 5, 16, 232, 194, 24, 180, 48, 70, - 209, 13, 160, 126, 204, 241, 32, 74, 242, 199, - 51, 177, 101, 175, 11, 127, 4, 100, 23, 202, - 224, 72, 153, 81, 113, 37, 232, 83, 223, 243, - 58, 112, 133, 190, 236, 71, 255, 85, 90, 8, - 101, 40, 197, 112, 175, 20, 137, 225, 11, 4, - 120, 160, 10, 189, 104, 167, 9, 98, 161, 130, - 23, 20, 149, 40, 181, 64, 202, 97, 137, 175, - 44, 205, 163, 213, 7, 222, 208, 129, 190, 68, - 72, 99, 104, 248, 194, 2, 78, 133, 67, 23, - 154, 196, 92, 19, 146, 97, 33, 3, 118, 202, - 161, 73, 231, 117, 130, 72, 129, 4, 222, 240, - 67, 165, 40, 177, 95, 205, 60, 150, 43, 173, - 182, 18, 68, 98, 129, 137, 26, 3, 131, 48, - 251, 242, 56, 39, 68, 238, 121, 18, 232, 229, - 88, 214, 216, 47, 26, 156, 97, 156, 82, 64, - 102, 127, 184, 240, 170, 173, 169, 146, 57, 109, - 12, 88, 4, 206, 112, 1, 103, 178, 205, 121, - 130, 120, 193, 9, 36, 208, 73, 165, 48, 82, - 92, 102, 32, 195, 24, 6, 80, 167, 25, 118, - 208, 159, 196, 212, 31, 255, 240, 101, 6, 25, - 50, 128, 142, 73, 41, 154, 19, 142, 70, 136, - 33, 156, 224, 13, 99, 161, 152, 254, 102, 57, - 75, 50, 112, 97, 12, 133, 66, 83, 160, 72, - 26, 74, 86, 158, 68, 5, 92, 96, 233, 232, - 46, 40, 6, 150, 134, 210, 164, 40, 101, 192, - 16, 165, 3, 50, 67, 164, 224, 4, 39, 80, - 39, 82, 96, 200, 133, 11, 208, 131, 30, 5, - 248, 35, 1, 252, 105, 18, 64, 30, 245, 168, - 153, 3, 212, 0, 158, 74, 143, 67, 46, 147, - 57, 94, 255, 48, 234, 81, 147, 234, 71, 2, - 236, 116, 44, 7, 75, 216, 33, 146, 16, 131, - 19, 160, 0, 41, 215, 76, 36, 83, 125, 36, - 133, 5, 52, 177, 60, 89, 192, 40, 114, 220, - 229, 4, 120, 25, 34, 1, 101, 45, 104, 114, - 238, 185, 66, 182, 178, 164, 1, 13, 140, 88, - 199, 242, 83, 78, 105, 41, 162, 4, 121, 101, - 201, 65, 249, 104, 76, 191, 74, 129, 1, 149, - 108, 14, 24, 208, 19, 160, 114, 210, 106, 17, - 136, 53, 171, 4, 171, 198, 0, 199, 170, 68, - 119, 82, 188, 36, 101, 52, 122, 89, 70, 148, - 96, 2, 49, 232, 64, 30, 165, 64, 212, 122, - 122, 214, 36, 121, 115, 217, 233, 162, 211, 129, - 3, 64, 171, 180, 141, 72, 0, 106, 37, 160, - 197, 180, 98, 97, 12, 107, 245, 209, 2, 22, - 199, 70, 185, 250, 133, 8, 61, 128, 150, 97, - 35, 161, 132, 39, 76, 64, 179, 82, 248, 223, - 22, 166, 75, 93, 222, 189, 214, 158, 212, 165, - 46, 24, 6, 251, 26, 5, 200, 74, 0, 50, - 154, 196, 11, 64, 224, 135, 24, 240, 22, 0, - 5, 160, 42, 61, 16, 119, 93, 41, 160, 87, - 189, 16, 112, 45, 101, 136, 112, 48, 39, 68, - 128, 163, 150, 72, 128, 27, 80, 251, 134, 213, - 182, 215, 175, 39, 176, 173, 114, 65, 241, 130, - 41, 248, 1, 181, 170, 253, 175, 95, 81, 192, - 1, 89, 57, 161, 8, 248, 5, 133, 255, 18, - 244, 224, 134, 3, 247, 87, 193, 37, 58, 193, - 26, 28, 220, 131, 240, 178, 131, 5, 20, 62, - 176, 4, 206, 138, 225, 240, 28, 225, 0, 138, - 18, 64, 15, 96, 167, 24, 22, 128, 96, 7, - 110, 112, 67, 12, 168, 89, 98, 202, 248, 129, - 3, 1, 8, 147, 0, 2, 192, 98, 211, 8, - 34, 9, 37, 32, 194, 14, 96, 60, 1, 26, - 215, 56, 41, 19, 32, 80, 15, 132, 36, 38, - 187, 250, 120, 16, 41, 72, 128, 30, 116, 64, - 4, 33, 187, 33, 168, 254, 197, 240, 27, 142, - 128, 227, 13, 45, 185, 8, 120, 120, 193, 147, - 23, 241, 2, 41, 235, 224, 204, 103, 222, 193, - 71, 73, 124, 221, 29, 28, 65, 1, 237, 129, - 209, 134, 14, 112, 3, 15, 141, 249, 17, 47, - 64, 192, 20, 136, 0, 131, 62, 251, 153, 8, - 126, 248, 168, 80, 243, 51, 1, 34, 60, 0, - 52, 213, 113, 143, 162, 113, 16, 2, 59, 223, - 153, 18, 34, 24, 194, 158, 41, 64, 233, 74, - 83, 250, 8, 125, 174, 112, 160, 223, 192, 105, - 78, 75, 224, 211, 159, 6, 42, 80, 137, 112, - 105, 182, 136, 166, 55, 7, 168, 78, 17, 2, - 112, 0, 28, 108, 32, 49, 143, 22, 70, 10, - 62, 80, 2, 16, 88, 1, 42, 80, 121, 128, - 174, 119, 61, 149, 37, 172, 5, 8, 108, 105, - 11, 97, 10, 99, 152, 208, 156, 186, 55, 69, - 80, 0, 21, 110, 56, 48, 4, 49, 199, 90, - 49, 41, 80, 2, 2, 60, 224, 129, 13, 108, - 32, 45, 190, 6, 118, 176, 219, 66, 108, 195, - 112, 128, 10, 35, 24, 129, 21, 172, 80, 130, - 102, 63, 251, 220, 139, 16, 65, 26, 16, 112, - 21, 116, 187, 251, 221, 240, 142, 119, 188, 3, - 1, 0, 59, 0 }; - -static const unsigned char php_egg_logo[] = { - 71, 73, 70, 56, 57, 97, 120, 0, 67, 0, - 231, 255, 0, 18, 25, 33, 32, 30, 34, 28, - 33, 44, 15, 35, 71, 6, 37, 85, 37, 40, - 47, 34, 41, 53, 41, 40, 43, 9, 47, 109, - 30, 45, 68, 21, 48, 84, 51, 46, 55, 43, - 49, 59, 31, 59, 98, 15, 61, 128, 58, 55, - 69, 50, 57, 74, 0, 66, 144, 56, 58, 60, - 54, 59, 71, 32, 66, 113, 60, 65, 67, 63, - 65, 84, 63, 68, 79, 28, 79, 145, 15, 82, - 162, 75, 72, 98, 68, 78, 86, 74, 77, 88, - 50, 82, 122, 41, 85, 134, 76, 78, 108, 70, - 83, 101, 5, 94, 190, 0, 95, 197, 86, 80, - 101, 28, 92, 159, 80, 84, 96, 83, 83, 115, - 81, 87, 89, 22, 97, 183, 86, 88, 85, 0, - 102, 210, 8, 101, 204, 24, 100, 177, 85, 90, - 127, 35, 101, 169, 42, 100, 159, 88, 92, 103, - 0, 107, 216, 69, 95, 132, 0, 108, 210, 84, - 93, 112, 94, 90, 117, 18, 105, 201, 96, 92, - 105, 89, 96, 98, 94, 93, 135, 94, 94, 126, - 30, 106, 210, 7, 112, 222, 33, 108, 198, 16, - 114, 217, 27, 113, 198, 24, 113, 209, 59, 108, - 159, 96, 100, 138, 0, 120, 229, 44, 112, 180, - 49, 112, 171, 71, 108, 148, 99, 104, 115, 90, - 106, 125, 27, 115, 232, 100, 102, 147, 42, 115, - 192, 86, 110, 137, 9, 123, 239, 106, 108, 105, - 105, 105, 138, 33, 118, 228, 12, 125, 227, 48, - 117, 208, 16, 126, 222, 37, 120, 224, 20, 125, - 235, 35, 123, 213, 50, 121, 190, 43, 123, 206, - 40, 123, 220, 105, 110, 160, 59, 122, 182, 78, - 119, 158, 44, 122, 233, 3, 134, 250, 112, 112, - 151, 73, 123, 175, 113, 118, 114, 51, 128, 205, - 34, 129, 246, 11, 136, 245, 34, 130, 240, 113, - 117, 149, 111, 116, 166, 111, 119, 141, 48, 130, - 221, 38, 132, 235, 53, 130, 215, 97, 124, 146, - 116, 122, 124, 117, 121, 131, 54, 130, 229, 41, - 135, 232, 68, 130, 223, 46, 135, 246, 65, 134, - 202, 42, 137, 241, 75, 131, 205, 124, 121, 161, - 101, 125, 191, 86, 128, 210, 121, 122, 169, 105, - 128, 157, 121, 122, 180, 114, 124, 181, 94, 128, - 201, 81, 134, 185, 46, 138, 252, 76, 135, 195, - 34, 142, 252, 62, 137, 229, 63, 138, 217, 33, - 144, 247, 58, 139, 223, 56, 141, 246, 54, 143, - 234, 57, 143, 241, 102, 135, 193, 129, 130, 176, - 122, 136, 144, 46, 148, 252, 45, 149, 246, 118, - 133, 191, 65, 146, 231, 73, 146, 216, 129, 133, - 185, 135, 135, 156, 69, 148, 226, 44, 153, 255, - 94, 143, 216, 132, 136, 175, 88, 146, 207, 137, - 139, 136, 93, 146, 197, 95, 147, 188, 137, 139, - 150, 104, 146, 178, 122, 143, 172, 135, 139, 191, - 57, 156, 254, 67, 154, 245, 70, 154, 239, 134, - 141, 180, 117, 145, 201, 120, 146, 190, 79, 154, - 233, 140, 141, 188, 129, 144, 194, 142, 142, 176, - 137, 147, 156, 88, 155, 222, 82, 157, 230, 93, - 157, 218, 66, 162, 253, 100, 157, 210, 77, 161, - 247, 55, 168, 255, 81, 162, 241, 148, 148, 195, - 145, 149, 202, 127, 156, 204, 77, 166, 255, 142, - 155, 177, 141, 153, 200, 123, 160, 193, 73, 171, - 255, 93, 167, 240, 96, 167, 234, 152, 158, 160, - 101, 167, 228, 119, 164, 206, 155, 158, 171, 110, - 167, 219, 156, 155, 203, 89, 172, 252, 128, 164, - 219, 151, 163, 174, 81, 178, 255, 158, 162, 202, - 102, 175, 249, 93, 178, 251, 108, 175, 237, 103, - 177, 244, 166, 168, 165, 97, 182, 255, 87, 185, - 255, 149, 174, 216, 125, 181, 235, 110, 185, 252, - 117, 183, 254, 171, 172, 209, 166, 175, 197, 103, - 190, 255, 174, 176, 189, 140, 183, 221, 128, 184, - 248, 120, 187, 249, 179, 180, 184, 115, 193, 253, - 170, 183, 193, 174, 181, 215, 107, 197, 255, 135, - 191, 246, 151, 192, 219, 187, 183, 213, 128, 197, - 253, 121, 202, 255, 147, 198, 239, 188, 191, 219, - 148, 200, 252, 192, 193, 197, 134, 205, 254, 171, - 199, 236, 183, 199, 218, 163, 207, 251, 142, 213, - 255, 158, 211, 253, 195, 205, 217, 166, 211, 245, - 205, 204, 228, 153, 218, 255, 190, 210, 236, 186, - 212, 231, 177, 213, 248, 162, 224, 255, 188, 221, - 250, 214, 219, 221, 214, 219, 233, 174, 229, 254, - 198, 225, 247, 209, 226, 248, 186, 233, 251, 227, - 230, 239, 225, 241, 252, 253, 255, 252, 255, 255, - 255, 33, 249, 4, 1, 10, 0, 255, 0, 44, - 0, 0, 0, 0, 120, 0, 67, 0, 0, 8, - 254, 0, 255, 9, 28, 72, 176, 160, 193, 131, - 8, 19, 42, 92, 200, 176, 161, 195, 135, 16, - 35, 74, 156, 72, 177, 162, 197, 139, 22, 131, - 105, 12, 134, 177, 163, 199, 143, 193, 164, 73, - 227, 38, 141, 28, 56, 112, 228, 76, 146, 20, - 41, 205, 152, 75, 99, 183, 100, 201, 50, 101, - 202, 147, 77, 79, 166, 102, 205, 250, 200, 19, - 100, 73, 114, 239, 238, 221, 123, 71, 148, 104, - 202, 163, 224, 86, 138, 124, 25, 115, 166, 205, - 72, 145, 246, 72, 221, 195, 39, 207, 30, 69, - 158, 118, 246, 220, 202, 208, 24, 184, 160, 252, - 248, 9, 29, 59, 212, 100, 75, 99, 53, 159, - 66, 93, 203, 182, 109, 84, 169, 124, 248, 156, - 57, 163, 165, 174, 150, 60, 138, 76, 113, 221, - 251, 207, 24, 183, 119, 97, 3, 135, 125, 71, - 78, 90, 76, 62, 142, 70, 141, 18, 53, 109, - 170, 227, 199, 144, 35, 75, 157, 91, 87, 137, - 229, 28, 74, 190, 228, 229, 139, 209, 43, 96, - 193, 247, 10, 203, 114, 212, 167, 82, 47, 93, - 197, 138, 81, 163, 166, 173, 19, 47, 201, 176, - 99, 59, 166, 171, 36, 135, 237, 22, 45, 114, - 216, 209, 203, 25, 98, 176, 191, 66, 195, 134, - 54, 230, 233, 150, 179, 100, 197, 106, 181, 90, - 158, 171, 57, 179, 110, 231, 124, 185, 145, 77, - 157, 186, 150, 218, 45, 76, 104, 111, 145, 71, - 86, 239, 133, 198, 200, 254, 145, 189, 199, 205, - 212, 212, 115, 244, 232, 157, 107, 86, 172, 185, - 234, 92, 197, 154, 137, 11, 231, 11, 77, 245, - 251, 178, 207, 40, 201, 254, 225, 131, 134, 39, - 138, 124, 103, 80, 73, 68, 13, 37, 141, 39, - 144, 213, 115, 14, 60, 235, 116, 211, 12, 123, - 197, 136, 67, 141, 106, 226, 156, 51, 78, 16, - 92, 208, 194, 7, 126, 28, 70, 166, 159, 9, - 26, 132, 104, 130, 29, 2, 254, 67, 32, 81, - 224, 200, 18, 91, 56, 240, 208, 35, 78, 51, - 238, 49, 40, 223, 58, 240, 88, 99, 132, 31, - 207, 168, 131, 14, 55, 206, 56, 115, 203, 41, - 167, 172, 229, 73, 36, 158, 196, 133, 216, 83, - 29, 58, 166, 69, 11, 26, 88, 96, 129, 6, - 95, 112, 230, 213, 81, 210, 188, 21, 27, 59, - 208, 208, 179, 14, 123, 205, 81, 227, 96, 55, - 235, 208, 227, 14, 23, 126, 244, 162, 204, 49, - 200, 64, 3, 13, 51, 194, 232, 162, 139, 50, - 105, 106, 131, 13, 54, 225, 132, 227, 205, 157, - 207, 96, 243, 204, 48, 195, 244, 72, 28, 126, - 103, 48, 233, 164, 6, 36, 246, 20, 210, 81, - 198, 224, 87, 143, 48, 12, 78, 8, 75, 43, - 242, 21, 3, 38, 60, 227, 116, 224, 2, 22, - 135, 32, 162, 41, 33, 112, 208, 129, 72, 35, - 135, 8, 242, 72, 40, 163, 150, 82, 202, 42, - 186, 172, 178, 203, 46, 169, 170, 154, 76, 50, - 254, 123, 158, 194, 97, 14, 22, 60, 240, 192, - 7, 188, 117, 228, 23, 74, 198, 88, 41, 219, - 56, 189, 36, 19, 203, 57, 235, 80, 147, 11, - 44, 176, 20, 211, 96, 51, 240, 192, 195, 14, - 5, 36, 88, 129, 8, 33, 116, 200, 81, 198, - 181, 101, 208, 1, 199, 27, 220, 110, 59, 69, - 22, 130, 20, 82, 200, 35, 165, 76, 34, 110, - 33, 147, 64, 162, 174, 42, 192, 200, 122, 223, - 25, 38, 216, 186, 192, 19, 24, 133, 52, 82, - 149, 247, 161, 179, 203, 35, 136, 8, 243, 72, - 57, 244, 80, 179, 220, 39, 185, 192, 163, 77, - 55, 244, 236, 227, 14, 5, 17, 0, 65, 7, - 25, 101, 120, 81, 197, 196, 216, 82, 97, 49, - 21, 81, 68, 145, 69, 22, 105, 116, 236, 113, - 26, 161, 148, 59, 136, 24, 98, 64, 210, 203, - 40, 28, 106, 161, 193, 2, 11, 88, 144, 171, - 68, 246, 74, 163, 226, 125, 207, 156, 105, 8, - 25, 212, 54, 218, 202, 39, 4, 227, 115, 142, - 54, 233, 177, 211, 65, 4, 51, 84, 113, 109, - 21, 77, 52, 1, 69, 23, 19, 15, 1, 197, - 16, 84, 12, 17, 197, 182, 112, 8, 146, 198, - 20, 86, 147, 139, 204, 49, 169, 78, 50, 200, - 32, 144, 56, 210, 97, 14, 15, 176, 28, 37, - 204, 198, 180, 228, 107, 108, 158, 60, 19, 202, - 43, 159, 200, 225, 133, 28, 175, 224, 3, 15, - 50, 176, 80, 2, 75, 254, 51, 94, 34, 140, - 143, 208, 68, 119, 129, 45, 210, 93, 48, 13, - 197, 210, 60, 240, 0, 133, 15, 111, 104, 138, - 8, 28, 27, 79, 1, 199, 35, 163, 234, 18, - 139, 155, 233, 206, 177, 97, 202, 22, 28, 112, - 128, 14, 17, 5, 227, 210, 204, 213, 69, 178, - 11, 40, 160, 16, 194, 8, 33, 134, 52, 17, - 142, 122, 197, 236, 156, 11, 51, 185, 52, 3, - 244, 62, 128, 207, 16, 49, 182, 93, 36, 125, - 120, 23, 135, 67, 193, 131, 15, 112, 148, 147, - 143, 58, 216, 8, 3, 249, 198, 89, 192, 1, - 199, 33, 143, 196, 18, 203, 42, 144, 104, 222, - 33, 31, 26, 120, 62, 194, 67, 162, 255, 121, - 159, 35, 149, 104, 58, 135, 21, 100, 64, 92, - 69, 139, 198, 238, 156, 236, 222, 226, 208, 131, - 207, 56, 13, 56, 80, 116, 19, 215, 54, 81, - 197, 24, 73, 23, 126, 248, 16, 62, 248, 144, - 133, 62, 110, 112, 194, 50, 202, 113, 8, 231, - 101, 193, 7, 64, 152, 220, 184, 30, 129, 42, - 93, 168, 66, 108, 29, 50, 129, 231, 52, 208, - 16, 89, 220, 162, 87, 248, 137, 68, 29, 178, - 160, 6, 53, 188, 225, 5, 85, 176, 86, 21, - 232, 1, 15, 113, 228, 98, 57, 173, 104, 143, - 151, 224, 241, 190, 248, 249, 160, 126, 114, 136, - 161, 181, 202, 16, 53, 167, 13, 97, 120, 105, - 184, 7, 7, 12, 224, 4, 111, 192, 65, 114, - 254, 144, 3, 66, 26, 14, 145, 6, 43, 88, - 1, 11, 107, 128, 196, 42, 86, 1, 65, 14, - 181, 224, 0, 1, 160, 160, 66, 100, 114, 139, - 181, 197, 230, 22, 117, 152, 194, 20, 162, 160, - 134, 42, 144, 64, 10, 248, 163, 67, 122, 214, - 17, 187, 79, 232, 45, 23, 226, 16, 7, 62, - 240, 97, 13, 5, 16, 109, 12, 215, 98, 4, - 207, 64, 193, 51, 77, 53, 66, 83, 84, 240, - 65, 26, 218, 113, 1, 3, 180, 1, 27, 144, - 19, 196, 183, 128, 128, 196, 66, 132, 98, 13, - 63, 72, 228, 15, 176, 32, 134, 68, 52, 241, - 62, 45, 8, 64, 0, 106, 144, 144, 89, 152, - 66, 22, 8, 186, 207, 40, 214, 32, 8, 107, - 216, 194, 5, 67, 144, 218, 15, 134, 208, 5, - 68, 184, 15, 30, 205, 120, 148, 25, 97, 1, - 157, 125, 208, 227, 25, 3, 136, 64, 12, 232, - 215, 136, 121, 200, 35, 31, 249, 168, 71, 61, - 242, 33, 143, 118, 108, 67, 30, 208, 128, 195, - 32, 218, 49, 1, 1, 180, 1, 121, 199, 120, - 197, 35, 136, 184, 134, 102, 146, 11, 137, 88, - 80, 228, 37, 104, 145, 36, 13, 72, 178, 80, - 5, 153, 5, 78, 50, 73, 157, 72, 92, 98, - 13, 135, 208, 135, 63, 252, 129, 132, 40, 116, - 193, 105, 192, 11, 5, 62, 92, 217, 140, 157, - 49, 162, 21, 104, 60, 199, 62, 224, 225, 10, - 2, 68, 128, 10, 114, 254, 32, 196, 49, 178, - 113, 129, 11, 112, 224, 159, 37, 224, 192, 6, - 46, 176, 129, 108, 148, 99, 21, 213, 40, 230, - 1, 78, 128, 3, 55, 240, 34, 29, 216, 8, - 197, 36, 122, 81, 10, 114, 61, 2, 93, 107, - 136, 230, 28, 230, 96, 13, 43, 202, 230, 1, - 1, 56, 128, 119, 10, 146, 150, 251, 240, 65, - 21, 88, 200, 194, 60, 198, 233, 143, 84, 164, - 193, 104, 72, 43, 195, 49, 214, 8, 143, 216, - 49, 226, 157, 197, 208, 70, 251, 216, 193, 5, - 2, 100, 160, 10, 129, 64, 4, 54, 54, 81, - 2, 24, 148, 128, 6, 48, 160, 193, 81, 3, - 202, 0, 115, 120, 99, 19, 19, 40, 128, 1, - 74, 208, 79, 6, 20, 32, 12, 222, 8, 133, - 45, 136, 241, 141, 103, 232, 194, 84, 143, 72, - 195, 15, 196, 112, 9, 87, 248, 226, 22, 28, - 58, 3, 20, 183, 71, 144, 89, 16, 201, 163, - 145, 185, 68, 74, 7, 145, 130, 106, 140, 83, - 15, 136, 40, 131, 181, 154, 48, 6, 111, 140, - 145, 61, 173, 72, 214, 131, 210, 83, 41, 2, - 160, 128, 12, 140, 104, 68, 57, 220, 80, 212, - 106, 224, 50, 151, 250, 248, 69, 9, 24, 208, - 6, 126, 28, 225, 2, 1, 32, 70, 53, 126, - 193, 88, 1, 0, 96, 17, 165, 96, 2, 65, - 113, 16, 6, 76, 96, 98, 27, 202, 16, 43, - 89, 51, 193, 10, 82, 108, 174, 58, 38, 144, - 254, 228, 203, 134, 4, 87, 200, 220, 1, 11, - 64, 160, 66, 16, 12, 80, 128, 118, 216, 195, - 5, 141, 40, 31, 182, 216, 145, 30, 23, 181, - 135, 149, 212, 8, 19, 60, 188, 145, 0, 4, - 100, 225, 19, 59, 155, 7, 13, 78, 80, 130, - 109, 60, 67, 24, 141, 128, 67, 33, 204, 81, - 130, 2, 84, 224, 30, 37, 152, 128, 4, 242, - 113, 167, 121, 216, 162, 152, 39, 120, 6, 8, - 4, 192, 128, 13, 112, 160, 159, 6, 192, 68, - 41, 122, 240, 131, 65, 0, 2, 16, 115, 48, - 171, 51, 238, 3, 69, 41, 254, 195, 173, 181, - 125, 12, 31, 122, 0, 132, 25, 248, 192, 3, - 211, 56, 0, 13, 54, 145, 5, 50, 236, 149, - 126, 236, 104, 17, 60, 186, 113, 44, 73, 73, - 120, 29, 174, 136, 37, 28, 102, 215, 10, 121, - 208, 192, 13, 71, 72, 135, 50, 38, 22, 133, - 66, 164, 163, 187, 12, 216, 6, 7, 24, 112, - 132, 114, 192, 33, 13, 144, 248, 69, 1, 0, - 112, 2, 98, 126, 54, 30, 211, 32, 6, 26, - 120, 11, 12, 32, 244, 64, 12, 115, 240, 195, - 18, 174, 0, 8, 87, 144, 226, 20, 164, 147, - 76, 36, 3, 48, 82, 243, 4, 120, 42, 3, - 182, 193, 10, 86, 48, 3, 18, 20, 32, 0, - 2, 32, 129, 26, 200, 80, 133, 194, 53, 129, - 12, 236, 160, 17, 60, 210, 7, 11, 113, 172, - 227, 204, 225, 144, 129, 254, 97, 65, 33, 12, - 129, 165, 131, 3, 55, 112, 131, 45, 142, 81, - 5, 42, 188, 225, 17, 237, 88, 241, 2, 36, - 107, 128, 69, 196, 66, 13, 130, 120, 6, 26, - 60, 187, 136, 106, 120, 22, 23, 186, 224, 90, - 60, 12, 0, 0, 78, 76, 161, 7, 88, 152, - 67, 16, 92, 176, 4, 34, 92, 97, 11, 91, - 200, 132, 53, 204, 35, 153, 51, 72, 146, 94, - 255, 120, 242, 84, 60, 177, 4, 41, 171, 64, - 5, 59, 0, 2, 5, 18, 128, 1, 56, 220, - 236, 90, 189, 83, 3, 59, 206, 97, 230, 102, - 64, 55, 23, 201, 61, 179, 55, 26, 128, 128, - 52, 188, 162, 24, 204, 128, 196, 52, 56, 0, - 131, 77, 88, 67, 24, 132, 64, 196, 33, 212, - 241, 139, 11, 20, 224, 8, 104, 184, 128, 0, - 170, 129, 8, 53, 100, 193, 25, 16, 0, 0, - 0, 182, 49, 104, 6, 36, 67, 153, 143, 184, - 68, 2, 0, 192, 133, 52, 160, 0, 11, 87, - 120, 129, 11, 88, 192, 110, 18, 144, 128, 8, - 153, 118, 70, 162, 34, 99, 129, 40, 10, 196, - 164, 128, 232, 193, 10, 98, 16, 131, 29, 248, - 27, 8, 133, 224, 32, 33, 132, 123, 173, 70, - 172, 35, 141, 235, 64, 6, 116, 97, 65, 172, - 51, 103, 98, 0, 25, 120, 133, 48, 218, 163, - 138, 84, 252, 51, 27, 232, 160, 6, 51, 160, - 193, 142, 108, 28, 97, 2, 12, 176, 7, 18, - 254, 250, 136, 142, 14, 102, 161, 19, 140, 102, - 64, 59, 178, 189, 1, 109, 188, 34, 20, 133, - 240, 131, 103, 57, 113, 136, 31, 44, 97, 14, - 91, 32, 1, 187, 89, 224, 110, 23, 144, 160, - 8, 96, 240, 3, 46, 146, 44, 149, 15, 4, - 96, 1, 247, 174, 206, 41, 176, 96, 131, 29, - 240, 32, 6, 42, 224, 247, 14, 124, 16, 5, - 58, 88, 221, 193, 85, 240, 2, 51, 194, 113, - 142, 110, 72, 40, 23, 202, 233, 70, 179, 202, - 209, 1, 2, 212, 129, 25, 108, 202, 133, 55, - 208, 192, 129, 18, 152, 227, 30, 230, 216, 6, - 49, 156, 64, 108, 8, 164, 226, 30, 48, 152, - 192, 6, 158, 65, 7, 53, 88, 1, 9, 158, - 61, 194, 52, 102, 76, 12, 109, 8, 35, 22, - 144, 232, 196, 161, 225, 32, 134, 43, 92, 161, - 8, 47, 120, 1, 17, 212, 237, 110, 12, 252, - 28, 211, 156, 128, 140, 18, 36, 41, 144, 215, - 194, 198, 19, 115, 0, 194, 10, 84, 192, 131, - 33, 240, 187, 223, 62, 160, 66, 178, 7, 14, - 49, 50, 208, 233, 96, 231, 152, 16, 123, 230, - 83, 142, 12, 59, 32, 22, 26, 103, 70, 43, - 230, 1, 130, 182, 95, 128, 6, 19, 184, 64, - 240, 139, 234, 134, 120, 84, 99, 197, 109, 240, - 134, 26, 232, 80, 7, 11, 104, 123, 27, 72, - 0, 192, 6, 228, 49, 14, 61, 165, 131, 6, - 0, 144, 0, 43, 4, 254, 49, 136, 43, 16, - 33, 8, 30, 136, 60, 188, 225, 237, 238, 23, - 20, 97, 11, 153, 127, 204, 230, 3, 240, 223, - 234, 140, 2, 11, 83, 142, 58, 15, 202, 80, - 133, 167, 199, 96, 8, 141, 128, 155, 33, 62, - 65, 6, 67, 112, 29, 26, 21, 114, 14, 204, - 144, 83, 212, 112, 14, 222, 80, 118, 98, 128, - 12, 180, 35, 12, 185, 32, 15, 16, 0, 103, - 71, 0, 98, 71, 0, 3, 48, 224, 6, 219, - 48, 15, 143, 32, 9, 28, 48, 1, 188, 80, - 14, 84, 160, 6, 137, 192, 104, 23, 144, 14, - 217, 38, 1, 188, 112, 130, 188, 0, 3, 152, - 149, 10, 230, 50, 8, 150, 22, 4, 50, 0, - 6, 91, 64, 4, 46, 224, 2, 145, 7, 126, - 65, 16, 4, 91, 128, 11, 234, 199, 121, 255, - 16, 23, 178, 81, 7, 82, 32, 2, 168, 22, - 3, 62, 48, 4, 100, 160, 6, 79, 23, 5, - 135, 240, 10, 173, 48, 45, 251, 7, 13, 231, - 160, 38, 102, 118, 14, 117, 82, 39, 126, 0, - 113, 186, 128, 12, 12, 88, 11, 185, 176, 13, - 19, 112, 3, 37, 192, 15, 185, 84, 15, 243, - 16, 15, 234, 112, 12, 136, 80, 10, 237, 64, - 12, 196, 112, 15, 215, 64, 5, 112, 128, 11, - 22, 208, 103, 182, 32, 1, 0, 192, 0, 239, - 5, 80, 23, 208, 6, 207, 80, 8, 96, 3, - 111, 70, 128, 6, 118, 192, 4, 96, 0, 121, - 254, 36, 240, 2, 96, 176, 33, 150, 192, 5, - 92, 224, 43, 235, 39, 16, 103, 224, 121, 144, - 49, 10, 63, 48, 3, 163, 23, 3, 195, 243, - 129, 101, 160, 6, 169, 247, 10, 200, 0, 10, - 204, 209, 10, 194, 16, 14, 201, 195, 34, 7, - 151, 12, 225, 0, 12, 10, 224, 0, 147, 160, - 13, 180, 227, 133, 208, 240, 11, 196, 230, 6, - 253, 112, 12, 159, 208, 119, 86, 103, 8, 214, - 246, 10, 209, 80, 14, 209, 0, 10, 67, 0, - 7, 227, 16, 15, 247, 192, 15, 72, 192, 91, - 246, 176, 13, 169, 176, 8, 110, 144, 10, 214, - 5, 61, 35, 227, 2, 91, 32, 3, 86, 33, - 21, 92, 0, 6, 47, 224, 1, 50, 32, 10, - 176, 17, 137, 63, 72, 137, 142, 113, 10, 98, - 208, 116, 81, 199, 111, 60, 64, 5, 143, 83, - 6, 67, 160, 6, 177, 16, 14, 208, 160, 13, - 106, 194, 12, 200, 160, 12, 218, 112, 12, 82, - 152, 12, 187, 160, 10, 151, 64, 1, 8, 240, - 3, 10, 184, 51, 148, 208, 10, 139, 85, 2, - 37, 176, 9, 253, 32, 12, 134, 80, 6, 251, - 83, 62, 84, 144, 45, 141, 64, 8, 84, 192, - 3, 158, 8, 4, 86, 64, 10, 28, 32, 0, - 56, 224, 13, 194, 176, 11, 222, 80, 14, 202, - 16, 10, 135, 32, 46, 141, 7, 111, 45, 224, - 24, 145, 144, 9, 91, 0, 6, 70, 0, 6, - 112, 101, 116, 72, 247, 254, 15, 123, 112, 6, - 176, 65, 11, 63, 176, 111, 59, 208, 111, 154, - 216, 142, 135, 0, 10, 136, 16, 10, 194, 160, - 13, 201, 160, 13, 117, 34, 14, 208, 128, 12, - 186, 208, 11, 187, 112, 9, 128, 224, 1, 20, - 64, 0, 8, 96, 3, 203, 1, 11, 159, 112, - 83, 175, 80, 15, 52, 208, 118, 196, 144, 15, - 185, 32, 66, 67, 80, 5, 100, 64, 7, 81, - 83, 56, 85, 48, 3, 20, 233, 3, 54, 208, - 3, 157, 192, 0, 0, 64, 12, 208, 0, 10, - 63, 4, 7, 202, 54, 146, 133, 48, 7, 151, - 64, 4, 96, 112, 146, 144, 225, 7, 96, 192, - 5, 226, 40, 21, 245, 38, 69, 158, 48, 23, - 145, 97, 10, 115, 96, 3, 34, 48, 122, 231, - 88, 122, 112, 160, 6, 165, 16, 11, 161, 112, - 12, 202, 112, 9, 151, 16, 14, 226, 32, 143, - 244, 40, 6, 24, 224, 0, 8, 128, 0, 17, - 128, 2, 135, 128, 66, 173, 64, 9, 140, 64, - 9, 185, 208, 15, 196, 144, 10, 191, 192, 15, - 236, 0, 10, 114, 96, 56, 93, 32, 7, 73, - 120, 67, 80, 64, 5, 59, 128, 132, 84, 0, - 4, 107, 48, 104, 5, 240, 13, 194, 0, 10, - 111, 0, 4, 64, 32, 57, 105, 128, 46, 171, - 48, 7, 223, 39, 4, 145, 1, 132, 157, 246, - 105, 2, 49, 11, 115, 33, 142, 167, 240, 3, - 54, 224, 3, 153, 152, 56, 80, 243, 6, 112, - 254, 0, 138, 177, 32, 12, 208, 160, 10, 106, - 130, 13, 0, 24, 14, 197, 128, 148, 107, 208, - 3, 86, 32, 138, 202, 193, 51, 85, 121, 83, - 173, 112, 14, 229, 192, 14, 234, 80, 14, 173, - 160, 87, 101, 0, 60, 33, 148, 132, 112, 32, - 60, 60, 48, 3, 184, 233, 3, 170, 224, 75, - 237, 128, 13, 79, 72, 5, 84, 246, 45, 83, - 0, 136, 221, 71, 4, 50, 64, 147, 29, 178, - 100, 35, 37, 147, 132, 249, 24, 137, 128, 152, - 43, 224, 111, 57, 121, 132, 92, 4, 7, 161, - 160, 12, 111, 162, 11, 115, 32, 153, 199, 176, - 117, 63, 83, 158, 244, 8, 10, 148, 48, 144, - 237, 25, 8, 44, 26, 8, 114, 16, 8, 169, - 193, 8, 11, 41, 56, 133, 195, 3, 244, 99, - 117, 84, 80, 5, 80, 192, 111, 244, 195, 63, - 64, 16, 10, 186, 32, 12, 5, 234, 3, 49, - 48, 3, 195, 153, 6, 88, 48, 50, 240, 246, - 1, 73, 178, 7, 253, 213, 86, 90, 224, 160, - 142, 33, 6, 33, 48, 101, 254, 118, 67, 169, - 39, 8, 175, 208, 132, 210, 179, 11, 189, 176, - 5, 202, 160, 12, 107, 194, 117, 83, 216, 10, - 180, 83, 149, 44, 234, 5, 99, 224, 5, 127, - 224, 5, 110, 58, 6, 178, 89, 6, 74, 51, - 49, 80, 192, 144, 246, 83, 6, 159, 210, 119, - 166, 55, 75, 12, 57, 3, 213, 201, 132, 160, - 160, 6, 81, 48, 4, 254, 51, 48, 3, 89, - 96, 68, 73, 234, 125, 65, 96, 2, 73, 18, - 91, 1, 240, 50, 255, 160, 8, 81, 234, 24, - 142, 176, 4, 33, 32, 2, 137, 57, 3, 84, - 0, 5, 29, 84, 53, 64, 154, 42, 170, 144, - 9, 92, 112, 9, 165, 16, 143, 196, 98, 133, - 12, 184, 51, 104, 170, 166, 99, 176, 166, 115, - 227, 162, 173, 154, 52, 247, 217, 101, 89, 87, - 6, 132, 208, 8, 62, 89, 5, 67, 144, 147, - 19, 195, 3, 43, 96, 3, 81, 240, 10, 141, - 160, 6, 95, 217, 159, 126, 106, 3, 71, 36, - 6, 68, 80, 4, 50, 144, 36, 106, 21, 0, - 108, 5, 165, 147, 42, 21, 166, 96, 169, 83, - 214, 111, 137, 83, 5, 206, 3, 10, 161, 48, - 61, 170, 224, 7, 32, 0, 1, 50, 0, 9, - 186, 64, 39, 86, 104, 120, 202, 161, 170, 140, - 224, 166, 106, 250, 7, 109, 234, 166, 49, 228, - 5, 134, 224, 5, 73, 67, 63, 114, 80, 5, - 183, 154, 58, 55, 164, 2, 177, 73, 6, 80, - 96, 164, 108, 214, 10, 92, 198, 63, 51, 16, - 2, 6, 75, 95, 138, 42, 165, 248, 1, 82, - 34, 117, 16, 166, 80, 23, 155, 115, 11, 87, - 96, 161, 51, 192, 111, 156, 170, 108, 160, 32, - 61, 171, 192, 10, 32, 16, 124, 48, 208, 9, - 189, 128, 148, 208, 16, 14, 176, 72, 59, 55, - 69, 154, 129, 192, 166, 127, 176, 166, 114, 163, - 254, 166, 94, 0, 49, 77, 192, 3, 73, 208, - 4, 115, 67, 6, 160, 128, 171, 132, 160, 6, - 60, 10, 49, 60, 96, 3, 112, 112, 179, 100, - 16, 8, 236, 8, 4, 54, 96, 176, 33, 128, - 2, 40, 192, 2, 68, 160, 4, 213, 116, 77, - 9, 33, 169, 90, 48, 21, 115, 160, 111, 153, - 184, 3, 114, 136, 58, 135, 208, 173, 171, 224, - 10, 253, 132, 6, 81, 113, 10, 172, 240, 38, - 216, 160, 13, 242, 40, 164, 104, 250, 7, 129, - 224, 174, 129, 192, 8, 114, 208, 166, 134, 128, - 63, 17, 147, 56, 77, 32, 155, 132, 32, 138, - 136, 80, 5, 58, 11, 5, 47, 219, 5, 253, - 9, 7, 46, 74, 8, 236, 232, 3, 244, 133, - 2, 71, 139, 180, 44, 16, 4, 73, 178, 100, - 148, 164, 16, 121, 80, 23, 82, 225, 10, 55, - 153, 137, 70, 168, 6, 136, 32, 8, 47, 86, - 8, 165, 160, 9, 19, 96, 6, 142, 193, 7, - 163, 176, 11, 202, 192, 117, 242, 232, 78, 108, - 235, 174, 238, 58, 6, 104, 203, 170, 73, 227, - 5, 73, 48, 179, 65, 139, 171, 175, 80, 109, - 84, 80, 52, 178, 217, 4, 187, 58, 4, 217, - 82, 5, 83, 99, 5, 61, 128, 180, 190, 203, - 2, 46, 192, 180, 78, 36, 73, 254, 197, 184, - 117, 145, 7, 180, 192, 116, 138, 201, 111, 133, - 74, 117, 89, 112, 8, 186, 160, 9, 23, 16, - 25, 159, 171, 83, 240, 254, 120, 66, 104, 58, - 6, 129, 176, 166, 174, 10, 167, 100, 80, 175, - 245, 138, 51, 160, 144, 11, 112, 153, 71, 47, - 84, 62, 49, 91, 122, 116, 0, 60, 81, 0, - 4, 152, 122, 180, 75, 144, 1, 25, 112, 184, - 17, 68, 188, 15, 209, 184, 90, 80, 173, 54, - 80, 168, 167, 39, 60, 22, 243, 6, 208, 43, - 189, 146, 49, 10, 218, 112, 174, 19, 119, 44, - 60, 67, 186, 45, 234, 162, 114, 80, 175, 93, - 86, 6, 159, 0, 10, 177, 11, 7, 81, 112, - 132, 47, 75, 175, 78, 99, 52, 60, 160, 2, - 86, 90, 168, 54, 176, 4, 46, 144, 1, 87, - 112, 141, 213, 113, 6, 245, 102, 111, 16, 33, - 169, 138, 48, 177, 152, 184, 147, 19, 153, 122, - 28, 154, 12, 156, 48, 189, 146, 241, 12, 87, - 8, 13, 26, 215, 30, 237, 89, 11, 200, 128, - 12, 178, 3, 93, 235, 234, 5, 101, 144, 132, - 208, 149, 41, 21, 252, 144, 220, 27, 60, 117, - 250, 116, 161, 228, 163, 132, 116, 5, 46, 144, - 8, 248, 161, 4, 11, 32, 73, 139, 27, 17, - 166, 240, 5, 144, 208, 3, 251, 187, 111, 165, - 39, 135, 136, 240, 10, 146, 41, 192, 146, 113, - 10, 231, 96, 133, 212, 32, 12, 112, 195, 162, - 104, 27, 8, 173, 0, 55, 183, 214, 10, 55, - 85, 149, 79, 200, 173, 144, 99, 96, 170, 35, - 92, 192, 51, 4, 116, 64, 127, 161, 244, 129, - 254, 83, 80, 156, 147, 16, 100, 222, 8, 91, - 80, 116, 0, 103, 51, 17, 193, 192, 10, 145, - 123, 161, 6, 118, 181, 175, 240, 38, 153, 64, - 195, 53, 76, 178, 218, 128, 12, 185, 80, 149, - 109, 251, 7, 132, 32, 7, 134, 240, 7, 49, - 180, 182, 107, 11, 187, 91, 122, 8, 82, 96, - 3, 89, 128, 8, 173, 208, 8, 154, 92, 6, - 141, 208, 8, 129, 96, 8, 3, 103, 117, 207, - 35, 81, 27, 203, 131, 212, 161, 4, 32, 21, - 0, 18, 0, 169, 18, 49, 14, 107, 128, 137, - 251, 150, 122, 87, 43, 12, 245, 8, 12, 27, - 240, 151, 82, 241, 12, 218, 64, 13, 56, 44, - 12, 181, 192, 8, 105, 123, 83, 210, 44, 55, - 160, 204, 162, 148, 64, 48, 185, 16, 10, 161, - 80, 68, 105, 48, 190, 114, 76, 205, 55, 149, - 79, 172, 71, 45, 112, 208, 8, 163, 178, 10, - 201, 128, 203, 176, 161, 5, 39, 60, 73, 30, - 49, 8, 82, 230, 197, 95, 169, 202, 109, 162, - 12, 192, 64, 3, 150, 0, 27, 201, 35, 12, - 108, 34, 12, 210, 220, 162, 55, 229, 162, 110, - 26, 203, 238, 249, 198, 177, 160, 12, 144, 48, - 8, 177, 112, 12, 194, 0, 148, 205, 1, 55, - 210, 44, 205, 229, 67, 7, 201, 6, 42, 12, - 148, 12, 190, 0, 27, 124, 240, 1, 80, 20, - 0, 46, 243, 17, 170, 96, 5, 133, 122, 155, - 31, 168, 202, 14, 141, 254, 12, 189, 128, 4, - 146, 32, 25, 124, 160, 13, 171, 44, 144, 45, - 106, 8, 134, 240, 162, 11, 188, 182, 208, 149, - 66, 229, 169, 13, 151, 160, 10, 247, 88, 10, - 68, 89, 182, 85, 233, 96, 194, 101, 209, 81, - 160, 108, 151, 211, 11, 192, 240, 24, 168, 192, - 7, 42, 243, 209, 11, 144, 200, 30, 145, 12, - 105, 80, 168, 205, 171, 6, 231, 252, 10, 151, - 179, 11, 156, 112, 4, 252, 188, 198, 100, 112, - 205, 46, 26, 208, 114, 243, 162, 238, 233, 133, - 104, 87, 143, 47, 192, 10, 202, 80, 10, 200, - 64, 148, 225, 160, 198, 104, 26, 8, 179, 137, - 183, 114, 120, 8, 166, 162, 212, 190, 66, 43, - 158, 115, 0, 243, 194, 21, 127, 232, 167, 51, - 224, 111, 84, 87, 203, 165, 176, 11, 154, 0, - 3, 220, 244, 24, 189, 16, 206, 14, 214, 182, - 11, 108, 8, 105, 107, 211, 239, 36, 12, 150, - 29, 39, 30, 176, 5, 172, 208, 11, 14, 205, - 12, 218, 80, 11, 235, 73, 9, 44, 42, 155, - 134, 128, 49, 181, 60, 9, 170, 48, 10, 230, - 161, 5, 31, 240, 0, 125, 253, 0, 160, 182, - 23, 147, 64, 180, 23, 58, 117, 84, 23, 5, - 130, 112, 42, 174, 0, 3, 150, 240, 151, 171, - 144, 58, 1, 205, 174, 114, 80, 205, 160, 108, - 214, 3, 25, 209, 185, 160, 13, 202, 208, 0, - 3, 224, 1, 151, 32, 166, 152, 57, 48, 134, - 254, 112, 83, 16, 115, 45, 114, 184, 6, 125, - 112, 7, 123, 160, 5, 241, 178, 0, 125, 61, - 2, 216, 196, 23, 144, 80, 96, 21, 91, 177, - 253, 19, 5, 83, 112, 216, 192, 80, 2, 95, - 96, 23, 82, 234, 9, 165, 128, 8, 65, 27, - 180, 110, 74, 8, 163, 221, 182, 54, 157, 205, - 181, 192, 128, 185, 240, 10, 208, 160, 11, 13, - 160, 0, 24, 0, 6, 208, 32, 158, 208, 208, - 30, 234, 42, 223, 85, 144, 5, 216, 45, 23, - 57, 208, 218, 44, 227, 221, 22, 240, 4, 90, - 241, 29, 170, 64, 157, 215, 170, 147, 196, 147, - 208, 201, 128, 4, 102, 96, 25, 32, 94, 23, - 147, 120, 7, 125, 176, 6, 113, 160, 6, 214, - 60, 55, 106, 122, 223, 114, 4, 79, 39, 148, - 11, 255, 77, 1, 20, 112, 5, 170, 48, 182, - 205, 12, 205, 159, 64, 57, 120, 144, 221, 219, - 157, 3, 38, 80, 43, 101, 195, 50, 19, 238, - 203, 189, 1, 185, 243, 188, 188, 62, 48, 5, - 202, 128, 13, 201, 192, 6, 110, 224, 86, 121, - 0, 226, 82, 174, 4, 34, 126, 6, 36, 222, - 7, 120, 96, 226, 220, 226, 56, 17, 44, 154, - 151, 227, 148, 118, 201, 10, 124, 50, 10, 142, - 176, 33, 215, 225, 227, 77, 2, 228, 182, 242, - 0, 53, 240, 5, 68, 94, 34, 229, 120, 169, - 137, 169, 2, 6, 150, 5, 229, 186, 206, 48, - 64, 16, 166, 160, 8, 192, 81, 62, 229, 32, - 142, 25, 84, 238, 222, 115, 49, 232, 132, 110, - 23, 215, 113, 25, 218, 17, 34, 78, 178, 232, - 181, 98, 1, 109, 30, 32, 37, 162, 16, 151, - 64, 184, 152, 26, 127, 73, 94, 10, 73, 9, - 12, 56, 128, 16, 218, 148, 7, 121, 240, 5, - 182, 17, 234, 162, 158, 3, 184, 129, 27, 218, - 113, 234, 218, 209, 31, 253, 17, 34, 172, 206, - 232, 38, 160, 3, 0, 82, 225, 145, 206, 16, - 148, 142, 169, 116, 126, 164, 186, 144, 12, 187, - 237, 16, 150, 20, 9, 118, 96, 7, 95, 240, - 5, 216, 145, 29, 168, 158, 234, 170, 174, 1, - 31, 160, 3, 184, 17, 236, 120, 33, 235, 179, - 254, 16, 144, 75, 184, 136, 153, 106, 22, 185, - 6, 147, 192, 10, 174, 176, 1, 60, 65, 19, - 145, 240, 230, 207, 222, 17, 128, 64, 184, 33, - 96, 164, 86, 144, 6, 225, 226, 165, 154, 32, - 1, 223, 190, 238, 21, 225, 10, 75, 128, 2, - 54, 240, 3, 66, 148, 6, 228, 178, 11, 192, - 192, 4, 236, 158, 239, 2, 17, 16, 0, 59}; - diff --git a/main/main.c b/main/main.c index be289c8060839..325ef7ed531b3 100644 --- a/main/main.c +++ b/main/main.c @@ -86,7 +86,6 @@ #include "php_content_types.h" #include "php_ticks.h" -#include "php_logos.h" #include "php_streams.h" #include "php_open_temporary_file.h" @@ -522,6 +521,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("default_mimetype", SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateString, default_mimetype, sapi_globals_struct,sapi_globals) STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateErrorLog, error_log, php_core_globals, core_globals) STD_PHP_INI_ENTRY("extension_dir", PHP_EXTENSION_DIR, PHP_INI_SYSTEM, OnUpdateStringUnempty, extension_dir, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("sys_temp_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, sys_temp_dir, php_core_globals, core_globals) STD_PHP_INI_ENTRY("include_path", PHP_INCLUDE_PATH, PHP_INI_ALL, OnUpdateStringUnempty, include_path, php_core_globals, core_globals) PHP_INI_ENTRY("max_execution_time", "30", PHP_INI_ALL, OnUpdateTimeout) STD_PHP_INI_ENTRY("open_basedir", NULL, PHP_INI_ALL, OnUpdateBaseDir, open_basedir, php_core_globals, core_globals) @@ -552,7 +552,7 @@ PHP_INI_BEGIN() PHP_INI_ENTRY("mail.force_extra_parameters",NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnChangeMailForceExtra) PHP_INI_ENTRY("disable_functions", "", PHP_INI_SYSTEM, NULL) PHP_INI_ENTRY("disable_classes", "", PHP_INI_SYSTEM, NULL) - PHP_INI_ENTRY("max_file_uploads", "20", PHP_INI_SYSTEM|PHP_INI_PERDIR, NULL) + PHP_INI_ENTRY("max_file_uploads", "20", PHP_INI_SYSTEM|PHP_INI_PERDIR, NULL) STD_PHP_INI_BOOLEAN("allow_url_fopen", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_url_fopen, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("allow_url_include", "0", PHP_INI_SYSTEM, OnUpdateBool, allow_url_include, php_core_globals, core_globals) @@ -2176,14 +2176,6 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod return FAILURE; } - /* initialize registry for images to be used in phpinfo() - (this uses configuration parameters from php.ini) - */ - if (php_init_info_logos() == FAILURE) { - php_printf("PHP: Unable to initialize info phpinfo logos.\n"); - return FAILURE; - } - zuv.html_errors = 1; zuv.import_use_extension = ".php"; php_startup_auto_globals(TSRMLS_C); @@ -2367,7 +2359,6 @@ void php_module_shutdown(TSRMLS_D) /* Destroys filter & transport registries too */ php_shutdown_stream_wrappers(module_number TSRMLS_CC); - php_shutdown_info_logos(); UNREGISTER_INI_ENTRIES(); /* close down the ini config */ @@ -2415,10 +2406,6 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC) int retval = 0; EG(exit_status) = 0; - if (php_handle_special_queries(TSRMLS_C)) { - zend_file_handle_dtor(primary_file TSRMLS_CC); - return 0; - } #ifndef HAVE_BROKEN_GETCWD # define OLD_CWD_SIZE 4096 old_cwd = do_alloca(OLD_CWD_SIZE, use_heap); diff --git a/main/network.c b/main/network.c index ba2ee1c49836c..88e166311a8b5 100644 --- a/main/network.c +++ b/main/network.c @@ -25,7 +25,10 @@ #include + + #ifdef PHP_WIN32 +# include # include "win32/inet.h" # define O_RDONLY _O_RDONLY # include "win32/param.h" diff --git a/main/output.c b/main/output.c index 004b066b6b1bc..9324f059da8be 100644 --- a/main/output.c +++ b/main/output.c @@ -1508,7 +1508,7 @@ PHP_FUNCTION(ob_get_status) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &full_status) == FAILURE) { return; } - + array_init(return_value); if (!OG(active)) { diff --git a/main/php.h b/main/php.h index 9a7b09223069a..7c1f8fd0c7b96 100644 --- a/main/php.h +++ b/main/php.h @@ -26,7 +26,7 @@ #include #endif -#define PHP_API_VERSION 20100412 +#define PHP_API_VERSION 20121113 #define PHP_HAVE_STREAMS #define YYDEBUG 0 @@ -60,7 +60,6 @@ # else # define PHPAPI # endif - # define THREAD_LS # define PHP_DIR_SEPARATOR '/' # define PHP_EOL "\n" diff --git a/main/php_globals.h b/main/php_globals.h index 170431d079c63..256765d665a53 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -85,6 +85,7 @@ struct _php_core_globals { char *open_basedir; char *extension_dir; char *php_binary; + char *sys_temp_dir; char *upload_tmp_dir; long upload_max_filesize; diff --git a/main/php_logos.c b/main/php_logos.c deleted file mode 100644 index 5162c6c9bea3c..0000000000000 --- a/main/php_logos.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Hartmut Holzgraefe | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#include "php.h" -#include "logos.h" -#include "php_logos.h" -#include "ext/standard/info.h" -#include "SAPI.h" - -typedef struct _php_info_logo { - const char *mimetype; - int mimelen; - const unsigned char *data; - int size; -} php_info_logo; - -static HashTable phpinfo_logo_hash; - -PHPAPI int php_register_info_logo(char *logo_string, const char *mimetype, const unsigned char *data, int size) -{ - php_info_logo info_logo; - - info_logo.mimetype = mimetype; - info_logo.mimelen = strlen(mimetype); - info_logo.data = data; - info_logo.size = size; - - return zend_hash_add(&phpinfo_logo_hash, logo_string, strlen(logo_string), &info_logo, sizeof(php_info_logo), NULL); -} - -PHPAPI int php_unregister_info_logo(char *logo_string) -{ - return zend_hash_del(&phpinfo_logo_hash, logo_string, strlen(logo_string)); -} - -int php_init_info_logos(void) -{ - if(zend_hash_init(&phpinfo_logo_hash, 0, NULL, NULL, 1)==FAILURE) - return FAILURE; - - php_register_info_logo(PHP_LOGO_GUID , "image/gif", php_logo , sizeof(php_logo)); - php_register_info_logo(PHP_EGG_LOGO_GUID, "image/gif", php_egg_logo, sizeof(php_egg_logo)); - php_register_info_logo(ZEND_LOGO_GUID , "image/gif", zend_logo , sizeof(zend_logo)); - - return SUCCESS; -} - -int php_shutdown_info_logos(void) -{ - zend_hash_destroy(&phpinfo_logo_hash); - return SUCCESS; -} - -#define CONTENT_TYPE_HEADER "Content-Type: " -int php_info_logos(const char *logo_string TSRMLS_DC) -{ - php_info_logo *logo_image; - char *content_header; - int len; - - if(FAILURE==zend_hash_find(&phpinfo_logo_hash, (char *) logo_string, strlen(logo_string), (void **)&logo_image)) - return 0; - - len = sizeof(CONTENT_TYPE_HEADER) - 1 + logo_image->mimelen; - content_header = emalloc(len + 1); - memcpy(content_header, CONTENT_TYPE_HEADER, sizeof(CONTENT_TYPE_HEADER) - 1); - memcpy(content_header + sizeof(CONTENT_TYPE_HEADER) - 1 , logo_image->mimetype, logo_image->mimelen); - content_header[len] = '\0'; - sapi_add_header(content_header, len, 0); - - PHPWRITE((char*)logo_image->data, logo_image->size); - return 1; -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/main/php_network.h b/main/php_network.h index 8ffb51ca40756..c1535ee040b64 100644 --- a/main/php_network.h +++ b/main/php_network.h @@ -21,6 +21,8 @@ #ifndef _PHP_NETWORK_H #define _PHP_NETWORK_H +#include + #ifdef PHP_WIN32 # include "win32/inet.h" #else diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c index b43d6a78351c7..054d497be6d5c 100644 --- a/main/php_open_temporary_file.c +++ b/main/php_open_temporary_file.c @@ -189,13 +189,28 @@ PHPAPI void php_shutdown_temporary_directory(void) /* * Determine where to place temporary files. */ -PHPAPI const char* php_get_temporary_directory(void) +PHPAPI const char* php_get_temporary_directory(TSRMLS_D) { /* Did we determine the temporary directory already? */ if (temporary_directory) { return temporary_directory; } + /* Is there a temporary directory "sys_temp_dir" in .ini defined? */ + { + char *sys_temp_dir = PG(sys_temp_dir); + if (sys_temp_dir) { + int len = strlen(sys_temp_dir); + if (len >= 2 && sys_temp_dir[len - 1] == DEFAULT_SLASH) { + temporary_directory = zend_strndup(sys_temp_dir, len - 1); + return temporary_directory; + } else if (len >= 1 && sys_temp_dir[len - 1] != DEFAULT_SLASH) { + temporary_directory = zend_strndup(sys_temp_dir, len); + return temporary_directory; + } + } + } + #ifdef PHP_WIN32 /* We can't count on the environment variables TEMP or TMP, * and so must make the Win32 API call to get the default @@ -263,7 +278,7 @@ PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, char **ope if (!dir || *dir == '\0') { def_tmp: - temp_dir = php_get_temporary_directory(); + temp_dir = php_get_temporary_directory(TSRMLS_C); if (temp_dir && *temp_dir != '\0' && (!open_basedir_check || !php_check_open_basedir(temp_dir TSRMLS_CC))) { return php_do_open_temporary_file(temp_dir, pfx, opened_path_p TSRMLS_CC); @@ -294,12 +309,12 @@ PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, char **op if (fd == -1) { return NULL; } - + fp = fdopen(fd, "r+b"); if (fp == NULL) { close(fd); } - + return fp; } /* }}} */ diff --git a/main/php_open_temporary_file.h b/main/php_open_temporary_file.h index e7dce359bb92b..75ac0bb0fea32 100644 --- a/main/php_open_temporary_file.h +++ b/main/php_open_temporary_file.h @@ -25,7 +25,7 @@ BEGIN_EXTERN_C() PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC); PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, char **opened_path_p, zend_bool open_basedir_check TSRMLS_DC); PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC); -PHPAPI const char *php_get_temporary_directory(void); +PHPAPI const char *php_get_temporary_directory(TSRMLS_D); PHPAPI void php_shutdown_temporary_directory(void); END_EXTERN_C() diff --git a/main/php_streams.h b/main/php_streams.h index f9b94337d255d..5acf942e434bb 100644 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -162,10 +162,6 @@ struct _php_stream_wrapper { php_stream_wrapper_ops *wops; /* operations the wrapper can perform */ void *abstract; /* context for the wrapper */ int is_url; /* so that PG(allow_url_fopen) can be respected */ - - /* support for wrappers to return (multiple) error messages to the stream opener */ - int err_count; /* unused */ - char **err_stack; /* unusued */ }; #define PHP_STREAM_FLAG_NO_SEEK 1 diff --git a/main/php_variables.c b/main/php_variables.c index cf2b623d6165a..fd52f311d17df 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -27,7 +27,6 @@ #include "php_globals.h" #include "php_content_types.h" #include "SAPI.h" -#include "php_logos.h" #include "zend_globals.h" /* for systems that need to override reading of environment variables */ @@ -532,22 +531,6 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC) } /* }}} */ -/* {{{ php_handle_special_queries - */ -PHPAPI int php_handle_special_queries(TSRMLS_D) -{ - if (PG(expose_php) && SG(request_info).query_string && SG(request_info).query_string[0] == '=') { - if (php_info_logos(SG(request_info).query_string + 1 TSRMLS_CC)) { - return 1; - } else if (!strcmp(SG(request_info).query_string + 1, PHP_CREDITS_GUID)) { - php_print_credits(PHP_CREDITS_ALL TSRMLS_CC); - return 1; - } - } - return 0; -} -/* }}} */ - /* {{{ php_register_server_variables */ static inline void php_register_server_variables(TSRMLS_D) diff --git a/main/php_version.h b/main/php_version.h index 46dbbb12c8c05..d48bf13c6f7ff 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -1,8 +1,8 @@ /* automatically generated by configure */ /* edit configure.in to change version number */ #define PHP_MAJOR_VERSION 5 -#define PHP_MINOR_VERSION 4 -#define PHP_RELEASE_VERSION 13 +#define PHP_MINOR_VERSION 6 +#define PHP_RELEASE_VERSION 0 #define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "5.4.13-dev" -#define PHP_VERSION_ID 50413 +#define PHP_VERSION "5.6.0-dev" +#define PHP_VERSION_ID 50600 diff --git a/main/rfc1867.c b/main/rfc1867.c index 35a1a15956a9e..e3e6e1d1d531f 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -408,7 +408,7 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header T /* get lines of text, or CRLF_CRLF */ - while( (line = get_line(self TSRMLS_CC)) && strlen(line) > 0 ) + while( (line = get_line(self TSRMLS_CC)) && line[0] != '\0' ) { /* add header to table */ char *key = line; @@ -979,7 +979,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ continue; } - if (strlen(filename) == 0) { + if (filename[0] == '\0') { #if DEBUG_FILE_UPLOAD sapi_module.sapi_error(E_NOTICE, "No file uploaded"); #endif @@ -1063,12 +1063,12 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ if (!cancel_upload && !end) { #if DEBUG_FILE_UPLOAD - sapi_module.sapi_error(E_NOTICE, "Missing mime boundary at the end of the data for file %s", strlen(filename) > 0 ? filename : ""); + sapi_module.sapi_error(E_NOTICE, "Missing mime boundary at the end of the data for file %s", filename[0] != '\0' ? filename : ""); #endif cancel_upload = UPLOAD_ERROR_C; } #if DEBUG_FILE_UPLOAD - if (strlen(filename) > 0 && total_bytes == 0 && !cancel_upload) { + if (filename[0] != '\0' && total_bytes == 0 && !cancel_upload) { sapi_module.sapi_error(E_WARNING, "Uploaded file size 0 - file [%s=%s] not saved", param, filename); cancel_upload = 5; } diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h index 240f6e0e8dd80..59fa604306d14 100644 --- a/main/streams/php_stream_context.h +++ b/main/streams/php_stream_context.h @@ -53,7 +53,6 @@ struct _php_stream_notifier { struct _php_stream_context { php_stream_notifier *notifier; zval *options; /* hash keyed by wrapper family or specific wrapper */ - zval *links; /* hash keyed by hostent for connection pooling */ int rsrc_id; /* used for auto-cleanup */ }; @@ -65,13 +64,6 @@ PHPAPI int php_stream_context_get_option(php_stream_context *context, PHPAPI int php_stream_context_set_option(php_stream_context *context, const char *wrappername, const char *optionname, zval *optionvalue); -PHPAPI int php_stream_context_get_link(php_stream_context *context, - const char *hostent, php_stream **stream); -PHPAPI int php_stream_context_set_link(php_stream_context *context, - const char *hostent, php_stream *stream); -PHPAPI int php_stream_context_del_link(php_stream_context *context, - php_stream *stream); - PHPAPI php_stream_notifier *php_stream_notification_alloc(void); PHPAPI void php_stream_notification_free(php_stream_notifier *notifier); END_EXTERN_C() diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 4ee81506b359b..39df31a170503 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -113,7 +113,7 @@ typedef struct { unsigned is_pipe:1; /* don't try and seek */ unsigned cached_fstat:1; /* sb is valid */ unsigned _reserved:29; - + int lock_flag; /* stores the lock state */ char *temp_file_name; /* if non-null, this is the path to a temporary file that * is to be deleted when the stream is closed */ @@ -139,7 +139,7 @@ static int do_fstat(php_stdio_stream_data *d, int force) if (!d->cached_fstat || force) { int fd; int r; - + PHP_STDIOP_GET_FD(fd, d); r = fstat(fd, &d->sb); d->cached_fstat = r == 0; @@ -152,7 +152,7 @@ static int do_fstat(php_stdio_stream_data *d, int force) static php_stream *_php_stream_fopen_from_fd_int(int fd, const char *mode, const char *persistent_id STREAMS_DC TSRMLS_DC) { php_stdio_stream_data *self; - + self = pemalloc_rel_orig(sizeof(*self), persistent_id); memset(self, 0, sizeof(*self)); self->file = NULL; @@ -161,14 +161,14 @@ static php_stream *_php_stream_fopen_from_fd_int(int fd, const char *mode, const self->is_process_pipe = 0; self->temp_file_name = NULL; self->fd = fd; - + return php_stream_alloc_rel(&php_stream_stdio_ops, self, persistent_id, mode); } static php_stream *_php_stream_fopen_from_file_int(FILE *file, const char *mode STREAMS_DC TSRMLS_DC) { php_stdio_stream_data *self; - + self = emalloc_rel_orig(sizeof(*self)); memset(self, 0, sizeof(*self)); self->file = file; @@ -213,7 +213,7 @@ PHPAPI php_stream *_php_stream_fopen_tmpfile(int dummy STREAMS_DC TSRMLS_DC) self->temp_file_name = opened_path; self->lock_flag = LOCK_UN; - + return stream; } close(fd); @@ -246,7 +246,7 @@ PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const cha } } #endif - + if (self->is_pipe) { stream->flags |= PHP_STREAM_FLAG_NO_SEEK; } else { @@ -285,7 +285,7 @@ PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STRE } } #endif - + if (self->is_pipe) { stream->flags |= PHP_STREAM_FLAG_NO_SEEK; } else { @@ -354,9 +354,9 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS so script can retry if desired */ ret = read(data->fd, buf, count); } - + stream->eof = (ret == 0 || (ret == (size_t)-1 && errno != EWOULDBLOCK && errno != EINTR && errno != EBADF)); - + } else { #if HAVE_FLUSHIO if (!data->is_pipe && data->last_op == 'w') @@ -393,7 +393,7 @@ static int php_stdiop_close(php_stream *stream, int close_handle TSRMLS_DC) data->file_mapping = NULL; } #endif - + if (close_handle) { if (data->file) { if (data->is_process_pipe) { @@ -463,14 +463,14 @@ static int php_stdiop_seek(php_stream *stream, off_t offset, int whence, off_t * if (data->fd >= 0) { off_t result; - + result = lseek(data->fd, offset, whence); if (result == (off_t)-1) return -1; *newoffset = result; return 0; - + } else { ret = fseek(data->file, offset, whence); *newoffset = ftell(data->file); @@ -484,7 +484,7 @@ static int php_stdiop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC) php_stdio_stream_data *data = (php_stdio_stream_data*) stream->abstract; assert(data != NULL); - + /* as soon as someone touches the stdio layer, buffering may ensue, * so we need to stop using the fd directly in that case */ @@ -502,7 +502,7 @@ static int php_stdiop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC) return FAILURE; } } - + *(FILE**)ret = data->file; data->fd = -1; } @@ -558,9 +558,9 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void int flags; int oldval; #endif - + PHP_STDIOP_GET_FD(fd, data); - + switch(option) { case PHP_STREAM_OPTION_BLOCKING: if (fd == -1) @@ -572,20 +572,20 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void flags &= ~O_NONBLOCK; else flags |= O_NONBLOCK; - + if (-1 == fcntl(fd, F_SETFL, flags)) return -1; return oldval; #else return -1; /* not yet implemented */ #endif - + case PHP_STREAM_OPTION_WRITE_BUFFER: if (data->file == NULL) { return -1; } - + if (ptrparam) size = *(size_t *)ptrparam; else @@ -594,10 +594,10 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void switch(value) { case PHP_STREAM_BUFFER_NONE: return setvbuf(data->file, NULL, _IONBF, 0); - + case PHP_STREAM_BUFFER_LINE: return setvbuf(data->file, NULL, _IOLBF, size); - + case PHP_STREAM_BUFFER_FULL: return setvbuf(data->file, NULL, _IOFBF, size); @@ -605,7 +605,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void return -1; } break; - + case PHP_STREAM_OPTION_LOCKING: if (fd == -1) { return -1; @@ -628,7 +628,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void { php_stream_mmap_range *range = (php_stream_mmap_range*)ptrparam; int prot, flags; - + switch (value) { case PHP_STREAM_MMAP_SUPPORTED: return fd == -1 ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK; @@ -793,7 +793,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void return ftruncate(fd, new_size) == 0 ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR; } } - + default: return PHP_STREAM_OPTION_RETURN_NOTIMPL; } @@ -866,7 +866,7 @@ static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, char if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(path TSRMLS_CC)) { return NULL; } - + dir = VCWD_OPENDIR(path); #ifdef PHP_WIN32 @@ -884,7 +884,7 @@ static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, char if (stream == NULL) closedir(dir); } - + return stream; } /* }}} */ @@ -932,7 +932,7 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, cha return ret; } } - + fd = open(realpath, open_flags, 0666); if (fd != -1) { @@ -1001,9 +1001,12 @@ static php_stream *php_plain_files_stream_opener(php_stream_wrapper *wrapper, ch static int php_plain_files_url_stater(php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) { + char *p; - if (strncmp(url, "file://", sizeof("file://") - 1) == 0) { - url += sizeof("file://") - 1; + if ((p = strstr(url, "://")) != NULL) { + if (p < strchr(url, '/')) { + url = p + 3; + } } if (php_check_open_basedir_ex(url, (flags & PHP_STREAM_URL_STAT_QUIET) ? 0 : 1 TSRMLS_CC)) { @@ -1032,7 +1035,9 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, int op int ret; if ((p = strstr(url, "://")) != NULL) { - url = p + 3; + if (p < strchr(url, '/')) { + url = p + 3; + } } if (php_check_open_basedir(url TSRMLS_CC)) { @@ -1074,11 +1079,15 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c #endif if ((p = strstr(url_from, "://")) != NULL) { - url_from = p + 3; + if (p < strchr(url_from, '/')) { + url_from = p + 3; + } } if ((p = strstr(url_to, "://")) != NULL) { - url_to = p + 3; + if (p < strchr(url_to, '/')) { + url_to = p + 3; + } } if (php_check_open_basedir(url_from TSRMLS_CC) || php_check_open_basedir(url_to TSRMLS_CC)) { @@ -1144,7 +1153,9 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod char *p; if ((p = strstr(dir, "://")) != NULL) { - dir = p + 3; + if (p < strchr(dir, '/')) { + dir = p + 3; + } } if (!recursive) { @@ -1169,7 +1180,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod } if (p && dir_len == 1) { - /* buf == "DEFAULT_SLASH" */ + /* buf == "DEFAULT_SLASH" */ } else { /* find a top level directory we need to create */ @@ -1273,7 +1284,9 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, char *url, int #endif if ((p = strstr(url, "://")) != NULL) { - url = p + 3; + if (p < strchr(url, '/')) { + url = p + 3; + } } if (php_check_open_basedir(url TSRMLS_CC)) { @@ -1409,7 +1422,7 @@ PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char return php_stream_fopen_rel(filename, mode, opened_path, options); } - + #ifdef PHP_WIN32 if (IS_SLASH(filename[0])) { size_t cwd_len; @@ -1417,17 +1430,17 @@ PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char cwd = virtual_getcwd_ex(&cwd_len TSRMLS_CC); /* getcwd() will return always return [DRIVE_LETTER]:/) on windows. */ *(cwd+3) = '\0'; - + if (snprintf(trypath, MAXPATHLEN, "%s%s", cwd, filename) >= MAXPATHLEN) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", cwd, filename, MAXPATHLEN); } - + free(cwd); - + if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(trypath TSRMLS_CC)) { return NULL; } - + return php_stream_fopen_rel(trypath, mode, opened_path, options); } #endif @@ -1479,7 +1492,7 @@ PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir_ex(trypath, 0 TSRMLS_CC)) { goto stream_skip; } - + stream = php_stream_fopen_rel(trypath, mode, opened_path, options); if (stream) { efree(pathbuf); diff --git a/main/streams/streams.c b/main/streams/streams.c index 47d86b586e0ba..4163c5b392668 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -470,11 +470,6 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov while (zend_list_delete(stream->rsrc_id) == SUCCESS) {} } - /* Remove stream from any context link list */ - if (context && context->links) { - php_stream_context_del_link(context, stream); - } - if (close_options & PHP_STREAM_FREE_CALL_DTOR) { if (release_cast && stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FOPENCOOKIE) { /* calling fclose on an fopencookied stream will ultimately @@ -2188,10 +2183,6 @@ PHPAPI void php_stream_context_free(php_stream_context *context) php_stream_notification_free(context->notifier); context->notifier = NULL; } - if (context->links) { - zval_ptr_dtor(&context->links); - context->links = NULL; - } efree(context); } @@ -2254,66 +2245,6 @@ PHPAPI int php_stream_context_set_option(php_stream_context *context, } return zend_hash_update(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)&copied_val, sizeof(zval *), NULL); } - -PHPAPI int php_stream_context_get_link(php_stream_context *context, - const char *hostent, php_stream **stream) -{ - php_stream **pstream; - - if (!stream || !hostent || !context || !(context->links)) { - return FAILURE; - } - if (SUCCESS == zend_hash_find(Z_ARRVAL_P(context->links), (char*)hostent, strlen(hostent)+1, (void**)&pstream)) { - *stream = *pstream; - return SUCCESS; - } - return FAILURE; -} - -PHPAPI int php_stream_context_set_link(php_stream_context *context, - const char *hostent, php_stream *stream) -{ - if (!context) { - return FAILURE; - } - if (!context->links) { - ALLOC_INIT_ZVAL(context->links); - array_init(context->links); - } - if (!stream) { - /* Delete any entry for */ - return zend_hash_del(Z_ARRVAL_P(context->links), (char*)hostent, strlen(hostent)+1); - } - return zend_hash_update(Z_ARRVAL_P(context->links), (char*)hostent, strlen(hostent)+1, (void**)&stream, sizeof(php_stream *), NULL); -} - -PHPAPI int php_stream_context_del_link(php_stream_context *context, - php_stream *stream) -{ - php_stream **pstream; - char *hostent; - int ret = SUCCESS; - - if (!context || !context->links || !stream) { - return FAILURE; - } - - for(zend_hash_internal_pointer_reset(Z_ARRVAL_P(context->links)); - SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(context->links), (void**)&pstream); - zend_hash_move_forward(Z_ARRVAL_P(context->links))) { - if (*pstream == stream) { - if (SUCCESS == zend_hash_get_current_key(Z_ARRVAL_P(context->links), &hostent, NULL, 0)) { - if (FAILURE == zend_hash_del(Z_ARRVAL_P(context->links), (char*)hostent, strlen(hostent)+1)) { - ret = FAILURE; - } - } else { - ret = FAILURE; - } - } - } - - return ret; -} /* }}} */ /* {{{ php_stream_dirent_alphasort diff --git a/makedist b/makedist index bfc8fcc44a239..bce40a9488035 100755 --- a/makedist +++ b/makedist @@ -119,8 +119,14 @@ tar cf $ARCHIVE php-$VER || exit 10 bzip2 -9 $ARCHIVE || exit 11 echo "" +$ECHO_N "makedist: making xz2zipped tar archive...$ECHO_C" +rm -f $ARCHIVE.xz +tar cf $ARCHIVE php-$VER || exit 10 +xz -9 $ARCHIVE || exit 12 +echo "" + $ECHO_N "makedist: cleaning up...$ECHO_C" -rm -rf $DIRPATH || exit 12 +rm -rf $DIRPATH || exit 13 echo "" exit 0 diff --git a/php.ini-development b/php.ini-development index 4ff4192f6f84e..a9c2d06e675a8 100644 --- a/php.ini-development +++ b/php.ini-development @@ -78,11 +78,13 @@ ; compatibility with older or less security conscience applications. We ; recommending using the production ini in production and testing environments. -; php.ini-development is very similar to its production variant, except it's -; much more verbose when it comes to errors. We recommending using the -; development version only in development environments as errors shown to +; php.ini-development is very similar to its production variant, except it is +; much more verbose when it comes to errors. We recommend using the +; development version only in development environments, as errors shown to ; application users can inadvertently leak otherwise secure information. +; This is php.ini-development INI file. + ;;;;;;;;;;;;;;;;;;; ; Quick Reference ; ;;;;;;;;;;;;;;;;;;; @@ -197,13 +199,13 @@ engine = On ; This directive determines whether or not PHP will recognize code between -; tags as PHP source which should be processed as such. It's been -; recommended for several years that you not use the short tag "short cut" and -; instead to use the full tag combination. With the wide spread use +; tags as PHP source which should be processed as such. For several +; years we recommended that you not use the short tag shortcut and +; instead to use the full tag combination. With the widespread use ; of XML and use of these tags by other languages, the server can become easily -; confused and end up parsing the wrong code in the wrong context. But because -; this short cut has been a feature for such a long time, it's currently still -; supported for backwards compatibility, but we recommend you don't use them. +; confused and end up parsing the wrong code in the wrong context. +; This shortcut is still supported for backwards compatibility, but we +; recommend against its use. ; Default Value: On ; Development Value: Off ; Production Value: Off @@ -432,7 +434,7 @@ memory_limit = 128M ; E_NOTICE - run-time notices (these are warnings which often result ; from a bug in your code, but it's possible that it was ; intentional (e.g., using an uninitialized variable and -; relying on the fact it's automatically initialized to an +; relying on the fact it is automatically initialized to an ; empty string) ; E_STRICT - run-time notices, enable to have PHP suggest changes ; to your code which will ensure the best interoperability @@ -465,8 +467,8 @@ error_reporting = E_ALL ; it could be very dangerous in production environments. Depending on the code ; which is triggering the error, sensitive information could potentially leak ; out of your application such as database usernames and passwords or worse. -; It's recommended that errors be logged on production servers rather than -; having the errors sent to STDOUT. +; For production environments, we recommend logging errors rather than +; sending them to STDOUT. ; Possible Values: ; Off = Do not display any errors ; stderr = Display errors to STDERR (affects only CGI/CLI binaries!) @@ -480,8 +482,8 @@ display_errors = On ; The display of errors which occur during PHP's startup sequence are handled ; separately from display_errors. PHP's default behavior is to suppress those ; errors from clients. Turning the display of startup errors on can be useful in -; debugging configuration problems. But, it's strongly recommended that you -; leave this setting off on production servers. +; debugging configuration problems. We strongly recommend you +; set this to 'off' for production servers. ; Default Value: Off ; Development Value: On ; Production Value: Off @@ -729,6 +731,10 @@ user_dir = ; On windows: ; extension_dir = "ext" +; Directory where the temporary files should be placed. +; Defaults to the system default (see sys_get_temp_dir) +; sys_temp_dir = "/tmp" + ; Whether or not to enable the dl() function. The dl() function does NOT work ; properly in multithreaded servers, such as IIS or Zeus, and is automatically ; disabled on them. @@ -775,8 +781,8 @@ enable_dl = Off ;fastcgi.logging = 0 ; cgi.rfc2616_headers configuration option tells PHP what type of headers to -; use when sending HTTP response code. If it's set 0 PHP sends Status: header that -; is supported by Apache. When this option is set to 1 PHP will send +; use when sending HTTP response code. If set to 0, PHP sends Status: header that +; is supported by Apache. When this option is set to 1, PHP will send ; RFC2616 compliant header. ; Default is zero. ; http://php.net/cgi.rfc2616-headers @@ -1376,9 +1382,9 @@ session.save_handler = files ; ; where N is an integer. Instead of storing all the session files in ; /path, what this will do is use subdirectories N-levels deep, and -; store the session data in those directories. This is useful if you -; or your OS have problems with lots of files in one directory, and is -; a more efficient layout for servers that handle lots of sessions. +; store the session data in those directories. This is useful if +; your OS has problems with many files in one directory, and is +; a more efficient layout for servers that handle many sessions. ; ; NOTE 1: PHP will not create this directory structure automatically. ; You can use the script in the ext/session dir for that purpose. @@ -1405,7 +1411,7 @@ session.use_cookies = 1 ; This option forces PHP to fetch and use a cookie for storing and maintaining ; the session id. We encourage this operation as it's very helpful in combating ; session hijacking when not specifying and managing your own session id. It is -; not the end all be all of session hijacking defense, but it's a good start. +; not the be-all and end-all of session hijacking defense, but it's a good start. ; http://php.net/session.use-only-cookies session.use_only_cookies = 1 @@ -1478,14 +1484,14 @@ session.gc_maxlifetime = 1440 ; PHP 4.2 and less have an undocumented feature/bug that allows you to ; to initialize a session variable in the global scope. -; PHP 4.3 and later will warn you, if this feature is used. +; PHP 4.3 and later will warn you if this feature is used. ; You can disable the feature and the warning separately. At this time, ; the warning is only displayed, if bug_compat_42 is enabled. This feature -; introduces some serious security problems if not handled correctly. It's -; recommended that you do not use this feature on production servers. But you +; introduces some serious security problems if not handled correctly. We +; recommend you not use this feature on production servers. You ; should enable this on development servers and enable the warning as well. If you ; do not enable the feature on development servers, you won't be warned when it's -; used and debugging errors caused by this can be difficult to track down. +; used, so debugging errors caused by this can be difficult to track down. ; Default Value: On ; Development Value: On ; Production Value: Off @@ -1530,7 +1536,7 @@ session.cache_limiter = nocache session.cache_expire = 180 ; trans sid support is disabled by default. -; Use of trans sid may risk your users security. +; Use of trans sid may risk your users' security. ; Use this option with caution. ; - User may send URL contains active session ID ; to other person via. email/irc/etc. @@ -1727,16 +1733,16 @@ mssql.secure_connection = Off ; Some encoding cannot work as internal encoding. ; (e.g. SJIS, BIG5, ISO-2022-*) ; http://php.net/mbstring.internal-encoding -;mbstring.internal_encoding = EUC-JP +;mbstring.internal_encoding = UTF-8 ; http input encoding. ; http://php.net/mbstring.http-input -;mbstring.http_input = auto +;mbstring.http_input = UTF-8 ; http output encoding. mb_output_handler must be ; registered as output buffer to function ; http://php.net/mbstring.http-output -;mbstring.http_output = SJIS +;mbstring.http_output = pass ; enable automatic encoding translation according to ; mbstring.internal_encoding setting. Input chars are @@ -1754,7 +1760,7 @@ mssql.secure_connection = Off ; substitute_character used when character cannot be converted ; one from another ; http://php.net/mbstring.substitute-character -;mbstring.substitute_character = none; +;mbstring.substitute_character = none ; overload(replace) single byte functions by mbstring functions. ; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(), @@ -1768,7 +1774,7 @@ mssql.secure_connection = Off ;mbstring.func_overload = 0 ; enable strict encoding detection. -;mbstring.strict_detection = Off +;mbstring.strict_detection = On ; This directive specifies the regex pattern of content types for which mb_output_handler() ; is activated. diff --git a/php.ini-production b/php.ini-production index 814455bbbbbfe..76d5fb5dd6ce2 100644 --- a/php.ini-production +++ b/php.ini-production @@ -78,11 +78,13 @@ ; compatibility with older or less security conscience applications. We ; recommending using the production ini in production and testing environments. -; php.ini-development is very similar to its production variant, except it's -; much more verbose when it comes to errors. We recommending using the -; development version only in development environments as errors shown to +; php.ini-development is very similar to its production variant, except it is +; much more verbose when it comes to errors. We recommend using the +; development version only in development environments, as errors shown to ; application users can inadvertently leak otherwise secure information. +; This is php.ini-production INI file. + ;;;;;;;;;;;;;;;;;;; ; Quick Reference ; ;;;;;;;;;;;;;;;;;;; @@ -197,13 +199,14 @@ engine = On ; This directive determines whether or not PHP will recognize code between -; tags as PHP source which should be processed as such. It's been -; recommended for several years that you not use the short tag "short cut" and -; instead to use the full tag combination. With the wide spread use +; tags as PHP source which should be processed as such. For several +; years we recommended that you not use the short tag shortcut and +; instead to use the full tag combination. With the widespread use ; of XML and use of these tags by other languages, the server can become easily -; confused and end up parsing the wrong code in the wrong context. But because -; this short cut has been a feature for such a long time, it's currently still -; supported for backwards compatibility, but we recommend you don't use them. +; confused and end up parsing the wrong code in the wrong context. +; This shortcut is still supported for backwards compatibility, but we +; recommend against its use. +; Default Value: On ; Default Value: On ; Development Value: Off ; Production Value: Off @@ -432,7 +435,7 @@ memory_limit = 128M ; E_NOTICE - run-time notices (these are warnings which often result ; from a bug in your code, but it's possible that it was ; intentional (e.g., using an uninitialized variable and -; relying on the fact it's automatically initialized to an +; relying on the fact it is automatically initialized to an ; empty string) ; E_STRICT - run-time notices, enable to have PHP suggest changes ; to your code which will ensure the best interoperability @@ -465,8 +468,8 @@ error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT ; it could be very dangerous in production environments. Depending on the code ; which is triggering the error, sensitive information could potentially leak ; out of your application such as database usernames and passwords or worse. -; It's recommended that errors be logged on production servers rather than -; having the errors sent to STDOUT. +; For production environments, we recommend logging errors rather than +; sending them to STDOUT. ; Possible Values: ; Off = Do not display any errors ; stderr = Display errors to STDERR (affects only CGI/CLI binaries!) @@ -480,8 +483,8 @@ display_errors = Off ; The display of errors which occur during PHP's startup sequence are handled ; separately from display_errors. PHP's default behavior is to suppress those ; errors from clients. Turning the display of startup errors on can be useful in -; debugging configuration problems. But, it's strongly recommended that you -; leave this setting off on production servers. +; debugging configuration problems. We strongly recommend you +; set this to 'off' for production servers. ; Default Value: Off ; Development Value: On ; Production Value: Off @@ -729,6 +732,10 @@ user_dir = ; On windows: ; extension_dir = "ext" +; Directory where the temporary files should be placed. +; Defaults to the system default (see sys_get_temp_dir) +; sys_temp_dir = "/tmp" + ; Whether or not to enable the dl() function. The dl() function does NOT work ; properly in multithreaded servers, such as IIS or Zeus, and is automatically ; disabled on them. @@ -775,8 +782,8 @@ enable_dl = Off ;fastcgi.logging = 0 ; cgi.rfc2616_headers configuration option tells PHP what type of headers to -; use when sending HTTP response code. If it's set 0 PHP sends Status: header that -; is supported by Apache. When this option is set to 1 PHP will send +; use when sending HTTP response code. If set to 0, PHP sends Status: header that +; is supported by Apache. When this option is set to 1, PHP will send ; RFC2616 compliant header. ; Default is zero. ; http://php.net/cgi.rfc2616-headers @@ -1376,9 +1383,9 @@ session.save_handler = files ; ; where N is an integer. Instead of storing all the session files in ; /path, what this will do is use subdirectories N-levels deep, and -; store the session data in those directories. This is useful if you -; or your OS have problems with lots of files in one directory, and is -; a more efficient layout for servers that handle lots of sessions. +; store the session data in those directories. This is useful if +; your OS has problems with many files in one directory, and is +; a more efficient layout for servers that handle many sessions. ; ; NOTE 1: PHP will not create this directory structure automatically. ; You can use the script in the ext/session dir for that purpose. @@ -1405,7 +1412,7 @@ session.use_cookies = 1 ; This option forces PHP to fetch and use a cookie for storing and maintaining ; the session id. We encourage this operation as it's very helpful in combating ; session hijacking when not specifying and managing your own session id. It is -; not the end all be all of session hijacking defense, but it's a good start. +; not the be-all and end-all of session hijacking defense, but it's a good start. ; http://php.net/session.use-only-cookies session.use_only_cookies = 1 @@ -1478,14 +1485,14 @@ session.gc_maxlifetime = 1440 ; PHP 4.2 and less have an undocumented feature/bug that allows you to ; to initialize a session variable in the global scope. -; PHP 4.3 and later will warn you, if this feature is used. +; PHP 4.3 and later will warn you if this feature is used. ; You can disable the feature and the warning separately. At this time, ; the warning is only displayed, if bug_compat_42 is enabled. This feature -; introduces some serious security problems if not handled correctly. It's -; recommended that you do not use this feature on production servers. But you +; introduces some serious security problems if not handled correctly. We +; recommend you not use this feature on production servers. You ; should enable this on development servers and enable the warning as well. If you ; do not enable the feature on development servers, you won't be warned when it's -; used and debugging errors caused by this can be difficult to track down. +; used, so debugging errors caused by this can be difficult to track down. ; Default Value: On ; Development Value: On ; Production Value: Off @@ -1530,7 +1537,7 @@ session.cache_limiter = nocache session.cache_expire = 180 ; trans sid support is disabled by default. -; Use of trans sid may risk your users security. +; Use of trans sid may risk your users' security. ; Use this option with caution. ; - User may send URL contains active session ID ; to other person via. email/irc/etc. @@ -1727,16 +1734,16 @@ mssql.secure_connection = Off ; Some encoding cannot work as internal encoding. ; (e.g. SJIS, BIG5, ISO-2022-*) ; http://php.net/mbstring.internal-encoding -;mbstring.internal_encoding = EUC-JP +;mbstring.internal_encoding = UTF-8 ; http input encoding. ; http://php.net/mbstring.http-input -;mbstring.http_input = auto +;mbstring.http_input = UTF-8 ; http output encoding. mb_output_handler must be ; registered as output buffer to function ; http://php.net/mbstring.http-output -;mbstring.http_output = SJIS +;mbstring.http_output = pass ; enable automatic encoding translation according to ; mbstring.internal_encoding setting. Input chars are @@ -1754,7 +1761,7 @@ mssql.secure_connection = Off ; substitute_character used when character cannot be converted ; one from another ; http://php.net/mbstring.substitute-character -;mbstring.substitute_character = none; +;mbstring.substitute_character = none ; overload(replace) single byte functions by mbstring functions. ; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(), @@ -1768,7 +1775,7 @@ mssql.secure_connection = Off ;mbstring.func_overload = 0 ; enable strict encoding detection. -;mbstring.strict_detection = Off +;mbstring.strict_detection = On ; This directive specifies the regex pattern of content types for which mb_output_handler() ; is activated. diff --git a/run-tests.php b/run-tests.php index a746c369653cc..8b7fa7f8be556 100755 --- a/run-tests.php +++ b/run-tests.php @@ -311,6 +311,7 @@ function write_information($show_html) define('PHP_QA_EMAIL', 'qa-reports@lists.php.net'); define('QA_SUBMISSION_PAGE', 'http://qa.php.net/buildtest-process.php'); define('QA_REPORTS_PAGE', 'http://qa.php.net/reports'); +define('TRAVIS_CI' , (bool) getenv('TRAVIS_PHP_VERSION')); function save_or_mail_results() { @@ -318,7 +319,7 @@ function save_or_mail_results() $PHP_FAILED_TESTS, $CUR_DIR, $php, $output_file, $compression; /* We got failed Tests, offer the user to send an e-mail to QA team, unless NO_INTERACTION is set */ - if (!getenv('NO_INTERACTION')) { + if (!getenv('NO_INTERACTION') && !TRAVIS_CI) { $fp = fopen("php://stdin", "r+"); if ($sum_results['FAILED'] || $sum_results['BORKED'] || $sum_results['WARNED'] || $sum_results['LEAKED'] || $sum_results['XFAILED']) { echo "\nYou may have found a problem in PHP."; @@ -335,8 +336,8 @@ function save_or_mail_results() $just_save_results = (strtolower($user_input[0]) == 's'); } - if ($just_save_results || !getenv('NO_INTERACTION')) { - if ($just_save_results || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') { + if ($just_save_results || !getenv('NO_INTERACTION') || TRAVIS_CI) { + if ($just_save_results || TRAVIS_CI || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') { /* * Collect information about the host system for our report * Fetch phpinfo() output so that we can see the PHP enviroment @@ -348,7 +349,9 @@ function save_or_mail_results() } /* Ask the user to provide an email address, so that QA team can contact the user */ - if (!strncasecmp($user_input, 'y', 1) || strlen(trim($user_input)) == 0) { + if (TRAVIS_CI) { + $user_email = 'travis at php dot net'; + } elseif (!strncasecmp($user_input, 'y', 1) || strlen(trim($user_input)) == 0) { echo "\nPlease enter your email address.\n(Your address will be mangled so that it will not go out on any\nmailinglist in plain text): "; flush(); $user_email = trim(fgets($fp, 1024)); @@ -424,7 +427,7 @@ function save_or_mail_results() $failed_tests_data .= $sep . "PHPINFO" . $sep; $failed_tests_data .= shell_exec($php . ' -ddisplay_errors=stderr -dhtml_errors=0 -i 2> /dev/null'); - if ($just_save_results || !mail_qa_team($failed_tests_data, $compression, $status)) { + if ($just_save_results || !mail_qa_team($failed_tests_data, $compression, $status) && !TRAVIS_CI) { file_put_contents($output_file, $failed_tests_data); if (!$just_save_results) { @@ -432,7 +435,7 @@ function save_or_mail_results() } echo "Please send " . $output_file . " to " . PHP_QA_EMAIL . " manually, thank you.\n"; - } else { + } elseif (!getenv('NO_INTERACTION') && !TRAVIS_CI) { fwrite($fp, "\nThank you for helping to make PHP better.\n"); fclose($fp); } @@ -799,14 +802,12 @@ function save_or_mail_results() fclose($failed_tests_file); } - if (count($test_files) || count($test_results)) { - compute_summary(); - if ($html_output) { - fwrite($html_file, "
\n" . get_summary(false, true)); - } - echo "====================================================================="; - echo get_summary(false, false); + compute_summary(); + if ($html_output) { + fwrite($html_file, "
\n" . get_summary(false, true)); } + echo "====================================================================="; + echo get_summary(false, false); if ($html_output) { fclose($html_file); @@ -818,7 +819,7 @@ function save_or_mail_results() junit_save_xml(); - if (getenv('REPORT_EXIT_STATUS') == 1 and preg_match('/FAILED(?: |$)/', implode(' ', $test_results))) { + if (getenv('REPORT_EXIT_STATUS') == 1 and $sum_results['FAILED']) { exit(1); } diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 35402a47d9867..fbb9f512d0063 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -880,7 +880,6 @@ static int sapi_cgi_activate(TSRMLS_D) } else { doc_root = getenv("DOCUMENT_ROOT"); } - /* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */ if (doc_root) { doc_root_len = strlen(doc_root); diff --git a/sapi/cli/config.m4 b/sapi/cli/config.m4 index cdfa1f7daff2a..9a1b98da46193 100644 --- a/sapi/cli/config.m4 +++ b/sapi/cli/config.m4 @@ -6,6 +6,23 @@ PHP_ARG_ENABLE(cli,, [ --disable-cli Disable building CLI version of PHP (this forces --without-pear)], yes, no) +AC_CHECK_FUNCS(setproctitle) + +AC_CHECK_HEADERS([sys/pstat.h]) + +AC_CACHE_CHECK([for PS_STRINGS], [cli_cv_var_PS_STRINGS], +[AC_TRY_LINK( +[#include +#include +], +[PS_STRINGS->ps_nargvstr = 1; +PS_STRINGS->ps_argvstr = "foo";], +[cli_cv_var_PS_STRINGS=yes], +[cli_cv_var_PS_STRINGS=no])]) +if test "$cli_cv_var_PS_STRINGS" = yes ; then + AC_DEFINE([HAVE_PS_STRINGS], [], [Define to 1 if the PS_STRINGS thing exists.]) +fi + AC_MSG_CHECKING(for CLI build) if test "$PHP_CLI" != "no"; then PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/cli/Makefile.frag) @@ -14,7 +31,7 @@ if test "$PHP_CLI" != "no"; then SAPI_CLI_PATH=sapi/cli/php dnl Select SAPI - PHP_SELECT_SAPI(cli, program, php_cli.c php_http_parser.c php_cli_server.c,, '$(SAPI_CLI_PATH)') + PHP_SELECT_SAPI(cli, program, php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c,, '$(SAPI_CLI_PATH)') case $host_alias in *aix*) diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32 index 4d0dad58e84b4..adcbb2b496acb 100644 --- a/sapi/cli/config.w32 +++ b/sapi/cli/config.w32 @@ -6,7 +6,7 @@ ARG_ENABLE('crt-debug', 'Enable CRT memory dumps for debugging sent to STDERR', ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no'); if (PHP_CLI == "yes") { - SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c', 'php.exe'); + SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c php_cli_process_title.c ps_title.c', 'php.exe'); ADD_FLAG("LIBS_CLI", "ws2_32.lib"); if (PHP_CRT_DEBUG == "yes") { ADD_FLAG("CFLAGS_CLI", "/D PHP_WIN32_DEBUG_HEAP"); @@ -15,7 +15,7 @@ if (PHP_CLI == "yes") { } if (PHP_CLI_WIN32 == "yes") { - SAPI('cli_win32', 'cli_win32.c', 'php-win.exe'); + SAPI('cli_win32', 'cli_win32.c php_cli_process_title.c ps_title.c', 'php-win.exe'); ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:8388608"); } diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index c01f3705b59bc..ffb6a69c4cc9d 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -86,6 +86,9 @@ #include "php_cli_server.h" #endif +#include "ps_title.h" +#include "php_cli_process_title.h" + #ifndef PHP_WIN32 # define php_select(m, r, w, e, t) select(m, r, w, e, t) #else @@ -478,6 +481,8 @@ ZEND_END_ARG_INFO() static const zend_function_entry additional_functions[] = { ZEND_FE(dl, arginfo_dl) + PHP_FE(cli_set_process_title, arginfo_cli_set_process_title) + PHP_FE(cli_get_process_title, NULL) {NULL, NULL, NULL} }; @@ -1200,6 +1205,7 @@ int main(int argc, char *argv[]) int argc = __argc; char **argv = __argv; #endif + int c; int exit_status = SUCCESS; int module_started = 0, sapi_started = 0; @@ -1211,6 +1217,12 @@ int main(int argc, char *argv[]) int ini_ignore = 0; sapi_module_struct *sapi_module = &cli_sapi_module; + /* + * Do not move this initialization. It needs to happen before argv is used + * in any way. + */ + argv = save_ps_args(argc, argv); + cli_sapi_module.additional_functions = additional_functions; #if defined(PHP_WIN32) && defined(_DEBUG) && defined(PHP_WIN32_DEBUG_HEAP) @@ -1299,6 +1311,7 @@ int main(int argc, char *argv[]) #ifndef PHP_CLI_WIN32_NO_CONSOLE case 'S': sapi_module = &cli_server_sapi_module; + cli_server_sapi_module.additional_functions = server_additional_functions; break; #endif case 'h': /* help & quit */ diff --git a/sapi/cli/php_cli_process_title.c b/sapi/cli/php_cli_process_title.c new file mode 100644 index 0000000000000..8631f82893c4d --- /dev/null +++ b/sapi/cli/php_cli_process_title.c @@ -0,0 +1,76 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Keyur Govande (kgovande@gmail.com) | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_cli_process_title.h" +#include "ps_title.h" + +/* {{{ proto boolean cli_set_process_title(string arg) + Return a boolean to confirm if the process title was successfully changed or not */ +PHP_FUNCTION(cli_set_process_title) +{ + char *title = NULL; + int title_len; + int rc; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &title, &title_len) == FAILURE) { + RETURN_FALSE; + } + + rc = set_ps_title(title); + if (rc == PS_TITLE_SUCCESS) { + RETURN_TRUE; + } + + php_error_docref(NULL TSRMLS_CC, E_WARNING, "cli_set_process_title had an error: %s", ps_title_errno(rc)); + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto string cli_get_process_title(string arg) + Return a string with the current process title. NULL if error. */ +PHP_FUNCTION(cli_get_process_title) +{ + int length = 0; + const char* title = NULL; + int rc; + + rc = get_ps_title(&length, &title); + if (rc != PS_TITLE_SUCCESS) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "cli_get_process_title had an error: %s", ps_title_errno(rc)); + RETURN_NULL(); + } + + RETURN_STRINGL(title, length, 1); +} +/* }}} */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/main/php_logos.h b/sapi/cli/php_cli_process_title.h similarity index 70% rename from main/php_logos.h rename to sapi/cli/php_cli_process_title.h index d0f0b5ecef4ad..62ef5673db57e 100644 --- a/main/php_logos.h +++ b/sapi/cli/php_cli_process_title.h @@ -12,23 +12,29 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Author: | + | Author: Keyur Govande (kgovande@gmail.com) | +----------------------------------------------------------------------+ */ /* $Id$ */ +#ifndef PHP_PS_TITLE_HEADER +#define PHP_PS_TITLE_HEADER -#ifndef _PHP_LOGOS_H -#define _PHP_LOGOS_H +ZEND_BEGIN_ARG_INFO(arginfo_cli_set_process_title, 0) + ZEND_ARG_INFO(0, title) +ZEND_END_ARG_INFO() -BEGIN_EXTERN_C() -PHPAPI int php_register_info_logo(char *logo_string, const char *mimetype, const unsigned char *data, int size); -PHPAPI int php_unregister_info_logo(char *logo_string); -END_EXTERN_C() +PHP_FUNCTION(cli_set_process_title); +PHP_FUNCTION(cli_get_process_title); -int php_init_info_logos(void); -int php_shutdown_info_logos(void); -int php_info_logos(const char *logo_string TSRMLS_DC); +#endif -#endif /* _PHP_LOGOS_H */ +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 6a4e7c53ab7c9..4c0b7e7f0d0ca 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -103,6 +103,8 @@ #include "php_http_parser.h" #include "php_cli_server.h" +#include "php_cli_process_title.h" + #define OUTPUT_NOT_CHECKED -1 #define OUTPUT_IS_TTY 1 #define OUTPUT_NOT_TTY 0 @@ -246,7 +248,7 @@ static php_cli_server_http_reponse_status_code_pair status_map[] = { static php_cli_server_http_reponse_status_code_pair template_map[] = { { 400, "

%s

Your browser sent a request that this server could not understand.

" }, - { 404, "

%s

The requested resource %s was not found on this server.

" }, + { 404, "

%s

The requested resource %s was not found on this server.

" }, { 500, "

%s

The server is temporarily unavailable.

" }, { 501, "

%s

Request method not supported.

" } }; @@ -283,8 +285,10 @@ ZEND_DECLARE_MODULE_GLOBALS(cli_server); * copied from ext/standard/info.c */ static const char php_cli_server_css[] = "\n"; /* }}} */ @@ -423,6 +427,12 @@ zend_module_entry cli_server_module_entry = { }; /* }}} */ +const zend_function_entry server_additional_functions[] = { + PHP_FE(cli_set_process_title, arginfo_cli_set_process_title) + PHP_FE(cli_get_process_title, NULL) + {NULL, NULL, NULL} +}; + static int sapi_cli_server_startup(sapi_module_struct *sapi_module) /* {{{ */ { if (php_module_startup(sapi_module, &cli_server_module_entry, 1) == FAILURE) { @@ -1936,40 +1946,38 @@ static int php_cli_server_request_shutdown(php_cli_server *server, php_cli_serve static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) /* {{{ */ { int decline = 0; - if (!php_handle_special_queries(TSRMLS_C)) { - zend_file_handle zfd; - char *old_cwd; - - ALLOCA_FLAG(use_heap) - old_cwd = do_alloca(MAXPATHLEN, use_heap); - old_cwd[0] = '\0'; - php_ignore_value(VCWD_GETCWD(old_cwd, MAXPATHLEN - 1)); - - zfd.type = ZEND_HANDLE_FILENAME; - zfd.filename = server->router; - zfd.handle.fp = NULL; - zfd.free_filename = 0; - zfd.opened_path = NULL; - - zend_try { - zval *retval = NULL; - if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, &retval, 1, &zfd)) { - if (retval) { - decline = Z_TYPE_P(retval) == IS_BOOL && !Z_LVAL_P(retval); - zval_ptr_dtor(&retval); - } - } else { - decline = 1; + zend_file_handle zfd; + char *old_cwd; + + ALLOCA_FLAG(use_heap) + old_cwd = do_alloca(MAXPATHLEN, use_heap); + old_cwd[0] = '\0'; + php_ignore_value(VCWD_GETCWD(old_cwd, MAXPATHLEN - 1)); + + zfd.type = ZEND_HANDLE_FILENAME; + zfd.filename = server->router; + zfd.handle.fp = NULL; + zfd.free_filename = 0; + zfd.opened_path = NULL; + + zend_try { + zval *retval = NULL; + if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, &retval, 1, &zfd)) { + if (retval) { + decline = Z_TYPE_P(retval) == IS_BOOL && !Z_LVAL_P(retval); + zval_ptr_dtor(&retval); } - } zend_end_try(); - - if (old_cwd[0] != '\0') { - php_ignore_value(VCWD_CHDIR(old_cwd)); + } else { + decline = 1; } + } zend_end_try(); - free_alloca(old_cwd, use_heap); + if (old_cwd[0] != '\0') { + php_ignore_value(VCWD_CHDIR(old_cwd)); } + free_alloca(old_cwd, use_heap); + return decline; } /* }}} */ diff --git a/sapi/cli/php_cli_server.h b/sapi/cli/php_cli_server.h index ed716f99f809e..9a29626c7f056 100644 --- a/sapi/cli/php_cli_server.h +++ b/sapi/cli/php_cli_server.h @@ -23,6 +23,7 @@ #include "SAPI.h" +extern const zend_function_entry server_additional_functions[]; extern sapi_module_struct cli_server_sapi_module; extern int do_cli_server(int argc, char **argv TSRMLS_DC); diff --git a/sapi/cli/ps_title.c b/sapi/cli/ps_title.c new file mode 100644 index 0000000000000..610def73c5f15 --- /dev/null +++ b/sapi/cli/ps_title.c @@ -0,0 +1,384 @@ +/* + * PostgreSQL is released under the PostgreSQL License, a liberal Open Source + * license, similar to the BSD or MIT licenses. + * PostgreSQL Database Management System (formerly known as Postgres, then as + * Postgres95) + * + * Portions Copyright (c) 1996-2013, The PostgreSQL Global Development Group + * + * Portions Copyright (c) 1994, The Regents of the University of California + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without a written + * agreement is hereby granted, provided that the above copyright notice + * and this paragraph and the following two paragraphs appear in all copies. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING + * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, + * EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN + * "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * The following code is adopted from the PostgreSQL's ps_status(.h/.c). + */ + +#include "ps_title.h" +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#include +#include + +#ifdef PHP_WIN32 +#include "config.w32.h" +#include +#include +#else +#include "php_config.h" +extern char** environ; +#endif + +#ifdef HAVE_SYS_PSTAT_H +#include // for HP-UX +#endif +#ifdef HAVE_PS_STRINGS +#include // for old BSD +#include +#endif +#if defined(DARWIN) +#include +#endif + +/* + * Ways of updating ps display: + * + * PS_USE_SETPROCTITLE + * use the function setproctitle(const char *, ...) + * (newer BSD systems) + * PS_USE_PSTAT + * use the pstat(PSTAT_SETCMD, ) + * (HPUX) + * PS_USE_PS_STRINGS + * assign PS_STRINGS->ps_argvstr = "string" + * (some BSD systems) + * PS_USE_CHANGE_ARGV + * assign argv[0] = "string" + * (some other BSD systems) + * PS_USE_CLOBBER_ARGV + * write over the argv and environment area + * (Linux and most SysV-like systems) + * PS_USE_WIN32 + * push the string out as the name of a Windows event + * PS_USE_NONE + * don't update ps display + * (This is the default, as it is safest.) + */ +#if defined(HAVE_SETPROCTITLE) +#define PS_USE_SETPROCTITLE +#elif defined(HAVE_SYS_PSTAT_H) && defined(PSTAT_SETCMD) +#define PS_USE_PSTAT +#elif defined(HAVE_PS_STRINGS) +#define PS_USE_PS_STRINGS +#elif defined(BSD) && !defined(DARWIN) +#define PS_USE_CHANGE_ARGV +#elif defined(__linux__) || defined(_AIX) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix) || defined(__osf__) || defined(DARWIN) +#define PS_USE_CLOBBER_ARGV +#elif defined(PHP_WIN32) +#define PS_USE_WIN32 +#else +#define PS_USE_NONE +#endif + +/* Different systems want the buffer padded differently */ +#if defined(_AIX) || defined(__linux__) || defined(DARWIN) +#define PS_PADDING '\0' +#else +#define PS_PADDING ' ' +#endif + +#ifndef PS_USE_CLOBBER_ARGV +#define PS_BUFFER_SIZE 256 +static char ps_buffer[PS_BUFFER_SIZE]; +static const size_t ps_buffer_size = PS_BUFFER_SIZE; +#else +static char *ps_buffer; /* will point to argv area */ +static size_t ps_buffer_size; /* space determined at run time */ +#endif + +static size_t ps_buffer_cur_len; /* actual string length in ps_buffer */ + +/* save the original argv[] location here */ +static int save_argc; +static char** save_argv; + + +/* + * Call this early in startup to save the original argc/argv values. + * If needed, we make a copy of the original argv[] array to preserve it + * from being clobbered by subsequent ps_display actions. + * + * (The original argv[] will not be overwritten by this routine. + * Also, the physical location of the environment strings may be moved, + * so this should be called before any code that might try to hang onto a + * getenv() result.) + */ +char** save_ps_args(int argc, char** argv) +{ + save_argc = argc; + save_argv = argv; + +#if defined(PS_USE_CLOBBER_ARGV) + /* + * If we're going to overwrite the argv area, count the available space. + * Also move the environment to make additional room. + */ + { + char* end_of_area = NULL; + int non_contiguous_area = 0; + char** new_environ; + int i; + + /* + * check for contiguous argv strings + */ + for (i = 0; (non_contiguous_area == 0) && (i < argc); i++) + { + if (i != 0 && end_of_area + 1 != argv[i]) + non_contiguous_area = 1; + end_of_area = argv[i] + strlen(argv[i]); + } + + /* + * check for contiguous environ strings following argv + */ + for (i = 0; (non_contiguous_area == 0) && (environ[i] != NULL); i++) + { + if (end_of_area + 1 != environ[i]) + non_contiguous_area = 1; + end_of_area = environ[i] + strlen(environ[i]); + } + + if (non_contiguous_area != 0) + goto clobber_error; + + ps_buffer = argv[0]; + ps_buffer_size = end_of_area - argv[0]; + + /* + * move the environment out of the way + */ + new_environ = (char **) malloc((i + 1) * sizeof(char *)); + for (i = 0; environ[i] != NULL; i++) + { + new_environ[i] = strdup(environ[i]); + if (!new_environ[i]) + goto clobber_error; + } + new_environ[i] = NULL; + environ = new_environ; + + } +#endif /* PS_USE_CLOBBER_ARGV */ + +#if defined(PS_USE_CHANGE_ARGV) || defined(PS_USE_CLOBBER_ARGV) + /* + * If we're going to change the original argv[] then make a copy for + * argument parsing purposes. + * + * (NB: do NOT think to remove the copying of argv[]! + * On some platforms, getopt() keeps pointers into the argv array, and + * will get horribly confused when it is re-called to analyze a subprocess' + * argument string if the argv storage has been clobbered meanwhile. + * Other platforms have other dependencies on argv[].) + */ + { + char** new_argv; + int i; + + new_argv = (char **) malloc((argc + 1) * sizeof(char *)); + for (i = 0; i < argc; i++) + { + new_argv[i] = strdup(argv[i]); + if (!new_argv[i]) + goto clobber_error; + } + new_argv[argc] = NULL; + +#if defined(DARWIN) + /* + * Darwin (and perhaps other NeXT-derived platforms?) has a static + * copy of the argv pointer, which we may fix like so: + */ + *_NSGetArgv() = new_argv; +#endif + + argv = new_argv; + + } +#endif /* PS_USE_CHANGE_ARGV or PS_USE_CLOBBER_ARGV */ + +#if defined(PS_USE_CLOBBER_ARGV) + { + /* make extra argv slots point at end_of_area (a NUL) */ + int i; + for (i = 1; i < save_argc; i++) + save_argv[i] = ps_buffer + ps_buffer_size; + } +#endif /* PS_USE_CLOBBER_ARGV */ + +#ifdef PS_USE_CHANGE_ARGV + save_argv[0] = ps_buffer; // ps_buffer here is a static const array of size PS_BUFFER_SIZE + save_argv[1] = NULL; +#endif /* PS_USE_CHANGE_ARGV */ + + return argv; + +#if defined(PS_USE_CHANGE_ARGV) || defined(PS_USE_CLOBBER_ARGV) +clobber_error: + /* probably can't happen?! + * if we ever get here, argv still points to originally passed + * in argument + */ + ps_buffer = NULL; + ps_buffer_size = 0; + return argv; +#endif /* PS_USE_CHANGE_ARGV or PS_USE_CLOBBER_ARGV */ +} + +/* + * Returns PS_TITLE_SUCCESS if the OS supports this functionality + * and the init function was called. + * Otherwise returns NOT_AVAILABLE or NOT_INITIALIZED + */ +int is_ps_title_available() +{ +#ifdef PS_USE_NONE + return PS_TITLE_NOT_AVAILABLE; // disabled functionality +#endif + + if (!save_argv) + return PS_TITLE_NOT_INITIALIZED; + +#ifdef PS_USE_CLOBBER_ARGV + if (!ps_buffer) + return PS_TITLE_BUFFER_NOT_AVAILABLE; +#endif /* PS_USE_CLOBBER_ARGV */ + + return PS_TITLE_SUCCESS; +} + +/* + * Convert error codes into error strings + */ +const char* ps_title_errno(int rc) +{ + switch(rc) + { + case PS_TITLE_SUCCESS: + return "Success"; + + case PS_TITLE_NOT_AVAILABLE: + return "Not available on this OS"; + + case PS_TITLE_NOT_INITIALIZED: + return "Not initialized correctly"; + + case PS_TITLE_BUFFER_NOT_AVAILABLE: + return "Buffer not contiguous"; + } + + return "Unknown error code"; +} + +/* + * Set a new process title. + * Returns the appropriate error code if if there's an error + * (like the functionality is compile time disabled, or the + * save_ps_args() was not called. + * Else returns 0 on success. + */ +int set_ps_title(const char* title) +{ + int rc = is_ps_title_available(); + if (rc != PS_TITLE_SUCCESS) + return rc; + + strncpy(ps_buffer, title, ps_buffer_size); + ps_buffer[ps_buffer_size - 1] = '\0'; + ps_buffer_cur_len = strlen(ps_buffer); + +#ifdef PS_USE_SETPROCTITLE + setproctitle("%s", ps_buffer); +#endif + +#ifdef PS_USE_PSTAT + { + union pstun pst; + + pst.pst_command = ps_buffer; + pstat(PSTAT_SETCMD, pst, ps_buffer_cur_len, 0, 0); + } +#endif /* PS_USE_PSTAT */ + +#ifdef PS_USE_PS_STRINGS + PS_STRINGS->ps_nargvstr = 1; + PS_STRINGS->ps_argvstr = ps_buffer; +#endif /* PS_USE_PS_STRINGS */ + +#ifdef PS_USE_CLOBBER_ARGV + /* pad unused memory */ + if (ps_buffer_cur_len < ps_buffer_size) + { + memset(ps_buffer + ps_buffer_cur_len, PS_PADDING, + ps_buffer_size - ps_buffer_cur_len); + } +#endif /* PS_USE_CLOBBER_ARGV */ + +#ifdef PS_USE_WIN32 + { + /* + * Win32 does not support showing any changed arguments. To make it at + * all possible to track which backend is doing what, we create a + * named object that can be viewed with for example Process Explorer. + */ + static HANDLE ident_handle = INVALID_HANDLE_VALUE; + char name[PS_BUFFER_SIZE + 32]; + + if (ident_handle != INVALID_HANDLE_VALUE) + CloseHandle(ident_handle); + + sprintf(name, "php-process(%d): %s", _getpid(), ps_buffer); + + ident_handle = CreateEvent(NULL, TRUE, FALSE, name); + } +#endif /* PS_USE_WIN32 */ + + return PS_TITLE_SUCCESS; +} + +/* + * Returns the current ps_buffer value into string. On some platforms + * the string will not be null-terminated, so return the effective + * length into *displen. + * The return code indicates the error. + */ +int get_ps_title(int *displen, const char** string) +{ + int rc = is_ps_title_available(); + if (rc != PS_TITLE_SUCCESS) + return rc; + + *displen = ps_buffer_cur_len; + *string = ps_buffer; + return PS_TITLE_SUCCESS; +} + diff --git a/sapi/cli/ps_title.h b/sapi/cli/ps_title.h new file mode 100644 index 0000000000000..00eddfd48b740 --- /dev/null +++ b/sapi/cli/ps_title.h @@ -0,0 +1,39 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Keyur Govande | + +----------------------------------------------------------------------+ + */ + +/* $Id$ */ + +#ifndef PS_TITLE_HEADER +#define PS_TITLE_HEADER + +#define PS_TITLE_SUCCESS 0 +#define PS_TITLE_NOT_AVAILABLE 1 +#define PS_TITLE_NOT_INITIALIZED 2 +#define PS_TITLE_BUFFER_NOT_AVAILABLE 3 + +extern char** save_ps_args(int argc, char** argv); + +extern int set_ps_title(const char* new_str); + +extern int get_ps_title(int* displen, const char** string); + +extern const char* ps_title_errno(int rc); + +extern int is_ps_title_available(); + +#endif // PS_TITLE_HEADER diff --git a/sapi/cli/tests/cli_process_title.phpt b/sapi/cli/tests/cli_process_title.phpt new file mode 100644 index 0000000000000..8ee2894e71ccf --- /dev/null +++ b/sapi/cli/tests/cli_process_title.phpt @@ -0,0 +1,46 @@ +--TEST-- +Check cli_process_title support +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +*** Testing setting the process title *** +Successfully set title +Successfully verified title using ps +Successfully verified title using get diff --git a/sapi/cli/tests/php_cli_server_011.phpt b/sapi/cli/tests/php_cli_server_011.phpt deleted file mode 100644 index a957a8ed4c0c3..0000000000000 --- a/sapi/cli/tests/php_cli_server_011.phpt +++ /dev/null @@ -1,41 +0,0 @@ ---TEST-- -Bug #60180 ($_SERVER["PHP_SELF"] incorrect) ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -okey diff --git a/sapi/cli/tests/php_cli_server_013.phpt b/sapi/cli/tests/php_cli_server_013.phpt index 570798a880117..0e3f4ff74f5b2 100644 --- a/sapi/cli/tests/php_cli_server_013.phpt +++ b/sapi/cli/tests/php_cli_server_013.phpt @@ -88,7 +88,7 @@ Content-Type: text/html; charset=UTF-8 Content-Length: %d 404 Not Found -

Not Found

The requested resource / was not found on this server.

+

Not Found

The requested resource / was not found on this server.

HTTP/1.1 404 Not Found Host: %s Connection: close @@ -96,7 +96,7 @@ Content-Type: text/html; charset=UTF-8 Content-Length: %d 404 Not Found -

Not Found

The requested resource /main/style.css was not found on this server.

+

Not Found

The requested resource /main/style.css was not found on this server.

HTTP/1.1 404 Not Found Host: %s Connection: close @@ -104,5 +104,5 @@ Content-Type: text/html; charset=UTF-8 Content-Length: %d 404 Not Found -

Not Found

The requested resource /main/foo/bar was not found on this server.

+

Not Found

The requested resource /main/foo/bar was not found on this server.

diff --git a/sapi/cli/tests/php_cli_server_014.phpt b/sapi/cli/tests/php_cli_server_014.phpt index f8a990561359a..e8bb5fa8a2f3c 100644 --- a/sapi/cli/tests/php_cli_server_014.phpt +++ b/sapi/cli/tests/php_cli_server_014.phpt @@ -77,4 +77,4 @@ Content-Type: %s Content-Length: %d 404 Not Found -

Not Found

The requested resource /main/no-exists.php was not found on this server.

+

Not Found

The requested resource /main/no-exists.php was not found on this server.

diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 6191c329bac82..3a2690ee2277f 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -587,16 +587,12 @@ if test "$PHP_FPM" != "no"; then AC_DEFINE_UNQUOTED(PHP_FPM_USER, "$php_fpm_user", [fpm user name]) AC_DEFINE_UNQUOTED(PHP_FPM_GROUP, "$php_fpm_group", [fpm group name]) - AC_DEFINE_UNQUOTED(PHP_FPM_USER, "$php_fpm_user", [fpm user name]) - AC_DEFINE_UNQUOTED(PHP_FPM_GROUP, "$php_fpm_group", [fpm group name]) - PHP_ADD_BUILD_DIR(sapi/fpm/fpm) PHP_ADD_BUILD_DIR(sapi/fpm/fpm/events) PHP_OUTPUT(sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html) PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/fpm/Makefile.frag]) SAPI_FPM_PATH=sapi/fpm/php-fpm - if test "$fpm_trace_type" && test -f "$abs_srcdir/sapi/fpm/fpm/fpm_trace_$fpm_trace_type.c"; then PHP_FPM_TRACE_FILES="fpm/fpm_trace.c fpm/fpm_trace_$fpm_trace_type.c" diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index f33b049780e1d..19364c66e06f2 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -75,8 +75,7 @@ static int lsapi_mode = 1; static char *php_self = ""; static char *script_filename = ""; static int source_highlight = 0; -static char * argv0 = NULL; -static int engine = 1; + #ifdef ZTS zend_compiler_globals *compiler_globals; zend_executor_globals *executor_globals; @@ -91,65 +90,40 @@ zend_module_entry litespeed_module_entry; */ static int php_lsapi_startup(sapi_module_struct *sapi_module) { - if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { - return FAILURE; - } - argv0 = sapi_module->executable_location; - return SUCCESS; + if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { + return FAILURE; + } + return SUCCESS; } /* }}} */ -/* {{{ sapi_lsapi_ini_defaults */ - -/* overwriteable ini defaults must be set in sapi_cli_ini_defaults() */ -#define INI_DEFAULT(name,value)\ - ZVAL_STRING(tmp, value, 0);\ - zend_hash_update(configuration_hash, name, sizeof(name), tmp, sizeof(zval), (void**)&entry);\ - Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry)) - -static void sapi_lsapi_ini_defaults(HashTable *configuration_hash) -{ - zval *tmp, *entry; - -#if PHP_MAJOR_VERSION > 4 -/* - MAKE_STD_ZVAL(tmp); - - INI_DEFAULT("register_long_arrays", "0"); - - FREE_ZVAL(tmp); -*/ -#endif - -} -/* }}} */ /* {{{ sapi_lsapi_ub_write */ static int sapi_lsapi_ub_write(const char *str, uint str_length TSRMLS_DC) { - int ret; - int remain; - if ( lsapi_mode ) { - ret = LSAPI_Write( str, str_length ); - if ( ret < str_length ) { - php_handle_aborted_connection(); - return str_length - ret; - } - } else { - remain = str_length; - while( remain > 0 ) { - ret = write( 1, str, remain ); - if ( ret <= 0 ) { - php_handle_aborted_connection(); - return str_length - remain; - } - str += ret; - remain -= ret; - } - } - return str_length; + int ret; + int remain; + if ( lsapi_mode ) { + ret = LSAPI_Write( str, str_length ); + if ( ret < str_length ) { + php_handle_aborted_connection(); + return str_length - ret; + } + } else { + remain = str_length; + while( remain > 0 ) { + ret = write( 1, str, remain ); + if ( ret <= 0 ) { + php_handle_aborted_connection(); + return str_length - remain; + } + str += ret; + remain -= ret; + } + } + return str_length; } /* }}} */ @@ -158,11 +132,11 @@ static int sapi_lsapi_ub_write(const char *str, uint str_length TSRMLS_DC) */ static void sapi_lsapi_flush( void * server_context ) { - if ( lsapi_mode ) { - if ( LSAPI_Flush() == -1) { - php_handle_aborted_connection(); - } - } + if ( lsapi_mode ) { + if ( LSAPI_Flush() == -1) { + php_handle_aborted_connection(); + } + } } /* }}} */ @@ -171,12 +145,8 @@ static void sapi_lsapi_flush( void * server_context ) */ static int sapi_lsapi_deactivate(TSRMLS_D) { - if ( SG(request_info).path_translated ) - { - efree( SG(request_info).path_translated ); - } - - return SUCCESS; + LSAPI_Finish(); + return SUCCESS; } /* }}} */ @@ -187,99 +157,46 @@ static int sapi_lsapi_deactivate(TSRMLS_D) */ static char *sapi_lsapi_getenv( char * name, size_t name_len TSRMLS_DC ) { - if ( lsapi_mode ) { - return LSAPI_GetEnv( name ); - } else { - return getenv( name ); - } + if ( lsapi_mode ) { + return LSAPI_GetEnv( name ); + } else { + return getenv( name ); + } } /* }}} */ -/* -static int add_variable( const char * pKey, int keyLen, const char * pValue, int valLen, - void * arg ) -{ - php_register_variable_safe((char *)pKey, (char *)pValue, valLen, (zval *)arg TSRMLS_CC); - return 1; -} -*/ static int add_variable( const char * pKey, int keyLen, const char * pValue, int valLen, - void * arg ) + void * arg ) { - zval * gpc_element, **gpc_element_p; - HashTable * symtable1 = Z_ARRVAL_P((zval * )arg); - register char * pKey1 = (char *)pKey; - - MAKE_STD_ZVAL(gpc_element); - Z_STRLEN_P( gpc_element ) = valLen; - Z_STRVAL_P( gpc_element ) = estrndup(pValue, valLen); - Z_TYPE_P( gpc_element ) = IS_STRING; -#if PHP_MAJOR_VERSION > 4 - zend_symtable_update( symtable1, pKey1, keyLen + 1, &gpc_element, sizeof( zval *), (void **) &gpc_element_p ); -#else - zend_hash_update( symtable1, pKey1, keyLen + 1, &gpc_element, sizeof( zval *), (void **) &gpc_element_p ); -#endif - return 1; + php_register_variable_safe((char *)pKey, (char *)pValue, valLen, (zval *)arg TSRMLS_CC); + return 1; } -#if ((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || PHP_MAJOR_VERSION < 5) -static int add_variable_magic_quote( const char * pKey, int keyLen, const char * pValue, int valLen, - void * arg ) -{ - zval * gpc_element, **gpc_element_p; - HashTable * symtable1 = Z_ARRVAL_P((zval * )arg); - register char * pKey1 = (char *)pKey; - - MAKE_STD_ZVAL(gpc_element); - Z_STRLEN_P( gpc_element ) = valLen; - Z_STRVAL_P( gpc_element ) = php_addslashes((char *)pValue, valLen, &Z_STRLEN_P( gpc_element ), 0 ); - Z_TYPE_P( gpc_element ) = IS_STRING; -#if PHP_MAJOR_VERSION > 4 - zend_symtable_update( symtable1, pKey1, keyLen + 1, &gpc_element, sizeof( zval *), (void **) &gpc_element_p ); -#else - zend_hash_update( symtable1, pKey1, keyLen + 1, &gpc_element, sizeof( zval *), (void **) &gpc_element_p ); -#endif - return 1; -} - -#endif /* {{{ sapi_lsapi_register_variables */ static void sapi_lsapi_register_variables(zval *track_vars_array TSRMLS_DC) { - char * php_self = ""; - if ( lsapi_mode ) { - if ( (SG(request_info).request_uri ) ) - php_self = (SG(request_info).request_uri ); -#if ((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || PHP_MAJOR_VERSION < 5) - if (!PG(magic_quotes_gpc)) { -#endif - LSAPI_ForeachHeader( add_variable, track_vars_array ); - LSAPI_ForeachEnv( add_variable, track_vars_array ); - add_variable("PHP_SELF", 8, php_self, strlen( php_self ), track_vars_array ); -#if ((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || PHP_MAJOR_VERSION < 5) - } else { - LSAPI_ForeachHeader( add_variable_magic_quote, track_vars_array ); - LSAPI_ForeachEnv( add_variable_magic_quote, track_vars_array ); - add_variable_magic_quote("PHP_SELF", 8, php_self, strlen( php_self ), track_vars_array ); - } -#endif - php_import_environment_variables(track_vars_array TSRMLS_CC); - } else { - php_import_environment_variables(track_vars_array TSRMLS_CC); + if ( lsapi_mode ) { + LSAPI_ForeachHeader( add_variable, track_vars_array ); + LSAPI_ForeachEnv( add_variable, track_vars_array ); + php_import_environment_variables(track_vars_array TSRMLS_CC); - php_register_variable("PHP_SELF", php_self, track_vars_array TSRMLS_CC); - php_register_variable("SCRIPT_NAME", php_self, track_vars_array TSRMLS_CC); - php_register_variable("SCRIPT_FILENAME", script_filename, track_vars_array TSRMLS_CC); - php_register_variable("PATH_TRANSLATED", script_filename, track_vars_array TSRMLS_CC); - php_register_variable("DOCUMENT_ROOT", "", track_vars_array TSRMLS_CC); + php_register_variable("PHP_SELF", (SG(request_info).request_uri ? SG(request_info).request_uri:""), track_vars_array TSRMLS_CC); + } else { + php_import_environment_variables(track_vars_array TSRMLS_CC); - } + php_register_variable("PHP_SELF", php_self, track_vars_array TSRMLS_CC); + php_register_variable("SCRIPT_NAME", php_self, track_vars_array TSRMLS_CC); + php_register_variable("SCRIPT_FILENAME", script_filename, track_vars_array TSRMLS_CC); + php_register_variable("PATH_TRANSLATED", script_filename, track_vars_array TSRMLS_CC); + php_register_variable("DOCUMENT_ROOT", "", track_vars_array TSRMLS_CC); + + } } /* }}} */ @@ -288,11 +205,11 @@ static void sapi_lsapi_register_variables(zval *track_vars_array TSRMLS_DC) */ static int sapi_lsapi_read_post(char *buffer, uint count_bytes TSRMLS_DC) { - if ( lsapi_mode ) { - return LSAPI_ReadReqBody( buffer, count_bytes ); - } else { - return 0; - } + if ( lsapi_mode ) { + return LSAPI_ReadReqBody( buffer, count_bytes ); + } else { + return 0; + } } /* }}} */ @@ -303,11 +220,11 @@ static int sapi_lsapi_read_post(char *buffer, uint count_bytes TSRMLS_DC) */ static char *sapi_lsapi_read_cookies(TSRMLS_D) { - if ( lsapi_mode ) { - return LSAPI_GetHeader( H_COOKIE ); - } else { - return NULL; - } + if ( lsapi_mode ) { + return LSAPI_GetHeader( H_COOKIE ); + } else { + return NULL; + } } /* }}} */ @@ -316,33 +233,33 @@ static char *sapi_lsapi_read_cookies(TSRMLS_D) */ static int sapi_lsapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { - sapi_header_struct *h; - zend_llist_position pos; - if ( lsapi_mode ) { - LSAPI_SetRespStatus( SG(sapi_headers).http_response_code ); - - h = zend_llist_get_first_ex(&sapi_headers->headers, &pos); - while (h) { - if ( h->header_len > 0 ) { - LSAPI_AppendRespHeader(h->header, h->header_len); - } - h = zend_llist_get_next_ex(&sapi_headers->headers, &pos); - } - if (SG(sapi_headers).send_default_content_type) { - char *hd; - int len; - char headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH]; - - hd = sapi_get_default_content_type(TSRMLS_C); - len = snprintf( headerBuf, SAPI_LSAPI_MAX_HEADER_LENGTH - 1, - "Content-type: %s", hd ); - efree(hd); - - LSAPI_AppendRespHeader( headerBuf, len ); - } - } - LSAPI_FinalizeRespHeaders(); - return SAPI_HEADER_SENT_SUCCESSFULLY; + sapi_header_struct *h; + zend_llist_position pos; + if ( lsapi_mode ) { + LSAPI_SetRespStatus( SG(sapi_headers).http_response_code ); + + h = zend_llist_get_first_ex(&sapi_headers->headers, &pos); + while (h) { + if ( h->header_len > 0 ) { + LSAPI_AppendRespHeader(h->header, h->header_len); + } + h = zend_llist_get_next_ex(&sapi_headers->headers, &pos); + } + if (SG(sapi_headers).send_default_content_type) { + char *hd; + int len; + char headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH]; + + hd = sapi_get_default_content_type(TSRMLS_C); + len = snprintf( headerBuf, SAPI_LSAPI_MAX_HEADER_LENGTH - 1, + "Content-type: %s", hd ); + efree(hd); + + LSAPI_AppendRespHeader( headerBuf, len ); + } + } + LSAPI_FinalizeRespHeaders(); + return SAPI_HEADER_SENT_SUCCESSFULLY; } @@ -353,8 +270,8 @@ static int sapi_lsapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) */ static void sapi_lsapi_log_message(char *message TSRMLS_DC) { - int len = strlen( message ); - LSAPI_Write_Stderr( message, len); + int len = strlen( message ); + LSAPI_Write_Stderr( message, len); } /* }}} */ @@ -363,247 +280,158 @@ static void sapi_lsapi_log_message(char *message TSRMLS_DC) */ static sapi_module_struct lsapi_sapi_module = { - "litespeed", - "LiteSpeed V5.5", + "litespeed", + "LiteSpeed", - php_lsapi_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ + php_lsapi_startup, /* startup */ + php_module_shutdown_wrapper, /* shutdown */ - NULL, /* activate */ - sapi_lsapi_deactivate, /* deactivate */ + NULL, /* activate */ + sapi_lsapi_deactivate, /* deactivate */ - sapi_lsapi_ub_write, /* unbuffered write */ - sapi_lsapi_flush, /* flush */ - NULL, /* get uid */ - sapi_lsapi_getenv, /* getenv */ + sapi_lsapi_ub_write, /* unbuffered write */ + sapi_lsapi_flush, /* flush */ + NULL, /* get uid */ + sapi_lsapi_getenv, /* getenv */ - php_error, /* error handler */ + php_error, /* error handler */ - NULL, /* header handler */ - sapi_lsapi_send_headers, /* send headers handler */ - NULL, /* send header handler */ + NULL, /* header handler */ + sapi_lsapi_send_headers, /* send headers handler */ + NULL, /* send header handler */ - sapi_lsapi_read_post, /* read POST data */ - sapi_lsapi_read_cookies, /* read Cookies */ + sapi_lsapi_read_post, /* read POST data */ + sapi_lsapi_read_cookies, /* read Cookies */ - sapi_lsapi_register_variables, /* register server variables */ - sapi_lsapi_log_message, /* Log message */ + sapi_lsapi_register_variables, /* register server variables */ + sapi_lsapi_log_message, /* Log message */ - NULL, /* php.ini path override */ - NULL, /* block interruptions */ - NULL, /* unblock interruptions */ - NULL, /* default post reader */ - NULL, /* treat data */ - NULL, /* executable location */ + NULL, /* php.ini path override */ + NULL, /* block interruptions */ + NULL, /* unblock interruptions */ + NULL, /* default post reader */ + NULL, /* treat data */ + NULL, /* executable location */ - 0, /* php.ini ignore */ + 0, /* php.ini ignore */ - STANDARD_SAPI_MODULE_PROPERTIES + STANDARD_SAPI_MODULE_PROPERTIES }; /* }}} */ static int init_request_info( TSRMLS_D ) { - char * pContentType = LSAPI_GetHeader( H_CONTENT_TYPE ); - char * pAuth; - - SG(request_info).content_type = pContentType ? pContentType : ""; - SG(request_info).request_method = LSAPI_GetRequestMethod(); - SG(request_info).query_string = LSAPI_GetQueryString(); - SG(request_info).request_uri = LSAPI_GetScriptName(); - SG(request_info).content_length = LSAPI_GetReqBodyLen(); - SG(request_info).path_translated = estrdup( LSAPI_GetScriptFileName()); - - /* It is not reset by zend engine, set it to 0. */ - SG(sapi_headers).http_response_code = 0; - - pAuth = LSAPI_GetHeader( H_AUTHORIZATION ); - php_handle_auth_data(pAuth TSRMLS_CC); -} - -static char s_cur_chdir[4096] = ""; + char * pContentType = LSAPI_GetHeader( H_CONTENT_TYPE ); + char * pAuth; + + SG(request_info).content_type = pContentType ? pContentType : ""; + SG(request_info).request_method = LSAPI_GetRequestMethod(); + SG(request_info).query_string = LSAPI_GetQueryString(); + SG(request_info).request_uri = LSAPI_GetScriptName(); + SG(request_info).content_length = LSAPI_GetReqBodyLen(); + SG(request_info).path_translated = LSAPI_GetScriptFileName(); -static int lsapi_chdir_primary_script( zend_file_handle * file_handle ) -{ -#if PHP_MAJOR_VERSION > 4 - char * p; - char ch; - - SG(options) |= SAPI_OPTION_NO_CHDIR; - getcwd( s_cur_chdir, sizeof( s_cur_chdir ) ); - - p = strrchr( file_handle->filename, '/' ); - if ( *p ) - { - *p = 0; - if ( strcmp( file_handle->filename, s_cur_chdir ) != 0 ) { - chdir( file_handle->filename ); - } - *p++ = '/'; - ch = *p; - *p = 0; - if ( !CWDG(cwd).cwd || - ( strcmp( file_handle->filename, CWDG(cwd).cwd ) != 0 ) ) { - CWDG(cwd).cwd_length = p - file_handle->filename; - CWDG(cwd).cwd = (char *) realloc(CWDG(cwd).cwd, CWDG(cwd).cwd_length+1); - memmove( CWDG(cwd).cwd, file_handle->filename, CWDG(cwd).cwd_length+1 ); - } - *p = ch; - } - /* virtual_file_ex(&CWDG(cwd), file_handle->filename, NULL, CWD_REALPATH); */ -#else - VCWD_CHDIR_FILE( file_handle->filename ); -#endif - return 0; -} - -static int lsapi_fopen_primary_script( zend_file_handle * file_handle ) -{ - FILE * fp; - char * p; - fp = fopen( SG(request_info).path_translated, "rb" ); - if ( !fp ) - { - return -1; - } - file_handle->type = ZEND_HANDLE_FP; - file_handle->handle.fp = fp; - file_handle->filename = SG(request_info).path_translated; - file_handle->free_filename = 0; - file_handle->opened_path = NULL; - - lsapi_chdir_primary_script( file_handle ); - - return 0; + /* It is not reset by zend engine, set it to 0. */ + SG(sapi_headers).http_response_code = 0; + + pAuth = LSAPI_GetHeader( H_AUTHORIZATION ); + php_handle_auth_data(pAuth TSRMLS_CC); } -static int lsapi_execute_script( zend_file_handle * file_handle TSRMLS_DC) +static int lsapi_module_main(int show_source TSRMLS_DC) { - char *p; - int len; - file_handle->type = ZEND_HANDLE_FILENAME; - file_handle->handle.fd = 0; - file_handle->filename = SG(request_info).path_translated; - file_handle->free_filename = 0; - file_handle->opened_path = NULL; - - p = argv0; - *p++ = ':'; - len = strlen( SG(request_info).path_translated ); - if ( len > 45 ) - len = len - 45; - else - len = 0; - memccpy( p, SG(request_info).path_translated + len, 0, 46 ); - - php_execute_script(file_handle TSRMLS_CC); - return 0; + zend_file_handle file_handle = {0}; -} + if (php_request_startup(TSRMLS_C) == FAILURE ) { + return -1; + } + if (show_source) { + zend_syntax_highlighter_ini syntax_highlighter_ini; + php_get_highlight_struct(&syntax_highlighter_ini); + highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC); + } else { + file_handle.type = ZEND_HANDLE_FILENAME; + file_handle.handle.fd = 0; + file_handle.filename = SG(request_info).path_translated; + file_handle.free_filename = 0; + file_handle.opened_path = NULL; -static int lsapi_module_main(int show_source TSRMLS_DC) -{ - zend_file_handle file_handle = {0}; - - if (php_request_startup(TSRMLS_C) == FAILURE ) { - return -1; - } - if (show_source) { - zend_syntax_highlighter_ini syntax_highlighter_ini; - - php_get_highlight_struct(&syntax_highlighter_ini); - highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC); - } else { - lsapi_execute_script( &file_handle TSRMLS_CC); - } - zend_try { - php_request_shutdown(NULL); - *argv0 = 0; - } zend_end_try(); - return 0; + php_execute_script(&file_handle TSRMLS_CC); + } + zend_try { + php_request_shutdown(NULL); + } zend_end_try(); + return 0; } static int alter_ini( const char * pKey, int keyLen, const char * pValue, int valLen, - void * arg ) + void * arg ) { - int type = ZEND_INI_PERDIR; - if ( '\001' == *pKey ) { - ++pKey; - if ( *pKey == 4 ) { - type = ZEND_INI_SYSTEM; - } - ++pKey; - --keyLen; - if (( keyLen == 7 )&&( strncasecmp( pKey, "engine", 6 )== 0 )) - { - if ( *pValue == '0' ) - engine = 0; - } - else - zend_alter_ini_entry((char *)pKey, keyLen, - (char *)pValue, valLen, - type, PHP_INI_STAGE_ACTIVATE); - } - return 1; + int type = ZEND_INI_PERDIR; + if ( '\001' == *pKey ) { + ++pKey; + if ( *pKey == 4 ) { + type = ZEND_INI_SYSTEM; + } + ++pKey; + --keyLen; + zend_alter_ini_entry((char *)pKey, keyLen, + (char *)pValue, valLen, + type, PHP_INI_STAGE_ACTIVATE); + } + return 1; } static void override_ini() { - LSAPI_ForeachSpecialEnv( alter_ini, NULL ); + LSAPI_ForeachSpecialEnv( alter_ini, NULL ); } static int processReq( TSRMLS_D ) { - int ret = 0; - zend_first_try { - /* avoid server_context==NULL checks */ - SG(server_context) = (void *) 1; - - engine = 1; - override_ini(); - - if ( engine ) { - init_request_info( TSRMLS_C ); - - if ( lsapi_module_main( source_highlight TSRMLS_CC ) == -1 ) { - ret = -1; - } - } else { - LSAPI_AppendRespHeader( "status: 403", 11 ); - LSAPI_AppendRespHeader( "content-type: text/html", 23 ); - LSAPI_Write( "Forbidden: PHP engine is disable.\n", 34 ); - } - } zend_end_try(); - return ret; + int ret = 0; + zend_first_try { + /* avoid server_context==NULL checks */ + SG(server_context) = (void *) 1; + + init_request_info( TSRMLS_C ); + + override_ini(); + + if ( lsapi_module_main( source_highlight TSRMLS_CC ) == -1 ) { + ret = -1; + } + } zend_end_try(); + return ret; } static void cli_usage( TSRMLS_D ) { - static const char * usage = - "Usage: php\n" - " php -[b|c|h|i|q|s|v|?] [] [args...]\n" - " Run in LSAPI mode, only '-b', '-s' and '-c' are effective\n" - " Run in Command Line Interpreter mode when parameters are specified\n" - "\n" - " -b | Bind Path for external LSAPI Server mode\n" - " -c | Look for php.ini file in this directory\n" - " -h This help\n" - " -i PHP information\n" - " -q Quiet-mode. Suppress HTTP Header output.\n" - " -s Display colour syntax highlighted source.\n" - " -v Version number\n" - " -? This help\n" - "\n" - " args... Arguments passed to script.\n"; - php_output_startup(); - php_output_activate(TSRMLS_C); - php_printf( "%s", usage ); + static const char * usage = + "Usage: php\n" + " php -[b|c|h|i|q|s|v|?] [] [args...]\n" + " Run in LSAPI mode, only '-b', '-s' and '-c' are effective\n" + " Run in Command Line Interpreter mode when parameters are specified\n" + "\n" + " -b | Bind Path for external LSAPI Server mode\n" + " -c | Look for php.ini file in this directory\n" + " -h This help\n" + " -i PHP information\n" + " -q Quiet-mode. Suppress HTTP Header output.\n" + " -s Display colour syntax highlighted source.\n" + " -v Version number\n" + " -? This help\n" + "\n" + " args... Arguments passed to script.\n"; + php_output_startup(); + php_output_activate(TSRMLS_C); + php_printf( "%s", usage ); #ifdef PHP_OUTPUT_NEWAPI php_output_end_all(TSRMLS_C); #else @@ -612,250 +440,250 @@ static void cli_usage( TSRMLS_D ) } static int parse_opt( int argc, char * argv[], int *climode, - char **php_ini_path, char ** php_bind ) -{ - char ** p = &argv[1]; - char ** argend= &argv[argc]; - int c; - while (( p < argend )&&(**p == '-' )) { - c = *((*p)+1); - ++p; - switch( c ) { - case 'b': - if ( p >= argend ) { - fprintf( stderr, "TCP or socket address must be specified following '-b' option.\n"); - return -1; - } - *php_bind = *p++; - break; - - case 'c': - if ( p >= argend ) { - fprintf( stderr, " or must be specified following '-c' option.\n"); - - return -1; - } - *php_ini_path = *p++; - break; - case 's': - source_highlight = 1; - break; - case 'h': - case 'i': - case 'q': - case 'v': - case '?': - default: - *climode = 1; - break; - } - } - if ( p - argv < argc ) { - *climode = 1; - } - return 0; + char **php_ini_path, char ** php_bind ) +{ + char ** p = &argv[1]; + char ** argend= &argv[argc]; + int c; + while (( p < argend )&&(**p == '-' )) { + c = *((*p)+1); + ++p; + switch( c ) { + case 'b': + if ( p >= argend ) { + fprintf( stderr, "TCP or socket address must be specified following '-b' option.\n"); + return -1; + } + *php_bind = *p++; + break; + + case 'c': + if ( p >= argend ) { + fprintf( stderr, " or must be specified following '-c' option.\n"); + + return -1; + } + *php_ini_path = *p++; + break; + case 's': + source_highlight = 1; + break; + case 'h': + case 'i': + case 'q': + case 'v': + case '?': + default: + *climode = 1; + break; + } + } + if ( p - argv < argc ) { + *climode = 1; + } + return 0; } static int cli_main( int argc, char * argv[] ) { - static const char * ini_defaults[] = { - "report_zend_debug", "0", - "display_errors", "1", - "register_argc_argv", "1", - "html_errors", "0", - "implicit_flush", "1", - "output_buffering", "0", - "max_execution_time", "0", - "max_input_time", "-1", - NULL - }; - - const char ** ini; - char ** p = &argv[1]; - char ** argend= &argv[argc]; - int ret = 0; - int c; - lsapi_mode = 0; /* enter CLI mode */ + static const char * ini_defaults[] = { + "report_zend_debug", "0", + "display_errors", "1", + "register_argc_argv", "1", + "html_errors", "0", + "implicit_flush", "1", + "output_buffering", "0", + "max_execution_time", "0", + "max_input_time", "-1", + NULL + }; + + const char ** ini; + char ** p = &argv[1]; + char ** argend= &argv[argc]; + int ret = 0; + int c; + lsapi_mode = 0; /* enter CLI mode */ #ifdef PHP_WIN32 - _fmode = _O_BINARY; /*sets default for file streams to binary */ - setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */ - setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */ - setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */ + _fmode = _O_BINARY; /*sets default for file streams to binary */ + setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */ + setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */ + setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */ #endif - zend_first_try { - SG(server_context) = (void *) 1; - - zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */ - CG(in_compilation) = 0; /* not initialized but needed for several options */ - EG(uninitialized_zval_ptr) = NULL; - - for( ini = ini_defaults; *ini; ini+=2 ) { - zend_alter_ini_entry( (char *)*ini, strlen( *ini )+1, - (char *)*(ini+1), strlen( *(ini+1) ), - PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); - } - - while (( p < argend )&&(**p == '-' )) { - c = *((*p)+1); - ++p; - switch( c ) { - case 'q': - break; - case 'i': - if (php_request_startup(TSRMLS_C) != FAILURE) { - php_print_info(0xFFFFFFFF TSRMLS_CC); + zend_first_try { + SG(server_context) = (void *) 1; + + zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */ + CG(in_compilation) = 0; /* not initialized but needed for several options */ + EG(uninitialized_zval_ptr) = NULL; + + for( ini = ini_defaults; *ini; ini+=2 ) { + zend_alter_ini_entry( (char *)*ini, strlen( *ini )+1, + (char *)*(ini+1), strlen( *(ini+1) ), + PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); + } + + while (( p < argend )&&(**p == '-' )) { + c = *((*p)+1); + ++p; + switch( c ) { + case 'q': + break; + case 'i': + if (php_request_startup(TSRMLS_C) != FAILURE) { + php_print_info(0xFFFFFFFF TSRMLS_CC); #ifdef PHP_OUTPUT_NEWAPI php_output_end_all(TSRMLS_C); #else php_end_ob_buffers(1 TSRMLS_CC); #endif - php_request_shutdown( NULL ); - } - ret = 1; - break; - case 'v': - if (php_request_startup(TSRMLS_C) != FAILURE) { + php_request_shutdown( NULL ); + } + ret = 1; + break; + case 'v': + if (php_request_startup(TSRMLS_C) != FAILURE) { #if ZEND_DEBUG - php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2013 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2013 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #else - php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2013 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2013 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #endif #ifdef PHP_OUTPUT_NEWAPI php_output_end_all(TSRMLS_C); #else php_end_ob_buffers(1 TSRMLS_CC); #endif - php_request_shutdown( NULL ); - } - ret = 1; - break; - case 'c': - ++p; - /* fall through */ - case 's': - break; - - case 'h': - case '?': - default: - cli_usage(TSRMLS_C); - ret = 1; - break; - - } - } - if ( !ret ) { - if ( *p ) { - zend_file_handle file_handle = {0}; - - file_handle.type = ZEND_HANDLE_FP; - file_handle.handle.fp = VCWD_FOPEN(*p, "rb"); - - if ( file_handle.handle.fp ) { - script_filename = *p; - php_self = *p; - - SG(request_info).path_translated = estrdup(*p); - SG(request_info).argc = argc - (p - argv); - SG(request_info).argv = p; - - if (php_request_startup(TSRMLS_C) == FAILURE ) { - fclose( file_handle.handle.fp ); - ret = 2; - } else { - if (source_highlight) { - zend_syntax_highlighter_ini syntax_highlighter_ini; - - php_get_highlight_struct(&syntax_highlighter_ini); - highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC); - } else { - file_handle.filename = *p; - file_handle.free_filename = 0; - file_handle.opened_path = NULL; - - php_execute_script(&file_handle TSRMLS_CC); - } - - php_request_shutdown( NULL ); - } - } else { - php_printf("Could not open input file: %s.\n", *p); - } - } else { - cli_usage(TSRMLS_C); - } - } - - }zend_end_try(); - - php_module_shutdown(TSRMLS_C); + php_request_shutdown( NULL ); + } + ret = 1; + break; + case 'c': + ++p; + /* fall through */ + case 's': + break; + + case 'h': + case '?': + default: + cli_usage(TSRMLS_C); + ret = 1; + break; + + } + } + if ( !ret ) { + if ( *p ) { + zend_file_handle file_handle = {0}; + + file_handle.type = ZEND_HANDLE_FP; + file_handle.handle.fp = VCWD_FOPEN(*p, "rb"); + + if ( file_handle.handle.fp ) { + script_filename = *p; + php_self = *p; + + SG(request_info).path_translated = *p; + SG(request_info).argc = argc - (p - argv); + SG(request_info).argv = p; + + if (php_request_startup(TSRMLS_C) == FAILURE ) { + fclose( file_handle.handle.fp ); + ret = 2; + } else { + if (source_highlight) { + zend_syntax_highlighter_ini syntax_highlighter_ini; + + php_get_highlight_struct(&syntax_highlighter_ini); + highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC); + } else { + file_handle.filename = *p; + file_handle.free_filename = 0; + file_handle.opened_path = NULL; + + php_execute_script(&file_handle TSRMLS_CC); + } + + php_request_shutdown( NULL ); + } + } else { + php_printf("Could not open input file: %s.\n", *p); + } + } else { + cli_usage(TSRMLS_C); + } + } + + }zend_end_try(); + + php_module_shutdown(TSRMLS_C); #ifdef ZTS - tsrm_shutdown(); + tsrm_shutdown(); #endif - return ret; + return ret; } static int s_stop; void litespeed_cleanup(int signal) { - s_stop = signal; + s_stop = signal; } void start_children( int children ) { - struct sigaction act, old_term, old_quit, old_int, old_usr1; - int running = 0; - int status; - pid_t pid; - - /* Create a process group */ - setsid(); - - /* Set up handler to kill children upon exit */ - act.sa_flags = 0; - act.sa_handler = litespeed_cleanup; - if( sigaction( SIGTERM, &act, &old_term ) || - sigaction( SIGINT, &act, &old_int ) || - sigaction( SIGUSR1, &act, &old_usr1 ) || - sigaction( SIGQUIT, &act, &old_quit )) { - perror( "Can't set signals" ); - exit( 1 ); - } - s_stop = 0; - while( 1 ) { - while((!s_stop )&&( running < children )) { - pid = fork(); - switch( pid ) { - case 0: /* children process */ - - /* don't catch our signals */ - sigaction( SIGTERM, &old_term, 0 ); - sigaction( SIGQUIT, &old_quit, 0 ); - sigaction( SIGINT, &old_int, 0 ); - sigaction( SIGUSR1, &old_usr1, 0 ); - return ; - case -1: - perror( "php (pre-forking)" ); - exit( 1 ); - break; - default: /* parent process */ - running++; - break; - } - } - if ( s_stop ) { - break; - } - pid = wait( &status ); - running--; - } - kill( -getpgrp(), SIGUSR1 ); - exit( 0 ); + struct sigaction act, old_term, old_quit, old_int, old_usr1; + int running = 0; + int status; + pid_t pid; + + /* Create a process group */ + setsid(); + + /* Set up handler to kill children upon exit */ + act.sa_flags = 0; + act.sa_handler = litespeed_cleanup; + if( sigaction( SIGTERM, &act, &old_term ) || + sigaction( SIGINT, &act, &old_int ) || + sigaction( SIGUSR1, &act, &old_usr1 ) || + sigaction( SIGQUIT, &act, &old_quit )) { + perror( "Can't set signals" ); + exit( 1 ); + } + s_stop = 0; + while( 1 ) { + while((!s_stop )&&( running < children )) { + pid = fork(); + switch( pid ) { + case 0: /* children process */ + + /* don't catch our signals */ + sigaction( SIGTERM, &old_term, 0 ); + sigaction( SIGQUIT, &old_quit, 0 ); + sigaction( SIGINT, &old_int, 0 ); + sigaction( SIGUSR1, &old_usr1, 0 ); + return ; + case -1: + perror( "php (pre-forking)" ); + exit( 1 ); + break; + default: /* parent process */ + running++; + break; + } + } + if ( s_stop ) { + break; + } + pid = wait( &status ); + running--; + } + kill( -getpgrp(), SIGUSR1 ); + exit( 0 ); } @@ -863,185 +691,153 @@ void start_children( int children ) #include int main( int argc, char * argv[] ) { - int ret; - int bindFd; - - char * php_ini_path = NULL; - char * php_bind = NULL; - char * p; - int n; - int climode = 0; - struct timeval tv_req_begin; - struct timeval tv_req_end; - int slow_script_msec = 0; - char time_buf[40]; - + int ret; + int bindFd; + + char * php_ini_path = NULL; + char * php_bind = NULL; + char * p; + int n; + int climode = 0; + #ifdef HAVE_SIGNAL_H #if defined(SIGPIPE) && defined(SIG_IGN) - signal(SIGPIPE, SIG_IGN); + signal(SIGPIPE, SIG_IGN); #endif #endif #ifdef ZTS - tsrm_startup(1, 1, 0, NULL); + tsrm_startup(1, 1, 0, NULL); #endif - if (argc > 1 ) { - if ( parse_opt( argc, argv, &climode, - &php_ini_path, &php_bind ) == -1 ) { - return 1; - } - } - if ( climode ) { - lsapi_sapi_module.phpinfo_as_text = 1; - } - argv0 = argv[0] + strlen( argv[0] ); - sapi_startup(&lsapi_sapi_module); + if (argc > 1 ) { + if ( parse_opt( argc, argv, &climode, + &php_ini_path, &php_bind ) == -1 ) { + return 1; + } + } + if ( climode ) { + lsapi_sapi_module.phpinfo_as_text = 1; + } + sapi_startup(&lsapi_sapi_module); #ifdef ZTS - compiler_globals = ts_resource(compiler_globals_id); - executor_globals = ts_resource(executor_globals_id); - core_globals = ts_resource(core_globals_id); - sapi_globals = ts_resource(sapi_globals_id); - tsrm_ls = ts_resource(0); + compiler_globals = ts_resource(compiler_globals_id); + executor_globals = ts_resource(executor_globals_id); + core_globals = ts_resource(core_globals_id); + sapi_globals = ts_resource(sapi_globals_id); + tsrm_ls = ts_resource(0); - SG(request_info).path_translated = NULL; + SG(request_info).path_translated = NULL; #endif - lsapi_sapi_module.executable_location = argv[0]; - - if ( php_ini_path ) { - lsapi_sapi_module.php_ini_path_override = php_ini_path; - } + lsapi_sapi_module.executable_location = argv[0]; + if ( php_ini_path ) { + lsapi_sapi_module.php_ini_path_override = php_ini_path; + } - lsapi_sapi_module.ini_defaults = sapi_lsapi_ini_defaults; - - if (php_module_startup(&lsapi_sapi_module, &litespeed_module_entry, 1) == FAILURE) { + if (php_module_startup(&lsapi_sapi_module, &litespeed_module_entry, 1) == FAILURE) { #ifdef ZTS - tsrm_shutdown(); + tsrm_shutdown(); #endif - return FAILURE; - } - - if ( climode ) { - return cli_main(argc, argv); - } - - if ( php_bind ) { - bindFd = LSAPI_CreateListenSock( php_bind, 10 ); - if ( bindFd == -1 ) { - fprintf( stderr, - "Failed to bind socket [%s]: %s\n", php_bind, strerror( errno ) ); - exit( 2 ); - } - if ( bindFd != 0 ) { - dup2( bindFd, 0 ); - close( bindFd ); - } - } - - LSAPI_Init(); + return FAILURE; + } + + if ( climode ) { + return cli_main(argc, argv); + } + + + if ( php_bind ) { + bindFd = LSAPI_CreateListenSock( php_bind, 10 ); + if ( bindFd == -1 ) { + fprintf( stderr, + "Failed to bind socket [%s]: %s\n", php_bind, strerror( errno ) ); + exit( 2 ); + } + if ( bindFd != 0 ) { + dup2( bindFd, 0 ); + close( bindFd ); + } + } + + LSAPI_Init(); - LSAPI_Init_Env_Parameters( NULL ); - - slow_script_msec = LSAPI_Get_Slow_Req_Msecs(); - - if ( php_bind ) { - LSAPI_No_Check_ppid(); - } - - while( LSAPI_Prefork_Accept_r( &g_req ) >= 0 ) { - if ( slow_script_msec ) { - gettimeofday( &tv_req_begin, NULL ); - } - ret = processReq(TSRMLS_C); - if ( slow_script_msec ) { - gettimeofday( &tv_req_end, NULL ); - n = ((long) tv_req_end.tv_sec - tv_req_begin.tv_sec ) * 1000 - + (tv_req_end.tv_usec - tv_req_begin.tv_usec) / 1000; - if ( n > slow_script_msec ) - { - strftime( time_buf, 30, "%d/%b/%Y:%H:%M:%S", localtime( &tv_req_end.tv_sec ) ); - fprintf( stderr, "[%s] Slow PHP script: %d ms\n URL: %s %s\n Query String: %s\n Script: %s\n", - time_buf, n, LSAPI_GetRequestMethod(), - LSAPI_GetScriptName(), LSAPI_GetQueryString(), - LSAPI_GetScriptFileName() ); - - } - } - LSAPI_Finish(); - if ( ret ) { - break; - } - } - php_module_shutdown(TSRMLS_C); + LSAPI_Init_Env_Parameters( NULL ); + + if ( php_bind ) { + LSAPI_No_Check_ppid(); + } + + while( LSAPI_Prefork_Accept_r( &g_req ) >= 0 ) { + ret = processReq(TSRMLS_C); + LSAPI_Finish(); + if ( ret ) { + break; + } + } + php_module_shutdown(TSRMLS_C); #ifdef ZTS - tsrm_shutdown(); + tsrm_shutdown(); #endif - return ret; + return ret; } /* LiteSpeed PHP module starts here */ -#if PHP_MAJOR_VERSION > 4 - /* {{{ arginfo */ ZEND_BEGIN_ARG_INFO(arginfo_litespeed__void, 0) ZEND_END_ARG_INFO() /* }}} */ -#else -#define arginfo_litespeed__void NULL -#endif - PHP_FUNCTION(litespeed_request_headers); PHP_FUNCTION(litespeed_response_headers); PHP_MINFO_FUNCTION(litespeed); zend_function_entry litespeed_functions[] = { - PHP_FE(litespeed_request_headers, arginfo_litespeed__void) - PHP_FE(litespeed_response_headers, arginfo_litespeed__void) - PHP_FALIAS(getallheaders, litespeed_request_headers, arginfo_litespeed__void) - PHP_FALIAS(apache_request_headers, litespeed_request_headers, arginfo_litespeed__void) - PHP_FALIAS(apache_response_headers, litespeed_response_headers, arginfo_litespeed__void) - {NULL, NULL, NULL} + PHP_FE(litespeed_request_headers, arginfo_litespeed__void) + PHP_FE(litespeed_response_headers, arginfo_litespeed__void) + PHP_FALIAS(getallheaders, litespeed_request_headers, arginfo_litespeed__void) + PHP_FALIAS(apache_request_headers, litespeed_request_headers, arginfo_litespeed__void) + PHP_FALIAS(apache_response_headers, litespeed_response_headers, arginfo_litespeed__void) + {NULL, NULL, NULL} }; static PHP_MINIT_FUNCTION(litespeed) { - /* REGISTER_INI_ENTRIES(); */ - return SUCCESS; + /* REGISTER_INI_ENTRIES(); */ + return SUCCESS; } static PHP_MSHUTDOWN_FUNCTION(litespeed) { - /* UNREGISTER_INI_ENTRIES(); */ - return SUCCESS; + /* UNREGISTER_INI_ENTRIES(); */ + return SUCCESS; } zend_module_entry litespeed_module_entry = { - STANDARD_MODULE_HEADER, - "litespeed", - litespeed_functions, - PHP_MINIT(litespeed), - PHP_MSHUTDOWN(litespeed), - NULL, - NULL, - NULL, - NO_VERSION_YET, - STANDARD_MODULE_PROPERTIES + STANDARD_MODULE_HEADER, + "litespeed", + litespeed_functions, + PHP_MINIT(litespeed), + PHP_MSHUTDOWN(litespeed), + NULL, + NULL, + NULL, + NO_VERSION_YET, + STANDARD_MODULE_PROPERTIES }; static int add_associate_array( const char * pKey, int keyLen, const char * pValue, int valLen, - void * arg ) + void * arg ) { - add_assoc_string_ex( (zval *)arg, (char *)pKey, keyLen+1, (char *)pValue, 1 ); - return 1; + add_assoc_string_ex( (zval *)arg, (char *)pKey, keyLen+1, (char *)pValue, 1 ); + return 1; } @@ -1049,14 +845,13 @@ static int add_associate_array( const char * pKey, int keyLen, const char * pVal Fetch all HTTP request headers */ PHP_FUNCTION(litespeed_request_headers) { - /* TODO: */ - if (ZEND_NUM_ARGS() > 0) { - WRONG_PARAM_COUNT; - } - array_init(return_value); + /* TODO: */ + if (ZEND_NUM_ARGS() > 0) { + WRONG_PARAM_COUNT; + } + array_init(return_value); - if ( lsapi_mode ) - LSAPI_ForeachOrgHeader( add_associate_array, return_value ); + LSAPI_ForeachOrgHeader( add_associate_array, return_value ); } /* }}} */ @@ -1067,40 +862,40 @@ PHP_FUNCTION(litespeed_request_headers) Fetch all HTTP response headers */ PHP_FUNCTION(litespeed_response_headers) { - sapi_header_struct *h; - zend_llist_position pos; - char * p; - int len; - char headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH]; - - if (ZEND_NUM_ARGS() > 0) { - WRONG_PARAM_COUNT; - } - - if (!&SG(sapi_headers).headers) { - RETURN_FALSE; - } - array_init(return_value); - - h = zend_llist_get_first_ex(&SG(sapi_headers).headers, &pos); - while (h) { - if ( h->header_len > 0 ) { - p = strchr( h->header, ':' ); - len = p - h->header; - if (( p )&&( len > 0 )) { - memmove( headerBuf, h->header, len ); - while( len > 0 && (isspace( headerBuf[len-1])) ) { - --len; - } - headerBuf[len] = 0; - if ( len ) { - while( isspace(*++p)); - add_assoc_string_ex(return_value, headerBuf, len+1, p, 1 ); - } - } - } - h = zend_llist_get_next_ex(&SG(sapi_headers).headers, &pos); - } + sapi_header_struct *h; + zend_llist_position pos; + char * p; + int len; + char headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH]; + + if (ZEND_NUM_ARGS() > 0) { + WRONG_PARAM_COUNT; + } + + if (!&SG(sapi_headers).headers) { + RETURN_FALSE; + } + array_init(return_value); + + h = zend_llist_get_first_ex(&SG(sapi_headers).headers, &pos); + while (h) { + if ( h->header_len > 0 ) { + p = strchr( h->header, ':' ); + len = p - h->header; + if (( p )&&( len > 0 )) { + memmove( headerBuf, h->header, len ); + while( len > 0 && (isspace( headerBuf[len-1])) ) { + --len; + } + headerBuf[len] = 0; + if ( len ) { + while( isspace(*++p)); + add_assoc_string_ex(return_value, headerBuf, len+1, p, 1 ); + } + } + } + h = zend_llist_get_next_ex(&SG(sapi_headers).headers, &pos); + } } /* }}} */ diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c index 10ea74981a72c..3a13000e11f28 100644 --- a/sapi/litespeed/lsapilib.c +++ b/sapi/litespeed/lsapilib.c @@ -86,7 +86,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. static int g_inited = 0; static int g_running = 1; static int s_ppid; -static int s_slow_req_msecs = 0; LSAPI_Request g_req = { -1, -1 }; void Flush_RespBuf_r( LSAPI_Request * pReq ); @@ -508,13 +507,11 @@ static int parseRequest( LSAPI_Request * pReq, int totalLen ) return 0; } -static int s_accept_notify = 0; - static struct lsapi_packet_header ack = {'L', 'S', LSAPI_REQ_RECEIVED, LSAPI_ENDIAN, {LSAPI_PACKET_HEADER_LEN} }; -static inline int notify_req_received( int fd ) +static inline int notify_req_received( LSAPI_Request * pReq ) { - if ( write( fd, &ack, LSAPI_PACKET_HEADER_LEN ) + if ( write( pReq->m_fd, &ack, LSAPI_PACKET_HEADER_LEN ) < LSAPI_PACKET_HEADER_LEN ) { return -1; } @@ -570,10 +567,7 @@ static int readReq( LSAPI_Request * pReq ) pReq->m_bufProcessed = packetLen; pReq->m_reqState = LSAPI_ST_REQ_BODY | LSAPI_ST_RESP_HEADER; - if ( !s_accept_notify ) - return notify_req_received( pReq->m_fd ); - else - return 0; + return notify_req_received( pReq ); } @@ -683,10 +677,6 @@ int LSAPI_Accept_r( LSAPI_Request * pReq ) setsockopt(pReq->m_fd, IPPROTO_TCP, TCP_NODELAY, (char *)&nodelay, sizeof(nodelay)); } - - if ( s_accept_notify ) - return notify_req_received( pReq->m_fd ); - } } else { return -1; @@ -1249,13 +1239,12 @@ int LSAPI_ForeachHeader_r( LSAPI_Request * pReq, while( pCur < pEnd ) { pKey = pReq->m_pHttpHeader + pCur->nameOff; keyLen = pCur->nameLen; - if ( keyLen > 250 ) { - keyLen = 250; - } - pKeyEnd = pKey + keyLen; memcpy( achHeaderName, "HTTP_", 5 ); p = &achHeaderName[5]; + if ( keyLen > 250 ) { + keyLen = 250; + } while( pKey < pKeyEnd ) { char ch = *pKey++; @@ -1640,9 +1629,6 @@ static int lsapi_accept( int fdListen ) setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, (char *)&nodelay, sizeof(nodelay)); } - - if ( s_accept_notify ) - notify_req_received( fd ); } return fd; @@ -2087,15 +2073,6 @@ void LSAPI_Set_Server_Max_Idle_Secs( int serverMaxIdle ) } } -void LSAPI_Set_Slow_Req_Msecs( int msecs ) -{ - s_slow_req_msecs = msecs; -} - -int LSAPI_Get_Slow_Req_Msecs() -{ - return s_slow_req_msecs; -} void LSAPI_No_Check_ppid() { @@ -2149,18 +2126,6 @@ void LSAPI_Init_Env_Parameters( fn_select_t fp ) avoidFork = atoi( p ); } - p = getenv( "LSAPI_ACCEPT_NOTIFY" ); - if ( p ) { - s_accept_notify = atoi( p ); - } - - p = getenv( "LSAPI_SLOW_REQ_MSECS" ); - if ( p ) { - n = atoi( p ); - LSAPI_Set_Slow_Req_Msecs( n ); - } - - #if defined( RLIMIT_CORE ) p = getenv( "LSAPI_ALLOW_CORE_DUMP" ); if ( !p ) { diff --git a/sapi/litespeed/lsapilib.h b/sapi/litespeed/lsapilib.h index 3a987b4064c11..538a170b44cd8 100644 --- a/sapi/litespeed/lsapilib.h +++ b/sapi/litespeed/lsapilib.h @@ -343,11 +343,6 @@ void LSAPI_Set_Max_Process_Time( int secs ); void LSAPI_Init_Env_Parameters( fn_select_t fp ); -void LSAPI_Set_Slow_Req_Msecs( int msecs ); - -int LSAPI_Get_Slow_Req_Msecs( ); - - #if defined (c_plusplus) || defined (__cplusplus) } #endif diff --git a/server-tests.php b/server-tests.php index 051a1cfa0819e..ca39b198b8c8b 100755 --- a/server-tests.php +++ b/server-tests.php @@ -138,7 +138,7 @@ function generate_diff($wanted,$output) } function mkpath($path,$mode = 0777) { - $dirs = split('[\\/]',$path); + $dirs = preg_split('/[\\/]/',$path); $path = $dirs[0]; for($i = 1;$i < count($dirs);$i++) { $path .= '/'.$dirs[$i]; @@ -358,7 +358,7 @@ function &_getRequest() return $this->outgoing_payload; } - function &_sendHTTP() + function _sendHTTP() { $this->_getRequest(); $host = $this->urlparts['host']; @@ -555,7 +555,7 @@ function getInstalledExtensions() { // get the list of installed extensions $out = $this->runscript(PHP_EXTENSIONS_SCRIPT,true); - $this->exts_to_test = split(":",$out); + $this->exts_to_test = explode(":",$out); sort($this->exts_to_test); $this->exts_tested = count($this->exts_to_test); } @@ -716,9 +716,9 @@ function setTestPaths() if (@$this->conf['TEST_PATHS']) { $this->test_dirs = array(); if ($this->iswin32) { - $paths = split(';',$this->conf['TEST_PATHS']); + $paths = explode(';',$this->conf['TEST_PATHS']); } else { - $paths = split(':|;',$this->conf['TEST_PATHS']); + $paths = explode(':|;',$this->conf['TEST_PATHS']); } foreach($paths as $path) { $this->test_dirs[] = realpath($path); @@ -1152,7 +1152,7 @@ function getSectionText($file) while (!feof($fp)) { $line = fgets($fp); // Match the beginning of a section. - if (ereg('^--([A-Z]+)--',$line,$r)) { + if (preg_match('/^--([A-Z]+)--/',$line,$r)) { $section = $r[1]; $section_text[$section] = ''; continue; @@ -1211,14 +1211,14 @@ function getSkipReason($file,&$section_text,$docgi=false) if (!$output) return NULL; if ($this->conf['TEST_PHP_DETAILED'] > 2) print "SKIPIF: [$output]\n"; - if (eregi("^skip", $output)){ + if (preg_match("/^skip/i", $output)){ - $reason = (ereg("^skip[[:space:]]*(.+)\$", $output)) ? ereg_replace("^skip[[:space:]]*(.+)\$", "\\1", $output) : FALSE; + $reason = (preg_match("/^skip\s*(.+)\$/", $output)) ? preg_replace("/^skip\s*(.+)\$/", "\\1", $output) : FALSE; $this->showstatus($section_text['TEST'], 'SKIPPED', $reason); return 'SKIPPED'; } - if (eregi("^info", $output)) { - $reason = (ereg("^info[[:space:]]*(.+)\$", $output)) ? ereg_replace("^info[[:space:]]*(.+)\$", "\\1", $output) : FALSE; + if (preg_match("/^info/i", $output)) { + $reason = (preg_match("/^info\s*(.+)\$/", $output)) ? preg_replace("/^info\s*(.+)\$/", "\\1", $output) : FALSE; if ($reason) { $tested .= " (info: $reason)"; } @@ -1244,19 +1244,19 @@ function run_test($file) $tested = $section_text['TEST']." [$shortname]"; if ($this->conf['TEST_WEB']) { - $tmp_file = ereg_replace('\.phpt$','.'.$this->conf['TEST_WEB_EXT'],$file); + $tmp_file = preg_replace('/\.phpt$/','.'.$this->conf['TEST_WEB_EXT'],$file); $uri = $this->conf['TEST_BASE_SCRIPT_NAME'].str_replace($this->conf['TEST_BASE_PATH'], '', $tmp_file); $uri = str_replace('\\', '/', $uri); } else { - $tmp_file = ereg_replace('\.phpt$','.php',$file); + $tmp_file = preg_replace('/\.phpt$/','.php',$file); } @unlink($tmp_file); // unlink old test results - @unlink(ereg_replace('\.phpt$','.diff',$file)); - @unlink(ereg_replace('\.phpt$','.log',$file)); - @unlink(ereg_replace('\.phpt$','.exp',$file)); - @unlink(ereg_replace('\.phpt$','.out',$file)); + @unlink(preg_replace('/\.phpt$/','.diff',$file)); + @unlink(preg_replace('/\.phpt$/','.log',$file)); + @unlink(preg_replace('/\.phpt$/','.exp',$file)); + @unlink(preg_replace('/\.phpt$/','.out',$file)); if (!$this->conf['TEST_WEB']) { // Reset environment from any previous test. @@ -1425,15 +1425,68 @@ function run_test($file) } $wanted_re = preg_replace('/\r\n/',"\n",$wanted); if (isset($section_text['EXPECTF'])) { - $wanted_re = preg_quote($wanted_re, '/'); + // do preg_quote, but miss out any %r delimited sections + $temp = ""; + $r = "%r"; + $startOffset = 0; + $length = strlen($wanted_re); + while($startOffset < $length) { + $start = strpos($wanted_re, $r, $startOffset); + if ($start !== false) { + // we have found a start tag + $end = strpos($wanted_re, $r, $start+2); + if ($end === false) { + // unbalanced tag, ignore it. + $end = $start = $length; + } + } else { + // no more %r sections + $start = $end = $length; + } + // quote a non re portion of the string + $temp = $temp . preg_quote(substr($wanted_re, $startOffset, ($start - $startOffset)), '/'); + // add the re unquoted. + if ($end > $start) { + $temp = $temp . '(' . substr($wanted_re, $start+2, ($end - $start-2)). ')'; + } + $startOffset = $end + 2; + } + $wanted_re = $temp; + + $wanted_re = str_replace( + array('%binary_string_optional%'), + 'string', + $wanted_re + ); + $wanted_re = str_replace( + array('%unicode_string_optional%'), + 'string', + $wanted_re + ); + $wanted_re = str_replace( + array('%unicode\|string%', '%string\|unicode%'), + 'string', + $wanted_re + ); + $wanted_re = str_replace( + array('%u\|b%', '%b\|u%'), + '', + $wanted_re + ); // Stick to basics - $wanted_re = str_replace("%s", ".+?", $wanted_re); //not greedy - $wanted_re = str_replace("%i", "[+\-]?[0-9]+", $wanted_re); - $wanted_re = str_replace("%d", "[0-9]+", $wanted_re); - $wanted_re = str_replace("%x", "[0-9a-fA-F]+", $wanted_re); - $wanted_re = str_replace("%f", "[+\-]?\.?[0-9]+\.?[0-9]*(E-?[0-9]+)?", $wanted_re); - $wanted_re = str_replace("%c", ".", $wanted_re); + $wanted_re = str_replace('%e', '\\' . DIRECTORY_SEPARATOR, $wanted_re); + $wanted_re = str_replace('%s', '[^\r\n]+', $wanted_re); + $wanted_re = str_replace('%S', '[^\r\n]*', $wanted_re); + $wanted_re = str_replace('%a', '.+', $wanted_re); + $wanted_re = str_replace('%A', '.*', $wanted_re); + $wanted_re = str_replace('%w', '\s*', $wanted_re); + $wanted_re = str_replace('%i', '[+-]?\d+', $wanted_re); + $wanted_re = str_replace('%d', '\d+', $wanted_re); + $wanted_re = str_replace('%x', '[0-9a-fA-F]+', $wanted_re); + $wanted_re = str_replace('%f', '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', $wanted_re); + $wanted_re = str_replace('%c', '.', $wanted_re); // %f allows two points "-.0.0" but that is the best *simple* expression + } /* DEBUG YOUR REGEX HERE var_dump($wanted_re); @@ -1489,8 +1542,8 @@ function run_test($file) $this->failed_tests[] = array( 'name' => $file, 'test_name' => $tested, - 'output' => ereg_replace('\.phpt$','.log', $file), - 'diff' => ereg_replace('\.phpt$','.diff', $file) + 'output' => preg_replace('/\.phpt$/','.log', $file), + 'diff' => preg_replace('/\.phpt$/','.diff', $file) ); if ($this->conf['TEST_PHP_DETAILED']) @@ -1498,25 +1551,25 @@ function run_test($file) // write .exp if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'E') !== FALSE) { - $logname = ereg_replace('\.phpt$','.exp',$file); + $logname = preg_replace('/\.phpt$/','.exp',$file); file_put_contents($logname,$wanted); } // write .out if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'O') !== FALSE) { - $logname = ereg_replace('\.phpt$','.out',$file); + $logname = preg_replace('/\.phpt$/','.out',$file); file_put_contents($logname,$output); } // write .diff if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'D') !== FALSE) { - $logname = ereg_replace('\.phpt$','.diff',$file); + $logname = preg_replace('/\.phpt$/','.diff',$file); file_put_contents($logname,generate_diff($wanted,$output)); } // write .log if (strpos($this->conf['TEST_PHP_LOG_FORMAT'],'L') !== FALSE) { - $logname = ereg_replace('\.phpt$','.log',$file); + $logname = preg_replace('/\.phpt$/','.log',$file); file_put_contents($logname, "\n---- EXPECTED OUTPUT\n$wanted\n". "---- ACTUAL OUTPUT\n$output\n". diff --git a/tests/basic/php_egg_logo_guid.phpt b/tests/basic/php_egg_logo_guid.phpt deleted file mode 100644 index b3c5d7bdfd2e4..0000000000000 --- a/tests/basic/php_egg_logo_guid.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Testing php_egg_logo_guid() function ---FILE-- - ---EXPECT-- -PHPE9568F36-D428-11d2-A769-00AA001ACF42 - ---CREDITS-- -Jason Easter -PHPUG Würzburg -Testfest 2009 2009-06-20 \ No newline at end of file diff --git a/tests/basic/php_logo_guid.phpt b/tests/basic/php_logo_guid.phpt deleted file mode 100644 index b5724a96abe10..0000000000000 --- a/tests/basic/php_logo_guid.phpt +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -Testing php_logo_guid() function ---FILE-- - ---EXPECT-- -PHPE9568F34-D428-11d2-A769-00AA001ACF42 ---CREDITS-- -Testfest 2009 2009-06-20 \ No newline at end of file diff --git a/tests/basic/php_real_logo_guid.phpt b/tests/basic/php_real_logo_guid.phpt deleted file mode 100644 index 2b9003a35066f..0000000000000 --- a/tests/basic/php_real_logo_guid.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Testing php_real_logo_guid() function ---FILE-- - ---EXPECT-- -PHPE9568F34-D428-11d2-A769-00AA001ACF42 ---CREDITS-- -Jason Easter -PHPUG Würzburg -Testfest 2009 2009-06-20 \ No newline at end of file diff --git a/tests/basic/req60524.phpt b/tests/basic/req60524.phpt new file mode 100644 index 0000000000000..6803e1fd88bfe --- /dev/null +++ b/tests/basic/req60524.phpt @@ -0,0 +1,8 @@ +--TEST-- +Req #60524 (Specify temporary directory) +--INI-- +sys_temp_dir=/path/to/temp/dir +--FILE-- + +--EXPECT-- +/path/to/temp/dir diff --git a/tests/basic/zend_logo_guid.phpt b/tests/basic/zend_logo_guid.phpt deleted file mode 100644 index 23ca0165ae64a..0000000000000 --- a/tests/basic/zend_logo_guid.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Testing zend_logo_guid() function ---FILE-- - ---EXPECT-- -PHPE9568F35-D428-11d2-A769-00AA001ACF42 - ---CREDITS-- -Jason Easter -PHPUG Würzburg -Testfest 2009 2009-06-20 \ No newline at end of file diff --git a/tests/lang/bug24403.phpt b/tests/lang/bug24403.phpt index fe99257d3d3ae..8f4934e7b9ff8 100644 --- a/tests/lang/bug24403.phpt +++ b/tests/lang/bug24403.phpt @@ -17,4 +17,5 @@ class a } new a(); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in %s on line %d diff --git a/tests/lang/foreachLoop.007.phpt b/tests/lang/foreachLoop.007.phpt deleted file mode 100644 index f47fdc735fa36..0000000000000 --- a/tests/lang/foreachLoop.007.phpt +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -Foreach loop tests - error case: reference to constant array. ---FILE-- - ---EXPECTF-- -Parse error: %s on line 3 diff --git a/tests/lang/foreachLoop.008.phpt b/tests/lang/foreachLoop.008.phpt deleted file mode 100644 index 787f43b88375b..0000000000000 --- a/tests/lang/foreachLoop.008.phpt +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -Foreach loop tests - error case: reference to constant array, with key. ---FILE-- -&$v) { - var_dump($v); -} -?> ---EXPECTF-- -Fatal error: Cannot create references to elements of a temporary array expression in %s on line 2 diff --git a/travis/compile.sh b/travis/compile.sh new file mode 100755 index 0000000000000..b48bfe8e24eea --- /dev/null +++ b/travis/compile.sh @@ -0,0 +1,37 @@ +#!/bin/bash +./buildconf +./configure --quiet \ +--with-pdo-mysql \ +--with-mysql \ +--with-mysqli \ +--with-pgsql \ +--with-pdo-pgsql \ +--with-pdo-sqlite \ +--enable-intl \ +--without-pear \ +--with-gd \ +--with-jpeg-dir=/usr \ +--with-png-dir=/usr \ +--enable-exif \ +--enable-zip \ +--with-zlib \ +--with-zlib-dir=/usr \ +--with-mcrypt=/usr \ +--enable-soap \ +--enable-xmlreader \ +--with-xsl \ +--with-curl=/usr \ +--with-tidy \ +--with-xmlrpc \ +--enable-sysvsem \ +--enable-sysvshm \ +--enable-shmop \ +--enable-pcntl \ +--with-readline \ +--enable-mbstring \ +--with-curl \ +--with-gettext \ +--enable-sockets \ +--with-bz2 \ +--enable-bcmath +make --quiet diff --git a/travis/ext/curl/setup.sh b/travis/ext/curl/setup.sh new file mode 100755 index 0000000000000..74dad16eb35ba --- /dev/null +++ b/travis/ext/curl/setup.sh @@ -0,0 +1,5 @@ +#!/bin/bash +export PHP_CURL_HTTP_REMOTE_SERVER="http://localhost" +cd ./ext/curl/tests/responder +sudo php -S localhost:80 & +cd - \ No newline at end of file diff --git a/travis/ext/mysql/setup.sh b/travis/ext/mysql/setup.sh new file mode 100755 index 0000000000000..994fad13766d8 --- /dev/null +++ b/travis/ext/mysql/setup.sh @@ -0,0 +1,2 @@ +#!/bin/bash +mysql -u root -e "CREATE DATABASE IF NOT EXISTS test" diff --git a/travis/ext/mysqli/setup.sh b/travis/ext/mysqli/setup.sh new file mode 100755 index 0000000000000..994fad13766d8 --- /dev/null +++ b/travis/ext/mysqli/setup.sh @@ -0,0 +1,2 @@ +#!/bin/bash +mysql -u root -e "CREATE DATABASE IF NOT EXISTS test" diff --git a/travis/ext/pdo_mysql/setup.sh b/travis/ext/pdo_mysql/setup.sh new file mode 100755 index 0000000000000..994fad13766d8 --- /dev/null +++ b/travis/ext/pdo_mysql/setup.sh @@ -0,0 +1,2 @@ +#!/bin/bash +mysql -u root -e "CREATE DATABASE IF NOT EXISTS test" diff --git a/travis/ext/pdo_pgsql/setup.sh b/travis/ext/pdo_pgsql/setup.sh new file mode 100755 index 0000000000000..6f16f72cc2581 --- /dev/null +++ b/travis/ext/pdo_pgsql/setup.sh @@ -0,0 +1,2 @@ +#!/bin/bash +export PDO_PGSQL_TEST_DSN='pgsql:host=localhost port=5432 dbname=test user=postgres password=' \ No newline at end of file diff --git a/travis/ext/pgsql/setup.sh b/travis/ext/pgsql/setup.sh new file mode 100755 index 0000000000000..32b39a40443e4 --- /dev/null +++ b/travis/ext/pgsql/setup.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo ' +' >> "./ext/pgsql/tests/config.inc" +psql -c 'create database test;' -U postgres \ No newline at end of file diff --git a/win32/build/Makefile b/win32/build/Makefile index e2d62545b8c78..057b5845499d8 100644 --- a/win32/build/Makefile +++ b/win32/build/Makefile @@ -55,10 +55,10 @@ Zend\zend_language_parser.c Zend\zend_language_parser.h: Zend\zend_language_pars !if $(RE2C) != "" Zend\zend_ini_scanner.c: Zend\zend_ini_scanner.l - $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l + $(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l Zend\zend_language_scanner.c: Zend\zend_language_scanner.l - $(RE2C) $(RE2C_FLAGS) --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l + $(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l !endif !if $(PGOMGR) != "" diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 1a4b834be425d..3face08a8c2b5 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -181,8 +181,13 @@ if (VCVERS >= 1500 && PHP_MP != 'disable') { } // General link flags -DEFINE("LDFLAGS", "/nologo /version:" + - PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION); + +if (VCVERS >= 1700) { + DEFINE("LDFLAGS", "/nologo "); +} else { + DEFINE("LDFLAGS", "/nologo /version:" + + PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION); +} // General DLL link flags DEFINE("DLL_LDFLAGS", "/dll "); @@ -359,7 +364,7 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \ zend_stream.c zend_iterators.c zend_interfaces.c zend_objects.c \ zend_object_handlers.c zend_objects_API.c \ zend_default_classes.c zend_execute.c zend_strtod.c zend_gc.c zend_closures.c \ - zend_float.c zend_string.c"); + zend_float.c zend_string.c zend_generators.c"); if (VCVERS == 1200) { AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1); @@ -368,7 +373,7 @@ if (VCVERS == 1200) { ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \ php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \ strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c network.c \ - php_open_temporary_file.c php_logos.c output.c internal_functions.c php_sprintf.c"); + php_open_temporary_file.c output.c internal_functions.c php_sprintf.c"); ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c"); // Newer versions have it diff --git a/win32/build/config.w32.h.in b/win32/build/config.w32.h.in index c6cf076bab772..9efdfdea3ea57 100644 --- a/win32/build/config.w32.h.in +++ b/win32/build/config.w32.h.in @@ -6,8 +6,8 @@ /* Define the minimum supported version */ #undef _WIN32_WINNT #undef NTDDI_VERSION -#define _WIN32_WINNT 0x0501 -#define NTDDI_VERSION 0x05010200 +#define _WIN32_WINNT 0x0600 +#define NTDDI_VERSION 0x06000100 /* Default PHP / PEAR directories */ #define PHP_CONFIG_FILE_PATH (getenv("SystemRoot"))?getenv("SystemRoot"):"" diff --git a/win32/build/confutils.js b/win32/build/confutils.js index c0a1ce895bad6..d9a0c1b5f1e90 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -46,6 +46,7 @@ VC_VERSIONS[1310] = 'MSVC7.1 (Visual C++ 2003)'; VC_VERSIONS[1400] = 'MSVC8 (Visual C++ 2005)'; VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)'; VC_VERSIONS[1600] = 'MSVC10 (Visual C++ 2010)'; +VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)'; var VC_VERSIONS_SHORT = new Array(); VC_VERSIONS_SHORT[1200] = 'VC6'; @@ -54,6 +55,7 @@ VC_VERSIONS_SHORT[1310] = 'VC7.1'; VC_VERSIONS_SHORT[1400] = 'VC8'; VC_VERSIONS_SHORT[1500] = 'VC9'; VC_VERSIONS_SHORT[1600] = 'VC10'; +VC_VERSIONS_SHORT[1700] = 'VC11'; if (PROGRAM_FILES == null) { PROGRAM_FILES = "C:\\Program Files"; diff --git a/win32/inet.c b/win32/inet.c index b794bcaeb45d2..686cf1265c524 100644 --- a/win32/inet.c +++ b/win32/inet.c @@ -1,81 +1,5 @@ -#include "config.w32.h" -#if (_WIN32_WINNT < 0x0600) /* Vista/2k8 have these functions */ -#include "php.h" -#include -#include -#include - #include "inet.h" -PHPAPI int inet_pton(int af, const char* src, void* dst) -{ - int address_length; - struct sockaddr_storage sa; - struct sockaddr_in *sin = (struct sockaddr_in *)&sa; - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa; - - switch (af) { - case AF_INET: - address_length = sizeof (struct sockaddr_in); - break; - - case AF_INET6: - address_length = sizeof (struct sockaddr_in6); - break; - - default: - return -1; - } - - if (WSAStringToAddress ((LPTSTR) src, af, NULL, (LPSOCKADDR) &sa, &address_length) == 0) { - switch (af) { - case AF_INET: - memcpy (dst, &sin->sin_addr, sizeof (struct in_addr)); - break; - - case AF_INET6: - memcpy (dst, &sin6->sin6_addr, sizeof (struct in6_addr)); - break; - } - return 1; - } - - return 0; -} - -PHPAPI const char* inet_ntop(int af, const void* src, char* dst, size_t size) -{ - int address_length; - DWORD string_length = size; - struct sockaddr_storage sa; - struct sockaddr_in *sin = (struct sockaddr_in *)&sa; - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa; - - memset (&sa, 0, sizeof (sa)); - switch (af) { - case AF_INET: - address_length = sizeof (struct sockaddr_in); - sin->sin_family = af; - memcpy (&sin->sin_addr, src, sizeof (struct in_addr)); - break; - - case AF_INET6: - address_length = sizeof (struct sockaddr_in6); - sin6->sin6_family = af; - memcpy (&sin6->sin6_addr, src, sizeof (struct in6_addr)); - break; - - default: - return NULL; - } - - if (WSAAddressToString ((LPSOCKADDR) &sa, address_length, NULL, dst, &string_length) == 0) { - return dst; - } - - return NULL; -} - int inet_aton(const char *cp, struct in_addr *inp) { inp->s_addr = inet_addr(cp); @@ -85,4 +9,3 @@ int inet_aton(const char *cp, struct in_addr *inp) { return 1; } -#endif diff --git a/win32/inet.h b/win32/inet.h index e58083828f4fa..d71723759fa10 100644 --- a/win32/inet.h +++ b/win32/inet.h @@ -1,10 +1,4 @@ -#if _MSC_VER >= 1500 -# include -#endif -#include +#include +#include -#if (_WIN32_WINNT < 0x0600) -PHPAPI int inet_pton(int af, const char* src, void* dst); -PHPAPI const char* inet_ntop(int af, const void* src, char* dst, size_t size); PHPAPI int inet_aton(const char *cp, struct in_addr *inp); -#endif diff --git a/win32/php5dll.dsp b/win32/php5dll.dsp index 2216d7dfe6e0a..cc56f538af1c9 100644 --- a/win32/php5dll.dsp +++ b/win32/php5dll.dsp @@ -164,10 +164,6 @@ SOURCE=..\main\php_ini.c # End Source File # Begin Source File -SOURCE=..\main\php_logos.c -# End Source File -# Begin Source File - SOURCE=..\main\php_open_temporary_file.c # End Source File # Begin Source File @@ -288,10 +284,6 @@ SOURCE=..\main\php_ini.h # End Source File # Begin Source File -SOURCE=..\main\php_logos.h -# End Source File -# Begin Source File - SOURCE=..\main\php_open_temporary_file.h # End Source File # Begin Source File diff --git a/win32/php5dllts.dsp b/win32/php5dllts.dsp index a8e93ec5e778c..3755ea79f9696 100644 --- a/win32/php5dllts.dsp +++ b/win32/php5dllts.dsp @@ -201,10 +201,6 @@ SOURCE=..\main\php_ini.c # End Source File # Begin Source File -SOURCE=..\main\php_logos.c -# End Source File -# Begin Source File - SOURCE=..\main\php_open_temporary_file.c # End Source File # Begin Source File @@ -317,10 +313,6 @@ SOURCE=..\main\php_ini.h # End Source File # Begin Source File -SOURCE=..\main\php_logos.h -# End Source File -# Begin Source File - SOURCE=..\main\php_main.h # End Source File # Begin Source File diff --git a/win32/sendmail.c b/win32/sendmail.c index c4969ad5e3a85..4b09697e95dfe 100644 --- a/win32/sendmail.c +++ b/win32/sendmail.c @@ -25,6 +25,7 @@ #ifndef NETWARE #include #include "time.h" +# include #else /* NETWARE */ #include #endif /* NETWARE */ diff --git a/win32/syslog.reg b/win32/syslog.reg index 4d3e273970f91..cb12d6e6b9743 100644 --- a/win32/syslog.reg +++ b/win32/syslog.reg @@ -2,4 +2,4 @@ REGEDIT4 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\PHP-5.3.99-dev] "TypesSupported"=dword:00000007 -"EventMessageFile"="g:\\test\\srcinstall6\\php5ts_debug.dll" +"EventMessageFile"="g:\\test\\srctrunkinstall\\php5ts.dll"