summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2014-08-25 21:21:16 +0200
committerNikita Popov <nikic@php.net>2014-08-25 21:52:18 +0200
commit6db293d5e043d35c281a6b11cb68460f5d7188a9 (patch)
treed1880c1810fe147de6ff7f8ff317b4ec300a518f
parent7813d85d3d5901b24f77b63538eb6754e161f471 (diff)
parent455741fce3c4f4392deb97775cba7a39f6490271 (diff)
downloadphp-git-6db293d5e043d35c281a6b11cb68460f5d7188a9.tar.gz
Merge remote-tracking branch 'php-src/master' into ast
Conflicts: Zend/zend_compile.c Zend/zend_compile.h Zend/zend_globals.h Zend/zend_language_parser.y Zend/zend_language_scanner.c Zend/zend_language_scanner.l Zend/zend_types.h
-rw-r--r--.travis.yml1
-rw-r--r--NEWS11
-rw-r--r--TSRM/TSRM.h2
-rw-r--r--UPGRADING17
-rw-r--r--UPGRADING.INTERNALS88
-rw-r--r--Zend/tests/bug54013.phpt2
-rw-r--r--Zend/tests/bug60825.phpt9
-rw-r--r--Zend/tests/bug64515.phpt2
-rw-r--r--Zend/tests/bug67856.phpt11
-rw-r--r--Zend/tests/bug67874.phpt14
-rw-r--r--Zend/tests/closure_026.phpt5
-rw-r--r--Zend/zend.c44
-rw-r--r--Zend/zend.h46
-rw-r--r--Zend/zend_API.c214
-rw-r--r--Zend/zend_API.h99
-rw-r--r--Zend/zend_alloc.c32
-rw-r--r--Zend/zend_alloc.h19
-rw-r--r--Zend/zend_ast.c36
-rw-r--r--Zend/zend_ast.h32
-rw-r--r--Zend/zend_builtin_functions.c232
-rw-r--r--Zend/zend_closures.c18
-rw-r--r--Zend/zend_compile.c530
-rw-r--r--Zend/zend_compile.h89
-rw-r--r--Zend/zend_constants.c52
-rw-r--r--Zend/zend_constants.h6
-rw-r--r--Zend/zend_exceptions.c42
-rw-r--r--Zend/zend_execute.c104
-rw-r--r--Zend/zend_execute.h14
-rw-r--r--Zend/zend_execute_API.c56
-rw-r--r--Zend/zend_gc.h18
-rw-r--r--Zend/zend_generators.c4
-rw-r--r--Zend/zend_generators.h2
-rw-r--r--Zend/zend_globals.h8
-rw-r--r--Zend/zend_hash.c138
-rw-r--r--Zend/zend_hash.h64
-rw-r--r--Zend/zend_highlight.c4
-rw-r--r--Zend/zend_indent.c2
-rw-r--r--Zend/zend_ini.c14
-rw-r--r--Zend/zend_ini.h2
-rw-r--r--Zend/zend_ini_parser.y40
-rw-r--r--Zend/zend_ini_scanner.c2
-rw-r--r--Zend/zend_ini_scanner.l2
-rw-r--r--Zend/zend_interfaces.c10
-rw-r--r--Zend/zend_interfaces.h8
-rw-r--r--Zend/zend_iterators.c9
-rw-r--r--Zend/zend_iterators.h2
-rw-r--r--Zend/zend_language_parser.y4
-rw-r--r--Zend/zend_language_scanner.c42
-rw-r--r--Zend/zend_language_scanner.l38
-rw-r--r--Zend/zend_long.h141
-rw-r--r--Zend/zend_multiply.h25
-rw-r--r--Zend/zend_object_handlers.c40
-rw-r--r--Zend/zend_object_handlers.h2
-rw-r--r--Zend/zend_objects.c2
-rw-r--r--Zend/zend_objects_API.c12
-rw-r--r--Zend/zend_objects_API.h6
-rw-r--r--Zend/zend_opcode.c70
-rw-r--r--Zend/zend_operators.c286
-rw-r--r--Zend/zend_operators.h100
-rw-r--r--Zend/zend_qsort.c2
-rw-r--r--Zend/zend_static_allocator.c8
-rw-r--r--Zend/zend_static_allocator.h8
-rw-r--r--Zend/zend_stream.c9
-rw-r--r--Zend/zend_stream.h19
-rw-r--r--Zend/zend_string.c22
-rw-r--r--Zend/zend_string.h79
-rw-r--r--Zend/zend_ts_hash.c8
-rw-r--r--Zend/zend_ts_hash.h10
-rw-r--r--Zend/zend_types.h69
-rw-r--r--Zend/zend_variables.c10
-rw-r--r--Zend/zend_virtual_cwd.c54
-rw-r--r--Zend/zend_virtual_cwd.h18
-rw-r--r--Zend/zend_vm_def.h77
-rw-r--r--Zend/zend_vm_execute.h462
-rw-r--r--ext/bcmath/bcmath.c18
-rw-r--r--ext/bcmath/libbcmath/src/num2str.c4
-rw-r--r--ext/bcmath/php_bcmath.h2
-rw-r--r--ext/bz2/bz2.c18
-rw-r--r--ext/bz2/bz2_filter.c8
-rw-r--r--ext/calendar/calendar.c42
-rw-r--r--ext/calendar/dow.c2
-rw-r--r--ext/calendar/easter.c6
-rw-r--r--ext/calendar/french.c6
-rw-r--r--ext/calendar/gregor.c6
-rw-r--r--ext/calendar/jewish.c44
-rw-r--r--ext/calendar/julian.c10
-rw-r--r--ext/calendar/sdncal.h22
-rw-r--r--ext/com_dotnet/com_com.c6
-rw-r--r--ext/com_dotnet/com_extension.c16
-rw-r--r--ext/com_dotnet/com_handlers.c10
-rw-r--r--ext/com_dotnet/com_iterator.c4
-rw-r--r--ext/com_dotnet/com_misc.c2
-rw-r--r--ext/com_dotnet/com_persist.c4
-rw-r--r--ext/com_dotnet/com_saproxy.c14
-rw-r--r--ext/com_dotnet/com_typeinfo.c4
-rw-r--r--ext/com_dotnet/com_variant.c36
-rw-r--r--ext/com_dotnet/com_wrapper.c26
-rw-r--r--ext/com_dotnet/php_com_dotnet_internal.h2
-rw-r--r--ext/curl/interface.c68
-rw-r--r--ext/curl/multi.c16
-rw-r--r--ext/curl/php_curl.h2
-rw-r--r--ext/curl/share.c6
-rw-r--r--ext/date/lib/parse_date.c246
-rw-r--r--ext/date/lib/parse_date.re50
-rw-r--r--ext/date/lib/timelib.c6
-rw-r--r--ext/date/lib/timelib.h3
-rw-r--r--ext/date/php_date.c104
-rw-r--r--ext/date/php_date.h2
-rw-r--r--ext/date/tests/bug66985.phpt175
-rw-r--r--ext/date/tests/bug67109.phpt14
-rw-r--r--ext/dba/dba.c4
-rw-r--r--ext/dba/dba_db1.c2
-rw-r--r--ext/dba/dba_db2.c2
-rw-r--r--ext/dba/dba_db3.c2
-rw-r--r--ext/dba/dba_db4.c2
-rw-r--r--ext/dba/dba_dbm.c2
-rw-r--r--ext/dba/dba_gdbm.c2
-rw-r--r--ext/dba/dba_ndbm.c2
-rw-r--r--ext/dom/attr.c2
-rw-r--r--ext/dom/characterdata.c10
-rw-r--r--ext/dom/document.c20
-rw-r--r--ext/dom/namednodemap.c2
-rw-r--r--ext/dom/node.c8
-rw-r--r--ext/dom/php_dom.c10
-rw-r--r--ext/dom/processinginstruction.c2
-rw-r--r--ext/dom/text.c2
-rw-r--r--ext/dom/xpath.c6
-rw-r--r--ext/enchant/enchant.c4
-rw-r--r--ext/ereg/ereg.c24
-rw-r--r--ext/exif/exif.c6
-rw-r--r--ext/fileinfo/fileinfo.c14
-rw-r--r--ext/fileinfo/libmagic/apprentice.c8
-rw-r--r--ext/fileinfo/libmagic/cdf.c10
-rw-r--r--ext/fileinfo/libmagic/compress.c4
-rw-r--r--ext/fileinfo/libmagic/elfclass.h6
-rw-r--r--ext/fileinfo/libmagic/fsmagic.c2
-rw-r--r--ext/fileinfo/libmagic/funcs.c2
-rw-r--r--ext/fileinfo/libmagic/readelf.c52
-rw-r--r--ext/fileinfo/libmagic/softmagic.c8
-rw-r--r--ext/filter/filter.c38
-rw-r--r--ext/filter/filter_private.h2
-rw-r--r--ext/filter/logical_filters.c48
-rw-r--r--ext/filter/php_filter.h6
-rw-r--r--ext/filter/sanitizing_filters.c10
-rw-r--r--ext/ftp/ftp.c38
-rw-r--r--ext/ftp/ftp.h16
-rw-r--r--ext/ftp/php_ftp.c40
-rw-r--r--ext/gd/gd.c166
-rw-r--r--ext/gd/gd_ctx.c7
-rw-r--r--ext/gd/libgd/gdft.c6
-rw-r--r--ext/gd/tests/imagegd2_nullbyte_injection.phpt31
-rw-r--r--ext/gd/tests/imagegd_nullbyte_injection.phpt31
-rw-r--r--ext/gd/tests/imagegif_nullbyte_injection.phpt38
-rw-r--r--ext/gd/tests/imagejpeg_nullbyte_injection.phpt38
-rw-r--r--ext/gd/tests/imagepng_nullbyte_injection.phpt38
-rw-r--r--ext/gd/tests/imagewbmp_nullbyte_injection.phpt38
-rw-r--r--ext/gd/tests/imagewebp_nullbyte_injection.phpt38
-rw-r--r--ext/gettext/gettext.c8
-rw-r--r--ext/gmp/gmp.c66
-rw-r--r--ext/hash/hash.c52
-rw-r--r--ext/hash/php_hash.h2
-rw-r--r--ext/iconv/iconv.c246
-rw-r--r--ext/iconv/tests/iconv_strpos_variation3_64bit.phpt4
-rw-r--r--ext/imap/php_imap.c26
-rw-r--r--ext/interbase/ibase_blobs.c2
-rw-r--r--ext/interbase/ibase_events.c8
-rw-r--r--ext/interbase/ibase_query.c6
-rw-r--r--ext/interbase/interbase.c2
-rw-r--r--ext/intl/breakiterator/breakiterator_class.cpp2
-rw-r--r--ext/intl/breakiterator/breakiterator_iterators.cpp6
-rw-r--r--ext/intl/breakiterator/breakiterator_methods.cpp18
-rw-r--r--ext/intl/breakiterator/codepointiterator_internal.cpp4
-rw-r--r--ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp2
-rw-r--r--ext/intl/calendar/calendar_class.cpp4
-rw-r--r--ext/intl/calendar/calendar_methods.cpp46
-rw-r--r--ext/intl/calendar/gregoriancalendar_methods.cpp4
-rw-r--r--ext/intl/collator/collator_attr.c6
-rw-r--r--ext/intl/collator/collator_convert.c10
-rw-r--r--ext/intl/collator/collator_is_numeric.c18
-rw-r--r--ext/intl/collator/collator_is_numeric.h2
-rw-r--r--ext/intl/collator/collator_locale.c2
-rw-r--r--ext/intl/collator/collator_sort.c8
-rw-r--r--ext/intl/common/common_date.cpp2
-rw-r--r--ext/intl/common/common_error.c4
-rw-r--r--ext/intl/config.m42
-rw-r--r--ext/intl/converter/converter.c18
-rw-r--r--ext/intl/dateformat/dateformat_attr.c2
-rw-r--r--ext/intl/dateformat/dateformat_attrcpp.cpp2
-rw-r--r--ext/intl/dateformat/dateformat_create.cpp6
-rw-r--r--ext/intl/dateformat/dateformat_format.c2
-rw-r--r--ext/intl/dateformat/dateformat_format_object.cpp4
-rw-r--r--ext/intl/dateformat/dateformat_helpers.cpp8
-rw-r--r--ext/intl/dateformat/dateformat_helpers.h2
-rw-r--r--ext/intl/dateformat/dateformat_parse.c12
-rw-r--r--ext/intl/formatter/formatter_attr.c16
-rw-r--r--ext/intl/formatter/formatter_format.c8
-rw-r--r--ext/intl/formatter/formatter_main.c2
-rw-r--r--ext/intl/formatter/formatter_parse.c12
-rw-r--r--ext/intl/grapheme/grapheme_string.c18
-rw-r--r--ext/intl/grapheme/grapheme_util.h2
-rw-r--r--ext/intl/idn/idn.c12
-rw-r--r--ext/intl/intl_error.c4
-rw-r--r--ext/intl/locale/locale_methods.c4
-rw-r--r--ext/intl/msgformat/msgformat_data.h2
-rw-r--r--ext/intl/msgformat/msgformat_helpers.cpp18
-rw-r--r--ext/intl/normalizer/normalizer_normalize.c4
-rw-r--r--ext/intl/php_intl.h2
-rw-r--r--ext/intl/resourcebundle/resourcebundle.c2
-rw-r--r--ext/intl/resourcebundle/resourcebundle_class.c2
-rw-r--r--ext/intl/resourcebundle/resourcebundle_iterator.h4
-rw-r--r--ext/intl/spoofchecker/spoofchecker_main.c2
-rw-r--r--ext/intl/tests/dateformat_calendars.phpt2
-rw-r--r--ext/intl/tests/dateformat_create_cal_arg.phpt2
-rw-r--r--ext/intl/tests/dateformat_format.phpt2
-rw-r--r--ext/intl/tests/dateformat_formatObject_calendar.phpt66
-rw-r--r--ext/intl/tests/dateformat_formatObject_datetime.phpt52
-rw-r--r--ext/intl/tests/dateformat_format_parse.phpt2
-rw-r--r--ext/intl/tests/dateformat_get_set_calendar.phpt2
-rw-r--r--ext/intl/tests/dateformat_get_set_timezone.phpt2
-rw-r--r--ext/intl/tests/dateformat_set_timezone_id2.phpt2
-rw-r--r--ext/intl/tests/dateformat_timezone_arg_variations.phpt2
-rw-r--r--ext/intl/tests/formatter_get_locale.phpt4
-rw-r--r--ext/intl/tests/locale_filter_matches2.phpt4
-rw-r--r--ext/intl/tests/locale_get_display_name2.phpt4
-rw-r--r--ext/intl/tests/locale_get_display_region2.phpt2
-rw-r--r--ext/intl/tests/locale_lookup.phpt4
-rw-r--r--ext/intl/tests/msgfmt_format_intlcalendar.phpt4
-rw-r--r--ext/intl/tests/resourcebundle_null_mandatory_args.phpt2
-rw-r--r--ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt6
-rw-r--r--ext/intl/timezone/timezone_class.cpp6
-rw-r--r--ext/intl/timezone/timezone_methods.cpp24
-rw-r--r--ext/intl/transliterator/transliterator_class.c2
-rw-r--r--ext/intl/transliterator/transliterator_methods.c12
-rw-r--r--ext/json/JSON_parser.c2
-rw-r--r--ext/json/json.c20
-rw-r--r--ext/json/php_json.h4
-rw-r--r--ext/ldap/ldap.c46
-rw-r--r--ext/ldap/php_ldap.h4
-rw-r--r--ext/mbstring/mb_gpc.c6
-rw-r--r--ext/mbstring/mbstring.c48
-rw-r--r--ext/mbstring/php_mbregex.c8
-rw-r--r--ext/mcrypt/mcrypt.c14
-rw-r--r--ext/mssql/php_mssql.c20
-rw-r--r--ext/mysql/php_mysql.c84
-rw-r--r--ext/mysql/php_mysql_structs.h18
-rw-r--r--ext/mysqli/mysqli.c22
-rw-r--r--ext/mysqli/mysqli_api.c98
-rw-r--r--ext/mysqli/mysqli_embedded.c2
-rw-r--r--ext/mysqli/mysqli_nonapi.c20
-rw-r--r--ext/mysqli/mysqli_priv.h6
-rw-r--r--ext/mysqli/mysqli_prop.c40
-rw-r--r--ext/mysqli/mysqli_report.c2
-rw-r--r--ext/mysqli/mysqli_warning.c10
-rw-r--r--ext/mysqli/php_mysqli_structs.h38
-rw-r--r--ext/mysqlnd/mysqlnd.c28
-rw-r--r--ext/mysqlnd/mysqlnd.h24
-rw-r--r--ext/mysqlnd/mysqlnd_alloc.c18
-rw-r--r--ext/mysqlnd/mysqlnd_auth.c10
-rw-r--r--ext/mysqlnd/mysqlnd_charset.c4
-rw-r--r--ext/mysqlnd/mysqlnd_charset.h8
-rw-r--r--ext/mysqlnd/mysqlnd_enum_n_def.h2
-rw-r--r--ext/mysqlnd/mysqlnd_net.c4
-rw-r--r--ext/mysqlnd/mysqlnd_portability.h16
-rw-r--r--ext/mysqlnd/mysqlnd_priv.h2
-rw-r--r--ext/mysqlnd/mysqlnd_ps.c10
-rw-r--r--ext/mysqlnd/mysqlnd_ps_codec.c36
-rw-r--r--ext/mysqlnd/mysqlnd_result.c32
-rw-r--r--ext/mysqlnd/mysqlnd_result_meta.c6
-rw-r--r--ext/mysqlnd/mysqlnd_structs.h38
-rw-r--r--ext/mysqlnd/mysqlnd_wireprotocol.c44
-rw-r--r--ext/mysqlnd/mysqlnd_wireprotocol.h8
-rw-r--r--ext/mysqlnd/php_mysqlnd.c10
-rw-r--r--ext/oci8/oci8.c8
-rw-r--r--ext/oci8/oci8_statement.c6
-rw-r--r--ext/odbc/birdstep.c26
-rw-r--r--ext/odbc/php_birdstep.h12
-rw-r--r--ext/odbc/php_odbc.c42
-rw-r--r--ext/odbc/php_odbc_includes.h22
-rw-r--r--ext/opcache/Optimizer/block_pass.c18
-rw-r--r--ext/opcache/Optimizer/compact_literals.c24
-rw-r--r--ext/opcache/Optimizer/nop_removal.c12
-rw-r--r--ext/opcache/Optimizer/pass1_5.c20
-rw-r--r--ext/opcache/Optimizer/pass2.c6
-rw-r--r--ext/opcache/Optimizer/pass3.c6
-rw-r--r--ext/opcache/Optimizer/zend_optimizer.c24
-rw-r--r--ext/opcache/Optimizer/zend_optimizer_internal.h2
-rw-r--r--ext/opcache/ZendAccelerator.c48
-rw-r--r--ext/opcache/ZendAccelerator.h44
-rw-r--r--ext/opcache/zend_accelerator_debug.c2
-rw-r--r--ext/opcache/zend_accelerator_hash.c12
-rw-r--r--ext/opcache/zend_accelerator_hash.h18
-rw-r--r--ext/opcache/zend_accelerator_module.c46
-rw-r--r--ext/opcache/zend_accelerator_util_funcs.c74
-rw-r--r--ext/opcache/zend_persist.c38
-rw-r--r--ext/opcache/zend_persist_calc.c10
-rw-r--r--ext/opcache/zend_shared_alloc.c10
-rw-r--r--ext/opcache/zend_shared_alloc.h2
-rwxr-xr-xext/openssl/openssl.c117
-rw-r--r--ext/openssl/xp_ssl.c55
-rw-r--r--ext/pcntl/pcntl.c150
-rw-r--r--ext/pcntl/php_pcntl.h2
-rw-r--r--ext/pcre/php_pcre.c86
-rw-r--r--ext/pcre/tests/bug47662.phpt3
-rw-r--r--ext/pdo/pdo.c10
-rw-r--r--ext/pdo/pdo_dbh.c205
-rw-r--r--ext/pdo/pdo_sql_parser.c26
-rw-r--r--ext/pdo/pdo_sql_parser.re6
-rw-r--r--ext/pdo/pdo_stmt.c88
-rw-r--r--ext/pdo/php_pdo.h6
-rw-r--r--ext/pdo/php_pdo_driver.h42
-rw-r--r--ext/pdo/tests/pdo_005.phpt2
-rw-r--r--ext/pdo_dblib/dblib_driver.c4
-rw-r--r--ext/pdo_dblib/dblib_stmt.c6
-rw-r--r--ext/pdo_firebird/firebird_driver.c18
-rw-r--r--ext/pdo_firebird/firebird_statement.c24
-rw-r--r--ext/pdo_firebird/pdo_firebird.c6
-rw-r--r--ext/pdo_firebird/php_pdo_firebird_int.h4
-rw-r--r--ext/pdo_mysql/mysql_driver.c20
-rw-r--r--ext/pdo_mysql/mysql_statement.c28
-rw-r--r--ext/pdo_mysql/pdo_mysql.c32
-rw-r--r--ext/pdo_mysql/php_pdo_mysql_int.h10
-rw-r--r--ext/pdo_oci/oci_driver.c2
-rw-r--r--ext/pdo_odbc/odbc_driver.c8
-rw-r--r--ext/pdo_odbc/odbc_stmt.c26
-rw-r--r--ext/pdo_odbc/php_pdo_odbc_int.h4
-rw-r--r--ext/pdo_pgsql/pdo_pgsql.c10
-rw-r--r--ext/pdo_pgsql/pgsql_driver.c44
-rw-r--r--ext/pdo_pgsql/pgsql_statement.c25
-rw-r--r--ext/pdo_pgsql/php_pdo_pgsql_int.h2
-rw-r--r--ext/pdo_sqlite/sqlite_driver.c34
-rw-r--r--ext/pdo_sqlite/sqlite_statement.c10
-rw-r--r--ext/pgsql/config.w322
-rw-r--r--ext/pgsql/pgsql.c138
-rw-r--r--ext/pgsql/php_pgsql.h18
-rw-r--r--ext/pgsql/tests/config.inc2
-rw-r--r--ext/phar/dirstream.c10
-rw-r--r--ext/phar/dirstream.h2
-rw-r--r--ext/phar/func_interceptors.c34
-rw-r--r--ext/phar/phar.c30
-rw-r--r--ext/phar/phar_internal.h24
-rwxr-xr-xext/phar/phar_object.c42
-rw-r--r--ext/phar/stream.c28
-rw-r--r--ext/phar/stream.h2
-rw-r--r--ext/phar/tar.c6
-rw-r--r--ext/phar/util.c34
-rw-r--r--ext/phar/zip.c28
-rw-r--r--ext/posix/posix.c32
-rw-r--r--ext/pspell/pspell.c32
-rw-r--r--ext/readline/readline.c14
-rw-r--r--ext/readline/readline_cli.c16
-rw-r--r--ext/reflection/php_reflection.c138
-rw-r--r--ext/session/mod_files.c20
-rw-r--r--ext/session/mod_user.c6
-rw-r--r--ext/session/mod_user_class.c2
-rw-r--r--ext/session/php_session.h26
-rw-r--r--ext/session/session.c131
-rw-r--r--ext/session/tests/bug67694.phpt41
-rw-r--r--ext/session/tests/session_module_name_variation3.phpt2
-rw-r--r--ext/shmop/php_shmop.h2
-rw-r--r--ext/shmop/shmop.c23
-rw-r--r--ext/simplexml/simplexml.c38
-rw-r--r--ext/simplexml/tests/bug62328.phpt (renamed from ext/xml/tests/bug62328.phpt)4
-rw-r--r--ext/skeleton/php_skeleton.h2
-rw-r--r--ext/snmp/php_snmp.h2
-rw-r--r--ext/snmp/snmp.c40
-rw-r--r--ext/soap/php_encoding.c26
-rw-r--r--ext/soap/php_http.c12
-rw-r--r--ext/soap/php_packet_soap.c4
-rw-r--r--ext/soap/php_schema.c4
-rw-r--r--ext/soap/php_sdl.c8
-rw-r--r--ext/soap/php_sdl.h2
-rw-r--r--ext/soap/php_soap.h4
-rw-r--r--ext/soap/soap.c80
-rw-r--r--ext/sockets/conversions.c40
-rw-r--r--ext/sockets/multicast.c6
-rw-r--r--ext/sockets/sendrecvmsg.c18
-rw-r--r--ext/sockets/sockaddr_conv.c2
-rw-r--r--ext/sockets/sockets.c78
-rw-r--r--ext/spl/php_spl.c87
-rw-r--r--ext/spl/php_spl.h2
-rw-r--r--ext/spl/spl_array.c56
-rw-r--r--ext/spl/spl_directory.c60
-rw-r--r--ext/spl/spl_directory.h4
-rw-r--r--ext/spl/spl_dllist.c44
-rw-r--r--ext/spl/spl_engine.c6
-rw-r--r--ext/spl/spl_engine.h2
-rw-r--r--ext/spl/spl_fixedarray.c46
-rw-r--r--ext/spl/spl_functions.c6
-rw-r--r--ext/spl/spl_functions.h2
-rw-r--r--ext/spl/spl_heap.c26
-rw-r--r--ext/spl/spl_iterators.c56
-rw-r--r--ext/spl/spl_iterators.h10
-rw-r--r--ext/spl/spl_observer.c35
-rw-r--r--ext/sqlite3/php_sqlite3_structs.h6
-rw-r--r--ext/sqlite3/sqlite3.c122
-rw-r--r--ext/standard/array.c188
-rw-r--r--ext/standard/assert.c36
-rw-r--r--ext/standard/base64.c16
-rw-r--r--ext/standard/base64.h6
-rw-r--r--ext/standard/basic_functions.c58
-rw-r--r--ext/standard/basic_functions.h8
-rw-r--r--ext/standard/browscap.c22
-rw-r--r--ext/standard/credits.c1
-rw-r--r--ext/standard/crypt.c14
-rw-r--r--ext/standard/crypt_sha256.c2
-rw-r--r--ext/standard/crypt_sha512.c2
-rw-r--r--ext/standard/cyr_convert.c2
-rw-r--r--ext/standard/dir.c12
-rw-r--r--ext/standard/dns.c94
-rw-r--r--ext/standard/dns_win32.c2
-rw-r--r--ext/standard/exec.c10
-rw-r--r--ext/standard/file.c91
-rw-r--r--ext/standard/file.h10
-rw-r--r--ext/standard/filestat.c28
-rw-r--r--ext/standard/filters.c14
-rw-r--r--ext/standard/formatted_print.c96
-rw-r--r--ext/standard/fsock.c16
-rw-r--r--ext/standard/ftp_fopen_wrapper.c6
-rw-r--r--ext/standard/head.c20
-rw-r--r--ext/standard/html.c58
-rw-r--r--ext/standard/http.c18
-rw-r--r--ext/standard/http_fopen_wrapper.c6
-rw-r--r--ext/standard/image.c6
-rw-r--r--ext/standard/incomplete_class.c6
-rw-r--r--ext/standard/info.c18
-rw-r--r--ext/standard/iptc.c6
-rw-r--r--ext/standard/levenshtein.c2
-rw-r--r--ext/standard/link_win32.c2
-rw-r--r--ext/standard/mail.c12
-rw-r--r--ext/standard/math.c52
-rw-r--r--ext/standard/md5.c9
-rw-r--r--ext/standard/metaphone.c26
-rw-r--r--ext/standard/microtime.c2
-rw-r--r--ext/standard/pack.c61
-rw-r--r--ext/standard/pageinfo.c18
-rw-r--r--ext/standard/pageinfo.h6
-rw-r--r--ext/standard/password.c34
-rw-r--r--ext/standard/php_array.h2
-rw-r--r--ext/standard/php_fopen_wrapper.c18
-rw-r--r--ext/standard/php_incomplete_class.h6
-rw-r--r--ext/standard/php_math.h2
-rw-r--r--ext/standard/php_rand.h12
-rw-r--r--ext/standard/php_smart_str.h18
-rw-r--r--ext/standard/php_smart_string.h4
-rw-r--r--ext/standard/php_string.h30
-rw-r--r--ext/standard/php_uuencode.h4
-rw-r--r--ext/standard/proc_open.c12
-rw-r--r--ext/standard/quot_print.c30
-rw-r--r--ext/standard/rand.c26
-rw-r--r--ext/standard/scanf.c30
-rw-r--r--ext/standard/sha1.c9
-rw-r--r--ext/standard/sha1.h2
-rw-r--r--ext/standard/streamsfuncs.c70
-rw-r--r--ext/standard/string.c954
-rw-r--r--ext/standard/syslog.c4
-rw-r--r--ext/standard/tests/http/bug60570.phpt4
-rw-r--r--ext/standard/tests/strings/bug55871.phpt32
-rw-r--r--ext/standard/tests/strings/setlocale_variation2.phpt7
-rw-r--r--ext/standard/type.c10
-rw-r--r--ext/standard/url.c28
-rw-r--r--ext/standard/url_scanner_ex.c2
-rw-r--r--ext/standard/url_scanner_ex.re2
-rw-r--r--ext/standard/user_filters.c10
-rw-r--r--ext/standard/uuencode.c30
-rw-r--r--ext/standard/var.c84
-rw-r--r--ext/standard/var_unserializer.c68
-rw-r--r--ext/standard/var_unserializer.re68
-rw-r--r--ext/sybase_ct/php_sybase_ct.c12
-rw-r--r--ext/sysvmsg/php_sysvmsg.h4
-rw-r--r--ext/sysvmsg/sysvmsg.c22
-rw-r--r--ext/sysvsem/sysvsem.c2
-rw-r--r--ext/sysvshm/php_sysvshm.h18
-rw-r--r--ext/sysvshm/sysvshm.c44
-rw-r--r--ext/tidy/tidy.c12
-rw-r--r--ext/tokenizer/tokenizer.c4
-rwxr-xr-xext/tokenizer/tokenizer_data_gen.sh4
-rw-r--r--ext/wddx/wddx.c34
-rw-r--r--ext/xml/xml.c48
-rw-r--r--ext/xmlreader/php_xmlreader.c12
-rw-r--r--ext/xmlrpc/xmlrpc-epi-php.c11
-rw-r--r--ext/xmlwriter/php_xmlwriter.c2
-rw-r--r--ext/xsl/php_xsl.h2
-rw-r--r--ext/xsl/xsltprocessor.c23
-rw-r--r--ext/zip/php_zip.c127
-rw-r--r--ext/zip/php_zip.h2
-rw-r--r--ext/zip/zip_stream.c10
-rw-r--r--ext/zlib/php_zlib.h6
-rw-r--r--ext/zlib/zlib.c28
-rw-r--r--ext/zlib/zlib_filter.c19
-rw-r--r--ext/zlib/zlib_fopen_wrapper.c2
-rw-r--r--main/SAPI.c14
-rw-r--r--main/SAPI.h21
-rw-r--r--main/main.c53
-rw-r--r--main/network.c18
-rw-r--r--main/output.c32
-rw-r--r--main/php.h4
-rw-r--r--main/php_globals.h20
-rw-r--r--main/php_ini.c20
-rw-r--r--main/php_ini.h2
-rw-r--r--main/php_network.h2
-rw-r--r--main/php_streams.h16
-rw-r--r--main/php_variables.c40
-rw-r--r--main/php_variables.h2
-rw-r--r--main/rfc1867.c32
-rw-r--r--main/rfc1867.h2
-rw-r--r--main/snprintf.c29
-rw-r--r--main/snprintf.h9
-rw-r--r--main/spprintf.c33
-rw-r--r--main/spprintf.h4
-rw-r--r--main/streams/cast.c14
-rw-r--r--main/streams/glob_wrapper.c2
-rw-r--r--main/streams/memory.c12
-rw-r--r--main/streams/mmap.c2
-rw-r--r--main/streams/php_stream_mmap.h2
-rw-r--r--main/streams/plain_wrapper.c40
-rw-r--r--main/streams/streams.c24
-rw-r--r--main/streams/transports.c4
-rw-r--r--main/streams/userspace.c14
-rw-r--r--main/streams/xp_socket.c26
-rw-r--r--sapi/apache2handler/php_apache.h5
-rw-r--r--sapi/apache2handler/sapi_apache2.c16
-rw-r--r--sapi/cgi/cgi_main.c32
-rw-r--r--sapi/cgi/config.w322
-rw-r--r--sapi/cgi/fastcgi.c3
-rw-r--r--sapi/cli/cli.h6
-rw-r--r--sapi/cli/config.w324
-rw-r--r--sapi/cli/php.1.in34
-rw-r--r--sapi/cli/php_cli.c24
-rw-r--r--sapi/cli/php_cli_server.c44
-rw-r--r--sapi/embed/php_embed.c8
-rw-r--r--sapi/fpm/fpm/fastcgi.c4
-rw-r--r--sapi/fpm/fpm/fpm_conf.c31
-rw-r--r--sapi/fpm/fpm/fpm_status.c6
-rw-r--r--sapi/phpdbg/phpdbg.h2
-rw-r--r--sapi/phpdbg/phpdbg_bp.c12
-rw-r--r--sapi/phpdbg/phpdbg_cmd.c2
-rw-r--r--sapi/phpdbg/phpdbg_frame.c2
-rw-r--r--sapi/phpdbg/phpdbg_opcode.c4
-rw-r--r--sapi/phpdbg/phpdbg_print.c2
-rw-r--r--sapi/phpdbg/phpdbg_prompt.c8
-rw-r--r--scripts/man1/php-config.1.in14
-rw-r--r--scripts/man1/phpize.1.in14
-rwxr-xr-xtravis/compile.sh1
-rw-r--r--win32/glob.c10
-rw-r--r--win32/glob.h6
-rw-r--r--win32/php_stdint.h6
-rw-r--r--win32/registry.c2
-rw-r--r--win32/sendmail.c21
-rw-r--r--win32/winutil.c2
-rw-r--r--win32/winutil.h2
550 files changed, 7914 insertions, 6886 deletions
diff --git a/.travis.yml b/.travis.yml
index d9e11a07d2..10ea74e4df 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -47,4 +47,3 @@ before_script:
# Run PHPs run-tests.php
script:
- ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff --set-timeout 120
- - ./sapi/cli/php sapi/phpdbg/tests/run-tests.php -diff2stdout --phpdbg sapi/phpdbg/phpdbg
diff --git a/NEWS b/NEWS
index 66e709ef88..16d8b26b2d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,6 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-?? ??? 20??, PHP 5.7.0
+?? ??? 20??, PHP 7.0.0
- CLI server:
. Refactor MIME type handling to use a hash table instead of linear search.
@@ -16,6 +16,9 @@ PHP NEWS
- DBA:
. Fixed bug #62490 (dba_delete returns true on missing item (inifile)). (Mike)
+- FPM:
+ . Fixed bug #65933 (Cannot specify config lines longer than 1024 bytes). (Chris Wright)
+
- Standard:
. Removed call_user_method() and call_user_method_array() functions. (Kalle)
. Fix user session handlers (See rfc:session.user.return-value). (Sara)
@@ -25,4 +28,10 @@ PHP NEWS
- XSL:
. Fixed bug #64776 (The XSLT extension is not thread safe). (Mike)
+- GD:
+ . Made fontFetch's path parser thread-safe. (Sara)
+
+- Session:
+ . Fixed bug #67694 (Regression in session_regenerate_id()). (Tjerk)
+
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h
index b232429d4d..82e272db5b 100644
--- a/TSRM/TSRM.h
+++ b/TSRM/TSRM.h
@@ -64,7 +64,7 @@ typedef int ts_rsrc_id;
/* Define THREAD_T and MUTEX_T */
#ifdef TSRM_WIN32
-# define THREAD_T DWORD
+# define THREAD_T UINT_PTR
# define MUTEX_T CRITICAL_SECTION *
#elif defined(GNUPTH)
# define THREAD_T pth_t
diff --git a/UPGRADING b/UPGRADING
index df68cb1b4b..8b6f8cd3ce 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -13,7 +13,8 @@ PHP X.Y UPGRADE NOTES
9. Other Changes to Extensions
10. New Global Constants
11. Changes to INI File Handling
-12. Other Changes
+12. Windows Support
+13. Other Changes
========================================
@@ -28,6 +29,9 @@ PHP X.Y UPGRADE NOTES
2. New Features
========================================
+- Core
+ . Support for strings with length >= 2^31 bytes in 64 bit builds
+
- Standard
. intdiv() function for integer division added.
@@ -35,6 +39,8 @@ PHP X.Y UPGRADE NOTES
3. Changes in SAPI modules
========================================
+- FPM
+ . Fixed bug #65933 (Cannot specify config lines longer than 1024 bytes).
========================================
4. Deprecated Functionality
@@ -77,9 +83,16 @@ PHP X.Y UPGRADE NOTES
11. Changes to INI File Handling
========================================
+========================================
+12. Windows Support
+========================================
+
+- Core
+ . Support for native 64 bit integers in 64 bit builds
+ . Support for large files in 64 bit builds
========================================
-12. Other Changes
+13. Other Changes
========================================
- Standard
diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
index 97b281a93e..f1ce1a7907 100644
--- a/UPGRADING.INTERNALS
+++ b/UPGRADING.INTERNALS
@@ -7,6 +7,12 @@ UPGRADE NOTES - PHP X.Y
b. return_value_ptr now always available, RETVAL_ZVAL_FAST macros
c. POST data handling
d. Arginfo changes
+ e. New data types
+ f. zend_parse_parameters() specs
+ g. sprintf() formats
+ h. HashTable API
+ i. New portable macros for large file support
+ j. New portable macros for integers
2. Build system changes
a. Unix build system changes
@@ -18,7 +24,89 @@ UPGRADE NOTES - PHP X.Y
========================
a. zend_set_memory_limit() now takes the TSRMLS_CC macro as its last argument
+ e. New data types
+ String
+
+ Besides the old way of accepting the strings with 's', the new 'S' ZPP spec
+ was introduced. It expects an argument of the type zend_string *. String lengths
+ in it do no more depend on the firm 'int' datatype. The replacement
+ is a platform dependent size_t datatype called php_size_t.
+
+ String length is defined as zend_size_t inside Zend and aliased as php_size_t
+ anywhere else. The inclusion of php.h is necessary.
+
+ Integer types
+
+ Integers do no more depend on the firm 'long' type. Instead a platform
+ dependent integer type is used. That datatype is defined dynamically to
+ guarantee the consistent 64 bit support. The zval field representing user
+ land integer it bound to php_int_t.
+
+ Signed integer is defined as zend_int_t, unsigned integer as zend_uint_t
+ inside Zend. Both are aliased as php_int_t and php_uint_t anywhere else,
+ respectively. The inclusion of php.h is necessary.
+
+ Other datatypes
+
+ zend_off_t - portable off_t analogue
+ zend_stat_t - portable 'struct stat' analogue
+
+ These datatypes are declared to be portable across platforms. Thus, direct
+ usage of the functions like fseek, stat, etc. as well as direct usage of
+ off_t and struct stat is strongly not recommended. Instead the portable
+ macros should be used.
+
+ zend_fseek - portable fseek equivalent
+ zend_ftell - portable ftell equivalent
+ zend_lseek - portable lseek equivalent
+ zend_fstat - portable fstat equivalent
+ zend_stat - portable stat equivalent
+
+ f. zend_parse_parameters() specs
+
+ The new spec 'S' introduced, which expects an argument of type zend_string *.
+ The new specs 'i' and 'I' introduced, which expect an argument of type php_int_t.
+
+ g. sprintf() formats
+
+ New printf modifier 'p' was implemented to platform independently output php_int_t,
+ php_uint_t and php_size_t datatypes. That modifier can be used with'd', 'u', 'x' and 'o'
+ printf format specs with spprintf, snprintf and the wrapping printf implementations.
+ %pu is sufficient for both php_uint_t and php_size_t. the code using %p spec to output
+ pointer address might need to be enclosed into #ifdef when it unlickily followed by 'd',
+ 'u', 'x' or 'o'.
+
+ The only exceptions are the snprintf and zend_sprintf functions yet, because in some cases
+ they can use the implemenations available on the system, not the PHP one. Fro snprintf the
+ the macros ZEND_INT_FMT ZEND_UINT_FMT should be used.
+
+ h. HashTable API
+
+ Datatype for array indexes was changed to php_uint_t, for string keys to zend_string *.
+
+ i. New portable macros for large file support
+
+ Function(s) Alias Comment
+ stat, _stat64 zend_stat for use with zend_stat_t
+ fstat, _fstat64 zend_fstat for use with zend_stat_t
+ lseek, _lseeki64 zend_lseek for use with zend_off_t
+ ftell, _ftelli64 zend_ftell for use with zend_off_t
+ fseek, _fseeki64 zend_fseek for use with zend_off_t
+
+ j. New portable macros for integers
+
+ Function(s) Alias Comment
+ snprintf with "%ld" or "%lld", _ltoa_s, _i64toa_s ZEND_ITOA for use with zend_int_t
+ atol, atoll, _atoi64 ZEND_ATOI for use with zend_int_t
+ strtol, strtoll, _strtoi64 ZEND_STRTOI for use with zend_int_t
+ strtoul, strtoull, _strtoui64 ZEND_STRTOUI for use with zend_int_t
+ abs, llabs, _abs64 ZEND_ABS for use with zend_int_t
+ - ZEND_INT_MAX Aliased with PHP_INT_MAX in php.h, replaces LONG_MAX where appropriate
+ - ZEND_INT_MIN Aliased with PHP_INT_MIN in php.h, replaces LONG_MIN where appropriate
+ - ZEND_UINT_MAX ULONG_MAX
+ - SIZEOF_ZEND_INT Replaces SIZEOF_ZEND_LONG where appropriate
+ - ZEND_SIZE_MAX Max value of zend_size_t
========================
2. Build system changes
diff --git a/Zend/tests/bug54013.phpt b/Zend/tests/bug54013.phpt
index d3069678b4..8e498a7f51 100644
--- a/Zend/tests/bug54013.phpt
+++ b/Zend/tests/bug54013.phpt
@@ -21,4 +21,4 @@ var_dump($params[0], $params[1]);
?>
--EXPECTF--
-Fatal error: Redefinition of parameter aaaaaaaa in %sbug54013.php on line 5
+Fatal error: Redefinition of parameter $aaaaaaaa in %sbug54013.php on line 5
diff --git a/Zend/tests/bug60825.phpt b/Zend/tests/bug60825.phpt
index 0aeb8f77e3..f2f5b602ad 100644
--- a/Zend/tests/bug60825.phpt
+++ b/Zend/tests/bug60825.phpt
@@ -1,5 +1,5 @@
--TEST--
-Bug #60825 (Segfault when running symfony 2 tests)
+Bug #60825 (Segfault when running symfony 2 tests) (PHP7)
--DESCRIPTION--
run this with valgrind
--FILE--
@@ -13,7 +13,10 @@ class test {
}
$a = new test;
require_once $a;
-debug_zval_dump(test::$x);
+debug_zval_dump($a, test::$x);
?>
--EXPECTF--
-string(%d) "%sbug60825.php" refcount(2)
+object(test)#%d (0) refcount(%d){
+}
+object(test)#%d (0) refcount(%d){
+}
diff --git a/Zend/tests/bug64515.phpt b/Zend/tests/bug64515.phpt
index 6330ec8096..b101c17c3a 100644
--- a/Zend/tests/bug64515.phpt
+++ b/Zend/tests/bug64515.phpt
@@ -9,4 +9,4 @@ foo();
echo "okey";
?>
--EXPECTF--
-Fatal error: Redefinition of parameter unused in %sbug64515.php on line 2
+Fatal error: Redefinition of parameter $unused in %sbug64515.php on line 2
diff --git a/Zend/tests/bug67856.phpt b/Zend/tests/bug67856.phpt
new file mode 100644
index 0000000000..e867c8f37c
--- /dev/null
+++ b/Zend/tests/bug67856.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #67856 (Leak when using array_reduce with by-ref function)
+--FILE--
+<?php
+$array = [1, 2, 3];
+var_dump(array_reduce($array, function(&$a, &$b) {
+ return $a + $b;
+}, 0));
+?>
+--EXPECT--
+int(6)
diff --git a/Zend/tests/bug67874.phpt b/Zend/tests/bug67874.phpt
new file mode 100644
index 0000000000..d851c9a4c1
--- /dev/null
+++ b/Zend/tests/bug67874.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #67874 Crash in array_map()
+--FILE--
+<?php
+$a = array(1,2,3);
+$data = array($a);
+$data = array_map('current', $data);
+var_dump($data);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ int(1)
+}
diff --git a/Zend/tests/closure_026.phpt b/Zend/tests/closure_026.phpt
index 150cc86584..82a948d1a0 100644
--- a/Zend/tests/closure_026.phpt
+++ b/Zend/tests/closure_026.phpt
@@ -47,7 +47,10 @@ array(1) {
["this"]=>
object(foo)#%d (1) {
["a"]=>
- *RECURSION*
+ array(1) {
+ [0]=>
+ *RECURSION*
+ }
}
}
}
diff --git a/Zend/zend.c b/Zend/zend.c
index 8bcdbd82c2..2d4232ee98 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -46,7 +46,7 @@
/* true multithread-shared globals */
ZEND_API zend_class_entry *zend_standard_class_def = NULL;
-ZEND_API int (*zend_printf)(const char *format, ...);
+ZEND_API size_t (*zend_printf)(const char *format, ...);
ZEND_API zend_write_func_t zend_write;
ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
@@ -54,14 +54,14 @@ ZEND_API void (*zend_block_interruptions)(void);
ZEND_API void (*zend_unblock_interruptions)(void);
ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC);
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
-int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
+size_t (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap);
ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
void (*zend_on_timeout)(int seconds TSRMLS_DC);
-static void (*zend_message_dispatcher_p)(long message, const void *data TSRMLS_DC);
+static void (*zend_message_dispatcher_p)(zend_long message, const void *data TSRMLS_DC);
static int (*zend_get_configuration_directive_p)(const char *name, uint name_length, zval *contents);
static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
@@ -134,7 +134,7 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent,
{
zval *tmp;
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
int i;
for (i = 0; i < indent; i++) {
@@ -174,7 +174,7 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent,
}
} else {
char key[25];
- snprintf(key, sizeof(key), "%ld", num_key);
+ snprintf(key, sizeof(key), ZEND_LONG_FMT, num_key);
ZEND_PUTS_EX(key);
}
ZEND_PUTS_EX("] => ");
@@ -193,7 +193,7 @@ static void print_flat_hash(HashTable *ht TSRMLS_DC) /* {{{ */
{
zval *tmp;
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
int i = 0;
ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, string_key, tmp) {
@@ -204,7 +204,7 @@ static void print_flat_hash(HashTable *ht TSRMLS_DC) /* {{{ */
if (string_key) {
ZEND_WRITE(string_key->val, string_key->len);
} else {
- zend_printf("%ld", num_key);
+ zend_printf(ZEND_ULONG_FMT, num_key);
}
ZEND_PUTS("] => ");
zend_print_flat_zval_r(tmp TSRMLS_CC);
@@ -226,23 +226,23 @@ again:
break;
case IS_TRUE:
if (CG(one_char_string)['1']) {
- ZVAL_INT_STR(expr_copy, CG(one_char_string)['1']);
+ ZVAL_INTERNED_STR(expr_copy, CG(one_char_string)['1']);
} else {
- ZVAL_NEW_STR(expr_copy, STR_INIT("1", 1, 0));
+ ZVAL_NEW_STR(expr_copy, zend_string_init("1", 1, 0));
}
break;
case IS_RESOURCE: {
char buf[sizeof("Resource id #") + MAX_LENGTH_OF_LONG];
int len;
- len = snprintf(buf, sizeof(buf), "Resource id #%ld", Z_RES_HANDLE_P(expr));
- ZVAL_NEW_STR(expr_copy, STR_INIT(buf, len, 0));
+ len = snprintf(buf, sizeof(buf), "Resource id #" ZEND_LONG_FMT, Z_RES_HANDLE_P(expr));
+ ZVAL_NEW_STR(expr_copy, zend_string_init(buf, len, 0));
}
break;
case IS_ARRAY:
zend_error(E_NOTICE, "Array to string conversion");
// TODO: use interned string ???
- ZVAL_NEW_STR(expr_copy, STR_INIT("Array", sizeof("Array") - 1, 0));
+ ZVAL_NEW_STR(expr_copy, zend_string_init("Array", sizeof("Array") - 1, 0));
break;
case IS_OBJECT:
if (Z_OBJ_HANDLER_P(expr, cast_object)) {
@@ -278,7 +278,7 @@ again:
case IS_REFERENCE:
expr = Z_REFVAL_P(expr);
if (Z_TYPE_P(expr) == IS_STRING) {
- ZVAL_STR(expr_copy, STR_COPY(Z_STR_P(expr)));
+ ZVAL_STR(expr_copy, zend_string_copy(Z_STR_P(expr)));
return 1;
}
goto again;
@@ -307,7 +307,7 @@ ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int in
write_func(str->val, len);
}
- STR_RELEASE(str);
+ zend_string_release(str);
return len;
}
/* }}} */
@@ -343,7 +343,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC) /* {{{ */
zend_printf("%s Object (", "Unknown Class");
}
if (class_name) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
}
if (Z_OBJ_HANDLER_P(expr, get_properties)) {
properties = Z_OBJPROP_P(expr);
@@ -406,7 +406,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
}
ZEND_PUTS_EX(" Object\n");
if (class_name) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
}
if ((properties = Z_OBJDEBUG_P(expr, is_temp)) == NULL) {
break;
@@ -443,7 +443,7 @@ static FILE *zend_fopen_wrapper(const char *filename, char **opened_path TSRMLS_
#ifdef ZTS
static zend_bool asp_tags_default = 0;
static zend_bool short_tags_default = 1;
-static zend_uint compiler_options_default = ZEND_COMPILE_DEFAULT;
+static uint32_t compiler_options_default = ZEND_COMPILE_DEFAULT;
#else
# define asp_tags_default 0
# define short_tags_default 1
@@ -739,7 +739,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions TS
zend_interned_strings_init(TSRMLS_C);
zend_startup_builtin_functions(TSRMLS_C);
zend_register_standard_constants(TSRMLS_C);
- zend_register_auto_global(STR_INIT("GLOBALS", sizeof("GLOBALS") - 1, 1), 1, php_auto_globals_create_globals TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("GLOBALS", sizeof("GLOBALS") - 1, 1), 1, php_auto_globals_create_globals TSRMLS_CC);
#ifndef ZTS
zend_init_rsrc_plist(TSRMLS_C);
@@ -972,7 +972,7 @@ ZEND_API void zend_deactivate(TSRMLS_D) /* {{{ */
/* }}} */
BEGIN_EXTERN_C()
-ZEND_API void zend_message_dispatcher(long message, const void *data TSRMLS_DC) /* {{{ */
+ZEND_API void zend_message_dispatcher(zend_long message, const void *data TSRMLS_DC) /* {{{ */
{
if (zend_message_dispatcher_p) {
zend_message_dispatcher_p(message, data TSRMLS_CC);
@@ -1148,7 +1148,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
#endif
va_copy(usr_copy, args);
len = zend_vspprintf(&str, 0, format, usr_copy);
- ZVAL_NEW_STR(&params[1], STR_INIT(str, len, 0));
+ ZVAL_NEW_STR(&params[1], zend_string_init(str, len, 0));
efree(str);
#ifdef va_copy
va_end(usr_copy);
@@ -1281,7 +1281,7 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou
int i;
zend_file_handle *file_handle;
zend_op_array *op_array;
- long orig_interactive = CG(interactive);
+ zend_long orig_interactive = CG(interactive);
va_start(files, file_count);
for (i = 0; i < file_count; i++) {
@@ -1378,7 +1378,7 @@ void free_estring(char **str_p) /* {{{ */
void free_string_zval(zval *zv) /* {{{ */
{
zend_string *str = Z_PTR_P(zv);
- STR_RELEASE(str);
+ zend_string_release(str);
}
/* }}} */
diff --git a/Zend/zend.h b/Zend/zend.h
index 52cc923e74..52adbd267e 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -273,14 +273,14 @@ char *alloca ();
#define LONG_MIN (- LONG_MAX - 1)
#endif
-#if SIZEOF_LONG == 4
+#if SIZEOF_ZEND_INT == 4
#define MAX_LENGTH_OF_LONG 11
static const char long_min_digits[] = "2147483648";
-#elif SIZEOF_LONG == 8
+#elif SIZEOF_ZEND_INT == 8
#define MAX_LENGTH_OF_LONG 20
static const char long_min_digits[] = "9223372036854775808";
#else
-#error "Unknown SIZEOF_LONG"
+#error "Unknown SIZEOF_ZEND_INT"
#endif
#define MAX_LENGTH_OF_DOUBLE 32
@@ -293,7 +293,7 @@ typedef enum {
#include "zend_hash.h"
#include "zend_llist.h"
-#define INTERNAL_FUNCTION_PARAMETERS zend_uint param_count, zval *return_value TSRMLS_DC
+#define INTERNAL_FUNCTION_PARAMETERS uint32_t param_count, zval *return_value TSRMLS_DC
#define INTERNAL_FUNCTION_PARAM_PASSTHRU param_count, return_value TSRMLS_CC
#define USED_RET() \
@@ -387,7 +387,7 @@ void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((nore
# else /* ! (CRAY || __arm) */
# define XtOffset(p_type, field) \
- ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
+ ((zend_long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
# endif /* !CRAY */
@@ -402,22 +402,22 @@ void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((nore
#include "zend_string.h"
#include "zend_ast.h"
-static zend_always_inline zend_uint zval_refcount_p(zval* pz) {
+static zend_always_inline uint32_t zval_refcount_p(zval* pz) {
ZEND_ASSERT(Z_REFCOUNTED_P(pz) || Z_IMMUTABLE_P(pz));
return GC_REFCOUNT(Z_COUNTED_P(pz));
}
-static zend_always_inline zend_uint zval_set_refcount_p(zval* pz, zend_uint rc) {
+static zend_always_inline uint32_t zval_set_refcount_p(zval* pz, uint32_t rc) {
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
return GC_REFCOUNT(Z_COUNTED_P(pz)) = rc;
}
-static zend_always_inline zend_uint zval_addref_p(zval* pz) {
+static zend_always_inline uint32_t zval_addref_p(zval* pz) {
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
return ++GC_REFCOUNT(Z_COUNTED_P(pz));
}
-static zend_always_inline zend_uint zval_delref_p(zval* pz) {
+static zend_always_inline uint32_t zval_delref_p(zval* pz) {
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
return --GC_REFCOUNT(Z_COUNTED_P(pz));
}
@@ -463,7 +463,7 @@ struct _zend_trait_alias {
/**
* modifiers to be set on trait method
*/
- zend_uint modifiers;
+ uint32_t modifiers;
};
typedef struct _zend_trait_alias zend_trait_alias;
@@ -472,7 +472,7 @@ struct _zend_class_entry {
zend_string *name;
struct _zend_class_entry *parent;
int refcount;
- zend_uint ce_flags;
+ uint32_t ce_flags;
HashTable function_table;
HashTable properties_info;
@@ -506,22 +506,22 @@ struct _zend_class_entry {
union _zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method TSRMLS_DC);
/* serializer callbacks */
- int (*serialize)(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
- int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
+ int (*serialize)(zval *object, unsigned char **buffer, uint32_t *buf_len, zend_serialize_data *data TSRMLS_DC);
+ int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, uint32_t buf_len, zend_unserialize_data *data TSRMLS_DC);
zend_class_entry **interfaces;
- zend_uint num_interfaces;
+ uint32_t num_interfaces;
zend_class_entry **traits;
- zend_uint num_traits;
+ uint32_t num_traits;
zend_trait_alias **trait_aliases;
zend_trait_precedence **trait_precedences;
union {
struct {
zend_string *filename;
- zend_uint line_start;
- zend_uint line_end;
+ uint32_t line_start;
+ uint32_t line_end;
zend_string *doc_comment;
} user;
struct {
@@ -534,8 +534,8 @@ struct _zend_class_entry {
#include "zend_stream.h"
typedef struct _zend_utility_functions {
void (*error_function)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
- int (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
- int (*write_function)(const char *str, uint str_length);
+ size_t (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
+ size_t (*write_function)(const char *str, size_t str_length);
FILE *(*fopen_function)(const char *filename, char **opened_path TSRMLS_DC);
void (*message_handler)(long message, const void *data TSRMLS_DC);
void (*block_interruptions)(void);
@@ -544,7 +544,7 @@ typedef struct _zend_utility_functions {
void (*ticks_function)(int ticks TSRMLS_DC);
void (*on_timeout)(int seconds TSRMLS_DC);
int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
- int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
+ size_t (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
zend_string *(*vstrpprintf_function)(size_t max_len, const char *format, va_list ap);
char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC);
char *(*resolve_path_function)(const char *filename, int filename_len TSRMLS_DC);
@@ -646,7 +646,7 @@ END_EXTERN_C()
#define ZEND_PUTC(c) zend_write(&(c), 1)
BEGIN_EXTERN_C()
-extern ZEND_API int (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
+extern ZEND_API size_t (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
extern ZEND_API zend_write_func_t zend_write;
extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
extern ZEND_API void (*zend_block_interruptions)(void);
@@ -655,7 +655,7 @@ extern ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC);
extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC);
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
-extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
+extern size_t (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
extern zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap);
extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
@@ -685,7 +685,7 @@ END_EXTERN_C()
#endif
BEGIN_EXTERN_C()
-ZEND_API void zend_message_dispatcher(long message, const void *data TSRMLS_DC);
+ZEND_API void zend_message_dispatcher(zend_long message, const void *data TSRMLS_DC);
ZEND_API int zend_get_configuration_directive(const char *name, uint name_length, zval *contents);
END_EXTERN_C()
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 9881740c06..41b0149038 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -413,7 +413,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
case 'l':
case 'L':
{
- long *p = va_arg(*va, long *);
+ zend_long *p = va_arg(*va, zend_long *);
if (check_null) {
zend_bool *p = va_arg(*va, zend_bool *);
@@ -430,11 +430,11 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
return "long";
} else if (type == IS_DOUBLE) {
if (c == 'L') {
- if (d > LONG_MAX) {
- *p = LONG_MAX;
+ if (d > ZEND_LONG_MAX) {
+ *p = ZEND_LONG_MAX;
break;
- } else if (d < LONG_MIN) {
- *p = LONG_MIN;
+ } else if (d < ZEND_LONG_MIN) {
+ *p = ZEND_LONG_MIN;
break;
}
}
@@ -446,11 +446,11 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
case IS_DOUBLE:
if (c == 'L') {
- if (Z_DVAL_P(arg) > LONG_MAX) {
- *p = LONG_MAX;
+ if (Z_DVAL_P(arg) > ZEND_LONG_MAX) {
+ *p = ZEND_LONG_MAX;
break;
- } else if (Z_DVAL_P(arg) < LONG_MIN) {
- *p = LONG_MIN;
+ } else if (Z_DVAL_P(arg) < ZEND_LONG_MIN) {
+ *p = ZEND_LONG_MIN;
break;
}
}
@@ -458,7 +458,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
case IS_FALSE:
case IS_TRUE:
case IS_LONG:
- convert_to_long_ex(arg);
+ convert_to_int_ex(arg);
*p = Z_LVAL_P(arg);
break;
@@ -483,7 +483,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
switch (Z_TYPE_P(arg)) {
case IS_STRING:
{
- long l;
+ zend_long l;
int type;
if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &l, p, -1)) == 0) {
@@ -871,6 +871,7 @@ static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va,
case 'f': case 'A':
case 'H': case 'p':
case 'S': case 'P':
+ case 'L':
max_num_args++;
break;
@@ -1143,7 +1144,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties TSRMLS_DC)
if (key) {
zval member;
- ZVAL_STR(&member, STR_COPY(key));
+ ZVAL_STR(&member, zend_string_copy(key));
obj_ht->write_property(obj, &member, value, NULL TSRMLS_CC);
zval_ptr_dtor(&member);
}
@@ -1363,7 +1364,7 @@ ZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr)
}
/* }}} */
-ZEND_API int add_assoc_long_ex(zval *arg, const char *key, uint key_len, long n) /* {{{ */
+ZEND_API int add_assoc_long_ex(zval *arg, const char *key, uint key_len, zend_long n) /* {{{ */
{
zval *ret, tmp;
@@ -1452,7 +1453,7 @@ ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, uint key_len, zval *v
}
/* }}} */
-ZEND_API int add_index_long(zval *arg, ulong index, long n) /* {{{ */
+ZEND_API int add_index_long(zval *arg, zend_ulong index, zend_long n) /* {{{ */
{
zval tmp;
@@ -1461,7 +1462,7 @@ ZEND_API int add_index_long(zval *arg, ulong index, long n) /* {{{ */
}
/* }}} */
-ZEND_API int add_index_null(zval *arg, ulong index) /* {{{ */
+ZEND_API int add_index_null(zval *arg, zend_ulong index) /* {{{ */
{
zval tmp;
@@ -1470,7 +1471,7 @@ ZEND_API int add_index_null(zval *arg, ulong index) /* {{{ */
}
/* }}} */
-ZEND_API int add_index_bool(zval *arg, ulong index, int b) /* {{{ */
+ZEND_API int add_index_bool(zval *arg, zend_ulong index, int b) /* {{{ */
{
zval tmp;
@@ -1479,7 +1480,7 @@ ZEND_API int add_index_bool(zval *arg, ulong index, int b) /* {{{ */
}
/* }}} */
-ZEND_API int add_index_resource(zval *arg, ulong index, zend_resource *r) /* {{{ */
+ZEND_API int add_index_resource(zval *arg, zend_ulong index, zend_resource *r) /* {{{ */
{
zval tmp;
@@ -1488,7 +1489,7 @@ ZEND_API int add_index_resource(zval *arg, ulong index, zend_resource *r) /* {{{
}
/* }}} */
-ZEND_API int add_index_double(zval *arg, ulong index, double d) /* {{{ */
+ZEND_API int add_index_double(zval *arg, zend_ulong index, double d) /* {{{ */
{
zval tmp;
@@ -1497,7 +1498,7 @@ ZEND_API int add_index_double(zval *arg, ulong index, double d) /* {{{ */
}
/* }}} */
-ZEND_API int add_index_str(zval *arg, ulong index, zend_string *str) /* {{{ */
+ZEND_API int add_index_str(zval *arg, zend_ulong index, zend_string *str) /* {{{ */
{
zval tmp;
@@ -1506,7 +1507,7 @@ ZEND_API int add_index_str(zval *arg, ulong index, zend_string *str) /* {{{ */
}
/* }}} */
-ZEND_API int add_index_string(zval *arg, ulong index, const char *str) /* {{{ */
+ZEND_API int add_index_string(zval *arg, zend_ulong index, const char *str) /* {{{ */
{
zval tmp;
@@ -1515,7 +1516,7 @@ ZEND_API int add_index_string(zval *arg, ulong index, const char *str) /* {{{ */
}
/* }}} */
-ZEND_API int add_index_stringl(zval *arg, ulong index, const char *str, uint length) /* {{{ */
+ZEND_API int add_index_stringl(zval *arg, zend_ulong index, const char *str, uint length) /* {{{ */
{
zval tmp;
@@ -1524,13 +1525,13 @@ ZEND_API int add_index_stringl(zval *arg, ulong index, const char *str, uint len
}
/* }}} */
-ZEND_API int add_index_zval(zval *arg, ulong index, zval *value) /* {{{ */
+ZEND_API int add_index_zval(zval *arg, zend_ulong index, zval *value) /* {{{ */
{
return zend_hash_index_update(Z_ARRVAL_P(arg), index, value) ? SUCCESS : FAILURE;
}
/* }}} */
-ZEND_API int add_next_index_long(zval *arg, long n) /* {{{ */
+ZEND_API int add_next_index_long(zval *arg, zend_long n) /* {{{ */
{
zval tmp;
@@ -1628,7 +1629,7 @@ ZEND_API zval *add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len
}
/* }}} */
-ZEND_API zval *add_get_index_long(zval *arg, ulong index, long l) /* {{{ */
+ZEND_API zval *add_get_index_long(zval *arg, zend_ulong index, zend_long l) /* {{{ */
{
zval tmp;
@@ -1637,7 +1638,7 @@ ZEND_API zval *add_get_index_long(zval *arg, ulong index, long l) /* {{{ */
}
/* }}} */
-ZEND_API zval *add_get_index_double(zval *arg, ulong index, double d) /* {{{ */
+ZEND_API zval *add_get_index_double(zval *arg, zend_ulong index, double d) /* {{{ */
{
zval tmp;
@@ -1646,7 +1647,7 @@ ZEND_API zval *add_get_index_double(zval *arg, ulong index, double d) /* {{{ */
}
/* }}} */
-ZEND_API zval *add_get_index_str(zval *arg, ulong index, zend_string *str) /* {{{ */
+ZEND_API zval *add_get_index_str(zval *arg, zend_ulong index, zend_string *str) /* {{{ */
{
zval tmp;
@@ -1655,7 +1656,7 @@ ZEND_API zval *add_get_index_str(zval *arg, ulong index, zend_string *str) /* {{
}
/* }}} */
-ZEND_API zval *add_get_index_string(zval *arg, ulong index, const char *str) /* {{{ */
+ZEND_API zval *add_get_index_string(zval *arg, zend_ulong index, const char *str) /* {{{ */
{
zval tmp;
@@ -1664,7 +1665,7 @@ ZEND_API zval *add_get_index_string(zval *arg, ulong index, const char *str) /*
}
/* }}} */
-ZEND_API zval *add_get_index_stringl(zval *arg, ulong index, const char *str, uint length) /* {{{ */
+ZEND_API zval *add_get_index_stringl(zval *arg, zend_ulong index, const char *str, uint length) /* {{{ */
{
zval tmp;
@@ -1685,7 +1686,7 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value TSRMLS_DC)
result = zend_symtable_update(ht, STR_EMPTY_ALLOC(), value);
break;
case IS_RESOURCE:
- zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_RES_HANDLE_P(key), Z_RES_HANDLE_P(key));
+ zend_error(E_STRICT, "Resource ID#" ZEND_LONG_FMT " used as offset, casting to integer (%pd)", Z_RES_HANDLE_P(key), Z_RES_HANDLE_P(key));
result = zend_hash_index_update(ht, Z_RES_HANDLE_P(key), value);
break;
case IS_FALSE:
@@ -1716,7 +1717,7 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value TSRMLS_DC)
}
/* }}} */
-ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, long n TSRMLS_DC) /* {{{ */
+ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, zend_long n TSRMLS_DC) /* {{{ */
{
zval tmp;
zval z_key;
@@ -1730,7 +1731,7 @@ ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, long
}
/* }}} */
-ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, int b TSRMLS_DC) /* {{{ */
+ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, zend_long b TSRMLS_DC) /* {{{ */
{
zval tmp;
zval z_key;
@@ -1858,17 +1859,17 @@ ZEND_API int zend_startup_module_ex(zend_module_entry *module TSRMLS_DC) /* {{{
zend_module_entry *req_mod;
name_len = strlen(dep->name);
- lcname = STR_ALLOC(name_len, 0);
+ lcname = zend_string_alloc(name_len, 0);
zend_str_tolower_copy(lcname->val, dep->name, name_len);
if ((req_mod = zend_hash_find_ptr(&module_registry, lcname)) == NULL || !req_mod->module_started) {
- STR_FREE(lcname);
+ zend_string_free(lcname);
/* TODO: Check version relationship */
zend_error(E_CORE_WARNING, "Cannot load module '%s' because required module '%s' is not loaded", module->name, dep->name);
module->module_started = 0;
return FAILURE;
}
- STR_FREE(lcname);
+ zend_string_free(lcname);
}
++dep;
}
@@ -2047,31 +2048,31 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module TS
while (dep->name) {
if (dep->type == MODULE_DEP_CONFLICTS) {
name_len = strlen(dep->name);
- lcname = STR_ALLOC(name_len, 0);
+ lcname = zend_string_alloc(name_len, 0);
zend_str_tolower_copy(lcname->val, dep->name, name_len);
if (zend_hash_exists(&module_registry, lcname)) {
- STR_FREE(lcname);
+ zend_string_free(lcname);
/* TODO: Check version relationship */
zend_error(E_CORE_WARNING, "Cannot load module '%s' because conflicting module '%s' is already loaded", module->name, dep->name);
return NULL;
}
- STR_FREE(lcname);
+ zend_string_free(lcname);
}
++dep;
}
}
name_len = strlen(module->name);
- lcname = STR_ALLOC(name_len, 1);
+ lcname = zend_string_alloc(name_len, 1);
zend_str_tolower_copy(lcname->val, module->name, name_len);
if ((module_ptr = zend_hash_add_mem(&module_registry, lcname, module, sizeof(zend_module_entry))) == NULL) {
zend_error(E_CORE_WARNING, "Module '%s' already loaded", module->name);
- STR_RELEASE(lcname);
+ zend_string_release(lcname);
return NULL;
}
- STR_RELEASE(lcname);
+ zend_string_release(lcname);
module = module_ptr;
EG(current_module) = module;
@@ -2199,7 +2200,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
while (ptr->fname) {
fname_len = strlen(ptr->fname);
internal_function->handler = ptr->handler;
- internal_function->function_name = zend_new_interned_string(STR_INIT(ptr->fname, fname_len, 1) TSRMLS_CC);
+ internal_function->function_name = zend_new_interned_string(zend_string_init(ptr->fname, fname_len, 1) TSRMLS_CC);
internal_function->scope = scope;
internal_function->prototype = NULL;
if (ptr->flags) {
@@ -2265,7 +2266,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
return FAILURE;
}
}
- lowercase_name = STR_ALLOC(fname_len, 1);
+ lowercase_name = zend_string_alloc(fname_len, 1);
zend_str_tolower_copy(lowercase_name->val, ptr->fname, fname_len);
lowercase_name = zend_new_interned_string(lowercase_name TSRMLS_CC);
reg_function = malloc(sizeof(zend_internal_function));
@@ -2273,7 +2274,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
if (zend_hash_add_ptr(target_function_table, lowercase_name, reg_function) == NULL) {
unload=1;
free(reg_function);
- STR_RELEASE(lowercase_name);
+ zend_string_release(lowercase_name);
break;
}
@@ -2330,7 +2331,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
}
ptr++;
count++;
- STR_RELEASE(lowercase_name);
+ zend_string_release(lowercase_name);
}
if (unload) { /* before unloading, display all remaining bad function in the module */
if (scope) {
@@ -2338,12 +2339,12 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
}
while (ptr->fname) {
fname_len = strlen(ptr->fname);
- lowercase_name = STR_ALLOC(fname_len, 0);
+ lowercase_name = zend_string_alloc(fname_len, 0);
zend_str_tolower_copy(lowercase_name->val, ptr->fname, fname_len);
if (zend_hash_exists(target_function_table, lowercase_name)) {
zend_error(error_type, "Function registration failed - duplicate name - %s%s%s", scope ? scope->name->val : "", scope ? "::" : "", ptr->fname);
}
- STR_FREE(lowercase_name);
+ zend_string_free(lowercase_name);
ptr++;
}
zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);
@@ -2454,10 +2455,10 @@ ZEND_API void zend_unregister_functions(const zend_function_entry *functions, in
break;
}
fname_len = strlen(ptr->fname);
- lowercase_name = STR_ALLOC(fname_len, 0);
+ lowercase_name = zend_string_alloc(fname_len, 0);
zend_str_tolower_copy(lowercase_name->val, ptr->fname, fname_len);
zend_hash_del(target_function_table, lowercase_name);
- STR_FREE(lowercase_name);
+ zend_string_free(lowercase_name);
ptr++;
i++;
}
@@ -2656,10 +2657,10 @@ int zend_next_free_module(void) /* {{{ */
}
/* }}} */
-static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class_entry, zend_uint ce_flags TSRMLS_DC) /* {{{ */
+static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class_entry, uint32_t ce_flags TSRMLS_DC) /* {{{ */
{
zend_class_entry *class_entry = malloc(sizeof(zend_class_entry));
- zend_string *lowercase_name = STR_ALLOC(orig_class_entry->name->len, 1);
+ zend_string *lowercase_name = zend_string_alloc(orig_class_entry->name->len, 1);
*class_entry = *orig_class_entry;
class_entry->type = ZEND_INTERNAL_CLASS;
@@ -2674,7 +2675,7 @@ static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class
zend_str_tolower_copy(lowercase_name->val, orig_class_entry->name->val, class_entry->name->len);
lowercase_name = zend_new_interned_string(lowercase_name TSRMLS_CC);
zend_hash_update_ptr(CG(class_table), lowercase_name, class_entry);
- STR_RELEASE(lowercase_name);
+ zend_string_release(lowercase_name);
return class_entry;
}
/* }}} */
@@ -2731,14 +2732,14 @@ ZEND_API int zend_register_class_alias_ex(const char *name, int name_len, zend_c
zend_string *lcname;
if (name[0] == '\\') {
- lcname = STR_ALLOC(name_len-1, 1);
+ lcname = zend_string_alloc(name_len-1, 1);
zend_str_tolower_copy(lcname->val, name+1, name_len-1);
} else {
- lcname = STR_ALLOC(name_len, 1);
+ lcname = zend_string_alloc(name_len, 1);
zend_str_tolower_copy(lcname->val, name, name_len);
}
ce = zend_hash_add_ptr(CG(class_table), lcname, ce);
- STR_RELEASE(lcname);
+ zend_string_release(lcname);
if (ce) {
ce->refcount++;
return SUCCESS;
@@ -2824,7 +2825,7 @@ ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_
zend_class_entry *disabled_class;
zend_string *key;
- key = STR_ALLOC(class_name_length, 0);
+ key = zend_string_alloc(class_name_length, 0);
zend_str_tolower_copy(key->val, class_name, class_name_length);
disabled_class = zend_hash_find_ptr(CG(class_table), key);
if (!disabled_class) {
@@ -2846,7 +2847,7 @@ static int zend_is_callable_check_class(zend_string *name, zend_fcall_info_cache
ALLOCA_FLAG(use_heap);
STR_ALLOCA_ALLOC(lcname, name_len, use_heap);
- zend_str_tolower_copy(lcname->val, name->val, name_len + 1);
+ zend_str_tolower_copy(lcname->val, name->val, name_len);
*strict_class = 0;
if (name_len == sizeof("self") - 1 &&
@@ -2956,7 +2957,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
if (lmname == Z_STR_P(callable)) {
STR_ALLOCA_INIT(lmname, Z_STRVAL_P(callable), Z_STRLEN_P(callable), use_heap);
} else {
- STR_FORGET_HASH_VAL(lmname);
+ zend_string_forget_hash_val(lmname);
}
zend_str_tolower(lmname->val, lmname->len);
if ((fcc->function_handler = zend_hash_find_ptr(EG(function_table), lmname)) != NULL) {
@@ -2990,13 +2991,13 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
EG(scope) = ce_org;
}
- cname = STR_INIT(Z_STRVAL_P(callable), clen, 0);
+ cname = zend_string_init(Z_STRVAL_P(callable), clen, 0);
if (!zend_is_callable_check_class(cname, fcc, &strict_class, error TSRMLS_CC)) {
- STR_RELEASE(cname);
+ zend_string_release(cname);
EG(scope) = last_scope;
return 0;
}
- STR_RELEASE(cname);
+ zend_string_release(cname);
EG(scope) = last_scope;
ftable = &fcc->calling_scope->function_table;
@@ -3004,12 +3005,12 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
if (error) zend_spprintf(error, 0, "class '%s' is not a subclass of '%s'", ce_org->name->val, fcc->calling_scope->name->val);
return 0;
}
- mname = STR_INIT(Z_STRVAL_P(callable) + clen + 2, mlen, 0);
+ mname = zend_string_init(Z_STRVAL_P(callable) + clen + 2, mlen, 0);
} else if (ce_org) {
/* Try to fetch find static method of given class. */
mlen = Z_STRLEN_P(callable);
mname = Z_STR_P(callable);
- STR_ADDREF(mname);
+ zend_string_addref(mname);
ftable = &ce_org->function_table;
fcc->calling_scope = ce_org;
} else {
@@ -3020,7 +3021,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
return 0;
}
- lmname = STR_ALLOC(mlen, 0);
+ lmname = zend_string_alloc(mlen, 0);
zend_str_tolower_copy(lmname->val, mname->val, mlen);
if (strict_class &&
fcc->calling_scope &&
@@ -3074,7 +3075,7 @@ get_function_via_handler:
fcc->function_handler->internal_function.scope = ce_org;
fcc->function_handler->internal_function.fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
fcc->function_handler->internal_function.function_name = mname;
- STR_ADDREF(mname);
+ zend_string_addref(mname);
call_via_handler = 1;
retval = 1;
} else if (fcc->object->handlers->get_method) {
@@ -3085,7 +3086,7 @@ get_function_via_handler:
!instanceof_function(ce_org, fcc->function_handler->common.scope TSRMLS_CC))) {
if ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) {
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
- STR_RELEASE(fcc->function_handler->common.function_name);
+ zend_string_release(fcc->function_handler->common.function_name);
}
efree(fcc->function_handler);
}
@@ -3188,8 +3189,8 @@ get_function_via_handler:
if (error) zend_spprintf(error, 0, "function '%s' does not exist", mname->val);
}
}
- STR_FREE(lmname);
- STR_RELEASE(mname);
+ zend_string_free(lmname);
+ zend_string_release(mname);
if (fcc->object) {
fcc->called_scope = zend_get_class_entry(fcc->object TSRMLS_CC);
@@ -3237,7 +3238,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
if (callable_name) {
char *ptr;
- *callable_name = STR_ALLOC(fcc->calling_scope->name->len + Z_STRLEN_P(callable) + sizeof("::") - 1, 0);
+ *callable_name = zend_string_alloc(fcc->calling_scope->name->len + Z_STRLEN_P(callable) + sizeof("::") - 1, 0);
ptr = (*callable_name)->val;
memcpy(ptr, fcc->calling_scope->name->val, fcc->calling_scope->name->len);
ptr += fcc->calling_scope->name->len;
@@ -3246,7 +3247,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
memcpy(ptr, Z_STRVAL_P(callable), Z_STRLEN_P(callable) + 1);
}
} else if (callable_name) {
- *callable_name = STR_COPY(Z_STR_P(callable));
+ *callable_name = zend_string_copy(Z_STR_P(callable));
}
if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
fcc->called_scope = fcc->calling_scope;
@@ -3261,7 +3262,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
- STR_RELEASE(fcc->function_handler->common.function_name);
+ zend_string_release(fcc->function_handler->common.function_name);
}
efree(fcc->function_handler);
}
@@ -3294,7 +3295,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
char *ptr;
- *callable_name = STR_ALLOC(Z_STRLEN_P(obj) + Z_STRLEN_P(method) + sizeof("::") - 1, 0);
+ *callable_name = zend_string_alloc(Z_STRLEN_P(obj) + Z_STRLEN_P(method) + sizeof("::") - 1, 0);
ptr = (*callable_name)->val;
memcpy(ptr, Z_STRVAL_P(obj), Z_STRLEN_P(obj));
ptr += Z_STRLEN_P(obj);
@@ -3324,7 +3325,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
if (callable_name) {
char *ptr;
- *callable_name = STR_ALLOC(fcc->calling_scope->name->len + Z_STRLEN_P(method) + sizeof("::") - 1, 0);
+ *callable_name = zend_string_alloc(fcc->calling_scope->name->len + Z_STRLEN_P(method) + sizeof("::") - 1, 0);
ptr = (*callable_name)->val;
memcpy(ptr, fcc->calling_scope->name->val, fcc->calling_scope->name->len);
ptr += fcc->calling_scope->name->len;
@@ -3349,7 +3350,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
- STR_RELEASE(fcc->function_handler->common.function_name);
+ zend_string_release(fcc->function_handler->common.function_name);
}
efree(fcc->function_handler);
}
@@ -3368,7 +3369,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
if (error) zend_spprintf(error, 0, "array must have exactly two members");
}
if (callable_name) {
- *callable_name = STR_INIT("Array", sizeof("Array")-1, 0);
+ *callable_name = zend_string_init("Array", sizeof("Array")-1, 0);
}
}
return 0;
@@ -3379,7 +3380,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
if (callable_name) {
zend_class_entry *ce = Z_OBJCE_P(callable); /* TBFixed: what if it's overloaded? */
- *callable_name = STR_ALLOC(ce->name->len + sizeof("::__invoke") - 1, 0);
+ *callable_name = zend_string_alloc(ce->name->len + sizeof("::__invoke") - 1, 0);
memcpy((*callable_name)->val, ce->name->val, ce->name->len);
memcpy((*callable_name)->val + ce->name->len, "::__invoke", sizeof("::__invoke"));
}
@@ -3411,8 +3412,8 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam
if (Z_TYPE_P(callable) == IS_STRING && fcc.calling_scope) {
zval_dtor(callable);
array_init(callable);
- add_next_index_str(callable, STR_COPY(fcc.calling_scope->name));
- add_next_index_str(callable, STR_COPY(fcc.function_handler->common.function_name));
+ add_next_index_str(callable, zend_string_copy(fcc.calling_scope->name));
+ add_next_index_str(callable, zend_string_copy(fcc.function_handler->common.function_name));
}
if (fcc.function_handler &&
((fcc.function_handler->type == ZEND_INTERNAL_FUNCTION &&
@@ -3420,7 +3421,7 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam
fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
if (fcc.function_handler->type != ZEND_OVERLOADED_FUNCTION) {
- STR_RELEASE(fcc.function_handler->common.function_name);
+ zend_string_release(fcc.function_handler->common.function_name);
}
efree(fcc.function_handler);
}
@@ -3484,9 +3485,10 @@ ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, int param_count
}
/* }}} */
-ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC) /* {{{ */
+ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args TSRMLS_DC) /* {{{ */
{
zval *arg, *params;
+ int n = 1;
zend_fcall_info_args_clear(fci, !args);
@@ -3502,14 +3504,28 @@ ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC) /*
fci->params = params = (zval *) erealloc(fci->params, fci->param_count * sizeof(zval));
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args), arg) {
- ZVAL_COPY(params, arg);
+ if (func && !Z_ISREF_P(arg) && ARG_SHOULD_BE_SENT_BY_REF(func, n)) {
+ ZVAL_NEW_REF(params, arg);
+ if (Z_REFCOUNTED_P(arg)) {
+ Z_ADDREF_P(arg);
+ }
+ } else {
+ ZVAL_COPY(params, arg);
+ }
params++;
+ n++;
} ZEND_HASH_FOREACH_END();
return SUCCESS;
}
/* }}} */
+ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC) /* {{{ */
+{
+ return zend_fcall_info_args_ex(fci, NULL, args TSRMLS_CC);
+}
+/* }}} */
+
ZEND_API int zend_fcall_info_argp(zend_fcall_info *fci TSRMLS_DC, int argc, zval *argv) /* {{{ */
{
int i;
@@ -3599,10 +3615,10 @@ ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */
int name_len = strlen(module_name);
zend_module_entry *module;
- lname = STR_ALLOC(name_len, 0);
+ lname = zend_string_alloc(name_len, 0);
zend_str_tolower_copy(lname->val, module_name, name_len);
module = zend_hash_find_ptr(&module_registry, lname);
- STR_FREE(lname);
+ zend_string_free(lname);
return module ? module->version : NULL;
}
/* }}} */
@@ -3670,7 +3686,7 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z
}
break;
case ZEND_ACC_PUBLIC:
- property_info->name = STR_COPY(name);
+ property_info->name = zend_string_copy(name);
break;
}
@@ -3686,9 +3702,9 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z
ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type TSRMLS_DC) /* {{{ */
{
- zend_string *key = STR_INIT(name, name_length, ce->type & ZEND_INTERNAL_CLASS);
+ zend_string *key = zend_string_init(name, name_length, ce->type & ZEND_INTERNAL_CLASS);
int ret = zend_declare_property_ex(ce, key, property, access_type, NULL TSRMLS_CC);
- STR_RELEASE(key);
+ zend_string_release(key);
return ret;
}
/* }}} */
@@ -3702,7 +3718,7 @@ ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name,
}
/* }}} */
-ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC) /* {{{ */
+ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, zend_long value, int access_type TSRMLS_DC) /* {{{ */
{
zval property;
@@ -3711,7 +3727,7 @@ ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name,
}
/* }}} */
-ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC) /* {{{ */
+ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, int name_length, zend_long value, int access_type TSRMLS_DC) /* {{{ */
{
zval property;
@@ -3733,7 +3749,7 @@ ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name
{
zval property;
- ZVAL_NEW_STR(&property, STR_INIT(value, strlen(value), ce->type & ZEND_INTERNAL_CLASS));
+ ZVAL_NEW_STR(&property, zend_string_init(value, strlen(value), ce->type & ZEND_INTERNAL_CLASS));
return zend_declare_property(ce, name, name_length, &property, access_type TSRMLS_CC);
}
/* }}} */
@@ -3742,7 +3758,7 @@ ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *nam
{
zval property;
- ZVAL_NEW_STR(&property, STR_INIT(value, value_len, ce->type & ZEND_INTERNAL_CLASS));
+ ZVAL_NEW_STR(&property, zend_string_init(value, value_len, ce->type & ZEND_INTERNAL_CLASS));
return zend_declare_property(ce, name, name_length, &property, access_type TSRMLS_CC);
}
/* }}} */
@@ -3766,7 +3782,7 @@ ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *
}
/* }}} */
-ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, long value TSRMLS_DC) /* {{{ */
+ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value TSRMLS_DC) /* {{{ */
{
zval constant;
@@ -3797,7 +3813,7 @@ ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, const cha
{
zval constant;
- ZVAL_NEW_STR(&constant, STR_INIT(value, value_length, ce->type & ZEND_INTERNAL_CLASS));
+ ZVAL_NEW_STR(&constant, zend_string_init(value, value_length, ce->type & ZEND_INTERNAL_CLASS));
return zend_declare_class_constant(ce, name, name_length, &constant TSRMLS_CC);
}
/* }}} */
@@ -3836,7 +3852,7 @@ ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, c
}
/* }}} */
-ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */
+ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */
{
zval tmp;
@@ -3845,7 +3861,7 @@ ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, c
}
/* }}} */
-ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */
+ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */
{
zval tmp;
@@ -3896,12 +3912,12 @@ ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *na
{
zval *property;
zend_class_entry *old_scope = EG(scope);
- zend_string *key = STR_INIT(name, name_length, 0);
+ zend_string *key = zend_string_init(name, name_length, 0);
EG(scope) = scope;
property = zend_std_get_static_property(scope, key, 0, NULL TSRMLS_CC);
EG(scope) = old_scope;
- STR_FREE(key);
+ zend_string_free(key);
if (!property) {
return FAILURE;
} else {
@@ -3938,7 +3954,7 @@ ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const cha
}
/* }}} */
-ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */
+ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */
{
zval tmp;
@@ -3947,7 +3963,7 @@ ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const cha
}
/* }}} */
-ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */
+ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */
{
zval tmp;
@@ -4011,12 +4027,12 @@ ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *na
{
zval *property;
zend_class_entry *old_scope = EG(scope);
- zend_string *key = STR_INIT(name, name_length, 0);
+ zend_string *key = zend_string_init(name, name_length, 0);
EG(scope) = scope;
property = zend_std_get_static_property(scope, key, silent, NULL TSRMLS_CC);
EG(scope) = old_scope;
- STR_FREE(key);
+ zend_string_free(key);
return property;
}
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 0268374fc4..15c4d9e149 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -36,8 +36,8 @@ typedef struct _zend_function_entry {
const char *fname;
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
const struct _zend_arg_info *arg_info;
- zend_uint num_args;
- zend_uint flags;
+ uint32_t num_args;
+ uint32_t flags;
} zend_function_entry;
typedef struct _zend_fcall_info {
@@ -46,7 +46,7 @@ typedef struct _zend_fcall_info {
zval function_name;
zend_array *symbol_table;
zval *retval;
- zend_uint param_count;
+ uint32_t param_count;
zval *params;
zend_object *object;
zend_bool no_separation;
@@ -68,9 +68,9 @@ typedef struct _zend_fcall_info_cache {
#define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name))
#define ZEND_METHOD(classname, name) ZEND_NAMED_FUNCTION(ZEND_MN(classname##_##name))
-#define ZEND_FENTRY(zend_name, name, arg_info, flags) { #zend_name, name, arg_info, (zend_uint) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
+#define ZEND_FENTRY(zend_name, name, arg_info, flags) { #zend_name, name, arg_info, (uint32_t) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
-#define ZEND_RAW_FENTRY(zend_name, name, arg_info, flags) { zend_name, name, arg_info, (zend_uint) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
+#define ZEND_RAW_FENTRY(zend_name, name, arg_info, flags) { zend_name, name, arg_info, (uint32_t) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
#define ZEND_RAW_NAMED_FE(zend_name, name, arg_info) ZEND_RAW_FENTRY(#zend_name, name, arg_info, 0)
#define ZEND_NAMED_FE(zend_name, name, arg_info) ZEND_FENTRY(zend_name, name, arg_info, 0)
@@ -171,7 +171,7 @@ typedef struct _zend_fcall_info_cache {
#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
{ \
zend_string *cl_name; \
- cl_name = STR_INIT(class_name, class_name_len, 1); \
+ cl_name = zend_string_init(class_name, class_name_len, 1); \
class_container.name = zend_new_interned_string(cl_name TSRMLS_CC); \
INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
}
@@ -303,15 +303,15 @@ ZEND_API int zend_get_module_started(const char *module_name);
ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment TSRMLS_DC);
ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, int name_length, int access_type TSRMLS_DC);
-ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC);
-ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC);
+ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, zend_long value, int access_type TSRMLS_DC);
+ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, int name_length, zend_long value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, int name_length, double value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, int name_length, const char *value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, int name_length, const char *value, int value_len, int access_type TSRMLS_DC);
ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value TSRMLS_DC);
ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length TSRMLS_DC);
-ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, long value TSRMLS_DC);
+ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value TSRMLS_DC);
ZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_bool value TSRMLS_DC);
ZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, const char *name, size_t name_length, double value TSRMLS_DC);
ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length TSRMLS_DC);
@@ -320,8 +320,8 @@ ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char
ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC);
ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, int name_length, zval *value TSRMLS_DC);
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC);
-ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC);
-ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC);
+ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_long value TSRMLS_DC);
+ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_long value TSRMLS_DC);
ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, int name_length, double value TSRMLS_DC);
ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_string *value TSRMLS_DC);
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value TSRMLS_DC);
@@ -329,8 +329,8 @@ ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object
ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, int name_length, zval *value TSRMLS_DC);
ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, int name_length TSRMLS_DC);
-ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC);
-ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC);
+ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, zend_long value TSRMLS_DC);
+ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, int name_length, zend_long value TSRMLS_DC);
ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, int name_length, double value TSRMLS_DC);
ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, int name_length, const char *value TSRMLS_DC);
ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, int name_length, const char *value, int value_length TSRMLS_DC);
@@ -374,7 +374,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties TSRMLS_DC);
/* no longer supported */
ZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
-ZEND_API int add_assoc_long_ex(zval *arg, const char *key, uint key_len, long n);
+ZEND_API int add_assoc_long_ex(zval *arg, const char *key, uint key_len, zend_long n);
ZEND_API int add_assoc_null_ex(zval *arg, const char *key, uint key_len);
ZEND_API int add_assoc_bool_ex(zval *arg, const char *key, uint key_len, int b);
ZEND_API int add_assoc_resource_ex(zval *arg, const char *key, uint key_len, zend_resource *r);
@@ -400,17 +400,17 @@ ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, uint key_len, zval *v
#define add_next_index_unset(__arg) add_next_index_null(__arg)
#define add_property_unset(__arg, __key) add_property_null(__arg, __key)
-ZEND_API int add_index_long(zval *arg, ulong idx, long n);
-ZEND_API int add_index_null(zval *arg, ulong idx);
-ZEND_API int add_index_bool(zval *arg, ulong idx, int b);
-ZEND_API int add_index_resource(zval *arg, ulong idx, zend_resource *r);
-ZEND_API int add_index_double(zval *arg, ulong idx, double d);
-ZEND_API int add_index_str(zval *arg, ulong idx, zend_string *str);
-ZEND_API int add_index_string(zval *arg, ulong idx, const char *str);
-ZEND_API int add_index_stringl(zval *arg, ulong idx, const char *str, uint length);
-ZEND_API int add_index_zval(zval *arg, ulong index, zval *value);
-
-ZEND_API int add_next_index_long(zval *arg, long n);
+ZEND_API int add_index_long(zval *arg, zend_ulong idx, zend_long n);
+ZEND_API int add_index_null(zval *arg, zend_ulong idx);
+ZEND_API int add_index_bool(zval *arg, zend_ulong idx, int b);
+ZEND_API int add_index_resource(zval *arg, zend_ulong idx, zend_resource *r);
+ZEND_API int add_index_double(zval *arg, zend_ulong idx, double d);
+ZEND_API int add_index_str(zval *arg, zend_ulong idx, zend_string *str);
+ZEND_API int add_index_string(zval *arg, zend_ulong idx, const char *str);
+ZEND_API int add_index_stringl(zval *arg, zend_ulong idx, const char *str, uint length);
+ZEND_API int add_index_zval(zval *arg, zend_ulong index, zval *value);
+
+ZEND_API int add_next_index_long(zval *arg, zend_long n);
ZEND_API int add_next_index_null(zval *arg);
ZEND_API int add_next_index_bool(zval *arg, int b);
ZEND_API int add_next_index_resource(zval *arg, zend_resource *r);
@@ -426,17 +426,17 @@ ZEND_API zval *add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len
#define add_get_assoc_string(__arg, __key, __str) add_get_assoc_string_ex(__arg, __key, strlen(__key), __str)
#define add_get_assoc_stringl(__arg, __key, __str, __length) add_get_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length)
-ZEND_API zval *add_get_index_long(zval *arg, ulong idx, long l);
-ZEND_API zval *add_get_index_double(zval *arg, ulong idx, double d);
-ZEND_API zval *add_get_index_str(zval *arg, ulong index, zend_string *str);
-ZEND_API zval *add_get_index_string(zval *arg, ulong idx, const char *str);
-ZEND_API zval *add_get_index_stringl(zval *arg, ulong idx, const char *str, uint length);
+ZEND_API zval *add_get_index_long(zval *arg, zend_ulong idx, zend_long l);
+ZEND_API zval *add_get_index_double(zval *arg, zend_ulong idx, double d);
+ZEND_API zval *add_get_index_str(zval *arg, zend_ulong index, zend_string *str);
+ZEND_API zval *add_get_index_string(zval *arg, zend_ulong idx, const char *str);
+ZEND_API zval *add_get_index_stringl(zval *arg, zend_ulong idx, const char *str, uint length);
ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value TSRMLS_DC);
-ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, long l TSRMLS_DC);
+ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, zend_long l TSRMLS_DC);
ZEND_API int add_property_null_ex(zval *arg, const char *key, uint key_len TSRMLS_DC);
-ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, int b TSRMLS_DC);
+ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, zend_long b TSRMLS_DC);
ZEND_API int add_property_resource_ex(zval *arg, const char *key, uint key_len, zend_resource *r TSRMLS_DC);
ZEND_API int add_property_double_ex(zval *arg, const char *key, uint key_len, double d TSRMLS_DC);
ZEND_API int add_property_str_ex(zval *arg, const char *key, uint key_len, zend_string *str TSRMLS_DC);
@@ -455,8 +455,8 @@ ZEND_API int add_property_zval_ex(zval *arg, const char *key, uint key_len, zval
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value TSRMLS_CC)
-ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, zend_uint param_count, zval params[] TSRMLS_DC);
-ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, zend_uint param_count, zval params[], int no_separation, zend_array *symbol_table TSRMLS_DC);
+ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[] TSRMLS_DC);
+ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation, zend_array *symbol_table TSRMLS_DC);
ZEND_API extern const zend_fcall_info empty_fcall_info;
ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache;
@@ -491,6 +491,7 @@ ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, int param_count
* refcount. If args is NULL and arguments are set then those are cleared.
*/
ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC);
+ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args TSRMLS_DC);
/** Set arguments in the zend_fcall_info struct taking care of refcount.
* If argc is 0 the arguments which are set will be cleared, else pass
@@ -550,7 +551,7 @@ END_EXTERN_C()
#define CHECK_NULL_PATH(p, l) (strlen(p) != l)
#define ZVAL_STRINGL(z, s, l) do { \
- ZVAL_NEW_STR(z, STR_INIT(s, l, 0)); \
+ ZVAL_NEW_STR(z, zend_string_init(s, l, 0)); \
} while (0)
#define ZVAL_STRING(z, s) do { \
@@ -559,11 +560,11 @@ END_EXTERN_C()
} while (0)
#define ZVAL_EMPTY_STRING(z) do { \
- ZVAL_INT_STR(z, STR_EMPTY_ALLOC()); \
+ ZVAL_INTERNED_STR(z, STR_EMPTY_ALLOC()); \
} while (0)
#define ZVAL_PSTRINGL(z, s, l) do { \
- ZVAL_NEW_STR(z, STR_INIT(s, l, 1)); \
+ ZVAL_NEW_STR(z, zend_string_init(s, l, 1)); \
} while (0)
#define ZVAL_PSTRING(z, s) do { \
@@ -600,7 +601,7 @@ END_EXTERN_C()
#define RETVAL_LONG(l) ZVAL_LONG(return_value, l)
#define RETVAL_DOUBLE(d) ZVAL_DOUBLE(return_value, d)
#define RETVAL_STR(s) ZVAL_STR(return_value, s)
-#define RETVAL_INT_STR(s) ZVAL_INT_STR(return_value, s)
+#define RETVAL_LONG_STR(s) ZVAL_INTERNED_STR(return_value, s)
#define RETVAL_NEW_STR(s) ZVAL_NEW_STR(return_value, s)
#define RETVAL_STRING(s) ZVAL_STRING(return_value, s)
#define RETVAL_STRINGL(s, l) ZVAL_STRINGL(return_value, s, l)
@@ -616,7 +617,7 @@ END_EXTERN_C()
#define RETURN_LONG(l) { RETVAL_LONG(l); return; }
#define RETURN_DOUBLE(d) { RETVAL_DOUBLE(d); return; }
#define RETURN_STR(s) { RETVAL_STR(s); return; }
-#define RETURN_INT_STR(s) { RETVAL_INT_STR(s); return; }
+#define RETURN_LONG_STR(s) { RETVAL_LONG_STR(s); return; }
#define RETURN_NEW_STR(s) { RETVAL_NEW_STR(s); return; }
#define RETURN_STRING(s) { RETVAL_STRING(s); return; }
#define RETURN_STRINGL(s, l) { RETVAL_STRINGL(s, l); return; }
@@ -1072,7 +1073,7 @@ static zend_always_inline int _z_param_bool(zval *arg, zend_bool *dest, zend_boo
return 1;
}
-static zend_always_inline int _z_param_long(zval *arg, long *dest, zend_bool *is_null, int check_null, int strict)
+static zend_always_inline int _z_param_long(zval *arg, zend_long *dest, zend_bool *is_null, int check_null, int strict)
{
if (check_null) {
*is_null = 0;
@@ -1080,10 +1081,10 @@ static zend_always_inline int _z_param_long(zval *arg, long *dest, zend_bool *is
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
*dest = Z_LVAL_P(arg);
} else if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
- if (strict && UNEXPECTED(Z_DVAL_P(arg) > LONG_MAX)) {
- *dest = LONG_MAX;
- } else if (strict && UNEXPECTED(Z_DVAL_P(arg) < LONG_MIN)) {
- *dest = LONG_MIN;
+ if (strict && UNEXPECTED(Z_DVAL_P(arg) > ZEND_LONG_MAX)) {
+ *dest = ZEND_LONG_MAX;
+ } else if (strict && UNEXPECTED(Z_DVAL_P(arg) < ZEND_LONG_MIN)) {
+ *dest = ZEND_LONG_MIN;
} else {
*dest = zend_dval_to_lval(Z_DVAL_P(arg));
}
@@ -1093,10 +1094,10 @@ static zend_always_inline int _z_param_long(zval *arg, long *dest, zend_bool *is
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) {
if (EXPECTED(type != 0)) {
- if (strict && UNEXPECTED(d > LONG_MAX)) {
- *dest = LONG_MAX;
- } else if (strict && UNEXPECTED(d < LONG_MIN)) {
- *dest = LONG_MIN;
+ if (strict && UNEXPECTED(d > ZEND_LONG_MAX)) {
+ *dest = ZEND_LONG_MAX;
+ } else if (strict && UNEXPECTED(d < ZEND_LONG_MIN)) {
+ *dest = ZEND_LONG_MIN;
} else {
*dest = zend_dval_to_lval(d);
}
@@ -1127,7 +1128,7 @@ static zend_always_inline int _z_param_double(zval *arg, double *dest, zend_bool
} else if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
*dest = (double)Z_LVAL_P(arg);
} else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
- long l;
+ zend_long l;
int type;
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), &l, dest)) != IS_DOUBLE)) {
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index bb3e66c989..cace802579 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -1231,9 +1231,9 @@ ZEND_API zend_mm_heap *zend_mm_startup(void)
}
#if ZEND_DEBUG
-static long zend_mm_find_leaks(zend_mm_segment *segment, zend_mm_block *b)
+static zend_long zend_mm_find_leaks(zend_mm_segment *segment, zend_mm_block *b)
{
- long leaks = 0;
+ zend_long leaks = 0;
zend_mm_block *p, *q;
p = ZEND_MM_NEXT_BLOCK(b);
@@ -1276,7 +1276,7 @@ static void zend_mm_check_leaks(zend_mm_heap *heap TSRMLS_DC)
{
zend_mm_segment *segment = heap->segments_list;
zend_mm_block *p, *q;
- zend_uint total = 0;
+ uint32_t total = 0;
if (!segment) {
return;
@@ -1291,7 +1291,7 @@ static void zend_mm_check_leaks(zend_mm_heap *heap TSRMLS_DC)
}
if (!ZEND_MM_IS_FREE_BLOCK(p)) {
if (p->magic == MEM_BLOCK_VALID) {
- long repeated;
+ zend_long repeated;
zend_leak_info leak;
ZEND_MM_SET_MAGIC(p, MEM_BLOCK_LEAK);
@@ -1373,7 +1373,7 @@ static int zend_mm_check_ptr(zend_mm_heap *heap, void *ptr, int silent ZEND_FILE
#ifdef ZTS
if (ZEND_MM_BAD_THREAD_ID(p)) {
if (!silent) {
- zend_debug_alloc_output("Invalid pointer: ((thread_id=0x%0.8X) != (expected=0x%0.8X))\n", (long)p->thread_id, (long)tsrm_thread_id());
+ zend_debug_alloc_output("Invalid pointer: ((thread_id=0x%0.8X) != (expected=0x%0.8X))\n", (zend_long)p->thread_id, (zend_long)tsrm_thread_id());
had_problems = 1;
} else {
return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
@@ -1984,9 +1984,9 @@ static void *_zend_mm_alloc_int(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D
#endif
HANDLE_UNBLOCK_INTERRUPTIONS();
#if ZEND_DEBUG
- zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted at %s:%d (tried to allocate %lu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
+ zend_mm_safe_error(heap, "Allowed memory size of " ZEND_ULONG_FMT " bytes exhausted at %s:%d (tried to allocate " ZEND_ULONG_FMT " bytes)", heap->limit, __zend_filename, __zend_lineno, size);
#else
- zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted (tried to allocate %lu bytes)", heap->limit, size);
+ zend_mm_safe_error(heap, "Allowed memory size of " ZEND_ULONG_FMT " bytes exhausted (tried to allocate " ZEND_ULONG_FMT " bytes)", heap->limit, size);
#endif
}
@@ -2297,9 +2297,9 @@ realloc_segment:
#endif
HANDLE_UNBLOCK_INTERRUPTIONS();
#if ZEND_DEBUG
- zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted at %s:%d (tried to allocate %ld bytes)", heap->limit, __zend_filename, __zend_lineno, size);
+ zend_mm_safe_error(heap, "Allowed memory size of " ZEND_ULONG_FMT " bytes exhausted at %s:%d (tried to allocate " ZEND_ULONG_FMT " bytes)", heap->limit, __zend_filename, __zend_lineno, size);
#else
- zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted (tried to allocate %ld bytes)", heap->limit, size);
+ zend_mm_safe_error(heap, "Allowed memory size of " ZEND_ULONG_FMT " bytes exhausted (tried to allocate " ZEND_ULONG_FMT " bytes)", heap->limit, size);
#endif
return NULL;
}
@@ -2474,7 +2474,7 @@ ZEND_API size_t _zend_mem_block_size(void *ptr TSRMLS_DC ZEND_FILE_LINE_DC ZEND_
static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
{
size_t res = nmemb;
- unsigned long overflow = 0;
+ zend_ulong overflow = 0;
__asm__ ("mull %3\n\taddl %4,%0\n\tadcl $0,%1"
: "=&a"(res), "=&d" (overflow)
@@ -2494,7 +2494,7 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
{
size_t res = nmemb;
- unsigned long overflow = 0;
+ zend_ulong overflow = 0;
#ifdef __ILP32__ /* x32 */
# define LP_SUFF "l"
@@ -2523,7 +2523,7 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
{
size_t res;
- unsigned long overflow;
+ zend_ulong overflow;
__asm__ ("umlal %0,%1,%2,%3"
: "=r"(res), "=r"(overflow)
@@ -2544,7 +2544,7 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
{
size_t res;
- unsigned long overflow;
+ zend_ulong overflow;
__asm__ ("mul %0,%2,%3\n\tumulh %1,%2,%3\n\tadds %0,%0,%4\n\tadc %1,%1,xzr"
: "=&r"(res), "=&r"(overflow)
@@ -2630,7 +2630,7 @@ ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LI
ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
- int length;
+ size_t length;
char *p;
#ifdef ZEND_SIGNALS
TSRMLS_FETCH();
@@ -2649,7 +2649,7 @@ ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
return p;
}
-ZEND_API char *_estrndup(const char *s, uint length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+ZEND_API char *_estrndup(const char *s, size_t length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
char *p;
#ifdef ZEND_SIGNALS
@@ -2670,7 +2670,7 @@ ZEND_API char *_estrndup(const char *s, uint length ZEND_FILE_LINE_DC ZEND_FILE_
}
-ZEND_API char *zend_strndup(const char *s, uint length)
+ZEND_API char *zend_strndup(const char *s, size_t length)
{
char *p;
#ifdef ZEND_SIGNALS
diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h
index 609db22dac..0d47d1c926 100644
--- a/Zend/zend_alloc.h
+++ b/Zend/zend_alloc.h
@@ -26,20 +26,21 @@
#include "../TSRM/TSRM.h"
#include "zend.h"
+#include "zend_types.h"
#ifndef ZEND_MM_ALIGNMENT
-# define ZEND_MM_ALIGNMENT 8
-# define ZEND_MM_ALIGNMENT_LOG2 3
-#elif ZEND_MM_ALIGNMENT < 4
+# define ZEND_MM_ALIGNMENT Z_I(8)
+# define ZEND_MM_ALIGNMENT_LOG2 Z_I(3)
+#elif ZEND_MM_ALIGNMENT < Z_I(4)
# undef ZEND_MM_ALIGNMENT
# undef ZEND_MM_ALIGNMENT_LOG2
-# define ZEND_MM_ALIGNMENT 4
-# define ZEND_MM_ALIGNMENT_LOG2 2
+# define ZEND_MM_ALIGNMENT Z_I(4)
+# define ZEND_MM_ALIGNMENT_LOG2 Z_I(2)
#endif
-#define ZEND_MM_ALIGNMENT_MASK ~(ZEND_MM_ALIGNMENT-1)
+#define ZEND_MM_ALIGNMENT_MASK ~(ZEND_MM_ALIGNMENT-Z_I(1))
-#define ZEND_MM_ALIGNED_SIZE(size) (((size) + ZEND_MM_ALIGNMENT - 1) & ZEND_MM_ALIGNMENT_MASK)
+#define ZEND_MM_ALIGNED_SIZE(size) (((size) + ZEND_MM_ALIGNMENT - Z_I(1)) & ZEND_MM_ALIGNMENT_MASK)
typedef struct _zend_leak_info {
void *addr;
@@ -52,7 +53,7 @@ typedef struct _zend_leak_info {
BEGIN_EXTERN_C()
-ZEND_API char *zend_strndup(const char *s, unsigned int length) ZEND_ATTRIBUTE_MALLOC;
+ZEND_API char *zend_strndup(const char *s, size_t length) 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;
@@ -63,7 +64,7 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LIN
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;
-ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
+ZEND_API char *_estrndup(const char *s, size_t length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
ZEND_API size_t _zend_mem_block_size(void *ptr TSRMLS_DC ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
/* Standard wrapper macros */
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c
index 822698a354..2532018274 100644
--- a/Zend/zend_ast.c
+++ b/Zend/zend_ast.c
@@ -33,11 +33,11 @@ static inline void *zend_ast_realloc(void *old, size_t old_size, size_t new_size
return new;
}
-size_t zend_ast_size(zend_uint children) {
+static inline size_t zend_ast_size(uint32_t children) {
return sizeof(zend_ast) - sizeof(zend_ast *) + sizeof(zend_ast *) * children;
}
-size_t zend_ast_list_size(zend_uint children) {
+static inline size_t zend_ast_list_size(uint32_t children) {
return sizeof(zend_ast_list) - sizeof(zend_ast *) + sizeof(zend_ast *) * children;
}
@@ -62,7 +62,7 @@ ZEND_API zend_ast *zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr) {
}
ZEND_API zend_ast *zend_ast_create_decl(
- zend_ast_kind kind, zend_uint flags, zend_uint start_lineno, zend_string *doc_comment,
+ zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment,
zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2
) {
TSRMLS_FETCH();
@@ -85,16 +85,16 @@ ZEND_API zend_ast *zend_ast_create_decl(
static zend_ast *zend_ast_create_from_va_list(zend_ast_kind kind, zend_ast_attr attr, va_list va) {
TSRMLS_FETCH();
- zend_uint i, children = kind >> ZEND_AST_NUM_CHILDREN_SHIFT;
+ uint32_t i, children = kind >> ZEND_AST_NUM_CHILDREN_SHIFT;
zend_ast *ast = zend_ast_alloc(zend_ast_size(children) TSRMLS_CC);
ast->kind = kind;
ast->attr = attr;
- ast->lineno = UINT_MAX;
+ ast->lineno = (uint32_t) -1;
for (i = 0; i < children; ++i) {
ast->child[i] = va_arg(va, zend_ast *);
if (ast->child[i] != NULL) {
- zend_uint lineno = zend_ast_get_lineno(ast->child[i]);
+ uint32_t lineno = zend_ast_get_lineno(ast->child[i]);
if (lineno < ast->lineno) {
ast->lineno = lineno;
}
@@ -130,7 +130,7 @@ ZEND_API zend_ast *zend_ast_create(zend_ast_kind kind, ...) {
return ast;
}
-ZEND_API zend_ast_list *zend_ast_create_list(zend_uint init_children, zend_ast_kind kind, ...) {
+ZEND_API zend_ast_list *zend_ast_create_list(uint32_t init_children, zend_ast_kind kind, ...) {
TSRMLS_FETCH();
zend_ast_list *list = zend_ast_alloc(zend_ast_list_size(4) TSRMLS_CC);
list->kind = kind;
@@ -140,7 +140,7 @@ ZEND_API zend_ast_list *zend_ast_create_list(zend_uint init_children, zend_ast_k
{
va_list va;
- zend_uint i;
+ uint32_t i;
va_start(va, kind);
for (i = 0; i < init_children; ++i) {
list = zend_ast_list_add(list, va_arg(va, zend_ast *));
@@ -151,7 +151,7 @@ ZEND_API zend_ast_list *zend_ast_create_list(zend_uint init_children, zend_ast_k
return list;
}
-static inline zend_bool is_power_of_two(unsigned short n) {
+static inline zend_bool is_power_of_two(uint32_t n) {
return n == (n & -n);
}
@@ -300,7 +300,7 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
case ZEND_AST_ARRAY:
array_init(result);
{
- zend_uint i;
+ uint32_t i;
zend_ast_list *list = zend_ast_get_list(ast);
for (i = 0; i < list->children; i++) {
zend_ast *elem = list->child[i];
@@ -343,7 +343,7 @@ ZEND_API zend_ast *zend_ast_copy(zend_ast *ast)
} else if (zend_ast_is_list(ast)) {
zend_ast_list *list = zend_ast_get_list(ast);
zend_ast_list *new = emalloc(zend_ast_list_size(list->children));
- zend_uint i;
+ uint32_t i;
new->kind = list->kind;
new->attr = list->attr;
new->children = list->children;
@@ -352,7 +352,7 @@ ZEND_API zend_ast *zend_ast_copy(zend_ast *ast)
}
return (zend_ast *) new;
} else {
- zend_uint i, children = zend_ast_get_num_children(ast);
+ uint32_t i, children = zend_ast_get_num_children(ast);
zend_ast *new = emalloc(zend_ast_size(children));
new->kind = ast->kind;
new->attr = ast->attr;
@@ -386,9 +386,9 @@ static void zend_ast_destroy_ex(zend_ast *ast, zend_bool free) {
case ZEND_AST_CLASS:
{
zend_ast_decl *decl = (zend_ast_decl *) ast;
- STR_RELEASE(decl->name);
+ zend_string_release(decl->name);
if (decl->doc_comment) {
- STR_RELEASE(decl->doc_comment);
+ zend_string_release(decl->doc_comment);
}
zend_ast_destroy_ex(decl->child[0], free);
zend_ast_destroy_ex(decl->child[1], free);
@@ -398,12 +398,12 @@ static void zend_ast_destroy_ex(zend_ast *ast, zend_bool free) {
default:
if (zend_ast_is_list(ast)) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
for (i = 0; i < list->children; i++) {
zend_ast_destroy_ex(list->child[i], free);
}
} else {
- zend_uint i, children = zend_ast_get_num_children(ast);
+ uint32_t i, children = zend_ast_get_num_children(ast);
for (i = 0; i < children; i++) {
zend_ast_destroy_ex(ast->child[i], free);
}
@@ -425,12 +425,12 @@ ZEND_API void zend_ast_destroy_and_free(zend_ast *ast) {
ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn TSRMLS_DC) {
if (zend_ast_is_list(ast)) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
for (i = 0; i < list->children; ++i) {
fn(&list->child[i] TSRMLS_CC);
}
} else {
- zend_uint i, children = zend_ast_get_num_children(ast);
+ uint32_t i, children = zend_ast_get_num_children(ast);
for (i = 0; i < children; ++i) {
fn(&ast->child[i] TSRMLS_CC);
}
diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h
index c8cac17cef..24d2aa6308 100644
--- a/Zend/zend_ast.h
+++ b/Zend/zend_ast.h
@@ -146,13 +146,13 @@ enum _zend_ast_kind {
ZEND_AST_FOREACH,
};
-typedef unsigned short zend_ast_kind;
-typedef unsigned short zend_ast_attr;
+typedef uint16_t zend_ast_kind;
+typedef uint16_t zend_ast_attr;
struct _zend_ast {
zend_ast_kind kind; /* Type of the node (ZEND_AST_* enum constant) */
zend_ast_attr attr; /* Additional attribute, use depending on node type */
- zend_uint lineno; /* Line number */
+ uint32_t lineno; /* Line number */
zend_ast *child[1]; /* Array of children (using struct hack) */
};
@@ -160,8 +160,8 @@ struct _zend_ast {
typedef struct _zend_ast_list {
zend_ast_kind kind;
zend_ast_attr attr;
- zend_uint lineno;
- zend_uint children;
+ uint32_t lineno;
+ uint32_t children;
zend_ast *child[1];
} zend_ast_list;
@@ -176,9 +176,9 @@ typedef struct _zend_ast_zval {
typedef struct _zend_ast_decl {
zend_ast_kind kind;
zend_ast_attr attr; /* Unused - for structure compatibility */
- zend_uint start_lineno;
- zend_uint end_lineno;
- zend_uint flags;
+ uint32_t start_lineno;
+ uint32_t end_lineno;
+ uint32_t flags;
unsigned char *lex_pos;
zend_string *doc_comment;
zend_string *name;
@@ -191,11 +191,11 @@ ZEND_API zend_ast *zend_ast_create_ex(zend_ast_kind kind, zend_ast_attr attr, ..
ZEND_API zend_ast *zend_ast_create(zend_ast_kind kind, ...);
ZEND_API zend_ast *zend_ast_create_decl(
- zend_ast_kind kind, zend_uint flags, zend_uint start_lineno, zend_string *doc_comment,
+ zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment,
zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2
);
-ZEND_API zend_ast_list *zend_ast_create_list(zend_uint init_children, zend_ast_kind kind, ...);
+ZEND_API zend_ast_list *zend_ast_create_list(uint32_t init_children, zend_ast_kind kind, ...);
ZEND_API zend_ast_list *zend_ast_list_add(zend_ast_list *list, zend_ast *op);
ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope TSRMLS_DC);
@@ -223,11 +223,11 @@ static inline zend_string *zend_ast_get_str(zend_ast *ast) {
return Z_STR_P(zend_ast_get_zval(ast));
}
-static inline zend_uint zend_ast_get_num_children(zend_ast *ast) {
+static inline uint32_t zend_ast_get_num_children(zend_ast *ast) {
ZEND_ASSERT(!zend_ast_is_list(ast));
return ast->kind >> ZEND_AST_NUM_CHILDREN_SHIFT;
}
-static inline zend_uint zend_ast_get_lineno(zend_ast *ast) {
+static inline uint32_t zend_ast_get_lineno(zend_ast *ast) {
if (ast->kind == ZEND_AST_ZVAL) {
zval *zv = zend_ast_get_zval(ast);
return zv->u2.lineno;
@@ -244,19 +244,19 @@ static inline zend_ast *zend_ast_create_zval_from_str(zend_string *str) {
ZVAL_STR(&zv, str);
return zend_ast_create_zval(&zv);
}
-static inline zend_ast *zend_ast_create_zval_from_long(long lval) {
+static inline zend_ast *zend_ast_create_zval_from_long(zend_long lval) {
zval zv;
ZVAL_LONG(&zv, lval);
return zend_ast_create_zval(&zv);
}
-static inline zend_ast *zend_ast_create_binary_op(zend_uint opcode, zend_ast *op0, zend_ast *op1) {
+static inline zend_ast *zend_ast_create_binary_op(uint32_t opcode, zend_ast *op0, zend_ast *op1) {
return zend_ast_create_ex(ZEND_AST_BINARY_OP, opcode, op0, op1);
}
-static inline zend_ast *zend_ast_create_assign_op(zend_uint opcode, zend_ast *op0, zend_ast *op1) {
+static inline zend_ast *zend_ast_create_assign_op(uint32_t opcode, zend_ast *op0, zend_ast *op1) {
return zend_ast_create_ex(ZEND_AST_ASSIGN_OP, opcode, op0, op1);
}
-static inline zend_ast *zend_ast_create_cast(zend_uint type, zend_ast *op0) {
+static inline zend_ast *zend_ast_create_cast(uint32_t type, zend_ast *op0) {
return zend_ast_create_ex(ZEND_AST_CAST, type, op0);
}
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 1e29ea4db1..0adb3d2df5 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -78,6 +78,7 @@ static ZEND_FUNCTION(get_defined_functions);
static ZEND_FUNCTION(get_defined_vars);
static ZEND_FUNCTION(create_function);
static ZEND_FUNCTION(get_resource_type);
+static ZEND_FUNCTION(get_resources);
static ZEND_FUNCTION(get_loaded_extensions);
static ZEND_FUNCTION(extension_loaded);
static ZEND_FUNCTION(get_extension_funcs);
@@ -218,6 +219,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_get_resource_type, 0, 0, 1)
ZEND_ARG_INFO(0, res)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_get_resources, 0, 0, 0)
+ ZEND_ARG_INFO(0, type)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_loaded_extensions, 0, 0, 0)
ZEND_ARG_INFO(0, zend_extensions)
ZEND_END_ARG_INFO()
@@ -291,6 +296,7 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
ZEND_FE(get_defined_vars, arginfo_zend__void)
ZEND_FE(create_function, arginfo_create_function)
ZEND_FE(get_resource_type, arginfo_get_resource_type)
+ ZEND_FE(get_resources, arginfo_get_resources)
ZEND_FE(get_loaded_extensions, arginfo_get_loaded_extensions)
ZEND_FE(extension_loaded, arginfo_extension_loaded)
ZEND_FE(get_extension_funcs, arginfo_extension_loaded)
@@ -374,9 +380,9 @@ ZEND_FUNCTION(gc_enabled)
Activates the circular reference collector */
ZEND_FUNCTION(gc_enable)
{
- zend_string *key = STR_INIT("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
+ zend_string *key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
zend_alter_ini_entry(key, "1", sizeof("1")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
- STR_RELEASE(key);
+ zend_string_release(key);
}
/* }}} */
@@ -384,9 +390,9 @@ ZEND_FUNCTION(gc_enable)
Deactivates the circular reference collector */
ZEND_FUNCTION(gc_disable)
{
- zend_string *key = STR_INIT("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
+ zend_string *key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
zend_alter_ini_entry(key, "0", sizeof("0")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
- STR_RELEASE(key);
+ zend_string_release(key);
}
/* }}} */
@@ -411,7 +417,7 @@ ZEND_FUNCTION(func_get_arg)
{
int arg_count, first_extra_arg;
zval *arg;
- long requested_offset;
+ zend_long requested_offset;
zend_execute_data *ex;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &requested_offset) == FAILURE) {
@@ -432,7 +438,7 @@ ZEND_FUNCTION(func_get_arg)
arg_count = ex->num_args;
if (requested_offset >= arg_count) {
- zend_error(E_WARNING, "func_get_arg(): Argument %ld not passed to function", requested_offset);
+ zend_error(E_WARNING, "func_get_arg(): Argument " ZEND_LONG_FMT " not passed to function", requested_offset);
RETURN_FALSE;
}
@@ -537,14 +543,13 @@ ZEND_FUNCTION(strlen)
Binary safe string comparison */
ZEND_FUNCTION(strcmp)
{
- char *s1, *s2;
- int s1_len, s2_len;
+ zend_string *s1, *s2;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &s1, &s1_len, &s2, &s2_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &s1, &s2) == FAILURE) {
return;
}
- RETURN_LONG(zend_binary_strcmp(s1, s1_len, s2, s2_len));
+ RETURN_LONG(zend_binary_strcmp(s1->val, s1->len, s2->val, s2->len));
}
/* }}} */
@@ -553,11 +558,10 @@ ZEND_FUNCTION(strcmp)
Binary safe string comparison */
ZEND_FUNCTION(strncmp)
{
- char *s1, *s2;
- int s1_len, s2_len;
- long len;
+ zend_string *s1, *s2;
+ zend_long len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSl", &s1, &s2, &len) == FAILURE) {
return;
}
@@ -566,7 +570,7 @@ ZEND_FUNCTION(strncmp)
RETURN_FALSE;
}
- RETURN_LONG(zend_binary_strncmp(s1, s1_len, s2, s2_len, len));
+ RETURN_LONG(zend_binary_strncmp(s1->val, s1->len, s2->val, s2->len, len));
}
/* }}} */
@@ -575,14 +579,13 @@ ZEND_FUNCTION(strncmp)
Binary safe case-insensitive string comparison */
ZEND_FUNCTION(strcasecmp)
{
- char *s1, *s2;
- int s1_len, s2_len;
+ zend_string *s1, *s2;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &s1, &s1_len, &s2, &s2_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &s1, &s2) == FAILURE) {
return;
}
- RETURN_LONG(zend_binary_strcasecmp(s1, s1_len, s2, s2_len));
+ RETURN_LONG(zend_binary_strcasecmp(s1->val, s1->len, s2->val, s2->len));
}
/* }}} */
@@ -591,11 +594,10 @@ ZEND_FUNCTION(strcasecmp)
Binary safe string comparison */
ZEND_FUNCTION(strncasecmp)
{
- char *s1, *s2;
- int s1_len, s2_len;
- long len;
+ zend_string *s1, *s2;
+ zend_long len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSl", &s1, &s2, &len) == FAILURE) {
return;
}
@@ -604,7 +606,7 @@ ZEND_FUNCTION(strncasecmp)
RETURN_FALSE;
}
- RETURN_LONG(zend_binary_strncasecmp(s1, s1_len, s2, s2_len, len));
+ RETURN_LONG(zend_binary_strncasecmp(s1->val, s1->len, s2->val, s2->len, len));
}
/* }}} */
@@ -614,7 +616,7 @@ ZEND_FUNCTION(strncasecmp)
ZEND_FUNCTION(each)
{
zval *array, *entry, tmp;
- ulong num_key;
+ zend_ulong num_key;
HashTable *target_hash;
zend_string *key;
@@ -657,7 +659,7 @@ ZEND_FUNCTION(each)
/* add the key elements */
if (zend_hash_get_current_key(target_hash, &key, &num_key, 0) == HASH_KEY_IS_STRING) {
- ZVAL_STR(&tmp, STR_COPY(key));
+ ZVAL_STR(&tmp, zend_string_copy(key));
if (Z_REFCOUNTED(tmp)) Z_ADDREF(tmp);
} else {
ZVAL_LONG(&tmp, num_key);
@@ -683,9 +685,9 @@ ZEND_FUNCTION(error_reporting)
old_error_reporting = EG(error_reporting);
if(ZEND_NUM_ARGS() != 0) {
- zend_string *key = STR_INIT("error_reporting", sizeof("error_reporting")-1, 0);
+ zend_string *key = zend_string_init("error_reporting", sizeof("error_reporting")-1, 0);
zend_alter_ini_entry(key, err, err_len, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
- STR_RELEASE(key);
+ zend_string_release(key);
}
RETVAL_LONG(old_error_reporting);
@@ -762,7 +764,7 @@ repeat:
ZVAL_DUP(&c.value, val);
zval_ptr_dtor(&val_free);
c.flags = case_sensitive; /* non persistent */
- c.name = STR_COPY(name);
+ c.name = zend_string_copy(name);
c.module_number = PHP_USER_CONSTANT;
if (zend_register_constant(&c TSRMLS_CC) == SUCCESS) {
RETURN_TRUE;
@@ -810,7 +812,7 @@ ZEND_FUNCTION(get_class)
if (!obj) {
if (EG(scope)) {
- RETURN_STR(STR_COPY(EG(scope)->name));
+ RETURN_STR(zend_string_copy(EG(scope)->name));
} else {
zend_error(E_WARNING, "get_class() called without object from outside a class");
RETURN_FALSE;
@@ -831,7 +833,7 @@ ZEND_FUNCTION(get_called_class)
}
if (EG(current_execute_data)->called_scope) {
- RETURN_STR(STR_COPY(EG(current_execute_data)->called_scope->name));
+ RETURN_STR(zend_string_copy(EG(current_execute_data)->called_scope->name));
} else if (!EG(scope)) {
zend_error(E_WARNING, "get_called_class() called from outside a class");
}
@@ -855,7 +857,7 @@ ZEND_FUNCTION(get_parent_class)
if (!ZEND_NUM_ARGS()) {
ce = EG(scope);
if (ce && ce->parent) {
- RETURN_STR(STR_COPY(ce->parent->name));
+ RETURN_STR(zend_string_copy(ce->parent->name));
} else {
RETURN_FALSE;
}
@@ -873,7 +875,7 @@ ZEND_FUNCTION(get_parent_class)
}
if (ce && ce->parent) {
- RETURN_STR(STR_COPY(ce->parent->name));
+ RETURN_STR(zend_string_copy(ce->parent->name));
} else {
RETURN_FALSE;
}
@@ -1078,7 +1080,7 @@ ZEND_FUNCTION(get_object_vars)
}
/* }}} */
-static int same_name(const char *key, const char *name, zend_uint name_len)
+static int same_name(const char *key, const char *name, uint32_t name_len)
{
char *lcname = zend_str_tolower_dup(name, name_len);
int ret = memcmp(lcname, key, name_len) == 0;
@@ -1128,7 +1130,7 @@ ZEND_FUNCTION(get_class_methods)
/* Do not display old-style inherited constructors */
if (!key) {
- ZVAL_STR(&method_name, STR_COPY(mptr->common.function_name));
+ ZVAL_STR(&method_name, zend_string_copy(mptr->common.function_name));
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
} else if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 ||
mptr->common.scope == ce ||
@@ -1138,10 +1140,10 @@ ZEND_FUNCTION(get_class_methods)
*mptr->op_array.refcount > 1 &&
(len != key->len ||
!same_name(key->val, mptr->common.function_name->val, len))) {
- ZVAL_STR(&method_name, STR_COPY(zend_find_alias_name(mptr->common.scope, key)));
+ ZVAL_STR(&method_name, zend_string_copy(zend_find_alias_name(mptr->common.scope, key)));
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
} else {
- ZVAL_STR(&method_name, STR_COPY(mptr->common.function_name));
+ ZVAL_STR(&method_name, zend_string_copy(mptr->common.function_name));
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
}
}
@@ -1180,10 +1182,10 @@ ZEND_FUNCTION(method_exists)
RETURN_FALSE;
}
- lcname = STR_ALLOC(method_name->len, 0);
+ lcname = zend_string_alloc(method_name->len, 0);
zend_str_tolower_copy(lcname->val, method_name->val, method_name->len);
if (zend_hash_exists(&ce->function_table, lcname)) {
- STR_FREE(lcname);
+ zend_string_free(lcname);
RETURN_TRUE;
} else {
union _zend_function *func = NULL;
@@ -1200,8 +1202,8 @@ ZEND_FUNCTION(method_exists)
&& (method_name->len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
&& memcmp(lcname->val, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0) ? 1 : 0);
- STR_FREE(lcname);
- STR_RELEASE(func->common.function_name);
+ zend_string_free(lcname);
+ zend_string_release(func->common.function_name);
efree(func);
return;
}
@@ -1285,14 +1287,14 @@ ZEND_FUNCTION(class_exists)
if (!autoload) {
if (class_name->val[0] == '\\') {
/* Ignore leading "\" */
- lc_name = STR_ALLOC(class_name->len - 1, 0);
+ lc_name = zend_string_alloc(class_name->len - 1, 0);
zend_str_tolower_copy(lc_name->val, class_name->val + 1, class_name->len - 1);
} else {
- lc_name = STR_ALLOC(class_name->len, 0);
+ lc_name = zend_string_alloc(class_name->len, 0);
zend_str_tolower_copy(lc_name->val, class_name->val, class_name->len);
}
ce = zend_hash_find_ptr(EG(class_table), lc_name);
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
RETURN_BOOL(ce && !((ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT)) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS));
}
@@ -1328,14 +1330,14 @@ ZEND_FUNCTION(interface_exists)
if (!autoload) {
if (iface_name->val[0] == '\\') {
/* Ignore leading "\" */
- lc_name = STR_ALLOC(iface_name->len - 1, 0);
+ lc_name = zend_string_alloc(iface_name->len - 1, 0);
zend_str_tolower_copy(lc_name->val, iface_name->val + 1, iface_name->len - 1);
} else {
- lc_name = STR_ALLOC(iface_name->len, 0);
+ lc_name = zend_string_alloc(iface_name->len, 0);
zend_str_tolower_copy(lc_name->val, iface_name->val, iface_name->len);
}
ce = zend_hash_find_ptr(EG(class_table), lc_name);
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
RETURN_BOOL(ce && ce->ce_flags & ZEND_ACC_INTERFACE);
}
@@ -1371,14 +1373,14 @@ ZEND_FUNCTION(trait_exists)
if (!autoload) {
if (trait_name->val[0] == '\\') {
/* Ignore leading "\" */
- lc_name = STR_ALLOC(trait_name->len - 1, 0);
+ lc_name = zend_string_alloc(trait_name->len - 1, 0);
zend_str_tolower_copy(lc_name->val, trait_name->val + 1, trait_name->len - 1);
} else {
- lc_name = STR_ALLOC(trait_name->len, 0);
+ lc_name = zend_string_alloc(trait_name->len, 0);
zend_str_tolower_copy(lc_name->val, trait_name->val, trait_name->len);
}
ce = zend_hash_find_ptr(EG(class_table), lc_name);
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
RETURN_BOOL(ce && ((ce->ce_flags & ZEND_ACC_TRAIT) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS));
}
@@ -1413,15 +1415,15 @@ ZEND_FUNCTION(function_exists)
if (name[0] == '\\') {
/* Ignore leading "\" */
- lcname = STR_ALLOC(name_len - 1, 0);
+ lcname = zend_string_alloc(name_len - 1, 0);
zend_str_tolower_copy(lcname->val, name + 1, name_len - 1);
} else {
- lcname = STR_ALLOC(name_len, 0);
+ lcname = zend_string_alloc(name_len, 0);
zend_str_tolower_copy(lcname->val, name, name_len);
}
func = zend_hash_find_ptr(EG(function_table), lcname);
- STR_FREE(lcname);
+ zend_string_free(lcname);
/*
* A bit of a hack, but not a bad one: we see if the handler of the function
@@ -1472,7 +1474,7 @@ ZEND_FUNCTION(class_alias)
Cause an intentional memory leak, for testing/debugging purposes */
ZEND_FUNCTION(leak)
{
- long leakbytes=3;
+ zend_long leakbytes=3;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &leakbytes) == FAILURE) {
return;
@@ -1529,7 +1531,7 @@ ZEND_FUNCTION(get_included_files)
array_init(return_value);
ZEND_HASH_FOREACH_STR_KEY(&EG(included_files), entry) {
if (entry) {
- add_next_index_str(return_value, STR_COPY(entry));
+ add_next_index_str(return_value, zend_string_copy(entry));
}
} ZEND_HASH_FOREACH_END();
}
@@ -1540,7 +1542,7 @@ ZEND_FUNCTION(get_included_files)
Generates a user-level error/warning/notice message */
ZEND_FUNCTION(trigger_error)
{
- long error_type = E_USER_NOTICE;
+ zend_long error_type = E_USER_NOTICE;
char *message;
int message_len;
@@ -1572,7 +1574,7 @@ ZEND_FUNCTION(set_error_handler)
{
zval *error_handler;
zend_string *error_handler_name = NULL;
- long error_type = E_ALL;
+ zend_long error_type = E_ALL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) {
return;
@@ -1582,10 +1584,10 @@ ZEND_FUNCTION(set_error_handler)
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->val:"unknown");
- STR_RELEASE(error_handler_name);
+ zend_string_release(error_handler_name);
return;
}
- STR_RELEASE(error_handler_name);
+ zend_string_release(error_handler_name);
}
if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
@@ -1648,10 +1650,10 @@ ZEND_FUNCTION(set_exception_handler)
if (!zend_is_callable(exception_handler, 0, &exception_handler_name TSRMLS_CC)) {
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name->val:"unknown");
- STR_RELEASE(exception_handler_name);
+ zend_string_release(exception_handler_name);
return;
}
- STR_RELEASE(exception_handler_name);
+ zend_string_release(exception_handler_name);
}
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
@@ -1692,18 +1694,18 @@ static int copy_class_or_interface_name(zval *el TSRMLS_DC, int num_args, va_lis
{
zend_class_entry *ce = (zend_class_entry *)Z_PTR_P(el);
zval *array = va_arg(args, zval *);
- zend_uint mask = va_arg(args, zend_uint);
- zend_uint comply = va_arg(args, zend_uint);
- zend_uint comply_mask = (comply)? mask:0;
+ uint32_t mask = va_arg(args, uint32_t);
+ uint32_t comply = va_arg(args, uint32_t);
+ uint32_t comply_mask = (comply)? mask:0;
if ((hash_key->key && hash_key->key->val[0] != 0)
&& (comply_mask == (ce->ce_flags & mask))) {
if (ce->refcount > 1 &&
- (ce->name->len != hash_key->key->len - 1 ||
+ (ce->name->len != hash_key->key->len ||
!same_name(hash_key->key->val, ce->name->val, ce->name->len))) {
- add_next_index_str(array, STR_COPY(hash_key->key));
+ add_next_index_str(array, zend_string_copy(hash_key->key));
} else {
- add_next_index_str(array, STR_COPY(ce->name));
+ add_next_index_str(array, zend_string_copy(ce->name));
}
}
return ZEND_HASH_APPLY_KEEP;
@@ -1713,8 +1715,8 @@ static int copy_class_or_interface_name(zval *el TSRMLS_DC, int num_args, va_lis
Returns an array of all declared traits. */
ZEND_FUNCTION(get_declared_traits)
{
- zend_uint mask = ZEND_ACC_TRAIT;
- zend_uint comply = 1;
+ uint32_t mask = ZEND_ACC_TRAIT;
+ uint32_t comply = 1;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1730,8 +1732,8 @@ ZEND_FUNCTION(get_declared_traits)
Returns an array of all declared classes. */
ZEND_FUNCTION(get_declared_classes)
{
- zend_uint mask = ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT & ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
- zend_uint comply = 0;
+ uint32_t mask = ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT & ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
+ uint32_t comply = 0;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1746,8 +1748,8 @@ ZEND_FUNCTION(get_declared_classes)
Returns an array of all declared interfaces. */
ZEND_FUNCTION(get_declared_interfaces)
{
- zend_uint mask = ZEND_ACC_INTERFACE;
- zend_uint comply = 1;
+ uint32_t mask = ZEND_ACC_INTERFACE;
+ uint32_t comply = 1;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1770,9 +1772,9 @@ static int copy_function_name(zval *zv TSRMLS_DC, int num_args, va_list args, ze
}
if (func->type == ZEND_INTERNAL_FUNCTION) {
- add_next_index_str(internal_ar, STR_COPY(hash_key->key));
+ add_next_index_str(internal_ar, zend_string_copy(hash_key->key));
} else if (func->type == ZEND_USER_FUNCTION) {
- add_next_index_str(user_ar, STR_COPY(hash_key->key));
+ add_next_index_str(user_ar, zend_string_copy(hash_key->key));
}
return 0;
@@ -1880,7 +1882,7 @@ ZEND_FUNCTION(create_function)
}
(*func->refcount)++;
- function_name = STR_ALLOC(sizeof("0lambda_")+MAX_LENGTH_OF_LONG, 0);
+ function_name = zend_string_alloc(sizeof("0lambda_")+MAX_LENGTH_OF_LONG, 0);
function_name->val[0] = '\0';
do {
@@ -1911,7 +1913,7 @@ ZEND_FUNCTION(zend_test_func)
#ifdef ZTS
ZEND_FUNCTION(zend_thread_id)
{
- RETURN_LONG((long)tsrm_thread_id());
+ RETURN_LONG((zend_long)tsrm_thread_id());
}
#endif
#endif
@@ -1936,6 +1938,54 @@ ZEND_FUNCTION(get_resource_type)
}
/* }}} */
+/* {{{ proto array get_resources([string resouce_type])
+ Get an array with all active resources */
+ZEND_FUNCTION(get_resources)
+{
+ zend_string *type = NULL;
+ zend_string *key;
+ zend_ulong index;
+ zval *val;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &type) == FAILURE) {
+ return;
+ }
+
+ if (!type) {
+ array_init(return_value);
+ ZEND_HASH_FOREACH_KEY_VAL(&EG(regular_list), index, key, val) {
+ if (!key) {
+ Z_ADDREF_P(val);
+ zend_hash_index_add_new(Z_ARRVAL_P(return_value), index, val);
+ }
+ } ZEND_HASH_FOREACH_END();
+ } else if (type->len == sizeof("Unknown")-1 &&
+ memcmp(type->val, "Unknown", sizeof("Unknown")-1) == 0) {
+ array_init(return_value);
+ ZEND_HASH_FOREACH_KEY_VAL(&EG(regular_list), index, key, val) {
+ if (!key && Z_RES_TYPE_P(val) <= 0) {
+ Z_ADDREF_P(val);
+ zend_hash_index_add_new(Z_ARRVAL_P(return_value), index, val);
+ }
+ } ZEND_HASH_FOREACH_END();
+ } else {
+ int id = zend_fetch_list_dtor_id(type->val);
+
+ if (id <= 0) {
+ zend_error(E_WARNING, "get_resources(): Unknown resource type '%s'", type->val);
+ RETURN_FALSE;
+ }
+
+ array_init(return_value);
+ ZEND_HASH_FOREACH_KEY_VAL(&EG(regular_list), index, key, val) {
+ if (!key && Z_RES_TYPE_P(val) == id) {
+ Z_ADDREF_P(val);
+ zend_hash_index_add_new(Z_ARRVAL_P(return_value), index, val);
+ }
+ } ZEND_HASH_FOREACH_END();
+ }
+}
+/* }}} */
static int add_extension_info(zval *item, void *arg TSRMLS_DC)
{
@@ -2115,8 +2165,8 @@ ZEND_FUNCTION(debug_print_backtrace)
const char *include_filename = NULL;
zval arg_array;
int indent = 0;
- long options = 0;
- long limit = 0;
+ zend_long options = 0;
+ zend_long limit = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &options, &limit) == FAILURE) {
return;
@@ -2374,7 +2424,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
break;
}
if (prev->func && ZEND_USER_CODE(prev->func->common.type)) {
- add_assoc_str_ex(&stack_frame, "file", sizeof("file")-1, STR_COPY(prev->func->op_array.filename));
+ add_assoc_str_ex(&stack_frame, "file", sizeof("file")-1, zend_string_copy(prev->func->op_array.filename));
add_assoc_long_ex(&stack_frame, "line", sizeof("line")-1, prev->opline->lineno);
break;
}
@@ -2412,10 +2462,10 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
if (object) {
if (func->common.scope) {
- add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, STR_COPY(func->common.scope->name));
+ add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, zend_string_copy(func->common.scope->name));
} else {
class_name = zend_get_object_classname(object TSRMLS_CC);
- add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, STR_COPY(class_name));
+ add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, zend_string_copy(class_name));
}
if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) {
@@ -2427,7 +2477,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
add_assoc_string_ex(&stack_frame, "type", sizeof("type")-1, "->");
} else if (func->common.scope) {
- add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, STR_COPY(func->common.scope->name));
+ add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, zend_string_copy(func->common.scope->name));
add_assoc_string_ex(&stack_frame, "type", sizeof("type")-1, "::");
}
@@ -2503,8 +2553,8 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
Return backtrace as array */
ZEND_FUNCTION(debug_backtrace)
{
- long options = DEBUG_BACKTRACE_PROVIDE_OBJECT;
- long limit = 0;
+ zend_long options = DEBUG_BACKTRACE_PROVIDE_OBJECT;
+ zend_long limit = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &options, &limit) == FAILURE) {
return;
@@ -2526,14 +2576,14 @@ ZEND_FUNCTION(extension_loaded)
return;
}
- lcname = STR_ALLOC(extension_name_len, 0);
+ lcname = zend_string_alloc(extension_name_len, 0);
zend_str_tolower_copy(lcname->val, extension_name, extension_name_len);
if (zend_hash_exists(&module_registry, lcname)) {
RETVAL_TRUE;
} else {
RETVAL_FALSE;
}
- STR_FREE(lcname);
+ zend_string_free(lcname);
}
/* }}} */
@@ -2552,13 +2602,13 @@ ZEND_FUNCTION(get_extension_funcs)
return;
}
if (strncasecmp(extension_name, "zend", sizeof("zend"))) {
- lcname = STR_ALLOC(extension_name_len, 0);
+ lcname = zend_string_alloc(extension_name_len, 0);
zend_str_tolower_copy(lcname->val, extension_name, extension_name_len);
} else {
- lcname = STR_INIT("core", sizeof("core")-1, 0);
+ lcname = zend_string_init("core", sizeof("core")-1, 0);
}
module = zend_hash_find_ptr(&module_registry, lcname);
- STR_FREE(lcname);
+ zend_string_free(lcname);
if (!module) {
RETURN_FALSE;
}
@@ -2578,7 +2628,7 @@ ZEND_FUNCTION(get_extension_funcs)
array_init(return_value);
array = 1;
}
- add_next_index_str(return_value, STR_COPY(zif->common.function_name));
+ add_next_index_str(return_value, zend_string_copy(zif->common.function_name));
}
} ZEND_HASH_FOREACH_END();
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index c10c1a4327..525be9dca1 100644
--- a/Zend/zend_closures.c
+++ b/Zend/zend_closures.c
@@ -61,7 +61,7 @@ ZEND_METHOD(Closure, __invoke) /* {{{ */
efree(arguments);
/* destruct the function also, then - we have allocated it in get_method */
- STR_RELEASE(func->internal_function.function_name);
+ zend_string_release(func->internal_function.function_name);
efree(func);
}
/* }}} */
@@ -96,10 +96,10 @@ ZEND_METHOD(Closure, bind)
ce = closure->func.common.scope;
} else if ((ce = zend_lookup_class_ex(class_name, NULL, 1 TSRMLS_CC)) == NULL) {
zend_error(E_WARNING, "Class '%s' not found", class_name->val);
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
RETURN_NULL();
}
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
}
} else { /* scope argument not given; do not change the scope by default */
ce = closure->func.common.scope;
@@ -133,7 +133,7 @@ ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object TSRML
invoke->internal_function.handler = ZEND_MN(Closure___invoke);
invoke->internal_function.module = 0;
invoke->internal_function.scope = zend_ce_closure;
- invoke->internal_function.function_name = STR_INIT(ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1, 0);
+ invoke->internal_function.function_name = zend_string_init(ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1, 0);
return invoke;
}
/* }}} */
@@ -156,15 +156,15 @@ static zend_function *zend_closure_get_method(zend_object **object, zend_string
{
zend_string *lc_name;
- lc_name = STR_ALLOC(method->len, 0);
+ lc_name = zend_string_alloc(method->len, 0);
zend_str_tolower_copy(lc_name->val, method->val, method->len);
if ((method->len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) &&
memcmp(lc_name->val, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
) {
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
return zend_get_closure_invoke_method(*object TSRMLS_CC);
}
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
return std_object_handlers.get_method(object, method, key TSRMLS_CC);
}
/* }}} */
@@ -308,7 +308,7 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp TSRMLS_
}
if (arg_info) {
- zend_uint i, required = closure->func.common.required_num_args;
+ uint32_t i, required = closure->func.common.required_num_args;
array_init(&val);
@@ -326,7 +326,7 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp TSRMLS_
}
ZVAL_STR(&info, zend_strpprintf(0, "%s", i >= required ? "<optional>" : "<required>"));
zend_hash_update(Z_ARRVAL(val), name, &info);
- STR_RELEASE(name);
+ zend_string_release(name);
arg_info++;
}
zend_hash_str_update(closure->debug_info, "parameter", sizeof("parameter")-1, &val);
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 4b292d5bef..346ba66e3f 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -60,7 +60,7 @@
target = src; \
} while (0)
-static inline void zend_alloc_cache_slot(zend_uint literal TSRMLS_DC) {
+static inline void zend_alloc_cache_slot(uint32_t literal TSRMLS_DC) {
zend_op_array *op_array = CG(active_op_array);
Z_CACHE_SLOT(op_array->literals[literal]) = op_array->last_cache_slot++;
if ((op_array->fn_flags & ZEND_ACC_INTERACTIVE) && op_array->run_time_cache) {
@@ -72,7 +72,7 @@ static inline void zend_alloc_cache_slot(zend_uint literal TSRMLS_DC) {
#define POLYMORPHIC_CACHE_SLOT_SIZE 2
-static inline void zend_alloc_polymorphic_cache_slot(zend_uint literal TSRMLS_DC) {
+static inline void zend_alloc_polymorphic_cache_slot(uint32_t literal TSRMLS_DC) {
zend_op_array *op_array = CG(active_op_array);
Z_CACHE_SLOT(op_array->literals[literal]) = op_array->last_cache_slot;
op_array->last_cache_slot += POLYMORPHIC_CACHE_SLOT_SIZE;
@@ -98,9 +98,9 @@ static zend_property_info *zend_duplicate_property_info(zend_property_info *prop
new_property_info = zend_arena_alloc(&CG(arena), sizeof(zend_property_info));
memcpy(new_property_info, property_info, sizeof(zend_property_info));
- STR_ADDREF(new_property_info->name);
+ zend_string_addref(new_property_info->name);
if (new_property_info->doc_comment) {
- STR_ADDREF(new_property_info->doc_comment);
+ zend_string_addref(new_property_info->doc_comment);
}
return new_property_info;
}
@@ -110,7 +110,7 @@ static zend_property_info *zend_duplicate_property_info_internal(zend_property_i
{
zend_property_info* new_property_info = pemalloc(sizeof(zend_property_info), 1);
memcpy(new_property_info, property_info, sizeof(zend_property_info));
- STR_ADDREF(new_property_info->name);
+ zend_string_addref(new_property_info->name);
return new_property_info;
}
/* }}} */
@@ -119,9 +119,9 @@ static void zend_destroy_property_info(zval *zv) /* {{{ */
{
zend_property_info *property_info = Z_PTR_P(zv);
- STR_RELEASE(property_info->name);
+ zend_string_release(property_info->name);
if (property_info->doc_comment) {
- STR_RELEASE(property_info->doc_comment);
+ zend_string_release(property_info->doc_comment);
}
}
/* }}} */
@@ -130,7 +130,7 @@ static void zend_destroy_property_info_internal(zval *zv) /* {{{ */
{
zend_property_info *property_info = Z_PTR_P(zv);
- STR_RELEASE(property_info->name);
+ zend_string_release(property_info->name);
free(property_info);
}
/* }}} */
@@ -138,12 +138,12 @@ static void zend_destroy_property_info_internal(zval *zv) /* {{{ */
static zend_string *zend_new_interned_string_safe(zend_string *str TSRMLS_DC) {
zend_string *interned_str;
- STR_ADDREF(str);
+ zend_string_addref(str);
interned_str = zend_new_interned_string(str TSRMLS_CC);
if (str != interned_str) {
return interned_str;
} else {
- STR_RELEASE(str);
+ zend_string_release(str);
return str;
}
}
@@ -163,7 +163,7 @@ static zend_string *zend_build_runtime_definition_key(
}
/* NULL, name length, filename length, last accepting char position length */
- result = STR_ALLOC(1 + name->len + strlen(filename) + char_pos_len, 0);
+ result = zend_string_alloc(1 + name->len + strlen(filename) + char_pos_len, 0);
result->val[0] = '\0';
sprintf(result->val + 1, "%s%s%s", name->val, filename, char_pos_buf);
@@ -252,7 +252,7 @@ ZEND_API zend_string *zend_set_compiled_filename(zend_string *new_compiled_filen
CG(compiled_filename) = p;
return p;
}
- p = STR_COPY(new_compiled_filename);
+ p = zend_string_copy(new_compiled_filename);
zend_hash_update_ptr(&CG(filenames_table), new_compiled_filename, p);
CG(compiled_filename) = p;
return p;
@@ -283,22 +283,22 @@ ZEND_API zend_bool zend_is_compiling(TSRMLS_D) /* {{{ */
}
/* }}} */
-static zend_uint get_temporary_variable(zend_op_array *op_array) /* {{{ */
+static uint32_t get_temporary_variable(zend_op_array *op_array) /* {{{ */
{
- return (zend_uint)op_array->T++;
+ return (uint32_t)op_array->T++;
}
/* }}} */
static int lookup_cv(zend_op_array *op_array, zend_string* name TSRMLS_DC) /* {{{ */{
int i = 0;
- ulong hash_value = STR_HASH_VAL(name);
+ zend_ulong hash_value = zend_string_hash_val(name);
while (i < op_array->last_var) {
if (op_array->vars[i]->val == name->val ||
(op_array->vars[i]->h == hash_value &&
op_array->vars[i]->len == name->len &&
memcmp(op_array->vars[i]->val, name->val, name->len) == 0)) {
- STR_RELEASE(name);
+ zend_string_release(name);
return (int)(zend_intptr_t)EX_VAR_NUM_2(NULL, i);
}
i++;
@@ -330,7 +330,7 @@ void zend_del_literal(zend_op_array *op_array, int n) /* {{{ */
static inline void zend_insert_literal(zend_op_array *op_array, zval *zv, int literal_position TSRMLS_DC) /* {{{ */
{
if (Z_TYPE_P(zv) == IS_STRING || Z_TYPE_P(zv) == IS_CONSTANT) {
- STR_HASH_VAL(Z_STR_P(zv));
+ zend_string_hash_val(Z_STR_P(zv));
Z_STR_P(zv) = zend_new_interned_string(Z_STR_P(zv) TSRMLS_CC);
if (IS_INTERNED(Z_STR_P(zv))) {
Z_TYPE_FLAGS_P(zv) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE);
@@ -374,7 +374,7 @@ static int zend_add_func_name_literal(zend_op_array *op_array, zval *zv TSRMLS_D
ret = zend_add_literal(op_array, zv TSRMLS_CC);
}
- lc_name = STR_ALLOC(Z_STRLEN_P(zv), 0);
+ lc_name = zend_string_alloc(Z_STRLEN_P(zv), 0);
zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv), Z_STRLEN_P(zv));
ZVAL_NEW_STR(&c, lc_name);
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
@@ -400,7 +400,7 @@ static int zend_add_ns_func_name_literal(zend_op_array *op_array, zval *zv TSRML
ret = zend_add_literal(op_array, zv TSRMLS_CC);
}
- lc_name = STR_ALLOC(Z_STRLEN_P(zv), 0);
+ lc_name = zend_string_alloc(Z_STRLEN_P(zv), 0);
zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv), Z_STRLEN_P(zv));
ZVAL_NEW_STR(&c, lc_name);
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
@@ -410,7 +410,7 @@ static int zend_add_ns_func_name_literal(zend_op_array *op_array, zval *zv TSRML
if (ns_separator != NULL) {
ns_separator += 1;
lc_len = Z_STRLEN_P(zv) - (ns_separator - Z_STRVAL_P(zv));
- lc_name = STR_ALLOC(lc_len, 0);
+ lc_name = zend_string_alloc(lc_len, 0);
zend_str_tolower_copy(lc_name->val, ns_separator, lc_len);
ZVAL_NEW_STR(&c, lc_name);
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
@@ -430,7 +430,7 @@ static int zend_add_class_name_literal(zend_op_array *op_array, zend_string *nam
ret = zend_add_literal(op_array, &zv TSRMLS_CC);
name = Z_STR(zv); /* Load new name string in case it was interned */
- lc_name = STR_ALLOC(name->len, 0);
+ lc_name = zend_string_alloc(name->len, 0);
zend_str_tolower_copy(lc_name->val, name->val, name->len);
ZVAL_NEW_STR(&zv, lc_name);
@@ -477,13 +477,13 @@ static int zend_add_const_name_literal(zend_op_array *op_array, zval *zv, int un
if (ns_len) {
/* lowercased namespace name & original constant name */
- tmp_name = STR_INIT(name, name_len, 0);
+ tmp_name = zend_string_init(name, name_len, 0);
zend_str_tolower(tmp_name->val, ns_len);
ZVAL_NEW_STR(&c, tmp_name);
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
/* lowercased namespace name & lowercased constant name */
- tmp_name = STR_ALLOC(name_len, 0);
+ tmp_name = zend_string_alloc(name_len, 0);
zend_str_tolower_copy(tmp_name->val, name, name_len);
ZVAL_NEW_STR(&c, tmp_name);
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
@@ -499,12 +499,12 @@ static int zend_add_const_name_literal(zend_op_array *op_array, zval *zv, int un
}
/* original constant name */
- tmp_name = STR_INIT(name, name_len, 0);
+ tmp_name = zend_string_init(name, name_len, 0);
ZVAL_NEW_STR(&c, tmp_name);
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
/* lowercased constant name */
- tmp_name = STR_ALLOC(name_len, 0);
+ tmp_name = zend_string_alloc(name_len, 0);
zend_str_tolower_copy(tmp_name->val, name, name_len);
ZVAL_NEW_STR(&c, tmp_name);
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
@@ -625,8 +625,8 @@ void zend_do_free(znode *op1 TSRMLS_DC) /* {{{ */
}
/* }}} */
-zend_uint zend_add_member_modifier(zend_uint flags, zend_uint new_flag) {
- zend_uint new_flags = flags | new_flag;
+uint32_t zend_add_member_modifier(uint32_t flags, uint32_t new_flag) {
+ uint32_t new_flags = flags | new_flag;
if ((flags & ZEND_ACC_PPP_MASK) && (new_flag & ZEND_ACC_PPP_MASK)) {
zend_error_noreturn(E_COMPILE_ERROR, "Multiple access type modifiers are not allowed");
}
@@ -649,7 +649,7 @@ zend_string *zend_concat3(
char *str1, size_t str1_len, char *str2, size_t str2_len, char *str3, size_t str3_len
) {
size_t len = str1_len + str2_len + str3_len;
- zend_string *res = STR_ALLOC(len, 0);
+ zend_string *res = zend_string_alloc(len, 0);
memcpy(res->val, str1, str1_len);
memcpy(res->val + str1_len, str2, str2_len);
@@ -668,21 +668,21 @@ zend_string *zend_prefix_with_ns(zend_string *name TSRMLS_DC) {
zend_string *ns = CG(current_namespace);
return zend_concat_names(ns->val, ns->len, name->val, name->len);
} else {
- return STR_COPY(name);
+ return zend_string_copy(name);
}
}
void *zend_hash_find_ptr_lc(HashTable *ht, char *str, size_t len) {
void *result;
- zend_string *lcname = STR_ALLOC(len, 0);
+ zend_string *lcname = zend_string_alloc(len, 0);
zend_str_tolower_copy(lcname->val, str, len);
result = zend_hash_find_ptr(ht, lcname);
- STR_FREE(lcname);
+ zend_string_free(lcname);
return result;
}
zend_string *zend_resolve_non_class_name(
- zend_string *name, zend_uint type, zend_bool *is_fully_qualified,
+ zend_string *name, uint32_t type, zend_bool *is_fully_qualified,
zend_bool case_sensitive, HashTable *current_import_sub TSRMLS_DC
) {
char *compound;
@@ -690,12 +690,12 @@ zend_string *zend_resolve_non_class_name(
if (name->val[0] == '\\') {
/* Remove \ prefix (only relevant if this is a string rather than a label) */
- return STR_INIT(name->val + 1, name->len - 1, 0);
+ return zend_string_init(name->val + 1, name->len - 1, 0);
}
if (type == ZEND_NAME_FQ) {
*is_fully_qualified = 1;
- return STR_COPY(name);
+ return zend_string_copy(name);
}
if (type == ZEND_NAME_RELATIVE) {
@@ -714,7 +714,7 @@ zend_string *zend_resolve_non_class_name(
if (import_name) {
*is_fully_qualified = 1;
- return STR_COPY(import_name);
+ return zend_string_copy(import_name);
}
}
@@ -739,21 +739,21 @@ zend_string *zend_resolve_non_class_name(
/* }}} */
zend_string *zend_resolve_function_name(
- zend_string *name, zend_uint type, zend_bool *is_fully_qualified TSRMLS_DC
+ zend_string *name, uint32_t type, zend_bool *is_fully_qualified TSRMLS_DC
) {
return zend_resolve_non_class_name(
name, type, is_fully_qualified, 0, CG(current_import_function) TSRMLS_CC);
}
zend_string *zend_resolve_const_name(
- zend_string *name, zend_uint type, zend_bool *is_fully_qualified TSRMLS_DC
+ zend_string *name, uint32_t type, zend_bool *is_fully_qualified TSRMLS_DC
) {
return zend_resolve_non_class_name(
name, type, is_fully_qualified, 1, CG(current_import_const) TSRMLS_CC);
}
zend_string *zend_resolve_class_name(
- zend_string *name, zend_uint type TSRMLS_DC
+ zend_string *name, uint32_t type TSRMLS_DC
) {
char *compound;
@@ -764,9 +764,9 @@ zend_string *zend_resolve_class_name(
if (type == ZEND_NAME_FQ || name->val[0] == '\\') {
/* Remove \ prefix (only relevant if this is a string rather than a label) */
if (name->val[0] == '\\') {
- name = STR_INIT(name->val + 1, name->len - 1, 0);
+ name = zend_string_init(name->val + 1, name->len - 1, 0);
} else {
- STR_ADDREF(name);
+ zend_string_addref(name);
}
/* Ensure that \self, \parent and \static are not used */
if (ZEND_FETCH_CLASS_DEFAULT != zend_get_class_fetch_type(name)) {
@@ -792,7 +792,7 @@ zend_string *zend_resolve_class_name(
= zend_hash_find_ptr_lc(CG(current_import), name->val, name->len);
if (import_name) {
- return STR_COPY(import_name);
+ return zend_string_copy(import_name);
}
}
}
@@ -813,13 +813,13 @@ static void ptr_dtor(zval *zv) /* {{{ */
/* }}} */
static void str_dtor(zval *zv) {
- STR_RELEASE(Z_STR_P(zv));
+ zend_string_release(Z_STR_P(zv));
}
void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2 TSRMLS_DC) /* {{{ */
{
zend_label *dest;
- long current, distance;
+ zend_long current, distance;
zval *label;
if (pass2) {
@@ -930,10 +930,10 @@ static int generate_free_foreach_copy(const zend_op *foreach_copy TSRMLS_DC) /*
}
/* }}} */
-static zend_uint zend_add_try_element(zend_uint try_op TSRMLS_DC) /* {{{ */
+static uint32_t zend_add_try_element(uint32_t try_op TSRMLS_DC) /* {{{ */
{
zend_op_array *op_array = CG(active_op_array);
- zend_uint try_catch_offset = op_array->last_try_catch++;
+ uint32_t try_catch_offset = op_array->last_try_catch++;
zend_try_catch_element *elem;
op_array->try_catch_array = safe_erealloc(
@@ -964,7 +964,7 @@ ZEND_API void function_add_ref(zend_function *function) /* {{{ */
op_array->run_time_cache = NULL;
} else if (function->type == ZEND_INTERNAL_FUNCTION) {
if (function->common.function_name) {
- STR_ADDREF(function->common.function_name);
+ zend_string_addref(function->common.function_name);
}
}
}
@@ -1050,10 +1050,10 @@ static void do_inherit_parent_constructor(zend_class_entry *ce TSRMLS_DC) /* {{{
zend_string *lc_class_name;
zend_string *lc_parent_class_name;
- lc_class_name = STR_ALLOC(ce->name->len, 0);
+ lc_class_name = zend_string_alloc(ce->name->len, 0);
zend_str_tolower_copy(lc_class_name->val, ce->name->val, ce->name->len);
if (!zend_hash_exists(&ce->function_table, lc_class_name)) {
- lc_parent_class_name = STR_ALLOC(ce->parent->name->len, 0);
+ lc_parent_class_name = zend_string_alloc(ce->parent->name->len, 0);
zend_str_tolower_copy(lc_parent_class_name->val, ce->parent->name->val, ce->parent->name->len);
if (!zend_hash_exists(&ce->function_table, lc_parent_class_name) &&
(function = zend_hash_find_ptr(&ce->parent->function_table, lc_parent_class_name)) != NULL) {
@@ -1065,15 +1065,15 @@ static void do_inherit_parent_constructor(zend_class_entry *ce TSRMLS_DC) /* {{{
function_add_ref(new_function);
}
}
- STR_RELEASE(lc_parent_class_name);
+ zend_string_release(lc_parent_class_name);
}
- STR_FREE(lc_class_name);
+ zend_string_free(lc_class_name);
}
ce->constructor = ce->parent->constructor;
}
/* }}} */
-char *zend_visibility_string(zend_uint fn_flags) /* {{{ */
+char *zend_visibility_string(uint32_t fn_flags) /* {{{ */
{
if (fn_flags & ZEND_ACC_PRIVATE) {
return "private";
@@ -1110,7 +1110,7 @@ static zend_function *do_inherit_method(zend_function *old_function TSRMLS_DC) /
static zend_bool zend_do_perform_implementation_check(const zend_function *fe, const zend_function *proto TSRMLS_DC) /* {{{ */
{
- zend_uint i, num_args;
+ uint32_t i, num_args;
/* If it's a user function then arg_info == NULL means we don't have any parameters but
* we still need to do the arg number checks. We are only willing to ignore this for internal
@@ -1180,21 +1180,21 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
zend_string *fe_class_name, *proto_class_name;
if (!strcasecmp(fe_arg_info->class_name, "parent") && proto->common.scope) {
- fe_class_name = STR_COPY(proto->common.scope->name);
+ fe_class_name = zend_string_copy(proto->common.scope->name);
} else if (!strcasecmp(fe_arg_info->class_name, "self") && fe->common.scope) {
- fe_class_name = STR_COPY(fe->common.scope->name);
+ fe_class_name = zend_string_copy(fe->common.scope->name);
} else {
- fe_class_name = STR_INIT(
+ fe_class_name = zend_string_init(
fe_arg_info->class_name,
fe_arg_info->class_name_len, 0);
}
if (!strcasecmp(proto_arg_info->class_name, "parent") && proto->common.scope && proto->common.scope->parent) {
- proto_class_name = STR_COPY(proto->common.scope->parent->name);
+ proto_class_name = zend_string_copy(proto->common.scope->parent->name);
} else if (!strcasecmp(proto_arg_info->class_name, "self") && proto->common.scope) {
- proto_class_name = STR_COPY(proto->common.scope->name);
+ proto_class_name = zend_string_copy(proto->common.scope->name);
} else {
- proto_class_name = STR_INIT(
+ proto_class_name = zend_string_init(
proto_arg_info->class_name,
proto_arg_info->class_name_len, 0);
}
@@ -1203,8 +1203,8 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
const char *colon;
if (fe->common.type != ZEND_USER_FUNCTION) {
- STR_RELEASE(proto_class_name);
- STR_RELEASE(fe_class_name);
+ zend_string_release(proto_class_name);
+ zend_string_release(fe_class_name);
return 0;
} else if (strchr(proto_class_name->val, '\\') != NULL ||
(colon = zend_memrchr(fe_class_name->val, '\\', fe_class_name->len)) == NULL ||
@@ -1219,14 +1219,14 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
fe_ce->type == ZEND_INTERNAL_CLASS ||
proto_ce->type == ZEND_INTERNAL_CLASS ||
fe_ce != proto_ce) {
- STR_RELEASE(proto_class_name);
- STR_RELEASE(fe_class_name);
+ zend_string_release(proto_class_name);
+ zend_string_release(fe_class_name);
return 0;
}
}
}
- STR_RELEASE(proto_class_name);
- STR_RELEASE(fe_class_name);
+ zend_string_release(proto_class_name);
+ zend_string_release(fe_class_name);
}
if (fe_arg_info->type_hint != proto_arg_info->type_hint) {
/* Incompatible type hint */
@@ -1252,7 +1252,7 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
static char *zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{{ */
{
char *offset, *buf;
- zend_uint length = 1024;
+ uint32_t length = 1024;
offset = buf = (char *)emalloc(length * sizeof(char));
if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
@@ -1276,14 +1276,14 @@ static char *zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{{
*(offset++) = '(';
if (fptr->common.arg_info) {
- zend_uint i, required;
+ uint32_t i, required;
zend_arg_info *arg_info = fptr->common.arg_info;
required = fptr->common.required_num_args;
for (i = 0; i < fptr->common.num_args;) {
if (arg_info->class_name) {
const char *class_name;
- zend_uint class_name_len;
+ uint32_t class_name_len;
if (!strcasecmp(arg_info->class_name, "self") && fptr->common.scope ) {
class_name = fptr->common.scope->name->val;
class_name_len = fptr->common.scope->name->len;
@@ -1299,7 +1299,7 @@ static char *zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{{
offset += class_name_len;
*(offset++) = ' ';
} else if (arg_info->type_hint) {
- zend_uint type_name_len;
+ uint32_t type_name_len;
char *type_name = zend_get_type_by_const(arg_info->type_hint);
type_name_len = strlen(type_name);
REALLOC_BUF_IF_EXCEED(buf, offset, length, type_name_len);
@@ -1325,7 +1325,7 @@ static char *zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{{
memcpy(offset, arg_info->name, arg_info->name_len);
offset += arg_info->name_len;
} else {
- zend_uint idx = i;
+ uint32_t idx = i;
memcpy(offset, "param", 5);
offset += 5;
do {
@@ -1340,7 +1340,7 @@ static char *zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{{
if (fptr->type == ZEND_USER_FUNCTION) {
zend_op *precv = NULL;
{
- zend_uint idx = i;
+ uint32_t idx = i;
zend_op *op = ((zend_op_array *)fptr)->opcodes;
zend_op *end = op + ((zend_op_array *)fptr)->last;
@@ -1392,7 +1392,7 @@ static char *zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{{
REALLOC_BUF_IF_EXCEED(buf, offset, length, str->len);
memcpy(offset, str->val, str->len);
offset += str->len;
- STR_RELEASE(str);
+ zend_string_release(str);
}
}
} else {
@@ -1418,8 +1418,8 @@ static char *zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{{
static void do_inheritance_check_on_method(zend_function *child, zend_function *parent TSRMLS_DC) /* {{{ */
{
- zend_uint child_flags;
- zend_uint parent_flags = parent->common.fn_flags;
+ uint32_t child_flags;
+ uint32_t parent_flags = parent->common.fn_flags;
if ((parent->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0
&& parent->common.fn_flags & ZEND_ACC_ABSTRACT
@@ -1490,7 +1490,7 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_function *parent, zend_string *key, zend_class_entry *child_ce) /* {{{ */
{
- zend_uint parent_flags = parent->common.fn_flags;
+ uint32_t parent_flags = parent->common.fn_flags;
zend_function *child;
TSRMLS_FETCH();
@@ -1569,7 +1569,7 @@ static inline void do_implement_interface(zend_class_entry *ce, zend_class_entry
ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface TSRMLS_DC) /* {{{ */
{
/* expects interface to be contained in ce's interface list already */
- zend_uint i, ce_num, if_num = iface->num_interfaces;
+ uint32_t i, ce_num, if_num = iface->num_interfaces;
zend_class_entry *entry;
if (if_num==0) {
@@ -1808,9 +1808,9 @@ static void do_inherit_iface_constant(zend_string *name, zval *zv, zend_class_en
ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC) /* {{{ */
{
- zend_uint i, ignore = 0;
- zend_uint current_iface_num = ce->num_interfaces;
- zend_uint parent_iface_num = ce->parent ? ce->parent->num_interfaces : 0;
+ uint32_t i, ignore = 0;
+ uint32_t current_iface_num = ce->num_interfaces;
+ uint32_t parent_iface_num = ce->parent ? ce->parent->num_interfaces : 0;
zend_function *func;
zend_string *key;
zval *zv;
@@ -1861,9 +1861,9 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry
ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *trait TSRMLS_DC) /* {{{ */
{
- zend_uint i, ignore = 0;
- zend_uint current_trait_num = ce->num_traits;
- zend_uint parent_trait_num = ce->parent ? ce->parent->num_traits : 0;
+ uint32_t i, ignore = 0;
+ uint32_t current_trait_num = ce->num_traits;
+ uint32_t parent_trait_num = ce->parent ? ce->parent->num_traits : 0;
for (i = 0; i < ce->num_traits; i++) {
if (ce->traits[i] == NULL) {
@@ -1890,8 +1890,8 @@ ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *tr
static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_function *other_fn TSRMLS_DC) /* {{{ */
{
- zend_uint fn_flags = fn->common.scope->ce_flags;
- zend_uint other_flags = other_fn->common.scope->ce_flags;
+ uint32_t fn_flags = fn->common.scope->ce_flags;
+ uint32_t other_flags = other_fn->common.scope->ce_flags;
return zend_do_perform_implementation_check(fn, other_fn TSRMLS_CC)
&& ((other_fn->common.scope->ce_flags & ZEND_ACC_INTERFACE) || zend_do_perform_implementation_check(other_fn, fn TSRMLS_CC))
@@ -1928,7 +1928,7 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen
} else if (!strncmp(mname->val, ZEND_DEBUGINFO_FUNC_NAME, mname->len)) {
ce->__debugInfo = fe;
} else if (ce->name->len == mname->len) {
- zend_string *lowercase_name = STR_ALLOC(ce->name->len, 0);
+ zend_string *lowercase_name = zend_string_alloc(ce->name->len, 0);
zend_str_tolower_copy(lowercase_name->val, ce->name->val, ce->name->len);
lowercase_name = zend_new_interned_string(lowercase_name TSRMLS_CC);
if (!memcmp(mname->val, lowercase_name->val, mname->len)) {
@@ -1938,7 +1938,7 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen
ce->constructor = fe;
fe->common.fn_flags |= ZEND_ACC_CTOR;
}
- STR_RELEASE(lowercase_name);
+ zend_string_release(lowercase_name);
}
}
/* }}} */
@@ -2057,10 +2057,10 @@ static int zend_traits_copy_functions(zend_string *fnname, zend_function *fn, ze
fn_copy.common.fn_flags = alias->modifiers | (fn->common.fn_flags ^ (fn->common.fn_flags & ZEND_ACC_PPP_MASK));
}
- lcname = STR_ALLOC(alias->alias->len, 0);
+ lcname = zend_string_alloc(alias->alias->len, 0);
zend_str_tolower_copy(lcname->val, alias->alias->val, alias->alias->len);
zend_add_trait_method(ce, alias->alias->val, lcname, &fn_copy, overriden TSRMLS_CC);
- STR_RELEASE(lcname);
+ zend_string_release(lcname);
/* Record the trait from which this alias was resolved. */
if (!alias->trait_method->ce) {
@@ -2108,7 +2108,7 @@ static int zend_traits_copy_functions(zend_string *fnname, zend_function *fn, ze
static void zend_check_trait_usage(zend_class_entry *ce, zend_class_entry *trait TSRMLS_DC) /* {{{ */
{
- zend_uint i;
+ uint32_t i;
if ((trait->ce_flags & ZEND_ACC_TRAIT) != ZEND_ACC_TRAIT) {
zend_error_noreturn(E_COMPILE_ERROR, "Class %s is not a trait, Only traits may be used in 'as' and 'insteadof' statements", trait->name->val);
@@ -2145,13 +2145,13 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
zend_check_trait_usage(ce, cur_precedence->trait_method->ce TSRMLS_CC);
/** Ensure that the prefered method is actually available. */
- lcname = STR_ALLOC(cur_method_ref->method_name->len, 0);
+ lcname = zend_string_alloc(cur_method_ref->method_name->len, 0);
zend_str_tolower_copy(lcname->val,
cur_method_ref->method_name->val,
cur_method_ref->method_name->len);
method_exists = zend_hash_exists(&cur_method_ref->ce->function_table,
lcname);
- STR_FREE(lcname);
+ zend_string_free(lcname);
if (!method_exists) {
zend_error_noreturn(E_COMPILE_ERROR,
"A precedence rule was defined for %s::%s but this method does not exist",
@@ -2185,7 +2185,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
cur_precedence->trait_method->ce->name->val);
}
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
j++;
}
}
@@ -2205,13 +2205,13 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce TSRMLS_DC) /*
zend_check_trait_usage(ce, cur_method_ref->ce TSRMLS_CC);
/** And, ensure that the referenced method is resolvable, too. */
- lcname = STR_ALLOC(cur_method_ref->method_name->len, 0);
+ lcname = zend_string_alloc(cur_method_ref->method_name->len, 0);
zend_str_tolower_copy(lcname->val,
cur_method_ref->method_name->val,
cur_method_ref->method_name->len);
method_exists = zend_hash_exists(&cur_method_ref->ce->function_table,
lcname);
- STR_FREE(lcname);
+ zend_string_free(lcname);
if (!method_exists) {
zend_error_noreturn(E_COMPILE_ERROR, "An alias was defined for %s::%s but this method does not exist", cur_method_ref->ce->name->val, cur_method_ref->method_name->val);
@@ -2235,16 +2235,16 @@ static void zend_traits_compile_exclude_table(HashTable* exclude_table, zend_tra
j = 0;
while (precedences[i]->exclude_from_classes[j].ce) {
if (precedences[i]->exclude_from_classes[j].ce == trait) {
- zend_string *lcname = STR_ALLOC(precedences[i]->trait_method->method_name->len, 0);
+ zend_string *lcname = zend_string_alloc(precedences[i]->trait_method->method_name->len, 0);
zend_str_tolower_copy(lcname->val,
precedences[i]->trait_method->method_name->val,
precedences[i]->trait_method->method_name->len);
if (zend_hash_add_empty_element(exclude_table, lcname) == NULL) {
- STR_RELEASE(lcname);
+ zend_string_release(lcname);
zend_error_noreturn(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->val, trait->name->val);
}
- STR_RELEASE(lcname);
+ zend_string_release(lcname);
}
++j;
}
@@ -2256,7 +2256,7 @@ static void zend_traits_compile_exclude_table(HashTable* exclude_table, zend_tra
static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ */
{
- zend_uint i;
+ uint32_t i;
HashTable *overriden = NULL;
zend_string *key;
zend_function *fn;
@@ -2320,7 +2320,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;
- zend_uint flags;
+ uint32_t flags;
zend_string *doc_comment;
/* In the following steps the properties are inserted into the property table
@@ -2335,7 +2335,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {
*/
flags = property_info->flags;
if ((flags & ZEND_ACC_PPP_MASK) == ZEND_ACC_PUBLIC) {
- prop_name = STR_COPY(property_info->name);
+ prop_name = zend_string_copy(property_info->name);
} else {
const char *pname;
int pname_len;
@@ -2343,7 +2343,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {
/* for private and protected we need to unmangle the names */
zend_unmangle_property_name_ex(property_info->name->val, property_info->name->len,
&class_name_unused, &pname, &pname_len);
- prop_name = STR_INIT(pname, pname_len, 0);
+ prop_name = zend_string_init(pname, pname_len, 0);
}
/* next: check for conflicts with current class */
@@ -2385,7 +2385,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {
property_info->ce->name->val,
prop_name->val,
ce->name->val);
- STR_RELEASE(prop_name);
+ zend_string_release(prop_name);
continue;
}
}
@@ -2399,11 +2399,11 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {
}
if (Z_REFCOUNTED_P(prop_value)) Z_ADDREF_P(prop_value);
- doc_comment = property_info->doc_comment ? STR_COPY(property_info->doc_comment) : NULL;
+ doc_comment = property_info->doc_comment ? zend_string_copy(property_info->doc_comment) : NULL;
zend_declare_property_ex(ce, prop_name,
prop_value, flags,
doc_comment TSRMLS_CC);
- STR_RELEASE(prop_name);
+ zend_string_release(prop_name);
} ZEND_HASH_FOREACH_END();
}
}
@@ -2436,19 +2436,19 @@ static void zend_do_check_for_inconsistent_traits_aliasing(zend_class_entry *ce
2) it is just a plain old inconsitency/typo/bug
as in the case where alias is set. */
- lc_method_name = STR_ALLOC(cur_alias->trait_method->method_name->len, 0);
+ lc_method_name = zend_string_alloc(cur_alias->trait_method->method_name->len, 0);
zend_str_tolower_copy(
lc_method_name->val,
cur_alias->trait_method->method_name->val,
cur_alias->trait_method->method_name->len);
if (zend_hash_exists(&ce->function_table,
lc_method_name)) {
- STR_FREE(lc_method_name);
+ zend_string_free(lc_method_name);
zend_error_noreturn(E_COMPILE_ERROR,
"The modifiers for the trait alias %s() need to be changed in the same statment in which the alias is defined. Error",
cur_alias->trait_method->method_name->val);
} else {
- STR_FREE(lc_method_name);
+ zend_string_free(lc_method_name);
zend_error_noreturn(E_COMPILE_ERROR,
"The modifiers of the trait method %s() are changed, but this method does not exist. Error",
cur_alias->trait_method->method_name->val);
@@ -2646,7 +2646,7 @@ void zend_do_early_binding(TSRMLS_D) /* {{{ */
((CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES) &&
(ce->type == ZEND_INTERNAL_CLASS))) {
if (CG(compiler_options) & ZEND_COMPILE_DELAYED_BINDING) {
- zend_uint *opline_num = &CG(active_op_array)->early_binding;
+ uint32_t *opline_num = &CG(active_op_array)->early_binding;
while (*opline_num != -1) {
opline_num = &CG(active_op_array)->opcodes[*opline_num].result.opline_num;
@@ -2691,7 +2691,7 @@ ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array TSRMLS
{
if (op_array->early_binding != -1) {
zend_bool orig_in_compilation = CG(in_compilation);
- zend_uint opline_num = op_array->early_binding;
+ uint32_t opline_num = op_array->early_binding;
zend_class_entry *ce;
CG(in_compilation) = 1;
@@ -2712,7 +2712,7 @@ ZEND_API zend_string *zend_mangle_property_name(const char *src1, int src1_lengt
int prop_name_length;
prop_name_length = 1 + src1_length + 1 + src2_length;
- prop_name = STR_ALLOC(prop_name_length, internal);
+ prop_name = zend_string_alloc(prop_name_length, internal);
prop_name->val[0] = '\0';
memcpy(prop_name->val + 1, src1, src1_length+1);
memcpy(prop_name->val + 1 + src1_length + 1, src2, src2_length+1);
@@ -2928,7 +2928,7 @@ int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global
retval = zend_hash_add_mem(CG(auto_globals), name, &auto_global, sizeof(zend_auto_global)) != NULL ? SUCCESS : FAILURE;
- STR_RELEASE(auto_global.name);
+ zend_string_release(auto_global.name);
return retval;
}
/* }}} */
@@ -3062,7 +3062,7 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify
}
/* }}} */
-zend_uint zend_get_class_fetch_type(zend_string *name) {
+uint32_t zend_get_class_fetch_type(zend_string *name) {
if (name->len == sizeof("self") - 1 &&
!strncasecmp(name->val, "self", sizeof("self") - 1)) {
return ZEND_FETCH_CLASS_SELF;
@@ -3077,7 +3077,7 @@ zend_uint zend_get_class_fetch_type(zend_string *name) {
}
}
-ZEND_API zend_string *zend_get_compiled_variable_name(const zend_op_array *op_array, zend_uint var) /* {{{ */
+ZEND_API zend_string *zend_get_compiled_variable_name(const zend_op_array *op_array, uint32_t var) /* {{{ */
{
return op_array->vars[EX_VAR_TO_NUM(var)];
}
@@ -3092,11 +3092,11 @@ zend_ast *zend_ast_append_str(zend_ast *left_ast, zend_ast *right_ast) {
size_t left_len = left->len;
size_t len = left_len + right->len + 1; /* left\right */
- result = STR_REALLOC(left, len, 0);
+ result = zend_string_realloc(left, len, 0);
result->val[left_len] = '\\';
memcpy(&result->val[left_len + 1], right->val, right->len);
result->val[len] = '\0';
- STR_RELEASE(right);
+ zend_string_release(right);
ZVAL_STR(left_zv, result);
return left_ast;
@@ -3144,7 +3144,7 @@ static void zend_end_namespace(TSRMLS_D) {
CG(in_namespace) = 0;
zend_reset_import_tables(TSRMLS_C);
if (CG(current_namespace)) {
- STR_RELEASE(CG(current_namespace));
+ zend_string_release(CG(current_namespace));
CG(current_namespace) = NULL;
}
}
@@ -3264,7 +3264,7 @@ static inline zend_bool zend_str_equals_str_ci(zend_string *str1, zend_string *s
((str)->len == sizeof(c) - 1 \
&& !zend_binary_strcasecmp((str)->val, (str)->len, (c), sizeof(c) - 1))
-static void zend_adjust_for_fetch_type(zend_op *opline, zend_uint type) {
+static void zend_adjust_for_fetch_type(zend_op *opline, uint32_t type) {
switch (type & BP_VAR_MASK) {
case BP_VAR_R:
return;
@@ -3362,23 +3362,23 @@ static inline zend_op *zend_emit_op_data(znode *value TSRMLS_DC) {
return zend_emit_op(NULL, ZEND_OP_DATA, value, NULL TSRMLS_CC);
}
-static inline zend_uint zend_emit_jump(zend_uint opnum_target TSRMLS_DC) {
- zend_uint opnum = get_next_op_number(CG(active_op_array));
+static inline uint32_t zend_emit_jump(uint32_t opnum_target TSRMLS_DC) {
+ uint32_t opnum = get_next_op_number(CG(active_op_array));
zend_op *opline = zend_emit_op(NULL, ZEND_JMP, NULL, NULL TSRMLS_CC);
opline->op1.opline_num = opnum_target;
return opnum;
}
-static inline zend_uint zend_emit_cond_jump(
- zend_uchar opcode, znode *cond, zend_uint opnum_target TSRMLS_DC
+static inline uint32_t zend_emit_cond_jump(
+ zend_uchar opcode, znode *cond, uint32_t opnum_target TSRMLS_DC
) {
- zend_uint opnum = get_next_op_number(CG(active_op_array));
+ uint32_t opnum = get_next_op_number(CG(active_op_array));
zend_op *opline = zend_emit_op(NULL, opcode, cond, NULL TSRMLS_CC);
opline->op2.opline_num = opnum_target;
return opnum;
}
-static inline void zend_update_jump_target(zend_uint opnum_jump, zend_uint opnum_target TSRMLS_DC) {
+static inline void zend_update_jump_target(uint32_t opnum_jump, uint32_t opnum_target TSRMLS_DC) {
zend_op *opline = &CG(active_op_array)->opcodes[opnum_jump];
switch (opline->opcode) {
case ZEND_JMP:
@@ -3394,7 +3394,7 @@ static inline void zend_update_jump_target(zend_uint opnum_jump, zend_uint opnum
}
}
-static inline void zend_update_jump_target_to_next(zend_uint opnum_jump TSRMLS_DC) {
+static inline void zend_update_jump_target_to_next(uint32_t opnum_jump TSRMLS_DC) {
zend_update_jump_target(opnum_jump, get_next_op_number(CG(active_op_array)) TSRMLS_CC);
}
@@ -3414,13 +3414,13 @@ static inline zend_op *zend_delayed_emit_op(
return zend_stack_top(&CG(delayed_oplines_stack));
}
-static inline zend_uint zend_delayed_compile_begin(TSRMLS_D) {
+static inline uint32_t zend_delayed_compile_begin(TSRMLS_D) {
return zend_stack_count(&CG(delayed_oplines_stack));
}
-static zend_op *zend_delayed_compile_end(zend_uint offset TSRMLS_DC) {
+static zend_op *zend_delayed_compile_end(uint32_t offset TSRMLS_DC) {
zend_op *opline, *oplines = zend_stack_base(&CG(delayed_oplines_stack));
- zend_uint i, count = zend_stack_count(&CG(delayed_oplines_stack));
+ uint32_t i, count = zend_stack_count(&CG(delayed_oplines_stack));
ZEND_ASSERT(count > offset);
for (i = offset; i < count; ++i) {
@@ -3515,19 +3515,19 @@ static zend_op *zend_compile_class_ref(znode *result, zend_ast *name_ast TSRMLS_
if (name_node.op_type == IS_CONST) {
zend_string *name = Z_STR(name_node.u.constant);
- zend_uint fetch_type = zend_get_class_fetch_type(name);
+ uint32_t fetch_type = zend_get_class_fetch_type(name);
opline = zend_emit_op(result, ZEND_FETCH_CLASS, NULL, NULL TSRMLS_CC);
opline->extended_value = fetch_type;
if (fetch_type == ZEND_FETCH_CLASS_DEFAULT) {
- zend_uint type = name_ast->kind == ZEND_AST_ZVAL ? name_ast->attr : ZEND_NAME_FQ;
+ uint32_t type = name_ast->kind == ZEND_AST_ZVAL ? name_ast->attr : ZEND_NAME_FQ;
opline->op2_type = IS_CONST;
opline->op2.constant = zend_add_class_name_literal(CG(active_op_array),
zend_resolve_class_name(name, type TSRMLS_CC) TSRMLS_CC);
}
- STR_RELEASE(name);
+ zend_string_release(name);
} else {
opline = zend_emit_op(result, ZEND_FETCH_CLASS, NULL, &name_node TSRMLS_CC);
opline->extended_value = ZEND_FETCH_CLASS_DEFAULT;
@@ -3542,7 +3542,7 @@ static int zend_try_compile_cv(znode *result, zend_ast *ast TSRMLS_DC) {
zend_string *name = zval_get_string(zend_ast_get_zval(name_ast));
if (zend_is_auto_global(name TSRMLS_CC)) {
- STR_RELEASE(name);
+ zend_string_release(name);
return FAILURE;
}
@@ -3567,7 +3567,7 @@ static zend_op *zend_compile_simple_var_no_cv(znode *result, zend_ast *ast, int
if (ast->kind != ZEND_AST_ZVAL
&& CG(active_op_array)->scope && CG(active_op_array)->this_var == -1
) {
- zend_string *key = STR_INIT("this", sizeof("this") - 1, 0);
+ zend_string *key = zend_string_init("this", sizeof("this") - 1, 0);
CG(active_op_array)->this_var = lookup_cv(CG(active_op_array), key TSRMLS_CC);
}
@@ -3601,9 +3601,9 @@ static void zend_separate_if_call_and_write(znode *node, zend_ast *ast, int type
}
}
-void zend_delayed_compile_var(znode *result, zend_ast *ast, zend_uint type TSRMLS_DC);
+void zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t type TSRMLS_DC);
-static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, zend_uint type TSRMLS_DC) {
+static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, uint32_t type TSRMLS_DC) {
zend_ast *var_ast = ast->child[0];
zend_ast *dim_ast = ast->child[1];
@@ -3629,9 +3629,9 @@ static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, zend_uint
}
static inline zend_op *zend_compile_dim_common(
- znode *result, zend_ast *ast, zend_uint type TSRMLS_DC
+ znode *result, zend_ast *ast, uint32_t type TSRMLS_DC
) {
- zend_uint offset = zend_delayed_compile_begin(TSRMLS_C);
+ uint32_t offset = zend_delayed_compile_begin(TSRMLS_C);
zend_delayed_compile_dim(result, ast, type TSRMLS_CC);
return zend_delayed_compile_end(offset TSRMLS_CC);
}
@@ -3651,7 +3651,7 @@ static zend_bool is_this_fetch(zend_ast *ast) {
}
static zend_op *zend_delayed_compile_prop(
- znode *result, zend_ast *ast, zend_uint type TSRMLS_DC
+ znode *result, zend_ast *ast, uint32_t type TSRMLS_DC
) {
zend_ast *obj_ast = ast->child[0];
zend_ast *prop_ast = ast->child[1];
@@ -3675,8 +3675,8 @@ static zend_op *zend_delayed_compile_prop(
return opline;
}
-static zend_op *zend_compile_prop_common(znode *result, zend_ast *ast, zend_uint type TSRMLS_DC) {
- zend_uint offset = zend_delayed_compile_begin(TSRMLS_C);
+static zend_op *zend_compile_prop_common(znode *result, zend_ast *ast, uint32_t type TSRMLS_DC) {
+ uint32_t offset = zend_delayed_compile_begin(TSRMLS_C);
zend_delayed_compile_prop(result, ast, type TSRMLS_CC);
return zend_delayed_compile_end(offset TSRMLS_CC);
}
@@ -3718,7 +3718,7 @@ zend_op *zend_compile_static_prop_common(znode *result, zend_ast *ast, int type
return opline;
}
-void zend_compile_static_prop(znode *result, zend_ast *ast, zend_uint type TSRMLS_DC) {
+void zend_compile_static_prop(znode *result, zend_ast *ast, uint32_t type TSRMLS_DC) {
zend_op *opline = zend_compile_static_prop_common(result, ast, type TSRMLS_CC);
zend_adjust_for_fetch_type(opline, type);
}
@@ -3737,7 +3737,7 @@ static inline zend_uchar get_list_fetch_opcode(zend_uchar op_type) {
static void zend_compile_list_assign(znode *result, zend_ast *ast, znode *expr_node TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
if (list->children == 1 && !list->child[0]) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use empty list");
@@ -3805,8 +3805,8 @@ zend_bool zend_is_assign_to_self(zend_ast *var_ast, zend_ast *expr_ast TSRMLS_DC
zend_string *name1 = zval_get_string(zend_ast_get_zval(var_ast->child[0]));
zend_string *name2 = zval_get_string(zend_ast_get_zval(expr_ast->child[0]));
zend_bool result = zend_str_equals_str(name1, name2);
- STR_RELEASE(name1);
- STR_RELEASE(name2);
+ zend_string_release(name1);
+ zend_string_release(name2);
return result;
}
}
@@ -3817,7 +3817,7 @@ void zend_compile_assign(znode *result, zend_ast *ast TSRMLS_DC) {
znode var_node, expr_node;
zend_op *opline;
- zend_uint offset;
+ uint32_t offset;
if (is_this_fetch(var_ast)) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot re-assign $this");
@@ -3912,11 +3912,11 @@ static inline void zend_emit_assign_ref_znode(zend_ast *var_ast, znode *value_no
void zend_compile_compound_assign(znode *result, zend_ast *ast TSRMLS_DC) {
zend_ast *var_ast = ast->child[0];
zend_ast *expr_ast = ast->child[1];
- zend_uint opcode = ast->attr;
+ uint32_t opcode = ast->attr;
znode var_node, expr_node;
zend_op *opline;
- zend_uint offset;
+ uint32_t offset;
zend_ensure_writable_variable(var_ast);
@@ -3955,16 +3955,16 @@ void zend_compile_compound_assign(znode *result, zend_ast *ast TSRMLS_DC) {
}
}
-zend_uint zend_compile_args(zend_ast *ast, zend_function *fbc TSRMLS_DC) {
+uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc TSRMLS_DC) {
// TODO.AST &var error
zend_ast_list *args = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
zend_bool uses_arg_unpack = 0;
- zend_uint arg_count = 0; /* number of arguments not including unpacks */
+ uint32_t arg_count = 0; /* number of arguments not including unpacks */
for (i = 0; i < args->children; ++i) {
zend_ast *arg = args->child[i];
- zend_uint arg_num = i + 1;
+ uint32_t arg_num = i + 1;
znode arg_node;
zend_op *opline;
@@ -4051,9 +4051,9 @@ zend_uint zend_compile_args(zend_ast *ast, zend_function *fbc TSRMLS_DC) {
void zend_compile_call_common(znode *result, zend_ast *args_ast, zend_function *fbc TSRMLS_DC) {
zend_op *opline;
- zend_uint opnum_init = get_next_op_number(CG(active_op_array)) - 1;
- zend_uint arg_count;
- zend_uint call_flags;
+ uint32_t opnum_init = get_next_op_number(CG(active_op_array)) - 1;
+ uint32_t arg_count;
+ uint32_t call_flags;
zend_do_extended_fcall_begin(TSRMLS_C);
@@ -4109,7 +4109,7 @@ void zend_compile_dynamic_call(znode *result, znode *name_node, zend_ast *args_a
}
static zend_bool zend_args_contain_unpack(zend_ast_list *args) {
- zend_uint i;
+ uint32_t i;
for (i = 0; i < args->children; ++i) {
if (args->child[i]->kind == ZEND_AST_UNPACK) {
return 1;
@@ -4132,7 +4132,7 @@ int zend_compile_func_strlen(znode *result, zend_ast_list *args TSRMLS_DC) {
return SUCCESS;
}
-int zend_compile_func_typecheck(znode *result, zend_ast_list *args, zend_uint type TSRMLS_DC) {
+int zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t type TSRMLS_DC) {
znode arg_node;
zend_op *opline;
@@ -4156,7 +4156,7 @@ int zend_compile_func_defined(znode *result, zend_ast_list *args TSRMLS_DC) {
name = zval_get_string(zend_ast_get_zval(args->child[0]));
if (zend_memrchr(name->val, '\\', name->len) || zend_memrchr(name->val, ':', name->len)) {
- STR_RELEASE(name);
+ zend_string_release(name);
return FAILURE;
}
@@ -4168,7 +4168,7 @@ int zend_compile_func_defined(znode *result, zend_ast_list *args TSRMLS_DC) {
/* Lowercase constant name in a separate literal */
{
zval c;
- zend_string *lcname = STR_ALLOC(name->len, 0);
+ zend_string *lcname = zend_string_alloc(name->len, 0);
zend_str_tolower_copy(lcname->val, name->val, name->len);
ZVAL_NEW_STR(&c, lcname);
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
@@ -4177,7 +4177,7 @@ int zend_compile_func_defined(znode *result, zend_ast_list *args TSRMLS_DC) {
}
static int zend_try_compile_ct_bound_init_user_func(
- znode *result, zend_ast *name_ast, zend_uint num_args TSRMLS_DC
+ znode *result, zend_ast *name_ast, uint32_t num_args TSRMLS_DC
) {
zend_string *name, *lcname;
zend_function *fbc;
@@ -4188,14 +4188,14 @@ static int zend_try_compile_ct_bound_init_user_func(
}
name = zend_ast_get_str(name_ast);
- lcname = STR_ALLOC(name->len, 0);
+ lcname = zend_string_alloc(name->len, 0);
zend_str_tolower_copy(lcname->val, name->val, name->len);
fbc = zend_hash_find_ptr(CG(function_table), lcname);
if (!fbc || (fbc->type == ZEND_INTERNAL_FUNCTION &&
(CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS))
) {
- STR_FREE(lcname);
+ zend_string_free(lcname);
return FAILURE;
}
@@ -4208,7 +4208,7 @@ static int zend_try_compile_ct_bound_init_user_func(
}
static void zend_compile_init_user_func(
- znode *result, zend_ast *name_ast, zend_uint num_args, zend_string *orig_func_name TSRMLS_DC
+ znode *result, zend_ast *name_ast, uint32_t num_args, zend_string *orig_func_name TSRMLS_DC
) {
zend_op *opline;
znode name_node;
@@ -4221,7 +4221,7 @@ static void zend_compile_init_user_func(
opline = zend_emit_op(NULL, ZEND_INIT_USER_CALL, NULL, &name_node TSRMLS_CC);
opline->op1_type = IS_CONST;
- LITERAL_STR(opline->op1, STR_COPY(orig_func_name));
+ LITERAL_STR(opline->op1, zend_string_copy(orig_func_name));
opline->extended_value = num_args;
}
@@ -4243,7 +4243,7 @@ int zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcna
/* cuf = call_user_func */
int zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcname TSRMLS_DC) {
- zend_uint i;
+ uint32_t i;
if (args->children < 1 || zend_args_contain_unpack(args)) {
return FAILURE;
@@ -4333,7 +4333,7 @@ void zend_compile_call(znode *result, zend_ast *ast, int type TSRMLS_DC) {
{
zval *name = &name_node.u.constant;
- zend_string *lcname = STR_ALLOC(Z_STRLEN_P(name), 0);
+ zend_string *lcname = zend_string_alloc(Z_STRLEN_P(name), 0);
zend_function *fbc;
zend_op *opline;
@@ -4343,7 +4343,7 @@ void zend_compile_call(znode *result, zend_ast *ast, int type TSRMLS_DC) {
if (!fbc || (fbc->type == ZEND_INTERNAL_FUNCTION &&
(CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS))
) {
- STR_RELEASE(lcname);
+ zend_string_release(lcname);
zend_compile_dynamic_call(result, &name_node, args_ast TSRMLS_CC);
return;
}
@@ -4351,7 +4351,7 @@ void zend_compile_call(znode *result, zend_ast *ast, int type TSRMLS_DC) {
if (zend_try_compile_special_func(result, lcname,
zend_ast_get_list(args_ast) TSRMLS_CC) == SUCCESS
) {
- STR_RELEASE(lcname);
+ zend_string_release(lcname);
zval_ptr_dtor(&name_node.u.constant);
return;
}
@@ -4460,7 +4460,7 @@ void zend_compile_new(znode *result, zend_ast *ast TSRMLS_DC) {
znode class_node, ctor_result;
zend_op *opline;
- zend_uint opnum;
+ uint32_t opnum;
zend_compile_class_ref(&class_node, class_ast TSRMLS_CC);
@@ -4585,7 +4585,7 @@ void zend_compile_unset(zend_ast *ast TSRMLS_DC) {
}
static void zend_free_foreach_and_switch_variables(TSRMLS_D) {
- zend_uint opnum_start, opnum_end, i;
+ uint32_t opnum_start, opnum_end, i;
opnum_start = get_next_op_number(CG(active_op_array));
@@ -4721,7 +4721,7 @@ void zend_compile_while(zend_ast *ast TSRMLS_DC) {
zend_ast *stmt_ast = ast->child[1];
znode cond_node;
- zend_uint opnum_start, opnum_jmpz;
+ uint32_t opnum_start, opnum_jmpz;
opnum_start = get_next_op_number(CG(active_op_array));
zend_compile_expr(&cond_node, cond_ast TSRMLS_CC);
@@ -4743,7 +4743,7 @@ void zend_compile_do_while(zend_ast *ast TSRMLS_DC) {
zend_ast *cond_ast = ast->child[1];
znode cond_node;
- zend_uint opnum_start, opnum_cond;
+ uint32_t opnum_start, opnum_cond;
zend_begin_loop(TSRMLS_C);
@@ -4760,7 +4760,7 @@ void zend_compile_do_while(zend_ast *ast TSRMLS_DC) {
void zend_compile_expr_list(znode *result, zend_ast *ast TSRMLS_DC) {
zend_ast_list *list;
- zend_uint i;
+ uint32_t i;
result->op_type = IS_CONST;
ZVAL_TRUE(&result->u.constant);
@@ -4785,7 +4785,7 @@ void zend_compile_for(zend_ast *ast TSRMLS_DC) {
zend_ast *stmt_ast = ast->child[3];
znode result;
- zend_uint opnum_cond, opnum_jmpz, opnum_loop;
+ uint32_t opnum_cond, opnum_jmpz, opnum_loop;
zend_compile_expr_list(&result, init_ast TSRMLS_CC);
zend_do_free(&result TSRMLS_CC);
@@ -4821,7 +4821,7 @@ void zend_compile_foreach(zend_ast *ast TSRMLS_DC) {
znode expr_node, reset_node, value_node, key_node, dummy_node;
zend_op *opline;
- zend_uint opnum_reset, opnum_fetch;
+ uint32_t opnum_reset, opnum_fetch;
zend_op foreach_stack_opline;
if (key_ast) {
@@ -4911,8 +4911,8 @@ void zend_compile_foreach(zend_ast *ast TSRMLS_DC) {
void zend_compile_if(zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
- zend_uint *jmp_opnums = safe_emalloc(sizeof(zend_uint), list->children - 1, 0);
+ uint32_t i;
+ uint32_t *jmp_opnums = safe_emalloc(sizeof(uint32_t), list->children - 1, 0);
for (i = 0; i < list->children; ++i) {
zend_ast *elem_ast = list->child[i];
@@ -4920,7 +4920,7 @@ void zend_compile_if(zend_ast *ast TSRMLS_DC) {
zend_ast *stmt_ast = elem_ast->child[1];
znode cond_node;
- zend_uint opnum_jmpz;
+ uint32_t opnum_jmpz;
if (cond_ast) {
zend_compile_expr(&cond_node, cond_ast TSRMLS_CC);
opnum_jmpz = zend_emit_cond_jump(ZEND_JMPZ, &cond_node, 0 TSRMLS_CC);
@@ -4948,14 +4948,14 @@ void zend_compile_switch(zend_ast *ast TSRMLS_DC) {
zend_ast *expr_ast = ast->child[0];
zend_ast_list *cases = zend_ast_get_list(ast->child[1]);
- zend_uint i;
+ uint32_t i;
zend_bool has_default_case = 0;
zend_switch_entry switch_entry;
znode expr_node, case_node;
zend_op *opline;
- zend_uint *jmpnz_opnums = safe_emalloc(sizeof(zend_uint), cases->children, 0);
- zend_uint opnum_default_jmp;
+ uint32_t *jmpnz_opnums = safe_emalloc(sizeof(uint32_t), cases->children, 0);
+ uint32_t opnum_default_jmp;
zend_compile_expr(&expr_node, expr_ast TSRMLS_CC);
@@ -5028,11 +5028,11 @@ void zend_compile_try(zend_ast *ast TSRMLS_DC) {
zend_ast_list *catches = zend_ast_get_list(ast->child[1]);
zend_ast *finally_ast = ast->child[2];
- zend_uint i;
+ uint32_t i;
zend_op *opline;
- zend_uint try_catch_offset = zend_add_try_element(
+ uint32_t try_catch_offset = zend_add_try_element(
get_next_op_number(CG(active_op_array)) TSRMLS_CC);
- zend_uint *jmp_opnums = safe_emalloc(sizeof(zend_uint), catches->children, 0);
+ uint32_t *jmp_opnums = safe_emalloc(sizeof(uint32_t), catches->children, 0);
if (catches->children == 0 && !finally_ast) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use try without catch or finally");
@@ -5052,7 +5052,7 @@ void zend_compile_try(zend_ast *ast TSRMLS_DC) {
zval *var_name = zend_ast_get_zval(var_ast);
zend_bool is_last_catch = (i + 1 == catches->children);
- zend_uint opnum_catch;
+ uint32_t opnum_catch;
if (!zend_is_const_default_class_ref(class_ast)) {
zend_error_noreturn(E_COMPILE_ERROR, "Bad class name in the catch statement");
@@ -5072,7 +5072,7 @@ void zend_compile_try(zend_ast *ast TSRMLS_DC) {
zend_resolve_class_name_ast(class_ast TSRMLS_CC) TSRMLS_CC);
opline->op2_type = IS_CV;
- opline->op2.var = lookup_cv(CG(active_op_array), STR_COPY(Z_STR_P(var_name)) TSRMLS_CC);
+ opline->op2.var = lookup_cv(CG(active_op_array), zend_string_copy(Z_STR_P(var_name)) TSRMLS_CC);
opline->result.num = is_last_catch;
zend_compile_stmt(stmt_ast TSRMLS_CC);
@@ -5090,7 +5090,7 @@ void zend_compile_try(zend_ast *ast TSRMLS_DC) {
}
if (finally_ast) {
- zend_uint opnum_jmp = get_next_op_number(CG(active_op_array)) + 1;
+ uint32_t opnum_jmp = get_next_op_number(CG(active_op_array)) + 1;
opline = zend_emit_op(NULL, ZEND_FAST_CALL, NULL, NULL TSRMLS_CC);
opline->op1.opline_num = opnum_jmp + 1;
@@ -5116,7 +5116,7 @@ void zend_compile_try(zend_ast *ast TSRMLS_DC) {
/* Encoding declarations must already be handled during parsing */
void zend_handle_encoding_declaration(zend_ast_list *declares TSRMLS_DC) {
- zend_uint i;
+ uint32_t i;
for (i = 0; i < declares->children; ++i) {
zend_ast *declare_ast = declares->child[i];
zend_ast *name_ast = declare_ast->child[0];
@@ -5151,7 +5151,7 @@ void zend_handle_encoding_declaration(zend_ast_list *declares TSRMLS_DC) {
}
}
- STR_RELEASE(encoding_name);
+ zend_string_release(encoding_name);
} else {
zend_error(E_COMPILE_WARNING, "declare(encoding=...) ignored because "
"Zend multibyte feature is turned off by settings");
@@ -5164,7 +5164,7 @@ void zend_compile_declare(zend_ast *ast TSRMLS_DC) {
zend_ast_list *declares = zend_ast_get_list(ast->child[0]);
zend_ast *stmt_ast = ast->child[1];
zend_declarables orig_declarables = CG(declarables);
- zend_uint i;
+ uint32_t i;
for (i = 0; i < declares->children; ++i) {
zend_ast *declare_ast = declares->child[i];
@@ -5175,13 +5175,13 @@ void zend_compile_declare(zend_ast *ast TSRMLS_DC) {
if (zend_str_equals_literal_ci(name, "ticks")) {
zval value_zv;
zend_const_expr_to_zval(&value_zv, value_ast TSRMLS_CC);
- convert_to_long(&value_zv);
+ convert_to_int(&value_zv);
ZVAL_COPY_VALUE(&CG(declarables).ticks, &value_zv);
zval_dtor(&value_zv);
} else if (zend_str_equals_literal_ci(name, "encoding")) {
/* Encoding declaration was already handled during parsing. Here we
* only check that it is the first statement in the file. */
- zend_uint num = CG(active_op_array)->last;
+ uint32_t num = CG(active_op_array)->last;
while (num > 0 &&
(CG(active_op_array)->opcodes[num-1].opcode == ZEND_EXT_STMT ||
CG(active_op_array)->opcodes[num-1].opcode == ZEND_TICKS)) {
@@ -5206,7 +5206,7 @@ void zend_compile_declare(zend_ast *ast TSRMLS_DC) {
void zend_compile_stmt_list(zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
for (i = 0; i < list->children; ++i) {
zend_compile_stmt(list->child[i] TSRMLS_CC);
}
@@ -5214,7 +5214,7 @@ void zend_compile_stmt_list(zend_ast *ast TSRMLS_DC) {
void zend_compile_params(zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
zend_op_array *op_array = CG(active_op_array);
zend_arg_info *arg_infos;
@@ -5243,10 +5243,10 @@ void zend_compile_params(zend_ast *ast TSRMLS_DC) {
}
var_node.op_type = IS_CV;
- var_node.u.op.var = lookup_cv(CG(active_op_array), STR_COPY(name) TSRMLS_CC);
+ var_node.u.op.var = lookup_cv(CG(active_op_array), zend_string_copy(name) TSRMLS_CC);
if (EX_VAR_TO_NUM(var_node.u.op.var) != i) {
- zend_error_noreturn(E_COMPILE_ERROR, "Redefinition of parameter %s",
+ zend_error_noreturn(E_COMPILE_ERROR, "Redefinition of parameter $%s",
name->val);
} else if (zend_str_equals_literal(name, "this")) {
if (op_array->scope && (op_array->fn_flags & ZEND_ACC_STATIC) == 0) {
@@ -5323,14 +5323,14 @@ void zend_compile_params(zend_ast *ast TSRMLS_DC) {
if (zend_is_const_default_class_ref(type_ast)) {
class_name = zend_resolve_class_name_ast(type_ast TSRMLS_CC);
} else {
- STR_ADDREF(class_name);
+ zend_string_addref(class_name);
}
arg_info->type_hint = IS_OBJECT;
arg_info->class_name = estrndup(class_name->val, class_name->len);
arg_info->class_name_len = class_name->len;
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
if (default_ast && !has_null_default) {
zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters "
@@ -5347,7 +5347,7 @@ void zend_compile_params(zend_ast *ast TSRMLS_DC) {
void zend_compile_closure_uses(zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
for (i = 0; i < list->children; ++i) {
zend_ast *var_ast = list->child[i];
@@ -5413,9 +5413,9 @@ void zend_begin_method_decl(
}
op_array->scope = ce;
- op_array->function_name = STR_COPY(name);
+ op_array->function_name = zend_string_copy(name);
- lcname = STR_ALLOC(name->len, 0);
+ lcname = zend_string_alloc(name->len, 0);
zend_str_tolower_copy(lcname->val, name->val, name->len);
lcname = zend_new_interned_string(lcname TSRMLS_CC);
@@ -5544,7 +5544,7 @@ void zend_begin_method_decl(
}
}
- STR_RELEASE(lcname);
+ zend_string_release(lcname);
}
static void zend_begin_func_decl(
@@ -5556,7 +5556,7 @@ static void zend_begin_func_decl(
op_array->function_name = name = zend_prefix_with_ns(name TSRMLS_CC);
- lcname = STR_ALLOC(name->len, 0);
+ lcname = zend_string_alloc(name->len, 0);
zend_str_tolower_copy(lcname->val, name->val, name->len);
if (CG(current_import_function)) {
@@ -5580,7 +5580,7 @@ static void zend_begin_func_decl(
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_DECLARE_FUNCTION;
opline->op2_type = IS_CONST;
- LITERAL_STR(opline->op2, STR_COPY(lcname));
+ LITERAL_STR(opline->op2, zend_string_copy(lcname));
}
{
@@ -5592,7 +5592,7 @@ static void zend_begin_func_decl(
zend_hash_update_ptr(CG(function_table), key, op_array);
}
- STR_RELEASE(lcname);
+ zend_string_release(lcname);
}
void zend_compile_func_decl(znode *result, zend_ast *ast TSRMLS_DC) {
@@ -5613,7 +5613,7 @@ void zend_compile_func_decl(znode *result, zend_ast *ast TSRMLS_DC) {
op_array->line_start = decl->start_lineno;
op_array->line_end = decl->end_lineno;
if (decl->doc_comment) {
- op_array->doc_comment = STR_COPY(decl->doc_comment);
+ op_array->doc_comment = zend_string_copy(decl->doc_comment);
}
if (decl->kind == ZEND_AST_CLOSURE) {
op_array->fn_flags |= ZEND_ACC_CLOSURE;
@@ -5681,9 +5681,9 @@ void zend_compile_func_decl(znode *result, zend_ast *ast TSRMLS_DC) {
void zend_compile_prop_decl(zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint flags = list->attr;
+ uint32_t flags = list->attr;
zend_class_entry *ce = CG(active_class_entry);
- zend_uint i, children = list->children;
+ uint32_t i, children = list->children;
zend_string *doc_comment = NULL;
if (ce->ce_flags & ZEND_ACC_INTERFACE) {
@@ -5696,7 +5696,7 @@ void zend_compile_prop_decl(zend_ast *ast TSRMLS_DC) {
/* Doc comment has been appended as last element in property list */
if (list->child[children - 1]->kind == ZEND_AST_ZVAL) {
- doc_comment = STR_COPY(zend_ast_get_str(list->child[children - 1]));
+ doc_comment = zend_string_copy(zend_ast_get_str(list->child[children - 1]));
children -= 1;
}
@@ -5735,7 +5735,7 @@ void zend_compile_prop_decl(zend_ast *ast TSRMLS_DC) {
void zend_compile_class_const_decl(zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
zend_class_entry *ce = CG(active_class_entry);
- zend_uint i;
+ uint32_t i;
for (i = 0; i < list->children; ++i) {
zend_ast *const_ast = list->child[i];
@@ -5769,7 +5769,7 @@ static zend_trait_method_reference *zend_compile_method_ref(zend_ast *ast TSRMLS
zend_trait_method_reference *method_ref = emalloc(sizeof(zend_trait_method_reference));
method_ref->ce = NULL;
- method_ref->method_name = STR_COPY(zend_ast_get_str(method_ast));
+ method_ref->method_name = zend_string_copy(zend_ast_get_str(method_ast));
if (class_ast) {
method_ref->class_name = zend_resolve_class_name_ast(class_ast TSRMLS_CC);
@@ -5783,7 +5783,7 @@ static zend_trait_method_reference *zend_compile_method_ref(zend_ast *ast TSRMLS
static zend_string **zend_compile_name_list(zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
zend_string **names = safe_emalloc(sizeof(zend_string *), list->children + 1, 0);
- zend_uint i;
+ uint32_t i;
for (i = 0; i < list->children; ++i) {
zend_ast *name_ast = list->child[i];
@@ -5810,7 +5810,7 @@ static void zend_compile_trait_precedence(zend_ast *ast TSRMLS_DC) {
static void zend_compile_trait_alias(zend_ast *ast TSRMLS_DC) {
zend_ast *method_ref_ast = ast->child[0];
zend_ast *alias_ast = ast->child[1];
- zend_uint modifiers = ast->attr;
+ uint32_t modifiers = ast->attr;
zend_trait_alias *alias;
@@ -5827,7 +5827,7 @@ static void zend_compile_trait_alias(zend_ast *ast TSRMLS_DC) {
alias->modifiers = modifiers;
if (alias_ast) {
- alias->alias = STR_COPY(zend_ast_get_str(alias_ast));
+ alias->alias = zend_string_copy(zend_ast_get_str(alias_ast));
} else {
alias->alias = NULL;
}
@@ -5840,7 +5840,7 @@ void zend_compile_use_trait(zend_ast *ast TSRMLS_DC) {
zend_ast_list *adaptations = ast->child[1] ? zend_ast_get_list(ast->child[1]) : NULL;
zend_class_entry *ce = CG(active_class_entry);
zend_op *opline;
- zend_uint i;
+ uint32_t i;
for (i = 0; i < traits->children; ++i) {
zend_ast *trait_ast = traits->child[i];
@@ -5891,7 +5891,7 @@ void zend_compile_use_trait(zend_ast *ast TSRMLS_DC) {
void zend_compile_implements(znode *class_node, zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
for (i = 0; i < list->children; ++i) {
zend_ast *class_ast = list->child[i];
zend_string *name = zend_ast_get_str(class_ast);
@@ -5940,7 +5940,7 @@ void zend_compile_class_decl(zend_ast *ast TSRMLS_DC) {
name->val);
}
- lcname = STR_ALLOC(name->len, 0);
+ lcname = zend_string_alloc(name->len, 0);
zend_str_tolower_copy(lcname->val, name->val, name->len);
if (CG(current_import)) {
@@ -5950,11 +5950,11 @@ void zend_compile_class_decl(zend_ast *ast TSRMLS_DC) {
if (CG(current_namespace)) {
name = zend_prefix_with_ns(name TSRMLS_CC);
- STR_RELEASE(lcname);
- lcname = STR_ALLOC(name->len, 0);
+ zend_string_release(lcname);
+ lcname = zend_string_alloc(name->len, 0);
zend_str_tolower_copy(lcname->val, name->val, name->len);
} else {
- STR_ADDREF(name);
+ zend_string_addref(name);
}
if (import_name && !zend_str_equals_str_ci(lcname, import_name)) {
@@ -5974,7 +5974,7 @@ void zend_compile_class_decl(zend_ast *ast TSRMLS_DC) {
ce->info.user.line_start = decl->start_lineno;
ce->info.user.line_end = decl->end_lineno;
if (decl->doc_comment) {
- ce->info.user.doc_comment = STR_COPY(decl->doc_comment);
+ ce->info.user.doc_comment = zend_string_copy(decl->doc_comment);
}
if (extends_ast) {
@@ -6081,7 +6081,7 @@ void zend_compile_class_decl(zend_ast *ast TSRMLS_DC) {
CG(active_class_entry) = NULL;
}
-static HashTable *zend_get_import_ht(zend_uint type TSRMLS_DC) {
+static HashTable *zend_get_import_ht(uint32_t type TSRMLS_DC) {
switch (type) {
case T_CLASS:
if (!CG(current_import)) {
@@ -6105,7 +6105,7 @@ static HashTable *zend_get_import_ht(zend_uint type TSRMLS_DC) {
}
}
-static char *zend_get_use_type_str(zend_uint type) {
+static char *zend_get_use_type_str(uint32_t type) {
switch (type) {
case T_CLASS:
return "";
@@ -6118,7 +6118,7 @@ static char *zend_get_use_type_str(zend_uint type) {
}
static void zend_check_already_in_use(
- zend_uint type, zend_string *old_name, zend_string *new_name, zend_string *check_name
+ uint32_t type, zend_string *old_name, zend_string *new_name, zend_string *check_name
) {
if (zend_str_equals_str_ci(old_name, check_name)) {
return;
@@ -6130,9 +6130,9 @@ static void zend_check_already_in_use(
void zend_compile_use(zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
zend_string *current_ns = CG(current_namespace);
- zend_uint type = ast->attr;
+ uint32_t type = ast->attr;
HashTable *current_import = zend_get_import_ht(type TSRMLS_CC);
zend_bool case_sensitive = type == T_CONST;
@@ -6144,14 +6144,14 @@ void zend_compile_use(zend_ast *ast TSRMLS_DC) {
zend_string *new_name, *lookup_name;
if (new_name_ast) {
- new_name = STR_COPY(zend_ast_get_str(new_name_ast));
+ new_name = zend_string_copy(zend_ast_get_str(new_name_ast));
} else {
/* The form "use A\B" is eqivalent to "use A\B as B" */
const char *p = zend_memrchr(old_name->val, '\\', old_name->len);
if (p) {
- new_name = STR_INIT(p + 1, old_name->len - (p - old_name->val + 1), 0);
+ new_name = zend_string_init(p + 1, old_name->len - (p - old_name->val + 1), 0);
} else {
- new_name = STR_COPY(old_name);
+ new_name = zend_string_copy(old_name);
if (!current_ns) {
if (type == T_CLASS && zend_str_equals_literal(new_name, "strict")) {
@@ -6166,9 +6166,9 @@ void zend_compile_use(zend_ast *ast TSRMLS_DC) {
}
if (case_sensitive) {
- lookup_name = STR_COPY(new_name);
+ lookup_name = zend_string_copy(new_name);
} else {
- lookup_name = STR_ALLOC(new_name->len, 0);
+ lookup_name = zend_string_alloc(new_name->len, 0);
zend_str_tolower_copy(lookup_name->val, new_name->val, new_name->len);
}
@@ -6180,7 +6180,7 @@ void zend_compile_use(zend_ast *ast TSRMLS_DC) {
}
if (current_ns) {
- zend_string *ns_name = STR_ALLOC(current_ns->len + 1 + new_name->len, 0);
+ zend_string *ns_name = zend_string_alloc(current_ns->len + 1 + new_name->len, 0);
zend_str_tolower_copy(ns_name->val, current_ns->val, current_ns->len);
ns_name->val[current_ns->len] = '\\';
memcpy(ns_name->val + current_ns->len + 1, lookup_name->val, lookup_name->len);
@@ -6189,7 +6189,7 @@ void zend_compile_use(zend_ast *ast TSRMLS_DC) {
zend_check_already_in_use(type, old_name, new_name, ns_name);
}
- STR_FREE(ns_name);
+ zend_string_free(ns_name);
} else {
switch (type) {
case T_CLASS:
@@ -6224,20 +6224,20 @@ void zend_compile_use(zend_ast *ast TSRMLS_DC) {
}
}
- STR_ADDREF(old_name);
+ zend_string_addref(old_name);
if (!zend_hash_add_ptr(current_import, lookup_name, old_name)) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use%s %s as %s because the name "
"is already in use", zend_get_use_type_str(type), old_name->val, new_name->val);
}
- STR_RELEASE(lookup_name);
- STR_RELEASE(new_name);
+ zend_string_release(lookup_name);
+ zend_string_release(new_name);
}
}
void zend_compile_const_decl(zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
for (i = 0; i < list->children; ++i) {
zend_ast *const_ast = list->child[i];
zend_ast *name_ast = const_ast->child[0];
@@ -6304,7 +6304,7 @@ void zend_compile_namespace(zend_ast *ast TSRMLS_DC) {
|| (with_bracket && !CG(has_bracketed_namespaces))) && CG(active_op_array)->last > 0
) {
/* ignore ZEND_EXT_STMT and ZEND_TICKS */
- zend_uint num = CG(active_op_array)->last;
+ uint32_t num = CG(active_op_array)->last;
while (num > 0 &&
(CG(active_op_array)->opcodes[num-1].opcode == ZEND_EXT_STMT ||
CG(active_op_array)->opcodes[num-1].opcode == ZEND_TICKS)) {
@@ -6317,7 +6317,7 @@ void zend_compile_namespace(zend_ast *ast TSRMLS_DC) {
}
if (CG(current_namespace)) {
- STR_RELEASE(CG(current_namespace));
+ zend_string_release(CG(current_namespace));
}
if (name_ast) {
@@ -6327,7 +6327,7 @@ void zend_compile_namespace(zend_ast *ast TSRMLS_DC) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use '%s' as namespace name", name->val);
}
- CG(current_namespace) = STR_COPY(name);
+ CG(current_namespace) = zend_string_copy(name);
} else {
CG(current_namespace) = NULL;
}
@@ -6347,7 +6347,7 @@ void zend_compile_namespace(zend_ast *ast TSRMLS_DC) {
void zend_compile_halt_compiler(zend_ast *ast TSRMLS_DC) {
zend_ast *offset_ast = ast->child[0];
- long offset = Z_LVAL_P(zend_ast_get_zval(offset_ast));
+ zend_long offset = Z_LVAL_P(zend_ast_get_zval(offset_ast));
zend_string *filename, *name;
const char const_name[] = "__COMPILER_HALT_OFFSET__";
@@ -6362,7 +6362,7 @@ void zend_compile_halt_compiler(zend_ast *ast TSRMLS_DC) {
filename->val, filename->len, 0);
zend_register_long_constant(name->val, name->len, offset, CONST_CS, 0 TSRMLS_CC);
- STR_RELEASE(name);
+ zend_string_release(name);
}
static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC) {
@@ -6372,7 +6372,7 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC)
switch (ast->attr) {
case T_FUNC_C:
if (op_array && op_array->function_name) {
- ZVAL_STR(zv, STR_COPY(op_array->function_name));
+ ZVAL_STR(zv, zend_string_copy(op_array->function_name));
} else {
ZVAL_EMPTY_STRING(zv);
}
@@ -6383,10 +6383,10 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC)
ZVAL_STR(zv, zend_concat3(ce->name->val, ce->name->len, "::", 2,
op_array->function_name->val, op_array->function_name->len));
} else {
- ZVAL_STR(zv, STR_COPY(ce->name));
+ ZVAL_STR(zv, zend_string_copy(ce->name));
}
} else if (op_array && op_array->function_name) {
- ZVAL_STR(zv, STR_COPY(op_array->function_name));
+ ZVAL_STR(zv, zend_string_copy(op_array->function_name));
} else {
ZVAL_EMPTY_STRING(zv);
}
@@ -6396,7 +6396,7 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC)
if (ZEND_CE_IS_TRAIT(ce)) {
return 0;
} else {
- ZVAL_STR(zv, STR_COPY(ce->name));
+ ZVAL_STR(zv, zend_string_copy(ce->name));
}
} else {
ZVAL_EMPTY_STRING(zv);
@@ -6404,14 +6404,14 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC)
break;
case T_TRAIT_C:
if (ce && ZEND_CE_IS_TRAIT(ce)) {
- ZVAL_STR(zv, STR_COPY(ce->name));
+ ZVAL_STR(zv, zend_string_copy(ce->name));
} else {
ZVAL_EMPTY_STRING(zv);
}
break;
case T_NS_C:
if (CG(current_namespace)) {
- ZVAL_STR(zv, STR_COPY(CG(current_namespace)));
+ ZVAL_STR(zv, zend_string_copy(CG(current_namespace)));
} else {
ZVAL_EMPTY_STRING(zv);
}
@@ -6423,7 +6423,7 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC)
}
static inline void zend_ct_eval_binary_op(
- zval *result, zend_uint opcode, zval *op1, zval *op2 TSRMLS_DC
+ zval *result, uint32_t opcode, zval *op1, zval *op2 TSRMLS_DC
) {
binary_op_type fn = get_binary_op(opcode);
fn(result, op1, op2 TSRMLS_CC);
@@ -6448,7 +6448,7 @@ static inline void zend_ct_eval_greater(
static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
/* First ensure that *all* child nodes are constant and by-val */
for (i = 0; i < list->children; ++i) {
@@ -6510,7 +6510,7 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast TSRMLS_DC) {
void zend_compile_binary_op(znode *result, zend_ast *ast TSRMLS_DC) {
zend_ast *left_ast = ast->child[0];
zend_ast *right_ast = ast->child[1];
- zend_uint opcode = ast->attr;
+ uint32_t opcode = ast->attr;
znode left_node, right_node;
zend_compile_expr(&left_node, left_ast TSRMLS_CC);
@@ -6556,7 +6556,7 @@ void zend_compile_greater(znode *result, zend_ast *ast TSRMLS_DC) {
void zend_compile_unary_op(znode *result, zend_ast *ast TSRMLS_DC) {
zend_ast *expr_ast = ast->child[0];
- zend_uint opcode = ast->attr;
+ uint32_t opcode = ast->attr;
znode expr_node;
zend_compile_expr(&expr_node, expr_ast TSRMLS_CC);
@@ -6592,7 +6592,7 @@ void zend_compile_short_circuiting(znode *result, zend_ast *ast TSRMLS_DC) {
znode left_node, right_node;
zend_op *opline_jmpz, *opline_bool;
- zend_uint opnum_jmpz;
+ uint32_t opnum_jmpz;
ZEND_ASSERT(ast->kind == ZEND_AST_AND || ast->kind == ZEND_AST_OR);
@@ -6666,7 +6666,7 @@ static void zend_compile_shorthand_conditional(znode *result, zend_ast *ast TSRM
znode cond_node, false_node;
zend_op *opline_jmp_set, *opline_qm_assign;
- zend_uint opnum_jmp_set;
+ uint32_t opnum_jmp_set;
ZEND_ASSERT(ast->child[1] == NULL);
@@ -6700,7 +6700,7 @@ void zend_compile_conditional(znode *result, zend_ast *ast TSRMLS_DC) {
znode cond_node, true_node, false_node;
zend_op *opline_qm_assign1, *opline_qm_assign2;
- zend_uint opnum_jmpz, opnum_jmp, opnum_qm_assign1;
+ uint32_t opnum_jmpz, opnum_jmp, opnum_qm_assign1;
if (!true_ast) {
zend_compile_shorthand_conditional(result, ast TSRMLS_CC);
@@ -6917,7 +6917,7 @@ void zend_compile_shell_exec(znode *result, zend_ast *ast TSRMLS_DC) {
void zend_compile_array(znode *result, zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
zend_op *opline;
- zend_uint i, opnum_init;
+ uint32_t i, opnum_init;
zend_bool packed = 1;
if (zend_try_ct_eval_array(&result->u.constant, ast TSRMLS_CC)) {
@@ -7040,7 +7040,7 @@ void zend_compile_class_const(znode *result, zend_ast *ast TSRMLS_DC) {
void zend_compile_resolve_class_name(znode *result, zend_ast *ast TSRMLS_DC) {
zend_ast *name_ast = ast->child[0];
- zend_uint fetch_type = zend_get_class_fetch_type(zend_ast_get_str(name_ast));
+ uint32_t fetch_type = zend_get_class_fetch_type(zend_ast_get_str(name_ast));
switch (fetch_type) {
case ZEND_FETCH_CLASS_SELF:
@@ -7049,7 +7049,7 @@ void zend_compile_resolve_class_name(znode *result, zend_ast *ast TSRMLS_DC) {
"Cannot access self::class when no class scope is active");
}
result->op_type = IS_CONST;
- ZVAL_STR(&result->u.constant, STR_COPY(CG(active_class_entry)->name));
+ ZVAL_STR(&result->u.constant, zend_string_copy(CG(active_class_entry)->name));
break;
case ZEND_FETCH_CLASS_STATIC:
case ZEND_FETCH_CLASS_PARENT:
@@ -7081,7 +7081,7 @@ void zend_compile_resolve_class_name(znode *result, zend_ast *ast TSRMLS_DC) {
void zend_compile_encaps_list(znode *result, zend_ast *ast TSRMLS_DC) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
ZEND_ASSERT(list->children > 0);
@@ -7104,14 +7104,14 @@ void zend_compile_encaps_list(znode *result, zend_ast *ast TSRMLS_DC) {
opline->opcode = ZEND_ADD_STRING;
} else if (Z_STRLEN_P(zv) == 1) {
char ch = *Z_STRVAL_P(zv);
- STR_RELEASE(Z_STR_P(zv));
+ zend_string_release(Z_STR_P(zv));
ZVAL_LONG(zv, ch);
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_ADD_CHAR;
} else {
/* String can be empty after a variable at the end of a heredoc */
- STR_RELEASE(Z_STR_P(zv));
+ zend_string_release(Z_STR_P(zv));
continue;
}
} else {
@@ -7142,7 +7142,7 @@ void zend_compile_magic_const(znode *result, zend_ast *ast TSRMLS_DC) {
{
zend_ast *const_ast = zend_ast_create(ZEND_AST_CONST,
- zend_ast_create_zval_from_str(STR_INIT("__CLASS__", sizeof("__CLASS__") - 1, 0)));
+ zend_ast_create_zval_from_str(zend_string_init("__CLASS__", sizeof("__CLASS__") - 1, 0)));
zend_compile_const(result, const_ast TSRMLS_CC);
zend_ast_destroy(const_ast);
}
@@ -7184,7 +7184,7 @@ void zend_compile_const_expr_class_const(zend_ast **ast_ptr TSRMLS_DC) {
if (ZEND_FETCH_CLASS_DEFAULT == fetch_type) {
class_name = zend_resolve_class_name_ast(class_ast TSRMLS_CC);
} else {
- STR_ADDREF(class_name);
+ zend_string_addref(class_name);
}
Z_STR(result) = zend_concat3(
@@ -7197,7 +7197,7 @@ void zend_compile_const_expr_class_const(zend_ast **ast_ptr TSRMLS_DC) {
Z_CONST_FLAGS(result) = fetch_type;
zend_ast_destroy(ast);
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
*ast_ptr = zend_ast_create_zval(&result);
}
@@ -7232,7 +7232,7 @@ void zend_compile_const_expr_const(zend_ast **ast_ptr TSRMLS_DC) {
void zend_compile_const_expr_resolve_class_name(zend_ast **ast_ptr TSRMLS_DC) {
zend_ast *ast = *ast_ptr;
zend_ast *name_ast = ast->child[0];
- zend_uint fetch_type = zend_get_class_fetch_type(zend_ast_get_str(name_ast));
+ uint32_t fetch_type = zend_get_class_fetch_type(zend_ast_get_str(name_ast));
zval result;
switch (fetch_type) {
@@ -7241,7 +7241,7 @@ void zend_compile_const_expr_resolve_class_name(zend_ast **ast_ptr TSRMLS_DC) {
zend_error_noreturn(E_COMPILE_ERROR,
"Cannot access self::class when no class scope is active");
}
- ZVAL_STR(&result, STR_COPY(CG(active_class_entry)->name));
+ ZVAL_STR(&result, zend_string_copy(CG(active_class_entry)->name));
break;
case ZEND_FETCH_CLASS_STATIC:
case ZEND_FETCH_CLASS_PARENT:
@@ -7330,7 +7330,7 @@ void zend_compile_top_stmt(zend_ast *ast TSRMLS_DC) {
if (ast->kind == ZEND_AST_STMT_LIST) {
zend_ast_list *list = zend_ast_get_list(ast);
- zend_uint i;
+ uint32_t i;
for (i = 0; i < list->children; ++i) {
zend_compile_top_stmt(list->child[i] TSRMLS_CC);
}
@@ -7613,7 +7613,7 @@ void zend_compile_var(znode *result, zend_ast *ast, int type TSRMLS_DC) {
}
}
-void zend_delayed_compile_var(znode *result, zend_ast *ast, zend_uint type TSRMLS_DC) {
+void zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t type TSRMLS_DC) {
zend_op *opline;
switch (ast->kind) {
case ZEND_AST_DIM:
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index cecba02661..c45612355a 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -41,7 +41,7 @@
#define RESET_DOC_COMMENT() do { \
if (CG(doc_comment)) { \
- STR_RELEASE(CG(doc_comment)); \
+ zend_string_release(CG(doc_comment)); \
CG(doc_comment) = NULL; \
} \
} while (0)
@@ -50,7 +50,7 @@ typedef struct _zend_op_array zend_op_array;
typedef struct _zend_op zend_op;
typedef struct _zend_compiler_context {
- zend_uint opcodes_size;
+ uint32_t opcodes_size;
int vars_size;
int literals_size;
int current_brk_cont;
@@ -60,11 +60,11 @@ typedef struct _zend_compiler_context {
} zend_compiler_context;
typedef union _znode_op {
- zend_uint constant;
- zend_uint var;
- zend_uint num;
+ uint32_t constant;
+ uint32_t var;
+ uint32_t num;
zend_ulong hash;
- zend_uint opline_num; /* Needs to be signed */
+ uint32_t opline_num; /* Needs to be signed */
zend_op *jmp_addr;
zval *zv;
void *ptr; /* Used for passing pointers from the compile to execution phase, currently used for traits */
@@ -82,7 +82,7 @@ typedef struct _znode { /* used only during compilation */
typedef struct _zend_ast_znode {
zend_ast_kind kind;
zend_ast_attr attr;
- zend_uint lineno;
+ uint32_t lineno;
znode node;
} zend_ast_znode;
ZEND_API zend_ast *zend_ast_create_znode(znode *node);
@@ -120,7 +120,7 @@ struct _zend_op {
znode_op op1;
znode_op op2;
znode_op result;
- ulong extended_value;
+ zend_ulong extended_value;
uint lineno;
zend_uchar opcode;
zend_uchar op1_type;
@@ -138,18 +138,22 @@ typedef struct _zend_brk_cont_element {
typedef struct _zend_label {
int brk_cont;
- zend_uint opline_num;
+ uint32_t opline_num;
} 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;
+ uint32_t try_op;
+ uint32_t catch_op; /* ketchup! */
+ uint32_t finally_op;
+ uint32_t finally_end;
} zend_try_catch_element;
-#if SIZEOF_LONG == 8
-#define THIS_HASHVAL 6385726429UL
+#if SIZEOF_ZEND_INT == 8
+# ifdef _WIN32
+# define THIS_HASHVAL 6385726429Ui64
+# else
+# define THIS_HASHVAL 6385726429ULL
+# endif
#else
#define THIS_HASHVAL 2090759133UL
#endif
@@ -226,13 +230,12 @@ typedef struct _zend_try_catch_element {
#define ZEND_CE_IS_TRAIT(ce) (((ce)->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT)
-char *zend_visibility_string(zend_uint fn_flags);
-
+char *zend_visibility_string(uint32_t fn_flags);
typedef struct _zend_property_info {
- zend_uint flags;
+ uint32_t flags;
zend_string *name;
- ulong h;
+ zend_ulong h;
int offset;
zend_string *doc_comment;
zend_class_entry *ce;
@@ -240,9 +243,9 @@ typedef struct _zend_property_info {
typedef struct _zend_arg_info {
const char *name; // TODO: convert into zend_string ???
- zend_uint name_len;
+ uint32_t name_len;
const char *class_name; // TODO: convert into zend_string ???
- zend_uint class_name_len;
+ uint32_t class_name_len;
zend_uchar type_hint;
zend_uchar pass_by_reference;
zend_bool allow_null;
@@ -255,9 +258,9 @@ typedef struct _zend_arg_info {
*/
typedef struct _zend_internal_function_info {
const char *_name;
- zend_uint _name_len;
+ uint32_t _name_len;
const char *_class_name;
- zend_uint required_num_args;
+ uint32_t required_num_args;
zend_uchar _type_hint;
zend_bool return_reference;
zend_bool _allow_null;
@@ -269,22 +272,22 @@ struct _zend_op_array {
zend_uchar type;
zend_string *function_name;
zend_class_entry *scope;
- zend_uint fn_flags;
+ uint32_t fn_flags;
zend_function *prototype;
- zend_uint num_args;
- zend_uint required_num_args;
+ uint32_t num_args;
+ uint32_t required_num_args;
zend_arg_info *arg_info;
/* END of common elements */
- zend_uint *refcount;
+ uint32_t *refcount;
zend_op *opcodes;
- zend_uint last;
+ uint32_t last;
zend_string **vars;
int last_var;
- zend_uint T;
+ uint32_t T;
zend_brk_cont_element *brk_cont_array;
int last_brk_cont;
@@ -296,13 +299,13 @@ struct _zend_op_array {
/* static variables support */
HashTable *static_variables;
- zend_uint this_var;
+ uint32_t this_var;
zend_string *filename;
- zend_uint line_start;
- zend_uint line_end;
+ uint32_t line_start;
+ uint32_t line_end;
zend_string *doc_comment;
- zend_uint early_binding; /* the linked list of delayed declarations */
+ uint32_t early_binding; /* the linked list of delayed declarations */
zval *literals;
int last_literal;
@@ -322,10 +325,10 @@ typedef struct _zend_internal_function {
zend_uchar type;
zend_string* function_name;
zend_class_entry *scope;
- zend_uint fn_flags;
+ uint32_t fn_flags;
zend_function *prototype;
- zend_uint num_args;
- zend_uint required_num_args;
+ uint32_t num_args;
+ uint32_t required_num_args;
zend_arg_info *arg_info;
/* END of common elements */
@@ -342,10 +345,10 @@ union _zend_function {
zend_uchar type; /* never used */
zend_string *function_name;
zend_class_entry *scope;
- zend_uint fn_flags;
+ uint32_t fn_flags;
union _zend_function *prototype;
- zend_uint num_args;
- zend_uint required_num_args;
+ uint32_t num_args;
+ uint32_t required_num_args;
zend_arg_info *arg_info;
} common;
@@ -371,7 +374,7 @@ struct _zend_execute_data {
zend_execute_data *call; /* current call */
void **run_time_cache;
zend_function *func; /* executed op_array */
- zend_uint num_args;
+ uint32_t num_args;
zend_uchar flags;
zend_uchar frame_kind;
zend_class_entry *called_scope;
@@ -435,7 +438,7 @@ ZEND_API zend_string *zend_get_compiled_filename(TSRMLS_D);
ZEND_API int zend_get_compiled_lineno(TSRMLS_D);
ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D);
-ZEND_API zend_string *zend_get_compiled_variable_name(const zend_op_array *op_array, zend_uint var);
+ZEND_API zend_string *zend_get_compiled_variable_name(const zend_op_array *op_array, uint32_t var);
#ifdef ZTS
const char *zend_get_zendtext(TSRMLS_D);
@@ -451,7 +454,7 @@ ZEND_API binary_op_type get_binary_op(int opcode);
void zend_stop_lexing(TSRMLS_D);
void zend_emit_final_return(zval *zv TSRMLS_DC);
zend_ast *zend_ast_append_str(zend_ast *left, zend_ast *right);
-zend_uint zend_add_member_modifier(zend_uint flags, zend_uint new_flag);
+uint32_t zend_add_member_modifier(uint32_t flags, uint32_t new_flag);
zend_ast_list *zend_ast_append_doc_comment(zend_ast_list *list TSRMLS_DC);
void zend_handle_encoding_declaration(zend_ast_list *declares TSRMLS_DC);
@@ -528,7 +531,7 @@ zend_brk_cont_element *get_next_brk_cont_element(zend_op_array *op_array);
ZEND_API zend_bool zend_is_compiling(TSRMLS_D);
ZEND_API char *zend_make_compiled_string_description(const char *name TSRMLS_DC);
ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers TSRMLS_DC);
-zend_uint zend_get_class_fetch_type(zend_string *name);
+uint32_t zend_get_class_fetch_type(zend_string *name);
typedef zend_bool (*zend_auto_global_callback)(zend_string *name TSRMLS_DC);
typedef struct _zend_auto_global {
diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c
index 64ea7060fa..bca35cf591 100644
--- a/Zend/zend_constants.c
+++ b/Zend/zend_constants.c
@@ -37,7 +37,7 @@ void free_zend_constant(zval *zv)
zval_internal_dtor(&c->value);
}
if (c->name) {
- STR_RELEASE(c->name);
+ zend_string_release(c->name);
}
pefree(c, c->flags & CONST_PERSISTENT);
}
@@ -51,12 +51,12 @@ static void copy_zend_constant(zval *zv)
memcpy(Z_PTR_P(zv), c, sizeof(zend_constant));
c = Z_PTR_P(zv);
- c->name = STR_COPY(c->name);
+ c->name = zend_string_copy(c->name);
if (!(c->flags & CONST_PERSISTENT)) {
zval_copy_ctor(&c->value);
} else {
if (Z_TYPE(c->value) == IS_STRING) {
- Z_STR(c->value) = STR_DUP(Z_STR(c->value), 1);
+ Z_STR(c->value) = zend_string_dup(Z_STR(c->value), 1);
}
}
}
@@ -167,7 +167,7 @@ ZEND_API void zend_register_null_constant(const char *name, uint name_len, int f
ZVAL_NULL(&c.value);
c.flags = flags;
- c.name = STR_INIT(name, name_len, flags & CONST_PERSISTENT);
+ c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT);
c.module_number = module_number;
zend_register_constant(&c TSRMLS_CC);
}
@@ -178,18 +178,18 @@ ZEND_API void zend_register_bool_constant(const char *name, uint name_len, zend_
ZVAL_BOOL(&c.value, bval);
c.flags = flags;
- c.name = STR_INIT(name, name_len, flags & CONST_PERSISTENT);
+ c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT);
c.module_number = module_number;
zend_register_constant(&c TSRMLS_CC);
}
-ZEND_API void zend_register_long_constant(const char *name, uint name_len, long lval, int flags, int module_number TSRMLS_DC)
+ZEND_API void zend_register_long_constant(const char *name, uint name_len, zend_long lval, int flags, int module_number TSRMLS_DC)
{
zend_constant c;
ZVAL_LONG(&c.value, lval);
c.flags = flags;
- c.name = STR_INIT(name, name_len, flags & CONST_PERSISTENT);
+ c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT);
c.module_number = module_number;
zend_register_constant(&c TSRMLS_CC);
}
@@ -201,7 +201,7 @@ ZEND_API void zend_register_double_constant(const char *name, uint name_len, dou
ZVAL_DOUBLE(&c.value, dval);
c.flags = flags;
- c.name = STR_INIT(name, name_len, flags & CONST_PERSISTENT);
+ c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT);
c.module_number = module_number;
zend_register_constant(&c TSRMLS_CC);
}
@@ -211,9 +211,9 @@ ZEND_API void zend_register_stringl_constant(const char *name, uint name_len, ch
{
zend_constant c;
- ZVAL_NEW_STR(&c.value, STR_INIT(strval, strlen, flags & CONST_PERSISTENT));
+ ZVAL_NEW_STR(&c.value, zend_string_init(strval, strlen, flags & CONST_PERSISTENT));
c.flags = flags;
- c.name = STR_INIT(name, name_len, flags & CONST_PERSISTENT);
+ c.name = zend_string_init(name, name_len, flags & CONST_PERSISTENT);
c.module_number = module_number;
zend_register_constant(&c TSRMLS_CC);
}
@@ -240,25 +240,25 @@ static zend_constant *zend_get_special_constant(const char *name, uint name_len
zend_string *const_name;
const_name_len = sizeof("\0__CLASS__") + EG(scope)->name->len;
- const_name = STR_ALLOC(const_name_len, 0);
+ const_name = zend_string_alloc(const_name_len, 0);
memcpy(const_name->val, "\0__CLASS__", sizeof("\0__CLASS__")-1);
zend_str_tolower_copy(const_name->val + sizeof("\0__CLASS__")-1, EG(scope)->name->val, EG(scope)->name->len);
if ((c = zend_hash_find_ptr(EG(zend_constants), const_name)) == NULL) {
c = emalloc(sizeof(zend_constant));
memset(c, 0, sizeof(zend_constant));
- ZVAL_STR(&c->value, STR_COPY(EG(scope)->name));
+ ZVAL_STR(&c->value, zend_string_copy(EG(scope)->name));
zend_hash_add_ptr(EG(zend_constants), const_name, c);
}
- STR_RELEASE(const_name);
+ zend_string_release(const_name);
} else {
- zend_string *const_name = STR_INIT("\0__CLASS__", sizeof("\0__CLASS__")-1, 0);
+ zend_string *const_name = zend_string_init("\0__CLASS__", sizeof("\0__CLASS__")-1, 0);
if ((c = zend_hash_find_ptr(EG(zend_constants), const_name)) == NULL) {
c = emalloc(sizeof(zend_constant));
memset(c, 0, sizeof(zend_constant));
ZVAL_EMPTY_STRING(&c->value);
zend_hash_add_ptr(EG(zend_constants), const_name, c);
}
- STR_RELEASE(const_name);
+ zend_string_release(const_name);
}
return c;
} else if (name_len == sizeof("__COMPILER_HALT_OFFSET__")-1 &&
@@ -273,7 +273,7 @@ static zend_constant *zend_get_special_constant(const char *name, uint name_len
haltname = zend_mangle_property_name(haltoff,
sizeof("__COMPILER_HALT_OFFSET__") - 1, cfilename, clen, 0);
c = zend_hash_find_ptr(EG(zend_constants), haltname);
- STR_FREE(haltname);
+ zend_string_free(haltname);
return c;
} else {
return NULL;
@@ -323,7 +323,7 @@ ZEND_API zval *zend_get_constant(zend_string *name TSRMLS_DC)
return c ? &c->value : NULL;
}
-ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, ulong flags TSRMLS_DC)
+ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, zend_ulong flags TSRMLS_DC)
{
zend_constant *c;
const char *colon;
@@ -343,12 +343,12 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
colon > name && (*(colon - 1) == ':')) {
int class_name_len = colon - name - 1;
int const_name_len = name_len - class_name_len - 2;
- zend_string *constant_name = STR_INIT(colon + 1, const_name_len, 0);
+ zend_string *constant_name = zend_string_init(colon + 1, const_name_len, 0);
char *lcname;
zval *ret_constant = NULL;
ALLOCA_FLAG(use_heap)
- class_name = STR_INIT(name, class_name_len, 0);
+ class_name = zend_string_init(name, class_name_len, 0);
lcname = do_alloca(class_name_len + 1, use_heap);
zend_str_tolower_copy(lcname, name, class_name_len);
if (!scope) {
@@ -396,8 +396,8 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
ret_constant = Z_REFVAL_P(ret_constant);
}
}
- STR_RELEASE(class_name);
- STR_FREE(constant_name);
+ zend_string_release(class_name);
+ zend_string_free(constant_name);
if (ret_constant && Z_CONSTANT_P(ret_constant)) {
zval_update_constant_ex(ret_constant, 1, ce TSRMLS_CC);
}
@@ -449,7 +449,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
}
}
-zend_constant *zend_quick_get_constant(const zval *key, ulong flags TSRMLS_DC)
+zend_constant *zend_quick_get_constant(const zval *key, zend_ulong flags TSRMLS_DC)
{
zend_constant *c;
@@ -501,14 +501,14 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC)
#endif
if (!(c->flags & CONST_CS)) {
- lowercase_name = STR_ALLOC(c->name->len, c->flags & CONST_PERSISTENT);
+ lowercase_name = zend_string_alloc(c->name->len, c->flags & CONST_PERSISTENT);
zend_str_tolower_copy(lowercase_name->val, c->name->val, c->name->len);
lowercase_name = zend_new_interned_string(lowercase_name TSRMLS_CC);
name = lowercase_name;
} else {
char *slash = strrchr(c->name->val, '\\');
if (slash) {
- lowercase_name = STR_INIT(c->name->val, c->name->len, c->flags & CONST_PERSISTENT);
+ lowercase_name = zend_string_init(c->name->val, c->name->len, c->flags & CONST_PERSISTENT);
zend_str_tolower(lowercase_name->val, slash - c->name->val);
lowercase_name = zend_new_interned_string(lowercase_name TSRMLS_CC);
name = lowercase_name;
@@ -527,14 +527,14 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC)
&& memcmp(name->val, "\0__COMPILER_HALT_OFFSET__", sizeof("\0__COMPILER_HALT_OFFSET__")) == 0) {
}
zend_error(E_NOTICE,"Constant %s already defined", name->val);
- STR_RELEASE(c->name);
+ zend_string_release(c->name);
if (!(c->flags & CONST_PERSISTENT)) {
zval_dtor(&c->value);
}
ret = FAILURE;
}
if (lowercase_name) {
- STR_RELEASE(lowercase_name);
+ zend_string_release(lowercase_name);
}
return ret;
}
diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h
index 09a5dac63d..f535632905 100644
--- a/Zend/zend_constants.h
+++ b/Zend/zend_constants.h
@@ -67,16 +67,16 @@ void zend_register_standard_constants(TSRMLS_D);
void clean_non_persistent_constants(TSRMLS_D);
ZEND_API zval *zend_get_constant(zend_string *name TSRMLS_DC);
ZEND_API zval *zend_get_constant_str(const char *name, uint name_len TSRMLS_DC);
-ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, ulong flags TSRMLS_DC);
+ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, zend_ulong flags TSRMLS_DC);
ZEND_API void zend_register_bool_constant(const char *name, uint name_len, zend_bool bval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_null_constant(const char *name, uint name_len, int flags, int module_number TSRMLS_DC);
-ZEND_API void zend_register_long_constant(const char *name, uint name_len, long lval, int flags, int module_number TSRMLS_DC);
+ZEND_API void zend_register_long_constant(const char *name, uint name_len, zend_long lval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_double_constant(const char *name, uint name_len, double dval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_string_constant(const char *name, uint name_len, char *strval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_stringl_constant(const char *name, uint name_len, char *strval, uint strlen, int flags, int module_number TSRMLS_DC);
ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC);
void zend_copy_constants(HashTable *target, HashTable *sourc);
-zend_constant *zend_quick_get_constant(const zval *key, ulong flags TSRMLS_DC);
+zend_constant *zend_quick_get_constant(const zval *key, zend_ulong flags TSRMLS_DC);
END_EXTERN_C()
#define ZEND_CONSTANT_DTOR free_zend_constant
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 754927b577..ff408d0bfd 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -196,7 +196,7 @@ ZEND_METHOD(exception, __clone)
ZEND_METHOD(exception, __construct)
{
zend_string *message = NULL;
- long code = 0;
+ zend_long code = 0;
zval *object, *previous = NULL;
int argc = ZEND_NUM_ARGS();
@@ -225,7 +225,7 @@ ZEND_METHOD(exception, __construct)
ZEND_METHOD(error_exception, __construct)
{
char *message = NULL, *filename = NULL;
- long code = 0, severity = E_ERROR, lineno;
+ zend_long code = 0, severity = E_ERROR, lineno;
zval *object, *previous = NULL;
int argc = ZEND_NUM_ARGS(), message_len, filename_len;
@@ -335,12 +335,12 @@ ZEND_METHOD(error_exception, getSeverity)
/* {{{ gettraceasstring() macros */
#define TRACE_APPEND_CHR(chr) \
- str = STR_REALLOC(str, str->len + 1, 0); \
+ str = zend_string_realloc(str, str->len + 1, 0); \
str->val[str->len - 1] = chr
#define TRACE_APPEND_STRL(v, l) \
{ \
- str = STR_REALLOC(str, str->len + (l), 0); \
+ str = zend_string_realloc(str, str->len + (l), 0); \
memcpy(str->val + str->len - (l), (v), (l)); \
}
@@ -362,7 +362,7 @@ ZEND_METHOD(error_exception, getSeverity)
#define TRACE_ARG_APPEND(vallen) do { \
int len = str->len; \
- str = STR_REALLOC(str, len + vallen, 0); \
+ str = zend_string_realloc(str, len + vallen, 0); \
memmove(str->val + len - l_added + 1 + vallen, str->val + len - l_added + 1, l_added); \
} while (0)
@@ -459,18 +459,18 @@ static void _build_trace_args(zval *arg, zend_string **str_ptr TSRMLS_DC) /* {{{
TRACE_APPEND_STR("true, ");
break;
case IS_RESOURCE: {
- long lval = Z_RES_HANDLE_P(arg);
+ zend_long lval = Z_RES_HANDLE_P(arg);
char s_tmp[MAX_LENGTH_OF_LONG + 1];
- int l_tmp = zend_sprintf(s_tmp, "%ld", lval); /* SAFE */
+ int l_tmp = zend_sprintf(s_tmp, ZEND_LONG_FMT, lval); /* SAFE */
TRACE_APPEND_STR("Resource id #");
TRACE_APPEND_STRL(s_tmp, l_tmp);
TRACE_APPEND_STR(", ");
break;
}
case IS_LONG: {
- long lval = Z_LVAL_P(arg);
+ zend_long lval = Z_LVAL_P(arg);
char s_tmp[MAX_LENGTH_OF_LONG + 1];
- int l_tmp = zend_sprintf(s_tmp, "%ld", lval); /* SAFE */
+ int l_tmp = zend_sprintf(s_tmp, ZEND_LONG_FMT, lval); /* SAFE */
TRACE_APPEND_STRL(s_tmp, l_tmp);
TRACE_APPEND_STR(", ");
break;
@@ -509,7 +509,7 @@ static void _build_trace_args(zval *arg, zend_string **str_ptr TSRMLS_DC) /* {{{
}
/* }}} */
-static void _build_trace_string(zval *frame, ulong index, zend_string **str_ptr, int *num TSRMLS_DC) /* {{{ */
+static void _build_trace_string(zval *frame, zend_ulong index, zend_string **str_ptr, int *num TSRMLS_DC) /* {{{ */
{
char *s_tmp;
int len;
@@ -519,7 +519,7 @@ static void _build_trace_string(zval *frame, ulong index, zend_string **str_ptr,
zend_string *str = *str_ptr;
if (Z_TYPE_P(frame) != IS_ARRAY) {
- zend_error(E_WARNING, "Expected array for frame %lu", index);
+ zend_error(E_WARNING, "Expected array for frame %pu", index);
return;
}
@@ -584,14 +584,14 @@ static void _build_trace_string(zval *frame, ulong index, zend_string **str_ptr,
ZEND_METHOD(exception, getTraceAsString)
{
zval *trace, *frame;
- ulong index;
+ zend_ulong index;
zend_string *str, *key;
int num = 0, len;
char s_tmp[MAX_LENGTH_OF_LONG + 7 + 1 + 1];
DEFAULT_0_PARAMS;
- str = STR_ALLOC(0, 0);
+ str = zend_string_alloc(0, 0);
trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(trace), index, key, frame) {
@@ -665,9 +665,9 @@ ZEND_METHOD(exception, __toString)
_default_exception_get_entry(exception, "file", sizeof("file")-1, &file TSRMLS_CC);
_default_exception_get_entry(exception, "line", sizeof("line")-1, &line TSRMLS_CC);
- convert_to_string(&message);
- convert_to_string(&file);
- convert_to_long(&line);
+ convert_to_string_ex(&message);
+ convert_to_string_ex(&file);
+ convert_to_int_ex(&line);
fci.size = sizeof(fci);
fci.function_table = &Z_OBJCE_P(exception)->function_table;
@@ -697,7 +697,7 @@ ZEND_METHOD(exception, __toString)
(Z_TYPE(trace) == IS_STRING && Z_STRLEN(trace)) ? Z_STRVAL(trace) : "#0 {main}\n",
prev_str->len ? "\n\nNext " : "", prev_str->val);
}
- STR_RELEASE(prev_str);
+ zend_string_release(prev_str);
zval_dtor(&message);
zval_dtor(&file);
zval_dtor(&line);
@@ -894,7 +894,7 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity TSRMLS_DC) /* {
file = zend_read_property(default_exception_ce, &zv, "file", sizeof("file")-1, 1 TSRMLS_CC);
line = zend_read_property(default_exception_ce, &zv, "line", sizeof("line")-1, 1 TSRMLS_CC);
- convert_to_string(file);
+ convert_to_string_ex(file);
file = (Z_STRLEN_P(file) > 0) ? file : NULL;
line = (Z_TYPE_P(line) == IS_LONG) ? line : NULL;
} else {
@@ -908,9 +908,9 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity TSRMLS_DC) /* {
file = zend_read_property(default_exception_ce, &exception, "file", sizeof("file")-1, 1 TSRMLS_CC);
line = zend_read_property(default_exception_ce, &exception, "line", sizeof("line")-1, 1 TSRMLS_CC);
- convert_to_string(str);
- convert_to_string(file);
- convert_to_long(line);
+ convert_to_string_ex(str);
+ convert_to_string_ex(file);
+ convert_to_int_ex(line);
zend_error_va(severity, (Z_STRLEN_P(file) > 0) ? Z_STRVAL_P(file) : NULL, Z_LVAL_P(line), "Uncaught %s\n thrown", Z_STRVAL_P(str));
} else {
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index f3e97d71d0..8ae445284a 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -149,12 +149,12 @@ static const zend_internal_function zend_pass_function = {
#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)
+ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data, uint32_t var)
{
return EX_VAR(var);
}
-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)
+static zend_always_inline zval *_get_zval_ptr_tmp(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
{
zval *ret = EX_VAR(var);
should_free->var = ret;
@@ -164,7 +164,7 @@ static zend_always_inline zval *_get_zval_ptr_tmp(zend_uint var, const zend_exec
return ret;
}
-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)
+static zend_always_inline zval *_get_zval_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -172,7 +172,7 @@ static zend_always_inline zval *_get_zval_ptr_var(zend_uint var, const zend_exec
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_var_deref(zend_uint var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_var_deref(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -181,7 +181,7 @@ static zend_always_inline zval *_get_zval_ptr_var_deref(zend_uint var, const zen
return ret;
}
-static zend_never_inline zval *_get_zval_cv_lookup(zval *ptr, zend_uint var, int type, const zend_execute_data *execute_data TSRMLS_DC)
+static zend_never_inline zval *_get_zval_cv_lookup(zval *ptr, uint32_t var, int type, const zend_execute_data *execute_data TSRMLS_DC)
{
zend_string *cv;
@@ -205,7 +205,7 @@ static zend_never_inline zval *_get_zval_cv_lookup(zval *ptr, zend_uint var, int
return ptr;
}
-static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_R(zval *ptr, zend_uint var, const zend_execute_data *execute_data TSRMLS_DC)
+static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_R(zval *ptr, uint32_t var, const zend_execute_data *execute_data TSRMLS_DC)
{
zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
@@ -213,7 +213,7 @@ static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_R(zval *ptr, zend_uin
return &EG(uninitialized_zval);
}
-static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_UNSET(zval *ptr, zend_uint var, const zend_execute_data *execute_data TSRMLS_DC)
+static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_UNSET(zval *ptr, uint32_t var, const zend_execute_data *execute_data TSRMLS_DC)
{
zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
@@ -221,12 +221,12 @@ static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_UNSET(zval *ptr, zend
return &EG(uninitialized_zval);
}
-static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_IS(zval *ptr, zend_uint var, const zend_execute_data *execute_data TSRMLS_DC)
+static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_IS(zval *ptr, uint32_t var, const zend_execute_data *execute_data TSRMLS_DC)
{
return &EG(uninitialized_zval);
}
-static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_RW(zval *ptr, zend_uint var, const zend_execute_data *execute_data TSRMLS_DC)
+static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_RW(zval *ptr, uint32_t var, const zend_execute_data *execute_data TSRMLS_DC)
{
zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
@@ -235,13 +235,13 @@ static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_RW(zval *ptr, zend_ui
return ptr;
}
-static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_W(zval *ptr, zend_uint var, const zend_execute_data *execute_data TSRMLS_DC)
+static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_W(zval *ptr, uint32_t var, const zend_execute_data *execute_data TSRMLS_DC)
{
ZVAL_NULL(ptr);
return ptr;
}
-static zend_always_inline zval *_get_zval_ptr_cv(const zend_execute_data *execute_data, zend_uint var, int type TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv(const zend_execute_data *execute_data, uint32_t var, int type TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -251,7 +251,7 @@ static zend_always_inline zval *_get_zval_ptr_cv(const zend_execute_data *execut
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_cv_deref(const zend_execute_data *execute_data, zend_uint var, int type TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_deref(const zend_execute_data *execute_data, uint32_t var, int type TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -262,7 +262,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref(const zend_execute_data *
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -272,7 +272,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(const zend_execute_dat
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_R(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_R(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -283,7 +283,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_R(const zend_execu
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -293,7 +293,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(const zend_execute
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_UNSET(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_UNSET(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -304,7 +304,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_UNSET(const zend_e
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -314,7 +314,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(const zend_execute_da
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_IS(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_IS(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -325,7 +325,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_IS(const zend_exec
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -335,7 +335,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(const zend_execute_da
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_RW(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -346,7 +346,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_RW(const zend_exec
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -356,12 +356,12 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(const zend_execute_dat
return ret;
}
-static zend_always_inline zval *_get_zval_ptr_cv_undef_BP_VAR_W(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_undef_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC)
{
return EX_VAR(var);
}
-static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_W(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
+static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -432,7 +432,7 @@ static inline zval *_get_zval_ptr_deref(int op_type, const znode_op *node, const
return NULL;
}
-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)
+static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
{
zval *ret = EX_VAR(var);
@@ -525,7 +525,7 @@ static inline zval* make_real_object(zval *object_ptr TSRMLS_DC)
return object;
}
-ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, ulong fetch_type, char **class_name, zend_class_entry **pce TSRMLS_DC)
+ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, zend_ulong fetch_type, char **class_name, zend_class_entry **pce TSRMLS_DC)
{
zend_string *key;
ALLOCA_FLAG(use_heap);
@@ -542,7 +542,7 @@ ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, ul
}
}
-ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, zend_uint arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind, zval *arg TSRMLS_DC)
+ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, uint32_t arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind, zval *arg TSRMLS_DC)
{
zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data;
const char *fname = zf->common.function_name->val;
@@ -574,7 +574,7 @@ ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, zen
}
}
-static void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zval *arg, ulong fetch_type TSRMLS_DC)
+static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, zend_ulong fetch_type TSRMLS_DC)
{
zend_arg_info *cur_arg_info;
char *need_msg;
@@ -623,7 +623,7 @@ static void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zval *arg
}
}
-static inline int zend_verify_missing_arg_type(zend_function *zf, zend_uint arg_num, ulong fetch_type TSRMLS_DC)
+static inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_num, zend_ulong fetch_type TSRMLS_DC)
{
zend_arg_info *cur_arg_info;
char *need_msg;
@@ -660,7 +660,7 @@ static inline int zend_verify_missing_arg_type(zend_function *zf, zend_uint arg_
return 0;
}
-static void zend_verify_missing_arg(zend_execute_data *execute_data, zend_uint arg_num TSRMLS_DC)
+static void zend_verify_missing_arg(zend_execute_data *execute_data, uint32_t arg_num TSRMLS_DC)
{
if (EXPECTED(!(EX(func)->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) ||
zend_verify_missing_arg_type(EX(func), arg_num, EX(opline)->extended_value TSRMLS_CC)) {
@@ -768,12 +768,12 @@ static inline void zend_assign_to_object(zval *retval, zval *object_ptr, zval *p
static void zend_assign_to_string_offset(zval *str_offset, zval *value, int value_type, zval *result TSRMLS_DC)
{
zval *str = Z_STR_OFFSET_STR_P(str_offset);
- zend_uint offset = Z_STR_OFFSET_IDX_P(str_offset);
+ uint32_t offset = Z_STR_OFFSET_IDX_P(str_offset);
zend_string *old_str;
if ((int)offset < 0) {
zend_error(E_WARNING, "Illegal string offset: %d", offset);
- STR_RELEASE(Z_STR_P(str));
+ zend_string_release(Z_STR_P(str));
if (result) {
ZVAL_NULL(result);
}
@@ -783,12 +783,12 @@ static void zend_assign_to_string_offset(zval *str_offset, zval *value, int valu
old_str = Z_STR_P(str);
if (offset >= Z_STRLEN_P(str)) {
int old_len = Z_STRLEN_P(str);
- Z_STR_P(str) = STR_REALLOC(Z_STR_P(str), offset + 1, 0);
+ Z_STR_P(str) = zend_string_realloc(Z_STR_P(str), offset + 1, 0);
Z_TYPE_INFO_P(str) = IS_STRING_EX;
memset(Z_STRVAL_P(str) + old_len, ' ', offset - old_len);
Z_STRVAL_P(str)[offset+1] = 0;
} else if (IS_INTERNED(Z_STR_P(str))) {
- Z_STR_P(str) = STR_INIT(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
+ Z_STR_P(str) = zend_string_init(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
Z_TYPE_INFO_P(str) = IS_STRING_EX;
}
@@ -796,7 +796,7 @@ static void zend_assign_to_string_offset(zval *str_offset, zval *value, int valu
zend_string *tmp = zval_get_string(value);
Z_STRVAL_P(str)[offset] = tmp->val[0];
- STR_RELEASE(tmp);
+ zend_string_release(tmp);
} else {
Z_STRVAL_P(str)[offset] = Z_STRVAL_P(value)[0];
if (value_type == IS_TMP_VAR) {
@@ -811,14 +811,14 @@ static void zend_assign_to_string_offset(zval *str_offset, zval *value, int valu
T(result->u.var).var = &T->str_offset.str;
*/
- STR_RELEASE(old_str);
+ zend_string_release(old_str);
if (result) {
zend_uchar c = (zend_uchar)Z_STRVAL_P(str)[offset];
if (CG(one_char_string)[c]) {
- ZVAL_INT_STR(result, CG(one_char_string)[c]);
+ ZVAL_INTERNED_STR(result, CG(one_char_string)[c]);
} else {
- ZVAL_NEW_STR(result, STR_INIT(Z_STRVAL_P(str) + offset, 1, 0));
+ ZVAL_NEW_STR(result, zend_string_init(Z_STRVAL_P(str) + offset, 1, 0));
}
}
}
@@ -1015,7 +1015,7 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht
{
zval *retval;
zend_string *offset_key;
- ulong hval;
+ zend_ulong hval;
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
hval = Z_LVAL_P(dim);
@@ -1024,14 +1024,14 @@ num_index:
if (retval == NULL) {
switch (type) {
case BP_VAR_R:
- zend_error(E_NOTICE,"Undefined offset: %ld", hval);
+ zend_error(E_NOTICE,"Undefined offset: " ZEND_ULONG_FMT, hval);
/* break missing intentionally */
case BP_VAR_UNSET:
case BP_VAR_IS:
retval = &EG(uninitialized_zval);
break;
case BP_VAR_RW:
- zend_error(E_NOTICE,"Undefined offset: %ld", hval);
+ zend_error(E_NOTICE,"Undefined offset: " ZEND_ULONG_FMT, hval);
/* break missing intentionally */
case BP_VAR_W:
retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval));
@@ -1095,7 +1095,7 @@ str_index:
hval = zend_dval_to_lval(Z_DVAL_P(dim));
goto num_index;
case IS_RESOURCE:
- zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
+ zend_error(E_STRICT, "Resource ID#%pd used as offset, casting to integer (%pd)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
hval = Z_RES_HANDLE_P(dim);
goto num_index;
case IS_FALSE:
@@ -1139,7 +1139,7 @@ fetch_from_array:
ZVAL_INDIRECT(result, retval);
}
} else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
- long offset;
+ zend_long offset;
if (type != BP_VAR_UNSET && UNEXPECTED(Z_STRLEN_P(container) == 0)) {
zval_dtor(container);
@@ -1182,7 +1182,7 @@ convert_to_array:
offset = Z_LVAL_P(dim);
}
- if (!IS_INTERNED(Z_STR_P(container))) STR_ADDREF(Z_STR_P(container));
+ if (!IS_INTERNED(Z_STR_P(container))) zend_string_addref(Z_STR_P(container));
ZVAL_STR_OFFSET(result, container, offset);
} else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
if (!Z_OBJ_HT_P(container)->read_dimension) {
@@ -1279,7 +1279,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type TSRMLS_CC);
ZVAL_COPY(result, retval);
} else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
- long offset;
+ zend_long offset;
if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
switch(Z_TYPE_P(dim)) {
@@ -1319,9 +1319,9 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
zend_uchar c = (zend_uchar)Z_STRVAL_P(container)[offset];
if (CG(one_char_string)[c]) {
- ZVAL_INT_STR(result, CG(one_char_string)[c]);
+ ZVAL_INTERNED_STR(result, CG(one_char_string)[c]);
} else {
- ZVAL_NEW_STR(result, STR_INIT(Z_STRVAL_P(container) + offset, 1, 0));
+ ZVAL_NEW_STR(result, zend_string_init(Z_STRVAL_P(container) + offset, 1, 0));
}
}
} else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
@@ -1552,7 +1552,7 @@ void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC) /*
static zend_always_inline void i_init_func_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value, vm_frame_kind frame_kind TSRMLS_DC) /* {{{ */
{
- zend_uint first_extra_arg;
+ uint32_t first_extra_arg;
ZEND_ASSERT(EX(func) == (zend_function*)op_array);
ZEND_ASSERT(EX(object) == Z_OBJ(EG(This)));
@@ -1660,7 +1660,7 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da
if (UNEXPECTED(EX(symbol_table) != NULL)) {
zend_attach_symbol_table(execute_data);
} else {
- zend_uint first_extra_arg = op_array->num_args;
+ uint32_t first_extra_arg = op_array->num_args;
if (UNEXPECTED((op_array->fn_flags & ZEND_ACC_VARIADIC) != 0)) {
first_extra_arg--;
@@ -1718,7 +1718,7 @@ ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data
* restore it simply by replacing a pointer.
*/
zend_execute_data *execute_data;
- zend_uint num_args = call->num_args;
+ uint32_t num_args = call->num_args;
EG(argument_stack) = zend_vm_stack_new_page(
MAX(ZEND_VM_STACK_PAGE_SIZE,
@@ -1762,12 +1762,12 @@ ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_ar
static zend_always_inline zend_bool zend_is_by_ref_func_arg_fetch(zend_op *opline, zend_execute_data *call TSRMLS_DC) /* {{{ */
{
- zend_uint arg_num = opline->extended_value & ZEND_FETCH_ARG_MASK;
+ uint32_t arg_num = opline->extended_value & ZEND_FETCH_ARG_MASK;
return ARG_SHOULD_BE_SENT_BY_REF(call->func, arg_num);
}
/* }}} */
-static zend_execute_data *zend_vm_stack_copy_call_frame(zend_execute_data *call, zend_uint passed_args, zend_uint additional_args TSRMLS_DC) /* {{{ */
+static zend_execute_data *zend_vm_stack_copy_call_frame(zend_execute_data *call, uint32_t passed_args, uint32_t additional_args TSRMLS_DC) /* {{{ */
{
zend_execute_data *new_call;
int used_stack = (EG(argument_stack)->top - (zval*)call) + additional_args;
@@ -1803,7 +1803,7 @@ static zend_execute_data *zend_vm_stack_copy_call_frame(zend_execute_data *call,
}
/* }}} */
-static zend_always_inline void zend_vm_stack_extend_call_frame(zend_execute_data **call, zend_uint passed_args, zend_uint additional_args TSRMLS_DC) /* {{{ */
+static zend_always_inline void zend_vm_stack_extend_call_frame(zend_execute_data **call, uint32_t passed_args, uint32_t additional_args TSRMLS_DC) /* {{{ */
{
if (EXPECTED(EG(argument_stack)->end - EG(argument_stack)->top > additional_args)) {
EG(argument_stack)->top += additional_args;
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index cb7ca70ef3..ae777cdafe 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -48,8 +48,8 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s
ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
ZEND_API int zend_eval_stringl_ex(char *str, int str_len, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
-ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, ulong fetch_type, char **class_name, zend_class_entry **pce TSRMLS_DC);
-ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, zend_uint arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind, zval *arg TSRMLS_DC);
+ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, zend_ulong fetch_type, char **class_name, zend_class_entry **pce TSRMLS_DC);
+ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, uint32_t arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind, zval *arg TSRMLS_DC);
static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC)
{
@@ -208,7 +208,7 @@ static zend_always_inline void zend_vm_stack_extend(int count TSRMLS_DC)
EG(argument_stack) = p;
}
-static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(zend_function *func, zend_uint num_args, zend_uchar flags, zend_class_entry *called_scope, zend_object *object, zend_execute_data *prev TSRMLS_DC)
+static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(zend_function *func, uint32_t num_args, zend_uchar flags, zend_class_entry *called_scope, zend_object *object, zend_execute_data *prev TSRMLS_DC)
{
int used_stack = ZEND_CALL_FRAME_SLOT + num_args;
zend_execute_data *call;
@@ -230,7 +230,7 @@ static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(zend_
static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *call TSRMLS_DC)
{
- zend_uint first_extra_arg = call->func->op_array.num_args - ((call->func->common.fn_flags & ZEND_ACC_VARIADIC) != 0);
+ uint32_t first_extra_arg = call->func->op_array.num_args - ((call->func->common.fn_flags & ZEND_ACC_VARIADIC) != 0);
if (UNEXPECTED(call->num_args > first_extra_arg)) {
zval *end = EX_VAR_NUM_2(call, call->func->op_array.last_var + call->func->op_array.T);
@@ -244,7 +244,7 @@ static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *
static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call TSRMLS_DC)
{
- zend_uint num_args = call->num_args;
+ uint32_t num_args = call->num_args;
if (num_args > 0) {
zval *end = ZEND_CALL_ARG(call, 1);
@@ -279,7 +279,7 @@ ZEND_API const char *zend_get_executed_filename(TSRMLS_D);
ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
ZEND_API zend_bool zend_is_executing(TSRMLS_D);
-ZEND_API void zend_set_timeout(long seconds, int reset_signals);
+ZEND_API void zend_set_timeout(zend_long seconds, int reset_signals);
ZEND_API void zend_unset_timeout(TSRMLS_D);
ZEND_API void zend_timeout(int dummy);
ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type TSRMLS_DC);
@@ -300,7 +300,7 @@ void zend_shutdown_timeout_thread(void);
*/
#define Z_OBJ_CLASS_NAME_P(obj) (((obj) && (obj)->handlers->get_class_entry != NULL && (obj)->handlers->get_class_entry) ? (obj)->handlers->get_class_entry(obj TSRMLS_CC)->name->val : "")
-ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, zend_uint var);
+ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, uint32_t var);
#define ZEND_USER_OPCODE_CONTINUE 0 /* execute next opcode */
#define ZEND_USER_OPCODE_RETURN 1 /* exit from executor (return from function) */
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index a8ff27bda8..461225da99 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -537,11 +537,11 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
zend_error(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(p));
len = Z_STRLEN_P(p) - ((colon - Z_STRVAL_P(p)) + 1);
if (inline_change) {
- zend_string *tmp = STR_INIT(colon + 1, len, 0);
- STR_RELEASE(Z_STR_P(p));
+ zend_string *tmp = zend_string_init(colon + 1, len, 0);
+ zend_string_release(Z_STR_P(p));
Z_STR_P(p) = tmp;
} else {
- Z_STR_P(p) = STR_INIT(colon + 1, len, 0);
+ Z_STR_P(p) = zend_string_init(colon + 1, len, 0);
}
Z_TYPE_FLAGS_P(p) = IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE;
} else {
@@ -552,7 +552,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
actual = slash + 1;
actual_len -= (actual - Z_STRVAL_P(p));
if (inline_change) {
- zend_string *s = STR_INIT(actual, actual_len, 0);
+ zend_string *s = zend_string_init(actual, actual_len, 0);
Z_STR_P(p) = s;
Z_TYPE_FLAGS_P(p) = IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE;
}
@@ -573,7 +573,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
zend_error(E_ERROR, "Undefined constant '%s'", save->val);
}
if (inline_change) {
- STR_RELEASE(save);
+ zend_string_release(save);
}
save = NULL;
}
@@ -584,13 +584,13 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
Z_TYPE_INFO_P(p) = IS_INTERNED(Z_STR_P(p)) ?
IS_INTERNED_STRING_EX : IS_STRING_EX;
if (save && save->val != actual) {
- STR_RELEASE(save);
+ zend_string_release(save);
}
}
}
} else {
if (inline_change) {
- STR_RELEASE(Z_STR_P(p));
+ zend_string_release(Z_STR_P(p));
}
ZVAL_COPY_VALUE(p, const_value);
if (Z_OPT_CONSTANT_P(p)) {
@@ -633,13 +633,13 @@ ZEND_API int zval_update_constant(zval *pp, zend_bool inline_change TSRMLS_DC) /
}
/* }}} */
-int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, zend_uint param_count, zval params[] TSRMLS_DC) /* {{{ */
+int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[] TSRMLS_DC) /* {{{ */
{
return call_user_function_ex(function_table, object, function_name, retval_ptr, param_count, params, 1, NULL TSRMLS_CC);
}
/* }}} */
-int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, zend_uint param_count, zval params[], int no_separation, zend_array *symbol_table TSRMLS_DC) /* {{{ */
+int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation, zend_array *symbol_table TSRMLS_DC) /* {{{ */
{
zend_fcall_info fci;
@@ -659,7 +659,7 @@ int call_user_function_ex(HashTable *function_table, zval *object, zval *functio
int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC) /* {{{ */
{
- zend_uint i;
+ uint32_t i;
zend_class_entry *calling_scope = NULL;
zend_execute_data *call, dummy_execute_data;
zend_fcall_info_cache fci_cache_local;
@@ -724,7 +724,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
efree(error);
}
if (callable_name) {
- STR_RELEASE(callable_name);
+ zend_string_release(callable_name);
}
if (EG(current_execute_data) == &dummy_execute_data) {
EG(current_execute_data) = dummy_execute_data.prev_execute_data;
@@ -738,7 +738,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
zend_error(E_STRICT, "%s", error);
efree(error);
}
- STR_RELEASE(callable_name);
+ zend_string_release(callable_name);
}
func = fci_cache->function_handler;
@@ -903,7 +903,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
zend_vm_stack_free_call_frame(call TSRMLS_CC);
if (func->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
- STR_RELEASE(func->common.function_name);
+ zend_string_release(func->common.function_name);
}
efree(func);
@@ -948,10 +948,10 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
}
if (name->val[0] == '\\') {
- lc_name = STR_ALLOC(name->len - 1, 0);
+ lc_name = zend_string_alloc(name->len - 1, 0);
zend_str_tolower_copy(lc_name->val, name->val + 1, name->len - 1);
} else {
- lc_name = STR_ALLOC(name->len, 0);
+ lc_name = zend_string_alloc(name->len, 0);
zend_str_tolower_copy(lc_name->val, name->val, name->len);
}
}
@@ -959,7 +959,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
ce = zend_hash_find_ptr(EG(class_table), lc_name);
if (ce) {
if (!key) {
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
}
return ce;
}
@@ -969,7 +969,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
*/
if (!use_autoload || zend_is_compiling(TSRMLS_C)) {
if (!key) {
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
}
return NULL;
}
@@ -980,7 +980,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
EG(autoload_func) = func;
} else {
if (!key) {
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
}
return NULL;
}
@@ -990,7 +990,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
/* Verify class name before passing it to __autoload() */
if (strspn(name->val, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\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\\") != name->len) {
if (!key) {
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
}
return NULL;
}
@@ -1002,7 +1002,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
if (zend_hash_add_empty_element(EG(in_autoload), lc_name) == NULL) {
if (!key) {
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
}
return NULL;
}
@@ -1012,12 +1012,12 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
if (name->val[0] == '\\') {
ZVAL_STRINGL(&args[0], name->val + 1, name->len - 1);
} else {
- ZVAL_STR(&args[0], STR_COPY(name));
+ ZVAL_STR(&args[0], zend_string_copy(name));
}
fcall_info.size = sizeof(fcall_info);
fcall_info.function_table = EG(function_table);
- ZVAL_STR(&fcall_info.function_name, STR_COPY(EG(autoload_func)->common.function_name));
+ ZVAL_STR(&fcall_info.function_name, zend_string_copy(EG(autoload_func)->common.function_name));
fcall_info.symbol_table = NULL;
fcall_info.retval = &local_retval;
fcall_info.param_count = 1;
@@ -1046,7 +1046,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
ce = zend_hash_find_ptr(EG(class_table), lc_name);
}
if (!key) {
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
}
return ce;
}
@@ -1062,11 +1062,11 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s
{
zval pv;
zend_op_array *new_op_array;
- zend_uint original_compiler_options;
+ uint32_t original_compiler_options;
int retval;
if (retval_ptr) {
- ZVAL_NEW_STR(&pv, STR_ALLOC(str_len + sizeof("return ;")-1, 1));
+ ZVAL_NEW_STR(&pv, zend_string_alloc(str_len + sizeof("return ;")-1, 1));
memcpy(Z_STRVAL(pv), "return ", sizeof("return ") - 1);
memcpy(Z_STRVAL(pv) + sizeof("return ") - 1, str, str_len);
Z_STRVAL(pv)[Z_STRLEN(pv) - 1] = ';';
@@ -1360,7 +1360,7 @@ void zend_shutdown_timeout_thread(void) /* {{{ */
#define SIGPROF 27
#endif
-void zend_set_timeout(long seconds, int reset_signals) /* {{{ */
+void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */
{
TSRMLS_FETCH();
@@ -1584,7 +1584,7 @@ ZEND_API int zend_delete_global_variable(zend_string *name TSRMLS_DC) /* {{{ */
ZEND_API zend_array *zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */
{
- zend_uint i;
+ uint32_t i;
zend_execute_data *ex;
zend_array *symbol_table;
@@ -1680,7 +1680,7 @@ ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force TSRMLS
if (execute_data) {
if (!execute_data->symbol_table) {
- zend_ulong h = STR_HASH_VAL(name);
+ zend_ulong h = zend_string_hash_val(name);
zend_op_array *op_array = &execute_data->func->op_array;
int i;
diff --git a/Zend/zend_gc.h b/Zend/zend_gc.h
index 8d619f2e5e..84b7ef3208 100644
--- a/Zend/zend_gc.h
+++ b/Zend/zend_gc.h
@@ -77,7 +77,7 @@ typedef struct _gc_root_buffer {
zend_refcounted *ref;
struct _gc_root_buffer *next; /* double-linked list */
struct _gc_root_buffer *prev;
- zend_uint refcount;
+ uint32_t refcount;
} gc_root_buffer;
typedef struct _zend_gc_globals {
@@ -93,16 +93,16 @@ typedef struct _zend_gc_globals {
gc_root_buffer to_free; /* list to free */
gc_root_buffer *next_to_free;
- zend_uint gc_runs;
- zend_uint collected;
+ uint32_t gc_runs;
+ uint32_t collected;
#if GC_BENCH
- zend_uint root_buf_length;
- zend_uint root_buf_peak;
- zend_uint zval_possible_root;
- zend_uint zval_buffered;
- zend_uint zval_remove_from_buffer;
- zend_uint zval_marked_grey;
+ uint32_t root_buf_length;
+ uint32_t root_buf_peak;
+ uint32_t zval_possible_root;
+ uint32_t zval_buffered;
+ uint32_t zval_remove_from_buffer;
+ uint32_t zval_marked_grey;
#endif
} zend_gc_globals;
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index 922c6a3f2b..a2497cf16f 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -44,7 +44,7 @@ static void zend_generator_cleanup_unfinished_execution(zend_generator *generato
{
/* -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;
+ uint32_t op_num = execute_data->opline - op_array->opcodes - 1;
int i;
for (i = 0; i < op_array->last_brk_cont; ++i) {
@@ -143,7 +143,7 @@ static void zend_generator_dtor_storage(zend_object *object TSRMLS_DC) /* {{{ */
{
zend_generator *generator = (zend_generator*) object;
zend_execute_data *ex = generator->execute_data;
- zend_uint op_num, finally_op_num;
+ uint32_t op_num, finally_op_num;
int i;
if (!ex || !ex->func->op_array.has_finally_block) {
diff --git a/Zend/zend_generators.h b/Zend/zend_generators.h
index 5d1264cc4f..a85b8dd976 100644
--- a/Zend/zend_generators.h
+++ b/Zend/zend_generators.h
@@ -43,7 +43,7 @@ typedef struct _zend_generator {
/* Variable to put sent value into */
zval *send_target;
/* Largest used integer key for auto-incrementing keys */
- long largest_used_integer_key;
+ zend_long largest_used_integer_key;
/* ZEND_GENERATOR_* flags */
zend_uchar flags;
diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h
index c27d7bc717..c4a24486d9 100644
--- a/Zend/zend_globals.h
+++ b/Zend/zend_globals.h
@@ -106,14 +106,14 @@ struct _zend_compiler_globals {
int interactive;
- zend_uint start_lineno;
+ uint32_t start_lineno;
zend_bool increment_lineno;
znode implementing_class;
zend_string *doc_comment;
- zend_uint compiler_options; /* set of ZEND_COMPILE_* constants */
+ uint32_t compiler_options; /* set of ZEND_COMPILE_* constants */
zend_string *current_namespace;
HashTable *current_import;
@@ -179,7 +179,7 @@ struct _zend_executor_globals {
zval This;
- long precision;
+ zend_long precision;
int ticks_count;
@@ -211,7 +211,7 @@ struct _zend_executor_globals {
zend_class_entry *exception_class;
/* timeout support */
- int timeout_seconds;
+ zend_long timeout_seconds;
int lambda_count;
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index 78b38f7ea2..9dd5a4188d 100644
--- a/Zend/zend_hash.c
+++ b/Zend/zend_hash.c
@@ -87,15 +87,15 @@ static void zend_hash_do_resize(HashTable *ht);
(ht)->arData = (Bucket *) safe_pemalloc((ht)->nTableSize, sizeof(Bucket), 0, (ht)->u.flags & HASH_FLAG_PERSISTENT); \
(ht)->u.flags |= HASH_FLAG_PACKED; \
} else { \
- (ht)->arData = (Bucket *) safe_pemalloc((ht)->nTableSize, sizeof(Bucket) + sizeof(zend_uint), 0, (ht)->u.flags & HASH_FLAG_PERSISTENT); \
- (ht)->arHash = (zend_uint*)((ht)->arData + (ht)->nTableSize); \
- memset((ht)->arHash, INVALID_IDX, (ht)->nTableSize * sizeof(zend_uint)); \
+ (ht)->arData = (Bucket *) safe_pemalloc((ht)->nTableSize, sizeof(Bucket) + sizeof(uint32_t), 0, (ht)->u.flags & HASH_FLAG_PERSISTENT); \
+ (ht)->arHash = (uint32_t*)((ht)->arData + (ht)->nTableSize); \
+ memset((ht)->arHash, INVALID_IDX, (ht)->nTableSize * sizeof(uint32_t)); \
} \
(ht)->nTableMask = (ht)->nTableSize - 1; \
} \
} while (0)
-static const zend_uint uninitialized_bucket = {INVALID_IDX};
+static const uint32_t uninitialized_bucket = {INVALID_IDX};
ZEND_API void _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)
{
@@ -118,7 +118,7 @@ ZEND_API void _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor
ht->nNumOfElements = 0;
ht->nNextFreeElement = 0;
ht->arData = NULL;
- ht->arHash = (zend_uint*)&uninitialized_bucket;
+ ht->arHash = (uint32_t*)&uninitialized_bucket;
ht->pDestructor = pDestructor;
ht->nInternalPointer = INVALID_IDX;
if (persistent) {
@@ -148,8 +148,8 @@ ZEND_API void zend_hash_packed_to_hash(HashTable *ht)
{
HANDLE_BLOCK_INTERRUPTIONS();
ht->u.flags &= ~HASH_FLAG_PACKED;
- ht->arData = (Bucket *) safe_perealloc(ht->arData, ht->nTableSize, sizeof(Bucket) + sizeof(zend_uint), 0, ht->u.flags & HASH_FLAG_PERSISTENT);
- ht->arHash = (zend_uint*)(ht->arData + ht->nTableSize);
+ ht->arData = (Bucket *) safe_perealloc(ht->arData, ht->nTableSize, sizeof(Bucket) + sizeof(uint32_t), 0, ht->u.flags & HASH_FLAG_PERSISTENT);
+ ht->arHash = (uint32_t*)(ht->arData + ht->nTableSize);
zend_hash_rehash(ht);
HANDLE_UNBLOCK_INTERRUPTIONS();
}
@@ -159,7 +159,7 @@ ZEND_API void zend_hash_to_packed(HashTable *ht)
HANDLE_BLOCK_INTERRUPTIONS();
ht->u.flags |= HASH_FLAG_PACKED;
ht->arData = erealloc(ht->arData, ht->nTableSize * sizeof(Bucket));
- ht->arHash = (zend_uint*)&uninitialized_bucket;
+ ht->arHash = (uint32_t*)&uninitialized_bucket;
HANDLE_UNBLOCK_INTERRUPTIONS();
}
@@ -183,12 +183,12 @@ ZEND_API void zend_hash_set_apply_protection(HashTable *ht, zend_bool bApplyProt
static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, zend_string *key)
{
- ulong h;
+ zend_ulong h;
uint nIndex;
uint idx;
Bucket *p;
- h = STR_HASH_VAL(key);
+ h = zend_string_hash_val(key);
nIndex = h & ht->nTableMask;
idx = ht->arHash[nIndex];
while (idx != INVALID_IDX) {
@@ -205,7 +205,7 @@ static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, zen
return NULL;
}
-static zend_always_inline Bucket *zend_hash_str_find_bucket(const HashTable *ht, const char *str, int len, ulong h)
+static zend_always_inline Bucket *zend_hash_str_find_bucket(const HashTable *ht, const char *str, int len, zend_ulong h)
{
uint nIndex;
uint idx;
@@ -227,7 +227,7 @@ static zend_always_inline Bucket *zend_hash_str_find_bucket(const HashTable *ht,
return NULL;
}
-static zend_always_inline Bucket *zend_hash_index_find_bucket(const HashTable *ht, ulong h)
+static zend_always_inline Bucket *zend_hash_index_find_bucket(const HashTable *ht, zend_ulong h)
{
uint nIndex;
uint idx;
@@ -248,7 +248,7 @@ static zend_always_inline Bucket *zend_hash_index_find_bucket(const HashTable *h
static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_string *key, zval *pData, int flag ZEND_FILE_LINE_DC)
{
- ulong h;
+ zend_ulong h;
uint nIndex;
uint idx;
Bucket *p;
@@ -263,7 +263,7 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s
zend_hash_packed_to_hash(ht);
}
- h = STR_HASH_VAL(key);
+ h = zend_string_hash_val(key);
if ((flag & HASH_ADD_NEW) == 0) {
p = zend_hash_find_bucket(ht, key);
@@ -300,7 +300,7 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s
p = ht->arData + idx;
p->h = h;
p->key = key;
- STR_ADDREF(key);
+ zend_string_addref(key);
ZVAL_COPY_VALUE(&p->val, pData);
nIndex = h & ht->nTableMask;
Z_NEXT(p->val) = ht->arHash[nIndex];
@@ -337,45 +337,45 @@ ZEND_API zval *_zend_hash_add_new(HashTable *ht, zend_string *key, zval *pData Z
ZEND_API zval *_zend_hash_str_add_or_update(HashTable *ht, const char *str, int len, zval *pData, int flag ZEND_FILE_LINE_DC)
{
- zend_string *key = STR_INIT(str, len, ht->u.flags & HASH_FLAG_PERSISTENT);
+ zend_string *key = zend_string_init(str, len, ht->u.flags & HASH_FLAG_PERSISTENT);
zval *ret = _zend_hash_add_or_update_i(ht, key, pData, flag ZEND_FILE_LINE_CC);
- STR_RELEASE(key);
+ zend_string_release(key);
return ret;
}
ZEND_API zval *_zend_hash_str_update(HashTable *ht, const char *str, int len, zval *pData ZEND_FILE_LINE_DC)
{
- zend_string *key = STR_INIT(str, len, ht->u.flags & HASH_FLAG_PERSISTENT);
+ zend_string *key = zend_string_init(str, len, ht->u.flags & HASH_FLAG_PERSISTENT);
zval *ret = _zend_hash_add_or_update_i(ht, key, pData, HASH_UPDATE ZEND_FILE_LINE_CC);
- STR_RELEASE(key);
+ zend_string_release(key);
return ret;
}
ZEND_API zval *_zend_hash_str_update_ind(HashTable *ht, const char *str, int len, zval *pData ZEND_FILE_LINE_DC)
{
- zend_string *key = STR_INIT(str, len, ht->u.flags & HASH_FLAG_PERSISTENT);
+ zend_string *key = zend_string_init(str, len, ht->u.flags & HASH_FLAG_PERSISTENT);
zval *ret = _zend_hash_add_or_update_i(ht, key, pData, HASH_UPDATE | HASH_UPDATE_INDIRECT ZEND_FILE_LINE_CC);
- STR_RELEASE(key);
+ zend_string_release(key);
return ret;
}
ZEND_API zval *_zend_hash_str_add(HashTable *ht, const char *str, int len, zval *pData ZEND_FILE_LINE_DC)
{
- zend_string *key = STR_INIT(str, len, ht->u.flags & HASH_FLAG_PERSISTENT);
+ zend_string *key = zend_string_init(str, len, ht->u.flags & HASH_FLAG_PERSISTENT);
zval *ret = _zend_hash_add_or_update_i(ht, key, pData, HASH_ADD ZEND_FILE_LINE_CC);
- STR_RELEASE(key);
+ zend_string_release(key);
return ret;
}
ZEND_API zval *_zend_hash_str_add_new(HashTable *ht, const char *str, int len, zval *pData ZEND_FILE_LINE_DC)
{
- zend_string *key = STR_INIT(str, len, ht->u.flags & HASH_FLAG_PERSISTENT);
+ zend_string *key = zend_string_init(str, len, ht->u.flags & HASH_FLAG_PERSISTENT);
zval *ret = _zend_hash_add_or_update_i(ht, key, pData, HASH_ADD_NEW ZEND_FILE_LINE_CC);
- STR_RELEASE(key);
+ zend_string_release(key);
return ret;
}
-ZEND_API zval *zend_hash_index_add_empty_element(HashTable *ht, ulong h)
+ZEND_API zval *zend_hash_index_add_empty_element(HashTable *ht, zend_ulong h)
{
zval dummy;
@@ -402,7 +402,7 @@ ZEND_API zval *zend_hash_str_add_empty_element(HashTable *ht, const char *str, i
return zend_hash_str_add(ht, str, len, &dummy);
}
-static zend_always_inline zval *_zend_hash_index_update_or_next_insert_i(HashTable *ht, ulong h, zval *pData, int flag ZEND_FILE_LINE_DC)
+static zend_always_inline zval *_zend_hash_index_update_or_next_insert_i(HashTable *ht, zend_ulong h, zval *pData, int flag ZEND_FILE_LINE_DC)
{
uint nIndex;
uint idx;
@@ -430,8 +430,8 @@ static zend_always_inline zval *_zend_hash_index_update_or_next_insert_i(HashTab
ht->pDestructor(&p->val);
}
ZVAL_COPY_VALUE(&p->val, pData);
- if ((long)h >= (long)ht->nNextFreeElement) {
- ht->nNextFreeElement = h < LONG_MAX ? h + 1 : LONG_MAX;
+ if ((zend_long)h >= (zend_long)ht->nNextFreeElement) {
+ ht->nNextFreeElement = h < ZEND_LONG_MAX ? h + 1 : ZEND_LONG_MAX;
}
return &p->val;
} else { /* we have to keep the order :( */
@@ -460,8 +460,8 @@ static zend_always_inline zval *_zend_hash_index_update_or_next_insert_i(HashTab
if (ht->nInternalPointer == INVALID_IDX) {
ht->nInternalPointer = h;
}
- if ((long)h >= (long)ht->nNextFreeElement) {
- ht->nNextFreeElement = h < LONG_MAX ? h + 1 : LONG_MAX;
+ if ((zend_long)h >= (zend_long)ht->nNextFreeElement) {
+ ht->nNextFreeElement = h < ZEND_LONG_MAX ? h + 1 : ZEND_LONG_MAX;
}
p->h = h;
p->key = NULL;
@@ -490,8 +490,8 @@ convert_to_hash:
}
ZVAL_COPY_VALUE(&p->val, pData);
HANDLE_UNBLOCK_INTERRUPTIONS();
- if ((long)h >= (long)ht->nNextFreeElement) {
- ht->nNextFreeElement = h < LONG_MAX ? h + 1 : LONG_MAX;
+ if ((zend_long)h >= (zend_long)ht->nNextFreeElement) {
+ ht->nNextFreeElement = h < ZEND_LONG_MAX ? h + 1 : ZEND_LONG_MAX;
}
return &p->val;
}
@@ -505,8 +505,8 @@ convert_to_hash:
if (ht->nInternalPointer == INVALID_IDX) {
ht->nInternalPointer = idx;
}
- if ((long)h >= (long)ht->nNextFreeElement) {
- ht->nNextFreeElement = h < LONG_MAX ? h + 1 : LONG_MAX;
+ if ((zend_long)h >= (zend_long)ht->nNextFreeElement) {
+ ht->nNextFreeElement = h < ZEND_LONG_MAX ? h + 1 : ZEND_LONG_MAX;
}
p = ht->arData + idx;
p->h = h;
@@ -520,22 +520,22 @@ convert_to_hash:
return &p->val;
}
-ZEND_API zval *_zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, zval *pData, int flag ZEND_FILE_LINE_DC)
+ZEND_API zval *_zend_hash_index_update_or_next_insert(HashTable *ht, zend_ulong h, zval *pData, int flag ZEND_FILE_LINE_DC)
{
return _zend_hash_index_update_or_next_insert_i(ht, h, pData, flag ZEND_FILE_LINE_RELAY_CC);
}
-ZEND_API zval *_zend_hash_index_add(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC)
+ZEND_API zval *_zend_hash_index_add(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC)
{
return _zend_hash_index_update_or_next_insert_i(ht, h, pData, HASH_ADD ZEND_FILE_LINE_RELAY_CC);
}
-ZEND_API zval *_zend_hash_index_add_new(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC)
+ZEND_API zval *_zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC)
{
return _zend_hash_index_update_or_next_insert_i(ht, h, pData, HASH_ADD | HASH_ADD_NEW ZEND_FILE_LINE_RELAY_CC);
}
-ZEND_API zval *_zend_hash_index_update(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC)
+ZEND_API zval *_zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC)
{
return _zend_hash_index_update_or_next_insert_i(ht, h, pData, HASH_UPDATE ZEND_FILE_LINE_RELAY_CC);
}
@@ -564,8 +564,8 @@ static void zend_hash_do_resize(HashTable *ht)
HANDLE_UNBLOCK_INTERRUPTIONS();
} else if ((ht->nTableSize << 1) > 0) { /* Let's double the table size */
HANDLE_BLOCK_INTERRUPTIONS();
- ht->arData = (Bucket *) safe_perealloc(ht->arData, (ht->nTableSize << 1), sizeof(Bucket) + sizeof(zend_uint), 0, ht->u.flags & HASH_FLAG_PERSISTENT);
- ht->arHash = (zend_uint*)(ht->arData + (ht->nTableSize << 1));
+ ht->arData = (Bucket *) safe_perealloc(ht->arData, (ht->nTableSize << 1), sizeof(Bucket) + sizeof(uint32_t), 0, ht->u.flags & HASH_FLAG_PERSISTENT);
+ ht->arHash = (uint32_t*)(ht->arData + (ht->nTableSize << 1));
ht->nTableSize = (ht->nTableSize << 1);
ht->nTableMask = ht->nTableSize - 1;
zend_hash_rehash(ht);
@@ -582,12 +582,12 @@ ZEND_API int zend_hash_rehash(HashTable *ht)
if (UNEXPECTED(ht->nNumOfElements == 0)) {
if (ht->nTableMask) {
- memset(ht->arHash, INVALID_IDX, ht->nTableSize * sizeof(zend_uint));
+ memset(ht->arHash, INVALID_IDX, ht->nTableSize * sizeof(uint32_t));
}
return SUCCESS;
}
- memset(ht->arHash, INVALID_IDX, ht->nTableSize * sizeof(zend_uint));
+ memset(ht->arHash, INVALID_IDX, ht->nTableSize * sizeof(uint32_t));
for (i = 0, j = 0; i < ht->nNumUsed; i++) {
p = ht->arData + i;
if (Z_TYPE(p->val) == IS_UNDEF) continue;
@@ -634,7 +634,7 @@ static zend_always_inline void _zend_hash_del_el_ex(HashTable *ht, uint idx, Buc
}
}
if (p->key) {
- STR_RELEASE(p->key);
+ zend_string_release(p->key);
}
if (ht->pDestructor) {
zval tmp;
@@ -669,7 +669,7 @@ static zend_always_inline void _zend_hash_del_el(HashTable *ht, uint idx, Bucket
ZEND_API int zend_hash_del(HashTable *ht, zend_string *key)
{
- ulong h;
+ zend_ulong h;
uint nIndex;
uint idx;
Bucket *p;
@@ -684,7 +684,7 @@ ZEND_API int zend_hash_del(HashTable *ht, zend_string *key)
return FAILURE;
}
- h = STR_HASH_VAL(key);
+ h = zend_string_hash_val(key);
nIndex = h & ht->nTableMask;
idx = ht->arHash[nIndex];
@@ -708,7 +708,7 @@ ZEND_API int zend_hash_del(HashTable *ht, zend_string *key)
ZEND_API int zend_hash_del_ind(HashTable *ht, zend_string *key)
{
- ulong h;
+ zend_ulong h;
uint nIndex;
uint idx;
Bucket *p;
@@ -723,7 +723,7 @@ ZEND_API int zend_hash_del_ind(HashTable *ht, zend_string *key)
return FAILURE;
}
- h = STR_HASH_VAL(key);
+ h = zend_string_hash_val(key);
nIndex = h & ht->nTableMask;
idx = ht->arHash[nIndex];
@@ -760,7 +760,7 @@ ZEND_API int zend_hash_del_ind(HashTable *ht, zend_string *key)
ZEND_API int zend_hash_str_del(HashTable *ht, const char *str, int len)
{
- ulong h;
+ zend_ulong h;
uint nIndex;
uint idx;
Bucket *p;
@@ -811,7 +811,7 @@ ZEND_API int zend_hash_str_del(HashTable *ht, const char *str, int len)
ZEND_API int zend_hash_str_del_ind(HashTable *ht, const char *str, int len)
{
- ulong h;
+ zend_ulong h;
uint nIndex;
uint idx;
Bucket *p;
@@ -843,7 +843,7 @@ ZEND_API int zend_hash_str_del_ind(HashTable *ht, const char *str, int len)
return FAILURE;
}
-ZEND_API int zend_hash_index_del(HashTable *ht, ulong h)
+ZEND_API int zend_hash_index_del(HashTable *ht, zend_ulong h)
{
uint nIndex;
uint idx;
@@ -900,7 +900,7 @@ ZEND_API void zend_hash_destroy(HashTable *ht)
ht->pDestructor(&p->val);
}
if (p->key) {
- STR_RELEASE(p->key);
+ zend_string_release(p->key);
}
}
if (ht->nTableMask) {
@@ -925,7 +925,7 @@ ZEND_API void zend_hash_clean(HashTable *ht)
ht->pDestructor(&p->val);
}
if (p->key) {
- STR_RELEASE(p->key);
+ zend_string_release(p->key);
}
}
ht->nNumUsed = 0;
@@ -934,7 +934,7 @@ ZEND_API void zend_hash_clean(HashTable *ht)
ht->nInternalPointer = INVALID_IDX;
if (ht->nTableMask) {
if (!(ht->u.flags & HASH_FLAG_PACKED)) {
- memset(ht->arHash, INVALID_IDX, ht->nTableSize * sizeof(zend_uint));
+ memset(ht->arHash, INVALID_IDX, ht->nTableSize * sizeof(uint32_t));
}
}
}
@@ -1188,7 +1188,7 @@ ZEND_API void zend_array_dup(HashTable *target, HashTable *source)
target->nNumOfElements = source->nNumOfElements;
target->nNextFreeElement = source->nNextFreeElement;
target->arData = (Bucket *) safe_pemalloc(target->nTableSize, sizeof(Bucket), 0, 0);
- target->arHash = (zend_uint*)&uninitialized_bucket;
+ target->arHash = (uint32_t*)&uninitialized_bucket;
target->nInternalPointer = source->nInternalPointer;
for (idx = 0; idx < source->nNumUsed; idx++) {
@@ -1230,9 +1230,9 @@ ZEND_API void zend_array_dup(HashTable *target, HashTable *source)
}
} else {
target->nNextFreeElement = source->nNextFreeElement;
- target->arData = (Bucket *) safe_pemalloc(target->nTableSize, sizeof(Bucket) + sizeof(zend_uint), 0, 0);
- target->arHash = (zend_uint*)(target->arData + target->nTableSize);
- memset(target->arHash, INVALID_IDX, target->nTableSize * sizeof(zend_uint));
+ target->arData = (Bucket *) safe_pemalloc(target->nTableSize, sizeof(Bucket) + sizeof(uint32_t), 0, 0);
+ target->arHash = (uint32_t*)(target->arData + target->nTableSize);
+ memset(target->arHash, INVALID_IDX, target->nTableSize * sizeof(uint32_t));
for (idx = 0; idx < source->nNumUsed; idx++) {
p = source->arData + idx;
@@ -1254,7 +1254,7 @@ ZEND_API void zend_array_dup(HashTable *target, HashTable *source)
q->h = p->h;
q->key = p->key;
if (q->key) {
- STR_ADDREF(q->key);
+ zend_string_addref(q->key);
}
nIndex = q->h & target->nTableMask;
Z_NEXT(q->val) = target->arHash[nIndex];
@@ -1282,7 +1282,7 @@ ZEND_API void zend_array_dup(HashTable *target, HashTable *source)
target->nNumOfElements = 0;
target->nNextFreeElement = 0;
target->arData = NULL;
- target->arHash = (zend_uint*)&uninitialized_bucket;
+ target->arHash = (uint32_t*)&uninitialized_bucket;
}
}
@@ -1383,7 +1383,7 @@ ZEND_API zval *zend_hash_find(const HashTable *ht, zend_string *key)
ZEND_API zval *zend_hash_str_find(const HashTable *ht, const char *str, int len)
{
- ulong h;
+ zend_ulong h;
Bucket *p;
IS_CONSISTENT(ht);
@@ -1413,7 +1413,7 @@ ZEND_API int zend_hash_exists(const HashTable *ht, zend_string *key)
ZEND_API int zend_hash_str_exists(const HashTable *ht, const char *str, int len)
{
- ulong h;
+ zend_ulong h;
Bucket *p;
IS_CONSISTENT(ht);
@@ -1427,7 +1427,7 @@ ZEND_API int zend_hash_str_exists(const HashTable *ht, const char *str, int len)
return p ? 1 : 0;
}
-ZEND_API zval *zend_hash_index_find(const HashTable *ht, ulong h)
+ZEND_API zval *zend_hash_index_find(const HashTable *ht, zend_ulong h)
{
Bucket *p;
@@ -1448,7 +1448,7 @@ ZEND_API zval *zend_hash_index_find(const HashTable *ht, ulong h)
}
-ZEND_API int zend_hash_index_exists(const HashTable *ht, ulong h)
+ZEND_API int zend_hash_index_exists(const HashTable *ht, zend_ulong h)
{
Bucket *p;
@@ -1602,7 +1602,7 @@ ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos)
/* This function should be made binary safe */
-ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, ulong *num_index, zend_bool duplicate, HashPosition *pos)
+ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, zend_bool duplicate, HashPosition *pos)
{
uint idx = *pos;
Bucket *p;
@@ -1612,7 +1612,7 @@ ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str
p = ht->arData + idx;
if (p->key) {
if (duplicate) {
- *str_index = STR_COPY(p->key);
+ *str_index = zend_string_copy(p->key);
} else {
*str_index = p->key;
}
@@ -1637,7 +1637,7 @@ ZEND_API void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key,
p = ht->arData + idx;
if (p->key) {
ZVAL_STR(key, p->key);
- STR_ADDREF(p->key);
+ zend_string_addref(p->key);
} else {
ZVAL_LONG(key, p->h);
}
@@ -1712,7 +1712,7 @@ ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func,
p = ht->arData + j;
p->h = j;
if (p->key) {
- STR_RELEASE(p->key);
+ zend_string_release(p->key);
p->key = NULL;
}
}
@@ -1728,7 +1728,7 @@ ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func,
if (renumber) {
ht->u.flags |= HASH_FLAG_PACKED;
ht->arData = erealloc(ht->arData, ht->nTableSize * sizeof(Bucket));
- ht->arHash = (zend_uint*)&uninitialized_bucket;
+ ht->arHash = (uint32_t*)&uninitialized_bucket;
} else {
zend_hash_rehash(ht);
}
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h
index d7b419225e..42bacc5c16 100644
--- a/Zend/zend_hash.h
+++ b/Zend/zend_hash.h
@@ -45,7 +45,7 @@
#define HASH_MASK_CONSISTENCY 0x60
typedef struct _zend_hash_key {
- ulong h;
+ zend_ulong h;
zend_string *key;
} zend_hash_key;
@@ -98,10 +98,10 @@ ZEND_API zval *_zend_hash_str_add_new(HashTable *ht, const char *key, int len, z
#define zend_hash_str_add_new(ht, key, len, pData) \
_zend_hash_str_add_new(ht, key, len, pData ZEND_FILE_LINE_CC)
-ZEND_API zval *_zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, zval *pData, int flag ZEND_FILE_LINE_DC);
-ZEND_API zval *_zend_hash_index_add(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC);
-ZEND_API zval *_zend_hash_index_add_new(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC);
-ZEND_API zval *_zend_hash_index_update(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC);
+ZEND_API zval *_zend_hash_index_update_or_next_insert(HashTable *ht, zend_ulong h, zval *pData, int flag ZEND_FILE_LINE_DC);
+ZEND_API zval *_zend_hash_index_add(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC);
+ZEND_API zval *_zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC);
+ZEND_API zval *_zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC);
ZEND_API zval *_zend_hash_next_index_insert(HashTable *ht, zval *pData ZEND_FILE_LINE_DC);
ZEND_API zval *_zend_hash_next_index_insert_new(HashTable *ht, zval *pData ZEND_FILE_LINE_DC);
@@ -116,7 +116,7 @@ ZEND_API zval *_zend_hash_next_index_insert_new(HashTable *ht, zval *pData ZEND_
#define zend_hash_next_index_insert_new(ht, pData) \
_zend_hash_next_index_insert_new(ht, pData ZEND_FILE_LINE_CC)
-ZEND_API zval *zend_hash_index_add_empty_element(HashTable *ht, ulong h);
+ZEND_API zval *zend_hash_index_add_empty_element(HashTable *ht, zend_ulong h);
ZEND_API zval *zend_hash_add_empty_element(HashTable *ht, zend_string *key);
ZEND_API zval *zend_hash_str_add_empty_element(HashTable *ht, const char *key, int len);
@@ -148,24 +148,24 @@ ZEND_API int zend_hash_del(HashTable *ht, zend_string *key);
ZEND_API int zend_hash_del_ind(HashTable *ht, zend_string *key);
ZEND_API int zend_hash_str_del(HashTable *ht, const char *key, int len);
ZEND_API int zend_hash_str_del_ind(HashTable *ht, const char *key, int len);
-ZEND_API int zend_hash_index_del(HashTable *ht, ulong h);
+ZEND_API int zend_hash_index_del(HashTable *ht, zend_ulong h);
/* Data retreival */
ZEND_API zval *zend_hash_find(const HashTable *ht, zend_string *key);
ZEND_API zval *zend_hash_str_find(const HashTable *ht, const char *key, int len);
-ZEND_API zval *zend_hash_index_find(const HashTable *ht, ulong h);
+ZEND_API zval *zend_hash_index_find(const HashTable *ht, zend_ulong h);
/* Misc */
ZEND_API int zend_hash_exists(const HashTable *ht, zend_string *key);
ZEND_API int zend_hash_str_exists(const HashTable *ht, const char *str, int len);
-ZEND_API int zend_hash_index_exists(const HashTable *ht, ulong h);
+ZEND_API int zend_hash_index_exists(const HashTable *ht, zend_ulong h);
/* traversing */
#define zend_hash_has_more_elements_ex(ht, pos) \
(zend_hash_get_current_key_type_ex(ht, pos) == HASH_KEY_NON_EXISTENT ? FAILURE : SUCCESS)
ZEND_API int zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos);
ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos);
-ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, ulong *num_index, zend_bool duplicate, HashPosition *pos);
+ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, zend_bool duplicate, HashPosition *pos);
ZEND_API void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos);
ZEND_API int zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos);
ZEND_API zval *zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos);
@@ -175,7 +175,7 @@ ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos
typedef struct _HashPointer {
HashPosition pos;
HashTable *ht;
- ulong h;
+ zend_ulong h;
} HashPointer;
ZEND_API int zend_hash_get_pointer(const HashTable *ht, HashPointer *ptr);
@@ -235,7 +235,7 @@ END_EXTERN_C()
#define ZEND_INIT_SYMTABLE_EX(ht, n, persistent) \
zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent)
-static inline int _zend_handle_numeric_str(const char *key, int length, ulong *idx)
+static inline int _zend_handle_numeric_str(const char *key, size_t length, zend_ulong *idx)
{
register const char *tmp = key;
const char *end;
@@ -258,7 +258,7 @@ static inline int _zend_handle_numeric_str(const char *key, int length, ulong *i
if ((*end != '\0') /* not a null terminated string */
|| (*tmp == '0' && length > 1) /* numbers with leading zeros */
|| (end - tmp > MAX_LENGTH_OF_LONG - 1) /* number too long */
- || (SIZEOF_LONG == 4 &&
+ || (SIZEOF_ZEND_INT == 4 &&
end - tmp == MAX_LENGTH_OF_LONG - 1 &&
*tmp > '2')) { /* overflow */
return 0;
@@ -268,11 +268,11 @@ static inline int _zend_handle_numeric_str(const char *key, int length, ulong *i
++tmp;
if (tmp == end) {
if (*key == '-') {
- if (*idx-1 > LONG_MAX) { /* overflow */
+ if (*idx-1 > ZEND_LONG_MAX) { /* overflow */
return 0;
}
*idx = 0 - *idx;
- } else if (*idx > LONG_MAX) { /* overflow */
+ } else if (*idx > ZEND_LONG_MAX) { /* overflow */
return 0;
}
return 1;
@@ -322,7 +322,7 @@ static inline zval *zend_hash_str_find_ind(const HashTable *ht, const char *str,
static inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *pData)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC(key, idx)) {
return zend_hash_index_update(ht, idx, pData);
@@ -334,7 +334,7 @@ static inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *
static inline zval *zend_symtable_update_ind(HashTable *ht, zend_string *key, zval *pData)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC(key, idx)) {
return zend_hash_index_update(ht, idx, pData);
@@ -346,7 +346,7 @@ static inline zval *zend_symtable_update_ind(HashTable *ht, zend_string *key, zv
static inline int zend_symtable_del(HashTable *ht, zend_string *key)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC(key, idx)) {
return zend_hash_index_del(ht, idx);
@@ -358,7 +358,7 @@ static inline int zend_symtable_del(HashTable *ht, zend_string *key)
static inline int zend_symtable_del_ind(HashTable *ht, zend_string *key)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC(key, idx)) {
return zend_hash_index_del(ht, idx);
@@ -370,7 +370,7 @@ static inline int zend_symtable_del_ind(HashTable *ht, zend_string *key)
static inline zval *zend_symtable_find(const HashTable *ht, zend_string *key)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC(key, idx)) {
return zend_hash_index_find(ht, idx);
@@ -382,7 +382,7 @@ static inline zval *zend_symtable_find(const HashTable *ht, zend_string *key)
static inline zval *zend_symtable_find_ind(const HashTable *ht, zend_string *key)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC(key, idx)) {
return zend_hash_index_find(ht, idx);
@@ -394,7 +394,7 @@ static inline zval *zend_symtable_find_ind(const HashTable *ht, zend_string *key
static inline int zend_symtable_exists(HashTable *ht, zend_string *key)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC(key, idx)) {
return zend_hash_index_exists(ht, idx);
@@ -406,7 +406,7 @@ static inline int zend_symtable_exists(HashTable *ht, zend_string *key)
static inline zval *zend_symtable_str_update(HashTable *ht, const char *str, int len, zval *pData)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
return zend_hash_index_update(ht, idx, pData);
@@ -418,7 +418,7 @@ static inline zval *zend_symtable_str_update(HashTable *ht, const char *str, int
static inline zval *zend_symtable_str_update_ind(HashTable *ht, const char *str, int len, zval *pData)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
return zend_hash_index_update(ht, idx, pData);
@@ -430,7 +430,7 @@ static inline zval *zend_symtable_str_update_ind(HashTable *ht, const char *str,
static inline int zend_symtable_str_del(HashTable *ht, const char *str, int len)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
return zend_hash_index_del(ht, idx);
@@ -442,7 +442,7 @@ static inline int zend_symtable_str_del(HashTable *ht, const char *str, int len)
static inline int zend_symtable_str_del_ind(HashTable *ht, const char *str, int len)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
return zend_hash_index_del(ht, idx);
@@ -454,7 +454,7 @@ static inline int zend_symtable_str_del_ind(HashTable *ht, const char *str, int
static inline zval *zend_symtable_str_find(HashTable *ht, const char *str, int len)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
return zend_hash_index_find(ht, idx);
@@ -466,7 +466,7 @@ static inline zval *zend_symtable_str_find(HashTable *ht, const char *str, int l
static inline int zend_symtable_str_exists(HashTable *ht, const char *str, int len)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
return zend_hash_index_exists(ht, idx);
@@ -564,7 +564,7 @@ static inline void *zend_hash_str_update_mem(HashTable *ht, const char *str, int
return zend_hash_str_update_ptr(ht, str, len, p);
}
-static inline void *zend_hash_index_update_ptr(HashTable *ht, ulong h, void *pData)
+static inline void *zend_hash_index_update_ptr(HashTable *ht, zend_ulong h, void *pData)
{
zval tmp, *zv;
@@ -582,7 +582,7 @@ static inline void *zend_hash_next_index_insert_ptr(HashTable *ht, void *pData)
return zv ? Z_PTR_P(zv) : NULL;
}
-static inline void *zend_hash_index_update_mem(HashTable *ht, ulong h, void *pData, size_t size)
+static inline void *zend_hash_index_update_mem(HashTable *ht, zend_ulong h, void *pData, size_t size)
{
void *p;
@@ -620,7 +620,7 @@ static inline void *zend_hash_str_find_ptr(const HashTable *ht, const char *str,
return zv ? Z_PTR_P(zv) : NULL;
}
-static inline void *zend_hash_index_find_ptr(const HashTable *ht, ulong h)
+static inline void *zend_hash_index_find_ptr(const HashTable *ht, zend_ulong h)
{
zval *zv;
@@ -630,7 +630,7 @@ static inline void *zend_hash_index_find_ptr(const HashTable *ht, ulong h)
static inline void *zend_symtable_str_find_ptr(HashTable *ht, const char *str, int len)
{
- ulong idx;
+ zend_ulong idx;
if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
return zend_hash_index_find_ptr(ht, idx);
diff --git a/Zend/zend_highlight.c b/Zend/zend_highlight.c
index 50a1edce38..dab9595d60 100644
--- a/Zend/zend_highlight.c
+++ b/Zend/zend_highlight.c
@@ -150,7 +150,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
case T_DOC_COMMENT:
break;
default:
- STR_RELEASE(Z_STR(token));
+ zend_string_release(Z_STR(token));
break;
}
}
@@ -211,7 +211,7 @@ ZEND_API void zend_strip(TSRMLS_D)
break;
default:
- STR_RELEASE(Z_STR(token));
+ zend_string_release(Z_STR(token));
break;
}
}
diff --git a/Zend/zend_indent.c b/Zend/zend_indent.c
index 05254a30bc..5ebc4527e2 100644
--- a/Zend/zend_indent.c
+++ b/Zend/zend_indent.c
@@ -138,7 +138,7 @@ dflt_printout:
case T_WHITESPACE:
break;
default:
- STR_RELEASE(Z_STR(token));
+ zend_string_release(Z_STR(token));
break;
}
}
diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c
index c3a02d53a3..59c2776a85 100644
--- a/Zend/zend_ini.c
+++ b/Zend/zend_ini.c
@@ -352,7 +352,7 @@ ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*di
* Data retrieval
*/
-ZEND_API long zend_ini_long(char *name, uint name_length, int orig) /* {{{ */
+ZEND_API zend_long zend_ini_long(char *name, uint name_length, int orig) /* {{{ */
{
zend_ini_entry *ini_entry;
TSRMLS_FETCH();
@@ -360,9 +360,9 @@ ZEND_API long zend_ini_long(char *name, uint name_length, int orig) /* {{{ */
ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
if (ini_entry) {
if (orig && ini_entry->modified) {
- return (ini_entry->orig_value ? strtol(ini_entry->orig_value, NULL, 0) : 0);
+ return (ini_entry->orig_value ? ZEND_STRTOL(ini_entry->orig_value, NULL, 0) : 0);
} else {
- return (ini_entry->value ? strtol(ini_entry->value, NULL, 0) : 0);
+ return (ini_entry->value ? ZEND_STRTOL(ini_entry->value, NULL, 0) : 0);
}
}
@@ -587,7 +587,7 @@ ZEND_API ZEND_INI_MH(OnUpdateBool) /* {{{ */
ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */
{
- long *p;
+ zend_long *p;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
@@ -596,7 +596,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */
base = (char *) ts_resource(*((int *) mh_arg2));
#endif
- p = (long *) (base+(size_t) mh_arg1);
+ p = (zend_long *) (base+(size_t) mh_arg1);
*p = zend_atol(new_value, new_value_length);
return SUCCESS;
@@ -605,7 +605,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */
ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */
{
- long *p, tmp;
+ zend_long *p, tmp;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
@@ -619,7 +619,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */
return FAILURE;
}
- p = (long *) (base+(size_t) mh_arg1);
+ p = (zend_long *) (base+(size_t) mh_arg1);
*p = tmp;
return SUCCESS;
diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h
index 0a0c1137e1..68318612d0 100644
--- a/Zend/zend_ini.h
+++ b/Zend/zend_ini.h
@@ -69,7 +69,7 @@ ZEND_API int zend_alter_ini_entry_ex(zend_string *name, char *new_value, uint ne
ZEND_API int zend_restore_ini_entry(zend_string *name, int stage);
ZEND_API void display_ini_entries(zend_module_entry *module);
-ZEND_API long zend_ini_long(char *name, uint name_length, int orig);
+ZEND_API zend_long zend_ini_long(char *name, uint name_length, int orig);
ZEND_API double zend_ini_double(char *name, uint name_length, int orig);
ZEND_API char *zend_ini_string(char *name, uint name_length, int orig);
ZEND_API char *zend_ini_string_ex(char *name, uint name_length, int orig, zend_bool *exists);
diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y
index eaf451a3a1..8093458308 100644
--- a/Zend/zend_ini_parser.y
+++ b/Zend/zend_ini_parser.y
@@ -53,10 +53,10 @@ static void zend_ini_do_op(char type, zval *result, zval *op1, zval *op2)
char str_result[MAX_LENGTH_OF_LONG];
i_op1 = atoi(Z_STRVAL_P(op1));
- STR_FREE(Z_STR_P(op1));
+ zend_string_free(Z_STR_P(op1));
if (op2) {
i_op2 = atoi(Z_STRVAL_P(op2));
- STR_FREE(Z_STR_P(op2));
+ zend_string_free(Z_STR_P(op2));
} else {
i_op2 = 0;
}
@@ -102,7 +102,7 @@ static void zend_ini_add_string(zval *result, zval *op1, zval *op2)
int op1_len = Z_STRLEN_P(op1);
int length = op1_len + Z_STRLEN_P(op2);
- ZVAL_NEW_STR(result, STR_REALLOC(Z_STR_P(op1), length, 1));
+ ZVAL_NEW_STR(result, zend_string_realloc(Z_STR_P(op1), length, 1));
memcpy(Z_STRVAL_P(result)+op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2));
Z_STRVAL_P(result)[length] = 0;
}
@@ -130,7 +130,7 @@ static void zend_ini_get_constant(zval *result, zval *name TSRMLS_DC)
if (c == &tmp) {
zval_dtor(&tmp);
}
- STR_FREE(Z_STR_P(name));
+ zend_string_free(Z_STR_P(name));
} else {
*result = *name;
}
@@ -282,26 +282,26 @@ statement:
printf("SECTION: [%s]\n", Z_STRVAL($2));
#endif
ZEND_INI_PARSER_CB(&$2, NULL, NULL, ZEND_INI_PARSER_SECTION, ZEND_INI_PARSER_ARG TSRMLS_CC);
- STR_RELEASE(Z_STR($2));
+ zend_string_release(Z_STR($2));
}
| TC_LABEL '=' string_or_value {
#if DEBUG_CFG_PARSER
printf("NORMAL: '%s' = '%s'\n", Z_STRVAL($1), Z_STRVAL($3));
#endif
ZEND_INI_PARSER_CB(&$1, &$3, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG TSRMLS_CC);
- STR_RELEASE(Z_STR($1));
- STR_RELEASE(Z_STR($3));
+ zend_string_release(Z_STR($1));
+ zend_string_release(Z_STR($3));
}
| TC_OFFSET option_offset ']' '=' string_or_value {
#if DEBUG_CFG_PARSER
printf("OFFSET: '%s'[%s] = '%s'\n", Z_STRVAL($1), Z_STRVAL($2), Z_STRVAL($5));
#endif
ZEND_INI_PARSER_CB(&$1, &$5, &$2, ZEND_INI_PARSER_POP_ENTRY, ZEND_INI_PARSER_ARG TSRMLS_CC);
- STR_RELEASE(Z_STR($1));
- STR_RELEASE(Z_STR($2));
- STR_RELEASE(Z_STR($5));
+ zend_string_release(Z_STR($1));
+ zend_string_release(Z_STR($2));
+ zend_string_release(Z_STR($5));
}
- | TC_LABEL { ZEND_INI_PARSER_CB(&$1, NULL, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG TSRMLS_CC); STR_RELEASE(Z_STR($1)); }
+ | TC_LABEL { ZEND_INI_PARSER_CB(&$1, NULL, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG TSRMLS_CC); zend_string_release(Z_STR($1)); }
| END_OF_LINE
;
@@ -323,8 +323,8 @@ option_offset:
;
encapsed_list:
- encapsed_list cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
- | encapsed_list TC_QUOTED_STRING { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
+ encapsed_list cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); zend_string_free(Z_STR($2)); }
+ | encapsed_list TC_QUOTED_STRING { zend_ini_add_string(&$$, &$1, &$2); zend_string_free(Z_STR($2)); }
| /* empty */ { zend_ini_init_string(&$$); }
;
@@ -332,18 +332,18 @@ var_string_list_section:
cfg_var_ref { $$ = $1; }
| constant_literal { $$ = $1; }
| '"' encapsed_list '"' { $$ = $2; }
- | var_string_list_section cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
- | var_string_list_section constant_literal { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
- | var_string_list_section '"' encapsed_list '"' { zend_ini_add_string(&$$, &$1, &$3); STR_FREE(Z_STR($3)); }
+ | var_string_list_section cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); zend_string_free(Z_STR($2)); }
+ | var_string_list_section constant_literal { zend_ini_add_string(&$$, &$1, &$2); zend_string_free(Z_STR($2)); }
+ | var_string_list_section '"' encapsed_list '"' { zend_ini_add_string(&$$, &$1, &$3); zend_string_free(Z_STR($3)); }
;
var_string_list:
cfg_var_ref { $$ = $1; }
| constant_string { $$ = $1; }
| '"' encapsed_list '"' { $$ = $2; }
- | var_string_list cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
- | var_string_list constant_string { zend_ini_add_string(&$$, &$1, &$2); STR_FREE(Z_STR($2)); }
- | var_string_list '"' encapsed_list '"' { zend_ini_add_string(&$$, &$1, &$3); STR_FREE(Z_STR($3)); }
+ | var_string_list cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); zend_string_free(Z_STR($2)); }
+ | var_string_list constant_string { zend_ini_add_string(&$$, &$1, &$2); zend_string_free(Z_STR($2)); }
+ | var_string_list '"' encapsed_list '"' { zend_ini_add_string(&$$, &$1, &$3); zend_string_free(Z_STR($3)); }
;
expr:
@@ -357,7 +357,7 @@ expr:
;
cfg_var_ref:
- TC_DOLLAR_CURLY TC_VARNAME '}' { zend_ini_get_var(&$$, &$2 TSRMLS_CC); STR_FREE(Z_STR($2)); }
+ TC_DOLLAR_CURLY TC_VARNAME '}' { zend_ini_get_var(&$$, &$2 TSRMLS_CC); zend_string_free(Z_STR($2)); }
;
constant_literal:
diff --git a/Zend/zend_ini_scanner.c b/Zend/zend_ini_scanner.c
index b71f1ccb3c..0dcec0444b 100644
--- a/Zend/zend_ini_scanner.c
+++ b/Zend/zend_ini_scanner.c
@@ -134,7 +134,7 @@ ZEND_API zend_ini_scanner_globals ini_scanner_globals;
#define EAT_TRAILING_WHITESPACE() EAT_TRAILING_WHITESPACE_EX('X')
#define zend_ini_copy_value(retval, str, len) \
- ZVAL_NEW_STR(retval, STR_INIT(str, len, 1))
+ ZVAL_NEW_STR(retval, zend_string_init(str, len, 1))
#define RETURN_TOKEN(type, str, len) { \
diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l
index bbc48d1fc1..605d511f4f 100644
--- a/Zend/zend_ini_scanner.l
+++ b/Zend/zend_ini_scanner.l
@@ -132,7 +132,7 @@ ZEND_API zend_ini_scanner_globals ini_scanner_globals;
#define EAT_TRAILING_WHITESPACE() EAT_TRAILING_WHITESPACE_EX('X')
#define zend_ini_copy_value(retval, str, len) \
- ZVAL_NEW_STR(retval, STR_INIT(str, len, 1))
+ ZVAL_NEW_STR(retval, zend_string_init(str, len, 1))
#define RETURN_TOKEN(type, str, len) { \
diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c
index d5420dae76..8c55f3d7c1 100644
--- a/Zend/zend_interfaces.c
+++ b/Zend/zend_interfaces.c
@@ -303,7 +303,7 @@ ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *c
static int zend_implement_traversable(zend_class_entry *interface, zend_class_entry *class_type TSRMLS_DC)
{
/* check that class_type is traversable at c-level or implements at least one of 'aggregate' and 'Iterator' */
- zend_uint i;
+ uint32_t i;
if (class_type->get_iterator || (class_type->parent && class_type->parent->get_iterator)) {
return SUCCESS;
@@ -406,7 +406,7 @@ static int zend_implement_arrayaccess(zend_class_entry *interface, zend_class_en
/* }}}*/
/* {{{ zend_user_serialize */
-ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC)
+ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, uint32_t *buf_len, zend_serialize_data *data TSRMLS_DC)
{
zend_class_entry * ce = Z_OBJCE_P(object);
zval retval;
@@ -443,7 +443,7 @@ ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint
/* }}} */
/* {{{ zend_user_unserialize */
-ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC)
+ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, uint32_t buf_len, zend_unserialize_data *data TSRMLS_DC)
{
zval zdata;
@@ -463,7 +463,7 @@ ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const uns
}
/* }}} */
-ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */
+ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, uint32_t *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */
{
zend_class_entry *ce = Z_OBJCE_P(object);
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Serialization of '%s' is not allowed", ce->name->val);
@@ -471,7 +471,7 @@ ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zen
}
/* }}} */
-ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC) /* {{{ */
+ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, uint32_t buf_len, zend_unserialize_data *data TSRMLS_DC) /* {{{ */
{
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Unserialization of '%s' is not allowed", ce->name->val);
return FAILURE;
diff --git a/Zend/zend_interfaces.h b/Zend/zend_interfaces.h
index 7fe0e4e2f0..88e1dfe05b 100644
--- a/Zend/zend_interfaces.h
+++ b/Zend/zend_interfaces.h
@@ -61,11 +61,11 @@ ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *c
ZEND_API void zend_register_interfaces(TSRMLS_D);
-ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
-ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
+ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, uint32_t *buf_len, zend_serialize_data *data TSRMLS_DC);
+ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, uint32_t buf_len, zend_unserialize_data *data TSRMLS_DC);
-ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
-ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
+ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, uint32_t *buf_len, zend_serialize_data *data TSRMLS_DC);
+ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, uint32_t buf_len, zend_unserialize_data *data TSRMLS_DC);
END_EXTERN_C()
diff --git a/Zend/zend_iterators.c b/Zend/zend_iterators.c
index faf4f91d84..7c08ac59b5 100644
--- a/Zend/zend_iterators.c
+++ b/Zend/zend_iterators.c
@@ -24,13 +24,14 @@
static zend_class_entry zend_iterator_class_entry;
+static void iter_wrapper_free(zend_object *object TSRMLS_DC);
static void iter_wrapper_dtor(zend_object *object TSRMLS_DC);
static zend_object_handlers iterator_object_handlers = {
0,
+ iter_wrapper_free,
iter_wrapper_dtor,
NULL,
- NULL,
NULL, /* prop read */
NULL, /* prop write */
NULL, /* read dim */
@@ -58,12 +59,16 @@ ZEND_API void zend_register_iterator_wrapper(TSRMLS_D)
INIT_CLASS_ENTRY(zend_iterator_class_entry, "__iterator_wrapper", NULL);
}
-static void iter_wrapper_dtor(zend_object *object TSRMLS_DC)
+static void iter_wrapper_free(zend_object *object TSRMLS_DC)
{
zend_object_iterator *iter = (zend_object_iterator*)object;
iter->funcs->dtor(iter TSRMLS_CC);
}
+static void iter_wrapper_dtor(zend_object *object TSRMLS_DC)
+{
+}
+
ZEND_API void zend_iterator_init(zend_object_iterator *iter TSRMLS_DC)
{
zend_object_std_init(&iter->std, &zend_iterator_class_entry TSRMLS_CC);
diff --git a/Zend/zend_iterators.h b/Zend/zend_iterators.h
index 09346aee90..b0105d52e2 100644
--- a/Zend/zend_iterators.h
+++ b/Zend/zend_iterators.h
@@ -58,7 +58,7 @@ struct _zend_object_iterator {
zend_object std;
zval data;
zend_object_iterator_funcs *funcs;
- ulong index; /* private to fe_reset/fe_fetch opcodes */
+ zend_ulong index; /* private to fe_reset/fe_fetch opcodes */
};
typedef struct _zend_class_iterator_funcs {
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index 340371aba6..8622fbb441 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -864,13 +864,13 @@ expr_without_variable:
{ $$.str = CG(doc_comment); CG(doc_comment) = NULL; }
'{' inner_statement_list '}'
{ $$.ast = zend_ast_create_decl(ZEND_AST_CLOSURE, $2.num, $1.num, $7.str,
- STR_INIT("{closure}", sizeof("{closure}") - 1, 0),
+ zend_string_init("{closure}", sizeof("{closure}") - 1, 0),
$4.ast, $6.ast, $9.ast); }
| T_STATIC function returns_ref '(' parameter_list ')' lexical_vars
{ $$.str = CG(doc_comment); CG(doc_comment) = NULL; }
'{' inner_statement_list '}'
{ $$.ast = zend_ast_create_decl(ZEND_AST_CLOSURE, $3.num | ZEND_ACC_STATIC, $2.num,
- $8.str, STR_INIT("{closure}", sizeof("{closure}") - 1, 0),
+ $8.str, zend_string_init("{closure}", sizeof("{closure}") - 1, 0),
$5.ast, $7.ast, $10.ast); }
;
diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c
index 78654194d1..08db450374 100644
--- a/Zend/zend_language_scanner.c
+++ b/Zend/zend_language_scanner.c
@@ -535,9 +535,9 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
file_path = file_handle->filename;
}
- compiled_filename = STR_INIT(file_path, strlen(file_path), 0);
+ compiled_filename = zend_string_init(file_path, strlen(file_path), 0);
zend_set_compiled_filename(compiled_filename TSRMLS_CC);
- STR_RELEASE(compiled_filename);
+ zend_string_release(compiled_filename);
if (CG(start_lineno)) {
CG(zend_lineno) = CG(start_lineno);
@@ -660,7 +660,7 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
/* enforce ZEND_MMAP_AHEAD trailing NULLs for flex... */
old_len = Z_STRLEN_P(str);
- Z_STR_P(str) = STR_REALLOC(Z_STR_P(str), old_len + ZEND_MMAP_AHEAD, 0);
+ Z_STR_P(str) = zend_string_realloc(Z_STR_P(str), old_len + ZEND_MMAP_AHEAD, 0);
Z_TYPE_INFO_P(str) = IS_STRING_EX;
memset(Z_STRVAL_P(str) + old_len, 0, ZEND_MMAP_AHEAD + 1);
@@ -689,9 +689,9 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
yy_scan_buffer(buf, size TSRMLS_CC);
- new_compiled_filename = STR_INIT(filename, strlen(filename), 0);
+ new_compiled_filename = zend_string_init(filename, strlen(filename), 0);
zend_set_compiled_filename(new_compiled_filename TSRMLS_CC);
- STR_RELEASE(new_compiled_filename);
+ zend_string_release(new_compiled_filename);
CG(zend_lineno) = 1;
CG(increment_lineno) = 0;
RESET_DOC_COMMENT();
@@ -957,7 +957,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
hex_buf[1] = *(++s);
Z_STRLEN_P(zendlval)--;
}
- *t++ = (char) strtol(hex_buf, NULL, 16);
+ *t++ = (char) ZEND_STRTOL(hex_buf, NULL, 16);
} else {
*t++ = '\\';
*t++ = *s;
@@ -978,7 +978,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
Z_STRLEN_P(zendlval)--;
}
}
- *t++ = (char) strtol(octal_buf, NULL, 8);
+ *t++ = (char) ZEND_STRTOL(octal_buf, NULL, 8);
} else {
*t++ = '\\';
*t++ = *s;
@@ -1639,7 +1639,7 @@ yy61:
yyleng = YYCURSOR - SCNG(yy_text);
#line 2086 "Zend/zend_language_scanner.l"
{
- Z_LVAL_P(zendlval) = (long) '{';
+ Z_LVAL_P(zendlval) = (zend_long) '{';
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
yyless(1);
return T_CURLY_OPEN;
@@ -1867,7 +1867,7 @@ yy83:
yyleng = YYCURSOR - SCNG(yy_text);
#line 2086 "Zend/zend_language_scanner.l"
{
- Z_LVAL_P(zendlval) = (long) '{';
+ Z_LVAL_P(zendlval) = (zend_long) '{';
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
yyless(1);
return T_CURLY_OPEN;
@@ -2126,7 +2126,7 @@ yy107:
yyleng = YYCURSOR - SCNG(yy_text);
#line 2086 "Zend/zend_language_scanner.l"
{
- Z_LVAL_P(zendlval) = (long) '{';
+ Z_LVAL_P(zendlval) = (zend_long) '{';
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
yyless(1);
return T_CURLY_OPEN;
@@ -2946,10 +2946,10 @@ yy173:
#line 1536 "Zend/zend_language_scanner.l"
{
if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */
- ZVAL_LONG(zendlval, strtol(yytext, NULL, 0));
+ ZVAL_LONG(zendlval, ZEND_STRTOL(yytext, NULL, 0));
} else {
errno = 0;
- ZVAL_LONG(zendlval, strtol(yytext, NULL, 0));
+ ZVAL_LONG(zendlval, ZEND_STRTOL(yytext, NULL, 0));
if (errno == ERANGE) { /* Overflow */
if (yytext[0] == '0') { /* octal overflow */
ZVAL_DOUBLE(zendlval, zend_oct_strtod(yytext, NULL));
@@ -3307,11 +3307,11 @@ yy200:
--len;
}
- if (len < SIZEOF_LONG * 8) {
+ if (len < SIZEOF_ZEND_INT * 8) {
if (len == 0) {
ZVAL_LONG(zendlval, 0);
} else {
- ZVAL_LONG(zendlval, strtol(bin, NULL, 2));
+ ZVAL_LONG(zendlval, ZEND_STRTOL(bin, NULL, 2));
}
return T_LNUMBER;
} else {
@@ -3342,11 +3342,11 @@ yy203:
len--;
}
- if (len < SIZEOF_LONG * 2 || (len == SIZEOF_LONG * 2 && *hex <= '7')) {
+ if (len < SIZEOF_ZEND_INT * 2 || (len == SIZEOF_ZEND_INT * 2 && *hex <= '7')) {
if (len == 0) {
ZVAL_LONG(zendlval, 0);
} else {
- ZVAL_LONG(zendlval, strtol(hex, NULL, 16));
+ ZVAL_LONG(zendlval, ZEND_STRTOL(hex, NULL, 16));
}
return T_LNUMBER;
} else {
@@ -3562,7 +3562,7 @@ yy235:
HANDLE_NEWLINES(yytext, yyleng);
if (doc_com) {
- CG(doc_comment) = STR_INIT(yytext, yyleng, 0);
+ CG(doc_comment) = zend_string_init(yytext, yyleng, 0);
return T_DOC_COMMENT;
}
@@ -4191,11 +4191,11 @@ yy322:
filename = STR_EMPTY_ALLOC();
}
- dirname = STR_INIT(filename->val, filename->len, 0);
+ dirname = zend_string_init(filename->val, filename->len, 0);
zend_dirname(dirname->val, dirname->len);
if (strcmp(dirname->val, ".") == 0) {
- dirname = STR_REALLOC(dirname, MAXPATHLEN, 0);
+ dirname = zend_string_realloc(dirname, MAXPATHLEN, 0);
#if HAVE_GETCWD
VCWD_GETCWD(dirname->val, MAXPATHLEN);
#elif HAVE_GETWD
@@ -4358,7 +4358,7 @@ yy352:
if (!filename) {
ZVAL_EMPTY_STRING(zendlval);
} else {
- ZVAL_STR(zendlval, STR_COPY(filename));
+ ZVAL_STR(zendlval, zend_string_copy(filename));
}
return T_FILE;
}
@@ -7605,7 +7605,7 @@ yy839:
#line 1577 "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)) {
- ZVAL_LONG(zendlval, strtol(yytext, NULL, 10));
+ ZVAL_LONG(zendlval, ZEND_STRTOL(yytext, NULL, 10));
} else {
ZVAL_STRINGL(zendlval, yytext, yyleng);
}
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index 81d839b0fb..f0759d587b 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -533,9 +533,9 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
file_path = file_handle->filename;
}
- compiled_filename = STR_INIT(file_path, strlen(file_path), 0);
+ compiled_filename = zend_string_init(file_path, strlen(file_path), 0);
zend_set_compiled_filename(compiled_filename TSRMLS_CC);
- STR_RELEASE(compiled_filename);
+ zend_string_release(compiled_filename);
if (CG(start_lineno)) {
CG(zend_lineno) = CG(start_lineno);
@@ -658,7 +658,7 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
/* enforce ZEND_MMAP_AHEAD trailing NULLs for flex... */
old_len = Z_STRLEN_P(str);
- Z_STR_P(str) = STR_REALLOC(Z_STR_P(str), old_len + ZEND_MMAP_AHEAD, 0);
+ Z_STR_P(str) = zend_string_realloc(Z_STR_P(str), old_len + ZEND_MMAP_AHEAD, 0);
Z_TYPE_INFO_P(str) = IS_STRING_EX;
memset(Z_STRVAL_P(str) + old_len, 0, ZEND_MMAP_AHEAD + 1);
@@ -687,9 +687,9 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
yy_scan_buffer(buf, size TSRMLS_CC);
- new_compiled_filename = STR_INIT(filename, strlen(filename), 0);
+ new_compiled_filename = zend_string_init(filename, strlen(filename), 0);
zend_set_compiled_filename(new_compiled_filename TSRMLS_CC);
- STR_RELEASE(new_compiled_filename);
+ zend_string_release(new_compiled_filename);
CG(zend_lineno) = 1;
CG(increment_lineno) = 0;
RESET_DOC_COMMENT();
@@ -955,7 +955,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
hex_buf[1] = *(++s);
Z_STRLEN_P(zendlval)--;
}
- *t++ = (char) strtol(hex_buf, NULL, 16);
+ *t++ = (char) ZEND_STRTOL(hex_buf, NULL, 16);
} else {
*t++ = '\\';
*t++ = *s;
@@ -976,7 +976,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
Z_STRLEN_P(zendlval)--;
}
}
- *t++ = (char) strtol(octal_buf, NULL, 8);
+ *t++ = (char) ZEND_STRTOL(octal_buf, NULL, 8);
} else {
*t++ = '\\';
*t++ = *s;
@@ -1520,11 +1520,11 @@ NEWLINE ("\r"|"\n"|"\r\n")
--len;
}
- if (len < SIZEOF_LONG * 8) {
+ if (len < SIZEOF_ZEND_INT * 8) {
if (len == 0) {
ZVAL_LONG(zendlval, 0);
} else {
- ZVAL_LONG(zendlval, strtol(bin, NULL, 2));
+ ZVAL_LONG(zendlval, ZEND_STRTOL(bin, NULL, 2));
}
return T_LNUMBER;
} else {
@@ -1535,10 +1535,10 @@ NEWLINE ("\r"|"\n"|"\r\n")
<ST_IN_SCRIPTING>{LNUM} {
if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */
- ZVAL_LONG(zendlval, strtol(yytext, NULL, 0));
+ ZVAL_LONG(zendlval, ZEND_STRTOL(yytext, NULL, 0));
} else {
errno = 0;
- ZVAL_LONG(zendlval, strtol(yytext, NULL, 0));
+ ZVAL_LONG(zendlval, ZEND_STRTOL(yytext, NULL, 0));
if (errno == ERANGE) { /* Overflow */
if (yytext[0] == '0') { /* octal overflow */
ZVAL_DOUBLE(zendlval, zend_oct_strtod(yytext, NULL));
@@ -1561,11 +1561,11 @@ NEWLINE ("\r"|"\n"|"\r\n")
len--;
}
- if (len < SIZEOF_LONG * 2 || (len == SIZEOF_LONG * 2 && *hex <= '7')) {
+ if (len < SIZEOF_ZEND_INT * 2 || (len == SIZEOF_ZEND_INT * 2 && *hex <= '7')) {
if (len == 0) {
ZVAL_LONG(zendlval, 0);
} else {
- ZVAL_LONG(zendlval, strtol(hex, NULL, 16));
+ ZVAL_LONG(zendlval, ZEND_STRTOL(hex, NULL, 16));
}
return T_LNUMBER;
} else {
@@ -1576,7 +1576,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
<ST_VAR_OFFSET>[0]|([1-9][0-9]*) { /* 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)) {
- ZVAL_LONG(zendlval, strtol(yytext, NULL, 10));
+ ZVAL_LONG(zendlval, ZEND_STRTOL(yytext, NULL, 10));
} else {
ZVAL_STRINGL(zendlval, yytext, yyleng);
}
@@ -1620,7 +1620,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
if (!filename) {
ZVAL_EMPTY_STRING(zendlval);
} else {
- ZVAL_STR(zendlval, STR_COPY(filename));
+ ZVAL_STR(zendlval, zend_string_copy(filename));
}
return T_FILE;
}
@@ -1633,11 +1633,11 @@ NEWLINE ("\r"|"\n"|"\r\n")
filename = STR_EMPTY_ALLOC();
}
- dirname = STR_INIT(filename->val, filename->len, 0);
+ dirname = zend_string_init(filename->val, filename->len, 0);
zend_dirname(dirname->val, dirname->len);
if (strcmp(dirname->val, ".") == 0) {
- dirname = STR_REALLOC(dirname, MAXPATHLEN, 0);
+ dirname = zend_string_realloc(dirname, MAXPATHLEN, 0);
#if HAVE_GETCWD
VCWD_GETCWD(dirname->val, MAXPATHLEN);
#elif HAVE_GETWD
@@ -1880,7 +1880,7 @@ inline_html:
HANDLE_NEWLINES(yytext, yyleng);
if (doc_com) {
- CG(doc_comment) = STR_INIT(yytext, yyleng, 0);
+ CG(doc_comment) = zend_string_init(yytext, yyleng, 0);
return T_DOC_COMMENT;
}
@@ -2084,7 +2084,7 @@ inline_html:
<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"{$" {
- Z_LVAL_P(zendlval) = (long) '{';
+ Z_LVAL_P(zendlval) = (zend_long) '{';
yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
yyless(1);
return T_CURLY_OPEN;
diff --git a/Zend/zend_long.h b/Zend/zend_long.h
new file mode 100644
index 0000000000..34441c6e45
--- /dev/null
+++ b/Zend/zend_long.h
@@ -0,0 +1,141 @@
+/*
+ +----------------------------------------------------------------------+
+ | 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: Anatol Belski <ab@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+
+#ifndef ZEND_LONG_H
+#define ZEND_LONG_H
+
+#include "main/php_stdint.h"
+
+/* This is the heart of the whole int64 enablement in zval. Based on this
+ macros the size_t datatype is handled, see zend_types.h */
+#if defined(__X86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64)
+# define ZEND_ENABLE_INT64 1
+#endif
+
+/* Integer types or the old bad long. */
+#ifdef ZEND_ENABLE_INT64
+# ifdef ZEND_WIN32
+# ifdef _WIN64
+typedef __int64 zend_long;
+typedef unsigned __int64 zend_ulong;
+typedef __int64 zend_off_t;
+# define ZEND_LONG_MAX _I64_MAX
+# define ZEND_LONG_MIN _I64_MIN
+# define ZEND_ULONG_MAX _UI64_MAX
+# define Z_I(i) i##i64
+# define Z_UL(i) i##Ui64
+# else
+# error Cant enable 64 bit integers on non 64 bit platform
+# endif
+# else
+# if defined(__X86_64__) || defined(__LP64__) || defined(_LP64)
+typedef int64_t zend_long;
+typedef uint64_t zend_ulong;
+typedef off_t zend_off_t;
+# define ZEND_LONG_MAX INT64_MAX
+# define ZEND_LONG_MIN INT64_MIN
+# define ZEND_ULONG_MAX UINT64_MAX
+# define Z_I(i) i##LL
+# define Z_UL(i) i##ULL
+# else
+# error Cant enable 64 bit integers on non 64 bit platform
+# endif
+# endif
+# define SIZEOF_ZEND_INT 8
+#else
+typedef long zend_long;
+typedef unsigned long zend_ulong;
+typedef long zend_off_t;
+# define ZEND_LONG_MAX LONG_MAX
+# define ZEND_LONG_MIN LONG_MIN
+# define ZEND_ULONG_MAX ULONG_MAX
+# define Z_I(i) i##L
+# define Z_UL(i) i##UL
+# define SIZEOF_ZEND_INT SIZEOF_LONG
+#endif
+
+
+/* conversion macros */
+#define ZEND_LTOA_BUF_LEN 65
+
+#ifdef ZEND_ENABLE_INT64
+# ifdef PHP_WIN32
+# define ZEND_LTOA(i, s, len) _i64toa_s((i), (s), (len), 10)
+# define ZEND_ATOL(i, s) i = _atoi64((s))
+# define ZEND_STRTOL(s0, s1, base) _strtoi64((s0), (s1), (base))
+# define ZEND_STRTOUL(s0, s1, base) _strtoui64((s0), (s1), (base))
+# define ZEND_LONG_FMT "%I64d"
+# define ZEND_ULONG_FMT "%I64u"
+# define ZEND_LONG_FMT_SPEC "I64d"
+# define ZEND_ULONG_FMT_SPEC "I64u"
+# define ZEND_STRTOL_PTR _strtoi64
+# define ZEND_STRTOUL_PTR _strtoui64
+# define ZEND_ABS _abs64
+# else
+# define ZEND_LTOA(i, s, len) \
+ do { \
+ int st = snprintf((s), (len), "%lld", (i)); \
+ (s)[st] = '\0'; \
+ } while (0)
+# define ZEND_ATOL(i, s) (i) = atoll((s))
+# define ZEND_STRTOL(s0, s1, base) strtoll((s0), (s1), (base))
+# define ZEND_STRTOUL(s0, s1, base) strtoull((s0), (s1), (base))
+# define ZEND_LONG_FMT "%" PRId64
+# define ZEND_ULONG_FMT "%" PRIu64
+# define ZEND_LONG_FMT_SPEC PRId64
+# define ZEND_ULONG_FMT_SPEC PRIu64
+# define ZEND_STRTOL_PTR strtoll
+# define ZEND_STRTOUL_PTR strtoull
+# define ZEND_ABS llabs
+# endif
+#else
+# define ZEND_STRTOL(s0, s1, base) strtol((s0), (s1), (base))
+# define ZEND_STRTOUL(s0, s1, base) strtoul((s0), (s1), (base))
+# ifdef PHP_WIN32
+# define ZEND_LTOA(i, s, len) _ltoa_s((i), (s), (len), 10)
+# define ZEND_ATOL(i, s) i = atol((s))
+# else
+# define ZEND_LTOA(i, s, len) \
+ do { \
+ int st = snprintf((s), (len), "%ld", (i)); \
+ (s)[st] = '\0'; \
+ } while (0)
+# define ZEND_ATOL(i, s) (i) = atol((s))
+# endif
+# define ZEND_LONG_FMT "%ld"
+# define ZEND_ULONG_FMT "%lu"
+# define ZEND_LONG_FMT_SPEC "ld"
+# define ZEND_ULONG_FMT_SPEC "lu"
+# define ZEND_STRTOL_PTR strtol
+# define ZEND_STRTOUL_PTR strtoul
+# define ZEND_ABS abs
+#endif
+
+
+#endif /* ZEND_LONG_H */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ */
diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h
index 74dc7d1452..71223ad117 100644
--- a/Zend/zend_multiply.h
+++ b/Zend/zend_multiply.h
@@ -22,7 +22,7 @@
#if defined(__i386__) && defined(__GNUC__)
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
- long __tmpvar; \
+ zend_long __tmpvar; \
__asm__ ("imul %3,%0\n" \
"adc $0,%1" \
: "=r"(__tmpvar),"=r"(usedval) \
@@ -34,7 +34,7 @@
#elif defined(__x86_64__) && defined(__GNUC__)
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
- long __tmpvar; \
+ zend_long __tmpvar; \
__asm__ ("imul %3,%0\n" \
"adc $0,%1" \
: "=r"(__tmpvar),"=r"(usedval) \
@@ -46,7 +46,7 @@
#elif defined(__arm__) && defined(__GNUC__)
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
- long __tmpvar; \
+ zend_long __tmpvar; \
__asm__("smull %0, %1, %2, %3\n" \
"sub %1, %1, %0, asr #31" \
: "=r"(__tmpvar), "=r"(usedval) \
@@ -58,7 +58,7 @@
#elif defined(__aarch64__) && defined(__GNUC__)
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
- long __tmpvar; \
+ zend_long __tmpvar; \
__asm__("mul %0, %2, %3\n" \
"smulh %1, %2, %3\n" \
"sub %1, %1, %0, asr #63\n" \
@@ -68,11 +68,24 @@
else (lval) = __tmpvar; \
} while (0)
-#elif SIZEOF_LONG == 4 && defined(HAVE_ZEND_LONG64)
+#elif defined(ZEND_WIN32)
+
+#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
+ zend_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)
+
+#elif SIZEOF_ZEND_INT == 4 && defined(HAVE_ZEND_LONG64)
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
zend_long64 __result = (zend_long64) (a) * (zend_long64) (b); \
- if (__result > LONG_MAX || __result < LONG_MIN) { \
+ if (__result > ZEND_INT_MAX || __result < ZEND_INT_MIN) { \
(dval) = (double) __result; \
(usedval) = 1; \
} else { \
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index d7d8bf0a52..a91f60c7e4 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -401,12 +401,12 @@ ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_inf
if (prop_info_name->val[0] == 0) {
zend_unmangle_property_name_ex(prop_info_name->val, prop_info_name->len, &class_name, &prop_name, &prop_name_len);
- member = STR_INIT(prop_name, prop_name_len, 0);
+ member = zend_string_init(prop_name, prop_name_len, 0);
} else {
- member = STR_COPY(prop_info_name);
+ member = zend_string_copy(prop_info_name);
}
property_info = zend_get_property_info_quick(zobj->ce, member, 1, NULL TSRMLS_CC);
- STR_RELEASE(member);
+ zend_string_release(member);
if (!property_info) {
return FAILURE;
}
@@ -423,7 +423,7 @@ ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_inf
}
/* }}} */
-static long *zend_get_property_guard(zend_object *zobj, zend_property_info *property_info, zval *member) /* {{{ */
+static zend_long *zend_get_property_guard(zend_object *zobj, zend_property_info *property_info, zval *member) /* {{{ */
{
zend_property_info info;
zval stub, *guard;
@@ -437,7 +437,7 @@ static long *zend_get_property_guard(zend_object *zobj, zend_property_info *prop
zend_unmangle_property_name(property_info->name->val, property_info->name->len, &class_name, &prop_name);
if (class_name) {
/* use unmangled name for protected properties */
- str = info.name = STR_INIT(prop_name, strlen(prop_name), 0);
+ str = info.name = zend_string_init(prop_name, strlen(prop_name), 0);
property_info = &info;
}
}
@@ -446,7 +446,7 @@ static long *zend_get_property_guard(zend_object *zobj, zend_property_info *prop
zend_hash_init(zobj->guards, 8, NULL, NULL, 0);
} else if ((guard = zend_hash_find(zobj->guards, property_info->name)) != NULL) {
if (str) {
- STR_RELEASE(str);
+ zend_string_release(str);
}
return &Z_LVAL_P(guard);
}
@@ -454,7 +454,7 @@ static long *zend_get_property_guard(zend_object *zobj, zend_property_info *prop
ZVAL_LONG(&stub, 0);
guard = zend_hash_add_new(zobj->guards, property_info->name, &stub);
if (str) {
- STR_RELEASE(str);
+ zend_string_release(str);
}
return &Z_LVAL_P(guard);
}
@@ -501,7 +501,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_
/* magic get */
if (zobj->ce->__get) {
- long *guard = zend_get_property_guard(zobj, property_info, member);
+ zend_long *guard = zend_get_property_guard(zobj, property_info, member);
if (!((*guard) & IN_GET)) {
zval tmp_object;
@@ -635,7 +635,7 @@ found:
/* magic set */
if (zobj->ce->__set) {
- long *guard = zend_get_property_guard(zobj, property_info, member);
+ zend_long *guard = zend_get_property_guard(zobj, property_info, member);
if (!((*guard) & IN_SET)) {
zval tmp_object;
@@ -778,7 +778,7 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type,
zval tmp_member;
zval *retval, tmp;
zend_property_info *property_info;
- long *guard;
+ zend_long *guard;
zobj = Z_OBJ_P(object);
@@ -875,7 +875,7 @@ static void zend_std_unset_property(zval *object, zval *member, void **cache_slo
/* magic unset */
if (zobj->ce->__unset) {
- long *guard = zend_get_property_guard(zobj, property_info, member);
+ zend_long *guard = zend_get_property_guard(zobj, property_info, member);
if (!((*guard) & IN_UNSET)) {
zval tmp_object;
@@ -1046,9 +1046,9 @@ static inline union _zend_function *zend_get_user_call_function(zend_class_entry
//??? keep compatibility for "\0" characters
//??? see: Zend/tests/bug46238.phpt
if (UNEXPECTED(strlen(method_name->val) != method_name->len)) {
- call_user_call->function_name = STR_INIT(method_name->val, strlen(method_name->val), 0);
+ call_user_call->function_name = zend_string_init(method_name->val, strlen(method_name->val), 0);
} else {
- call_user_call->function_name = STR_COPY(method_name);
+ call_user_call->function_name = zend_string_copy(method_name);
}
return (union _zend_function *)call_user_call;
@@ -1185,9 +1185,9 @@ static inline union _zend_function *zend_get_user_callstatic_function(zend_class
//??? keep compatibility for "\0" characters
//??? see: Zend/tests/bug46238.phpt
if (UNEXPECTED(strlen(method_name->val) != method_name->len)) {
- callstatic_user_call->function_name = STR_INIT(method_name->val, strlen(method_name->val), 0);
+ callstatic_user_call->function_name = zend_string_init(method_name->val, strlen(method_name->val), 0);
} else {
- callstatic_user_call->function_name = STR_COPY(method_name);
+ callstatic_user_call->function_name = zend_string_copy(method_name);
}
return (zend_function *)callstatic_user_call;
@@ -1205,7 +1205,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
if (EXPECTED(key != NULL)) {
lc_function_name = Z_STR_P(key);
} else {
- lc_function_name = STR_ALLOC(function_name->len, 0);
+ lc_function_name = zend_string_alloc(function_name->len, 0);
zend_str_tolower_copy(lc_function_name->val, function_name->val, function_name->len);
}
@@ -1226,7 +1226,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
fbc = Z_FUNC_P(func);
} else {
if (UNEXPECTED(!key)) {
- STR_FREE(lc_function_name);
+ zend_string_free(lc_function_name);
}
if (ce->__call &&
Z_OBJ(EG(This)) &&
@@ -1278,7 +1278,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
}
if (UNEXPECTED(!key)) {
- STR_FREE(lc_function_name);
+ zend_string_free(lc_function_name);
}
return fbc;
@@ -1485,7 +1485,7 @@ found:
result = 0;
if ((has_set_exists != 2) && zobj->ce->__isset) {
- long *guard = zend_get_property_guard(zobj, property_info, member);
+ zend_long *guard = zend_get_property_guard(zobj, property_info, member);
if (!((*guard) & IN_ISSET)) {
zval rv;
@@ -1546,7 +1546,7 @@ zend_string* zend_std_object_get_class_name(const zend_object *zobj, int parent
ce = zobj->ce;
}
- return STR_COPY(ce->name);
+ return zend_string_copy(ce->name);
}
/* }}} */
diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h
index ac3d962071..ee6c9d9e5b 100644
--- a/Zend/zend_object_handlers.h
+++ b/Zend/zend_object_handlers.h
@@ -106,7 +106,7 @@ typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type TSRMLS_D
/* updates *count to hold the number of elements present and returns SUCCESS.
* Returns FAILURE if the object does not have any sense of overloaded dimensions */
-typedef int (*zend_object_count_elements_t)(zval *object, long *count TSRMLS_DC);
+typedef int (*zend_object_count_elements_t)(zval *object, zend_long *count TSRMLS_DC);
typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zend_object **obj_ptr TSRMLS_DC);
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c
index af0070c5fb..9eea73deaf 100644
--- a/Zend/zend_objects.c
+++ b/Zend/zend_objects.c
@@ -149,7 +149,7 @@ ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *o
}
if (old_object->properties) {
zval *prop, new_prop;
- ulong num_key;
+ zend_ulong num_key;
zend_string *key;
if (!new_object->properties) {
diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c
index c1b2f3ba6e..50930df20d 100644
--- a/Zend/zend_objects_API.c
+++ b/Zend/zend_objects_API.c
@@ -25,7 +25,7 @@
#include "zend_API.h"
#include "zend_objects_API.h"
-ZEND_API void zend_objects_store_init(zend_objects_store *objects, zend_uint init_size)
+ZEND_API void zend_objects_store_init(zend_objects_store *objects, uint32_t init_size)
{
objects->object_buckets = (zend_object **) emalloc(init_size * sizeof(zend_object*));
objects->top = 1; /* Skip 0 so that handles are true */
@@ -42,7 +42,7 @@ ZEND_API void zend_objects_store_destroy(zend_objects_store *objects)
ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TSRMLS_DC)
{
- zend_uint i;
+ uint32_t i;
for (i = 1; i < objects->top ; i++) {
zend_object *obj = objects->object_buckets[i];
@@ -60,7 +60,7 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TS
ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects TSRMLS_DC)
{
- zend_uint i;
+ uint32_t i;
if (!objects->object_buckets) {
return;
@@ -76,7 +76,7 @@ ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects TSR
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects TSRMLS_DC)
{
- zend_uint i;
+ uint32_t i;
/* Free object properties but don't free object their selves */
for (i = objects->top - 1; i > 0 ; i--) {
@@ -134,7 +134,7 @@ ZEND_API void zend_objects_store_put(zend_object *object TSRMLS_DC)
ZEND_API void zend_objects_store_free(zend_object *object TSRMLS_DC) /* {{{ */
{
- zend_uint handle = object->handle;
+ uint32_t handle = object->handle;
void *ptr = ((char*)object) - object->handlers->offset;
GC_REMOVE_FROM_BUFFER(object);
@@ -169,7 +169,7 @@ ZEND_API void zend_objects_store_del(zend_object *object TSRMLS_DC) /* {{{ */
}
if (GC_REFCOUNT(object) == 0) {
- zend_uint handle = object->handle;
+ uint32_t handle = object->handle;
void *ptr;
EG(objects_store).object_buckets[handle] = SET_OBJ_INVALID(object);
diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h
index 4d6afe6842..df22a26cc9 100644
--- a/Zend/zend_objects_API.h
+++ b/Zend/zend_objects_API.h
@@ -48,14 +48,14 @@
typedef struct _zend_objects_store {
zend_object **object_buckets;
- zend_uint top;
- zend_uint size;
+ uint32_t top;
+ uint32_t size;
int free_list_head;
} zend_objects_store;
/* Global store handling functions */
BEGIN_EXTERN_C()
-ZEND_API void zend_objects_store_init(zend_objects_store *objects, zend_uint init_size);
+ZEND_API void zend_objects_store_init(zend_objects_store *objects, uint32_t init_size);
ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TSRMLS_DC);
ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects TSRMLS_DC);
ZEND_API void zend_objects_store_destroy(zend_objects_store *objects);
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index 8bdb8d13ae..a893a34078 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -43,7 +43,7 @@ static void zend_extension_op_array_dtor_handler(zend_extension *extension, zend
}
}
-static void op_array_alloc_ops(zend_op_array *op_array, zend_uint size)
+static void op_array_alloc_ops(zend_op_array *op_array, uint32_t size)
{
op_array->opcodes = erealloc(op_array->opcodes, size * sizeof(zend_op));
}
@@ -59,7 +59,7 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz
initial_ops_size = INITIAL_INTERACTIVE_OP_ARRAY_SIZE;
}
- op_array->refcount = (zend_uint *) emalloc(sizeof(zend_uint));
+ op_array->refcount = (uint32_t *) emalloc(sizeof(uint32_t));
*op_array->refcount = 1;
op_array->last = 0;
op_array->opcodes = NULL;
@@ -114,7 +114,7 @@ ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC)
break;
case ZEND_INTERNAL_FUNCTION:
if (function->common.function_name) {
- STR_RELEASE(function->common.function_name);
+ zend_string_release(function->common.function_name);
}
/* do nothing */
break;
@@ -199,16 +199,16 @@ void _destroy_zend_class_traits_info(zend_class_entry *ce)
while (ce->trait_aliases[i]) {
if (ce->trait_aliases[i]->trait_method) {
if (ce->trait_aliases[i]->trait_method->method_name) {
- STR_RELEASE(ce->trait_aliases[i]->trait_method->method_name);
+ zend_string_release(ce->trait_aliases[i]->trait_method->method_name);
}
if (ce->trait_aliases[i]->trait_method->class_name) {
- STR_RELEASE(ce->trait_aliases[i]->trait_method->class_name);
+ zend_string_release(ce->trait_aliases[i]->trait_method->class_name);
}
efree(ce->trait_aliases[i]->trait_method);
}
if (ce->trait_aliases[i]->alias) {
- STR_RELEASE(ce->trait_aliases[i]->alias);
+ zend_string_release(ce->trait_aliases[i]->alias);
}
efree(ce->trait_aliases[i]);
@@ -222,8 +222,8 @@ void _destroy_zend_class_traits_info(zend_class_entry *ce)
size_t i = 0;
while (ce->trait_precedences[i]) {
- STR_RELEASE(ce->trait_precedences[i]->trait_method->method_name);
- STR_RELEASE(ce->trait_precedences[i]->trait_method->class_name);
+ zend_string_release(ce->trait_precedences[i]->trait_method->method_name);
+ zend_string_release(ce->trait_precedences[i]->trait_method->class_name);
efree(ce->trait_precedences[i]->trait_method);
if (ce->trait_precedences[i]->exclude_from_classes) {
@@ -267,14 +267,14 @@ ZEND_API void destroy_zend_class(zval *zv)
efree(ce->default_static_members_table);
}
zend_hash_destroy(&ce->properties_info);
- STR_RELEASE(ce->name);
+ zend_string_release(ce->name);
zend_hash_destroy(&ce->function_table);
zend_hash_destroy(&ce->constants_table);
if (ce->num_interfaces > 0 && ce->interfaces) {
efree(ce->interfaces);
}
if (ce->info.user.doc_comment) {
- STR_RELEASE(ce->info.user.doc_comment);
+ zend_string_release(ce->info.user.doc_comment);
}
_destroy_zend_class_traits_info(ce);
@@ -300,7 +300,7 @@ ZEND_API void destroy_zend_class(zval *zv)
free(ce->default_static_members_table);
}
zend_hash_destroy(&ce->properties_info);
- STR_RELEASE(ce->name);
+ zend_string_release(ce->name);
zend_hash_destroy(&ce->function_table);
zend_hash_destroy(&ce->constants_table);
if (ce->num_interfaces > 0) {
@@ -322,7 +322,7 @@ ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC)
{
zval *literal = op_array->literals;
zval *end;
- zend_uint i;
+ uint32_t i;
if (op_array->static_variables) {
zend_hash_destroy(op_array->static_variables);
@@ -343,7 +343,7 @@ ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC)
i = op_array->last_var;
while (i > 0) {
i--;
- STR_RELEASE(op_array->vars[i]);
+ zend_string_release(op_array->vars[i]);
}
efree(op_array->vars);
}
@@ -359,10 +359,10 @@ ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC)
efree(op_array->opcodes);
if (op_array->function_name) {
- STR_RELEASE(op_array->function_name);
+ zend_string_release(op_array->function_name);
}
if (op_array->doc_comment) {
- STR_RELEASE(op_array->doc_comment);
+ zend_string_release(op_array->doc_comment);
}
if (op_array->brk_cont_array) {
efree(op_array->brk_cont_array);
@@ -393,7 +393,7 @@ void init_op(zend_op *op TSRMLS_DC)
zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC)
{
- zend_uint next_op_num = op_array->last++;
+ uint32_t next_op_num = op_array->last++;
zend_op *next_op;
if (next_op_num >= CG(context).opcodes_size) {
@@ -456,9 +456,9 @@ 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)
+static void zend_check_finally_breakout(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num TSRMLS_DC)
{
- zend_uint i;
+ uint32_t i;
for (i = 0; i < op_array->last_try_catch; i++) {
if ((op_num < op_array->try_catch_array[i].finally_op ||
@@ -481,10 +481,10 @@ static void zend_check_finally_breakout(zend_op_array *op_array, zend_uint op_nu
}
}
-static void zend_adjust_fast_call(zend_op_array *op_array, zend_uint fast_call, zend_uint start, zend_uint end TSRMLS_DC)
+static void zend_adjust_fast_call(zend_op_array *op_array, uint32_t fast_call, uint32_t start, uint32_t end TSRMLS_DC)
{
int i;
- zend_uint op_num = 0;
+ uint32_t op_num = 0;
for (i = 0; i < op_array->last_try_catch; i++) {
if (op_array->try_catch_array[i].finally_op > start
@@ -502,10 +502,10 @@ static void zend_adjust_fast_call(zend_op_array *op_array, zend_uint fast_call,
}
}
-static void zend_resolve_fast_call(zend_op_array *op_array, zend_uint fast_call, zend_uint op_num TSRMLS_DC)
+static void zend_resolve_fast_call(zend_op_array *op_array, uint32_t fast_call, uint32_t op_num TSRMLS_DC)
{
int i;
- zend_uint finally_op_num = 0;
+ uint32_t finally_op_num = 0;
for (i = 0; i < op_array->last_try_catch; i++) {
if (op_num >= op_array->try_catch_array[i].finally_op
@@ -524,13 +524,13 @@ static void zend_resolve_fast_call(zend_op_array *op_array, zend_uint fast_call,
}
}
-static void zend_resolve_finally_call(zend_op_array *op_array, zend_uint op_num, zend_uint dst_num TSRMLS_DC)
+static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num TSRMLS_DC)
{
- zend_uint start_op;
+ uint32_t start_op;
zend_op *opline;
- zend_uint i = op_array->last_try_catch;
+ uint32_t i = op_array->last_try_catch;
- if (dst_num != (zend_uint)-1) {
+ if (dst_num != (uint32_t)-1) {
zend_check_finally_breakout(op_array, op_num, dst_num TSRMLS_CC);
}
@@ -602,10 +602,10 @@ static void zend_resolve_finally_call(zend_op_array *op_array, zend_uint op_num,
}
}
-static void zend_resolve_finally_ret(zend_op_array *op_array, zend_uint op_num TSRMLS_DC)
+static void zend_resolve_finally_ret(zend_op_array *op_array, uint32_t op_num TSRMLS_DC)
{
int i;
- zend_uint catch_op_num = 0, finally_op_num = 0;
+ uint32_t 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) {
@@ -632,7 +632,7 @@ static void zend_resolve_finally_ret(zend_op_array *op_array, zend_uint op_num T
static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC)
{
- zend_uint i, j;
+ uint32_t i, j;
zend_op *opline;
for (i = 0, j = op_array->last; i < j; i++) {
@@ -641,7 +641,7 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC)
case ZEND_RETURN:
case ZEND_RETURN_BY_REF:
case ZEND_GENERATOR_RETURN:
- zend_resolve_finally_call(op_array, i, (zend_uint)-1 TSRMLS_CC);
+ zend_resolve_finally_call(op_array, i, (uint32_t)-1 TSRMLS_CC);
break;
case ZEND_BRK:
case ZEND_CONT:
@@ -663,7 +663,7 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC)
}
case ZEND_GOTO:
if (Z_TYPE(op_array->literals[opline->op2.constant]) != IS_LONG) {
- zend_uint num = opline->op2.constant;
+ uint32_t num = opline->op2.constant;
opline->op2.zv = &op_array->literals[opline->op2.constant];
zend_resolve_goto_label(op_array, opline, 1 TSRMLS_CC);
opline->op2.constant = num;
@@ -719,20 +719,20 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC)
if (opline->op1_type == IS_CONST) {
opline->op1.zv = &op_array->literals[opline->op1.constant];
} else if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
- opline->op1.var = (zend_uint)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->op1.var);
+ opline->op1.var = (uint32_t)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->op1.var);
}
if (opline->op2_type == IS_CONST) {
opline->op2.zv = &op_array->literals[opline->op2.constant];
} else if (opline->op2_type & (IS_VAR|IS_TMP_VAR)) {
- opline->op2.var = (zend_uint)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->op2.var);
+ opline->op2.var = (uint32_t)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->op2.var);
}
if (opline->result_type & (IS_VAR|IS_TMP_VAR)) {
- opline->result.var = (zend_uint)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->result.var);
+ opline->result.var = (uint32_t)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->result.var);
}
switch (opline->opcode) {
case ZEND_DECLARE_INHERITED_CLASS:
case ZEND_DECLARE_INHERITED_CLASS_DELAYED:
- opline->extended_value = (zend_uint)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->extended_value);
+ opline->extended_value = (uint32_t)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->extended_value);
break;
case ZEND_GOTO:
if (Z_TYPE_P(opline->op2.zv) != IS_LONG) {
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 921d71b685..8aa3808431 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -86,7 +86,7 @@ ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */
if (!str_len) {
str_len = strlen(str);
}
- retval = strtol(str, NULL, 0);
+ retval = ZEND_STRTOL(str, NULL, 0);
if (str_len>0) {
switch (str[str_len-1]) {
case 'g':
@@ -107,14 +107,14 @@ ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */
}
/* }}} */
-ZEND_API long zend_atol(const char *str, int str_len) /* {{{ */
+ZEND_API zend_long zend_atol(const char *str, int str_len) /* {{{ */
{
- long retval;
+ zend_long retval;
if (!str_len) {
str_len = strlen(str);
}
- retval = strtol(str, NULL, 0);
+ retval = ZEND_STRTOL(str, NULL, 0);
if (str_len>0) {
switch (str[str_len-1]) {
case 'g':
@@ -135,7 +135,7 @@ ZEND_API long zend_atol(const char *str, int str_len) /* {{{ */
}
/* }}} */
-ZEND_API double zend_string_to_double(const char *number, zend_uint length) /* {{{ */
+ZEND_API double zend_string_to_double(const char *number, uint32_t length) /* {{{ */
{
double divisor = 10.0;
double result = 0.0;
@@ -201,7 +201,7 @@ try_again:
if ((Z_TYPE_INFO_P(op)=is_numeric_string(str->val, str->len, &Z_LVAL_P(op), &Z_DVAL_P(op), 1)) == 0) {
ZVAL_LONG(op, 0);
}
- STR_RELEASE(str);
+ zend_string_release(str);
break;
}
case IS_NULL:
@@ -213,13 +213,13 @@ try_again:
break;
case IS_RESOURCE:
{
- long l = Z_RES_HANDLE_P(op);
+ zend_long l = Z_RES_HANDLE_P(op);
zval_ptr_dtor(op);
ZVAL_LONG(op, l);
}
break;
case IS_OBJECT:
- convert_to_long_base(op, 10);
+ convert_to_int_base(op, 10);
break;
}
}
@@ -256,7 +256,7 @@ try_again:
break; \
case IS_OBJECT: \
ZVAL_DUP(&(holder), op); \
- convert_to_long_base(&(holder), 10); \
+ convert_to_int_base(&(holder), 10); \
if (Z_TYPE(holder) == IS_LONG) { \
(op) = &(holder); \
} \
@@ -266,10 +266,10 @@ try_again:
/* }}} */
-/* {{{ zendi_convert_to_long */
-#define zendi_convert_to_long(op, holder, result) \
+/* {{{ zendi_convert_to_int */
+#define zendi_convert_to_int(op, holder, result) \
if (op == result) { \
- convert_to_long(op); \
+ convert_to_int(op); \
} else if (Z_TYPE_P(op) != IS_LONG) { \
switch (Z_TYPE_P(op)) { \
case IS_NULL: \
@@ -283,14 +283,14 @@ try_again:
ZVAL_LONG(&holder, zend_dval_to_lval(Z_DVAL_P(op)));\
break; \
case IS_STRING: \
- ZVAL_LONG(&holder, strtol(Z_STRVAL_P(op), NULL, 10));\
+ ZVAL_LONG(&holder, ZEND_STRTOL(Z_STRVAL_P(op), NULL, 10));\
break; \
case IS_ARRAY: \
ZVAL_LONG(&holder, zend_hash_num_elements(Z_ARRVAL_P(op))?1:0); \
break; \
case IS_OBJECT: \
ZVAL_DUP(&(holder), (op)); \
- convert_to_long_base(&(holder), 10); \
+ convert_to_int_base(&(holder), 10); \
break; \
case IS_RESOURCE: \
ZVAL_LONG(&holder, Z_RES_HANDLE_P(op)); \
@@ -368,17 +368,17 @@ try_again:
/* }}} */
-ZEND_API void convert_to_long(zval *op) /* {{{ */
+ZEND_API void convert_to_int(zval *op) /* {{{ */
{
if (Z_TYPE_P(op) != IS_LONG) {
- convert_to_long_base(op, 10);
+ convert_to_int_base(op, 10);
}
}
/* }}} */
-ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */
+ZEND_API void convert_to_int_base(zval *op, int base) /* {{{ */
{
- long tmp;
+ zend_long tmp;
switch (Z_TYPE_P(op)) {
case IS_NULL:
@@ -389,7 +389,7 @@ ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */
ZVAL_LONG(op, 1);
break;
case IS_RESOURCE: {
- long l = Z_RES_HANDLE_P(op);
+ zend_long l = Z_RES_HANDLE_P(op);
zval_ptr_dtor(op);
ZVAL_LONG(op, l);
}
@@ -406,7 +406,7 @@ ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */
zend_string *str = Z_STR_P(op);
ZVAL_LONG(op, strtol(str->val, NULL, base));
- STR_RELEASE(str);
+ zend_string_release(str);
}
break;
case IS_ARRAY:
@@ -419,7 +419,7 @@ ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */
zval dst;
TSRMLS_FETCH();
- convert_object_to_type(op, &dst, IS_LONG, convert_to_long);
+ convert_object_to_type(op, &dst, IS_LONG, convert_to_int);
zval_dtor(op);
if (Z_TYPE(dst) == IS_LONG) {
@@ -464,7 +464,7 @@ ZEND_API void convert_to_double(zval *op) /* {{{ */
zend_string *str = Z_STR_P(op);
ZVAL_DOUBLE(op, zend_strtod(str->val, NULL));
- STR_RELEASE(str);
+ zend_string_release(str);
}
break;
case IS_ARRAY:
@@ -527,7 +527,7 @@ ZEND_API void convert_to_boolean(zval *op) /* {{{ */
ZVAL_BOOL(op, 0);
break;
case IS_RESOURCE: {
- long l = (Z_RES_HANDLE_P(op) ? 1 : 0);
+ zend_long l = (Z_RES_HANDLE_P(op) ? 1 : 0);
zval_ptr_dtor(op);
ZVAL_BOOL(op, l);
@@ -549,7 +549,7 @@ ZEND_API void convert_to_boolean(zval *op) /* {{{ */
} else {
ZVAL_BOOL(op, 1);
}
- STR_RELEASE(str);
+ zend_string_release(str);
}
break;
case IS_ARRAY:
@@ -593,18 +593,18 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */
break;
}
case IS_TRUE:
- ZVAL_NEW_STR(op, STR_INIT("1", 1, 0));
+ ZVAL_NEW_STR(op, zend_string_init("1", 1, 0));
break;
case IS_STRING:
break;
case IS_RESOURCE: {
char buf[sizeof("Resource id #") + MAX_LENGTH_OF_LONG];
- int len = snprintf(buf, sizeof(buf), "Resource id #%ld", Z_RES_HANDLE_P(op));
- ZVAL_NEW_STR(op, STR_INIT(buf, len, 0));
+ int len = snprintf(buf, sizeof(buf), "Resource id #" ZEND_LONG_FMT, Z_RES_HANDLE_P(op));
+ ZVAL_NEW_STR(op, zend_string_init(buf, len, 0));
break;
}
case IS_LONG: {
- ZVAL_NEW_STR(op, zend_long_to_str(Z_LVAL_P(op)));
+ ZVAL_NEW_STR(op, zend_longo_str(Z_LVAL_P(op)));
break;
}
case IS_DOUBLE: {
@@ -620,7 +620,7 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */
case IS_ARRAY:
zend_error(E_NOTICE, "Array to string conversion");
zval_dtor(op);
- ZVAL_NEW_STR(op, STR_INIT("Array", sizeof("Array")-1, 0));
+ ZVAL_NEW_STR(op, zend_string_init("Array", sizeof("Array")-1, 0));
break;
case IS_OBJECT: {
zval dst;
@@ -634,7 +634,7 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */
} else {
zend_error(E_NOTICE, "Object of class %s to string conversion", Z_OBJCE_P(op)->name->val);
zval_dtor(op);
- ZVAL_NEW_STR(op, STR_INIT("Object", sizeof("Object")-1, 0));
+ ZVAL_NEW_STR(op, zend_string_init("Object", sizeof("Object")-1, 0));
}
break;
}
@@ -736,7 +736,7 @@ ZEND_API void convert_to_object(zval *op) /* {{{ */
}
/* }}} */
-ZEND_API void multi_convert_to_long_ex(int argc, ...) /* {{{ */
+ZEND_API void multi_convert_to_int_ex(int argc, ...) /* {{{ */
{
zval *arg;
va_list ap;
@@ -745,7 +745,7 @@ ZEND_API void multi_convert_to_long_ex(int argc, ...) /* {{{ */
while (argc--) {
arg = va_arg(ap, zval *);
- convert_to_long_ex(arg);
+ convert_to_int_ex(arg);
}
va_end(ap);
@@ -784,7 +784,7 @@ ZEND_API void multi_convert_to_string_ex(int argc, ...) /* {{{ */
}
/* }}} */
-ZEND_API long _zval_get_long_func(zval *op TSRMLS_DC) /* {{{ */
+ZEND_API zend_long _zval_get_long_func(zval *op TSRMLS_DC) /* {{{ */
{
try_again:
switch (Z_TYPE_P(op)) {
@@ -800,13 +800,13 @@ try_again:
case IS_DOUBLE:
return zend_dval_to_lval(Z_DVAL_P(op));
case IS_STRING:
- return strtol(Z_STRVAL_P(op), NULL, 10);
+ return ZEND_STRTOL(Z_STRVAL_P(op), NULL, 10);
case IS_ARRAY:
return zend_hash_num_elements(Z_ARRVAL_P(op)) ? 1 : 0;
case IS_OBJECT:
{
zval dst;
- convert_object_to_type(op, &dst, IS_LONG, convert_to_long);
+ convert_object_to_type(op, &dst, IS_LONG, convert_to_int);
if (Z_TYPE(dst) == IS_LONG) {
return Z_LVAL(dst);
} else {
@@ -872,25 +872,25 @@ try_again:
case IS_FALSE:
return STR_EMPTY_ALLOC();
case IS_STRING:
- return STR_COPY(Z_STR_P(op));
+ return zend_string_copy(Z_STR_P(op));
case IS_TRUE:
- return STR_INIT("1", 1, 0);
+ return zend_string_init("1", 1, 0);
case IS_RESOURCE: {
char buf[sizeof("Resource id #") + MAX_LENGTH_OF_LONG];
int len;
- len = snprintf(buf, sizeof(buf), "Resource id #%ld", Z_RES_HANDLE_P(op));
- return STR_INIT(buf, len, 0);
+ len = snprintf(buf, sizeof(buf), "Resource id #" ZEND_LONG_FMT, Z_RES_HANDLE_P(op));
+ return zend_string_init(buf, len, 0);
}
case IS_LONG: {
- return zend_long_to_str(Z_LVAL_P(op));
+ return zend_longo_str(Z_LVAL_P(op));
}
case IS_DOUBLE: {
return zend_strpprintf(0, "%.*G", (int) EG(precision), Z_DVAL_P(op));
}
case IS_ARRAY:
zend_error(E_NOTICE, "Array to string conversion");
- return STR_INIT("Array", sizeof("Array")-1, 0);
+ return zend_string_init("Array", sizeof("Array")-1, 0);
case IS_OBJECT: {
zval tmp;
if (Z_OBJ_HT_P(op)->cast_object) {
@@ -926,7 +926,7 @@ ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
while (1) {
switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) {
case TYPE_PAIR(IS_LONG, IS_LONG): {
- long lval = Z_LVAL_P(op1) + Z_LVAL_P(op2);
+ zend_long lval = Z_LVAL_P(op1) + Z_LVAL_P(op2);
/* check for overflow by comparing sign bits */
if ((Z_LVAL_P(op1) & LONG_SIGN_MASK) == (Z_LVAL_P(op2) & LONG_SIGN_MASK)
@@ -990,7 +990,7 @@ ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
while (1) {
switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) {
case TYPE_PAIR(IS_LONG, IS_LONG): {
- long lval = Z_LVAL_P(op1) - Z_LVAL_P(op2);
+ zend_long lval = Z_LVAL_P(op1) - Z_LVAL_P(op2);
/* check for overflow by comparing sign bits */
if ((Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(op2) & LONG_SIGN_MASK)
@@ -1043,7 +1043,7 @@ ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
while (1) {
switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) {
case TYPE_PAIR(IS_LONG, IS_LONG): {
- long overflow;
+ zend_long overflow;
ZEND_SIGNED_MULTIPLY_LONG(Z_LVAL_P(op1),Z_LVAL_P(op2), Z_LVAL_P(result),Z_DVAL_P(result),overflow);
Z_TYPE_INFO_P(result) = overflow ? IS_DOUBLE : IS_LONG;
@@ -1091,7 +1091,7 @@ ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) {
case TYPE_PAIR(IS_LONG, IS_LONG):
if (Z_LVAL_P(op2) >= 0) {
- long l1 = 1, l2 = Z_LVAL_P(op1), i = Z_LVAL_P(op2);
+ zend_long l1 = 1, l2 = Z_LVAL_P(op1), i = Z_LVAL_P(op2);
if (i == 0) {
ZVAL_LONG(result, 1L);
@@ -1102,7 +1102,7 @@ ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
}
while (i >= 1) {
- long overflow;
+ zend_long overflow;
double dval = 0.0;
if (i % 2) {
@@ -1182,9 +1182,9 @@ ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
zend_error(E_WARNING, "Division by zero");
ZVAL_BOOL(result, 0);
return FAILURE; /* division by zero */
- } else if (Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN) {
+ } else if (Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == ZEND_LONG_MIN) {
/* Prevent overflow error/crash */
- ZVAL_DOUBLE(result, (double) LONG_MIN / -1);
+ ZVAL_DOUBLE(result, (double) ZEND_LONG_MIN / -1);
return SUCCESS;
}
if (Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0) { /* integer */
@@ -1244,14 +1244,14 @@ ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
- long op1_lval;
+ zend_long op1_lval;
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_MOD);
- zendi_convert_to_long(op1, op1_copy, result);
+ zendi_convert_to_int(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
- zendi_convert_to_long(op2, op2_copy, result);
+ zendi_convert_to_int(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
@@ -1276,7 +1276,7 @@ ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
- long op1_lval;
+ zend_long op1_lval;
if ((Z_TYPE_P(op1) != IS_FALSE && Z_TYPE_P(op1) != IS_TRUE) ||
(Z_TYPE_P(op2) != IS_FALSE && Z_TYPE_P(op2) != IS_TRUE)) {
@@ -1324,10 +1324,10 @@ ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */
ZVAL_LONG(result, ~zend_dval_to_lval(Z_DVAL_P(op1)));
return SUCCESS;
case IS_STRING: {
- int i;
+ size_t i;
zval op1_copy = *op1;
- ZVAL_NEW_STR(result, STR_ALLOC(Z_STRLEN(op1_copy), 0));
+ ZVAL_NEW_STR(result, zend_string_alloc(Z_STRLEN(op1_copy), 0));
for (i = 0; i < Z_STRLEN(op1_copy); i++) {
Z_STRVAL_P(result)[i] = ~Z_STRVAL(op1_copy)[i];
}
@@ -1346,12 +1346,12 @@ ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */
ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
- long op1_lval;
+ zend_long op1_lval;
if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) {
zval *longer, *shorter;
zend_string *str;
- int i;
+ size_t i;
if (Z_STRLEN_P(op1) >= Z_STRLEN_P(op2)) {
longer = op1;
@@ -1361,13 +1361,13 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
shorter = op1;
}
- str = STR_ALLOC(Z_STRLEN_P(longer), 0);
+ str = zend_string_alloc(Z_STRLEN_P(longer), 0);
for (i = 0; i < Z_STRLEN_P(shorter); i++) {
str->val[i] = Z_STRVAL_P(longer)[i] | Z_STRVAL_P(shorter)[i];
}
memcpy(str->val + i, Z_STRVAL_P(longer) + i, Z_STRLEN_P(longer) - i + 1);
if (result==op1) {
- STR_RELEASE(Z_STR_P(result));
+ zend_string_release(Z_STR_P(result));
}
ZVAL_NEW_STR(result, str);
return SUCCESS;
@@ -1376,9 +1376,9 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_BW_OR);
- zendi_convert_to_long(op1, op1_copy, result);
+ zendi_convert_to_int(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
- zendi_convert_to_long(op2, op2_copy, result);
+ zendi_convert_to_int(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
@@ -1391,12 +1391,12 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
- long op1_lval;
+ zend_long op1_lval;
if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) {
zval *longer, *shorter;
zend_string *str;
- int i;
+ size_t i;
if (Z_STRLEN_P(op1) >= Z_STRLEN_P(op2)) {
longer = op1;
@@ -1406,13 +1406,13 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
shorter = op1;
}
- str = STR_ALLOC(Z_STRLEN_P(shorter), 0);
+ str = zend_string_alloc(Z_STRLEN_P(shorter), 0);
for (i = 0; i < Z_STRLEN_P(shorter); i++) {
str->val[i] = Z_STRVAL_P(shorter)[i] & Z_STRVAL_P(longer)[i];
}
str->val[i] = 0;
if (result==op1) {
- STR_RELEASE(Z_STR_P(result));
+ zend_string_release(Z_STR_P(result));
}
ZVAL_NEW_STR(result, str);
return SUCCESS;
@@ -1421,9 +1421,9 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_BW_AND);
- zendi_convert_to_long(op1, op1_copy, result);
+ zendi_convert_to_int(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
- zendi_convert_to_long(op2, op2_copy, result);
+ zendi_convert_to_int(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
@@ -1436,12 +1436,12 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
- long op1_lval;
+ zend_long op1_lval;
if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) {
zval *longer, *shorter;
zend_string *str;
- int i;
+ size_t i;
if (Z_STRLEN_P(op1) >= Z_STRLEN_P(op2)) {
longer = op1;
@@ -1451,13 +1451,13 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
shorter = op1;
}
- str = STR_ALLOC(Z_STRLEN_P(shorter), 0);
+ str = zend_string_alloc(Z_STRLEN_P(shorter), 0);
for (i = 0; i < Z_STRLEN_P(shorter); i++) {
str->val[i] = Z_STRVAL_P(shorter)[i] ^ Z_STRVAL_P(longer)[i];
}
str->val[i] = 0;
if (result==op1) {
- STR_RELEASE(Z_STR_P(result));
+ zend_string_release(Z_STR_P(result));
}
ZVAL_NEW_STR(result, str);
return SUCCESS;
@@ -1466,9 +1466,9 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_BW_XOR);
- zendi_convert_to_long(op1, op1_copy, result);
+ zendi_convert_to_int(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
- zendi_convert_to_long(op2, op2_copy, result);
+ zendi_convert_to_int(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
@@ -1481,14 +1481,14 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
- long op1_lval;
+ zend_long op1_lval;
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SL);
- zendi_convert_to_long(op1, op1_copy, result);
+ zendi_convert_to_int(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
- zendi_convert_to_long(op2, op2_copy, result);
+ zendi_convert_to_int(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
@@ -1501,14 +1501,14 @@ ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /
ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
- long op1_lval;
+ zend_long op1_lval;
if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SR);
- zendi_convert_to_long(op1, op1_copy, result);
+ zendi_convert_to_int(op1, op1_copy, result);
op1_lval = Z_LVAL_P(op1);
- zendi_convert_to_long(op2, op2_copy, result);
+ zendi_convert_to_int(op2, op2_copy, result);
} else {
op1_lval = Z_LVAL_P(op1);
}
@@ -1521,8 +1521,8 @@ ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
/* must support result==op1 */
ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2) /* {{{ */
{
- int length = Z_STRLEN_P(op1) + 1;
- zend_string *buf = STR_REALLOC(Z_STR_P(op1), length, 0);
+ size_t length = Z_STRLEN_P(op1) + 1;
+ zend_string *buf = zend_string_realloc(Z_STR_P(op1), length, 0);
buf->val[length - 1] = (char) Z_LVAL_P(op2);
buf->val[length] = 0;
@@ -1534,9 +1534,9 @@ ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2)
/* must support result==op1 */
ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2) /* {{{ */
{
- int op1_len = Z_STRLEN_P(op1);
- int length = op1_len + Z_STRLEN_P(op2);
- zend_string *buf = STR_REALLOC(Z_STR_P(op1), length, 0);
+ size_t op1_len = Z_STRLEN_P(op1);
+ size_t length = op1_len + Z_STRLEN_P(op2);
+ zend_string *buf = zend_string_realloc(Z_STR_P(op1), length, 0);
memcpy(buf->val + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2));
buf->val[length] = 0;
@@ -1576,22 +1576,22 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{
}
if (result==op1 && !IS_INTERNED(Z_STR_P(op1))) { /* special case, perform operations on result */
- uint op1_len = Z_STRLEN_P(op1);
- uint op2_len = Z_STRLEN_P(op2);
- uint res_len = op1_len + op2_len;
+ size_t op1_len = Z_STRLEN_P(op1);
+ size_t op2_len = Z_STRLEN_P(op2);
+ size_t res_len = op1_len + op2_len;
- if (Z_STRLEN_P(result) < 0 || (int) (op1_len + op2_len) < 0) {
+ if (Z_STRLEN_P(result) < 0 || (size_t) (op1_len + op2_len) < 0) {
ZVAL_EMPTY_STRING(result);
zend_error(E_ERROR, "String size overflow");
}
- Z_STR_P(result) = STR_REALLOC(Z_STR_P(result), res_len, 0 );
+ Z_STR_P(result) = zend_string_realloc(Z_STR_P(result), res_len, 0 );
Z_TYPE_INFO_P(result) = IS_STRING_EX;
memcpy(Z_STRVAL_P(result) + op1_len, Z_STRVAL_P(op2), op2_len);
Z_STRVAL_P(result)[res_len]=0;
} else {
- int length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);
- zend_string *buf = STR_ALLOC(length, 0);
+ size_t length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);
+ zend_string *buf = zend_string_alloc(length, 0);
memcpy(buf->val, Z_STRVAL_P(op1), Z_STRLEN_P(op1));
memcpy(buf->val + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
@@ -1619,8 +1619,8 @@ ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend
ZVAL_LONG(result, zend_binary_strcmp(str1->val, str1->len, str2->val, str2->len));
}
- STR_RELEASE(str1);
- STR_RELEASE(str2);
+ zend_string_release(str1);
+ zend_string_release(str2);
return SUCCESS;
}
/* }}} */
@@ -1640,8 +1640,8 @@ ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_D
ZVAL_LONG(result, zend_binary_strcmp(str1->val, str1->len, str2->val, str2->len));
- STR_RELEASE(str1);
- STR_RELEASE(str2);
+ zend_string_release(str1);
+ zend_string_release(str2);
}
return SUCCESS;
}
@@ -1662,8 +1662,8 @@ ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2 TSR
ZVAL_LONG(result, zend_binary_strcasecmp_l(str1->val, str1->len, str2->val, str1->len));
- STR_RELEASE(str1);
- STR_RELEASE(str2);
+ zend_string_release(str1);
+ zend_string_release(str2);
}
return SUCCESS;
}
@@ -1677,8 +1677,8 @@ ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 T
ZVAL_LONG(result, strcoll(str1->val, str2->val));
- STR_RELEASE(str1);
- STR_RELEASE(str2);
+ zend_string_release(str1);
+ zend_string_release(str2);
return SUCCESS;
}
/* }}} */
@@ -2013,7 +2013,7 @@ ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSR
ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool interfaces_only TSRMLS_DC) /* {{{ */
{
- zend_uint i;
+ uint32_t i;
for (i=0; i<instance_ce->num_interfaces; i++) {
if (instanceof_function(instance_ce->interfaces[i], ce TSRMLS_CC)) {
@@ -2046,27 +2046,27 @@ ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, cons
static void increment_string(zval *str) /* {{{ */
{
int carry=0;
- int pos=Z_STRLEN_P(str)-1;
+ size_t pos=Z_STRLEN_P(str)-1;
char *s;
zend_string *t;
int last=0; /* Shut up the compiler warning */
int ch;
if (Z_STRLEN_P(str) == 0) {
- STR_RELEASE(Z_STR_P(str));
- Z_STR_P(str) = STR_INIT("1", sizeof("1")-1, 0);
+ zend_string_release(Z_STR_P(str));
+ Z_STR_P(str) = zend_string_init("1", sizeof("1")-1, 0);
Z_TYPE_INFO_P(str) = IS_STRING_EX;
return;
}
if (IS_INTERNED(Z_STR_P(str))) {
- Z_STR_P(str) = STR_INIT(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
+ Z_STR_P(str) = zend_string_init(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
Z_TYPE_INFO_P(str) = IS_STRING_EX;
} else if (Z_REFCOUNT_P(str) > 1) {
Z_DELREF_P(str);
- Z_STR_P(str) = STR_INIT(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
+ Z_STR_P(str) = zend_string_init(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
} else {
- STR_FORGET_HASH_VAL(Z_STR_P(str));
+ zend_string_forget_hash_val(Z_STR_P(str));
}
s = Z_STRVAL_P(str);
@@ -2110,7 +2110,7 @@ static void increment_string(zval *str) /* {{{ */
}
if (carry) {
- t = STR_ALLOC(Z_STRLEN_P(str)+1, 0);
+ t = zend_string_alloc(Z_STRLEN_P(str)+1, 0);
memcpy(t->val + 1, Z_STRVAL_P(str), Z_STRLEN_P(str));
t->val[Z_STRLEN_P(str) + 1] = '\0';
switch (last) {
@@ -2124,7 +2124,7 @@ static void increment_string(zval *str) /* {{{ */
t->val[0] = 'a';
break;
}
- STR_FREE(Z_STR_P(str));
+ zend_string_free(Z_STR_P(str));
ZVAL_NEW_STR(str, t);
}
}
@@ -2135,7 +2135,7 @@ ZEND_API int increment_function(zval *op1) /* {{{ */
try_again:
switch (Z_TYPE_P(op1)) {
case IS_LONG:
- if (Z_LVAL_P(op1) == LONG_MAX) {
+ if (Z_LVAL_P(op1) == ZEND_LONG_MAX) {
/* switch to double */
double d = (double)Z_LVAL_P(op1);
ZVAL_DOUBLE(op1, d+1);
@@ -2150,13 +2150,13 @@ try_again:
ZVAL_LONG(op1, 1);
break;
case IS_STRING: {
- long lval;
+ zend_long lval;
double dval;
switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, 0)) {
case IS_LONG:
- STR_RELEASE(Z_STR_P(op1));
- if (lval == LONG_MAX) {
+ zend_string_release(Z_STR_P(op1));
+ if (lval == ZEND_LONG_MAX) {
/* switch to double */
double d = (double)lval;
ZVAL_DOUBLE(op1, d+1);
@@ -2165,7 +2165,7 @@ try_again:
}
break;
case IS_DOUBLE:
- STR_RELEASE(Z_STR_P(op1));
+ zend_string_release(Z_STR_P(op1));
ZVAL_DOUBLE(op1, dval+1);
break;
default:
@@ -2200,13 +2200,13 @@ try_again:
ZEND_API int decrement_function(zval *op1) /* {{{ */
{
- long lval;
+ zend_long lval;
double dval;
try_again:
switch (Z_TYPE_P(op1)) {
case IS_LONG:
- if (Z_LVAL_P(op1) == LONG_MIN) {
+ if (Z_LVAL_P(op1) == ZEND_LONG_MIN) {
double d = (double)Z_LVAL_P(op1);
ZVAL_DOUBLE(op1, d-1);
} else {
@@ -2218,14 +2218,14 @@ try_again:
break;
case IS_STRING: /* Like perl we only support string increment */
if (Z_STRLEN_P(op1) == 0) { /* consider as 0 */
- STR_RELEASE(Z_STR_P(op1));
+ zend_string_release(Z_STR_P(op1));
ZVAL_LONG(op1, -1);
break;
}
switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, 0)) {
case IS_LONG:
- STR_RELEASE(Z_STR_P(op1));
- if (lval == LONG_MIN) {
+ zend_string_release(Z_STR_P(op1));
+ if (lval == ZEND_LONG_MIN) {
double d = (double)lval;
ZVAL_DOUBLE(op1, d-1);
} else {
@@ -2233,7 +2233,7 @@ try_again:
}
break;
case IS_DOUBLE:
- STR_RELEASE(Z_STR_P(op1));
+ zend_string_release(Z_STR_P(op1));
ZVAL_DOUBLE(op1, dval - 1);
break;
}
@@ -2277,7 +2277,7 @@ ZEND_API void zend_update_current_locale(void) /* {{{ */
/* }}} */
#endif
-ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned int length) /* {{{ */
+ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, size_t length) /* {{{ */
{
register unsigned char *str = (unsigned char*)source;
register unsigned char *result = (unsigned char*)dest;
@@ -2292,13 +2292,13 @@ ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned in
}
/* }}} */
-ZEND_API char *zend_str_tolower_dup(const char *source, unsigned int length) /* {{{ */
+ZEND_API char *zend_str_tolower_dup(const char *source, size_t length) /* {{{ */
{
return zend_str_tolower_copy((char *)emalloc(length+1), source, length);
}
/* }}} */
-ZEND_API void zend_str_tolower(char *str, unsigned int length) /* {{{ */
+ZEND_API void zend_str_tolower(char *str, size_t length) /* {{{ */
{
register unsigned char *p = (unsigned char*)str;
register unsigned char *end = p + length;
@@ -2310,7 +2310,7 @@ ZEND_API void zend_str_tolower(char *str, unsigned int length) /* {{{ */
}
/* }}} */
-ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */
+ZEND_API int zend_binary_strcmp(const char *s1, size_t len1, const char *s2, size_t len2) /* {{{ */
{
int retval;
@@ -2319,14 +2319,14 @@ ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint
}
retval = memcmp(s1, s2, MIN(len1, len2));
if (!retval) {
- return (len1 - len2);
+ return (int)(len1 - len2);
} else {
return retval;
}
}
/* }}} */
-ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */
+ZEND_API int zend_binary_strncmp(const char *s1, size_t len1, const char *s2, size_t len2, size_t length) /* {{{ */
{
int retval;
@@ -2335,16 +2335,16 @@ ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint
}
retval = memcmp(s1, s2, MIN(length, MIN(len1, len2)));
if (!retval) {
- return (MIN(length, len1) - MIN(length, len2));
+ return (int)(MIN(length, len1) - MIN(length, len2));
} else {
return retval;
}
}
/* }}} */
-ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */
+ZEND_API int zend_binary_strcasecmp(const char *s1, size_t len1, const char *s2, size_t len2) /* {{{ */
{
- int len;
+ size_t len;
int c1, c2;
if (s1 == s2) {
@@ -2360,13 +2360,13 @@ ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, u
}
}
- return len1 - len2;
+ return (int)(len1 - 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(const char *s1, size_t len1, const char *s2, size_t len2, size_t length) /* {{{ */
{
- int len;
+ size_t len;
int c1, c2;
if (s1 == s2) {
@@ -2381,13 +2381,13 @@ ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2,
}
}
- return MIN(length, len1) - MIN(length, len2);
+ return (int)(MIN(length, len1) - MIN(length, len2));
}
/* }}} */
-ZEND_API int zend_binary_strcasecmp_l(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */
+ZEND_API int zend_binary_strcasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2) /* {{{ */
{
- int len;
+ size_t len;
int c1, c2;
if (s1 == s2) {
@@ -2403,13 +2403,13 @@ ZEND_API int zend_binary_strcasecmp_l(const char *s1, uint len1, const char *s2,
}
}
- return len1 - len2;
+ return (int)(len1 - len2);
}
/* }}} */
-ZEND_API int zend_binary_strncasecmp_l(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */
+ZEND_API int zend_binary_strncasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2, size_t length) /* {{{ */
{
- int len;
+ size_t len;
int c1, c2;
if (s1 == s2) {
@@ -2424,7 +2424,7 @@ ZEND_API int zend_binary_strncasecmp_l(const char *s1, uint len1, const char *s2
}
}
- return MIN(length, len1) - MIN(length, len2);
+ return (int)(MIN(length, len1) - MIN(length, len2));
}
/* }}} */
@@ -2456,12 +2456,12 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) /* {{{ */
{
int ret1, ret2;
int oflow1, oflow2;
- long lval1 = 0, lval2 = 0;
+ zend_long lval1 = 0, lval2 = 0;
double dval1 = 0.0, dval2 = 0.0;
if ((ret1=is_numeric_string_ex(Z_STRVAL_P(s1), Z_STRLEN_P(s1), &lval1, &dval1, 0, &oflow1)) &&
(ret2=is_numeric_string_ex(Z_STRVAL_P(s2), Z_STRLEN_P(s2), &lval2, &dval2, 0, &oflow2))) {
-#if ULONG_MAX == 0xFFFFFFFF
+#if ZEND_ULONG_MAX == 0xFFFFFFFF
if (oflow1 != 0 && oflow1 == oflow2 && dval1 - dval2 == 0. &&
((oflow1 == 1 && dval1 > 9007199254740991. /*0x1FFFFFFFFFFFFF*/)
|| (oflow1 == -1 && dval1 < -9007199254740991.))) {
@@ -2558,16 +2558,16 @@ ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC) /* {{{ */
}
/* }}} */
-ZEND_API zend_string *zend_long_to_str(long num) /* {{{ */
+ZEND_API zend_string *zend_longo_str(zend_long num) /* {{{ */
{
char buf[MAX_LENGTH_OF_LONG + 1];
char *res;
- _zend_print_signed_to_buf(buf + sizeof(buf) - 1, num, unsigned long, res);
- return STR_INIT(res, buf + sizeof(buf) - 1 - res, 0);
+ _zend_print_signed_to_buf(buf + sizeof(buf) - 1, num, zend_ulong, res);
+ return zend_string_init(res, buf + sizeof(buf) - 1 - res, 0);
}
/* }}} */
-ZEND_API zend_uchar is_numeric_str_function(const zend_string *str, long *lval, double *dval) {
+ZEND_API zend_uchar is_numeric_str_function(const zend_string *str, zend_long *lval, double *dval) {
return is_numeric_string_ex(str->val, str->len, lval, dval, -1, NULL);
}
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index 1ab9518b9a..7e6e8b9772 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -41,7 +41,7 @@
#include "ext/bcmath/libbcmath/src/bcmath.h"
#endif
-#define LONG_SIGN_MASK (1L << (8*sizeof(long)-1))
+#define LONG_SIGN_MASK (((zend_long)1) << (8*sizeof(zend_long)-1))
BEGIN_EXTERN_C()
ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
@@ -72,11 +72,11 @@ ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, cons
END_EXTERN_C()
#if ZEND_DVAL_TO_LVAL_CAST_OK
-# define zend_dval_to_lval(d) ((long) (d))
-#elif SIZEOF_LONG == 4
-static zend_always_inline long zend_dval_to_lval(double d)
+# define zend_dval_to_lval(d) ((zend_long) (d))
+#elif SIZEOF_ZEND_INT == 4
+static zend_always_inline zend_long zend_dval_to_lval(double d)
{
- if (d > LONG_MAX || d < LONG_MIN) {
+ if (d > ZEND_LONG_MAX || d < ZEND_LONG_MIN) {
double two_pow_32 = pow(2., 32.),
dmod;
@@ -86,15 +86,15 @@ static zend_always_inline long zend_dval_to_lval(double d)
* to simulate rounding towards 0 of the negative number */
dmod = ceil(dmod) + two_pow_32;
}
- return (long)(unsigned long)dmod;
+ return (zend_long)(zend_ulong)dmod;
}
- return (long)d;
+ return (zend_long)d;
}
#else
-static zend_always_inline long zend_dval_to_lval(double d)
+static zend_always_inline zend_long zend_dval_to_lval(double d)
{
- /* >= as (double)LONG_MAX is outside signed range */
- if (d >= LONG_MAX || d < LONG_MIN) {
+ /* >= as (double)ZEND_LONG_MAX is outside signed range */
+ if (d >= ZEND_LONG_MAX || d < ZEND_LONG_MIN) {
double two_pow_64 = pow(2., 64.),
dmod;
@@ -104,9 +104,9 @@ static zend_always_inline long zend_dval_to_lval(double d)
* fractional part, hence dmod does not have one either */
dmod += two_pow_64;
}
- return (long)(unsigned long)dmod;
+ return (zend_long)(zend_ulong)dmod;
}
- return (long)d;
+ return (zend_long)d;
}
#endif
/* }}} */
@@ -127,9 +127,9 @@ static zend_always_inline long zend_dval_to_lval(double d)
*
* This variant also gives information if a string that represents an integer
* could not be represented as such due to overflow. It writes 1 to oflow_info
- * if the integer is larger than LONG_MAX and -1 if it's smaller than LONG_MIN.
+ * if the integer is larger than ZEND_LONG_MAX and -1 if it's smaller than ZEND_LONG_MIN.
*/
-static inline zend_uchar is_numeric_string_ex(const char *str, int length, long *lval, double *dval, int allow_errors, int *oflow_info)
+static inline zend_uchar is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors, int *oflow_info)
{
const char *ptr;
int base = 10, digits = 0, dp_or_e = 0;
@@ -202,7 +202,7 @@ check_digits:
dp_or_e = -1;
goto process_double;
}
- } else if (!(digits < SIZEOF_LONG * 2 || (digits == SIZEOF_LONG * 2 && ptr[-digits] <= '7'))) {
+ } else if (!(digits < SIZEOF_ZEND_INT * 2 || (digits == SIZEOF_ZEND_INT * 2 && ptr[-digits] <= '7'))) {
if (dval) {
local_dval = zend_hex_strtod(str, &ptr);
}
@@ -253,7 +253,7 @@ process_double:
}
if (lval) {
- *lval = strtol(str, NULL, base);
+ *lval = ZEND_STRTOL(str, NULL, base);
}
return IS_LONG;
@@ -266,23 +266,27 @@ process_double:
}
}
-static inline zend_uchar is_numeric_string(const char *str, int length, long *lval, double *dval, int allow_errors) {
+static inline zend_uchar is_numeric_string(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors) {
return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL);
}
-ZEND_API zend_uchar is_numeric_str_function(const zend_string *str, long *lval, double *dval);
+ZEND_API zend_uchar is_numeric_str_function(const zend_string *str, zend_long *lval, double *dval);
static inline const char *
-zend_memnstr(const char *haystack, const char *needle, int needle_len, char *end)
+zend_memnstr(const char *haystack, const char *needle, size_t needle_len, char *end)
{
const char *p = haystack;
const char ne = needle[needle_len-1];
+ ptrdiff_t off_p;
+ size_t off_s;
if (needle_len == 1) {
return (char *)memchr(p, *needle, (end-p));
}
- if (needle_len > end-haystack) {
+ off_p = end - haystack;
+ off_s = (off_p > 0) ? (size_t)off_p : 0;
+ if (needle_len > off_s) {
return NULL;
}
@@ -329,29 +333,29 @@ 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_int(zval *op);
ZEND_API void convert_to_double(zval *op);
-ZEND_API void convert_to_long_base(zval *op, int base);
+ZEND_API void convert_to_int_base(zval *op, int base);
ZEND_API void convert_to_null(zval *op);
ZEND_API void convert_to_boolean(zval *op);
ZEND_API void convert_to_array(zval *op);
ZEND_API void convert_to_object(zval *op);
-ZEND_API void multi_convert_to_long_ex(int argc, ...);
+ZEND_API void multi_convert_to_int_ex(int argc, ...);
ZEND_API void multi_convert_to_double_ex(int argc, ...);
ZEND_API void multi_convert_to_string_ex(int argc, ...);
-ZEND_API long _zval_get_long_func(zval *op TSRMLS_DC);
+ZEND_API zend_long _zval_get_long_func(zval *op TSRMLS_DC);
ZEND_API double _zval_get_double_func(zval *op TSRMLS_DC);
ZEND_API zend_string *_zval_get_string_func(zval *op TSRMLS_DC);
-static zend_always_inline long _zval_get_long(zval *op TSRMLS_DC) {
+static zend_always_inline zend_long _zval_get_long(zval *op TSRMLS_DC) {
return Z_TYPE_P(op) == IS_LONG ? Z_LVAL_P(op) : _zval_get_long_func(op TSRMLS_CC);
}
static zend_always_inline double _zval_get_double(zval *op TSRMLS_DC) {
return Z_TYPE_P(op) == IS_DOUBLE ? Z_DVAL_P(op) : _zval_get_double_func(op TSRMLS_CC);
}
static zend_always_inline zend_string *_zval_get_string(zval *op TSRMLS_DC) {
- return Z_TYPE_P(op) == IS_STRING ? STR_COPY(Z_STR_P(op)) : _zval_get_string_func(op TSRMLS_CC);
+ return Z_TYPE_P(op) == IS_STRING ? zend_string_copy(Z_STR_P(op)) : _zval_get_string_func(op TSRMLS_CC);
}
#define zval_get_long(op) _zval_get_long((op) TSRMLS_CC)
@@ -363,7 +367,7 @@ ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2
#define convert_to_cstring(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_cstring((op) ZEND_FILE_LINE_CC); }
#define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); }
-ZEND_API double zend_string_to_double(const char *number, zend_uint length);
+ZEND_API double zend_string_to_double(const char *number, uint32_t length);
ZEND_API int zval_is_true(zval *op);
ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
@@ -375,20 +379,20 @@ ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2 TSR
ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
#endif
-ZEND_API void zend_str_tolower(char *str, unsigned int length);
-ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned int length);
-ZEND_API char *zend_str_tolower_dup(const char *source, unsigned int length);
+ZEND_API void zend_str_tolower(char *str, size_t length);
+ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, size_t length);
+ZEND_API char *zend_str_tolower_dup(const char *source, size_t length);
ZEND_API int zend_binary_zval_strcmp(zval *s1, zval *s2);
ZEND_API int zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3);
ZEND_API int zend_binary_zval_strcasecmp(zval *s1, zval *s2);
ZEND_API int zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval *s3);
-ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint len2);
-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_strcasecmp_l(const char *s1, uint len1, const char *s2, uint len2);
-ZEND_API int zend_binary_strncasecmp_l(const char *s1, uint len1, const char *s2, uint len2, uint length);
+ZEND_API int zend_binary_strcmp(const char *s1, size_t len1, const char *s2, size_t len2);
+ZEND_API int zend_binary_strncmp(const char *s1, size_t len1, const char *s2, size_t len2, size_t length);
+ZEND_API int zend_binary_strcasecmp(const char *s1, size_t len1, const char *s2, size_t len2);
+ZEND_API int zend_binary_strncasecmp(const char *s1, size_t len1, const char *s2, size_t len2, size_t length);
+ZEND_API int zend_binary_strcasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2);
+ZEND_API int zend_binary_strncasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2, size_t 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);
@@ -396,7 +400,7 @@ ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2 TSRMLS_DC);
ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC);
ZEND_API int zend_atoi(const char *str, int str_len);
-ZEND_API long zend_atol(const char *str, int str_len);
+ZEND_API zend_long zend_atol(const char *str, int str_len);
ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC);
END_EXTERN_C()
@@ -414,7 +418,7 @@ END_EXTERN_C()
convert_to_null(pzv); \
break; \
case IS_LONG: \
- convert_to_long(pzv); \
+ convert_to_int(pzv); \
break; \
case IS_DOUBLE: \
convert_to_double(pzv); \
@@ -444,7 +448,7 @@ END_EXTERN_C()
}
#define convert_to_boolean_ex(pzv) convert_to_ex_master(pzv, boolean, _IS_BOOL)
-#define convert_to_long_ex(pzv) convert_to_ex_master(pzv, long, IS_LONG)
+#define convert_to_int_ex(pzv) convert_to_ex_master(pzv, int, IS_LONG)
#define convert_to_double_ex(pzv) convert_to_ex_master(pzv, double, IS_DOUBLE)
#define convert_to_string_ex(pzv) convert_to_ex_master(pzv, string, IS_STRING)
#define convert_to_array_ex(pzv) convert_to_ex_master(pzv, array, IS_ARRAY)
@@ -504,9 +508,9 @@ static zend_always_inline int fast_increment_function(zval *op1)
"n"(ZVAL_OFFSETOF_TYPE)
: "cc");
#else
- if (UNEXPECTED(Z_LVAL_P(op1) == LONG_MAX)) {
+ if (UNEXPECTED(Z_LVAL_P(op1) == ZEND_LONG_MAX)) {
/* switch to double */
- ZVAL_DOUBLE(op1, (double)LONG_MAX + 1.0);
+ ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0);
} else {
Z_LVAL_P(op1)++;
}
@@ -546,9 +550,9 @@ static zend_always_inline int fast_decrement_function(zval *op1)
"n"(ZVAL_OFFSETOF_TYPE)
: "cc");
#else
- if (UNEXPECTED(Z_LVAL_P(op1) == LONG_MIN)) {
+ if (UNEXPECTED(Z_LVAL_P(op1) == ZEND_LONG_MIN)) {
/* switch to double */
- ZVAL_DOUBLE(op1, (double)LONG_MIN - 1.0);
+ ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0);
} else {
Z_LVAL_P(op1)--;
}
@@ -726,7 +730,7 @@ static zend_always_inline int fast_mul_function(zval *result, zval *op1, zval *o
{
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
- long overflow;
+ zend_long overflow;
ZEND_SIGNED_MULTIPLY_LONG(Z_LVAL_P(op1), Z_LVAL_P(op2), Z_LVAL_P(result), Z_DVAL_P(result), overflow);
Z_TYPE_INFO_P(result) = overflow ? IS_DOUBLE : IS_LONG;
@@ -756,9 +760,9 @@ static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *o
zend_error(E_WARNING, "Division by zero");
ZVAL_BOOL(result, 0);
return FAILURE;
- } else if (UNEXPECTED(Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN)) {
+ } else if (UNEXPECTED(Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == ZEND_LONG_MIN)) {
/* Prevent overflow error/crash */
- ZVAL_DOUBLE(result, (double) LONG_MIN / -1);
+ ZVAL_DOUBLE(result, (double) ZEND_LONG_MIN / -1);
} else if (EXPECTED(Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0)) {
/* integer */
ZVAL_LONG(result, Z_LVAL_P(op1) / Z_LVAL_P(op2));
@@ -807,7 +811,7 @@ static zend_always_inline int fast_mod_function(zval *result, zval *op1, zval *o
ZVAL_BOOL(result, 0);
return FAILURE;
} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
- /* Prevent overflow error/crash if op1==LONG_MIN */
+ /* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
ZVAL_LONG(result, 0);
return SUCCESS;
}
@@ -1041,7 +1045,7 @@ static zend_always_inline void fast_is_not_identical_function(zval *result, zval
} \
} while (0)
-ZEND_API zend_string *zend_long_to_str(long num);
+ZEND_API zend_string *zend_longo_str(zend_long num);
#endif
diff --git a/Zend/zend_qsort.c b/Zend/zend_qsort.c
index ea577e1c07..16d513e93c 100644
--- a/Zend/zend_qsort.c
+++ b/Zend/zend_qsort.c
@@ -74,7 +74,7 @@ ZEND_API void zend_qsort_r(void *base, size_t nmemb, size_t siz, compare_r_func_
end = end_stack[loop];
while (begin < end) {
- offset = (end - begin) >> 1;
+ offset = (end - begin) >> Z_I(1);
_zend_qsort_swap(begin, begin + (offset - (offset % siz)), siz);
seg1 = begin + siz;
diff --git a/Zend/zend_static_allocator.c b/Zend/zend_static_allocator.c
index 71338d211e..049d29f6a2 100644
--- a/Zend/zend_static_allocator.c
+++ b/Zend/zend_static_allocator.c
@@ -22,13 +22,13 @@
/* Not checking emalloc() and erealloc() return values as they are supposed to bailout */
-inline static void block_init(Block *block, zend_uint block_size)
+inline static void block_init(Block *block, uint32_t block_size)
{
block->pos = block->bp = (char *) emalloc(block_size);
block->end = block->bp + block_size;
}
-inline static char *block_allocate(Block *block, zend_uint size)
+inline static char *block_allocate(Block *block, uint32_t size)
{
char *retval = block->pos;
if ((block->pos += size) >= block->end) {
@@ -50,7 +50,7 @@ void static_allocator_init(StaticAllocator *sa)
sa->current_block = 0;
}
-char *static_allocator_allocate(StaticAllocator *sa, zend_uint size)
+char *static_allocator_allocate(StaticAllocator *sa, uint32_t size)
{
char *retval;
@@ -67,7 +67,7 @@ char *static_allocator_allocate(StaticAllocator *sa, zend_uint size)
void static_allocator_destroy(StaticAllocator *sa)
{
- zend_uint i;
+ uint32_t i;
for (i=0; i<sa->num_blocks; i++) {
block_free(&sa->Blocks[i]);
diff --git a/Zend/zend_static_allocator.h b/Zend/zend_static_allocator.h
index 7516065707..cd9b0ff583 100644
--- a/Zend/zend_static_allocator.h
+++ b/Zend/zend_static_allocator.h
@@ -24,7 +24,7 @@
#define ALLOCATOR_BLOCK_SIZE 400000
/* Temporary */
-typedef unsigned int zend_uint;
+typedef unsigned int uint32_t;
#define emalloc(s) malloc(s)
#define efree(p) free(p)
@@ -36,12 +36,12 @@ typedef struct _Block {
typedef struct _StaticAllocator {
Block *Blocks;
- zend_uint num_blocks;
- zend_uint current_block;
+ uint32_t num_blocks;
+ uint32_t current_block;
} StaticAllocator;
void static_allocator_init(StaticAllocator *sa);
-char *static_allocator_allocate(StaticAllocator *sa, zend_uint size);
+char *static_allocator_allocate(StaticAllocator *sa, uint32_t size);
void static_allocator_destroy(StaticAllocator *sa);
#endif /* ZEND_STATIC_ALLOCATOR_H */
diff --git a/Zend/zend_stream.c b/Zend/zend_stream.c
index 6d306b337e..7824ee1f83 100644
--- a/Zend/zend_stream.c
+++ b/Zend/zend_stream.c
@@ -24,9 +24,8 @@
#include "zend.h"
#include "zend_compile.h"
+#include "zend_stream.h"
-#include <sys/types.h>
-#include <sys/stat.h>
#if HAVE_MMAP
# if HAVE_UNISTD_H
# include <unistd.h>
@@ -64,8 +63,8 @@ static void zend_stream_stdio_closer(void *handle TSRMLS_DC) /* {{{ */
static size_t zend_stream_stdio_fsizer(void *handle TSRMLS_DC) /* {{{ */
{
- struct stat buf;
- if (handle && fstat(fileno((FILE*)handle), &buf) == 0) {
+ zend_stat_t buf;
+ if (handle && zend_fstat(fileno((FILE*)handle), &buf) == 0) {
#ifdef S_ISREG
if (!S_ISREG(buf.st_mode)) {
return 0;
@@ -237,7 +236,7 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
/* *buf[size] is zeroed automatically by the kernel */
*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0);
if (*buf != MAP_FAILED) {
- long offset = ftell(file_handle->handle.fp);
+ zend_long offset = ftell(file_handle->handle.fp);
file_handle->handle.stream.mmap.map = *buf;
if (offset != -1) {
diff --git a/Zend/zend_stream.h b/Zend/zend_stream.h
index 5306b496f9..10fa8d8a60 100644
--- a/Zend/zend_stream.h
+++ b/Zend/zend_stream.h
@@ -24,6 +24,9 @@
#ifndef ZEND_STREAM_H
#define ZEND_STREAM_H
+#include <sys/types.h>
+#include <sys/stat.h>
+
/* Lightweight stream implementation for the ZE scanners.
* These functions are private to the engine.
* */
@@ -78,4 +81,20 @@ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh TSRMLS_DC);
ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2);
END_EXTERN_C()
+#ifdef _WIN64
+# define zend_fseek _fseeki64
+# define zend_ftell _ftelli64
+# define zend_lseek _lseeki64
+# define zend_fstat _fstat64
+# define zend_stat _stat64
+typedef struct __stat64 zend_stat_t;
+#else
+# define zend_fseek fseek
+# define zend_ftell ftell
+# define zend_lseek lseek
+# define zend_fstat fstat
+# define zend_stat stat
+typedef struct stat zend_stat_t;
+#endif
+
#endif
diff --git a/Zend/zend_string.c b/Zend/zend_string.c
index 2a415454ce..03ab71aff5 100644
--- a/Zend/zend_string.c
+++ b/Zend/zend_string.c
@@ -29,7 +29,7 @@ static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC);
static void zend_interned_strings_snapshot_int(TSRMLS_D);
static void zend_interned_strings_restore_int(TSRMLS_D);
-ZEND_API zend_ulong zend_hash_func(const char *str, uint len)
+ZEND_API zend_ulong zend_hash_func(const char *str, size_t len)
{
return zend_inline_hash_func(str, len);
}
@@ -50,17 +50,17 @@ void zend_interned_strings_init(TSRMLS_D)
CG(interned_strings).nTableMask = CG(interned_strings).nTableSize - 1;
CG(interned_strings).arData = (Bucket*) pecalloc(CG(interned_strings).nTableSize, sizeof(Bucket), 1);
- CG(interned_strings).arHash = (zend_uint*) pecalloc(CG(interned_strings).nTableSize, sizeof(zend_uint), 1);
- memset(CG(interned_strings).arHash, INVALID_IDX, CG(interned_strings).nTableSize * sizeof(zend_uint));
+ CG(interned_strings).arHash = (uint32_t*) pecalloc(CG(interned_strings).nTableSize, sizeof(uint32_t), 1);
+ memset(CG(interned_strings).arHash, INVALID_IDX, CG(interned_strings).nTableSize * sizeof(uint32_t));
/* interned empty string */
- str = STR_ALLOC(sizeof("")-1, 1);
+ str = zend_string_alloc(sizeof("")-1, 1);
str->val[0] = '\000';
CG(empty_string) = zend_new_interned_string_int(str TSRMLS_CC);
#else
- str = STR_ALLOC(sizeof("")-1, 1);
+ str = zend_string_alloc(sizeof("")-1, 1);
str->val[0] = '\000';
- STR_HASH_VAL(str);
+ zend_string_hash_val(str);
str->gc.u.v.flags |= IS_STR_INTERNED;
CG(empty_string) = str;
#endif
@@ -85,7 +85,7 @@ void zend_interned_strings_dtor(TSRMLS_D)
static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC)
{
#ifndef ZTS
- ulong h;
+ zend_ulong h;
uint nIndex;
uint idx;
Bucket *p;
@@ -94,14 +94,14 @@ static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC)
return str;
}
- h = STR_HASH_VAL(str);
+ h = zend_string_hash_val(str);
nIndex = h & CG(interned_strings).nTableMask;
idx = CG(interned_strings).arHash[nIndex];
while (idx != INVALID_IDX) {
p = CG(interned_strings).arData + idx;
if ((p->h == h) && (p->key->len == str->len)) {
if (!memcmp(p->key->val, str->val, str->len)) {
- STR_RELEASE(str);
+ zend_string_release(str);
return p->key;
}
}
@@ -114,7 +114,7 @@ static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC)
if (CG(interned_strings).nNumUsed >= CG(interned_strings).nTableSize) {
if ((CG(interned_strings).nTableSize << 1) > 0) { /* Let's double the table size */
Bucket *d = (Bucket *) perealloc_recoverable(CG(interned_strings).arData, (CG(interned_strings).nTableSize << 1) * sizeof(Bucket), 1);
- zend_uint *h = (zend_uint *) perealloc_recoverable(CG(interned_strings).arHash, (CG(interned_strings).nTableSize << 1) * sizeof(zend_uint), 1);
+ uint32_t *h = (uint32_t *) perealloc_recoverable(CG(interned_strings).arHash, (CG(interned_strings).nTableSize << 1) * sizeof(uint32_t), 1);
if (d && h) {
HANDLE_BLOCK_INTERRUPTIONS();
@@ -182,7 +182,7 @@ static void zend_interned_strings_restore_int(TSRMLS_D)
GC_FLAGS(p->key) &= ~IS_STR_INTERNED;
GC_REFCOUNT(p->key) = 1;
- STR_FREE(p->key);
+ zend_string_free(p->key);
nIndex = p->h & CG(interned_strings).nTableMask;
if (CG(interned_strings).arHash[nIndex] == idx) {
diff --git a/Zend/zend_string.h b/Zend/zend_string.h
index ef0116b938..6f276253e2 100644
--- a/Zend/zend_string.h
+++ b/Zend/zend_string.h
@@ -29,7 +29,7 @@ ZEND_API extern zend_string *(*zend_new_interned_string)(zend_string *str TSRMLS
ZEND_API extern void (*zend_interned_strings_snapshot)(TSRMLS_D);
ZEND_API extern void (*zend_interned_strings_restore)(TSRMLS_D);
-ZEND_API zend_ulong zend_hash_func(const char *str, uint len);
+ZEND_API zend_ulong zend_hash_func(const char *str, size_t len);
void zend_interned_strings_init(TSRMLS_D);
void zend_interned_strings_dtor(TSRMLS_D);
@@ -37,21 +37,6 @@ END_EXTERN_C()
#define IS_INTERNED(s) (GC_FLAGS(s) & IS_STR_INTERNED)
-#define STR_HASH_VAL(s) zend_str_hash_val(s)
-#define STR_FORGET_HASH_VAL(s) zend_str_forget_hash_val(s)
-
-#define STR_REFCOUNT(s) zend_str_refcount(s)
-#define STR_ADDREF(s) zend_str_addref(s)
-#define STR_DELREF(s) zend_str_delref(s)
-#define STR_ALLOC(len, persistent) zend_str_alloc(len, persistent)
-#define STR_SAFE_ALLOC(n, m, l, p) zend_str_safe_alloc(n, m, l, p)
-#define STR_INIT(str, len, persistent) zend_str_init(str, len, persistent)
-#define STR_COPY(s) zend_str_copy(s)
-#define STR_DUP(s, persistent) zend_str_dup(s, persistent)
-#define STR_REALLOC(s, len, persistent) zend_str_realloc(s, len, persistent)
-#define STR_SAFE_REALLOC(s, n, m, l, p) zend_str_safe_realloc(s, n, m, l, p)
-#define STR_FREE(s) zend_str_free(s)
-#define STR_RELEASE(s) zend_str_release(s)
#define STR_EMPTY_ALLOC() CG(empty_string)
#define _STR_HEADER_SIZE XtOffsetOf(zend_string, val)
@@ -70,7 +55,7 @@ END_EXTERN_C()
#define STR_ALLOCA_FREE(str, use_heap) free_alloca(str, use_heap)
-static zend_always_inline zend_ulong zend_str_hash_val(zend_string *s)
+static zend_always_inline zend_ulong zend_string_hash_val(zend_string *s)
{
if (!s->h) {
s->h = zend_hash_func(s->val, s->len);
@@ -78,12 +63,12 @@ static zend_always_inline zend_ulong zend_str_hash_val(zend_string *s)
return s->h;
}
-static zend_always_inline void zend_str_forget_hash_val(zend_string *s)
+static zend_always_inline void zend_string_forget_hash_val(zend_string *s)
{
s->h = 0;
}
-static zend_always_inline zend_uint zend_str_refcount(zend_string *s)
+static zend_always_inline uint32_t zend_string_refcount(zend_string *s)
{
if (!IS_INTERNED(s)) {
return GC_REFCOUNT(s);
@@ -91,7 +76,7 @@ static zend_always_inline zend_uint zend_str_refcount(zend_string *s)
return 1;
}
-static zend_always_inline zend_uint zend_str_addref(zend_string *s)
+static zend_always_inline uint32_t zend_string_addref(zend_string *s)
{
if (!IS_INTERNED(s)) {
return ++GC_REFCOUNT(s);
@@ -99,7 +84,7 @@ static zend_always_inline zend_uint zend_str_addref(zend_string *s)
return 1;
}
-static zend_always_inline zend_uint zend_str_delref(zend_string *s)
+static zend_always_inline uint32_t zend_string_delref(zend_string *s)
{
if (!IS_INTERNED(s)) {
return --GC_REFCOUNT(s);
@@ -107,7 +92,7 @@ static zend_always_inline zend_uint zend_str_delref(zend_string *s)
return 1;
}
-static zend_always_inline zend_string *zend_str_alloc(int len, int persistent)
+static zend_always_inline zend_string *zend_string_alloc(size_t len, int persistent)
{
zend_string *ret = (zend_string *)pemalloc(ZEND_MM_ALIGNED_SIZE(_STR_HEADER_SIZE + len + 1), persistent);
@@ -125,7 +110,7 @@ static zend_always_inline zend_string *zend_str_alloc(int len, int persistent)
return ret;
}
-static zend_always_inline zend_string *zend_str_safe_alloc(size_t n, size_t m, size_t l, int persistent)
+static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m, size_t l, int persistent)
{
zend_string *ret = (zend_string *)safe_pemalloc(n, m, ZEND_MM_ALIGNED_SIZE(_STR_HEADER_SIZE + l + 1), persistent);
@@ -143,82 +128,82 @@ static zend_always_inline zend_string *zend_str_safe_alloc(size_t n, size_t m, s
return ret;
}
-static zend_always_inline zend_string *zend_str_init(const char *str, int len, int persistent)
+static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, int persistent)
{
- zend_string *ret = STR_ALLOC(len, persistent);
+ zend_string *ret = zend_string_alloc(len, persistent);
memcpy(ret->val, str, len);
ret->val[len] = '\0';
return ret;
}
-static zend_always_inline zend_string *zend_str_copy(zend_string *s)
+static zend_always_inline zend_string *zend_string_copy(zend_string *s)
{
if (!IS_INTERNED(s)) {
- STR_ADDREF(s);
+ zend_string_addref(s);
}
return s;
}
-static zend_always_inline zend_string *zend_str_dup(zend_string *s, int persistent)
+static zend_always_inline zend_string *zend_string_dup(zend_string *s, int persistent)
{
if (IS_INTERNED(s)) {
return s;
} else {
- return STR_INIT(s->val, s->len, persistent);
+ return zend_string_init(s->val, s->len, persistent);
}
}
-static zend_always_inline zend_string *zend_str_realloc(zend_string *s, int len, int persistent)
+static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_t len, int persistent)
{
zend_string *ret;
if (IS_INTERNED(s)) {
- ret = STR_ALLOC(len, persistent);
+ ret = zend_string_alloc(len, persistent);
memcpy(ret->val, s->val, (len > s->len ? s->len : len) + 1);
- } else if (EXPECTED(STR_REFCOUNT(s) == 1)) {
+ } else if (EXPECTED(zend_string_refcount(s) == 1)) {
ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_STR_HEADER_SIZE + len + 1), persistent);
ret->len = len;
- STR_FORGET_HASH_VAL(ret);
+ zend_string_forget_hash_val(ret);
} else {
- ret = STR_ALLOC(len, persistent);
+ ret = zend_string_alloc(len, persistent);
memcpy(ret->val, s->val, (len > s->len ? s->len : len) + 1);
- STR_DELREF(s);
+ zend_string_delref(s);
}
return ret;
}
-static zend_always_inline zend_string *zend_str_safe_realloc(zend_string *s, size_t n, size_t m, size_t l, int persistent)
+static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s, size_t n, size_t m, size_t l, int persistent)
{
zend_string *ret;
if (IS_INTERNED(s)) {
- ret = STR_SAFE_ALLOC(n, m, l, persistent);
+ ret = zend_string_safe_alloc(n, m, l, persistent);
memcpy(ret->val, s->val, ((n * m) + l > (size_t)s->len ? (size_t)s->len : ((n * m) + l)) + 1);
- } else if (STR_REFCOUNT(s) == 1) {
+ } else if (zend_string_refcount(s) == 1) {
ret = (zend_string *)safe_perealloc(s, n, m, ZEND_MM_ALIGNED_SIZE(_STR_HEADER_SIZE + l + 1), persistent);
ret->len = (n * m) + l;
- STR_FORGET_HASH_VAL(ret);
+ zend_string_forget_hash_val(ret);
} else {
- ret = STR_SAFE_ALLOC(n, m, l, persistent);
+ ret = zend_string_safe_alloc(n, m, l, persistent);
memcpy(ret->val, s->val, ((n * m) + l > (size_t)s->len ? (size_t)s->len : ((n * m) + l)) + 1);
- STR_DELREF(s);
+ zend_string_delref(s);
}
return ret;
}
-static zend_always_inline void zend_str_free(zend_string *s)
+static zend_always_inline void zend_string_free(zend_string *s)
{
if (!IS_INTERNED(s)) {
- ZEND_ASSERT(STR_REFCOUNT(s) <= 1);
+ ZEND_ASSERT(zend_string_refcount(s) <= 1);
pefree(s, GC_FLAGS(s) & IS_STR_PERSISTENT);
}
}
-static zend_always_inline void zend_str_release(zend_string *s)
+static zend_always_inline void zend_string_release(zend_string *s)
{
if (!IS_INTERNED(s)) {
- if (STR_DELREF(s) == 0) {
+ if (zend_string_delref(s) == 0) {
pefree(s, GC_FLAGS(s) & IS_STR_PERSISTENT);
}
}
@@ -257,9 +242,9 @@ static zend_always_inline void zend_str_release(zend_string *s)
* -- Ralf S. Engelschall <rse@engelschall.com>
*/
-static inline ulong zend_inline_hash_func(const char *str, uint len)
+static inline zend_ulong zend_inline_hash_func(const char *str, size_t len)
{
- register ulong hash = 5381;
+ register zend_ulong hash = Z_UL(5381);
/* variant with the hash unrolled eight times */
for (; len >= 8; len -= 8) {
diff --git a/Zend/zend_ts_hash.c b/Zend/zend_ts_hash.c
index f6523574ae..b289ae17c9 100644
--- a/Zend/zend_ts_hash.c
+++ b/Zend/zend_ts_hash.c
@@ -110,7 +110,7 @@ ZEND_API zval *_zend_ts_hash_add_or_update(TsHashTable *ht, zend_string *key, zv
return retval;
}
-ZEND_API zval *_zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, ulong h, zval *pData, int flag ZEND_FILE_LINE_DC)
+ZEND_API zval *_zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, zend_ulong h, zval *pData, int flag ZEND_FILE_LINE_DC)
{
zval *retval;
@@ -187,7 +187,7 @@ ZEND_API int zend_ts_hash_del(TsHashTable *ht, zend_string *key)
return retval;
}
-ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, ulong h)
+ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h)
{
int retval;
@@ -209,7 +209,7 @@ ZEND_API zval *zend_ts_hash_find(TsHashTable *ht, zend_string *key)
return retval;
}
-ZEND_API zval *zend_ts_hash_index_find(TsHashTable *ht, ulong h)
+ZEND_API zval *zend_ts_hash_index_find(TsHashTable *ht, zend_ulong h)
{
zval *retval;
@@ -231,7 +231,7 @@ ZEND_API int zend_ts_hash_exists(TsHashTable *ht, zend_string *key)
return retval;
}
-ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, ulong h)
+ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, zend_ulong h)
{
int retval;
diff --git a/Zend/zend_ts_hash.h b/Zend/zend_ts_hash.h
index fcf8c3cda1..0adedff437 100644
--- a/Zend/zend_ts_hash.h
+++ b/Zend/zend_ts_hash.h
@@ -25,7 +25,7 @@
typedef struct _zend_ts_hashtable {
HashTable hash;
- zend_uint reader;
+ uint32_t reader;
#ifdef ZTS
MUTEX_T mx_reader;
MUTEX_T mx_writer;
@@ -55,7 +55,7 @@ ZEND_API zval *_zend_ts_hash_add_or_update(TsHashTable *ht, zend_string *key, zv
#define zend_ts_hash_add(ht, key, pData) \
_zend_ts_hash_add_or_update(ht, key, pData, HASH_ADD ZEND_FILE_LINE_CC)
-ZEND_API zval *_zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, ulong h, zval *pData, int flag ZEND_FILE_LINE_DC);
+ZEND_API zval *_zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, zend_ulong h, zval *pData, int flag ZEND_FILE_LINE_DC);
#define zend_ts_hash_index_update(ht, h, pData) \
_zend_ts_hash_index_update_or_next_insert(ht, h, pData, HASH_UPDATE ZEND_FILE_LINE_CC)
#define zend_ts_hash_next_index_insert(ht, pData) \
@@ -73,15 +73,15 @@ ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_fun
/* Deletes */
ZEND_API int zend_ts_hash_del(TsHashTable *ht, zend_string *key);
-ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, ulong h);
+ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h);
/* Data retreival */
ZEND_API zval *zend_ts_hash_find(TsHashTable *ht, zend_string *key);
-ZEND_API zval *zend_ts_hash_index_find(TsHashTable *ht, ulong);
+ZEND_API zval *zend_ts_hash_index_find(TsHashTable *ht, zend_ulong);
/* Misc */
ZEND_API int zend_ts_hash_exists(TsHashTable *ht, zend_string *key);
-ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, ulong h);
+ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, zend_ulong h);
/* Copying, merging and sorting */
ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor);
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
index 7ce259a34f..d2b562ecd9 100644
--- a/Zend/zend_types.h
+++ b/Zend/zend_types.h
@@ -22,6 +22,8 @@
#ifndef ZEND_TYPES_H
#define ZEND_TYPES_H
+#include "zend_long.h"
+
#ifdef WORDS_BIGENDIAN
# define ZEND_ENDIAN_LOHI(lo, hi) hi; lo;
# define ZEND_ENDIAN_LOHI_3(lo, mi, hi) hi; mi; lo;
@@ -40,9 +42,20 @@
typedef unsigned char zend_bool;
typedef unsigned char zend_uchar;
-typedef unsigned int zend_uint;
-typedef unsigned long zend_ulong;
-typedef unsigned short zend_ushort;
+
+#ifdef ZEND_ENABLE_INT64
+# ifdef ZEND_WIN32
+# define ZEND_SIZE_MAX _UI64_MAX
+# else
+# define ZEND_SIZE_MAX SIZE_MAX
+# endif
+#else
+# if defined(ZEND_WIN32)
+# define ZEND_SIZE_MAX _UI32_MAX
+# else
+# define ZEND_SIZE_MAX SIZE_MAX
+# endif
+#endif
#define HAVE_ZEND_LONG64
#ifdef ZEND_WIN32
@@ -87,7 +100,7 @@ typedef void (*dtor_func_t)(zval *pDest);
typedef void (*copy_ctor_func_t)(zval *pElement);
typedef union _zend_value {
- long lval; /* long value */
+ zend_long lval; /* long value */
double dval; /* double value */
zend_refcounted *counted;
zend_string *str;
@@ -112,61 +125,61 @@ struct _zval_struct {
zend_uchar const_flags,
zend_uchar reserved) /* various IS_VAR flags */
} v;
- zend_uint type_info;
+ uint32_t type_info;
} u1;
union {
- zend_uint var_flags;
- zend_uint next; /* hash collision chain */
- zend_uint str_offset; /* string offset */
- zend_uint cache_slot; /* literal cache slot */
- zend_uint lineno; /* line number (for ast nodes) */
+ uint32_t var_flags;
+ uint32_t next; /* hash collision chain */
+ uint32_t str_offset; /* string offset */
+ uint32_t cache_slot; /* literal cache slot */
+ uint32_t lineno; /* line number (for ast nodes) */
} u2;
};
struct _zend_refcounted {
- zend_uint refcount; /* reference counter 32-bit */
+ uint32_t refcount; /* reference counter 32-bit */
union {
struct {
ZEND_ENDIAN_LOHI_3(
zend_uchar type,
zend_uchar flags, /* used for strings & objects */
- zend_ushort gc_info) /* keeps GC root number (or 0) and color */
+ uint16_t gc_info) /* keeps GC root number (or 0) and color */
} v;
- zend_uint type_info;
+ uint32_t type_info;
} u;
};
struct _zend_string {
zend_refcounted gc;
- zend_ulong h; /* hash value */
- int len;
+ zend_ulong h; /* hash value */
+ size_t len;
char val[1];
};
typedef struct _Bucket {
- zend_ulong h; /* hash value (or numeric index) */
+ zend_ulong h; /* hash value (or numeric index) */
zend_string *key; /* string key or NULL for numerics */
zval val;
} Bucket;
typedef struct _HashTable {
- zend_uint nTableSize;
- zend_uint nTableMask;
- zend_uint nNumUsed;
- zend_uint nNumOfElements;
- long nNextFreeElement;
+ uint32_t nTableSize;
+ uint32_t nTableMask;
+ uint32_t nNumUsed;
+ uint32_t nNumOfElements;
+ zend_long nNextFreeElement;
Bucket *arData;
- zend_uint *arHash;
+ uint32_t *arHash;
dtor_func_t pDestructor;
- zend_uint nInternalPointer;
+ uint32_t nInternalPointer;
union {
struct {
ZEND_ENDIAN_LOHI_3(
zend_uchar flags,
zend_uchar nApplyCount,
- zend_ushort reserve)
+ uint16_t reserve)
} v;
- zend_uint flags;
+ uint32_t flags;
} u;
} HashTable;
@@ -177,7 +190,7 @@ struct _zend_array {
struct _zend_object {
zend_refcounted gc;
- zend_uint handle; // TODO: may be removed ???
+ uint32_t handle; // TODO: may be removed ???
zend_class_entry *ce;
const zend_object_handlers *handlers;
HashTable *properties;
@@ -187,7 +200,7 @@ struct _zend_object {
struct _zend_resource {
zend_refcounted gc;
- long handle; // TODO: may be removed ???
+ zend_long handle; // TODO: may be removed ???
int type;
void *ptr;
};
@@ -506,7 +519,7 @@ static inline zend_uchar zval_get_type(const zval* pz) {
IS_STRING_EX; \
} while (0)
-#define ZVAL_INT_STR(z, s) do { \
+#define ZVAL_INTERNED_STR(z, s) do { \
zval *__z = (z); \
zend_string *__s = (s); \
Z_STR_P(__z) = __s; \
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c
index c02e3c410b..df6dbd179a 100644
--- a/Zend/zend_variables.c
+++ b/Zend/zend_variables.c
@@ -34,7 +34,7 @@ ZEND_API void _zval_dtor_func(zend_refcounted *p ZEND_FILE_LINE_DC)
case IS_CONSTANT: {
zend_string *str = (zend_string*)p;
CHECK_ZVAL_STRING_REL(str);
- STR_RELEASE(str);
+ zend_string_release(str);
break;
}
case IS_ARRAY: {
@@ -94,7 +94,7 @@ ZEND_API void _zval_dtor_func_for_ptr(zend_refcounted *p ZEND_FILE_LINE_DC)
case IS_CONSTANT: {
zend_string *str = (zend_string*)p;
CHECK_ZVAL_STRING_REL(str);
- STR_FREE(str);
+ zend_string_free(str);
break;
}
case IS_ARRAY: {
@@ -150,7 +150,7 @@ ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC)
case IS_STRING:
case IS_CONSTANT:
CHECK_ZVAL_STRING_REL(Z_STR_P(zvalue));
- STR_RELEASE(Z_STR_P(zvalue));
+ zend_string_release(Z_STR_P(zvalue));
break;
case IS_ARRAY:
case IS_CONSTANT_AST:
@@ -181,7 +181,7 @@ ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC)
case IS_STRING:
case IS_CONSTANT:
CHECK_ZVAL_STRING_REL(Z_STR_P(zvalue));
- STR_FREE(Z_STR_P(zvalue));
+ zend_string_free(Z_STR_P(zvalue));
break;
case IS_ARRAY:
case IS_CONSTANT_AST:
@@ -234,7 +234,7 @@ ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
case IS_CONSTANT:
case IS_STRING:
CHECK_ZVAL_STRING_REL(Z_STR_P(zvalue));
- Z_STR_P(zvalue) = STR_DUP(Z_STR_P(zvalue), 0);
+ Z_STR_P(zvalue) = zend_string_dup(Z_STR_P(zvalue), 0);
break;
case IS_ARRAY: {
HashTable *ht;
diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c
index ab3d0d7c49..665829d685 100644
--- a/Zend/zend_virtual_cwd.c
+++ b/Zend/zend_virtual_cwd.c
@@ -178,7 +178,7 @@ static int php_check_dots(const char *element, int n)
#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 )
typedef struct {
- unsigned long ReparseTag;
+ zend_ulong ReparseTag;
unsigned short ReparseDataLength;
unsigned short Reserved;
union {
@@ -187,7 +187,7 @@ typedef struct {
unsigned short SubstituteNameLength;
unsigned short PrintNameOffset;
unsigned short PrintNameLength;
- unsigned long Flags;
+ zend_ulong Flags;
wchar_t ReparseTarget[1];
} SymbolicLinkReparseBuffer;
struct {
@@ -291,7 +291,7 @@ CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){
}
/* }}} */
-CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat) /* {{{ */
+CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{{ */
{
WIN32_FILE_ATTRIBUTE_DATA data;
__int64 t;
@@ -299,7 +299,7 @@ CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat) /* {{
ALLOCA_FLAG(use_heap_large);
if (!GetFileAttributesEx(path, GetFileExInfoStandard, &data)) {
- return stat(path, buf);
+ return zend_stat(path, buf);
}
if (path_len >= 1 && path[1] == ':') {
@@ -407,7 +407,7 @@ CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat) /* {{
static int php_is_dir_ok(const cwd_state *state) /* {{{ */
{
- struct stat buf;
+ zend_stat_t buf;
if (php_sys_stat(state->cwd, &buf) == 0 && S_ISDIR(buf.st_mode))
return (0);
@@ -418,7 +418,7 @@ static int php_is_dir_ok(const cwd_state *state) /* {{{ */
static int php_is_file_ok(const cwd_state *state) /* {{{ */
{
- struct stat buf;
+ zend_stat_t buf;
if (php_sys_stat(state->cwd, &buf) == 0 && S_ISREG(buf.st_mode))
return (0);
@@ -582,9 +582,9 @@ CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC) /* {{{ */
/* }}} */
#ifdef PHP_WIN32
-static inline unsigned long realpath_cache_key(const char *path, int path_len TSRMLS_DC) /* {{{ */
+static inline zend_ulong realpath_cache_key(const char *path, int path_len TSRMLS_DC) /* {{{ */
{
- register unsigned long h;
+ register zend_ulong h;
char *bucket_key_start = tsrm_win32_get_path_sid_key(path TSRMLS_CC);
char *bucket_key = (char *)bucket_key_start;
const char *e = bucket_key + strlen(bucket_key);
@@ -593,8 +593,8 @@ static inline unsigned long realpath_cache_key(const char *path, int path_len TS
return 0;
}
- for (h = 2166136261U; bucket_key < e;) {
- h *= 16777619;
+ for (h = Z_UL(2166136261); bucket_key < e;) {
+ h *= Z_UL(16777619);
h ^= *bucket_key++;
}
HeapFree(GetProcessHeap(), 0, (LPVOID)bucket_key_start);
@@ -602,13 +602,13 @@ static inline unsigned long realpath_cache_key(const char *path, int path_len TS
}
/* }}} */
#else
-static inline unsigned long realpath_cache_key(const char *path, int path_len) /* {{{ */
+static inline zend_ulong realpath_cache_key(const char *path, int path_len) /* {{{ */
{
- register unsigned long h;
+ register zend_ulong h;
const char *e = path + path_len;
- for (h = 2166136261U; path < e;) {
- h *= 16777619;
+ for (h = Z_UL(2166136261); path < e;) {
+ h *= Z_UL(16777619);
h ^= *path++;
}
@@ -637,11 +637,11 @@ CWD_API void realpath_cache_clean(TSRMLS_D) /* {{{ */
CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ */
{
#ifdef PHP_WIN32
- unsigned long key = realpath_cache_key(path, path_len TSRMLS_CC);
+ zend_ulong key = realpath_cache_key(path, path_len TSRMLS_CC);
#else
- unsigned long key = realpath_cache_key(path, path_len);
+ zend_ulong key = realpath_cache_key(path, path_len);
#endif
- unsigned long n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
+ zend_ulong n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
realpath_cache_bucket **bucket = &CWDG(realpath_cache)[n];
while (*bucket != NULL) {
@@ -668,7 +668,7 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{
static inline void realpath_cache_add(const char *path, int path_len, const char *realpath, int realpath_len, int is_dir, time_t t TSRMLS_DC) /* {{{ */
{
- long size = sizeof(realpath_cache_bucket) + path_len + 1;
+ zend_long size = sizeof(realpath_cache_bucket) + path_len + 1;
int same = 1;
if (realpath_len != path_len ||
@@ -679,7 +679,7 @@ static inline void realpath_cache_add(const char *path, int path_len, const char
if (CWDG(realpath_cache_size) + size <= CWDG(realpath_cache_size_limit)) {
realpath_cache_bucket *bucket = malloc(size);
- unsigned long n;
+ zend_ulong n;
if (bucket == NULL) {
return;
@@ -719,12 +719,12 @@ static inline void realpath_cache_add(const char *path, int path_len, const char
static inline realpath_cache_bucket* realpath_cache_find(const char *path, int path_len, time_t t TSRMLS_DC) /* {{{ */
{
#ifdef PHP_WIN32
- unsigned long key = realpath_cache_key(path, path_len TSRMLS_CC);
+ zend_ulong key = realpath_cache_key(path, path_len TSRMLS_CC);
#else
- unsigned long key = realpath_cache_key(path, path_len);
+ zend_ulong key = realpath_cache_key(path, path_len);
#endif
- unsigned long n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
+ zend_ulong n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
realpath_cache_bucket **bucket = &CWDG(realpath_cache)[n];
while (*bucket != NULL) {
@@ -756,12 +756,12 @@ CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_
}
/* }}} */
-CWD_API int realpath_cache_size(TSRMLS_D)
+CWD_API zend_long realpath_cache_size(TSRMLS_D)
{
return CWDG(realpath_cache_size);
}
-CWD_API int realpath_cache_max_buckets(TSRMLS_D)
+CWD_API zend_long realpath_cache_max_buckets(TSRMLS_D)
{
return (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
}
@@ -784,7 +784,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
HANDLE hFind;
ALLOCA_FLAG(use_heap_large)
#else
- struct stat st;
+ zend_stat_t st;
#endif
realpath_cache_bucket *bucket;
char *tmp;
@@ -1739,7 +1739,7 @@ CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC) /
}
/* }}} */
-CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ */
+CWD_API int virtual_stat(const char *path, zend_stat_t *buf TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int retval;
@@ -1757,7 +1757,7 @@ CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ */
}
/* }}} */
-CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ */
+CWD_API int virtual_lstat(const char *path, zend_stat_t *buf TSRMLS_DC) /* {{{ */
{
cwd_state new_state;
int retval;
diff --git a/Zend/zend_virtual_cwd.h b/Zend/zend_virtual_cwd.h
index b0df0ad310..b439d3eaa7 100644
--- a/Zend/zend_virtual_cwd.h
+++ b/Zend/zend_virtual_cwd.h
@@ -130,7 +130,7 @@ typedef unsigned short mode_t;
#endif
#ifdef TSRM_WIN32
-CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat);
+CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat);
# define php_sys_stat(path, buf) php_sys_stat_ex(path, buf, 0)
# define php_sys_lstat(path, buf) php_sys_stat_ex(path, buf, 1)
CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len);
@@ -164,8 +164,8 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC);
CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...);
CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC);
CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC);
-CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC);
-CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC);
+CWD_API int virtual_stat(const char *path, zend_stat_t *buf TSRMLS_DC);
+CWD_API int virtual_lstat(const char *path, zend_stat_t *buf TSRMLS_DC);
CWD_API int virtual_unlink(const char *path TSRMLS_DC);
CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC);
CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC);
@@ -211,7 +211,7 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC);
#define REALPATH_CACHE_SIZE 0 /* disabled while php.ini isn't loaded */
typedef struct _realpath_cache_bucket {
- unsigned long key;
+ zend_ulong key;
char *path;
int path_len;
char *realpath;
@@ -229,9 +229,9 @@ typedef struct _realpath_cache_bucket {
typedef struct _virtual_cwd_globals {
cwd_state cwd;
- long realpath_cache_size;
- long realpath_cache_size_limit;
- long realpath_cache_ttl;
+ zend_long realpath_cache_size;
+ zend_long realpath_cache_size_limit;
+ zend_long realpath_cache_ttl;
realpath_cache_bucket *realpath_cache[1024];
} virtual_cwd_globals;
@@ -246,8 +246,8 @@ extern virtual_cwd_globals cwd_globals;
CWD_API void realpath_cache_clean(TSRMLS_D);
CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC);
CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_len, time_t t TSRMLS_DC);
-CWD_API int realpath_cache_size(TSRMLS_D);
-CWD_API int realpath_cache_max_buckets(TSRMLS_D);
+CWD_API zend_long realpath_cache_size(TSRMLS_D);
+CWD_API zend_long realpath_cache_max_buckets(TSRMLS_D);
CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D);
/* The actual macros to be used in programs using TSRM
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 3122119998..388a262b18 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -1116,7 +1116,7 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMP|VAR|CV, UNUSED|CONST|
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -1131,7 +1131,7 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMP|VAR|CV, UNUSED|CONST|
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (OP1_TYPE != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
FREE_OP1();
CHECK_EXCEPTION();
@@ -1198,7 +1198,7 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMP|VAR|CV, UNUSED|CONST|
}
if (OP1_TYPE != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -2418,16 +2418,16 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV)
ZVAL_DEREF(function_name);
if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
if (Z_STRVAL_P(function_name)[0] == '\\') {
- lcname = STR_ALLOC(Z_STRLEN_P(function_name) - 1, 0);
+ lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
} else {
- lcname = STR_ALLOC(Z_STRLEN_P(function_name), 0);
+ lcname = zend_string_alloc(Z_STRLEN_P(function_name), 0);
zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name));
}
if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
}
- STR_FREE(lcname);
+ zend_string_free(lcname);
FREE_OP2();
fbc = Z_FUNC_P(func);
@@ -2677,7 +2677,7 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
EG(current_execute_data) = call;
if (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
- zend_uint i;
+ uint32_t i;
zval *p = ZEND_CALL_ARG(call, 1);
for (i = 0; i < call->num_args; ++i) {
@@ -2774,7 +2774,7 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
zend_vm_stack_free_call_frame(call TSRMLS_CC);
if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
- STR_RELEASE(fbc->common.function_name);
+ zend_string_release(fbc->common.function_name);
}
efree(fbc);
@@ -3083,10 +3083,7 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY)
varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) ||
(Z_VAR_FLAGS_P(varptr) & IS_VAR_RET_REF)) &&
- ((!Z_REFCOUNTED_P(varptr) && Z_TYPE_P(varptr) != IS_STRING) ||
- Z_ISREF_P(varptr) ||
- Z_TYPE_P(varptr) == IS_OBJECT ||
- (Z_REFCOUNTED_P(varptr) && Z_REFCOUNT_P(varptr) == 1))) {
+ (Z_ISREF_P(varptr) || Z_TYPE_P(varptr) == IS_OBJECT)) {
ZVAL_MAKE_REF(varptr);
if (OP1_TYPE == IS_CV) {
@@ -3358,7 +3355,7 @@ ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY)
EX(call)->called_scope = NULL;
EX(call)->object = NULL;
} else {
- zend_uint arg_num = 1;
+ uint32_t arg_num = 1;
HashTable *ht = Z_ARRVAL_P(args);
zval *arg, *param, tmp;
@@ -3366,7 +3363,7 @@ ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY)
zend_vm_stack_extend_call_frame(&EX(call), 0, zend_hash_num_elements(ht) TSRMLS_CC);
if (OP1_TYPE != IS_CONST && OP1_TYPE != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
- zend_uint i;
+ uint32_t i;
int separate = 0;
/* check if any of arguments are going to be passed by reference */
@@ -3536,7 +3533,7 @@ ZEND_VM_HANDLER(120, ZEND_SEND_USER, VAR|CV, ANY)
ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY)
{
USE_OPLINE
- zend_uint arg_num = opline->op1.num;
+ uint32_t arg_num = opline->op1.num;
SAVE_OPLINE();
if (UNEXPECTED(arg_num > EX(num_args))) {
@@ -3555,7 +3552,7 @@ ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY)
ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
{
USE_OPLINE
- zend_uint arg_num = opline->op1.num;
+ uint32_t arg_num = opline->op1.num;
zval *param;
SAVE_OPLINE();
@@ -3583,8 +3580,8 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
ZEND_VM_HANDLER(164, ZEND_RECV_VARIADIC, ANY, ANY)
{
USE_OPLINE
- zend_uint arg_num = opline->op1.num;
- zend_uint arg_count = EX(num_args);
+ uint32_t arg_num = opline->op1.num;
+ uint32_t arg_count = EX(num_args);
zval *params;
SAVE_OPLINE();
@@ -3898,7 +3895,7 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
} else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) {
/* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */
ZVAL_STR(EX_VAR(opline->result.var), ce->name);
- STR_ADDREF(ce->name);
+ zend_string_addref(ce->name);
} else {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv));
}
@@ -3947,7 +3944,7 @@ ZEND_VM_HANDLER(72, ZEND_ADD_ARRAY_ELEMENT, CONST|TMP|VAR|CV, CONST|TMP|VAR|UNUS
zend_free_op free_op2;
zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
ZEND_VM_C_LABEL(add_again):
switch (Z_TYPE_P(offset)) {
@@ -3999,7 +3996,7 @@ ZEND_VM_C_LABEL(str_index):
ZEND_VM_HANDLER(71, ZEND_INIT_ARRAY, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|UNUSED|CV)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -4338,7 +4335,7 @@ ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
zend_free_op free_op1, free_op2;
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET);
@@ -4548,15 +4545,23 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
}
ZVAL_DUP(&tmp, array_ref);
array_ptr = array_ref = &tmp;
- } else if (OP1_TYPE == IS_CV) {
+ } else if (OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) {
if (Z_ISREF_P(array_ref) && Z_REFCOUNT_P(array_ref) == 1) {
ZVAL_UNREF(array_ref);
array_ptr = array_ref;
}
- if (Z_IMMUTABLE_P(array_ptr)) {
+ if (Z_IMMUTABLE_P(array_ptr) ||
+ (Z_ISREF_P(array_ref) &&
+ Z_REFCOUNTED_P(array_ptr) &&
+ Z_REFCOUNT_P(array_ptr) > 1)) {
+ if (!Z_IMMUTABLE_P(array_ptr)) {
+ Z_DELREF_P(array_ptr);
+ }
zval_copy_ctor(array_ptr);
}
- Z_ADDREF_P(array_ref);
+ if (OP1_TYPE == IS_CV) {
+ Z_ADDREF_P(array_ref);
+ }
}
}
}
@@ -4611,7 +4616,7 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
zend_object *zobj = Z_OBJ_P(array_ptr);
while (zend_hash_has_more_elements(fe_ht) == SUCCESS) {
zend_string *str_key;
- ulong int_key;
+ zend_ulong int_key;
zend_uchar key_type;
key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
@@ -4875,7 +4880,7 @@ ZEND_VM_HANDLER(115, ZEND_ISSET_ISEMPTY_DIM_OBJ, CONST|TMP|VAR|UNUSED|CV, CONST|
zend_free_op free_op1, free_op2;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -4957,7 +4962,7 @@ ZEND_VM_C_LABEL(num_index_prop):
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -5097,7 +5102,7 @@ ZEND_VM_HANDLER(58, ZEND_END_SILENCE, TMP, ANY)
SAVE_OPLINE();
if (!EG(error_reporting) && Z_LVAL_P(EX_VAR(opline->op1.var)) != 0) {
EG(error_reporting) = Z_LVAL_P(EX_VAR(opline->op1.var));
- _zend_print_signed_to_buf(buf + sizeof(buf) - 1, EG(error_reporting), unsigned long, res);
+ _zend_print_signed_to_buf(buf + sizeof(buf) - 1, EG(error_reporting), zend_ulong, res);
if (EXPECTED(EG(error_reporting_ini_entry) != NULL)) {
if (EXPECTED(EG(error_reporting_ini_entry)->modified &&
EG(error_reporting_ini_entry)->value != EG(error_reporting_ini_entry)->orig_value)) {
@@ -5396,9 +5401,9 @@ ZEND_VM_HANDLER(155, ZEND_BIND_TRAITS, ANY, ANY)
ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
{
- zend_uint op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes;
+ uint32_t op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes;
int i;
- zend_uint catch_op_num = 0, finally_op_num = 0, finally_op_end = 0;
+ uint32_t catch_op_num = 0, finally_op_num = 0, finally_op_end = 0;
for (i = 0; i < EX(func)->op_array.last_try_catch; i++) {
if (EX(func)->op_array.try_catch_array[i].try_op > op_num) {
@@ -5472,9 +5477,9 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
ZVAL_LONG(&restored_error_reporting, Z_LVAL(EX(old_error_reporting)));
convert_to_string(&restored_error_reporting);
- key = STR_INIT("error_reporting", sizeof("error_reporting")-1, 0);
+ key = zend_string_init("error_reporting", sizeof("error_reporting")-1, 0);
zend_alter_ini_entry_ex(key, Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME, 1 TSRMLS_CC);
- STR_FREE(key);
+ zend_string_free(key);
zval_dtor(&restored_error_reporting);
}
ZVAL_UNDEF(&EX(old_error_reporting));
@@ -5572,7 +5577,7 @@ ZEND_VM_HANDLER(143, ZEND_DECLARE_CONST, CONST, CONST)
}
}
c.flags = CONST_CS; /* non persistent, case sensetive */
- c.name = STR_DUP(Z_STR_P(name), 0);
+ c.name = zend_string_dup(Z_STR_P(name), 0);
c.module_number = PHP_USER_CONSTANT;
if (zend_register_constant(&c TSRMLS_CC) == FAILURE) {
@@ -5883,7 +5888,7 @@ ZEND_VM_HANDLER(121, ZEND_STRLEN, CONST|TMP|VAR|CV, ANY)
} else if (Z_TYPE_P(value) <= IS_DOUBLE) {
zend_string *str = zval_get_string(value);
ZVAL_LONG(EX_VAR(opline->result.var), str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else if (Z_TYPE_P(value) == IS_OBJECT) {
zend_string *str;
@@ -5891,7 +5896,7 @@ ZEND_VM_HANDLER(121, ZEND_STRLEN, CONST|TMP|VAR|CV, ANY)
ZEND_VM_C_GOTO(strlen_error);
}
ZVAL_LONG(EX_VAR(opline->result.var), str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
ZEND_VM_C_LABEL(strlen_error):
zend_error(E_WARNING, "strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 8605333d05..3568e03ae6 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -564,7 +564,7 @@ static int ZEND_FASTCALL ZEND_DO_FCALL_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
EG(current_execute_data) = call;
if (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
- zend_uint i;
+ uint32_t i;
zval *p = ZEND_CALL_ARG(call, 1);
for (i = 0; i < call->num_args; ++i) {
@@ -661,7 +661,7 @@ static int ZEND_FASTCALL ZEND_DO_FCALL_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zend_vm_stack_free_call_frame(call TSRMLS_CC);
if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
- STR_RELEASE(fbc->common.function_name);
+ zend_string_release(fbc->common.function_name);
}
efree(fbc);
@@ -904,7 +904,7 @@ static int ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
EX(call)->called_scope = NULL;
EX(call)->object = NULL;
} else {
- zend_uint arg_num = 1;
+ uint32_t arg_num = 1;
HashTable *ht = Z_ARRVAL_P(args);
zval *arg, *param, tmp;
@@ -912,7 +912,7 @@ static int ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zend_vm_stack_extend_call_frame(&EX(call), 0, zend_hash_num_elements(ht) TSRMLS_CC);
if (opline->op1_type != IS_CONST && opline->op1_type != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
- zend_uint i;
+ uint32_t i;
int separate = 0;
/* check if any of arguments are going to be passed by reference */
@@ -1003,7 +1003,7 @@ static int ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
static int ZEND_FASTCALL ZEND_RECV_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
- zend_uint arg_num = opline->op1.num;
+ uint32_t arg_num = opline->op1.num;
SAVE_OPLINE();
if (UNEXPECTED(arg_num > EX(num_args))) {
@@ -1022,8 +1022,8 @@ static int ZEND_FASTCALL ZEND_RECV_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
static int ZEND_FASTCALL ZEND_RECV_VARIADIC_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
- zend_uint arg_num = opline->op1.num;
- zend_uint arg_count = EX(num_args);
+ uint32_t arg_num = opline->op1.num;
+ uint32_t arg_count = EX(num_args);
zval *params;
SAVE_OPLINE();
@@ -1297,9 +1297,9 @@ static int ZEND_FASTCALL ZEND_BIND_TRAITS_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS
static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
- zend_uint op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes;
+ uint32_t op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes;
int i;
- zend_uint catch_op_num = 0, finally_op_num = 0, finally_op_end = 0;
+ uint32_t catch_op_num = 0, finally_op_num = 0, finally_op_end = 0;
for (i = 0; i < EX(func)->op_array.last_try_catch; i++) {
if (EX(func)->op_array.try_catch_array[i].try_op > op_num) {
@@ -1373,9 +1373,9 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER
ZVAL_LONG(&restored_error_reporting, Z_LVAL(EX(old_error_reporting)));
convert_to_string(&restored_error_reporting);
- key = STR_INIT("error_reporting", sizeof("error_reporting")-1, 0);
+ key = zend_string_init("error_reporting", sizeof("error_reporting")-1, 0);
zend_alter_ini_entry_ex(key, Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME, 1 TSRMLS_CC);
- STR_FREE(key);
+ zend_string_free(key);
zval_dtor(&restored_error_reporting);
}
ZVAL_UNDEF(&EX(old_error_reporting));
@@ -1583,16 +1583,16 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE
ZVAL_DEREF(function_name);
if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
if (Z_STRVAL_P(function_name)[0] == '\\') {
- lcname = STR_ALLOC(Z_STRLEN_P(function_name) - 1, 0);
+ lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
} else {
- lcname = STR_ALLOC(Z_STRLEN_P(function_name), 0);
+ lcname = zend_string_alloc(Z_STRLEN_P(function_name), 0);
zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name));
}
if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
}
- STR_FREE(lcname);
+ zend_string_free(lcname);
fbc = Z_FUNC_P(func);
called_scope = NULL;
@@ -1737,7 +1737,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER
static int ZEND_FASTCALL ZEND_RECV_INIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
- zend_uint arg_num = opline->op1.num;
+ uint32_t arg_num = opline->op1.num;
zval *param;
SAVE_OPLINE();
@@ -1911,16 +1911,16 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H
ZVAL_DEREF(function_name);
if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
if (Z_STRVAL_P(function_name)[0] == '\\') {
- lcname = STR_ALLOC(Z_STRLEN_P(function_name) - 1, 0);
+ lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
} else {
- lcname = STR_ALLOC(Z_STRLEN_P(function_name), 0);
+ lcname = zend_string_alloc(Z_STRLEN_P(function_name), 0);
zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name));
}
if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
}
- STR_FREE(lcname);
+ zend_string_free(lcname);
zval_dtor(free_op2.var);
fbc = Z_FUNC_P(func);
@@ -2085,16 +2085,16 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H
ZVAL_DEREF(function_name);
if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
if (Z_STRVAL_P(function_name)[0] == '\\') {
- lcname = STR_ALLOC(Z_STRLEN_P(function_name) - 1, 0);
+ lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
} else {
- lcname = STR_ALLOC(Z_STRLEN_P(function_name), 0);
+ lcname = zend_string_alloc(Z_STRLEN_P(function_name), 0);
zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name));
}
if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
}
- STR_FREE(lcname);
+ zend_string_free(lcname);
zval_ptr_dtor_nogc(free_op2.var);
fbc = Z_FUNC_P(func);
@@ -2297,16 +2297,16 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA
ZVAL_DEREF(function_name);
if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
if (Z_STRVAL_P(function_name)[0] == '\\') {
- lcname = STR_ALLOC(Z_STRLEN_P(function_name) - 1, 0);
+ lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
} else {
- lcname = STR_ALLOC(Z_STRLEN_P(function_name), 0);
+ lcname = zend_string_alloc(Z_STRLEN_P(function_name), 0);
zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name));
}
if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
}
- STR_FREE(lcname);
+ zend_string_free(lcname);
fbc = Z_FUNC_P(func);
called_scope = NULL;
@@ -3154,15 +3154,23 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A
}
ZVAL_DUP(&tmp, array_ref);
array_ptr = array_ref = &tmp;
- } else if (IS_CONST == IS_CV) {
+ } else if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
if (Z_ISREF_P(array_ref) && Z_REFCOUNT_P(array_ref) == 1) {
ZVAL_UNREF(array_ref);
array_ptr = array_ref;
}
- if (Z_IMMUTABLE_P(array_ptr)) {
+ if (Z_IMMUTABLE_P(array_ptr) ||
+ (Z_ISREF_P(array_ref) &&
+ Z_REFCOUNTED_P(array_ptr) &&
+ Z_REFCOUNT_P(array_ptr) > 1)) {
+ if (!Z_IMMUTABLE_P(array_ptr)) {
+ Z_DELREF_P(array_ptr);
+ }
zval_copy_ctor(array_ptr);
}
- Z_ADDREF_P(array_ref);
+ if (IS_CONST == IS_CV) {
+ Z_ADDREF_P(array_ref);
+ }
}
}
}
@@ -3217,7 +3225,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A
zend_object *zobj = Z_OBJ_P(array_ptr);
while (zend_hash_has_more_elements(fe_ht) == SUCCESS) {
zend_string *str_key;
- ulong int_key;
+ zend_ulong int_key;
zend_uchar key_type;
key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
@@ -3377,7 +3385,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG
} else if (Z_TYPE_P(value) <= IS_DOUBLE) {
zend_string *str = zval_get_string(value);
ZVAL_LONG(EX_VAR(opline->result.var), str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else if (Z_TYPE_P(value) == IS_OBJECT) {
zend_string *str;
@@ -3385,7 +3393,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG
goto strlen_error;
}
ZVAL_LONG(EX_VAR(opline->result.var), str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
strlen_error:
zend_error(E_WARNING, "strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
@@ -3759,7 +3767,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_CONST(int type
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -3774,7 +3782,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_CONST(int type
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_CONST != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
CHECK_EXCEPTION();
@@ -3841,7 +3849,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_CONST(int type
}
if (IS_CONST != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -4345,7 +4353,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO
} else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) {
/* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */
ZVAL_STR(EX_VAR(opline->result.var), ce->name);
- STR_ADDREF(ce->name);
+ zend_string_addref(ce->name);
} else {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv));
}
@@ -4394,7 +4402,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CONST_HANDLER(ZEND_O
zval *offset = opline->op2.zv;
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -4446,7 +4454,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -4632,7 +4640,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CONST_CONST_HANDLER(ZE
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -4687,7 +4695,8 @@ num_index_prop:
if (opline->extended_value & ZEND_ISSET) {
/* > IS_NULL means not IS_UNDEF and not IS_NULL */
- result = (value != NULL && Z_TYPE_P(value) > IS_NULL);
+ result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
+ (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
result = (value == NULL || !i_zend_is_true(value TSRMLS_CC));
}
@@ -4706,11 +4715,14 @@ num_index_prop:
result = 0;
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
+ if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
+ ZVAL_DEREF(offset);
+ }
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -4789,7 +4801,7 @@ static int ZEND_FASTCALL ZEND_DECLARE_CONST_SPEC_CONST_CONST_HANDLER(ZEND_OPCOD
}
}
c.flags = CONST_CS; /* non persistent, case sensetive */
- c.name = STR_DUP(Z_STR_P(name), 0);
+ c.name = zend_string_dup(Z_STR_P(name), 0);
c.module_number = PHP_USER_CONSTANT;
if (zend_register_constant(&c TSRMLS_CC) == FAILURE) {
@@ -5603,7 +5615,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_TMP_HANDLER(ZEND_OPC
zend_free_op free_op2;
zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -5655,7 +5667,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -5689,7 +5701,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CONST_TMP_HANDLER(ZEND
zend_free_op free_op2;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -5744,7 +5756,8 @@ num_index_prop:
if (opline->extended_value & ZEND_ISSET) {
/* > IS_NULL means not IS_UNDEF and not IS_NULL */
- result = (value != NULL && Z_TYPE_P(value) > IS_NULL);
+ result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
+ (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
result = (value == NULL || !i_zend_is_true(value TSRMLS_CC));
}
@@ -5763,11 +5776,14 @@ num_index_prop:
result = 0;
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
+ if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
+ ZVAL_DEREF(offset);
+ }
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -6262,7 +6278,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_VAR(int type,
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -6277,7 +6293,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_VAR(int type,
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_CONST != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
CHECK_EXCEPTION();
@@ -6344,7 +6360,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_VAR(int type,
}
if (IS_CONST != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -6782,7 +6798,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_VAR_HANDLER(ZEND_OPC
zend_free_op free_op2;
zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -6834,7 +6850,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -7020,7 +7036,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CONST_VAR_HANDLER(ZEND
zend_free_op free_op2;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -7075,7 +7091,8 @@ num_index_prop:
if (opline->extended_value & ZEND_ISSET) {
/* > IS_NULL means not IS_UNDEF and not IS_NULL */
- result = (value != NULL && Z_TYPE_P(value) > IS_NULL);
+ result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
+ (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
result = (value == NULL || !i_zend_is_true(value TSRMLS_CC));
}
@@ -7094,11 +7111,14 @@ num_index_prop:
result = 0;
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
+ if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
+ ZVAL_DEREF(offset);
+ }
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -7318,7 +7338,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_UNUSED(int typ
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -7333,7 +7353,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_UNUSED(int typ
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_CONST != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
CHECK_EXCEPTION();
@@ -7400,7 +7420,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_UNUSED(int typ
}
if (IS_CONST != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -7645,7 +7665,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_UNUSED_HANDLER(ZEND_
zval *offset = NULL;
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -7697,7 +7717,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -8739,7 +8759,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CV_HANDLER(ZEND_OPCO
zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -8791,7 +8811,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -8825,7 +8845,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CONST_CV_HANDLER(ZEND_
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -8880,7 +8900,8 @@ num_index_prop:
if (opline->extended_value & ZEND_ISSET) {
/* > IS_NULL means not IS_UNDEF and not IS_NULL */
- result = (value != NULL && Z_TYPE_P(value) > IS_NULL);
+ result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
+ (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
result = (value == NULL || !i_zend_is_true(value TSRMLS_CC));
}
@@ -8899,11 +8920,14 @@ num_index_prop:
result = 0;
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
+ if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
+ ZVAL_DEREF(offset);
+ }
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -9882,15 +9906,23 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
}
ZVAL_DUP(&tmp, array_ref);
array_ptr = array_ref = &tmp;
- } else if (IS_TMP_VAR == IS_CV) {
+ } else if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
if (Z_ISREF_P(array_ref) && Z_REFCOUNT_P(array_ref) == 1) {
ZVAL_UNREF(array_ref);
array_ptr = array_ref;
}
- if (Z_IMMUTABLE_P(array_ptr)) {
+ if (Z_IMMUTABLE_P(array_ptr) ||
+ (Z_ISREF_P(array_ref) &&
+ Z_REFCOUNTED_P(array_ptr) &&
+ Z_REFCOUNT_P(array_ptr) > 1)) {
+ if (!Z_IMMUTABLE_P(array_ptr)) {
+ Z_DELREF_P(array_ptr);
+ }
zval_copy_ctor(array_ptr);
}
- Z_ADDREF_P(array_ref);
+ if (IS_TMP_VAR == IS_CV) {
+ Z_ADDREF_P(array_ref);
+ }
}
}
}
@@ -9945,7 +9977,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
zend_object *zobj = Z_OBJ_P(array_ptr);
while (zend_hash_has_more_elements(fe_ht) == SUCCESS) {
zend_string *str_key;
- ulong int_key;
+ zend_ulong int_key;
zend_uchar key_type;
key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
@@ -10006,7 +10038,7 @@ static int ZEND_FASTCALL ZEND_END_SILENCE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_
SAVE_OPLINE();
if (!EG(error_reporting) && Z_LVAL_P(EX_VAR(opline->op1.var)) != 0) {
EG(error_reporting) = Z_LVAL_P(EX_VAR(opline->op1.var));
- _zend_print_signed_to_buf(buf + sizeof(buf) - 1, EG(error_reporting), unsigned long, res);
+ _zend_print_signed_to_buf(buf + sizeof(buf) - 1, EG(error_reporting), zend_ulong, res);
if (EXPECTED(EG(error_reporting_ini_entry) != NULL)) {
if (EXPECTED(EG(error_reporting_ini_entry)->modified &&
EG(error_reporting_ini_entry)->value != EG(error_reporting_ini_entry)->orig_value)) {
@@ -10154,7 +10186,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else if (Z_TYPE_P(value) <= IS_DOUBLE) {
zend_string *str = zval_get_string(value);
ZVAL_LONG(EX_VAR(opline->result.var), str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else if (Z_TYPE_P(value) == IS_OBJECT) {
zend_string *str;
@@ -10162,7 +10194,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
goto strlen_error;
}
ZVAL_LONG(EX_VAR(opline->result.var), str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
strlen_error:
zend_error(E_WARNING, "strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
@@ -10516,7 +10548,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type,
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -10531,7 +10563,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type,
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_TMP_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
zval_dtor(free_op1.var);
CHECK_EXCEPTION();
@@ -10598,7 +10630,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type,
}
if (IS_TMP_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -11005,7 +11037,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CONST_HANDLER(ZEND_OPC
zval *offset = opline->op2.zv;
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -11057,7 +11089,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -11243,7 +11275,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP_CONST_HANDLER(ZEND
zend_free_op free_op1;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -11298,7 +11330,8 @@ num_index_prop:
if (opline->extended_value & ZEND_ISSET) {
/* > IS_NULL means not IS_UNDEF and not IS_NULL */
- result = (value != NULL && Z_TYPE_P(value) > IS_NULL);
+ result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
+ (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
result = (value == NULL || !i_zend_is_true(value TSRMLS_CC));
}
@@ -11317,11 +11350,14 @@ num_index_prop:
result = 0;
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
+ if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
+ ZVAL_DEREF(offset);
+ }
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -12138,7 +12174,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP_HANDLER(ZEND_OPCOD
zend_free_op free_op2;
zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -12190,7 +12226,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -12224,7 +12260,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP_TMP_HANDLER(ZEND_O
zend_free_op free_op1, free_op2;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -12279,7 +12315,8 @@ num_index_prop:
if (opline->extended_value & ZEND_ISSET) {
/* > IS_NULL means not IS_UNDEF and not IS_NULL */
- result = (value != NULL && Z_TYPE_P(value) > IS_NULL);
+ result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
+ (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
result = (value == NULL || !i_zend_is_true(value TSRMLS_CC));
}
@@ -12298,11 +12335,14 @@ num_index_prop:
result = 0;
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
+ if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
+ ZVAL_DEREF(offset);
+ }
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -12797,7 +12837,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -12812,7 +12852,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_TMP_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
zval_dtor(free_op1.var);
CHECK_EXCEPTION();
@@ -12879,7 +12919,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE
}
if (IS_TMP_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -13274,7 +13314,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_VAR_HANDLER(ZEND_OPCOD
zend_free_op free_op2;
zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -13326,7 +13366,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -13512,7 +13552,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP_VAR_HANDLER(ZEND_O
zend_free_op free_op1, free_op2;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -13567,7 +13607,8 @@ num_index_prop:
if (opline->extended_value & ZEND_ISSET) {
/* > IS_NULL means not IS_UNDEF and not IS_NULL */
- result = (value != NULL && Z_TYPE_P(value) > IS_NULL);
+ result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
+ (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
result = (value == NULL || !i_zend_is_true(value TSRMLS_CC));
}
@@ -13586,11 +13627,14 @@ num_index_prop:
result = 0;
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
+ if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
+ ZVAL_DEREF(offset);
+ }
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -13810,7 +13854,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type,
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -13825,7 +13869,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type,
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_TMP_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
zval_dtor(free_op1.var);
CHECK_EXCEPTION();
@@ -13892,7 +13936,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type,
}
if (IS_TMP_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -14021,7 +14065,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNUSED_HANDLER(ZEND_OP
zval *offset = NULL;
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -14073,7 +14117,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -14993,7 +15037,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE
zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -15045,7 +15089,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -15079,7 +15123,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP_CV_HANDLER(ZEND_OP
zend_free_op free_op1;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -15134,7 +15178,8 @@ num_index_prop:
if (opline->extended_value & ZEND_ISSET) {
/* > IS_NULL means not IS_UNDEF and not IS_NULL */
- result = (value != NULL && Z_TYPE_P(value) > IS_NULL);
+ result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
+ (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
result = (value == NULL || !i_zend_is_true(value TSRMLS_CC));
}
@@ -15153,11 +15198,14 @@ num_index_prop:
result = 0;
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
+ if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
+ ZVAL_DEREF(offset);
+ }
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -15962,10 +16010,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND
varptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) ||
(Z_VAR_FLAGS_P(varptr) & IS_VAR_RET_REF)) &&
- ((!Z_REFCOUNTED_P(varptr) && Z_TYPE_P(varptr) != IS_STRING) ||
- Z_ISREF_P(varptr) ||
- Z_TYPE_P(varptr) == IS_OBJECT ||
- (Z_REFCOUNTED_P(varptr) && Z_REFCOUNT_P(varptr) == 1))) {
+ (Z_ISREF_P(varptr) || Z_TYPE_P(varptr) == IS_OBJECT)) {
ZVAL_MAKE_REF(varptr);
if (IS_VAR == IS_CV) {
@@ -16533,15 +16578,23 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
}
ZVAL_DUP(&tmp, array_ref);
array_ptr = array_ref = &tmp;
- } else if (IS_VAR == IS_CV) {
+ } else if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
if (Z_ISREF_P(array_ref) && Z_REFCOUNT_P(array_ref) == 1) {
ZVAL_UNREF(array_ref);
array_ptr = array_ref;
}
- if (Z_IMMUTABLE_P(array_ptr)) {
+ if (Z_IMMUTABLE_P(array_ptr) ||
+ (Z_ISREF_P(array_ref) &&
+ Z_REFCOUNTED_P(array_ptr) &&
+ Z_REFCOUNT_P(array_ptr) > 1)) {
+ if (!Z_IMMUTABLE_P(array_ptr)) {
+ Z_DELREF_P(array_ptr);
+ }
zval_copy_ctor(array_ptr);
}
- Z_ADDREF_P(array_ref);
+ if (IS_VAR == IS_CV) {
+ Z_ADDREF_P(array_ref);
+ }
}
}
}
@@ -16596,7 +16649,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
zend_object *zobj = Z_OBJ_P(array_ptr);
while (zend_hash_has_more_elements(fe_ht) == SUCCESS) {
zend_string *str_key;
- ulong int_key;
+ zend_ulong int_key;
zend_uchar key_type;
key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
@@ -16927,7 +16980,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else if (Z_TYPE_P(value) <= IS_DOUBLE) {
zend_string *str = zval_get_string(value);
ZVAL_LONG(EX_VAR(opline->result.var), str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else if (Z_TYPE_P(value) == IS_OBJECT) {
zend_string *str;
@@ -16935,7 +16988,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
goto strlen_error;
}
ZVAL_LONG(EX_VAR(opline->result.var), str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
strlen_error:
zend_error(E_WARNING, "strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
@@ -17818,7 +17871,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type,
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -17833,7 +17886,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type,
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
zval_ptr_dtor_nogc(free_op1.var);
CHECK_EXCEPTION();
@@ -17900,7 +17953,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type,
}
if (IS_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -18680,7 +18733,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE
} else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) {
/* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */
ZVAL_STR(EX_VAR(opline->result.var), ce->name);
- STR_ADDREF(ce->name);
+ zend_string_addref(ce->name);
} else {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv));
}
@@ -18729,7 +18782,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CONST_HANDLER(ZEND_OPC
zval *offset = opline->op2.zv;
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -18781,7 +18834,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -18887,7 +18940,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND
zend_free_op free_op1;
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
@@ -19095,7 +19148,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_CONST_HANDLER(ZEND
zend_free_op free_op1;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -19177,7 +19230,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -20874,7 +20927,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCOD
zend_free_op free_op2;
zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -20926,7 +20979,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -20960,7 +21013,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE
zend_free_op free_op1, free_op2;
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
@@ -21088,7 +21141,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_O
zend_free_op free_op1, free_op2;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -21170,7 +21223,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -22203,7 +22256,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -22218,7 +22271,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
zval_ptr_dtor_nogc(free_op1.var);
CHECK_EXCEPTION();
@@ -22285,7 +22338,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE
}
if (IS_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -23086,7 +23139,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCOD
zend_free_op free_op2;
zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -23138,7 +23191,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -23244,7 +23297,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE
zend_free_op free_op1, free_op2;
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
@@ -23452,7 +23505,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_O
zend_free_op free_op1, free_op2;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -23534,7 +23587,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -24111,7 +24164,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type,
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -24126,7 +24179,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type,
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
zval_ptr_dtor_nogc(free_op1.var);
CHECK_EXCEPTION();
@@ -24193,7 +24246,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type,
}
if (IS_VAR != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -24549,7 +24602,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_HANDLER(ZEND_OP
zval *offset = NULL;
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -24601,7 +24654,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -26478,7 +26531,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE
zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -26530,7 +26583,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -26564,7 +26617,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER
zend_free_op free_op1;
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
@@ -26692,7 +26745,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_CV_HANDLER(ZEND_OP
zend_free_op free_op1;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -26774,7 +26827,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -27981,7 +28034,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC
} else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) {
/* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */
ZVAL_STR(EX_VAR(opline->result.var), ce->name);
- STR_ADDREF(ce->name);
+ zend_string_addref(ce->name);
} else {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv));
}
@@ -27994,7 +28047,7 @@ constant_fetch_end:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -28028,7 +28081,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_H
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_obj_zval_ptr_unused(TSRMLS_C);
@@ -28156,7 +28209,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_CONST_HANDLER(Z
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -28238,7 +28291,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -29277,7 +29330,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_TMP_HANDLER(ZEND_OPC
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -29311,7 +29364,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN
zend_free_op free_op2;
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_obj_zval_ptr_unused(TSRMLS_C);
@@ -29439,7 +29492,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_TMP_HANDLER(ZEN
zend_free_op free_op2;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -29521,7 +29574,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -30562,7 +30615,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_VAR_HANDLER(ZEND_OPC
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -30596,7 +30649,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN
zend_free_op free_op2;
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_obj_zval_ptr_unused(TSRMLS_C);
@@ -30724,7 +30777,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_VAR_HANDLER(ZEN
zend_free_op free_op2;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -30806,7 +30859,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -31353,7 +31406,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_BW_XOR_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPC
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -32356,7 +32409,7 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CV_HANDLER(ZEND_OPCO
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -32390,7 +32443,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAND
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_obj_zval_ptr_unused(TSRMLS_C);
@@ -32518,7 +32571,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_CV_HANDLER(ZEND
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -32600,7 +32653,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -33375,10 +33428,7 @@ static int ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL
varptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC);
if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) ||
(Z_VAR_FLAGS_P(varptr) & IS_VAR_RET_REF)) &&
- ((!Z_REFCOUNTED_P(varptr) && Z_TYPE_P(varptr) != IS_STRING) ||
- Z_ISREF_P(varptr) ||
- Z_TYPE_P(varptr) == IS_OBJECT ||
- (Z_REFCOUNTED_P(varptr) && Z_REFCOUNT_P(varptr) == 1))) {
+ (Z_ISREF_P(varptr) || Z_TYPE_P(varptr) == IS_OBJECT)) {
ZVAL_MAKE_REF(varptr);
if (IS_CV == IS_CV) {
@@ -33930,15 +33980,23 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
}
ZVAL_DUP(&tmp, array_ref);
array_ptr = array_ref = &tmp;
- } else if (IS_CV == IS_CV) {
+ } else if (IS_CV == IS_CV || IS_CV == IS_VAR) {
if (Z_ISREF_P(array_ref) && Z_REFCOUNT_P(array_ref) == 1) {
ZVAL_UNREF(array_ref);
array_ptr = array_ref;
}
- if (Z_IMMUTABLE_P(array_ptr)) {
+ if (Z_IMMUTABLE_P(array_ptr) ||
+ (Z_ISREF_P(array_ref) &&
+ Z_REFCOUNTED_P(array_ptr) &&
+ Z_REFCOUNT_P(array_ptr) > 1)) {
+ if (!Z_IMMUTABLE_P(array_ptr)) {
+ Z_DELREF_P(array_ptr);
+ }
zval_copy_ctor(array_ptr);
}
- Z_ADDREF_P(array_ref);
+ if (IS_CV == IS_CV) {
+ Z_ADDREF_P(array_ref);
+ }
}
}
}
@@ -33993,7 +34051,7 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
zend_object *zobj = Z_OBJ_P(array_ptr);
while (zend_hash_has_more_elements(fe_ht) == SUCCESS) {
zend_string *str_key;
- ulong int_key;
+ zend_ulong int_key;
zend_uchar key_type;
key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
@@ -34174,7 +34232,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else if (Z_TYPE_P(value) <= IS_DOUBLE) {
zend_string *str = zval_get_string(value);
ZVAL_LONG(EX_VAR(opline->result.var), str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else if (Z_TYPE_P(value) == IS_OBJECT) {
zend_string *str;
@@ -34182,7 +34240,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
goto strlen_error;
}
ZVAL_LONG(EX_VAR(opline->result.var), str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
strlen_error:
zend_error(E_WARNING, "strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
@@ -35064,7 +35122,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_CONST(int type, Z
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -35079,7 +35137,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_CONST(int type, Z
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_CV != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
CHECK_EXCEPTION();
@@ -35146,7 +35204,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_CONST(int type, Z
}
if (IS_CV != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -35761,7 +35819,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONST_HANDLER(ZEND_OPCO
zval *offset = opline->op2.zv;
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -35813,7 +35871,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -35919,7 +35977,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDL
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC);
@@ -36127,7 +36185,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_CONST_HANDLER(ZEND_
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -36209,7 +36267,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -37817,7 +37875,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE
zend_free_op free_op2;
zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -37869,7 +37927,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -37903,7 +37961,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER
zend_free_op free_op2;
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC);
@@ -38031,7 +38089,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_TMP_HANDLER(ZEND_OP
zend_free_op free_op2;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -38113,7 +38171,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -39144,7 +39202,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_VAR(int type, ZEN
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -39159,7 +39217,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_VAR(int type, ZEN
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_CV != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
CHECK_EXCEPTION();
@@ -39226,7 +39284,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_VAR(int type, ZEN
}
if (IS_CV != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -39909,7 +39967,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE
zend_free_op free_op2;
zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -39961,7 +40019,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -40067,7 +40125,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER
zend_free_op free_op2;
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC);
@@ -40275,7 +40333,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_VAR_HANDLER(ZEND_OP
zend_free_op free_op2;
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -40357,7 +40415,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
@@ -40932,7 +40990,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_UNUSED(int type,
name = Z_STR_P(varname);
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
name = Z_STR_P(varname);
- STR_ADDREF(name);
+ zend_string_addref(name);
} else {
name = zval_get_string(varname);
}
@@ -40947,7 +41005,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_UNUSED(int type,
ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
if (IS_CV != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
CHECK_EXCEPTION();
@@ -41014,7 +41072,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_UNUSED(int type,
}
if (IS_CV != IS_CONST) {
- STR_RELEASE(name);
+ zend_string_release(name);
}
ZEND_ASSERT(retval != NULL);
@@ -41254,7 +41312,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUSED_HANDLER(ZEND_OPC
zval *offset = NULL;
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -41306,7 +41364,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -43045,7 +43103,7 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_HANDLER(ZEND_OPCODE_
zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC);
zend_string *str;
- ulong hval;
+ zend_ulong hval;
add_again:
switch (Z_TYPE_P(offset)) {
@@ -43097,7 +43155,7 @@ str_index:
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zval *array;
- zend_uint size;
+ uint32_t size;
USE_OPLINE
array = EX_VAR(opline->result.var);
@@ -43131,7 +43189,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_
zval *container;
zval *offset;
- ulong hval;
+ zend_ulong hval;
SAVE_OPLINE();
container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC);
@@ -43259,7 +43317,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_CV_HANDLER(ZEND_OPC
zval *container;
int result;
- ulong hval;
+ zend_ulong hval;
zval *offset;
SAVE_OPLINE();
@@ -43341,7 +43399,7 @@ num_index_prop:
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
ZVAL_DUP(&tmp, offset);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
offset = &tmp;
}
}
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c
index 4b8c7c5f18..a6775c8c84 100644
--- a/ext/bcmath/bcmath.c
+++ b/ext/bcmath/bcmath.c
@@ -206,7 +206,7 @@ static void php_str2num(bc_num *num, char *str TSRMLS_DC)
PHP_FUNCTION(bcadd)
{
char *left, *right;
- long scale_param = 0;
+ zend_long scale_param = 0;
bc_num first, second, result;
int left_len, right_len;
int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS();
@@ -244,7 +244,7 @@ PHP_FUNCTION(bcsub)
{
char *left, *right;
int left_len, right_len;
- long scale_param = 0;
+ zend_long scale_param = 0;
bc_num first, second, result;
int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS();
@@ -281,7 +281,7 @@ PHP_FUNCTION(bcmul)
{
char *left, *right;
int left_len, right_len;
- long scale_param = 0;
+ zend_long scale_param = 0;
bc_num first, second, result;
int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS();
@@ -318,7 +318,7 @@ PHP_FUNCTION(bcdiv)
{
char *left, *right;
int left_len, right_len;
- long scale_param = 0;
+ zend_long scale_param = 0;
bc_num first, second, result;
int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS();
@@ -396,7 +396,7 @@ PHP_FUNCTION(bcpowmod)
char *left, *right, *modulous;
int left_len, right_len, modulous_len;
bc_num first, second, mod, result;
- long scale = BCG(bc_precision);
+ zend_long scale = BCG(bc_precision);
int scale_int;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|l", &left, &left_len, &right, &right_len, &modulous, &modulous_len, &scale) == FAILURE) {
@@ -436,7 +436,7 @@ PHP_FUNCTION(bcpow)
{
char *left, *right;
int left_len, right_len;
- long scale_param = 0;
+ zend_long scale_param = 0;
bc_num first, second, result;
int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS();
@@ -473,7 +473,7 @@ PHP_FUNCTION(bcsqrt)
{
char *left;
int left_len;
- long scale_param = 0;
+ zend_long scale_param = 0;
bc_num result;
int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS();
@@ -508,7 +508,7 @@ PHP_FUNCTION(bccomp)
{
char *left, *right;
int left_len, right_len;
- long scale_param = 0;
+ zend_long scale_param = 0;
bc_num first, second;
int scale = BCG(bc_precision), argc = ZEND_NUM_ARGS();
@@ -537,7 +537,7 @@ PHP_FUNCTION(bccomp)
Sets default scale parameter for all bc math functions */
PHP_FUNCTION(bcscale)
{
- long new_scale;
+ zend_long new_scale;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &new_scale) == FAILURE) {
return;
diff --git a/ext/bcmath/libbcmath/src/num2str.c b/ext/bcmath/libbcmath/src/num2str.c
index 47990d2e92..e38bf87797 100644
--- a/ext/bcmath/libbcmath/src/num2str.c
+++ b/ext/bcmath/libbcmath/src/num2str.c
@@ -52,9 +52,9 @@ zend_string
/* Allocate the string memory. */
signch = ( num->n_sign == PLUS ? 0 : 1 ); /* Number of sign chars. */
if (num->n_scale > 0)
- str = STR_ALLOC(num->n_len + num->n_scale + signch + 1, 0);
+ str = zend_string_alloc(num->n_len + num->n_scale + signch + 1, 0);
else
- str = STR_ALLOC(num->n_len + signch, 0);
+ str = zend_string_alloc(num->n_len + signch, 0);
if (str == NULL) bc_out_of_memory();
/* The negative sign if needed. */
diff --git a/ext/bcmath/php_bcmath.h b/ext/bcmath/php_bcmath.h
index a18e5287e6..df16410004 100644
--- a/ext/bcmath/php_bcmath.h
+++ b/ext/bcmath/php_bcmath.h
@@ -45,7 +45,7 @@ ZEND_BEGIN_MODULE_GLOBALS(bcmath)
bc_num _zero_;
bc_num _one_;
bc_num _two_;
- long bc_precision;
+ zend_long bc_precision;
ZEND_END_MODULE_GLOBALS(bcmath)
#ifdef ZTS
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c
index db4e834a20..b2e8f40760 100644
--- a/ext/bz2/bz2.c
+++ b/ext/bz2/bz2.c
@@ -343,7 +343,7 @@ static PHP_MINFO_FUNCTION(bz2)
static PHP_FUNCTION(bzread)
{
zval *bz;
- long len = 1024;
+ zend_long len = 1024;
php_stream *stream;
zend_string *data;
@@ -357,11 +357,11 @@ static PHP_FUNCTION(bzread)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "length may not be negative");
RETURN_FALSE;
}
- data = STR_ALLOC(len, 0);
+ data = zend_string_alloc(len, 0);
data->len = php_stream_read(stream, data->val, data->len);
if (data->len < 0) {
- STR_FREE(data);
+ zend_string_free(data);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not read valid bz2 data from stream");
RETURN_FALSE;
}
@@ -406,7 +406,7 @@ static PHP_FUNCTION(bzopen)
} else if (Z_TYPE_P(file) == IS_RESOURCE) {
/* If it is a resource, than its a stream resource */
php_socket_t fd;
- int stream_mode_len;
+ size_t stream_mode_len;
php_stream_from_zval(stream, file);
stream_mode_len = strlen(stream->mode);
@@ -490,8 +490,8 @@ static PHP_FUNCTION(bzerror)
static PHP_FUNCTION(bzcompress)
{
char *source; /* Source data to compress */
- long zblock_size = 0; /* Optional block size to use */
- long zwork_factor = 0;/* Optional work factor to use */
+ zend_long zblock_size = 0; /* Optional block size to use */
+ zend_long zwork_factor = 0;/* Optional work factor to use */
zend_string *dest = NULL; /* Destination to place the compressed data into */
int error, /* Error Container */
block_size = 4, /* Block size for compression algorithm */
@@ -513,7 +513,7 @@ static PHP_FUNCTION(bzcompress)
dest_len = (unsigned int) (source_len + (0.01 * source_len) + 600);
/* Allocate the destination buffer */
- dest = STR_ALLOC(dest_len, 0);
+ dest = zend_string_alloc(dest_len, 0);
/* Handle the optional arguments */
if (argc > 1) {
@@ -526,7 +526,7 @@ static PHP_FUNCTION(bzcompress)
error = BZ2_bzBuffToBuffCompress(dest->val, &dest_len, source, source_len, block_size, 0, work_factor);
if (error != BZ_OK) {
- STR_FREE(dest);
+ zend_string_free(dest);
RETURN_LONG(error);
} else {
/* Copy the buffer, we have perhaps allocate a lot more than we need,
@@ -544,7 +544,7 @@ static PHP_FUNCTION(bzdecompress)
{
char *source, *dest;
int source_len, error;
- long small = 0;
+ zend_long small = 0;
#if defined(PHP_WIN32)
unsigned __int64 size = 0;
#else
diff --git a/ext/bz2/bz2_filter.c b/ext/bz2/bz2_filter.c
index ea3b0de692..cb175af37c 100644
--- a/ext/bz2/bz2_filter.c
+++ b/ext/bz2/bz2_filter.c
@@ -380,9 +380,9 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi
zval tmp;
ZVAL_DUP(&tmp, tmpzval);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
if (Z_LVAL(tmp) < 1 || Z_LVAL(tmp) > 9) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter given for number of blocks to allocate. (%ld)", Z_LVAL_P(tmpzval));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter given for number of blocks to allocate. (%pd)", Z_LVAL_P(tmpzval));
} else {
blockSize100k = Z_LVAL(tmp);
}
@@ -393,10 +393,10 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi
zval tmp;
ZVAL_DUP(&tmp, tmpzval);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
if (Z_LVAL(tmp) < 0 || Z_LVAL(tmp) > 250) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter given for work factor. (%ld)", Z_LVAL(tmp));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter given for work factor. (%pd)", Z_LVAL(tmp));
} else {
workFactor = Z_LVAL(tmp);
}
diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c
index 6590eee903..173cf076e1 100644
--- a/ext/calendar/calendar.c
+++ b/ext/calendar/calendar.c
@@ -178,8 +178,8 @@ enum cal_name_type_t {
CAL_NUM_CALS
};
-typedef long int (*cal_to_jd_func_t) (int month, int day, int year);
-typedef void (*cal_from_jd_func_t) (long int jd, int *year, int *month, int *day);
+typedef zend_long (*cal_to_jd_func_t) (int month, int day, int year);
+typedef void (*cal_from_jd_func_t) (zend_long jd, int *year, int *month, int *day);
typedef char *(*cal_as_string_func_t) (int year, int month, int day);
struct cal_entry_t {
@@ -289,7 +289,7 @@ static void _php_cal_info(int cal, zval *ret)
Returns information about a particular calendar */
PHP_FUNCTION(cal_info)
{
- long cal = -1;
+ zend_long cal = -1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &cal) == FAILURE) {
@@ -311,7 +311,7 @@ PHP_FUNCTION(cal_info)
if (cal != -1 && (cal < 0 || cal >= CAL_NUM_CALS)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %ld.", cal);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %pd.", cal);
RETURN_FALSE;
}
@@ -324,16 +324,16 @@ PHP_FUNCTION(cal_info)
Returns the number of days in a month for a given year and calendar */
PHP_FUNCTION(cal_days_in_month)
{
- long cal, month, year;
+ zend_long cal, month, year;
struct cal_entry_t *calendar;
- long sdn_start, sdn_next;
+ zend_long sdn_start, sdn_next;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &cal, &month, &year) == FAILURE) {
RETURN_FALSE;
}
if (cal < 0 || cal >= CAL_NUM_CALS) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %ld.", cal);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %pd.", cal);
RETURN_FALSE;
}
@@ -368,14 +368,14 @@ PHP_FUNCTION(cal_days_in_month)
Converts from a supported calendar to Julian Day Count */
PHP_FUNCTION(cal_to_jd)
{
- long cal, month, day, year;
+ zend_long cal, month, day, year;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &cal, &month, &day, &year) != SUCCESS) {
RETURN_FALSE;
}
if (cal < 0 || cal >= CAL_NUM_CALS) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %ld.", cal);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %pd.", cal);
RETURN_FALSE;
}
@@ -387,7 +387,7 @@ PHP_FUNCTION(cal_to_jd)
Converts from Julian Day Count to a supported calendar and return extended information */
PHP_FUNCTION(cal_from_jd)
{
- long jd, cal;
+ zend_long jd, cal;
int month, day, year, dow;
char date[16];
struct cal_entry_t *calendar;
@@ -397,7 +397,7 @@ PHP_FUNCTION(cal_from_jd)
}
if (cal < 0 || cal >= CAL_NUM_CALS) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %ld", cal);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %pd", cal);
RETURN_FALSE;
}
calendar = &cal_conversion_table[cal];
@@ -434,7 +434,7 @@ PHP_FUNCTION(cal_from_jd)
Converts a julian day count to a gregorian calendar date */
PHP_FUNCTION(jdtogregorian)
{
- long julday;
+ zend_long julday;
int year, month, day;
char date[16];
@@ -453,7 +453,7 @@ PHP_FUNCTION(jdtogregorian)
Converts a gregorian calendar date to julian day count */
PHP_FUNCTION(gregoriantojd)
{
- long year, month, day;
+ zend_long year, month, day;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) {
RETURN_FALSE;
@@ -467,7 +467,7 @@ PHP_FUNCTION(gregoriantojd)
Convert a julian day count to a julian calendar date */
PHP_FUNCTION(jdtojulian)
{
- long julday;
+ zend_long julday;
int year, month, day;
char date[16];
@@ -486,7 +486,7 @@ PHP_FUNCTION(jdtojulian)
Converts a julian calendar date to julian day count */
PHP_FUNCTION(juliantojd)
{
- long year, month, day;
+ zend_long year, month, day;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) {
RETURN_FALSE;
@@ -595,7 +595,7 @@ static char *heb_number_to_chars(int n, int fl, char **ret)
Converts a julian day count to a jewish calendar date */
PHP_FUNCTION(jdtojewish)
{
- long julday, fl = 0;
+ zend_long julday, fl = 0;
zend_bool heb = 0;
int year, month, day;
char date[16], hebdate[32];
@@ -634,7 +634,7 @@ PHP_FUNCTION(jdtojewish)
Converts a jewish calendar date to a julian day count */
PHP_FUNCTION(jewishtojd)
{
- long year, month, day;
+ zend_long year, month, day;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) {
RETURN_FALSE;
@@ -648,7 +648,7 @@ PHP_FUNCTION(jewishtojd)
Converts a julian day count to a french republic calendar date */
PHP_FUNCTION(jdtofrench)
{
- long julday;
+ zend_long julday;
int year, month, day;
char date[16];
@@ -667,7 +667,7 @@ PHP_FUNCTION(jdtofrench)
Converts a french republic calendar date to julian day count */
PHP_FUNCTION(frenchtojd)
{
- long year, month, day;
+ zend_long year, month, day;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) {
RETURN_FALSE;
@@ -681,7 +681,7 @@ PHP_FUNCTION(frenchtojd)
Returns name or number of day of week from julian day count */
PHP_FUNCTION(jddayofweek)
{
- long julday, mode = CAL_DOW_DAYNO;
+ zend_long julday, mode = CAL_DOW_DAYNO;
int day;
char *daynamel, *daynames;
@@ -712,7 +712,7 @@ PHP_FUNCTION(jddayofweek)
Returns name of month for julian day count */
PHP_FUNCTION(jdmonthname)
{
- long julday, mode;
+ zend_long julday, mode;
char *monthname = NULL;
int month, day, year;
diff --git a/ext/calendar/dow.c b/ext/calendar/dow.c
index 64ae008f77..44f0490ed1 100644
--- a/ext/calendar/dow.c
+++ b/ext/calendar/dow.c
@@ -32,7 +32,7 @@
#include "sdncal.h"
int DayOfWeek(
- long int sdn)
+ zend_long sdn)
{
int dow;
diff --git a/ext/calendar/easter.c b/ext/calendar/easter.c
index 82c0aa633c..d2b36f981a 100644
--- a/ext/calendar/easter.c
+++ b/ext/calendar/easter.c
@@ -24,14 +24,14 @@
#include "sdncal.h"
#include <time.h>
-static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, int gm)
+static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, zend_long gm)
{
/* based on code by Simon Kershaw, <webmaster@ely.anglican.org> */
struct tm te;
- long year, golden, solar, lunar, pfm, dom, tmp, easter, result;
- long method = CAL_EASTER_DEFAULT;
+ zend_long year, golden, solar, lunar, pfm, dom, tmp, easter, result;
+ zend_long method = CAL_EASTER_DEFAULT;
/* Default to the current year if year parameter is not given */
{
diff --git a/ext/calendar/french.c b/ext/calendar/french.c
index 5b4dd53750..4eb0e78021 100644
--- a/ext/calendar/french.c
+++ b/ext/calendar/french.c
@@ -93,12 +93,12 @@
#define LAST_VALID 2380952
void SdnToFrench(
- long int sdn,
+ zend_long sdn,
int *pYear,
int *pMonth,
int *pDay)
{
- long int temp;
+ zend_long temp;
int dayOfYear;
if (sdn < FIRST_VALID || sdn > LAST_VALID) {
@@ -114,7 +114,7 @@ void SdnToFrench(
*pDay = dayOfYear % DAYS_PER_MONTH + 1;
}
-long int FrenchToSdn(
+zend_long FrenchToSdn(
int year,
int month,
int day)
diff --git a/ext/calendar/gregor.c b/ext/calendar/gregor.c
index ebb743fddc..069fe6eb5a 100644
--- a/ext/calendar/gregor.c
+++ b/ext/calendar/gregor.c
@@ -135,7 +135,7 @@
#define DAYS_PER_400_YEARS 146097
void SdnToGregorian(
- long int sdn,
+ zend_long sdn,
int *pYear,
int *pMonth,
int *pDay)
@@ -144,7 +144,7 @@ void SdnToGregorian(
int year;
int month;
int day;
- long int temp;
+ zend_long temp;
int dayOfYear;
if (sdn <= 0 ||
@@ -190,7 +190,7 @@ fail:
*pDay = 0;
}
-long int GregorianToSdn(
+zend_long GregorianToSdn(
int inputYear,
int inputMonth,
int inputDay)
diff --git a/ext/calendar/jewish.c b/ext/calendar/jewish.c
index ddc8aaaf86..6a32e6ff08 100644
--- a/ext/calendar/jewish.c
+++ b/ext/calendar/jewish.c
@@ -382,12 +382,12 @@ char *JewishMonthHebName[14] =
* (called dehiyyot) delays it. These 4 rules can delay the start of the
* year by as much as 2 days.
*/
-static long int Tishri1(
+static zend_long Tishri1(
int metonicYear,
- long int moladDay,
- long int moladHalakim)
+ zend_long moladDay,
+ zend_long moladHalakim)
{
- long int tishri1;
+ zend_long tishri1;
int dow;
int leapYear;
int lastWasLeapYear;
@@ -429,10 +429,10 @@ static long int Tishri1(
*/
static void MoladOfMetonicCycle(
int metonicCycle,
- long int *pMoladDay,
- long int *pMoladHalakim)
+ zend_long *pMoladDay,
+ zend_long *pMoladHalakim)
{
- register unsigned long int r1, r2, d1, d2;
+ register zend_ulong r1, r2, d1, d2;
/* Start with the time of the first molad after creation. */
r1 = NEW_MOON_OF_CREATION;
@@ -468,14 +468,14 @@ static void MoladOfMetonicCycle(
* us to avoid calculating the length of the year in most cases.
*/
static void FindTishriMolad(
- long int inputDay,
+ zend_long inputDay,
int *pMetonicCycle,
int *pMetonicYear,
- long int *pMoladDay,
- long int *pMoladHalakim)
+ zend_long *pMoladDay,
+ zend_long *pMoladHalakim)
{
- long int moladDay;
- long int moladHalakim;
+ zend_long moladDay;
+ zend_long moladHalakim;
int metonicCycle;
int metonicYear;
@@ -523,8 +523,8 @@ static void FindStartOfYear(
int year,
int *pMetonicCycle,
int *pMetonicYear,
- long int *pMoladDay,
- long int *pMoladHalakim,
+ zend_long *pMoladDay,
+ zend_long *pMoladHalakim,
int *pTishri1)
{
*pMetonicCycle = (year - 1) / 19;
@@ -546,14 +546,14 @@ static void FindStartOfYear(
* range 1 to 13 inclusive; *pDay will be in the range 1 to 30 inclusive.
*/
void SdnToJewish(
- long int sdn,
+ zend_long sdn,
int *pYear,
int *pMonth,
int *pDay)
{
- long int inputDay;
- long int day;
- long int halakim;
+ zend_long inputDay;
+ zend_long day;
+ zend_long halakim;
int metonicCycle;
int metonicYear;
int tishri1;
@@ -684,18 +684,18 @@ void SdnToJewish(
* value. To verify that a date is valid, convert it to SDN and then back
* and compare with the original.
*/
-long int JewishToSdn(
+zend_long JewishToSdn(
int year,
int month,
int day)
{
- long int sdn;
+ zend_long sdn;
int metonicCycle;
int metonicYear;
int tishri1;
int tishri1After;
- long int moladDay;
- long int moladHalakim;
+ zend_long moladDay;
+ zend_long moladHalakim;
int yearLength;
int lengthOfAdarIAndII;
diff --git a/ext/calendar/julian.c b/ext/calendar/julian.c
index 17e7bcb597..659ffc1740 100644
--- a/ext/calendar/julian.c
+++ b/ext/calendar/julian.c
@@ -11,7 +11,7 @@
*
* void
* SdnToJulian(
- * long int sdn,
+ * zend_long sdn,
* int *pYear,
* int *pMonth,
* int *pDay);
@@ -21,7 +21,7 @@
* will be >= -4713 and != 0; *pMonth will be in the range 1 to 12
* inclusive; *pDay will be in the range 1 to 31 inclusive.
*
- * long int
+ * zend_long
* JulianToSdn(
* int inputYear,
* int inputMonth,
@@ -153,7 +153,7 @@
#define DAYS_PER_4_YEARS 1461
void SdnToJulian(
- long int sdn,
+ zend_long sdn,
int *pYear,
int *pMonth,
int *pDay)
@@ -161,7 +161,7 @@ void SdnToJulian(
int year;
int month;
int day;
- long int temp;
+ zend_long temp;
int dayOfYear;
if (sdn <= 0) {
@@ -212,7 +212,7 @@ fail:
*pDay = 0;
}
-long int JulianToSdn(
+zend_long JulianToSdn(
int inputYear,
int inputMonth,
int inputDay)
diff --git a/ext/calendar/sdncal.h b/ext/calendar/sdncal.h
index c0463c80d4..c76fc0063b 100644
--- a/ext/calendar/sdncal.h
+++ b/ext/calendar/sdncal.h
@@ -53,7 +53,7 @@
*
* int y1, m1, d1;
* int y2, m2, d2;
- * long int sdn;
+ * zend_long sdn;
* ...
* sdn = GregorianToSdn(y1, m1, d1);
* if (sdn > 0) {
@@ -65,19 +65,21 @@
*
**************************************************************************/
+#include "php.h"
+
/* Gregorian calendar conversions. */
-void SdnToGregorian(long int sdn, int *pYear, int *pMonth, int *pDay);
-long int GregorianToSdn(int year, int month, int day);
+void SdnToGregorian(zend_long sdn, int *pYear, int *pMonth, int *pDay);
+zend_long GregorianToSdn(int year, int month, int day);
extern char *MonthNameShort[13];
extern char *MonthNameLong[13];
/* Julian calendar conversions. */
-void SdnToJulian(long int sdn, int *pYear, int *pMonth, int *pDay);
-long int JulianToSdn(int year, int month, int day);
+void SdnToJulian(zend_long sdn, int *pYear, int *pMonth, int *pDay);
+zend_long JulianToSdn(int year, int month, int day);
/* Jewish calendar conversions. */
-void SdnToJewish(long int sdn, int *pYear, int *pMonth, int *pDay);
-long int JewishToSdn(int year, int month, int day);
+void SdnToJewish(zend_long sdn, int *pYear, int *pMonth, int *pDay);
+zend_long JewishToSdn(int year, int month, int day);
extern char *JewishMonthName[14];
extern char *JewishMonthNameLeap[14];
extern char *JewishMonthHebName[14];
@@ -85,15 +87,15 @@ extern char *JewishMonthHebNameLeap[14];
extern int monthsPerYear[19];
/* French republic calendar conversions. */
-void SdnToFrench(long int sdn, int *pYear, int *pMonth, int *pDay);
-long int FrenchToSdn(int inputYear, int inputMonth, int inputDay);
+void SdnToFrench(zend_long sdn, int *pYear, int *pMonth, int *pDay);
+zend_long FrenchToSdn(int inputYear, int inputMonth, int inputDay);
extern char *FrenchMonthName[14];
/* Islamic calendar conversions. */
/* Not implemented yet. */
/* Day of week conversion. 0=Sunday, 6=Saturday */
-int DayOfWeek(long int sdn);
+int DayOfWeek(zend_long sdn);
extern char *DayNameShort[7];
extern char *DayNameLong[7];
diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c
index 6d3b15876f..892d8c3829 100644
--- a/ext/com_dotnet/com_com.c
+++ b/ext/com_dotnet/com_com.c
@@ -108,7 +108,7 @@ PHP_FUNCTION(com_create_instance)
if (NULL != (tmp = zend_hash_str_find(HASH_OF(server_params),
"Flags", sizeof("Flags")-1))) {
- convert_to_long_ex(tmp);
+ convert_to_int_ex(tmp);
ctx = (CLSCTX)Z_LVAL_P(tmp);
}
}
@@ -289,7 +289,7 @@ PHP_FUNCTION(com_get_active_object)
CLSID clsid;
char *module_name;
int module_name_len;
- long code_page = COMG(code_page);
+ zend_long code_page = COMG(code_page);
IUnknown *unk = NULL;
IDispatch *obj = NULL;
HRESULT res;
@@ -784,7 +784,7 @@ PHP_FUNCTION(com_print_typeinfo)
Process COM messages, sleeping for up to timeoutms milliseconds */
PHP_FUNCTION(com_message_pump)
{
- long timeoutms = 0;
+ zend_long timeoutms = 0;
MSG msg;
DWORD result;
diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c
index 0ba33a9b1a..2de35a58b1 100644
--- a/ext/com_dotnet/com_extension.c
+++ b/ext/com_dotnet/com_extension.c
@@ -22,6 +22,8 @@
#include "config.h"
#endif
+#include <intsafe.h>
+
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
@@ -382,6 +384,12 @@ PHP_MINIT_FUNCTION(com_dotnet)
REGISTER_INI_ENTRIES();
#define COM_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_CS|CONST_PERSISTENT)
+
+#define COM_ERR_CONST(x) { \
+ zend_long __tmp; \
+ ULongToUIntPtr(x, &__tmp); \
+ REGISTER_LONG_CONSTANT(#x, __tmp, CONST_CS|CONST_PERSISTENT); \
+}
COM_CONST(CLSCTX_INPROC_SERVER);
COM_CONST(CLSCTX_INPROC_HANDLER);
@@ -441,10 +449,10 @@ PHP_MINIT_FUNCTION(com_dotnet)
#ifdef NORM_IGNOREKASHIDA
COM_CONST(NORM_IGNOREKASHIDA);
#endif
- COM_CONST(DISP_E_DIVBYZERO);
- COM_CONST(DISP_E_OVERFLOW);
- COM_CONST(DISP_E_BADINDEX);
- COM_CONST(MK_E_UNAVAILABLE);
+ COM_ERR_CONST(DISP_E_DIVBYZERO);
+ COM_ERR_CONST(DISP_E_OVERFLOW);
+ COM_ERR_CONST(DISP_E_BADINDEX);
+ COM_ERR_CONST(MK_E_UNAVAILABLE);
return SUCCESS;
}
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c
index 0d83a86648..b9df407a1b 100644
--- a/ext/com_dotnet/com_handlers.c
+++ b/ext/com_dotnet/com_handlers.c
@@ -98,7 +98,7 @@ static zval *com_read_dimension(zval *object, zval *offset, int type, zval *rv T
VariantClear(&v);
}
} else if (V_ISARRAY(&obj->v)) {
- convert_to_long(offset);
+ convert_to_int(offset);
if (SafeArrayGetDim(V_ARRAY(&obj->v)) == 1) {
if (php_com_safearray_get_elem(&obj->v, &v, Z_LVAL_P(offset) TSRMLS_CC)) {
@@ -144,7 +144,7 @@ static void com_write_dimension(zval *object, zval *offset, zval *value TSRMLS_D
vt = V_VT(&obj->v) & ~VT_ARRAY;
}
- convert_to_long(offset);
+ convert_to_int(offset);
indices = Z_LVAL_P(offset);
VariantInit(&v);
@@ -238,7 +238,7 @@ static void function_dtor(zval *zv)
{
zend_internal_function *f = (zend_internal_function*)Z_PTR_P(zv);
- STR_RELEASE(f->function_name);
+ zend_string_release(f->function_name);
if (f->arg_info) {
efree(f->arg_info);
}
@@ -277,7 +277,7 @@ static union _zend_function *com_method_get(zend_object **object_ptr, zend_strin
f.arg_info = NULL;
f.scope = obj->ce;
f.fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
- f.function_name = STR_COPY(name);
+ f.function_name = zend_string_copy(name);
f.handler = PHP_FN(com_method_handler);
fptr = &f;
@@ -434,7 +434,7 @@ static zend_string* com_class_name_get(const zend_object *object, int parent TSR
{
php_com_dotnet_object *obj = (php_com_dotnet_object *)object;
- return STR_COPY(obj->ce->name);
+ return zend_string_copy(obj->ce->name);
}
/* This compares two variants for equality */
diff --git a/ext/com_dotnet/com_iterator.c b/ext/com_dotnet/com_iterator.c
index 7da10f1b66..f6aa1a1980 100644
--- a/ext/com_dotnet/com_iterator.c
+++ b/ext/com_dotnet/com_iterator.c
@@ -32,7 +32,7 @@
struct php_com_iterator {
zend_object_iterator iter;
IEnumVARIANT *ev;
- ulong key;
+ zend_ulong key;
VARIANT v; /* cached element */
int code_page;
VARIANT safe_array;
@@ -75,7 +75,7 @@ static void com_iter_get_key(zend_object_iterator *iter, zval *key TSRMLS_DC)
{
struct php_com_iterator *I = (struct php_com_iterator*)Z_PTR(iter->data);
- if (I->key == (ulong)-1) {
+ if (I->key == (zend_ulong)-1) {
ZVAL_NULL(key);
} else {
ZVAL_LONG(key, I->key);
diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c
index 5cd6808b36..d83aeeb188 100644
--- a/ext/com_dotnet/com_misc.c
+++ b/ext/com_dotnet/com_misc.c
@@ -36,7 +36,7 @@ void php_com_throw_exception(HRESULT code, char *message TSRMLS_DC)
message = php_win32_error_to_msg(code);
free_msg = 1;
}
- zend_throw_exception(php_com_exception_class_entry, message, (long)code TSRMLS_CC);
+ zend_throw_exception(php_com_exception_class_entry, message, (zend_long)code TSRMLS_CC);
if (free_msg) {
LocalFree(message);
}
diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c
index 66e3dec640..0b496404f4 100644
--- a/ext/com_dotnet/com_persist.c
+++ b/ext/com_dotnet/com_persist.c
@@ -439,7 +439,7 @@ CPH_METHOD(LoadFromFile)
HRESULT res;
char *filename, *fullpath;
int filename_len;
- long flags = 0;
+ zend_long flags = 0;
OLECHAR *olefilename;
CPH_FETCH();
@@ -506,7 +506,7 @@ CPH_METHOD(GetMaxStreamSize)
php_com_throw_exception(res, NULL TSRMLS_CC);
} else {
/* TODO: handle 64 bit properly */
- RETURN_LONG((LONG)size.QuadPart);
+ RETURN_LONG((zend_long)size.QuadPart);
}
}
/* }}} */
diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c
index 9b3716f43a..20aa33ed53 100644
--- a/ext/com_dotnet/com_saproxy.c
+++ b/ext/com_dotnet/com_saproxy.c
@@ -134,7 +134,7 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval *
/* the SafeArray case */
/* offset/index must be an integer */
- convert_to_long(offset);
+ convert_to_int(offset);
sa = V_ARRAY(&proxy->obj->v);
dims = SafeArrayGetDim(sa);
@@ -166,7 +166,7 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval *
/* copy indices from proxy */
for (i = 0; i < dims; i++) {
- convert_to_long(&proxy->indices[i]);
+ convert_to_int(&proxy->indices[i]);
indices[i] = Z_LVAL(proxy->indices[i]);
}
@@ -240,12 +240,12 @@ static void saproxy_write_dimension(zval *object, zval *offset, zval *value TSRM
indices = safe_emalloc(dims, sizeof(LONG), 0);
/* copy indices from proxy */
for (i = 0; i < dims; i++) {
- convert_to_long(&proxy->indices[i]);
+ convert_to_int(&proxy->indices[i]);
indices[i] = Z_LVAL(proxy->indices[i]);
}
/* add user-supplied index */
- convert_to_long(offset);
+ convert_to_int(offset);
indices[dims-1] = Z_LVAL_P(offset);
if (FAILED(SafeArrayGetVartype(V_ARRAY(&proxy->obj->v), &vt)) || vt == VT_EMPTY) {
@@ -340,7 +340,7 @@ static zend_class_entry *saproxy_class_entry_get(const zend_object *object TSRML
static zend_string* saproxy_class_name_get(const zend_object *object, int parent TSRMLS_DC)
{
- return STR_COPY(php_com_saproxy_class_entry->name);
+ return zend_string_copy(php_com_saproxy_class_entry->name);
}
static int saproxy_objects_compare(zval *object1, zval *object2 TSRMLS_DC)
@@ -353,7 +353,7 @@ static int saproxy_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC
return FAILURE;
}
-static int saproxy_count_elements(zval *object, long *count TSRMLS_DC)
+static int saproxy_count_elements(zval *object, zend_long *count TSRMLS_DC)
{
php_com_saproxy *proxy = SA_FETCH(object);
LONG ubound, lbound;
@@ -560,7 +560,7 @@ zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *objec
I->indices = safe_emalloc(proxy->dimensions + 1, sizeof(LONG), 0);
for (i = 0; i < proxy->dimensions; i++) {
- convert_to_long(&proxy->indices[i]);
+ convert_to_int(&proxy->indices[i]);
I->indices[i] = Z_LVAL(proxy->indices[i]);
}
diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c
index 46a3cbd5a1..b32c4b2600 100644
--- a/ext/com_dotnet/com_typeinfo.c
+++ b/ext/com_dotnet/com_typeinfo.c
@@ -186,7 +186,7 @@ PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepa
}
const_name = php_com_olestring_to_string(bstr_ids, &len, codepage TSRMLS_CC);
- c.name = STR_INIT(const_name, len, 1);
+ c.name = zend_string_init(const_name, len, 1);
// TODO: avoid reallocation???
efree(const_name);
if(c.name == NULL) {
@@ -201,7 +201,7 @@ PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepa
if (COMG(autoreg_verbose) && !compare_function(&results, &c.value, exists TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type library constant %s is already defined", c.name);
}
- STR_RELEASE(c.name);
+ zend_string_release(c.name);
ITypeInfo_ReleaseVarDesc(TypeInfo, pVarDesc);
continue;
}
diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c
index f7dbdd5efa..9931e7182f 100644
--- a/ext/com_dotnet/com_variant.c
+++ b/ext/com_dotnet/com_variant.c
@@ -39,8 +39,8 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC)
HashPosition pos;
int keytype;
zend_string *strindex;
- long intindex = -1;
- long max_index = 0;
+ zend_long intindex = -1;
+ zend_long max_index = 0;
VARIANT *va;
zval *item;
@@ -187,28 +187,28 @@ PHP_COM_DOTNET_API int php_com_zval_from_variant(zval *z, VARIANT *v, int codepa
ZVAL_NULL(z);
break;
case VT_UI1:
- ZVAL_LONG(z, (long)V_UI1(v));
+ ZVAL_LONG(z, (zend_long)V_UI1(v));
break;
case VT_I1:
- ZVAL_LONG(z, (long)V_I1(v));
+ ZVAL_LONG(z, (zend_long)V_I1(v));
break;
case VT_UI2:
- ZVAL_LONG(z, (long)V_UI2(v));
+ ZVAL_LONG(z, (zend_long)V_UI2(v));
break;
case VT_I2:
- ZVAL_LONG(z, (long)V_I2(v));
+ ZVAL_LONG(z, (zend_long)V_I2(v));
break;
case VT_UI4: /* TODO: promote to double if large? */
- ZVAL_LONG(z, (long)V_UI4(v));
+ ZVAL_LONG(z, (zend_long)V_UI4(v));
break;
case VT_I4:
- ZVAL_LONG(z, (long)V_I4(v));
+ ZVAL_LONG(z, (zend_long)V_I4(v));
break;
case VT_INT:
ZVAL_LONG(z, V_INT(v));
break;
case VT_UINT: /* TODO: promote to double if large? */
- ZVAL_LONG(z, (long)V_UINT(v));
+ ZVAL_LONG(z, (zend_long)V_UINT(v));
break;
case VT_R4:
ZVAL_DOUBLE(z, (double)V_R4(v));
@@ -406,8 +406,8 @@ PHP_COM_DOTNET_API int php_com_copy_variant(VARIANT *dstvar, VARIANT *srcvar TSR
/* {{{ com_variant_create_instance - ctor for new VARIANT() */
PHP_FUNCTION(com_variant_create_instance)
{
- /* VARTYPE == unsigned short */ long vt = VT_EMPTY;
- long codepage = CP_ACP;
+ /* VARTYPE == unsigned short */ zend_long vt = VT_EMPTY;
+ zend_long codepage = CP_ACP;
zval *object = getThis();
php_com_dotnet_object *obj;
zval *zvalue = NULL;
@@ -444,7 +444,7 @@ PHP_FUNCTION(com_variant_create_instance)
but will probably fail (original behavior)
*/
if ((vt & VT_ARRAY) && (V_VT(&obj->v) & VT_ARRAY)) {
- long orig_vt = vt;
+ zend_long orig_vt = vt;
vt &= ~VT_ARRAY;
if (vt) {
@@ -832,7 +832,7 @@ PHP_FUNCTION(variant_round)
zval *zleft = NULL;
php_com_dotnet_object *obj;
int codepage = CP_ACP;
- long decimals = 0;
+ zend_long decimals = 0;
VariantInit(&left_val);
VariantInit(&vres);
@@ -867,8 +867,8 @@ PHP_FUNCTION(variant_cmp)
zval *zleft = NULL, *zright = NULL;
php_com_dotnet_object *obj;
int codepage = CP_ACP;
- long lcid = LOCALE_SYSTEM_DEFAULT;
- long flags = 0;
+ zend_long lcid = LOCALE_SYSTEM_DEFAULT;
+ zend_long flags = 0;
/* it is safe to ignore the warning for this line; see the comments in com_handlers.c */
STDAPI VarCmp(LPVARIANT pvarLeft, LPVARIANT pvarRight, LCID lcid, DWORD flags);
@@ -959,7 +959,7 @@ PHP_FUNCTION(variant_date_to_timestamp)
Returns a variant date representation of a unix timestamp */
PHP_FUNCTION(variant_date_from_timestamp)
{
- long timestamp;
+ zend_long timestamp;
time_t ttstamp;
SYSTEMTIME systime;
struct tm *tmv;
@@ -1020,7 +1020,7 @@ PHP_FUNCTION(variant_set_type)
{
zval *zobj;
php_com_dotnet_object *obj;
- /* VARTYPE == unsigned short */ long vt;
+ /* VARTYPE == unsigned short */ zend_long vt;
HRESULT res;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@@ -1055,7 +1055,7 @@ PHP_FUNCTION(variant_cast)
{
zval *zobj;
php_com_dotnet_object *obj;
- /* VARTYPE == unsigned short */ long vt;
+ /* VARTYPE == unsigned short */ zend_long vt;
VARIANT vres;
HRESULT res;
diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c
index a55c767423..4ec1ab3ba3 100644
--- a/ext/com_dotnet/com_wrapper.c
+++ b/ext/com_dotnet/com_wrapper.c
@@ -450,7 +450,7 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
zend_string *name = NULL;
zval *tmp, tmp2;
int keytype;
- ulong pid;
+ zend_ulong pid;
if (disp->dispid_to_name == NULL) {
ALLOC_HASHTABLE(disp->dispid_to_name);
@@ -467,29 +467,29 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
&pid, 0, &pos))) {
char namebuf[32];
if (keytype == HASH_KEY_IS_LONG) {
- snprintf(namebuf, sizeof(namebuf), "%d", pid);
- name = STR_INIT(namebuf, strlen(namebuf), 0);
+ snprintf(namebuf, sizeof(namebuf), ZEND_ULONG_FMT, pid);
+ name = zend_string_init(namebuf, strlen(namebuf), 0);
} else {
- STR_ADDREF(name);
+ zend_string_addref(name);
}
zend_hash_move_forward_ex(Z_OBJPROP(disp->object), &pos);
/* Find the existing id */
if ((tmp = zend_hash_find(disp->name_to_dispid, name)) != NULL) {
- STR_RELEASE(name);
+ zend_string_release(name);
continue;
}
/* add the mappings */
- ZVAL_STR(&tmp2, STR_COPY(name));
+ ZVAL_STR(&tmp2, zend_string_copy(name));
pid = zend_hash_next_free_element(disp->dispid_to_name);
zend_hash_index_update(disp->dispid_to_name, pid, &tmp2);
ZVAL_LONG(&tmp2, pid);
zend_hash_update(disp->name_to_dispid, name, &tmp2);
- STR_RELEASE(name);
+ zend_string_release(name);
}
}
@@ -503,28 +503,28 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
char namebuf[32];
if (keytype == HASH_KEY_IS_LONG) {
snprintf(namebuf, sizeof(namebuf), "%d", pid);
- name = STR_INIT(namebuf, strlen(namebuf), 0);
+ name = zend_string_init(namebuf, strlen(namebuf), 0);
} else {
- STR_ADDREF(name);
+ zend_string_addref(name);
}
zend_hash_move_forward_ex(&Z_OBJCE(disp->object)->function_table, &pos);
/* Find the existing id */
if ((tmp = zend_hash_find(disp->name_to_dispid, name)) != NULL) {
- STR_RELEASE(name);
+ zend_string_release(name);
continue;
}
/* add the mappings */
- ZVAL_STR(&tmp2, STR_COPY(name));
+ ZVAL_STR(&tmp2, zend_string_copy(name));
pid = zend_hash_next_free_element(disp->dispid_to_name);
zend_hash_index_update(disp->dispid_to_name, pid, &tmp2);
ZVAL_LONG(&tmp2, pid);
zend_hash_update(disp->name_to_dispid, name, &tmp2);
- STR_RELEASE(name);
+ zend_string_release(name);
}
}
}
@@ -590,7 +590,7 @@ PHP_COM_DOTNET_API IDispatch *php_com_wrapper_export_as_sink(zval *val, GUID *si
zend_string *name = NULL;
zval tmp, *ntmp;
int keytype;
- ulong pid;
+ zend_ulong pid;
disp->dispid_to_name = id_to_name;
diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h
index d093e3c37b..b893523748 100644
--- a/ext/com_dotnet/php_com_dotnet_internal.h
+++ b/ext/com_dotnet/php_com_dotnet_internal.h
@@ -38,7 +38,7 @@ typedef struct _php_com_dotnet_object {
int modified;
ITypeInfo *typeinfo;
- long code_page;
+ zend_long code_page;
zend_class_entry *ce;
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index b45e7efc83..0f3c166043 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -154,7 +154,7 @@ static void _php_curl_close(zend_resource *rsrc TSRMLS_DC);
#define SAVE_CURL_ERROR(__handle, __err) (__handle)->err.no = (int) __err;
-#define CAAL(s, v) add_assoc_long_ex(return_value, s, sizeof(s) - 1, (long) v);
+#define CAAL(s, v) add_assoc_long_ex(return_value, s, sizeof(s) - 1, (zend_long) v);
#define CAAD(s, v) add_assoc_double_ex(return_value, s, sizeof(s) - 1, (double) v);
#define CAAS(s, v) add_assoc_string_ex(return_value, s, sizeof(s) - 1, (char *) (v ? v : ""));
#define CAASTR(s, v) add_assoc_str_ex(return_value, s, sizeof(s) - 1, v ? v : STR_EMPTY_ALLOC());
@@ -166,7 +166,7 @@ static void _php_curl_close(zend_resource *rsrc TSRMLS_DC);
# define php_curl_ret(__ret) RETVAL_FALSE; return;
#endif
-static int php_curl_option_str(php_curl *ch, long option, const char *str, const int len, zend_bool make_copy TSRMLS_DC)
+static int php_curl_option_str(php_curl *ch, zend_long option, const char *str, const int len, zend_bool make_copy TSRMLS_DC)
{
CURLcode error = CURLE_OK;
@@ -1319,7 +1319,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
length = -1;
} else if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
- convert_to_long_ex(&retval);
+ convert_to_int_ex(&retval);
}
length = Z_LVAL(retval);
}
@@ -1372,7 +1372,7 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_FNMATCH_FUNCTION");
} else if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
- convert_to_long_ex(&retval);
+ convert_to_int_ex(&retval);
}
rval = Z_LVAL(retval);
}
@@ -1432,7 +1432,7 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION");
} else if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
- convert_to_long_ex(&retval);
+ convert_to_int_ex(&retval);
}
if (0 != Z_LVAL(retval)) {
rval = 1;
@@ -1563,7 +1563,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
length = -1;
} else if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
- convert_to_long_ex(&retval);
+ convert_to_int_ex(&retval);
}
length = Z_LVAL(retval);
}
@@ -1589,10 +1589,10 @@ static int curl_debug(CURL *cp, curl_infotype type, char *buf, size_t buf_len, v
if (type == CURLINFO_HEADER_OUT) {
if (ch->header.str) {
- STR_RELEASE(ch->header.str);
+ zend_string_release(ch->header.str);
}
if (buf_len > 0) {
- ch->header.str = STR_INIT(buf, buf_len, 0);
+ ch->header.str = zend_string_init(buf, buf_len, 0);
}
}
@@ -1670,7 +1670,7 @@ static void curl_free_slist(zval *el)
PHP_FUNCTION(curl_version)
{
curl_version_info_data *d;
- long uversion = CURLVERSION_NOW;
+ zend_long uversion = CURLVERSION_NOW;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &uversion) == FAILURE) {
return;
@@ -1986,14 +1986,14 @@ PHP_FUNCTION(curl_copy_handle)
}
/* }}} */
-static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /* {{{ */
+static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue TSRMLS_DC) /* {{{ */
{
CURLcode error = CURLE_OK;
switch (option) {
/* Long options */
case CURLOPT_SSL_VERIFYHOST:
- convert_to_long(zvalue);
+ convert_to_int(zvalue);
if (Z_LVAL_P(zvalue) == 1) {
#if LIBCURL_VERSION_NUM <= 0x071c00 /* 7.28.0 */
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "CURLOPT_SSL_VERIFYHOST with value 1 is deprecated and will be removed as of libcurl 7.28.1. It is recommended to use value 2 instead");
@@ -2148,7 +2148,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
#if CURLOPT_MUTE != 0
case CURLOPT_MUTE:
#endif
- convert_to_long_ex(zvalue);
+ convert_to_int_ex(zvalue);
#if LIBCURL_VERSION_NUM >= 0x71304
if ((option == CURLOPT_PROTOCOLS || option == CURLOPT_REDIR_PROTOCOLS) &&
(PG(open_basedir) && *PG(open_basedir)) && (Z_LVAL_P(zvalue) & CURLPROTO_FILE)) {
@@ -2159,7 +2159,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
error = curl_easy_setopt(ch->cp, option, Z_LVAL_P(zvalue));
break;
case CURLOPT_SAFE_UPLOAD:
- convert_to_long_ex(zvalue);
+ convert_to_int_ex(zvalue);
ch->safe_upload = (Z_LVAL_P(zvalue) != 0);
break;
@@ -2436,7 +2436,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
break;
case CURLOPT_FOLLOWLOCATION:
- convert_to_long_ex(zvalue);
+ convert_to_int_ex(zvalue);
#if LIBCURL_VERSION_NUM < 0x071304
if (PG(open_basedir) && *PG(open_basedir)) {
if (Z_LVAL_P(zvalue) != 0) {
@@ -2476,9 +2476,9 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
char *postval;
/* Pretend we have a string_key here */
if (!string_key) {
- string_key = zend_long_to_str(num_key);
+ string_key = zend_longo_str(num_key);
} else {
- STR_ADDREF(string_key);
+ zend_string_addref(string_key);
}
if (Z_TYPE_P(current) == IS_OBJECT &&
@@ -2514,7 +2514,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
CURLFORM_END);
}
- STR_RELEASE(string_key);
+ zend_string_release(string_key);
continue;
}
@@ -2564,7 +2564,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
CURLFORM_END);
}
- STR_RELEASE(string_key);
+ zend_string_release(string_key);
} ZEND_HASH_FOREACH_END();
SAVE_CURL_ERROR(ch, error);
@@ -2619,7 +2619,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
break;
case CURLOPT_RETURNTRANSFER:
- convert_to_long_ex(zvalue);
+ convert_to_int_ex(zvalue);
if (Z_LVAL_P(zvalue)) {
ch->handlers->write->method = PHP_CURL_RETURN;
} else {
@@ -2639,14 +2639,14 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
#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);
+ convert_to_int_ex(zvalue);
error = curl_easy_setopt(ch->cp, option, (curl_off_t)Z_LVAL_P(zvalue));
break;
#endif
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
case CURLOPT_POSTREDIR:
- convert_to_long_ex(zvalue);
+ convert_to_int_ex(zvalue);
error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, Z_LVAL_P(zvalue) & CURL_REDIR_POST_ALL);
break;
#endif
@@ -2692,7 +2692,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
}
case CURLINFO_HEADER_OUT:
- convert_to_long_ex(zvalue);
+ convert_to_int_ex(zvalue);
if (Z_LVAL_P(zvalue) == 1) {
curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, curl_debug);
curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, (void *)ch);
@@ -2744,7 +2744,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
PHP_FUNCTION(curl_setopt)
{
zval *zid, *zvalue;
- long options;
+ zend_long options;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &zid, &options, &zvalue) == FAILURE) {
@@ -2772,7 +2772,7 @@ PHP_FUNCTION(curl_setopt_array)
{
zval *zid, *arr, *entry;
php_curl *ch;
- ulong option;
+ zend_ulong option;
zend_string *string_key;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "za", &zid, &arr) == FAILURE) {
@@ -2787,7 +2787,7 @@ PHP_FUNCTION(curl_setopt_array)
"Array keys must be CURLOPT constants or equivalent integer values");
RETURN_FALSE;
}
- if (_php_curl_setopt(ch, (long) option, entry TSRMLS_CC) == FAILURE) {
+ if (_php_curl_setopt(ch, (zend_long) option, entry TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
}
} ZEND_HASH_FOREACH_END();
@@ -2802,7 +2802,7 @@ void _php_curl_cleanup_handle(php_curl *ch)
{
smart_str_free(&ch->handlers->write->buf);
if (ch->header.str) {
- STR_RELEASE(ch->header.str);
+ zend_string_release(ch->header.str);
ch->header.str = NULL;
}
@@ -2847,7 +2847,7 @@ PHP_FUNCTION(curl_exec)
if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.s) {
smart_str_0(&ch->handlers->write->buf);
- RETURN_STR(STR_COPY(ch->handlers->write->buf.s));
+ RETURN_STR(zend_string_copy(ch->handlers->write->buf.s));
}
/* flush the file handle, so any remaining data is synched to disk */
@@ -2872,7 +2872,7 @@ PHP_FUNCTION(curl_getinfo)
{
zval *zid;
php_curl *ch;
- long option = 0;
+ zend_long option = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zid, &option) == FAILURE) {
return;
@@ -2882,7 +2882,7 @@ PHP_FUNCTION(curl_getinfo)
if (ZEND_NUM_ARGS() < 2) {
char *s_code;
- long l_code;
+ zend_long l_code;
double d_code;
#if LIBCURL_VERSION_NUM > 0x071301
struct curl_certinfo *ci = NULL;
@@ -2992,7 +2992,7 @@ PHP_FUNCTION(curl_getinfo)
switch (option) {
case CURLINFO_HEADER_OUT:
if (ch->header.str) {
- RETURN_STR(STR_COPY(ch->header.str));
+ RETURN_STR(zend_string_copy(ch->header.str));
} else {
RETURN_FALSE;
}
@@ -3026,7 +3026,7 @@ PHP_FUNCTION(curl_getinfo)
}
case CURLINFO_LONG:
{
- long code = 0;
+ zend_long code = 0;
if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
RETURN_LONG(code);
@@ -3175,7 +3175,7 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
#endif
zval_ptr_dtor(&ch->handlers->std_err);
if (ch->header.str) {
- STR_RELEASE(ch->header.str);
+ zend_string_release(ch->header.str);
}
zval_ptr_dtor(&ch->handlers->write_header->stream);
@@ -3217,7 +3217,7 @@ static void _php_curl_close(zend_resource *rsrc TSRMLS_DC)
return string describing error code */
PHP_FUNCTION(curl_strerror)
{
- long code;
+ zend_long code;
const char *str;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &code) == FAILURE) {
@@ -3363,7 +3363,7 @@ PHP_FUNCTION(curl_unescape)
pause and unpause a connection */
PHP_FUNCTION(curl_pause)
{
- long bitmask;
+ zend_long bitmask;
zval *zid;
php_curl *ch;
diff --git a/ext/curl/multi.c b/ext/curl/multi.c
index 5550972bba..14f1e1ae84 100644
--- a/ext/curl/multi.c
+++ b/ext/curl/multi.c
@@ -92,7 +92,7 @@ PHP_FUNCTION(curl_multi_add_handle)
zend_llist_add_element(&mh->easyh, &tmp_val);
- RETURN_LONG((long)curl_multi_add_handle(mh->multi, ch->cp));
+ RETURN_LONG((zend_long)curl_multi_add_handle(mh->multi, ch->cp));
}
/* }}} */
@@ -140,7 +140,7 @@ 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);
- RETVAL_LONG((long)curl_multi_remove_handle(mh->multi, ch->cp));
+ RETVAL_LONG((zend_long)curl_multi_remove_handle(mh->multi, ch->cp));
zend_llist_del_element(&mh->easyh, &z_ch, (int (*)(void *, void *))curl_compare_resources);
}
@@ -218,7 +218,7 @@ PHP_FUNCTION(curl_multi_exec)
}
}
- convert_to_long_ex(z_still_running);
+ convert_to_int_ex(z_still_running);
still_running = Z_LVAL_P(z_still_running);
result = curl_multi_perform(mh->multi, &still_running);
ZVAL_LONG(z_still_running, still_running);
@@ -242,7 +242,7 @@ PHP_FUNCTION(curl_multi_getcontent)
if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.s) {
smart_str_0(&ch->handlers->write->buf);
- RETURN_STR(STR_COPY(ch->handlers->write->buf.s));
+ RETURN_STR(zend_string_copy(ch->handlers->write->buf.s));
}
RETURN_EMPTY_STRING();
@@ -357,7 +357,7 @@ void _php_curl_multi_close(zend_resource *rsrc TSRMLS_DC) /* {{{ */
return string describing error code */
PHP_FUNCTION(curl_multi_strerror)
{
- long code;
+ zend_long code;
const char *str;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &code) == FAILURE) {
@@ -375,7 +375,7 @@ PHP_FUNCTION(curl_multi_strerror)
#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) /* {{{ */
+static int _php_curl_multi_setopt(php_curlm *mh, zend_long option, zval *zvalue, zval *return_value TSRMLS_DC) /* {{{ */
{
CURLMcode error = CURLM_OK;
@@ -386,7 +386,7 @@ static int _php_curl_multi_setopt(php_curlm *mh, long option, zval *zvalue, zval
#if LIBCURL_VERSION_NUM >= 0x071003 /* 7.16.3 */
case CURLMOPT_MAXCONNECTS:
#endif
- convert_to_long_ex(zvalue);
+ convert_to_int_ex(zvalue);
error = curl_multi_setopt(mh->multi, option, Z_LVAL_P(zvalue));
break;
@@ -409,7 +409,7 @@ static int _php_curl_multi_setopt(php_curlm *mh, long option, zval *zvalue, zval
PHP_FUNCTION(curl_multi_setopt)
{
zval *z_mh, *zvalue;
- long options;
+ zend_long options;
php_curlm *mh;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &z_mh, &options, &zvalue) == FAILURE) {
diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h
index e82fd3f38b..c75d7f80d1 100644
--- a/ext/curl/php_curl.h
+++ b/ext/curl/php_curl.h
@@ -179,7 +179,7 @@ typedef struct {
php_curl_handlers *handlers;
zend_resource *res;
zend_bool in_callback;
- zend_uint clone;
+ uint32_t clone;
zend_bool safe_upload;
} php_curl;
diff --git a/ext/curl/share.c b/ext/curl/share.c
index 5983579f08..254ab2d2d6 100644
--- a/ext/curl/share.c
+++ b/ext/curl/share.c
@@ -66,14 +66,14 @@ PHP_FUNCTION(curl_share_close)
}
/* }}} */
-static int _php_curl_share_setopt(php_curlsh *sh, long option, zval *zvalue, zval *return_value TSRMLS_DC) /* {{{ */
+static int _php_curl_share_setopt(php_curlsh *sh, zend_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);
+ convert_to_int_ex(zvalue);
error = curl_share_setopt(sh->share, option, Z_LVAL_P(zvalue));
break;
@@ -96,7 +96,7 @@ static int _php_curl_share_setopt(php_curlsh *sh, long option, zval *zvalue, zva
PHP_FUNCTION(curl_share_setopt)
{
zval *zid, *zvalue;
- long options;
+ zend_long options;
php_curlsh *sh;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &zid, &options, &zvalue) == FAILURE) {
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c
index 015da88914..ad9727d197 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 Thu Jul 31 14:33:37 2014 */
+/* Generated by re2c 0.13.5 on Tue Aug 19 08:27:07 2014 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
@@ -670,7 +670,7 @@ static void timelib_set_relative(char **ptr, timelib_sll amount, int behavior, S
}
}
-const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffset, int isdst)
+const static timelib_tz_lookup_table* abbr_search(const char *word, long gmtoffset, int isdst)
{
int first_found = 0;
const timelib_tz_lookup_table *tp, *first_found_elem = NULL;
@@ -698,25 +698,6 @@ const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffs
return first_found_elem;
}
- for (tp = timelib_timezone_lookup; tp->name; tp++) {
- if (tp->full_tz_name && strcasecmp(word, tp->full_tz_name) == 0) {
- if (!first_found) {
- first_found = 1;
- first_found_elem = tp;
- if (gmtoffset == -1) {
- return tp;
- }
- }
- if (tp->gmtoffset == gmtoffset) {
- return tp;
- }
- }
- }
- if (first_found) {
- return first_found_elem;
- }
-
-
/* Still didn't find anything, let's find the zone solely based on
* offset/isdst then */
for (fmp = timelib_timezone_fallbackmap; fmp->name; fmp++) {
@@ -727,7 +708,7 @@ const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffs
return NULL;
}
-static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found)
+static long timelib_lookup_abbr(char **ptr, int *dst, char **tz_abbr, int *found)
{
char *word;
char *begin = *ptr, *end;
@@ -741,7 +722,7 @@ static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found
word = calloc(1, end - begin + 1);
memcpy(word, begin, end - begin);
- if ((tp = zone_search(word, -1, 0))) {
+ if ((tp = abbr_search(word, -1, 0))) {
value = -tp->gmtoffset / 60;
*dst = tp->type;
value += tp->type * 60;
@@ -785,33 +766,26 @@ long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found
retval = timelib_parse_tz_cor(ptr);
} else {
int found = 0;
- long offset;
+ long offset = 0;
char *tz_abbr;
t->is_localtime = 1;
- offset = timelib_lookup_zone(ptr, dst, &tz_abbr, &found);
+ /* First, we lookup by abbreviation only */
+ offset = timelib_lookup_abbr(ptr, dst, &tz_abbr, &found);
if (found) {
t->zone_type = TIMELIB_ZONETYPE_ABBR;
+ timelib_time_tz_abbr_update(t, tz_abbr);
}
-#if 0
- /* If we found a TimeZone identifier, use it */
- if (tz_name) {
- t->tz_info = timelib_parse_tzfile(tz_name);
- t->zone_type = TIMELIB_ZONETYPE_ID;
- }
-#endif
- /* If we have a TimeZone identifier to start with, use it */
- if (strstr(tz_abbr, "/") || strcmp(tz_abbr, "UTC") == 0) {
+
+ /* Otherwise, we look if we have a TimeZone identifier */
+ if (!found || strcmp("UTC", tz_abbr) == 0) {
if ((res = tz_wrapper(tz_abbr, tzdb)) != NULL) {
t->tz_info = res;
t->zone_type = TIMELIB_ZONETYPE_ID;
found++;
}
}
- if (found && t->zone_type != TIMELIB_ZONETYPE_ID) {
- timelib_time_tz_abbr_update(t, tz_abbr);
- }
free(tz_abbr);
*tz_not_found = (found == 0);
retval = offset;
@@ -840,11 +814,11 @@ static int scan(Scanner *s, timelib_tz_get_wrapper tz_get_wrapper)
std:
s->tok = cursor;
s->len = 0;
-#line 966 "ext/date/lib/parse_date.re"
+#line 940 "ext/date/lib/parse_date.re"
-#line 848 "ext/date/lib/parse_date.c"
+#line 822 "ext/date/lib/parse_date.c"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
@@ -984,7 +958,7 @@ yy2:
}
yy3:
YYDEBUG(3, *YYCURSOR);
-#line 1646 "ext/date/lib/parse_date.re"
+#line 1620 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("tzcorrection | tz");
@@ -997,7 +971,7 @@ yy3:
TIMELIB_DEINIT;
return TIMELIB_TIMEZONE;
}
-#line 1001 "ext/date/lib/parse_date.c"
+#line 975 "ext/date/lib/parse_date.c"
yy4:
YYDEBUG(4, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1308,12 +1282,12 @@ yy11:
if (yych <= '9') goto yy1385;
yy12:
YYDEBUG(12, *YYCURSOR);
-#line 1741 "ext/date/lib/parse_date.re"
+#line 1715 "ext/date/lib/parse_date.re"
{
add_error(s, "Unexpected character");
goto std;
}
-#line 1317 "ext/date/lib/parse_date.c"
+#line 1291 "ext/date/lib/parse_date.c"
yy13:
YYDEBUG(13, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2370,11 +2344,11 @@ yy48:
if (yych <= '9') goto yy54;
yy49:
YYDEBUG(49, *YYCURSOR);
-#line 1730 "ext/date/lib/parse_date.re"
+#line 1704 "ext/date/lib/parse_date.re"
{
goto std;
}
-#line 2378 "ext/date/lib/parse_date.c"
+#line 2352 "ext/date/lib/parse_date.c"
yy50:
YYDEBUG(50, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2383,12 +2357,12 @@ yy51:
YYDEBUG(51, *YYCURSOR);
++YYCURSOR;
YYDEBUG(52, *YYCURSOR);
-#line 1735 "ext/date/lib/parse_date.re"
+#line 1709 "ext/date/lib/parse_date.re"
{
s->pos = cursor; s->line++;
goto std;
}
-#line 2392 "ext/date/lib/parse_date.c"
+#line 2366 "ext/date/lib/parse_date.c"
yy53:
YYDEBUG(53, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2775,7 +2749,7 @@ yy71:
if (yych == 's') goto yy73;
yy72:
YYDEBUG(72, *YYCURSOR);
-#line 1714 "ext/date/lib/parse_date.re"
+#line 1688 "ext/date/lib/parse_date.re"
{
timelib_ull i;
DEBUG_OUTPUT("relative");
@@ -2790,7 +2764,7 @@ yy72:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 2794 "ext/date/lib/parse_date.c"
+#line 2768 "ext/date/lib/parse_date.c"
yy73:
YYDEBUG(73, *YYCURSOR);
yych = *++YYCURSOR;
@@ -3552,7 +3526,7 @@ yy165:
}
yy166:
YYDEBUG(166, *YYCURSOR);
-#line 1577 "ext/date/lib/parse_date.re"
+#line 1551 "ext/date/lib/parse_date.re"
{
const timelib_relunit* relunit;
DEBUG_OUTPUT("daytext");
@@ -3569,7 +3543,7 @@ yy166:
TIMELIB_DEINIT;
return TIMELIB_WEEKDAY;
}
-#line 3573 "ext/date/lib/parse_date.c"
+#line 3547 "ext/date/lib/parse_date.c"
yy167:
YYDEBUG(167, *YYCURSOR);
yych = *++YYCURSOR;
@@ -4089,7 +4063,7 @@ yy192:
}
yy193:
YYDEBUG(193, *YYCURSOR);
-#line 1636 "ext/date/lib/parse_date.re"
+#line 1610 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("monthtext");
TIMELIB_INIT;
@@ -4098,7 +4072,7 @@ yy193:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
-#line 4102 "ext/date/lib/parse_date.c"
+#line 4076 "ext/date/lib/parse_date.c"
yy194:
YYDEBUG(194, *YYCURSOR);
++YYCURSOR;
@@ -4149,7 +4123,7 @@ yy197:
}
yy198:
YYDEBUG(198, *YYCURSOR);
-#line 1382 "ext/date/lib/parse_date.re"
+#line 1356 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datetextual | datenoyear");
@@ -4162,7 +4136,7 @@ yy198:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
-#line 4166 "ext/date/lib/parse_date.c"
+#line 4140 "ext/date/lib/parse_date.c"
yy199:
YYDEBUG(199, *YYCURSOR);
yyaccept = 6;
@@ -4431,7 +4405,7 @@ yy221:
}
yy222:
YYDEBUG(222, *YYCURSOR);
-#line 1684 "ext/date/lib/parse_date.re"
+#line 1658 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz");
@@ -4460,7 +4434,7 @@ yy222:
TIMELIB_DEINIT;
return TIMELIB_SHORTDATE_WITH_TIME;
}
-#line 4464 "ext/date/lib/parse_date.c"
+#line 4438 "ext/date/lib/parse_date.c"
yy223:
YYDEBUG(223, *YYCURSOR);
yyaccept = 7;
@@ -5158,7 +5132,7 @@ yy277:
YYDEBUG(277, *YYCURSOR);
++YYCURSOR;
YYDEBUG(278, *YYCURSOR);
-#line 1660 "ext/date/lib/parse_date.re"
+#line 1634 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("dateshortwithtimeshort12 | dateshortwithtimelong12");
TIMELIB_INIT;
@@ -5181,7 +5155,7 @@ yy277:
TIMELIB_DEINIT;
return TIMELIB_SHORTDATE_WITH_TIME;
}
-#line 5185 "ext/date/lib/parse_date.c"
+#line 5159 "ext/date/lib/parse_date.c"
yy279:
YYDEBUG(279, *YYCURSOR);
yych = *++YYCURSOR;
@@ -5359,7 +5333,7 @@ yy293:
++YYCURSOR;
yy294:
YYDEBUG(294, *YYCURSOR);
-#line 1354 "ext/date/lib/parse_date.re"
+#line 1328 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datenoday");
@@ -5372,7 +5346,7 @@ yy294:
TIMELIB_DEINIT;
return TIMELIB_DATE_NO_DAY;
}
-#line 5376 "ext/date/lib/parse_date.c"
+#line 5350 "ext/date/lib/parse_date.c"
yy295:
YYDEBUG(295, *YYCURSOR);
yych = *++YYCURSOR;
@@ -6592,7 +6566,7 @@ yy361:
if (yych <= '9') goto yy364;
yy363:
YYDEBUG(363, *YYCURSOR);
-#line 1498 "ext/date/lib/parse_date.re"
+#line 1472 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgtextshort");
@@ -6605,7 +6579,7 @@ yy363:
TIMELIB_DEINIT;
return TIMELIB_PG_TEXT;
}
-#line 6609 "ext/date/lib/parse_date.c"
+#line 6583 "ext/date/lib/parse_date.c"
yy364:
YYDEBUG(364, *YYCURSOR);
yych = *++YYCURSOR;
@@ -7243,7 +7217,7 @@ yy391:
}
yy392:
YYDEBUG(392, *YYCURSOR);
-#line 1556 "ext/date/lib/parse_date.re"
+#line 1530 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("ago");
TIMELIB_INIT;
@@ -7263,7 +7237,7 @@ yy392:
TIMELIB_DEINIT;
return TIMELIB_AGO;
}
-#line 7267 "ext/date/lib/parse_date.c"
+#line 7241 "ext/date/lib/parse_date.c"
yy393:
YYDEBUG(393, *YYCURSOR);
yyaccept = 5;
@@ -9013,7 +8987,7 @@ yy453:
++YYCURSOR;
yy454:
YYDEBUG(454, *YYCURSOR);
-#line 1259 "ext/date/lib/parse_date.re"
+#line 1233 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("iso8601date4 | iso8601date2 | iso8601dateslash | dateslash");
TIMELIB_INIT;
@@ -9024,7 +8998,7 @@ yy454:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 9028 "ext/date/lib/parse_date.c"
+#line 9002 "ext/date/lib/parse_date.c"
yy455:
YYDEBUG(455, *YYCURSOR);
yyaccept = 0;
@@ -9584,7 +9558,7 @@ yy474:
}
yy475:
YYDEBUG(475, *YYCURSOR);
-#line 1396 "ext/date/lib/parse_date.re"
+#line 1370 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenoyearrev");
TIMELIB_INIT;
@@ -9595,7 +9569,7 @@ yy475:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
-#line 9599 "ext/date/lib/parse_date.c"
+#line 9573 "ext/date/lib/parse_date.c"
yy476:
YYDEBUG(476, *YYCURSOR);
yyaccept = 10;
@@ -9736,7 +9710,7 @@ yy487:
YYDEBUG(487, *YYCURSOR);
++YYCURSOR;
YYDEBUG(488, *YYCURSOR);
-#line 1114 "ext/date/lib/parse_date.re"
+#line 1088 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12");
TIMELIB_INIT;
@@ -9752,7 +9726,7 @@ yy487:
TIMELIB_DEINIT;
return TIMELIB_TIME12;
}
-#line 9756 "ext/date/lib/parse_date.c"
+#line 9730 "ext/date/lib/parse_date.c"
yy489:
YYDEBUG(489, *YYCURSOR);
yyaccept = 11;
@@ -9765,7 +9739,7 @@ yy489:
}
yy490:
YYDEBUG(490, *YYCURSOR);
-#line 1151 "ext/date/lib/parse_date.re"
+#line 1125 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long");
@@ -9790,7 +9764,7 @@ yy490:
TIMELIB_DEINIT;
return TIMELIB_TIME24_WITH_ZONE;
}
-#line 9794 "ext/date/lib/parse_date.c"
+#line 9768 "ext/date/lib/parse_date.c"
yy491:
YYDEBUG(491, *YYCURSOR);
yyaccept = 11;
@@ -10100,7 +10074,7 @@ yy522:
YYDEBUG(522, *YYCURSOR);
++YYCURSOR;
YYDEBUG(523, *YYCURSOR);
-#line 1131 "ext/date/lib/parse_date.re"
+#line 1105 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("mssqltime");
TIMELIB_INIT;
@@ -10119,7 +10093,7 @@ yy522:
TIMELIB_DEINIT;
return TIMELIB_TIME24_WITH_ZONE;
}
-#line 10123 "ext/date/lib/parse_date.c"
+#line 10097 "ext/date/lib/parse_date.c"
yy524:
YYDEBUG(524, *YYCURSOR);
yyaccept = 11;
@@ -10225,7 +10199,7 @@ yy533:
if (yych <= '9') goto yy540;
yy534:
YYDEBUG(534, *YYCURSOR);
-#line 1313 "ext/date/lib/parse_date.re"
+#line 1287 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datefull");
@@ -10239,7 +10213,7 @@ yy534:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL;
}
-#line 10243 "ext/date/lib/parse_date.c"
+#line 10217 "ext/date/lib/parse_date.c"
yy535:
YYDEBUG(535, *YYCURSOR);
yych = *++YYCURSOR;
@@ -10976,7 +10950,7 @@ yy604:
YYDEBUG(605, *YYCURSOR);
++YYCURSOR;
YYDEBUG(606, *YYCURSOR);
-#line 1328 "ext/date/lib/parse_date.re"
+#line 1302 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("pointed date YYYY");
TIMELIB_INIT;
@@ -10987,7 +10961,7 @@ yy604:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL_POINTED;
}
-#line 10991 "ext/date/lib/parse_date.c"
+#line 10965 "ext/date/lib/parse_date.c"
yy607:
YYDEBUG(607, *YYCURSOR);
yyaccept = 11;
@@ -11023,7 +10997,7 @@ yy610:
if (yych <= '9') goto yy604;
yy611:
YYDEBUG(611, *YYCURSOR);
-#line 1340 "ext/date/lib/parse_date.re"
+#line 1314 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pointed date YY");
@@ -11036,7 +11010,7 @@ yy611:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL_POINTED;
}
-#line 11040 "ext/date/lib/parse_date.c"
+#line 11014 "ext/date/lib/parse_date.c"
yy612:
YYDEBUG(612, *YYCURSOR);
yyaccept = 11;
@@ -11677,7 +11651,7 @@ yy655:
}
yy656:
YYDEBUG(656, *YYCURSOR);
-#line 1299 "ext/date/lib/parse_date.re"
+#line 1273 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("gnudateshort");
@@ -11690,7 +11664,7 @@ yy656:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 11694 "ext/date/lib/parse_date.c"
+#line 11668 "ext/date/lib/parse_date.c"
yy657:
YYDEBUG(657, *YYCURSOR);
yyaccept = 13;
@@ -11796,7 +11770,7 @@ yy665:
}
yy666:
YYDEBUG(666, *YYCURSOR);
-#line 1243 "ext/date/lib/parse_date.re"
+#line 1217 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("americanshort | american");
@@ -11811,7 +11785,7 @@ yy666:
TIMELIB_DEINIT;
return TIMELIB_AMERICAN;
}
-#line 11815 "ext/date/lib/parse_date.c"
+#line 11789 "ext/date/lib/parse_date.c"
yy667:
YYDEBUG(667, *YYCURSOR);
yyaccept = 14;
@@ -12044,7 +12018,7 @@ yy699:
if (yych <= ':') goto yy703;
yy700:
YYDEBUG(700, *YYCURSOR);
-#line 1526 "ext/date/lib/parse_date.re"
+#line 1500 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("clf");
@@ -12064,7 +12038,7 @@ yy700:
TIMELIB_DEINIT;
return TIMELIB_CLF;
}
-#line 12068 "ext/date/lib/parse_date.c"
+#line 12042 "ext/date/lib/parse_date.c"
yy701:
YYDEBUG(701, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12616,7 +12590,7 @@ yy762:
}
yy763:
YYDEBUG(763, *YYCURSOR);
-#line 1271 "ext/date/lib/parse_date.re"
+#line 1245 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("iso8601date2");
@@ -12629,7 +12603,7 @@ yy763:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 12633 "ext/date/lib/parse_date.c"
+#line 12607 "ext/date/lib/parse_date.c"
yy764:
YYDEBUG(764, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12668,7 +12642,7 @@ yy770:
YYDEBUG(770, *YYCURSOR);
++YYCURSOR;
YYDEBUG(771, *YYCURSOR);
-#line 1512 "ext/date/lib/parse_date.re"
+#line 1486 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgtextreverse");
@@ -12681,7 +12655,7 @@ yy770:
TIMELIB_DEINIT;
return TIMELIB_PG_TEXT;
}
-#line 12685 "ext/date/lib/parse_date.c"
+#line 12659 "ext/date/lib/parse_date.c"
yy772:
YYDEBUG(772, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12819,7 +12793,7 @@ yy782:
}
yy783:
YYDEBUG(783, *YYCURSOR);
-#line 1547 "ext/date/lib/parse_date.re"
+#line 1521 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("year4");
TIMELIB_INIT;
@@ -12827,7 +12801,7 @@ yy783:
TIMELIB_DEINIT;
return TIMELIB_CLF;
}
-#line 12831 "ext/date/lib/parse_date.c"
+#line 12805 "ext/date/lib/parse_date.c"
yy784:
YYDEBUG(784, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12978,7 +12952,7 @@ yy792:
}
yy793:
YYDEBUG(793, *YYCURSOR);
-#line 1368 "ext/date/lib/parse_date.re"
+#line 1342 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datenodayrev");
@@ -12991,7 +12965,7 @@ yy793:
TIMELIB_DEINIT;
return TIMELIB_DATE_NO_DAY;
}
-#line 12995 "ext/date/lib/parse_date.c"
+#line 12969 "ext/date/lib/parse_date.c"
yy794:
YYDEBUG(794, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13206,7 +13180,7 @@ yy813:
if (yych <= '7') goto yy816;
yy814:
YYDEBUG(814, *YYCURSOR);
-#line 1479 "ext/date/lib/parse_date.re"
+#line 1453 "ext/date/lib/parse_date.re"
{
timelib_sll w, d;
DEBUG_OUTPUT("isoweek");
@@ -13224,7 +13198,7 @@ yy814:
TIMELIB_DEINIT;
return TIMELIB_ISO_WEEK;
}
-#line 13228 "ext/date/lib/parse_date.c"
+#line 13202 "ext/date/lib/parse_date.c"
yy815:
YYDEBUG(815, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13234,7 +13208,7 @@ yy816:
YYDEBUG(816, *YYCURSOR);
++YYCURSOR;
YYDEBUG(817, *YYCURSOR);
-#line 1460 "ext/date/lib/parse_date.re"
+#line 1434 "ext/date/lib/parse_date.re"
{
timelib_sll w, d;
DEBUG_OUTPUT("isoweekday");
@@ -13252,7 +13226,7 @@ yy816:
TIMELIB_DEINIT;
return TIMELIB_ISO_WEEK;
}
-#line 13256 "ext/date/lib/parse_date.c"
+#line 13230 "ext/date/lib/parse_date.c"
yy818:
YYDEBUG(818, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13316,7 +13290,7 @@ yy820:
}
yy821:
YYDEBUG(821, *YYCURSOR);
-#line 1446 "ext/date/lib/parse_date.re"
+#line 1420 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgydotd");
@@ -13329,7 +13303,7 @@ yy821:
TIMELIB_DEINIT;
return TIMELIB_PG_YEARDAY;
}
-#line 13333 "ext/date/lib/parse_date.c"
+#line 13307 "ext/date/lib/parse_date.c"
yy822:
YYDEBUG(822, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13432,7 +13406,7 @@ yy841:
++YYCURSOR;
yy842:
YYDEBUG(842, *YYCURSOR);
-#line 1420 "ext/date/lib/parse_date.re"
+#line 1394 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx | exif");
@@ -13457,7 +13431,7 @@ yy842:
TIMELIB_DEINIT;
return TIMELIB_XMLRPC_SOAP;
}
-#line 13461 "ext/date/lib/parse_date.c"
+#line 13435 "ext/date/lib/parse_date.c"
yy843:
YYDEBUG(843, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13719,7 +13693,7 @@ yy847:
}
yy848:
YYDEBUG(848, *YYCURSOR);
-#line 1408 "ext/date/lib/parse_date.re"
+#line 1382 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenocolon");
TIMELIB_INIT;
@@ -13730,7 +13704,7 @@ yy848:
TIMELIB_DEINIT;
return TIMELIB_DATE_NOCOLON;
}
-#line 13734 "ext/date/lib/parse_date.c"
+#line 13708 "ext/date/lib/parse_date.c"
yy849:
YYDEBUG(849, *YYCURSOR);
yych = *++YYCURSOR;
@@ -14650,7 +14624,7 @@ yy972:
if (yych <= '9') goto yy995;
yy973:
YYDEBUG(973, *YYCURSOR);
-#line 1285 "ext/date/lib/parse_date.re"
+#line 1259 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("gnudateshorter");
@@ -14663,7 +14637,7 @@ yy973:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 14667 "ext/date/lib/parse_date.c"
+#line 14641 "ext/date/lib/parse_date.c"
yy974:
YYDEBUG(974, *YYCURSOR);
yyaccept = 22;
@@ -15672,7 +15646,7 @@ yy1065:
}
yy1067:
YYDEBUG(1067, *YYCURSOR);
-#line 1177 "ext/date/lib/parse_date.re"
+#line 1151 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("gnunocolon");
TIMELIB_INIT;
@@ -15694,7 +15668,7 @@ yy1067:
TIMELIB_DEINIT;
return TIMELIB_GNU_NOCOLON;
}
-#line 15698 "ext/date/lib/parse_date.c"
+#line 15672 "ext/date/lib/parse_date.c"
yy1068:
YYDEBUG(1068, *YYCURSOR);
yych = *++YYCURSOR;
@@ -15786,7 +15760,7 @@ yy1074:
}
yy1075:
YYDEBUG(1075, *YYCURSOR);
-#line 1223 "ext/date/lib/parse_date.re"
+#line 1197 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("iso8601nocolon");
@@ -15805,7 +15779,7 @@ yy1075:
TIMELIB_DEINIT;
return TIMELIB_ISO_NOCOLON;
}
-#line 15809 "ext/date/lib/parse_date.c"
+#line 15783 "ext/date/lib/parse_date.c"
yy1076:
YYDEBUG(1076, *YYCURSOR);
yyaccept = 25;
@@ -16703,7 +16677,7 @@ yy1116:
}
yy1117:
YYDEBUG(1117, *YYCURSOR);
-#line 1619 "ext/date/lib/parse_date.re"
+#line 1593 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -16719,7 +16693,7 @@ yy1117:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 16723 "ext/date/lib/parse_date.c"
+#line 16697 "ext/date/lib/parse_date.c"
yy1118:
YYDEBUG(1118, *YYCURSOR);
++YYCURSOR;
@@ -16770,7 +16744,7 @@ yy1125:
YYDEBUG(1125, *YYCURSOR);
++YYCURSOR;
YYDEBUG(1126, *YYCURSOR);
-#line 1092 "ext/date/lib/parse_date.re"
+#line 1066 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -16791,7 +16765,7 @@ yy1125:
TIMELIB_DEINIT;
return TIMELIB_WEEK_DAY_OF_MONTH;
}
-#line 16795 "ext/date/lib/parse_date.c"
+#line 16769 "ext/date/lib/parse_date.c"
yy1127:
YYDEBUG(1127, *YYCURSOR);
yyaccept = 26;
@@ -16899,7 +16873,7 @@ yy1140:
}
yy1141:
YYDEBUG(1141, *YYCURSOR);
-#line 1595 "ext/date/lib/parse_date.re"
+#line 1569 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -16922,7 +16896,7 @@ yy1141:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 16926 "ext/date/lib/parse_date.c"
+#line 16900 "ext/date/lib/parse_date.c"
yy1142:
YYDEBUG(1142, *YYCURSOR);
yych = *++YYCURSOR;
@@ -19599,7 +19573,7 @@ yy1293:
goto yy1297;
yy1294:
YYDEBUG(1294, *YYCURSOR);
-#line 1069 "ext/date/lib/parse_date.re"
+#line 1043 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("backof | frontof");
TIMELIB_INIT;
@@ -19621,7 +19595,7 @@ yy1294:
TIMELIB_DEINIT;
return TIMELIB_LF_DAY_OF_MONTH;
}
-#line 19625 "ext/date/lib/parse_date.c"
+#line 19599 "ext/date/lib/parse_date.c"
yy1295:
YYDEBUG(1295, *YYCURSOR);
yyaccept = 28;
@@ -19882,14 +19856,14 @@ yy1315:
YYDEBUG(1315, *YYCURSOR);
++YYCURSOR;
YYDEBUG(1316, *YYCURSOR);
-#line 1052 "ext/date/lib/parse_date.re"
+#line 1026 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("firstdayof | lastdayof");
TIMELIB_INIT;
TIMELIB_HAVE_RELATIVE();
/* skip "last day of" or "first day of" */
- if (*ptr == 'l') {
+ if (*ptr == 'l' || *ptr == 'L') {
s->time->relative.first_last_day_of = 2;
} else {
s->time->relative.first_last_day_of = 1;
@@ -19898,7 +19872,7 @@ yy1315:
TIMELIB_DEINIT;
return TIMELIB_LF_DAY_OF_MONTH;
}
-#line 19902 "ext/date/lib/parse_date.c"
+#line 19876 "ext/date/lib/parse_date.c"
yy1317:
YYDEBUG(1317, *YYCURSOR);
yyaccept = 0;
@@ -21329,7 +21303,7 @@ yy1385:
if (yych <= '9') goto yy1385;
yy1387:
YYDEBUG(1387, *YYCURSOR);
-#line 1026 "ext/date/lib/parse_date.re"
+#line 1000 "ext/date/lib/parse_date.re"
{
timelib_ull i;
@@ -21354,7 +21328,7 @@ yy1387:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 21358 "ext/date/lib/parse_date.c"
+#line 21332 "ext/date/lib/parse_date.c"
yy1388:
YYDEBUG(1388, *YYCURSOR);
yych = *++YYCURSOR;
@@ -21790,7 +21764,7 @@ yy1416:
++YYCURSOR;
yy1417:
YYDEBUG(1417, *YYCURSOR);
-#line 1014 "ext/date/lib/parse_date.re"
+#line 988 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("tomorrow");
TIMELIB_INIT;
@@ -21801,7 +21775,7 @@ yy1417:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 21805 "ext/date/lib/parse_date.c"
+#line 21779 "ext/date/lib/parse_date.c"
yy1418:
YYDEBUG(1418, *YYCURSOR);
yych = *++YYCURSOR;
@@ -21836,7 +21810,7 @@ yy1419:
}
yy1420:
YYDEBUG(1420, *YYCURSOR);
-#line 1004 "ext/date/lib/parse_date.re"
+#line 978 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("midnight | today");
TIMELIB_INIT;
@@ -21845,7 +21819,7 @@ yy1420:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 21849 "ext/date/lib/parse_date.c"
+#line 21823 "ext/date/lib/parse_date.c"
yy1421:
YYDEBUG(1421, *YYCURSOR);
yych = *++YYCURSOR;
@@ -23857,7 +23831,7 @@ yy1499:
}
yy1500:
YYDEBUG(1500, *YYCURSOR);
-#line 983 "ext/date/lib/parse_date.re"
+#line 957 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("now");
TIMELIB_INIT;
@@ -23865,7 +23839,7 @@ yy1500:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 23869 "ext/date/lib/parse_date.c"
+#line 23843 "ext/date/lib/parse_date.c"
yy1501:
YYDEBUG(1501, *YYCURSOR);
yych = *++YYCURSOR;
@@ -24004,7 +23978,7 @@ yy1507:
}
yy1508:
YYDEBUG(1508, *YYCURSOR);
-#line 992 "ext/date/lib/parse_date.re"
+#line 966 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("noon");
TIMELIB_INIT;
@@ -24015,7 +23989,7 @@ yy1508:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 24019 "ext/date/lib/parse_date.c"
+#line 23993 "ext/date/lib/parse_date.c"
yy1509:
YYDEBUG(1509, *YYCURSOR);
yyaccept = 0;
@@ -24548,7 +24522,7 @@ yy1530:
++YYCURSOR;
yy1531:
YYDEBUG(1531, *YYCURSOR);
-#line 971 "ext/date/lib/parse_date.re"
+#line 945 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("yesterday");
TIMELIB_INIT;
@@ -24559,7 +24533,7 @@ yy1531:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 24563 "ext/date/lib/parse_date.c"
+#line 24537 "ext/date/lib/parse_date.c"
yy1532:
YYDEBUG(1532, *YYCURSOR);
yyaccept = 0;
@@ -24732,7 +24706,7 @@ yy1537:
goto yy1531;
}
}
-#line 1745 "ext/date/lib/parse_date.re"
+#line 1719 "ext/date/lib/parse_date.re"
}
@@ -25223,7 +25197,7 @@ char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst)
{
const timelib_tz_lookup_table *tp;
- tp = zone_search(abbr, gmtoffset, isdst);
+ tp = abbr_search(abbr, gmtoffset, isdst);
if (tp) {
return (tp->full_tz_name);
} else {
diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re
index 760caea330..c7953e75ba 100644
--- a/ext/date/lib/parse_date.re
+++ b/ext/date/lib/parse_date.re
@@ -668,7 +668,7 @@ static void timelib_set_relative(char **ptr, timelib_sll amount, int behavior, S
}
}
-const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffset, int isdst)
+const static timelib_tz_lookup_table* abbr_search(const char *word, long gmtoffset, int isdst)
{
int first_found = 0;
const timelib_tz_lookup_table *tp, *first_found_elem = NULL;
@@ -696,25 +696,6 @@ const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffs
return first_found_elem;
}
- for (tp = timelib_timezone_lookup; tp->name; tp++) {
- if (tp->full_tz_name && strcasecmp(word, tp->full_tz_name) == 0) {
- if (!first_found) {
- first_found = 1;
- first_found_elem = tp;
- if (gmtoffset == -1) {
- return tp;
- }
- }
- if (tp->gmtoffset == gmtoffset) {
- return tp;
- }
- }
- }
- if (first_found) {
- return first_found_elem;
- }
-
-
/* Still didn't find anything, let's find the zone solely based on
* offset/isdst then */
for (fmp = timelib_timezone_fallbackmap; fmp->name; fmp++) {
@@ -725,7 +706,7 @@ const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffs
return NULL;
}
-static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found)
+static long timelib_lookup_abbr(char **ptr, int *dst, char **tz_abbr, int *found)
{
char *word;
char *begin = *ptr, *end;
@@ -739,7 +720,7 @@ static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found
word = calloc(1, end - begin + 1);
memcpy(word, begin, end - begin);
- if ((tp = zone_search(word, -1, 0))) {
+ if ((tp = abbr_search(word, -1, 0))) {
value = -tp->gmtoffset / 60;
*dst = tp->type;
value += tp->type * 60;
@@ -783,33 +764,26 @@ long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found
retval = timelib_parse_tz_cor(ptr);
} else {
int found = 0;
- long offset;
+ long offset = 0;
char *tz_abbr;
t->is_localtime = 1;
- offset = timelib_lookup_zone(ptr, dst, &tz_abbr, &found);
+ /* First, we lookup by abbreviation only */
+ offset = timelib_lookup_abbr(ptr, dst, &tz_abbr, &found);
if (found) {
t->zone_type = TIMELIB_ZONETYPE_ABBR;
+ timelib_time_tz_abbr_update(t, tz_abbr);
}
-#if 0
- /* If we found a TimeZone identifier, use it */
- if (tz_name) {
- t->tz_info = timelib_parse_tzfile(tz_name);
- t->zone_type = TIMELIB_ZONETYPE_ID;
- }
-#endif
- /* If we have a TimeZone identifier to start with, use it */
- if (strstr(tz_abbr, "/") || strcmp(tz_abbr, "UTC") == 0) {
+
+ /* Otherwise, we look if we have a TimeZone identifier */
+ if (!found || strcmp("UTC", tz_abbr) == 0) {
if ((res = tz_wrapper(tz_abbr, tzdb)) != NULL) {
t->tz_info = res;
t->zone_type = TIMELIB_ZONETYPE_ID;
found++;
}
}
- if (found && t->zone_type != TIMELIB_ZONETYPE_ID) {
- timelib_time_tz_abbr_update(t, tz_abbr);
- }
free(tz_abbr);
*tz_not_found = (found == 0);
retval = offset;
@@ -1055,7 +1029,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
TIMELIB_HAVE_RELATIVE();
/* skip "last day of" or "first day of" */
- if (*ptr == 'l') {
+ if (*ptr == 'l' || *ptr == 'L') {
s->time->relative.first_last_day_of = 2;
} else {
s->time->relative.first_last_day_of = 1;
@@ -2232,7 +2206,7 @@ char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst)
{
const timelib_tz_lookup_table *tp;
- tp = zone_search(abbr, gmtoffset, isdst);
+ tp = abbr_search(abbr, gmtoffset, isdst);
if (tp) {
return (tp->full_tz_name);
} else {
diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c
index bf7c55a735..65029e7d1c 100644
--- a/ext/date/lib/timelib.c
+++ b/ext/date/lib/timelib.c
@@ -176,13 +176,13 @@ void timelib_error_container_dtor(timelib_error_container *errors)
free(errors);
}
-signed long timelib_date_to_int(timelib_time *d, int *error)
+zend_long timelib_date_to_int(timelib_time *d, int *error)
{
timelib_sll ts;
ts = d->sse;
- if (ts < LONG_MIN || ts > LONG_MAX) {
+ if (ts < ZEND_LONG_MIN || ts > ZEND_LONG_MAX) {
if (error) {
*error = 1;
}
@@ -191,7 +191,7 @@ signed long timelib_date_to_int(timelib_time *d, int *error)
if (error) {
*error = 0;
}
- return (signed long) d->sse;
+ return (zend_long) d->sse;
}
void timelib_decimal_hour_to_hms(double h, int *hour, int *min, int *sec)
diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h
index 08484fbec1..1185dbfe5c 100644
--- a/ext/date/lib/timelib.h
+++ b/ext/date/lib/timelib.h
@@ -21,6 +21,7 @@
#ifndef __TIMELIB_H__
#define __TIMELIB_H__
+#include "php.h" /* for zend_long */
#include "timelib_structs.h"
#if HAVE_LIMITS_H
#include <limits.h>
@@ -128,7 +129,7 @@ void timelib_time_offset_dtor(timelib_time_offset* t);
void timelib_error_container_dtor(timelib_error_container *errors);
-signed long timelib_date_to_int(timelib_time *d, int *error);
+zend_long timelib_date_to_int(timelib_time *d, int *error);
void timelib_dump_date(timelib_time *d, int options);
void timelib_dump_rel_time(timelib_rel_time *d);
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 6cea2af048..e8c8aac06a 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -1217,7 +1217,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime)
{
char *format;
int format_len;
- long ts;
+ zend_long ts;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &format, &format_len, &ts) == FAILURE) {
RETURN_FALSE;
@@ -1373,7 +1373,7 @@ PHP_FUNCTION(idate)
{
char *format;
int format_len;
- long ts = 0;
+ zend_long ts = 0;
int ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &format, &format_len, &ts) == FAILURE) {
@@ -1411,12 +1411,12 @@ PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb)
/* }}} */
/* {{{ php_parse_date: Backwards compatibility function */
-PHPAPI signed long php_parse_date(char *string, signed long *now)
+PHPAPI zend_long php_parse_date(char *string, zend_long *now)
{
timelib_time *parsed_time;
timelib_error_container *error = NULL;
int error2;
- signed long retval;
+ zend_long retval;
parsed_time = timelib_strtotime(string, strlen(string), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
if (error->error_count) {
@@ -1442,7 +1442,7 @@ PHP_FUNCTION(strtotime)
char *times, *initial_ts;
int time_len, error1, error2;
struct timelib_error_container *error;
- long preset_ts = 0, ts;
+ zend_long preset_ts = 0, ts;
timelib_time *t, *now;
timelib_tzinfo *tzi;
@@ -1454,7 +1454,7 @@ PHP_FUNCTION(strtotime)
now = timelib_time_ctor();
initial_ts = emalloc(25);
- snprintf(initial_ts, 24, "@%ld UTC", preset_ts);
+ snprintf(initial_ts, 24, "@" ZEND_LONG_FMT " UTC", preset_ts);
t = timelib_strtotime(initial_ts, strlen(initial_ts), NULL, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); /* we ignore the error here, as this should never fail */
timelib_update_ts(t, tzi);
now->tz_info = tzi;
@@ -1498,10 +1498,10 @@ PHP_FUNCTION(strtotime)
/* {{{ php_mktime - (gm)mktime helper */
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
{
- long hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0, dst = -1;
+ zend_long hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0, dst = -1;
timelib_time *now;
timelib_tzinfo *tzi = NULL;
- long ts, adjust_seconds = 0;
+ zend_long ts, adjust_seconds = 0;
int error;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lllllll", &hou, &min, &sec, &mon, &day, &yea, &dst) == FAILURE) {
@@ -1607,7 +1607,7 @@ PHP_FUNCTION(gmmktime)
Returns true(1) if it is a valid date in gregorian calendar */
PHP_FUNCTION(checkdate)
{
- long m, d, y;
+ zend_long m, d, y;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &m, &d, &y) == FAILURE) {
RETURN_FALSE;
@@ -1626,7 +1626,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
{
char *format;
int format_len;
- long timestamp = 0;
+ zend_long timestamp = 0;
struct tm ta;
int max_reallocs = 5;
size_t buf_len = 256, real_len;
@@ -1635,7 +1635,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
timelib_time_offset *offset = NULL;
zend_string *buf;
- timestamp = (long) time(NULL);
+ timestamp = (zend_long) time(NULL);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &format, &format_len, &timestamp) == FAILURE) {
RETURN_FALSE;
@@ -1686,10 +1686,10 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
/* VS2012 crt has a bug where strftime crash with %z and %Z format when the
initial buffer is too small. See
http://connect.microsoft.com/VisualStudio/feedback/details/759720/vs2012-strftime-crash-with-z-formatting-code */
- buf = STR_ALLOC(buf_len, 0);
+ buf = zend_string_alloc(buf_len, 0);
while ((real_len = strftime(buf->val, buf_len, format, &ta)) == buf_len || real_len == 0) {
buf_len *= 2;
- buf = STR_REALLOC(buf, buf_len, 0);
+ buf = zend_string_realloc(buf, buf_len, 0);
if (!--max_reallocs) {
break;
}
@@ -1698,7 +1698,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
/* VS2012 strftime() returns number of characters, not bytes.
See VC++11 bug id 766205. */
if (real_len > 0) {
- real_len = buf->len;
+ real_len = strlen(buf->val);
}
#endif
@@ -1708,10 +1708,10 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
}
if (real_len && real_len != buf_len) {
- buf = STR_REALLOC(buf, real_len, 0);
+ buf = zend_string_realloc(buf, real_len, 0);
RETURN_STR(buf);
}
- STR_FREE(buf);
+ zend_string_free(buf);
RETURN_FALSE;
}
/* }}} */
@@ -1737,7 +1737,7 @@ PHP_FUNCTION(gmstrftime)
Return current UNIX timestamp */
PHP_FUNCTION(time)
{
- RETURN_LONG((long)time(NULL));
+ RETURN_LONG((zend_long)time(NULL));
}
/* }}} */
@@ -1745,7 +1745,7 @@ PHP_FUNCTION(time)
Returns the results of the C system call localtime as an associative array if the associative_array argument is set to 1 other wise it is a regular array */
PHP_FUNCTION(localtime)
{
- long timestamp = (long)time(NULL);
+ zend_long timestamp = (zend_long)time(NULL);
zend_bool associative = 0;
timelib_tzinfo *tzi;
timelib_time *ts;
@@ -1792,7 +1792,7 @@ PHP_FUNCTION(localtime)
Get date/time information */
PHP_FUNCTION(getdate)
{
- long timestamp = (long)time(NULL);
+ zend_long timestamp = (zend_long)time(NULL);
timelib_tzinfo *tzi;
timelib_time *ts;
@@ -2211,7 +2211,7 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC) /* {{{ */
ZVAL_STRING(&zv, dateobj->time->tz_info->name);
break;
case TIMELIB_ZONETYPE_OFFSET: {
- zend_string *tmpstr = STR_ALLOC(sizeof("UTC+05:00")-1, 0);
+ zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0);
timelib_sll utc_offset = dateobj->time->z;
tmpstr->len = snprintf(tmpstr->val, sizeof("+05:00"), "%c%02d:%02d",
@@ -2304,7 +2304,7 @@ static HashTable *date_object_get_properties_timezone(zval *object TSRMLS_DC) /*
ZVAL_STRING(&zv, tzobj->tzi.tz->name);
break;
case TIMELIB_ZONETYPE_OFFSET: {
- zend_string *tmpstr = STR_ALLOC(sizeof("UTC+05:00")-1, 0);
+ zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0);
tmpstr->len = snprintf(tmpstr->val, sizeof("+05:00"), "%c%02d:%02d",
tzobj->tzi.utc_offset > 0 ? '-' : '+',
@@ -2377,7 +2377,7 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC) /*
}
#define PHP_DATE_INTERVAL_ADD_PROPERTY(n,f) \
- ZVAL_LONG(&zv, (long)intervalobj->diff->f); \
+ ZVAL_LONG(&zv, (zend_long)intervalobj->diff->f); \
zend_hash_str_update(props, n, sizeof(n)-1, &zv);
PHP_DATE_INTERVAL_ADD_PROPERTY("y", y);
@@ -2760,7 +2760,7 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
convert_to_string(z_date);
z_timezone_type = zend_hash_str_find(myht, "timezone_type", sizeof("timezone_type")-1);
if (z_timezone_type) {
- convert_to_long(z_timezone_type);
+ convert_to_int(z_timezone_type);
z_timezone = zend_hash_str_find(myht, "timezone", sizeof("timezone")-1);
if (z_timezone) {
convert_to_string(z_timezone);
@@ -3377,7 +3377,7 @@ PHP_FUNCTION(date_offset_get)
}
/* }}} */
-static void php_date_time_set(zval *object, long h, long i, long s, zval *return_value TSRMLS_DC) /* {{{ */
+static void php_date_time_set(zval *object, zend_long h, zend_long i, zend_long s, zval *return_value TSRMLS_DC) /* {{{ */
{
php_date_obj *dateobj;
@@ -3395,7 +3395,7 @@ static void php_date_time_set(zval *object, long h, long i, long s, zval *return
PHP_FUNCTION(date_time_set)
{
zval *object;
- long h, i, s = 0;
+ zend_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;
@@ -3412,7 +3412,7 @@ PHP_FUNCTION(date_time_set)
PHP_METHOD(DateTimeImmutable, setTime)
{
zval *object, new_object;
- long h, i, s = 0;
+ zend_long h, i, s = 0;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_immutable, &h, &i, &s) == FAILURE) {
RETURN_FALSE;
@@ -3425,7 +3425,7 @@ PHP_METHOD(DateTimeImmutable, setTime)
}
/* }}} */
-static void php_date_date_set(zval *object, long y, long m, long d, zval *return_value TSRMLS_DC) /* {{{ */
+static void php_date_date_set(zval *object, zend_long y, zend_long m, zend_long d, zval *return_value TSRMLS_DC) /* {{{ */
{
php_date_obj *dateobj;
@@ -3443,7 +3443,7 @@ static void php_date_date_set(zval *object, long y, long m, long d, zval *return
PHP_FUNCTION(date_date_set)
{
zval *object;
- long y, m, d;
+ zend_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;
@@ -3460,7 +3460,7 @@ PHP_FUNCTION(date_date_set)
PHP_METHOD(DateTimeImmutable, setDate)
{
zval *object, new_object;
- long y, m, d;
+ zend_long y, m, d;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olll", &object, date_ce_immutable, &y, &m, &d) == FAILURE) {
RETURN_FALSE;
@@ -3473,7 +3473,7 @@ PHP_METHOD(DateTimeImmutable, setDate)
}
/* }}} */
-static void php_date_isodate_set(zval *object, long y, long w, long d, zval *return_value TSRMLS_DC) /* {{{ */
+static void php_date_isodate_set(zval *object, zend_long y, zend_long w, zend_long d, zval *return_value TSRMLS_DC) /* {{{ */
{
php_date_obj *dateobj;
@@ -3495,7 +3495,7 @@ static void php_date_isodate_set(zval *object, long y, long w, long d, zval *ret
PHP_FUNCTION(date_isodate_set)
{
zval *object;
- long y, w, d = 1;
+ zend_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;
@@ -3512,7 +3512,7 @@ PHP_FUNCTION(date_isodate_set)
PHP_METHOD(DateTimeImmutable, setISODate)
{
zval *object, new_object;
- long y, w, d = 1;
+ zend_long y, w, d = 1;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_immutable, &y, &w, &d) == FAILURE) {
RETURN_FALSE;
@@ -3525,7 +3525,7 @@ PHP_METHOD(DateTimeImmutable, setISODate)
}
/* }}} */
-static void php_date_timestamp_set(zval *object, long timestamp, zval *return_value TSRMLS_DC) /* {{{ */
+static void php_date_timestamp_set(zval *object, zend_long timestamp, zval *return_value TSRMLS_DC) /* {{{ */
{
php_date_obj *dateobj;
@@ -3541,7 +3541,7 @@ static void php_date_timestamp_set(zval *object, long timestamp, zval *return_va
PHP_FUNCTION(date_timestamp_set)
{
zval *object;
- long timestamp;
+ zend_long timestamp;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &object, date_ce_date, &timestamp) == FAILURE) {
RETURN_FALSE;
@@ -3558,7 +3558,7 @@ PHP_FUNCTION(date_timestamp_set)
PHP_METHOD(DateTimeImmutable, setTimestamp)
{
zval *object, new_object;
- long timestamp;
+ zend_long timestamp;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &object, date_ce_immutable, &timestamp) == FAILURE) {
RETURN_FALSE;
@@ -3578,7 +3578,7 @@ PHP_FUNCTION(date_timestamp_get)
{
zval *object;
php_date_obj *dateobj;
- long timestamp;
+ zend_long timestamp;
int error;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, date_ce_interface) == FAILURE) {
@@ -3605,7 +3605,7 @@ PHP_FUNCTION(date_diff)
zval *object1, *object2;
php_date_obj *dateobj1, *dateobj2;
php_interval_obj *interval;
- long absolute = 0;
+ zend_long absolute = 0;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO|l", &object1, date_ce_interface, &object2, date_ce_interface, &absolute) == FAILURE) {
RETURN_FALSE;
@@ -3692,7 +3692,7 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
if ((z_timezone_type = zend_hash_str_find(myht, "timezone_type", sizeof("timezone_type")-1)) != NULL) {
if ((z_timezone = zend_hash_str_find(myht, "timezone", sizeof("timezone")-1)) != NULL) {
- convert_to_long(z_timezone_type);
+ convert_to_int(z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_P(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3756,7 +3756,7 @@ PHP_FUNCTION(timezone_name_get)
RETURN_STRING(tzobj->tzi.tz->name);
break;
case TIMELIB_ZONETYPE_OFFSET: {
- zend_string *tmpstr = STR_ALLOC(sizeof("UTC+05:00")-1, 0);
+ zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0);
timelib_sll utc_offset = tzobj->tzi.utc_offset;
tmpstr->len = snprintf(tmpstr->val, sizeof("+05:00"), "%c%02d:%02d",
@@ -3782,8 +3782,8 @@ PHP_FUNCTION(timezone_name_from_abbr)
char *abbr;
char *tzid;
int abbr_len;
- long gmtoffset = -1;
- long isdst = -1;
+ zend_long gmtoffset = -1;
+ zend_long isdst = -1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &abbr, &abbr_len, &gmtoffset, &isdst) == FAILURE) {
RETURN_FALSE;
@@ -3840,7 +3840,7 @@ PHP_FUNCTION(timezone_transitions_get)
zval *object, element;
php_timezone_obj *tzobj;
unsigned int i, begin = 0, found;
- long timestamp_begin = LONG_MIN, timestamp_end = LONG_MAX;
+ zend_long timestamp_begin = ZEND_LONG_MIN, timestamp_end = ZEND_LONG_MAX;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|ll", &object, date_ce_timezone, &timestamp_begin, &timestamp_end) == FAILURE) {
RETURN_FALSE;
@@ -3873,7 +3873,7 @@ PHP_FUNCTION(timezone_transitions_get)
array_init(return_value);
- if (timestamp_begin == LONG_MIN) {
+ if (timestamp_begin == ZEND_LONG_MIN) {
add_nominal();
begin = 0;
found = 1;
@@ -4131,7 +4131,7 @@ static int php_date_interval_initialize_from_hash(zval **return_value, php_inter
if (z_arg) { \
zend_string *str = zval_get_string(z_arg); \
DATE_A64I((*intobj)->diff->member, str->val); \
- STR_RELEASE(str); \
+ zend_string_release(str); \
} else { \
(*intobj)->diff->member = -1LL; \
} \
@@ -4248,8 +4248,8 @@ static zend_string *date_interval_format(char *format, int format_len, timelib_r
case 'I': length = slprintf(buffer, 32, "%02d", (int) t->i); break;
case 'i': length = slprintf(buffer, 32, "%d", (int) t->i); break;
- case 'S': length = slprintf(buffer, 32, "%02ld", (long) t->s); break;
- case 's': length = slprintf(buffer, 32, "%ld", (long) t->s); break;
+ case 'S': length = slprintf(buffer, 32, "%02" ZEND_LONG_FMT_SPEC, (zend_long) t->s); break;
+ case 's': length = slprintf(buffer, 32, ZEND_LONG_FMT, (zend_long) t->s); break;
case 'a': {
if ((int) t->days != -99999) {
@@ -4301,7 +4301,7 @@ PHP_FUNCTION(date_interval_format)
}
/* }}} */
-static int date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, long *recurrences, /*const*/ char *format, int format_length TSRMLS_DC) /* {{{ */
+static int date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, zend_long *recurrences, /*const*/ char *format, int format_length TSRMLS_DC) /* {{{ */
{
timelib_time *b = NULL, *e = NULL;
timelib_rel_time *p = NULL;
@@ -4334,7 +4334,7 @@ PHP_METHOD(DatePeriod, __construct)
php_date_obj *dateobj;
php_interval_obj *intobj;
zval *start, *end = NULL, *interval;
- long recurrences = 0, options = 0;
+ zend_long recurrences = 0, options = 0;
char *isostr = NULL;
int isostr_len = 0;
timelib_time *clone;
@@ -4413,7 +4413,7 @@ PHP_METHOD(DatePeriod, __construct)
}
/* }}} */
-static int check_id_allowed(char *id, long what) /* {{{ */
+static int check_id_allowed(char *id, zend_long what) /* {{{ */
{
if (what & PHP_DATE_TIMEZONE_GROUP_AFRICA && strncasecmp(id, "Africa/", 7) == 0) return 1;
if (what & PHP_DATE_TIMEZONE_GROUP_AMERICA && strncasecmp(id, "America/", 8) == 0) return 1;
@@ -4437,7 +4437,7 @@ PHP_FUNCTION(timezone_identifiers_list)
const timelib_tzdb *tzdb;
const timelib_tzdb_index_entry *table;
int i, item_count;
- long what = PHP_DATE_TIMEZONE_GROUP_ALL;
+ zend_long what = PHP_DATE_TIMEZONE_GROUP_ALL;
char *option = NULL;
int option_len = 0;
@@ -4558,7 +4558,7 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_su
double latitude = 0.0, longitude = 0.0, zenith = 0.0, gmt_offset = 0, altitude;
double h_rise, h_set, N;
timelib_sll rise, set, transit;
- long time, retformat = 0;
+ zend_long time, retformat = 0;
int rs;
timelib_time *t;
timelib_tzinfo *tzi;
@@ -4657,7 +4657,7 @@ PHP_FUNCTION(date_sunset)
Returns an array with information about sun set/rise and twilight begin/end */
PHP_FUNCTION(date_sun_info)
{
- long time;
+ zend_long time;
double latitude, longitude;
timelib_time *t, *t2;
timelib_tzinfo *tzi;
diff --git a/ext/date/php_date.h b/ext/date/php_date.h
index ff26c0fba3..1d4ea16a2d 100644
--- a/ext/date/php_date.h
+++ b/ext/date/php_date.h
@@ -203,7 +203,7 @@ ZEND_END_MODULE_GLOBALS(date)
#endif
/* Backwards compatibility wrapper */
-PHPAPI signed long php_parse_date(char *string, signed long *now);
+PHPAPI zend_long php_parse_date(char *string, zend_long *now);
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
PHPAPI int php_idate(char format, time_t ts, int localtime TSRMLS_DC);
#if HAVE_STRFTIME
diff --git a/ext/date/tests/bug66985.phpt b/ext/date/tests/bug66985.phpt
new file mode 100644
index 0000000000..0045ca29d6
--- /dev/null
+++ b/ext/date/tests/bug66985.phpt
@@ -0,0 +1,175 @@
+--TEST--
+Bug #66986 (Some timezones are no longer valid in PHP 5.5.10)
+--FILE--
+<?php
+$zones = array(
+ "CST6CDT", "Cuba", "Egypt", "Eire", "EST5EDT", "Factory", "GB-Eire",
+ "GMT0", "Greenwich", "Hongkong", "Iceland", "Iran", "Israel", "Jamaica",
+ "Japan", "Kwajalein", "Libya", "MST7MDT", "Navajo", "NZ-CHAT", "Poland",
+ "Portugal", "PST8PDT", "Singapore", "Turkey", "Universal", "W-SU",
+
+ "UTC", "GMT", "GMT+0100", "-0230",
+);
+
+foreach ( $zones as $zone )
+{
+ $d = new DateTimeZone( $zone );
+ print_r($d);
+}
+?>
+--EXPECT--
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => CST6CDT
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Cuba
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Egypt
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Eire
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => EST5EDT
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Factory
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => GB-Eire
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => GMT0
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Greenwich
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Hongkong
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Iceland
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Iran
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Israel
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Jamaica
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Japan
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Kwajalein
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Libya
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => MST7MDT
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Navajo
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => NZ-CHAT
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Poland
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Portugal
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => PST8PDT
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Singapore
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Turkey
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => Universal
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => W-SU
+)
+DateTimeZone Object
+(
+ [timezone_type] => 3
+ [timezone] => UTC
+)
+DateTimeZone Object
+(
+ [timezone_type] => 2
+ [timezone] => GMT
+)
+DateTimeZone Object
+(
+ [timezone_type] => 1
+ [timezone] => +01:00
+)
+DateTimeZone Object
+(
+ [timezone_type] => 1
+ [timezone] => -02:30
+)
diff --git a/ext/date/tests/bug67109.phpt b/ext/date/tests/bug67109.phpt
new file mode 100644
index 0000000000..a36bb98bb0
--- /dev/null
+++ b/ext/date/tests/bug67109.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #67109 (First uppercase letter breaks date string parsing)
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+var_dump(date('d.m.Y',strtotime('last day of april')));
+var_dump(date('d.m.Y',strtotime('Last day of april')));
+var_dump(date('d.m.Y',strtotime('lAst Day of April')));
+?>
+--EXPECTF--
+string(10) "30.04.%d"
+string(10) "30.04.%d"
+string(10) "30.04.%d"
diff --git a/ext/dba/dba.c b/ext/dba/dba.c
index 7b675ac6ac..68751ed6d0 100644
--- a/ext/dba/dba.c
+++ b/ext/dba/dba.c
@@ -256,7 +256,7 @@ static size_t php_dba_make_key(zval *key, char **key_str, char **key_free TSRMLS
zval *key; \
char *key_str, *key_free; \
size_t key_len; \
- long skip = 0; \
+ zend_long skip = 0; \
switch(ac) { \
case 2: \
if (zend_parse_parameters(ac TSRMLS_CC, "zr", &key, &id) == FAILURE) { \
@@ -1243,7 +1243,7 @@ PHP_FUNCTION(dba_handlers)
List opened databases */
PHP_FUNCTION(dba_list)
{
- ulong numitems, i;
+ zend_ulong numitems, i;
zend_resource *le;
dba_info *info;
diff --git a/ext/dba/dba_db1.c b/ext/dba/dba_db1.c
index 8ee5d95f22..66a6a57c60 100644
--- a/ext/dba/dba_db1.c
+++ b/ext/dba/dba_db1.c
@@ -51,7 +51,7 @@ DBA_OPEN_FUNC(db1)
int filemode = 0644;
if (info->argc > 0) {
- convert_to_long_ex(&info->argv[0]);
+ convert_to_int_ex(&info->argv[0]);
filemode = Z_LVAL(info->argv[0]);
}
diff --git a/ext/dba/dba_db2.c b/ext/dba/dba_db2.c
index 60aa37f93a..518e5c2093 100644
--- a/ext/dba/dba_db2.c
+++ b/ext/dba/dba_db2.c
@@ -72,7 +72,7 @@ DBA_OPEN_FUNC(db2)
}
if (info->argc > 0) {
- convert_to_long_ex(&info->argv[0]);
+ convert_to_int_ex(&info->argv[0]);
filemode = Z_LVAL(info->argv[0]);
}
diff --git a/ext/dba/dba_db3.c b/ext/dba/dba_db3.c
index 95a1e51fe0..599a15ad97 100644
--- a/ext/dba/dba_db3.c
+++ b/ext/dba/dba_db3.c
@@ -81,7 +81,7 @@ DBA_OPEN_FUNC(db3)
}
if (info->argc > 0) {
- convert_to_long_ex(&info->argv[0]);
+ convert_to_int_ex(&info->argv[0]);
filemode = Z_LVAL(info->argv[0]);
}
diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c
index 94a6c95e81..4fab0b92ce 100644
--- a/ext/dba/dba_db4.c
+++ b/ext/dba/dba_db4.c
@@ -118,7 +118,7 @@ DBA_OPEN_FUNC(db4)
}
if (info->argc > 0) {
- convert_to_long_ex(&info->argv[0]);
+ convert_to_int_ex(&info->argv[0]);
filemode = Z_LVAL(info->argv[0]);
}
diff --git a/ext/dba/dba_dbm.c b/ext/dba/dba_dbm.c
index f65a79bcc7..1d07998d62 100644
--- a/ext/dba/dba_dbm.c
+++ b/ext/dba/dba_dbm.c
@@ -60,7 +60,7 @@ DBA_OPEN_FUNC(dbm)
int filemode = 0644;
if(info->argc > 0) {
- convert_to_long_ex(&info->argv[0]);
+ convert_to_int_ex(&info->argv[0]);
filemode = Z_LVAL(info->argv[0]);
}
diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c
index d2c4a2f367..362eddd879 100644
--- a/ext/dba/dba_gdbm.c
+++ b/ext/dba/dba_gdbm.c
@@ -54,7 +54,7 @@ DBA_OPEN_FUNC(gdbm)
return FAILURE; /* not possible */
if(info->argc > 0) {
- convert_to_long_ex(&info->argv[0]);
+ convert_to_int_ex(&info->argv[0]);
filemode = Z_LVAL(info->argv[0]);
}
diff --git a/ext/dba/dba_ndbm.c b/ext/dba/dba_ndbm.c
index 417446759c..d2524ada48 100644
--- a/ext/dba/dba_ndbm.c
+++ b/ext/dba/dba_ndbm.c
@@ -59,7 +59,7 @@ DBA_OPEN_FUNC(ndbm)
}
if(info->argc > 0) {
- convert_to_long_ex(&info->argv[0]);
+ convert_to_int_ex(&info->argv[0]);
filemode = Z_LVAL(info->argv[0]);
}
diff --git a/ext/dom/attr.c b/ext/dom/attr.c
index b0489ef122..4cd4414691 100644
--- a/ext/dom/attr.c
+++ b/ext/dom/attr.c
@@ -175,7 +175,7 @@ int dom_attr_value_write(dom_object *obj, zval *newval TSRMLS_DC)
xmlNodeSetContentLen((xmlNodePtr) attrp, str->val, str->len + 1);
- STR_RELEASE(str);
+ zend_string_release(str);
return SUCCESS;
}
diff --git a/ext/dom/characterdata.c b/ext/dom/characterdata.c
index 2ef6352f20..ccae33ab74 100644
--- a/ext/dom/characterdata.c
+++ b/ext/dom/characterdata.c
@@ -110,7 +110,7 @@ int dom_characterdata_data_write(dom_object *obj, zval *newval TSRMLS_DC)
xmlNodeSetContentLen(nodep, str->val, str->len + 1);
- STR_RELEASE(str);
+ zend_string_release(str);
return SUCCESS;
}
@@ -156,7 +156,7 @@ PHP_FUNCTION(dom_characterdata_substring_data)
xmlChar *cur;
xmlChar *substring;
xmlNodePtr node;
- long offset, count;
+ zend_long offset, count;
int length;
dom_object *intern;
@@ -239,7 +239,7 @@ PHP_FUNCTION(dom_characterdata_insert_data)
xmlChar *cur, *first, *second;
xmlNodePtr node;
char *arg;
- long offset;
+ zend_long offset;
int length, arg_len;
dom_object *intern;
@@ -286,7 +286,7 @@ PHP_FUNCTION(dom_characterdata_delete_data)
zval *id;
xmlChar *cur, *substring, *second;
xmlNodePtr node;
- long offset, count;
+ zend_long offset, count;
int length;
dom_object *intern;
@@ -342,7 +342,7 @@ PHP_FUNCTION(dom_characterdata_replace_data)
xmlChar *cur, *substring, *second = NULL;
xmlNodePtr node;
char *arg;
- long offset, count;
+ zend_long offset, count;
int length, arg_len;
dom_object *intern;
diff --git a/ext/dom/document.c b/ext/dom/document.c
index b2c3274063..944d55c20b 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -352,7 +352,7 @@ int dom_document_encoding_write(dom_object *obj, zval *newval TSRMLS_DC)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Document Encoding");
}
- STR_RELEASE(str);
+ zend_string_release(str);
return SUCCESS;
}
@@ -440,7 +440,7 @@ int dom_document_version_write(dom_object *obj, zval *newval TSRMLS_DC)
docp->version = xmlStrdup((const xmlChar *) str->val);
- STR_RELEASE(str);
+ zend_string_release(str);
return SUCCESS;
}
@@ -668,7 +668,7 @@ int dom_document_document_uri_write(dom_object *obj, zval *newval TSRMLS_DC)
docp->URL = xmlStrdup((const xmlChar *) str->val);
- STR_RELEASE(str);
+ zend_string_release(str);
return SUCCESS;
}
@@ -970,7 +970,7 @@ PHP_FUNCTION(dom_document_import_node)
xmlNodePtr nodep, retnodep;
dom_object *intern, *nodeobj;
int ret;
- long recursive = 0;
+ zend_long recursive = 0;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO|l", &id, dom_document_class_entry, &node, dom_node_class_entry, &recursive) == FAILURE) {
return;
@@ -1465,7 +1465,7 @@ static void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode) {
dom_object *intern;
char *source;
int source_len, refcount, ret;
- long options = 0;
+ zend_long options = 0;
id = getThis();
if (id != NULL && ! instanceof_function(Z_OBJCE_P(id), dom_document_class_entry TSRMLS_CC)) {
@@ -1547,7 +1547,7 @@ PHP_FUNCTION(dom_document_save)
dom_object *intern;
dom_doc_propsptr doc_props;
char *file;
- long options = 0;
+ zend_long options = 0;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &id, dom_document_class_entry, &file, &file_len, &options) == FAILURE) {
return;
@@ -1593,7 +1593,7 @@ PHP_FUNCTION(dom_document_savexml)
dom_object *intern, *nodeobj;
dom_doc_propsptr doc_props;
int size, format, saveempty = 0;
- long options = 0;
+ zend_long options = 0;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|O!l", &id, dom_document_class_entry, &nodep, dom_node_class_entry, &options) == FAILURE) {
return;
@@ -1698,7 +1698,7 @@ PHP_FUNCTION(dom_document_xinclude)
zval *id;
xmlDoc *docp;
xmlNodePtr root;
- long flags = 0;
+ zend_long flags = 0;
int err;
dom_object *intern;
@@ -1772,7 +1772,7 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type
dom_object *intern;
char *source = NULL, *valid_file = NULL;
int source_len = 0, valid_opts = 0;
- long flags = 0;
+ zend_long flags = 0;
xmlSchemaParserCtxtPtr parser;
xmlSchemaPtr sptr;
xmlSchemaValidCtxtPtr vptr;
@@ -1963,7 +1963,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
dom_doc_propsptr doc_prop;
char *source;
int source_len, refcount, ret;
- long options = 0;
+ zend_long options = 0;
htmlParserCtxtPtr ctxt;
id = getThis();
diff --git a/ext/dom/namednodemap.c b/ext/dom/namednodemap.c
index 13acf5cbce..bae0b28ec2 100644
--- a/ext/dom/namednodemap.c
+++ b/ext/dom/namednodemap.c
@@ -200,7 +200,7 @@ Since:
PHP_FUNCTION(dom_namednodemap_item)
{
zval *id;
- long index;
+ zend_long index;
int ret;
dom_object *intern;
xmlNodePtr itemnode = NULL;
diff --git a/ext/dom/node.c b/ext/dom/node.c
index a35139bcad..32880ee7d9 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -345,7 +345,7 @@ int dom_node_node_value_write(dom_object *obj, zval *newval TSRMLS_DC)
{
zend_string *str = zval_get_string(newval);
xmlNodeSetContentLen(nodep, str->val, str->len + 1);
- STR_RELEASE(str);
+ zend_string_release(str);
break;
}
default:
@@ -745,14 +745,14 @@ int dom_node_prefix_write(dom_object *obj, zval *newval TSRMLS_DC)
}
if (ns == NULL) {
- STR_RELEASE(str);
+ zend_string_release(str);
php_dom_throw_error(NAMESPACE_ERR, dom_get_strict_error(obj->document) TSRMLS_CC);
return FAILURE;
}
xmlSetNs(nodep, ns);
}
- STR_RELEASE(str);
+ zend_string_release(str);
break;
default:
break;
@@ -1334,7 +1334,7 @@ PHP_FUNCTION(dom_node_clone_node)
xmlNode *n, *node;
int ret;
dom_object *intern;
- long recursive = 0;
+ zend_long recursive = 0;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &id, dom_node_class_entry, &recursive) == FAILURE) {
return;
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 8314e5c808..7f1c19bd0e 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -321,7 +321,7 @@ static zval *dom_get_property_ptr_ptr(zval *object, zval *member, int type, void
retval = std_hnd->get_property_ptr_ptr(object, member, type, cache_slot TSRMLS_CC);
}
- STR_RELEASE(member_str);
+ zend_string_release(member_str);
return retval;
}
/* }}} */
@@ -352,7 +352,7 @@ zval *dom_read_property(zval *object, zval *member, int type, void **cache_slot,
retval = std_hnd->read_property(object, member, type, cache_slot, rv TSRMLS_CC);
}
- STR_RELEASE(member_str);
+ zend_string_release(member_str);
return retval;
}
/* }}} */
@@ -374,7 +374,7 @@ void dom_write_property(zval *object, zval *member, zval *value, void **cache_sl
std_hnd->write_property(object, member, value, cache_slot TSRMLS_CC);
}
- STR_RELEASE(member_str);
+ zend_string_release(member_str);
}
/* }}} */
@@ -407,7 +407,7 @@ static int dom_property_exists(zval *object, zval *member, int check_empty, void
retval = std_hnd->has_property(object, member, check_empty, cache_slot TSRMLS_CC);
}
- STR_RELEASE(member_str);
+ zend_string_release(member_str);
return retval;
}
/* }}} */
@@ -440,7 +440,7 @@ static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp TSRMLS_DC
zend_hash_move_forward_ex(prop_handlers, &pos)) {
zval value;
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
if (entry->read_func(obj, &value TSRMLS_CC) == FAILURE) {
continue;
diff --git a/ext/dom/processinginstruction.c b/ext/dom/processinginstruction.c
index 36b159cc6e..c46b1bf244 100644
--- a/ext/dom/processinginstruction.c
+++ b/ext/dom/processinginstruction.c
@@ -149,7 +149,7 @@ int dom_processinginstruction_data_write(dom_object *obj, zval *newval TSRMLS_DC
xmlNodeSetContentLen(nodep, str->val, str->len + 1);
- STR_RELEASE(str);
+ zend_string_release(str);
return SUCCESS;
}
diff --git a/ext/dom/text.c b/ext/dom/text.c
index cccc44b311..9940dbf8d0 100644
--- a/ext/dom/text.c
+++ b/ext/dom/text.c
@@ -149,7 +149,7 @@ PHP_FUNCTION(dom_text_split_text)
xmlChar *second;
xmlNodePtr node;
xmlNodePtr nnode;
- long offset;
+ zend_long offset;
int length;
dom_object *intern;
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c
index 93a38614ce..549411d768 100644
--- a/ext/dom/xpath.c
+++ b/ext/dom/xpath.c
@@ -223,12 +223,12 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
} else {
zend_string *str = zval_get_string(&retval);
valuePush(ctxt, xmlXPathNewString(str->val));
- STR_RELEASE(str);
+ zend_string_release(str);
}
zval_ptr_dtor(&retval);
}
}
- STR_RELEASE(callable);
+ zend_string_release(callable);
zval_dtor(&fci.function_name);
if (fci.param_count > 0) {
for (i = 0; i < nargs - 1; i++) {
@@ -527,7 +527,7 @@ PHP_FUNCTION(dom_xpath_register_php_functions)
ZVAL_LONG(&new_string,1);
zend_hash_update(intern->registered_phpfunctions, str, &new_string);
zend_hash_move_forward(Z_ARRVAL_P(array_value));
- STR_RELEASE(str);
+ zend_string_release(str);
}
intern->registerPhpFunctions = 2;
RETURN_TRUE;
diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c
index e1449560f5..28b8d1a15b 100644
--- a/ext/enchant/enchant.c
+++ b/ext/enchant/enchant.c
@@ -422,7 +422,7 @@ PHP_FUNCTION(enchant_broker_set_dict_path)
{
zval *broker;
enchant_broker *pbroker;
- long dict_type;
+ zend_long dict_type;
char *value;
int value_len;
@@ -462,7 +462,7 @@ PHP_FUNCTION(enchant_broker_get_dict_path)
{
zval *broker;
enchant_broker *pbroker;
- long dict_type;
+ zend_long dict_type;
char *value;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &broker, &dict_type) == FAILURE) {
diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c
index 79bee9b79f..ca00b7a175 100644
--- a/ext/ereg/ereg.c
+++ b/ext/ereg/ereg.c
@@ -323,7 +323,7 @@ static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
} else {
/* we convert numbers to integers and treat them as a string */
if (Z_TYPE_P(regex) == IS_DOUBLE) {
- convert_to_long_ex(regex); /* get rid of decimal places */
+ convert_to_int_ex(regex); /* get rid of decimal places */
}
convert_to_string_ex(regex);
/* don't bother doing an extended regex with just a number */
@@ -565,32 +565,32 @@ static void php_do_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
if (Z_TYPE_P(arg_pattern) == IS_STRING) {
if (Z_STRVAL_P(arg_pattern) && Z_STRLEN_P(arg_pattern)) {
- pattern = STR_COPY(Z_STR_P(arg_pattern));
+ pattern = zend_string_copy(Z_STR_P(arg_pattern));
} else {
pattern = STR_EMPTY_ALLOC();
}
} else {
- convert_to_long_ex(arg_pattern);
- pattern = STR_ALLOC(1, 0);
+ convert_to_int_ex(arg_pattern);
+ pattern = zend_string_alloc(1, 0);
pattern->val[0] = (char) Z_LVAL_P(arg_pattern);
pattern->val[1] = '\0';
}
if (Z_TYPE_P(arg_replace) == IS_STRING) {
if (Z_STRVAL_P(arg_replace) && Z_STRLEN_P(arg_replace)) {
- replace = STR_COPY(Z_STR_P(arg_replace));
+ replace = zend_string_copy(Z_STR_P(arg_replace));
} else {
replace = STR_EMPTY_ALLOC();
}
} else {
- convert_to_long_ex(arg_replace);
- replace = STR_ALLOC(1, 0);
+ convert_to_int_ex(arg_replace);
+ replace = zend_string_alloc(1, 0);
replace->val[0] = (char) Z_LVAL_P(arg_replace);
replace->val[1] = '\0';
}
if (arg_string) {
- string = STR_COPY(arg_string);
+ string = zend_string_copy(arg_string);
} else {
string = STR_EMPTY_ALLOC();
}
@@ -604,9 +604,9 @@ static void php_do_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
efree(ret);
}
- STR_RELEASE(string);
- STR_RELEASE(replace);
- STR_RELEASE(pattern);
+ zend_string_release(string);
+ zend_string_release(replace);
+ zend_string_release(pattern);
}
/* }}} */
@@ -630,7 +630,7 @@ PHP_FUNCTION(eregi_replace)
*/
static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
{
- long count = -1;
+ zend_long count = -1;
regex_t re;
regmatch_t subs[1];
char *spliton, *str, *strp, *endp;
diff --git a/ext/exif/exif.c b/ext/exif/exif.c
index 127cb30941..6438623525 100644
--- a/ext/exif/exif.c
+++ b/ext/exif/exif.c
@@ -2334,7 +2334,7 @@ static char * exif_get_markername(int marker)
Get headername for index or false if not defined */
PHP_FUNCTION(exif_tagname)
{
- long tag;
+ zend_long tag;
char *szTemp;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &tag) == FAILURE) {
@@ -3847,7 +3847,7 @@ static int exif_discard_imageinfo(image_info_type *ImageInfo)
static int exif_read_file(image_info_type *ImageInfo, char *FileName, int read_thumbnail, int read_all TSRMLS_DC)
{
int ret;
- struct stat st;
+ zend_stat_t st;
zend_string *base;
/* Start with an empty image information structure. */
@@ -3884,7 +3884,7 @@ static int exif_read_file(image_info_type *ImageInfo, char *FileName, int read_t
base = php_basename(FileName, strlen(FileName), NULL, 0 TSRMLS_CC);
ImageInfo->FileName = estrndup(base->val, base->len);
- STR_RELEASE(base);
+ zend_string_release(base);
ImageInfo->read_thumbnail = read_thumbnail;
ImageInfo->read_all = read_all;
ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_UNKNOWN;
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
index a612e04280..db309de181 100644
--- a/ext/fileinfo/fileinfo.c
+++ b/ext/fileinfo/fileinfo.c
@@ -44,7 +44,7 @@
/* {{{ macros and type definitions */
typedef struct _php_fileinfo {
- long options;
+ zend_long options;
struct magic_set *magic;
} php_fileinfo;
@@ -176,7 +176,7 @@ zend_function_entry finfo_class_functions[] = {
#define FINFO_SET_OPTION(magic, options) \
if (magic_setflags(magic, options) == -1) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to set option '%ld' %d:%s", \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to set option '%pd' %d:%s", \
options, magic_errno(magic), magic_error(magic)); \
RETURN_FALSE; \
}
@@ -295,7 +295,7 @@ PHP_MINFO_FUNCTION(fileinfo)
Create a new fileinfo resource. */
PHP_FUNCTION(finfo_open)
{
- long options = MAGIC_NONE;
+ zend_long options = MAGIC_NONE;
char *file = NULL;
int file_len = 0;
php_fileinfo *finfo;
@@ -339,7 +339,7 @@ PHP_FUNCTION(finfo_open)
if (finfo->magic == NULL) {
efree(finfo);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid mode '%ld'.", options);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid mode '%pd'.", options);
FILEINFO_DESTROY_OBJECT(object);
RETURN_FALSE;
}
@@ -382,7 +382,7 @@ PHP_FUNCTION(finfo_close)
Set libmagic configuration options. */
PHP_FUNCTION(finfo_set_flags)
{
- long options;
+ zend_long options;
php_fileinfo *finfo;
zval *zfinfo;
FILEINFO_DECLARE_INIT_OBJECT(object)
@@ -412,7 +412,7 @@ PHP_FUNCTION(finfo_set_flags)
static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mimetype_emu) /* {{{ */
{
- long options = 0;
+ zend_long options = 0;
char *ret_val = NULL, *buffer = NULL;
int buffer_len;
php_fileinfo *finfo = NULL;
@@ -480,7 +480,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
case FILEINFO_MODE_STREAM:
{
php_stream *stream;
- off_t streampos;
+ zend_off_t streampos;
php_stream_from_zval_no_verify(stream, what);
if (!stream) {
diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c
index ce747378aa..41a3ac5239 100644
--- a/ext/fileinfo/libmagic/apprentice.c
+++ b/ext/fileinfo/libmagic/apprentice.c
@@ -1145,7 +1145,7 @@ apprentice_load(struct magic_set *ms, const char *fn, int action)
uint32_t i, j;
size_t files = 0, maxfiles = 0;
char **filearr = NULL;
- struct stat st;
+ zend_stat_t st;
struct magic_map *map;
struct magic_entry_set mset[MAGIC_SETS];
php_stream *dir;
@@ -1187,7 +1187,7 @@ apprentice_load(struct magic_set *ms, const char *fn, int action)
php_stream_closedir(dir);
goto out;
}
- if (stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) {
+ if (zend_stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) {
continue;
}
if (files >= maxfiles) {
@@ -2698,7 +2698,7 @@ internal_loaded:
if (NULL != fn) {
nentries = (uint32_t)(st.sb.st_size / sizeof(struct magic));
entries = (uint32_t)(st.sb.st_size / sizeof(struct magic));
- if ((off_t)(entries * sizeof(struct magic)) != st.sb.st_size) {
+ if ((zend_off_t)(entries * sizeof(struct magic)) != st.sb.st_size) {
file_error(ms, 0, "Size of `%s' %llu is not a multiple of %zu",
dbname, (unsigned long long)st.sb.st_size,
sizeof(struct magic));
@@ -2788,7 +2788,7 @@ apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn)
assert(nm + sizeof(ar) < m);
- if (php_stream_seek(stream,(off_t)sizeof(struct magic), SEEK_SET) != sizeof(struct magic)) {
+ if (php_stream_seek(stream,(zend_off_t)sizeof(struct magic), SEEK_SET) != sizeof(struct magic)) {
file_error(ms, errno, "error seeking `%s'", dbname);
goto out;
}
diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c
index c86763faa0..45ad6e3e57 100644
--- a/ext/fileinfo/libmagic/cdf.c
+++ b/ext/fileinfo/libmagic/cdf.c
@@ -291,11 +291,11 @@ cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
}
static ssize_t
-cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)
+cdf_read(const cdf_info_t *info, zend_off_t off, void *buf, size_t len)
{
size_t siz = (size_t)off + len;
- if ((off_t)(off + len) != (off_t)siz) {
+ if ((zend_off_t)(off + len) != (zend_off_t)siz) {
errno = EINVAL;
return -1;
}
@@ -308,7 +308,7 @@ cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)
if (info->i_fd == -1)
return -1;
- if (FINFO_LSEEK_FUNC(info->i_fd, off, SEEK_SET) == (off_t)-1)
+ if (FINFO_LSEEK_FUNC(info->i_fd, off, SEEK_SET) == (zend_off_t)-1)
return -1;
if (FINFO_READ_FUNC(info->i_fd, buf, len) != (ssize_t)len)
@@ -323,7 +323,7 @@ cdf_read_header(const cdf_info_t *info, cdf_header_t *h)
char buf[512];
(void)memcpy(cdf_bo.s, "\01\02\03\04", 4);
- if (cdf_read(info, (off_t)0, buf, sizeof(buf)) == -1)
+ if (cdf_read(info, (zend_off_t)0, buf, sizeof(buf)) == -1)
return -1;
cdf_unpack_header(h, buf);
cdf_swap_header(h);
@@ -357,7 +357,7 @@ cdf_read_sector(const cdf_info_t *info, void *buf, size_t offs, size_t len,
size_t ss = CDF_SEC_SIZE(h);
size_t pos = CDF_SEC_POS(h, id);
assert(ss == len);
- return cdf_read(info, (off_t)pos, ((char *)buf) + offs, len);
+ return cdf_read(info, (zend_off_t)pos, ((char *)buf) + offs, len);
}
ssize_t
diff --git a/ext/fileinfo/libmagic/compress.c b/ext/fileinfo/libmagic/compress.c
index fed7420a6a..0da5a3e6ce 100644
--- a/ext/fileinfo/libmagic/compress.c
+++ b/ext/fileinfo/libmagic/compress.c
@@ -300,7 +300,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
return -1;
}
(void)close(tfd);
- if (FINFO_LSEEK_FUNC(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
+ if (FINFO_LSEEK_FUNC(fd, (zend_off_t)0, SEEK_SET) == (zend_off_t)-1) {
file_badseek(ms);
return -1;
}
@@ -406,7 +406,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
(void) close(0);
if (fd != -1) {
(void) dup(fd);
- (void) FINFO_LSEEK_FUNC(0, (off_t)0, SEEK_SET);
+ (void) FINFO_LSEEK_FUNC(0, (zend_off_t)0, SEEK_SET);
} else {
(void) dup(fdin[0]);
(void) close(fdin[0]);
diff --git a/ext/fileinfo/libmagic/elfclass.h b/ext/fileinfo/libmagic/elfclass.h
index 010958a429..bfacceb88a 100644
--- a/ext/fileinfo/libmagic/elfclass.h
+++ b/ext/fileinfo/libmagic/elfclass.h
@@ -37,7 +37,7 @@
case ET_CORE:
flags |= FLAGS_IS_CORE;
if (dophn_core(ms, clazz, swap, fd,
- (off_t)elf_getu(swap, elfhdr.e_phoff),
+ (zend_off_t)elf_getu(swap, elfhdr.e_phoff),
elf_getu16(swap, elfhdr.e_phnum),
(size_t)elf_getu16(swap, elfhdr.e_phentsize),
fsize, &flags) == -1)
@@ -47,7 +47,7 @@
case ET_EXEC:
case ET_DYN:
if (dophn_exec(ms, clazz, swap, fd,
- (off_t)elf_getu(swap, elfhdr.e_phoff),
+ (zend_off_t)elf_getu(swap, elfhdr.e_phoff),
elf_getu16(swap, elfhdr.e_phnum),
(size_t)elf_getu16(swap, elfhdr.e_phentsize),
fsize, &flags, elf_getu16(swap, elfhdr.e_shnum))
@@ -56,7 +56,7 @@
/*FALLTHROUGH*/
case ET_REL:
if (doshn(ms, clazz, swap, fd,
- (off_t)elf_getu(swap, elfhdr.e_shoff),
+ (zend_off_t)elf_getu(swap, elfhdr.e_shoff),
elf_getu16(swap, elfhdr.e_shnum),
(size_t)elf_getu16(swap, elfhdr.e_shentsize),
fsize, &flags, elf_getu16(swap, elfhdr.e_machine),
diff --git a/ext/fileinfo/libmagic/fsmagic.c b/ext/fileinfo/libmagic/fsmagic.c
index 2010b26339..a7b420ff5d 100644
--- a/ext/fileinfo/libmagic/fsmagic.c
+++ b/ext/fileinfo/libmagic/fsmagic.c
@@ -90,7 +90,7 @@ handle_mime(struct magic_set *ms, int mime, const char *str)
}
protected int
-file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *stream)
+file_fsmagic(struct magic_set *ms, const char *fn, zend_stat_t *sb, php_stream *stream)
{
int ret, did = 0;
int mime = ms->flags & MAGIC_MIME;
diff --git a/ext/fileinfo/libmagic/funcs.c b/ext/fileinfo/libmagic/funcs.c
index 3c9d387470..4dd3d1c51f 100644
--- a/ext/fileinfo/libmagic/funcs.c
+++ b/ext/fileinfo/libmagic/funcs.c
@@ -471,7 +471,7 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep)
strncpy(ms->o.buf, res->val, res->len);
ms->o.buf[res->len] = '\0';
- STR_RELEASE(res);
+ zend_string_release(res);
out:
(void)setlocale(LC_CTYPE, "");
diff --git a/ext/fileinfo/libmagic/readelf.c b/ext/fileinfo/libmagic/readelf.c
index 6f776721b0..3b0aae54c1 100644
--- a/ext/fileinfo/libmagic/readelf.c
+++ b/ext/fileinfo/libmagic/readelf.c
@@ -42,13 +42,13 @@ FILE_RCSID("@(#)$File: readelf.c,v 1.99 2013/11/05 15:44:01 christos Exp $")
#include "magic.h"
#ifdef ELFCORE
-private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t,
- off_t, int *);
+private int dophn_core(struct magic_set *, int, int, int, zend_off_t, int, size_t,
+ zend_off_t, int *);
#endif
private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t,
- off_t, int *, int);
+ zend_off_t, int *, int);
private int doshn(struct magic_set *, int, int, int, off_t, int, size_t,
- off_t, int *, int);
+ zend_off_t, int *, int);
private size_t donote(struct magic_set *, unsigned char *, size_t, size_t, int,
int, size_t, int *);
@@ -144,7 +144,7 @@ getu64(int swap, uint64_t value)
#define xsh_size (size_t)(clazz == ELFCLASS32 \
? elf_getu32(swap, sh32.sh_size) \
: elf_getu64(swap, sh64.sh_size))
-#define xsh_offset (off_t)(clazz == ELFCLASS32 \
+#define xsh_offset (zend_off_t)(clazz == ELFCLASS32 \
? elf_getu32(swap, sh32.sh_offset) \
: elf_getu64(swap, sh64.sh_offset))
#define xsh_type (clazz == ELFCLASS32 \
@@ -162,13 +162,13 @@ getu64(int swap, uint64_t value)
#define xph_type (clazz == ELFCLASS32 \
? elf_getu32(swap, ph32.p_type) \
: elf_getu32(swap, ph64.p_type))
-#define xph_offset (off_t)(clazz == ELFCLASS32 \
+#define xph_offset (zend_off_t)(clazz == ELFCLASS32 \
? elf_getu32(swap, ph32.p_offset) \
: elf_getu64(swap, ph64.p_offset))
#define xph_align (size_t)((clazz == ELFCLASS32 \
- ? (off_t) (ph32.p_align ? \
+ ? (zend_off_t) (ph32.p_align ? \
elf_getu32(swap, ph32.p_align) : 4) \
- : (off_t) (ph64.p_align ? \
+ : (zend_off_t) (ph64.p_align ? \
elf_getu64(swap, ph64.p_align) : 4)))
#define xph_filesz (size_t)((clazz == ELFCLASS32 \
? elf_getu32(swap, ph32.p_filesz) \
@@ -293,8 +293,8 @@ private const char os_style_names[][8] = {
#define FLAGS_IS_CORE 0x10
private int
-dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
- int num, size_t size, off_t fsize, int *flags)
+dophn_core(struct magic_set *ms, int clazz, int swap, int fd, zend_off_t off,
+ int num, size_t size, zend_off_t fsize, int *flags)
{
Elf32_Phdr ph32;
Elf64_Phdr ph64;
@@ -312,7 +312,7 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
* Loop through all the program headers.
*/
for ( ; num; num--) {
- if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) {
file_badseek(ms);
return -1;
}
@@ -334,7 +334,7 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
* This is a PT_NOTE section; loop through all the notes
* in the section.
*/
- if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (off_t)-1) {
+ if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (zend_off_t)-1) {
file_badseek(ms);
return -1;
}
@@ -917,7 +917,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
Elf64_Shdr sh64;
int stripped = 1;
void *nbuf;
- off_t noff, coff, name_off;
+ zend_off_t noff, coff, name_off;
uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilites */
uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilites */
char name[50];
@@ -929,7 +929,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
}
for ( ; num; num--) {
- if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) {
file_badseek(ms);
return -1;
}
@@ -959,8 +959,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
switch (xsh_type) {
case SHT_NOTE:
nbuf = emalloc((size_t)xsh_size);
- if ((noff = FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, SEEK_SET)) ==
- (off_t)-1) {
+ if ((noff = FINFO_LSEEK_FUNC(fd, (zend_off_t)xsh_offset, SEEK_SET)) ==
+ (zend_off_t)-1) {
file_badread(ms);
efree(nbuf);
return -1;
@@ -974,7 +974,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
noff = 0;
for (;;) {
- if (noff >= (off_t)xsh_size)
+ if (noff >= (zend_off_t)xsh_size)
break;
noff = donote(ms, nbuf, (size_t)noff,
(size_t)xsh_size, clazz, swap, 4,
@@ -985,8 +985,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
efree(nbuf);
break;
case SHT_SUNW_cap:
- if (FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, SEEK_SET) ==
- (off_t)-1) {
+ if (FINFO_LSEEK_FUNC(fd, (zend_off_t)xsh_offset, SEEK_SET) ==
+ (zend_off_t)-1) {
file_badseek(ms);
return -1;
}
@@ -996,7 +996,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
Elf64_Cap cap64;
char cbuf[/*CONSTCOND*/
MAX(sizeof cap32, sizeof cap64)];
- if ((coff += xcap_sizeof) > (off_t)xsh_size)
+ if ((coff += xcap_sizeof) > (zend_off_t)xsh_size)
break;
if (FINFO_READ_FUNC(fd, cbuf, (size_t)xcap_sizeof) !=
(ssize_t)xcap_sizeof) {
@@ -1099,8 +1099,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
* otherwise it's statically linked.
*/
private int
-dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
- int num, size_t size, off_t fsize, int *flags, int sh_num)
+dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, zend_off_t off,
+ int num, size_t size, zend_off_t fsize, int *flags, int sh_num)
{
Elf32_Phdr ph32;
Elf64_Phdr ph64;
@@ -1117,7 +1117,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
}
for ( ; num; num--) {
- if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) {
file_badseek(ms);
return -1;
}
@@ -1161,7 +1161,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
* This is a PT_NOTE section; loop through all the notes
* in the section.
*/
- if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (off_t)-1) {
+ if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (zend_off_t)-1) {
file_badseek(ms);
return -1;
}
@@ -1204,7 +1204,7 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
int clazz;
int swap;
struct stat st;
- off_t fsize;
+ zend_off_t fsize;
int flags = 0;
Elf32_Ehdr elf32hdr;
Elf64_Ehdr elf64hdr;
@@ -1227,7 +1227,7 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
/*
* If we cannot seek, it must be a pipe, socket or fifo.
*/
- if((FINFO_LSEEK_FUNC(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))
+ if((FINFO_LSEEK_FUNC(fd, (zend_off_t)0, SEEK_SET) == (zend_off_t)-1) && (errno == ESPIPE))
fd = file_pipe2file(ms, fd, buf, nbytes);
if (fstat(fd, &st) == -1) {
diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c
index ef0cbb3891..0b323c0ec8 100644
--- a/ext/fileinfo/libmagic/softmagic.c
+++ b/ext/fileinfo/libmagic/softmagic.c
@@ -366,13 +366,13 @@ check_fmt(struct magic_set *ms, struct magic *m)
return 0;
(void)setlocale(LC_CTYPE, "C");
- pattern = STR_INIT("~%[-0-9.]*s~", sizeof("~%[-0-9.]*s~") - 1, 0);
+ pattern = zend_string_init("~%[-0-9.]*s~", sizeof("~%[-0-9.]*s~") - 1, 0);
if ((pce = pcre_get_compiled_regex(pattern, &re_extra, &re_options TSRMLS_CC)) == NULL) {
rv = -1;
} else {
rv = !pcre_exec(pce, re_extra, m->desc, strlen(m->desc), 0, re_options, NULL, 0);
}
- STR_RELEASE(pattern);
+ zend_string_release(pattern);
(void)setlocale(LC_CTYPE, "");
return rv;
}
@@ -1887,7 +1887,7 @@ convert_libmagic_pattern(zval *pattern, char *val, int len, int options)
int i, j=0;
zend_string *t;
- t = STR_ALLOC(len * 2 + 4, 0);
+ t = zend_string_alloc(len * 2 + 4, 0);
t->val[j++] = '~';
@@ -2156,7 +2156,7 @@ magiccheck(struct magic_set *ms, struct magic *m)
continue;
}
ZVAL_DUP(&offsetcopy, offset);
- convert_to_long(&offsetcopy);
+ convert_to_int(&offsetcopy);
pattern_offset = &offsetcopy;
} ZEND_HASH_FOREACH_END();
diff --git a/ext/filter/filter.c b/ext/filter/filter.c
index 6e723638aa..e5e9be249d 100644
--- a/ext/filter/filter.c
+++ b/ext/filter/filter.c
@@ -77,7 +77,7 @@ static const filter_list_entry filter_list[] = {
#define PARSE_SESSION 6
#endif
-static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC);
+static unsigned int php_sapi_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len TSRMLS_DC);
static unsigned int php_sapi_filter_init(TSRMLS_D);
/* {{{ arginfo */
@@ -327,7 +327,7 @@ PHP_MINFO_FUNCTION(filter)
}
/* }}} */
-static filter_list_entry php_find_filter(long id) /* {{{ */
+static filter_list_entry php_find_filter(zend_long id) /* {{{ */
{
int i, size = sizeof(filter_list) / sizeof(filter_list_entry);
@@ -358,7 +358,7 @@ static unsigned int php_sapi_filter_init(TSRMLS_D)
return SUCCESS;
}
-static void php_zval_filter(zval *value, long filter, long flags, zval *options, char* charset, zend_bool copy TSRMLS_DC) /* {{{ */
+static void php_zval_filter(zval *value, zend_long filter, zend_long flags, zval *options, char* charset, zend_bool copy TSRMLS_DC) /* {{{ */
{
filter_list_entry filter_func;
@@ -402,7 +402,7 @@ static void php_zval_filter(zval *value, long filter, long flags, zval *options,
}
/* }}} */
-static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC) /* {{{ */
+static unsigned int php_sapi_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len TSRMLS_DC) /* {{{ */
{
zval new_var, raw_var;
zval *array_ptr = NULL, *orig_array_ptr = NULL;
@@ -481,7 +481,7 @@ static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int
}
/* }}} */
-static void php_zval_filter_recursive(zval *value, long filter, long flags, zval *options, char *charset, zend_bool copy TSRMLS_DC) /* {{{ */
+static void php_zval_filter_recursive(zval *value, zend_long filter, zend_long flags, zval *options, char *charset, zend_bool copy TSRMLS_DC) /* {{{ */
{
if (Z_TYPE_P(value) == IS_ARRAY) {
zval *element;
@@ -506,7 +506,7 @@ static void php_zval_filter_recursive(zval *value, long filter, long flags, zval
}
/* }}} */
-static zval *php_filter_get_storage(long arg TSRMLS_DC)/* {{{ */
+static zval *php_filter_get_storage(zend_long arg TSRMLS_DC)/* {{{ */
{
zval *array_ptr = NULL;
@@ -523,17 +523,17 @@ static zval *php_filter_get_storage(long arg TSRMLS_DC)/* {{{ */
break;
case PARSE_SERVER:
if (PG(auto_globals_jit)) {
- zend_string *name = STR_INIT("_SERVER", sizeof("_SERVER") - 1, 0);
+ zend_string *name = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
zend_is_auto_global(name TSRMLS_CC);
- STR_RELEASE(name);
+ zend_string_release(name);
}
array_ptr = &IF_G(server_array);
break;
case PARSE_ENV:
if (PG(auto_globals_jit)) {
- zend_string *name = STR_INIT("_ENV", sizeof("_ENV") - 1, 0);
+ zend_string *name = zend_string_init("_ENV", sizeof("_ENV") - 1, 0);
zend_is_auto_global(name TSRMLS_CC);
- STR_RELEASE(name);
+ zend_string_release(name);
}
array_ptr = &IF_G(env_array) ? &IF_G(env_array) : &PG(http_globals)[TRACK_VARS_ENV];
break;
@@ -556,7 +556,7 @@ static zval *php_filter_get_storage(long arg TSRMLS_DC)/* {{{ */
*/
PHP_FUNCTION(filter_has_var)
{
- long arg;
+ zend_long arg;
zend_string *var;
zval *array_ptr = NULL;
@@ -574,14 +574,14 @@ PHP_FUNCTION(filter_has_var)
}
/* }}} */
-static void php_filter_call(zval *filtered, long filter, zval *filter_args, const int copy, long filter_flags TSRMLS_DC) /* {{{ */
+static void php_filter_call(zval *filtered, zend_long filter, zval *filter_args, const int copy, zend_long filter_flags TSRMLS_DC) /* {{{ */
{
zval *options = NULL;
zval *option;
char *charset = NULL;
if (filter_args && Z_TYPE_P(filter_args) != IS_ARRAY) {
- long lval;
+ zend_long lval;
PHP_FILTER_GET_LONG_OPT(filter_args, lval);
@@ -661,7 +661,7 @@ static void php_filter_call(zval *filtered, long filter, zval *filter_args, cons
static void php_filter_array_handler(zval *input, zval *op, zval *return_value, zend_bool add_empty TSRMLS_DC) /* {{{ */
{
- ulong index;
+ zend_ulong index;
zend_string *arg_key;
zval *tmp, *arg_elm;
@@ -710,7 +710,7 @@ static void php_filter_array_handler(zval *input, zval *op, zval *return_value,
*/
PHP_FUNCTION(filter_input)
{
- long fetch_from, filter = FILTER_DEFAULT;
+ zend_long fetch_from, filter = FILTER_DEFAULT;
zval *filter_args = NULL, *tmp;
zval *input = NULL;
zend_string *var;
@@ -726,7 +726,7 @@ PHP_FUNCTION(filter_input)
input = php_filter_get_storage(fetch_from TSRMLS_CC);
if (!input || !HASH_OF(input) || (tmp = zend_hash_find(HASH_OF(input), var)) == NULL) {
- long filter_flags = 0;
+ zend_long filter_flags = 0;
zval *option, *opt, *def;
if (filter_args) {
if (Z_TYPE_P(filter_args) == IS_LONG) {
@@ -766,7 +766,7 @@ PHP_FUNCTION(filter_input)
*/
PHP_FUNCTION(filter_var)
{
- long filter = FILTER_DEFAULT;
+ zend_long filter = FILTER_DEFAULT;
zval *filter_args = NULL, *data;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/|lz", &data, &filter, &filter_args) == FAILURE) {
@@ -788,7 +788,7 @@ PHP_FUNCTION(filter_var)
*/
PHP_FUNCTION(filter_input_array)
{
- long fetch_from;
+ zend_long fetch_from;
zval *array_input = NULL, *op = NULL;
zend_bool add_empty = 1;
@@ -803,7 +803,7 @@ PHP_FUNCTION(filter_input_array)
array_input = php_filter_get_storage(fetch_from TSRMLS_CC);
if (!array_input || !HASH_OF(array_input)) {
- long filter_flags = 0;
+ zend_long filter_flags = 0;
zval *option;
if (op) {
if (Z_TYPE_P(op) == IS_LONG) {
diff --git a/ext/filter/filter_private.h b/ext/filter/filter_private.h
index 4eec7b9119..45ab99a824 100644
--- a/ext/filter/filter_private.h
+++ b/ext/filter/filter_private.h
@@ -121,7 +121,7 @@
if (Z_TYPE_P(zv) != IS_LONG) { \
zval ___tmp; \
ZVAL_DUP(&___tmp, zv); \
- convert_to_long(&___tmp); \
+ convert_to_int(&___tmp); \
opt = Z_LVAL(___tmp); \
} else { \
opt = Z_LVAL_P(zv); \
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
index e2c743fd13..cbefae9d70 100644
--- a/ext/filter/logical_filters.c
+++ b/ext/filter/logical_filters.c
@@ -80,8 +80,8 @@
#define FORMAT_IPV4 4
#define FORMAT_IPV6 6
-static int php_filter_parse_int(const char *str, unsigned int str_len, long *ret TSRMLS_DC) { /* {{{ */
- long ctx_value;
+static int php_filter_parse_int(const char *str, unsigned int str_len, zend_long *ret TSRMLS_DC) { /* {{{ */
+ zend_long ctx_value;
int sign = 0, digit = 0;
const char *end = str + str_len;
@@ -115,9 +115,9 @@ static int php_filter_parse_int(const char *str, unsigned int str_len, long *ret
while (str < end) {
if (*str >= '0' && *str <= '9') {
digit = (*(str++) - '0');
- if ( (!sign) && ctx_value <= (LONG_MAX-digit)/10 ) {
+ if ( (!sign) && ctx_value <= (ZEND_LONG_MAX-digit)/10 ) {
ctx_value = (ctx_value * 10) + digit;
- } else if ( sign && ctx_value >= (LONG_MIN+digit)/10) {
+ } else if ( sign && ctx_value >= (ZEND_LONG_MIN+digit)/10) {
ctx_value = (ctx_value * 10) - digit;
} else {
return -1;
@@ -132,16 +132,16 @@ static int php_filter_parse_int(const char *str, unsigned int str_len, long *ret
}
/* }}} */
-static int php_filter_parse_octal(const char *str, unsigned int str_len, long *ret TSRMLS_DC) { /* {{{ */
- unsigned long ctx_value = 0;
+static int php_filter_parse_octal(const char *str, unsigned int str_len, zend_long *ret TSRMLS_DC) { /* {{{ */
+ zend_ulong ctx_value = 0;
const char *end = str + str_len;
while (str < end) {
if (*str >= '0' && *str <= '7') {
- unsigned long n = ((*(str++)) - '0');
+ zend_ulong n = ((*(str++)) - '0');
- if ((ctx_value > ((unsigned long)(~(long)0)) / 8) ||
- ((ctx_value = ctx_value * 8) > ((unsigned long)(~(long)0)) - n)) {
+ if ((ctx_value > ((zend_ulong)(~(zend_long)0)) / 8) ||
+ ((ctx_value = ctx_value * 8) > ((zend_ulong)(~(zend_long)0)) - n)) {
return -1;
}
ctx_value += n;
@@ -150,15 +150,15 @@ static int php_filter_parse_octal(const char *str, unsigned int str_len, long *r
}
}
- *ret = (long)ctx_value;
+ *ret = (zend_long)ctx_value;
return 1;
}
/* }}} */
-static int php_filter_parse_hex(const char *str, unsigned int str_len, long *ret TSRMLS_DC) { /* {{{ */
- unsigned long ctx_value = 0;
+static int php_filter_parse_hex(const char *str, unsigned int str_len, zend_long *ret TSRMLS_DC) { /* {{{ */
+ zend_ulong ctx_value = 0;
const char *end = str + str_len;
- unsigned long n;
+ zend_ulong n;
while (str < end) {
if (*str >= '0' && *str <= '9') {
@@ -170,14 +170,14 @@ static int php_filter_parse_hex(const char *str, unsigned int str_len, long *ret
} else {
return -1;
}
- if ((ctx_value > ((unsigned long)(~(long)0)) / 16) ||
- ((ctx_value = ctx_value * 16) > ((unsigned long)(~(long)0)) - n)) {
+ if ((ctx_value > ((zend_ulong)(~(zend_long)0)) / 16) ||
+ ((ctx_value = ctx_value * 16) > ((zend_ulong)(~(zend_long)0)) - n)) {
return -1;
}
ctx_value += n;
}
- *ret = (long)ctx_value;
+ *ret = (zend_long)ctx_value;
return 1;
}
/* }}} */
@@ -185,11 +185,11 @@ static int php_filter_parse_hex(const char *str, unsigned int str_len, long *ret
void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
{
zval *option_val;
- long min_range, max_range, option_flags;
+ zend_long min_range, max_range, option_flags;
int min_range_set, max_range_set;
int allow_octal = 0, allow_hex = 0;
int len, error = 0;
- long ctx_value;
+ zend_long ctx_value;
char *p;
/* Parse options */
@@ -327,7 +327,7 @@ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
char dec_sep = '.';
char tsd_sep[3] = "',.";
- long lval;
+ zend_long lval;
double dval;
int first, n;
@@ -422,7 +422,7 @@ void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
{
zval *option_val;
zend_string *regexp;
- long option_flags;
+ zend_long option_flags;
int regexp_set, option_flags_set;
pcre *re = NULL;
pcre_extra *pcre_extra = NULL;
@@ -547,13 +547,13 @@ void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
RETURN_VALIDATION_FAILED
}
- sregexp = STR_INIT(regexp, sizeof(regexp) - 1, 0);
+ sregexp = zend_string_init(regexp, sizeof(regexp) - 1, 0);
re = pcre_get_compiled_regex(sregexp, &pcre_extra, &preg_options TSRMLS_CC);
if (!re) {
- STR_RELEASE(sregexp);
+ zend_string_release(sregexp);
RETURN_VALIDATION_FAILED
}
- STR_RELEASE(sregexp);
+ zend_string_release(sregexp);
matches = pcre_exec(re, NULL, Z_STRVAL_P(value), Z_STRLEN_P(value), 0, 0, ovector, 3);
/* 0 means that the vector is too small to hold all the captured substring offsets */
@@ -796,7 +796,7 @@ void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
int tokens, length, i, offset, exp_separator_set, exp_separator_len;
char separator;
char *exp_separator;
- long ret = 0;
+ zend_long ret = 0;
zval *option_val;
FETCH_STRING_OPTION(exp_separator, "separator");
diff --git a/ext/filter/php_filter.h b/ext/filter/php_filter.h
index 9ebc18663b..e62ef8c677 100644
--- a/ext/filter/php_filter.h
+++ b/ext/filter/php_filter.h
@@ -59,8 +59,8 @@ ZEND_BEGIN_MODULE_GLOBALS(filter)
zval env_array;
zval server_array;
zval session_array;
- long default_filter;
- long default_filter_flags;
+ zend_long default_filter;
+ zend_long default_filter_flags;
ZEND_END_MODULE_GLOBALS(filter)
#ifdef ZTS
@@ -70,7 +70,7 @@ ZEND_END_MODULE_GLOBALS(filter)
#endif
-#define PHP_INPUT_FILTER_PARAM_DECL zval *value, long flags, zval *option_array, char *charset TSRMLS_DC
+#define PHP_INPUT_FILTER_PARAM_DECL zval *value, zend_long flags, zval *option_array, char *charset TSRMLS_DC
void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL);
diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c
index c93633418f..ca3059cd26 100644
--- a/ext/filter/sanitizing_filters.c
+++ b/ext/filter/sanitizing_filters.c
@@ -41,7 +41,7 @@ static void php_filter_encode_html(zval *value, const unsigned char *chars)
while (s < e) {
if (chars[*s]) {
smart_str_appendl(&str, "&#", 2);
- smart_str_append_unsigned(&str, (unsigned long)*s);
+ smart_str_append_unsigned(&str, (zend_ulong)*s);
smart_str_appendc(&str, ';');
} else {
/* XXX: this needs to be optimized to work with blocks of 'safe' chars */
@@ -87,7 +87,7 @@ static void php_filter_encode_url(zval *value, const unsigned char* chars, const
memset(tmp, 1, 32);
}
*/
- str = STR_ALLOC(3 * Z_STRLEN_P(value), 0);
+ str = zend_string_alloc(3 * Z_STRLEN_P(value), 0);
p = str->val;
s = Z_STRVAL_P(value);
e = s + Z_STRLEN_P(value);
@@ -108,7 +108,7 @@ static void php_filter_encode_url(zval *value, const unsigned char* chars, const
ZVAL_STR(value, str);
}
-static void php_filter_strip(zval *value, long flags)
+static void php_filter_strip(zval *value, zend_long flags)
{
unsigned char *str;
int i, c;
@@ -120,7 +120,7 @@ static void php_filter_strip(zval *value, long flags)
}
str = (unsigned char *)Z_STRVAL_P(value);
- buf = STR_ALLOC(Z_STRLEN_P(value) + 1, 0);
+ buf = zend_string_alloc(Z_STRLEN_P(value) + 1, 0);
c = 0;
for (i = 0; i < Z_STRLEN_P(value); i++) {
if ((str[i] > 127) && (flags & FILTER_FLAG_STRIP_HIGH)) {
@@ -162,7 +162,7 @@ static void filter_map_apply(zval *value, filter_map *map)
zend_string *buf;
str = (unsigned char *)Z_STRVAL_P(value);
- buf = STR_ALLOC(Z_STRLEN_P(value) + 1, 0);
+ buf = zend_string_alloc(Z_STRLEN_P(value) + 1, 0);
c = 0;
for (i = 0; i < Z_STRLEN_P(value); i++) {
if ((*map)[str[i]]) {
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index 30f8e1d1bb..27051677c9 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -121,7 +121,7 @@ union ipbox {
/* {{{ ftp_open
*/
ftpbuf_t*
-ftp_open(const char *host, short port, long timeout_sec TSRMLS_DC)
+ftp_open(const char *host, short port, zend_long timeout_sec TSRMLS_DC)
{
ftpbuf_t *ftp;
socklen_t size;
@@ -248,7 +248,7 @@ ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC)
{
#if HAVE_OPENSSL_EXT
SSL_CTX *ctx = NULL;
- long ssl_ctx_options = SSL_OP_ALL;
+ zend_long ssl_ctx_options = SSL_OP_ALL;
#endif
if (ftp == NULL) {
return 0;
@@ -554,13 +554,13 @@ ftp_mkdir(ftpbuf_t *ftp, const char *dir)
}
/* copy out the dir from response */
if ((mkd = strchr(ftp->inbuf, '"')) == NULL) {
- return STR_INIT(dir, strlen(dir), 0);
+ return zend_string_init(dir, strlen(dir), 0);
}
if ((end = strrchr(++mkd, '"')) == NULL) {
return NULL;
}
*end = 0;
- ret = STR_INIT(mkd, end - mkd, 0);
+ ret = zend_string_init(mkd, end - mkd, 0);
*end = '"';
return ret;
@@ -616,7 +616,7 @@ ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int filenam
/* {{{ ftp_alloc
*/
int
-ftp_alloc(ftpbuf_t *ftp, const long size, zend_string **response)
+ftp_alloc(ftpbuf_t *ftp, const zend_long size, zend_string **response)
{
char buffer[64];
@@ -624,7 +624,7 @@ ftp_alloc(ftpbuf_t *ftp, const long size, zend_string **response)
return 0;
}
- snprintf(buffer, sizeof(buffer) - 1, "%ld", size);
+ snprintf(buffer, sizeof(buffer) - 1, ZEND_LONG_FMT, size);
if (!ftp_putcmd(ftp, "ALLO", buffer)) {
return 0;
@@ -635,7 +635,7 @@ ftp_alloc(ftpbuf_t *ftp, const long size, zend_string **response)
}
if (response) {
- *response = STR_INIT(ftp->inbuf, strlen(ftp->inbuf), 0);
+ *response = zend_string_init(ftp->inbuf, strlen(ftp->inbuf), 0);
}
if (ftp->resp < 200 || ftp->resp >= 300) {
@@ -791,7 +791,7 @@ ftp_pasv(ftpbuf_t *ftp, int pasv)
/* {{{ ftp_get
*/
int
-ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC)
+ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, zend_long resumepos TSRMLS_DC)
{
databuf_t *data = NULL;
size_t rcvd;
@@ -811,7 +811,7 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type,
ftp->data = data;
if (resumepos > 0) {
- snprintf(arg, sizeof(arg), "%ld", resumepos);
+ snprintf(arg, sizeof(arg), ZEND_LONG_FMT, resumepos);
if (!ftp_putcmd(ftp, "REST", arg)) {
goto bail;
}
@@ -883,10 +883,10 @@ bail:
/* {{{ ftp_put
*/
int
-ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC)
+ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, zend_long startpos TSRMLS_DC)
{
databuf_t *data = NULL;
- long size;
+ zend_long size;
char *ptr;
int ch;
char arg[11];
@@ -903,7 +903,7 @@ ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, l
ftp->data = data;
if (startpos > 0) {
- snprintf(arg, sizeof(arg), "%ld", startpos);
+ snprintf(arg, sizeof(arg), ZEND_LONG_FMT, startpos);
if (!ftp_putcmd(ftp, "REST", arg)) {
goto bail;
}
@@ -960,7 +960,7 @@ bail:
/* {{{ ftp_size
*/
-long
+zend_long
ftp_size(ftpbuf_t *ftp, const char *path)
{
if (ftp == NULL) {
@@ -1227,7 +1227,7 @@ ftp_getresp(ftpbuf_t *ftp)
int
my_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len)
{
- long size, sent;
+ zend_long size, sent;
int n;
size = len;
@@ -1493,7 +1493,7 @@ data_accept(databuf_t *data, ftpbuf_t *ftp TSRMLS_DC)
#if HAVE_OPENSSL_EXT
SSL_CTX *ctx;
- long ssl_ctx_options = SSL_OP_ALL;
+ zend_long ssl_ctx_options = SSL_OP_ALL;
#endif
if (data->fd != -1) {
@@ -1711,7 +1711,7 @@ bail:
/* {{{ ftp_nb_get
*/
int
-ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC)
+ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, zend_long resumepos TSRMLS_DC)
{
databuf_t *data = NULL;
char arg[11];
@@ -1729,7 +1729,7 @@ ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t typ
}
if (resumepos>0) {
- snprintf(arg, sizeof(arg), "%ld", resumepos);
+ snprintf(arg, sizeof(arg), ZEND_LONG_FMT, resumepos);
if (!ftp_putcmd(ftp, "REST", arg)) {
goto bail;
}
@@ -1828,7 +1828,7 @@ bail:
/* {{{ ftp_nb_put
*/
int
-ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC)
+ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, zend_long startpos TSRMLS_DC)
{
databuf_t *data = NULL;
char arg[11];
@@ -1843,7 +1843,7 @@ ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type
goto bail;
}
if (startpos > 0) {
- snprintf(arg, sizeof(arg), "%ld", startpos);
+ snprintf(arg, sizeof(arg), ZEND_LONG_FMT, startpos);
if (!ftp_putcmd(ftp, "REST", arg)) {
goto bail;
}
diff --git a/ext/ftp/ftp.h b/ext/ftp/ftp.h
index 6b2b1ae192..57b3f663d7 100644
--- a/ext/ftp/ftp.h
+++ b/ext/ftp/ftp.h
@@ -69,7 +69,7 @@ typedef struct ftpbuf
ftptype_t type; /* current transfer type */
int pasv; /* 0=off; 1=pasv; 2=ready */
php_sockaddr_storage pasvaddr; /* passive mode address */
- long timeout_sec; /* User configureable timeout (seconds) */
+ zend_long timeout_sec; /* User configureable timeout (seconds) */
int autoseek; /* User configureable autoseek flag */
int nb; /* "nonblocking" transfer in progress */
@@ -93,7 +93,7 @@ typedef struct ftpbuf
/* open a FTP connection, returns ftpbuf (NULL on error)
* port is the ftp port in network byte order, or 0 for the default
*/
-ftpbuf_t* ftp_open(const char *host, short port, long timeout_sec TSRMLS_DC);
+ftpbuf_t* ftp_open(const char *host, short port, zend_long timeout_sec TSRMLS_DC);
/* quits from the ftp session (it still needs to be closed)
* return true on success, false on error
@@ -146,7 +146,7 @@ int ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int fi
* however some servers will not accept STOR or APPE until ALLO is confirmed.
* If response is passed, it is estrdup()ed from ftp->inbuf and must be freed
* or assigned to a zval returned to the user */
-int ftp_alloc(ftpbuf_t *ftp, const long size, zend_string **response);
+int ftp_alloc(ftpbuf_t *ftp, const zend_long size, zend_string **response);
/* returns a NULL-terminated array of filenames in the given path
* or NULL on error. the return array must be freed (but don't
@@ -169,15 +169,15 @@ int ftp_pasv(ftpbuf_t *ftp, int pasv);
/* retrieves a file and saves its contents to outfp
* returns true on success, false on error
*/
-int ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC);
+int ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, zend_long resumepos TSRMLS_DC);
/* stores the data from a file, socket, or process as a file on the remote server
* returns true on success, false on error
*/
-int ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC);
+int ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, zend_long startpos TSRMLS_DC);
/* returns the size of the given file, or -1 on error */
-long ftp_size(ftpbuf_t *ftp, const char *path);
+zend_long ftp_size(ftpbuf_t *ftp, const char *path);
/* returns the last modified time of the given file, or -1 on error */
time_t ftp_mdtm(ftpbuf_t *ftp, const char *path);
@@ -194,12 +194,12 @@ int ftp_site(ftpbuf_t *ftp, const char *cmd);
/* retrieves part of a file and saves its contents to outfp
* returns true on success, false on error
*/
-int ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC);
+int ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, zend_long resumepos TSRMLS_DC);
/* stores the data from a file, socket, or process as a file on the remote server
* returns true on success, false on error
*/
-int ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC);
+int ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, zend_long startpos TSRMLS_DC);
/* continues a previous nb_(f)get command
*/
diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c
index 1bf485f4ed..19fee1ffaa 100644
--- a/ext/ftp/php_ftp.c
+++ b/ext/ftp/php_ftp.c
@@ -344,8 +344,8 @@ PHP_FUNCTION(ftp_connect)
ftpbuf_t *ftp;
char *host;
int host_len;
- long port = 0;
- long timeout_sec = FTP_DEFAULT_TIMEOUT;
+ zend_long port = 0;
+ zend_long timeout_sec = FTP_DEFAULT_TIMEOUT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &host, &host_len, &port, &timeout_sec) == FAILURE) {
return;
@@ -380,8 +380,8 @@ PHP_FUNCTION(ftp_ssl_connect)
ftpbuf_t *ftp;
char *host;
int host_len;
- long port = 0;
- long timeout_sec = FTP_DEFAULT_TIMEOUT;
+ zend_long port = 0;
+ zend_long timeout_sec = FTP_DEFAULT_TIMEOUT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &host, &host_len, &port, &timeout_sec) == FAILURE) {
return;
@@ -606,7 +606,7 @@ PHP_FUNCTION(ftp_chmod)
ftpbuf_t *ftp;
char *filename;
int filename_len;
- long mode;
+ zend_long mode;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlp", &z_ftp, &mode, &filename, &filename_len) == FAILURE) {
RETURN_FALSE;
@@ -629,7 +629,7 @@ PHP_FUNCTION(ftp_alloc)
{
zval *z_ftp, *zresponse = NULL;
ftpbuf_t *ftp;
- long size, ret;
+ zend_long size, ret;
zend_string *response = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z/", &z_ftp, &size, &zresponse) == FAILURE) {
@@ -742,7 +742,7 @@ PHP_FUNCTION(ftp_fget)
php_stream *stream;
char *file;
int file_len;
- long mode, resumepos=0;
+ zend_long mode, resumepos=0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrsl|l", &z_ftp, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) {
return;
@@ -786,7 +786,7 @@ PHP_FUNCTION(ftp_nb_fget)
php_stream *stream;
char *file;
int file_len;
- long mode, resumepos=0, ret;
+ zend_long mode, resumepos=0, ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrsl|l", &z_ftp, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) {
return;
@@ -856,7 +856,7 @@ PHP_FUNCTION(ftp_get)
php_stream *outstream;
char *local, *remote;
int local_len, remote_len;
- long mode, resumepos=0;
+ zend_long mode, resumepos=0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &local, &local_len, &remote, &remote_len, &mode, &resumepos) == FAILURE) {
return;
@@ -919,7 +919,7 @@ PHP_FUNCTION(ftp_nb_get)
php_stream *outstream;
char *local, *remote;
int local_len, remote_len, ret;
- long mode, resumepos=0;
+ zend_long mode, resumepos=0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssl|l", &z_ftp, &local, &local_len, &remote, &remote_len, &mode, &resumepos) == FAILURE) {
return;
@@ -985,7 +985,7 @@ PHP_FUNCTION(ftp_nb_continue)
{
zval *z_ftp;
ftpbuf_t *ftp;
- long ret;
+ zend_long ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_ftp) == FAILURE) {
return;
@@ -1025,7 +1025,7 @@ PHP_FUNCTION(ftp_fput)
ftpbuf_t *ftp;
ftptype_t xtype;
int remote_len;
- long mode, startpos=0;
+ zend_long mode, startpos=0;
php_stream *stream;
char *remote;
@@ -1072,7 +1072,7 @@ PHP_FUNCTION(ftp_nb_fput)
ftpbuf_t *ftp;
ftptype_t xtype;
int remote_len, ret;
- long mode, startpos=0;
+ zend_long mode, startpos=0;
php_stream *stream;
char *remote;
@@ -1124,8 +1124,8 @@ PHP_FUNCTION(ftp_put)
ftpbuf_t *ftp;
ftptype_t xtype;
char *remote, *local;
- long remote_len, local_len;
- long mode, startpos=0;
+ zend_long remote_len, local_len;
+ zend_long mode, startpos=0;
php_stream *instream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) {
@@ -1178,7 +1178,7 @@ PHP_FUNCTION(ftp_nb_put)
ftptype_t xtype;
char *remote, *local;
int remote_len, local_len;
- long mode, startpos=0, ret;
+ zend_long mode, startpos=0, ret;
php_stream *instream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) {
@@ -1368,7 +1368,7 @@ PHP_FUNCTION(ftp_close)
PHP_FUNCTION(ftp_set_option)
{
zval *z_ftp, *z_value;
- long option;
+ zend_long option;
ftpbuf_t *ftp;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &z_ftp, &option, &z_value) == FAILURE) {
@@ -1401,7 +1401,7 @@ PHP_FUNCTION(ftp_set_option)
RETURN_TRUE;
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option '%ld'", option);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option '%pd'", option);
RETURN_FALSE;
break;
}
@@ -1413,7 +1413,7 @@ PHP_FUNCTION(ftp_set_option)
PHP_FUNCTION(ftp_get_option)
{
zval *z_ftp;
- long option;
+ zend_long option;
ftpbuf_t *ftp;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &z_ftp, &option) == FAILURE) {
@@ -1430,7 +1430,7 @@ PHP_FUNCTION(ftp_get_option)
RETURN_BOOL(ftp->autoseek);
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option '%ld'", option);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option '%pd'", option);
RETURN_FALSE;
break;
}
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index d7994476f0..53f07c06ec 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -1541,7 +1541,7 @@ PHP_FUNCTION(imagesetstyle)
if (Z_TYPE_P(item) != IS_LONG) {
zval lval;
ZVAL_COPY(&lval, item);
- convert_to_long(&lval);
+ convert_to_int(&lval);
stylearr[index++] = Z_LVAL(lval);
} else {
stylearr[index++] = Z_LVAL_P(item);
@@ -1560,7 +1560,7 @@ PHP_FUNCTION(imagesetstyle)
Create a new true color image */
PHP_FUNCTION(imagecreatetruecolor)
{
- long x_size, y_size;
+ zend_long x_size, y_size;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &x_size, &y_size) == FAILURE) {
@@ -1605,7 +1605,7 @@ PHP_FUNCTION(imagetruecolortopalette)
{
zval *IM;
zend_bool dither;
- long ncolors;
+ zend_long ncolors;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rbl", &IM, &dither, &ncolors) == FAILURE) {
@@ -1689,7 +1689,7 @@ PHP_FUNCTION(imagecolormatch)
PHP_FUNCTION(imagesetthickness)
{
zval *IM;
- long thick;
+ zend_long thick;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &IM, &thick) == FAILURE) {
@@ -1709,7 +1709,7 @@ PHP_FUNCTION(imagesetthickness)
PHP_FUNCTION(imagefilledellipse)
{
zval *IM;
- long cx, cy, w, h, color;
+ zend_long cx, cy, w, h, color;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlllll", &IM, &cx, &cy, &w, &h, &color) == FAILURE) {
@@ -1729,7 +1729,7 @@ PHP_FUNCTION(imagefilledellipse)
PHP_FUNCTION(imagefilledarc)
{
zval *IM;
- long cx, cy, w, h, ST, E, col, style;
+ zend_long cx, cy, w, h, ST, E, col, style;
gdImagePtr im;
int e, st;
@@ -1798,7 +1798,7 @@ PHP_FUNCTION(imagesavealpha)
PHP_FUNCTION(imagelayereffect)
{
zval *IM;
- long effect;
+ zend_long effect;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &IM, &effect) == FAILURE) {
@@ -1817,7 +1817,7 @@ PHP_FUNCTION(imagelayereffect)
PHP_FUNCTION(imagecolorallocatealpha)
{
zval *IM;
- long red, green, blue, alpha;
+ zend_long red, green, blue, alpha;
gdImagePtr im;
int ct = (-1);
@@ -1830,7 +1830,7 @@ PHP_FUNCTION(imagecolorallocatealpha)
if (ct < 0) {
RETURN_FALSE;
}
- RETURN_LONG((long)ct);
+ RETURN_LONG((zend_long)ct);
}
/* }}} */
@@ -1839,7 +1839,7 @@ PHP_FUNCTION(imagecolorallocatealpha)
PHP_FUNCTION(imagecolorresolvealpha)
{
zval *IM;
- long red, green, blue, alpha;
+ zend_long red, green, blue, alpha;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll", &IM, &red, &green, &blue, &alpha) == FAILURE) {
@@ -1857,7 +1857,7 @@ PHP_FUNCTION(imagecolorresolvealpha)
PHP_FUNCTION(imagecolorclosestalpha)
{
zval *IM;
- long red, green, blue, alpha;
+ zend_long red, green, blue, alpha;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll", &IM, &red, &green, &blue, &alpha) == FAILURE) {
@@ -1875,7 +1875,7 @@ PHP_FUNCTION(imagecolorclosestalpha)
PHP_FUNCTION(imagecolorexactalpha)
{
zval *IM;
- long red, green, blue, alpha;
+ zend_long red, green, blue, alpha;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll", &IM, &red, &green, &blue, &alpha) == FAILURE) {
@@ -1893,7 +1893,7 @@ PHP_FUNCTION(imagecolorexactalpha)
PHP_FUNCTION(imagecopyresampled)
{
zval *SIM, *DIM;
- long SX, SY, SW, SH, DX, DY, DW, DH;
+ zend_long SX, SY, SW, SH, DX, DY, DW, DH;
gdImagePtr im_dst, im_src;
int srcH, srcW, dstH, dstW, srcY, srcX, dstY, dstX;
@@ -1925,7 +1925,7 @@ PHP_FUNCTION(imagecopyresampled)
PHP_FUNCTION(imagegrabwindow)
{
HWND window;
- long client_area = 0;
+ zend_long client_area = 0;
RECT rc = {0};
RECT rc_win = {0};
int Width, Height;
@@ -1934,7 +1934,7 @@ PHP_FUNCTION(imagegrabwindow)
HBITMAP memBM;
HBITMAP hOld;
HINSTANCE handle;
- long lwindow_handle;
+ zend_long lwindow_handle;
typedef BOOL (WINAPI *tPrintWindow)(HWND, HDC,UINT);
tPrintWindow pPrintWindow = 0;
gdImagePtr im;
@@ -2076,8 +2076,8 @@ PHP_FUNCTION(imagerotate)
zval *SIM;
gdImagePtr im_dst, im_src;
double degrees;
- long color;
- long ignoretransparent = 0;
+ zend_long color;
+ zend_long ignoretransparent = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rdl|l", &SIM, &degrees, &color, &ignoretransparent) == FAILURE) {
RETURN_FALSE;
@@ -2139,7 +2139,7 @@ PHP_FUNCTION(imagesetbrush)
Create a new image */
PHP_FUNCTION(imagecreate)
{
- long x_size, y_size;
+ zend_long x_size, y_size;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &x_size, &y_size) == FAILURE) {
@@ -2344,7 +2344,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
{
char *file;
int file_len;
- long srcx, srcy, width, height;
+ zend_long srcx, srcy, width, height;
gdImagePtr im = NULL;
php_stream *stream;
FILE * fp = NULL;
@@ -2395,7 +2395,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
io_ctx = gdNewDynamicCtxEx(buff->len, pstr, 0);
if (!io_ctx) {
pefree(pstr, 1);
- STR_RELEASE(buff);
+ zend_string_release(buff);
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot allocate GD IO context");
goto out_err;
}
@@ -2407,7 +2407,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
}
io_ctx->gd_free(io_ctx);
pefree(pstr, 1);
- STR_RELEASE(buff);
+ zend_string_release(buff);
}
else if (php_stream_can_cast(stream, PHP_STREAM_AS_STDIO)) {
/* try and force the stream to be FILE* */
@@ -2551,7 +2551,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
{
zval *imgind;
char *file = NULL;
- long quality = 0, type = 0;
+ zend_long quality = 0, type = 0;
gdImagePtr im;
char *fn = NULL;
FILE *fp;
@@ -2794,7 +2794,7 @@ PHP_FUNCTION(imagedestroy)
PHP_FUNCTION(imagecolorallocate)
{
zval *IM;
- long red, green, blue;
+ zend_long red, green, blue;
gdImagePtr im;
int ct = (-1);
@@ -2835,7 +2835,7 @@ PHP_FUNCTION(imagepalettecopy)
PHP_FUNCTION(imagecolorat)
{
zval *IM;
- long x, y;
+ zend_long x, y;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &IM, &x, &y) == FAILURE) {
@@ -2848,14 +2848,14 @@ PHP_FUNCTION(imagecolorat)
if (im->tpixels && gdImageBoundsSafe(im, x, y)) {
RETURN_LONG(gdImageTrueColorPixel(im, x, y));
} else {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%ld,%ld is out of bounds", x, y);
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%pd,%pd is out of bounds", x, y);
RETURN_FALSE;
}
} else {
if (im->pixels && gdImageBoundsSafe(im, x, y)) {
RETURN_LONG(im->pixels[y][x]);
} else {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%ld,%ld is out of bounds", x, y);
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%pd,%pd is out of bounds", x, y);
RETURN_FALSE;
}
}
@@ -2867,7 +2867,7 @@ PHP_FUNCTION(imagecolorat)
PHP_FUNCTION(imagecolorclosest)
{
zval *IM;
- long red, green, blue;
+ zend_long red, green, blue;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlll", &IM, &red, &green, &blue) == FAILURE) {
@@ -2885,7 +2885,7 @@ PHP_FUNCTION(imagecolorclosest)
PHP_FUNCTION(imagecolorclosesthwb)
{
zval *IM;
- long red, green, blue;
+ zend_long red, green, blue;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlll", &IM, &red, &green, &blue) == FAILURE) {
@@ -2903,7 +2903,7 @@ PHP_FUNCTION(imagecolorclosesthwb)
PHP_FUNCTION(imagecolordeallocate)
{
zval *IM;
- long index;
+ zend_long index;
int col;
gdImagePtr im;
@@ -2935,7 +2935,7 @@ PHP_FUNCTION(imagecolordeallocate)
PHP_FUNCTION(imagecolorresolve)
{
zval *IM;
- long red, green, blue;
+ zend_long red, green, blue;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlll", &IM, &red, &green, &blue) == FAILURE) {
@@ -2953,7 +2953,7 @@ PHP_FUNCTION(imagecolorresolve)
PHP_FUNCTION(imagecolorexact)
{
zval *IM;
- long red, green, blue;
+ zend_long red, green, blue;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlll", &IM, &red, &green, &blue) == FAILURE) {
@@ -2971,7 +2971,7 @@ PHP_FUNCTION(imagecolorexact)
PHP_FUNCTION(imagecolorset)
{
zval *IM;
- long color, red, green, blue, alpha = 0;
+ zend_long color, red, green, blue, alpha = 0;
int col;
gdImagePtr im;
@@ -2999,7 +2999,7 @@ PHP_FUNCTION(imagecolorset)
PHP_FUNCTION(imagecolorsforindex)
{
zval *IM;
- long index;
+ zend_long index;
int col;
gdImagePtr im;
@@ -3073,7 +3073,7 @@ PHP_FUNCTION(imagegammacorrect)
PHP_FUNCTION(imagesetpixel)
{
zval *IM;
- long x, y, col;
+ zend_long x, y, col;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlll", &IM, &x, &y, &col) == FAILURE) {
@@ -3091,7 +3091,7 @@ PHP_FUNCTION(imagesetpixel)
PHP_FUNCTION(imageline)
{
zval *IM;
- long x1, y1, x2, y2, col;
+ zend_long x1, y1, x2, y2, col;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlllll", &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) {
@@ -3117,7 +3117,7 @@ PHP_FUNCTION(imageline)
PHP_FUNCTION(imagedashedline)
{
zval *IM;
- long x1, y1, x2, y2, col;
+ zend_long x1, y1, x2, y2, col;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlllll", &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) {
@@ -3135,7 +3135,7 @@ PHP_FUNCTION(imagedashedline)
PHP_FUNCTION(imagerectangle)
{
zval *IM;
- long x1, y1, x2, y2, col;
+ zend_long x1, y1, x2, y2, col;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlllll", &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) {
@@ -3153,7 +3153,7 @@ PHP_FUNCTION(imagerectangle)
PHP_FUNCTION(imagefilledrectangle)
{
zval *IM;
- long x1, y1, x2, y2, col;
+ zend_long x1, y1, x2, y2, col;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlllll", &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) {
@@ -3171,7 +3171,7 @@ PHP_FUNCTION(imagefilledrectangle)
PHP_FUNCTION(imagearc)
{
zval *IM;
- long cx, cy, w, h, ST, E, col;
+ zend_long cx, cy, w, h, ST, E, col;
gdImagePtr im;
int e, st;
@@ -3201,7 +3201,7 @@ PHP_FUNCTION(imagearc)
PHP_FUNCTION(imageellipse)
{
zval *IM;
- long cx, cy, w, h, color;
+ zend_long cx, cy, w, h, color;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlllll", &IM, &cx, &cy, &w, &h, &color) == FAILURE) {
@@ -3220,7 +3220,7 @@ PHP_FUNCTION(imageellipse)
PHP_FUNCTION(imagefilltoborder)
{
zval *IM;
- long x, y, border, col;
+ zend_long x, y, border, col;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll", &IM, &x, &y, &border, &col) == FAILURE) {
@@ -3238,7 +3238,7 @@ PHP_FUNCTION(imagefilltoborder)
PHP_FUNCTION(imagefill)
{
zval *IM;
- long x, y, col;
+ zend_long x, y, col;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlll", &IM, &x, &y, &col) == FAILURE) {
@@ -3273,7 +3273,7 @@ PHP_FUNCTION(imagecolorstotal)
PHP_FUNCTION(imagecolortransparent)
{
zval *IM;
- long COL = 0;
+ zend_long COL = 0;
gdImagePtr im;
int argc = ZEND_NUM_ARGS();
@@ -3297,7 +3297,7 @@ PHP_FUNCTION(imageinterlace)
{
zval *IM;
int argc = ZEND_NUM_ARGS();
- long INT = 0;
+ zend_long INT = 0;
gdImagePtr im;
if (zend_parse_parameters(argc TSRMLS_CC, "r|l", &IM, &INT) == FAILURE) {
@@ -3321,7 +3321,7 @@ PHP_FUNCTION(imageinterlace)
static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
{
zval *IM, *POINTS;
- long NPOINTS, COL;
+ zend_long NPOINTS, COL;
zval *var = NULL;
gdImagePtr im;
gdPointPtr points;
@@ -3357,7 +3357,7 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
if (Z_TYPE_P(var) != IS_LONG) {
zval lval;
ZVAL_COPY(&lval, var);
- convert_to_long(&lval);
+ convert_to_int(&lval);
points[i].x = Z_LVAL(lval);
} else {
points[i].x = Z_LVAL_P(var);
@@ -3367,7 +3367,7 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
if (Z_TYPE_P(var) != IS_LONG) {
zval lval;
ZVAL_COPY(&lval, var);
- convert_to_long(&lval);
+ convert_to_int(&lval);
points[i].y = Z_LVAL(lval);
} else {
points[i].y = Z_LVAL_P(var);
@@ -3449,7 +3449,7 @@ static gdFontPtr php_find_gd_font(int size TSRMLS_DC)
*/
static void php_imagefontsize(INTERNAL_FUNCTION_PARAMETERS, int arg)
{
- long SIZE;
+ zend_long SIZE;
gdFontPtr font;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &SIZE) == FAILURE) {
@@ -3512,7 +3512,7 @@ static void php_gdimagecharup(gdImagePtr im, gdFontPtr f, int x, int y, int c, i
static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
zval *IM;
- long SIZE, X, Y, COL;
+ zend_long SIZE, X, Y, COL;
char *C;
int C_len;
gdImagePtr im;
@@ -3607,7 +3607,7 @@ PHP_FUNCTION(imagestringup)
PHP_FUNCTION(imagecopy)
{
zval *SIM, *DIM;
- long SX, SY, SW, SH, DX, DY;
+ zend_long SX, SY, SW, SH, DX, DY;
gdImagePtr im_dst, im_src;
int srcH, srcW, srcY, srcX, dstY, dstX;
@@ -3635,7 +3635,7 @@ PHP_FUNCTION(imagecopy)
PHP_FUNCTION(imagecopymerge)
{
zval *SIM, *DIM;
- long SX, SY, SW, SH, DX, DY, PCT;
+ zend_long SX, SY, SW, SH, DX, DY, PCT;
gdImagePtr im_dst, im_src;
int srcH, srcW, srcY, srcX, dstY, dstX, pct;
@@ -3664,7 +3664,7 @@ PHP_FUNCTION(imagecopymerge)
PHP_FUNCTION(imagecopymergegray)
{
zval *SIM, *DIM;
- long SX, SY, SW, SH, DX, DY, PCT;
+ zend_long SX, SY, SW, SH, DX, DY, PCT;
gdImagePtr im_dst, im_src;
int srcH, srcW, srcY, srcX, dstY, dstX, pct;
@@ -3693,7 +3693,7 @@ PHP_FUNCTION(imagecopymergegray)
PHP_FUNCTION(imagecopyresized)
{
zval *SIM, *DIM;
- long SX, SY, SW, SH, DX, DY, DW, DH;
+ zend_long SX, SY, SW, SH, DX, DY, DW, DH;
gdImagePtr im_dst, im_src;
int srcH, srcW, dstH, dstW, srcY, srcX, dstY, dstX;
@@ -3804,7 +3804,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
{
zval *IM, *EXT = NULL;
gdImagePtr im=NULL;
- long col = -1, x = -1, y = -1;
+ zend_long col = -1, x = -1, y = -1;
int str_len, fontname_len, i, brect[8];
double ptsize, angle;
char *str = NULL, *fontname = NULL;
@@ -3833,7 +3833,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
if (extended && EXT) { /* parse extended info */
zval *item;
zend_string *key;
- ulong num_key;
+ zend_ulong num_key;
/* walk the assoc array */
ZEND_HASH_FOREACH_KEY_VAL(HASH_OF(EXT), num_key, key, item) {
@@ -4105,7 +4105,7 @@ PHP_FUNCTION(imagepstext)
{
zval *img, *fnt;
int i, j;
- long _fg, _bg, x, y, size, space = 0, aa_steps = 4, width = 0;
+ zend_long _fg, _bg, x, y, size, space = 0, aa_steps = 4, width = 0;
int *f_ind;
int h_lines, v_lines, c_ind;
int rd, gr, bl, fg_rd, fg_gr, fg_bl, bg_rd, bg_gr, bg_bl;
@@ -4135,12 +4135,12 @@ PHP_FUNCTION(imagepstext)
/* Ensure that the provided colors are valid */
if (_fg < 0 || (!gdImageTrueColor(bg_img) && _fg > gdImageColorsTotal(bg_img))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Foreground color index %ld out of range", _fg);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Foreground color index %pd out of range", _fg);
RETURN_FALSE;
}
if (_bg < 0 || (!gdImageTrueColor(bg_img) && _fg > gdImageColorsTotal(bg_img))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Background color index %ld out of range", _bg);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Background color index %pd out of range", _bg);
RETURN_FALSE;
}
@@ -4174,7 +4174,7 @@ PHP_FUNCTION(imagepstext)
T1_AASetLevel(T1_AA_HIGH);
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value %ld as number of steps for antialiasing", aa_steps);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value %pd as number of steps for antialiasing", aa_steps);
RETURN_FALSE;
}
@@ -4243,7 +4243,7 @@ PHP_FUNCTION(imagepstext)
PHP_FUNCTION(imagepsbbox)
{
zval *fnt;
- long sz = 0, sp = 0, wd = 0;
+ zend_long sz = 0, sp = 0, wd = 0;
char *str;
int i, space = 0, add_width = 0, char_width, amount_kern;
int cur_x, cur_y, dx, dy;
@@ -4423,7 +4423,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
{
char *f_org, *f_dest;
int f_org_len, f_dest_len;
- long height, width, threshold;
+ zend_long height, width, threshold;
gdImagePtr im_org, im_dest, im_tmp;
char *fn_org = NULL;
char *fn_dest = NULL;
@@ -4437,7 +4437,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
int x, y;
float x_ratio, y_ratio;
#ifdef HAVE_GD_JPG
- long ignore_warning;
+ zend_long ignore_warning;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pplll", &f_org, &f_org_len, &f_dest, &f_dest_len, &height, &width, &threshold) == FAILURE) {
@@ -4635,7 +4635,7 @@ static void php_image_filter_brightness(INTERNAL_FUNCTION_PARAMETERS)
{
zval *SIM;
gdImagePtr im_src;
- long brightness, tmp;
+ zend_long brightness, tmp;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zll", &SIM, &tmp, &brightness) == FAILURE) {
RETURN_FALSE;
@@ -4658,7 +4658,7 @@ static void php_image_filter_contrast(INTERNAL_FUNCTION_PARAMETERS)
{
zval *SIM;
gdImagePtr im_src;
- long contrast, tmp;
+ zend_long contrast, tmp;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &SIM, &tmp, &contrast) == FAILURE) {
RETURN_FALSE;
@@ -4681,8 +4681,8 @@ static void php_image_filter_colorize(INTERNAL_FUNCTION_PARAMETERS)
{
zval *SIM;
gdImagePtr im_src;
- long r,g,b,tmp;
- long a = 0;
+ zend_long r,g,b,tmp;
+ zend_long a = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll|l", &SIM, &tmp, &r, &g, &b, &a) == FAILURE) {
RETURN_FALSE;
@@ -4759,7 +4759,7 @@ static void php_image_filter_mean_removal(INTERNAL_FUNCTION_PARAMETERS)
static void php_image_filter_smooth(INTERNAL_FUNCTION_PARAMETERS)
{
zval *SIM;
- long tmp;
+ zend_long tmp;
gdImagePtr im_src;
double weight;
@@ -4784,7 +4784,7 @@ static void php_image_filter_pixelate(INTERNAL_FUNCTION_PARAMETERS)
{
zval *IM;
gdImagePtr im;
- long tmp, blocksize;
+ zend_long tmp, blocksize;
zend_bool mode = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll|b", &IM, &tmp, &blocksize, &mode) == FAILURE) {
@@ -4811,7 +4811,7 @@ PHP_FUNCTION(imagefilter)
zval *tmp;
typedef void (*image_filter)(INTERNAL_FUNCTION_PARAMETERS);
- long filtertype;
+ zend_long filtertype;
image_filter filters[] =
{
php_image_filter_negate ,
@@ -4903,7 +4903,7 @@ PHP_FUNCTION(imageconvolution)
PHP_FUNCTION(imageflip)
{
zval *IM;
- long mode;
+ zend_long mode;
gdImagePtr im;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &IM, &mode) == FAILURE) {
@@ -4975,7 +4975,7 @@ PHP_FUNCTION(imagecrop)
if (Z_TYPE_P(tmp) != IS_LONG) {
zval lval;
ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
+ convert_to_int(&lval);
rect.x = Z_LVAL(lval);
} else {
rect.x = Z_LVAL_P(tmp);
@@ -4989,7 +4989,7 @@ PHP_FUNCTION(imagecrop)
if (Z_TYPE_P(tmp) != IS_LONG) {
zval lval;
ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
+ convert_to_int(&lval);
rect.y = Z_LVAL(lval);
} else {
rect.y = Z_LVAL_P(tmp);
@@ -5003,7 +5003,7 @@ PHP_FUNCTION(imagecrop)
if (Z_TYPE_P(tmp) != IS_LONG) {
zval lval;
ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
+ convert_to_int(&lval);
rect.width = Z_LVAL(lval);
} else {
rect.width = Z_LVAL_P(tmp);
@@ -5017,7 +5017,7 @@ PHP_FUNCTION(imagecrop)
if (Z_TYPE_P(tmp) != IS_LONG) {
zval lval;
ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
+ convert_to_int(&lval);
rect.height = Z_LVAL(lval);
} else {
rect.height = Z_LVAL_P(tmp);
@@ -5042,8 +5042,8 @@ PHP_FUNCTION(imagecrop)
PHP_FUNCTION(imagecropauto)
{
zval *IM;
- long mode = -1;
- long color = -1;
+ zend_long mode = -1;
+ zend_long color = -1;
double threshold = 0.5f;
gdImagePtr im;
gdImagePtr im_crop;
@@ -5093,7 +5093,7 @@ PHP_FUNCTION(imagescale)
gdImagePtr im;
gdImagePtr im_scaled = NULL;
int new_width, new_height;
- long tmp_w, tmp_h=-1, tmp_m = GD_BILINEAR_FIXED;
+ zend_long tmp_w, tmp_h=-1, tmp_m = GD_BILINEAR_FIXED;
gdInterpolationMethod method;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|ll", &IM, &tmp_w, &tmp_h, &tmp_m) == FAILURE) {
@@ -5173,7 +5173,7 @@ PHP_FUNCTION(imageaffine)
if (Z_TYPE_P(tmp) != IS_LONG) {
zval lval;
ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
+ convert_to_int(&lval);
rect.x = Z_LVAL(lval);
} else {
rect.x = Z_LVAL_P(tmp);
@@ -5187,7 +5187,7 @@ PHP_FUNCTION(imageaffine)
if (Z_TYPE_P(tmp) != IS_LONG) {
zval lval;
ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
+ convert_to_int(&lval);
rect.y = Z_LVAL(lval);
} else {
rect.y = Z_LVAL_P(tmp);
@@ -5201,7 +5201,7 @@ PHP_FUNCTION(imageaffine)
if (Z_TYPE_P(tmp) != IS_LONG) {
zval lval;
ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
+ convert_to_int(&lval);
rect.width = Z_LVAL(lval);
} else {
rect.width = Z_LVAL_P(tmp);
@@ -5215,7 +5215,7 @@ PHP_FUNCTION(imageaffine)
if (Z_TYPE_P(tmp) != IS_LONG) {
zval lval;
ZVAL_COPY(&lval, tmp);
- convert_to_long(&lval);
+ convert_to_int(&lval);
rect.height = Z_LVAL(lval);
} else {
rect.height = Z_LVAL_P(tmp);
@@ -5250,7 +5250,7 @@ PHP_FUNCTION(imageaffine)
PHP_FUNCTION(imageaffinematrixget)
{
double affine[6];
- long type;
+ zend_long type;
zval *options = NULL;
zval *tmp;
int res = GD_FALSE, i;
@@ -5423,7 +5423,7 @@ PHP_FUNCTION(imagesetinterpolation)
{
zval *IM;
gdImagePtr im;
- long method = GD_BILINEAR_FIXED;
+ zend_long method = GD_BILINEAR_FIXED;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &IM, &method) == FAILURE) {
return;
diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c
index 4f97af846a..972d4f337c 100644
--- a/ext/gd/gd_ctx.c
+++ b/ext/gd/gd_ctx.c
@@ -79,7 +79,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
zval *imgind;
char *file = NULL;
int file_len = 0;
- long quality, basefilter;
+ zend_long quality, basefilter;
gdImagePtr im;
int argc = ZEND_NUM_ARGS();
int q = -1, i;
@@ -124,6 +124,11 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
RETURN_FALSE;
}
} else if (Z_TYPE_P(to_zval) == IS_STRING) {
+ if (CHECK_ZVAL_NULL_PATH(to_zval)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid 2nd parameter, filename must not contain null bytes");
+ RETURN_FALSE;
+ }
+
stream = php_stream_open_wrapper(Z_STRVAL_P(to_zval), "wb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL);
if (stream == NULL) {
RETURN_FALSE;
diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c
index 4979e1511f..4148cf47bb 100644
--- a/ext/gd/libgd/gdft.c
+++ b/ext/gd/libgd/gdft.c
@@ -390,9 +390,10 @@ static void *fontFetch (char **error, void *key)
fontlist = gdEstrdup(a->fontlist);
/*
- * Must use gd_strtok_r else pointer corrupted by strtok in nested loop.
+ * Must use gd_strtok_r becasuse strtok() isn't thread safe
*/
for (name = gd_strtok_r (fontlist, LISTSEPARATOR, &strtok_ptr); name; name = gd_strtok_r (0, LISTSEPARATOR, &strtok_ptr)) {
+ char *strtok_ptr_path;
/* make a fresh copy each time - strtok corrupts it. */
path = gdEstrdup (fontsearchpath);
@@ -408,7 +409,8 @@ static void *fontFetch (char **error, void *key)
break;
}
}
- for (dir = strtok (path, PATHSEPARATOR); dir; dir = strtok (0, PATHSEPARATOR)) {
+ for (dir = gd_strtok_r (path, PATHSEPARATOR, &strtok_ptr_path); dir;
+ dir = gd_strtok_r (0, PATHSEPARATOR, &strtok_ptr_path)) {
if (!strcmp(dir, ".")) {
TSRMLS_FETCH();
#if HAVE_GETCWD
diff --git a/ext/gd/tests/imagegd2_nullbyte_injection.phpt b/ext/gd/tests/imagegd2_nullbyte_injection.phpt
new file mode 100644
index 0000000000..49affefb96
--- /dev/null
+++ b/ext/gd/tests/imagegd2_nullbyte_injection.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Testing null byte injection in imagegd2
+--CLEAN--
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+rmdir($tempdir);
+--FILE--
+<?php
+$image = imagecreate(1,1);// 1px image
+
+
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+if (!file_exists($tempdir) && !is_dir($tempdir)) {
+ mkdir ($tempdir, 0777, true);
+}
+
+$userinput = "1\0"; // from post or get data
+$temp = $tempdir. "/test" . $userinput .".tmp";
+
+echo "\nimagegd2 TEST\n";
+imagegd2($image, $temp);
+var_dump(file_exists($tempdir. "/test1"));
+var_dump(file_exists($tempdir. "/test1.tmp"));
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+
+--EXPECTF--
+imagegd2 TEST
+
+Warning: imagegd2() expects parameter 2 to be a valid path, string given in %s on line %d
+bool(false)
+bool(false)
diff --git a/ext/gd/tests/imagegd_nullbyte_injection.phpt b/ext/gd/tests/imagegd_nullbyte_injection.phpt
new file mode 100644
index 0000000000..a423a551fd
--- /dev/null
+++ b/ext/gd/tests/imagegd_nullbyte_injection.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Testing null byte injection in imagegd
+--CLEAN--
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+rmdir($tempdir);
+--FILE--
+<?php
+$image = imagecreate(1,1);// 1px image
+
+
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+if (!file_exists($tempdir) && !is_dir($tempdir)) {
+ mkdir ($tempdir, 0777, true);
+}
+
+$userinput = "1\0"; // from post or get data
+$temp = $tempdir. "/test" . $userinput .".tmp";
+
+echo "\nimagegd TEST\n";
+imagegd($image, $temp);
+var_dump(file_exists($tempdir. "/test1"));
+var_dump(file_exists($tempdir. "/test1.tmp"));
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+
+--EXPECTF--
+imagegd TEST
+
+Warning: imagegd() expects parameter 2 to be a valid path, string given in %s on line %d
+bool(false)
+bool(false)
diff --git a/ext/gd/tests/imagegif_nullbyte_injection.phpt b/ext/gd/tests/imagegif_nullbyte_injection.phpt
new file mode 100644
index 0000000000..c3d0c30175
--- /dev/null
+++ b/ext/gd/tests/imagegif_nullbyte_injection.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Testing null byte injection in imagegif
+--CLEAN--
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+rmdir($tempdir);
+--SKIPIF--
+<?php
+$support = gd_info();
+if (!isset($support['GIF Create Support']) || $support['GIF Create Support'] === false) {
+ print 'skip gif support not available';
+}
+?>
+--FILE--
+<?php
+$image = imagecreate(1,1);// 1px image
+
+
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+if (!file_exists($tempdir) && !is_dir($tempdir)) {
+ mkdir ($tempdir, 0777, true);
+}
+
+$userinput = "1\0"; // from post or get data
+$temp = $tempdir. "/test" . $userinput .".tmp";
+
+echo "\nimagegif TEST\n";
+imagegif($image, $temp);
+var_dump(file_exists($tempdir. "/test1"));
+var_dump(file_exists($tempdir. "/test1.tmp"));
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+
+--EXPECTF--
+imagegif TEST
+
+Warning: imagegif(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d
+bool(false)
+bool(false)
diff --git a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt
new file mode 100644
index 0000000000..9c52355011
--- /dev/null
+++ b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Testing null byte injection in imagejpeg
+--CLEAN--
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+rmdir($tempdir);
+--SKIPIF--
+<?php
+$support = gd_info();
+if (!isset($support['JPEG Support']) || $support['JPEG Support'] === false) {
+ print 'skip jpeg support not available';
+}
+?>
+--FILE--
+<?php
+$image = imagecreate(1,1);// 1px image
+
+
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+if (!file_exists($tempdir) && !is_dir($tempdir)) {
+ mkdir ($tempdir, 0777, true);
+}
+
+$userinput = "1\0"; // from post or get data
+$temp = $tempdir. "/test" . $userinput .".tmp";
+
+echo "\nimagejpeg TEST\n";
+imagejpeg($image, $temp);
+var_dump(file_exists($tempdir. "/test1"));
+var_dump(file_exists($tempdir. "/test1.tmp"));
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+
+--EXPECTF--
+imagejpeg TEST
+
+Warning: imagejpeg(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d
+bool(false)
+bool(false)
diff --git a/ext/gd/tests/imagepng_nullbyte_injection.phpt b/ext/gd/tests/imagepng_nullbyte_injection.phpt
new file mode 100644
index 0000000000..13949dca0d
--- /dev/null
+++ b/ext/gd/tests/imagepng_nullbyte_injection.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Testing null byte injection in imagepng
+--CLEAN--
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+rmdir($tempdir);
+--SKIPIF--
+<?php
+$support = gd_info();
+if (!isset($support['PNG Support']) || $support['PNG Support'] === false) {
+ print 'skip png support not available';
+}
+?>
+--FILE--
+<?php
+$image = imagecreate(1,1);// 1px image
+
+
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+if (!file_exists($tempdir) && !is_dir($tempdir)) {
+ mkdir ($tempdir, 0777, true);
+}
+
+$userinput = "1\0"; // from post or get data
+$temp = $tempdir. "/test" . $userinput .".tmp";
+
+echo "\nimagepng TEST\n";
+imagepng($image, $temp);
+var_dump(file_exists($tempdir. "/test1"));
+var_dump(file_exists($tempdir. "/test1.tmp"));
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+
+--EXPECTF--
+imagepng TEST
+
+Warning: imagepng(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d
+bool(false)
+bool(false)
diff --git a/ext/gd/tests/imagewbmp_nullbyte_injection.phpt b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt
new file mode 100644
index 0000000000..f199626389
--- /dev/null
+++ b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Testing null byte injection in imagewbmp
+--CLEAN--
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+rmdir($tempdir);
+--SKIPIF--
+<?php
+$support = gd_info();
+if (!isset($support['WBMP Support']) || $support['WBMP Support'] === false) {
+ print 'skip wbmp support not available';
+}
+?>
+--FILE--
+<?php
+$image = imagecreate(1,1);// 1px image
+
+
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+if (!file_exists($tempdir) && !is_dir($tempdir)) {
+ mkdir ($tempdir, 0777, true);
+}
+
+$userinput = "1\0"; // from post or get data
+$temp = $tempdir. "/test" . $userinput .".tmp";
+
+echo "\nimagewbmp TEST\n";
+imagewbmp($image, $temp);
+var_dump(file_exists($tempdir. "/test1"));
+var_dump(file_exists($tempdir. "/test1.tmp"));
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+
+--EXPECTF--
+imagewbmp TEST
+
+Warning: imagewbmp(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d
+bool(false)
+bool(false)
diff --git a/ext/gd/tests/imagewebp_nullbyte_injection.phpt b/ext/gd/tests/imagewebp_nullbyte_injection.phpt
new file mode 100644
index 0000000000..3bd632591b
--- /dev/null
+++ b/ext/gd/tests/imagewebp_nullbyte_injection.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Testing null byte injection in imagewebp
+--CLEAN--
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+rmdir($tempdir);
+--SKIPIF--
+<?php
+$support = gd_info();
+if (!isset($support['WEBP Support']) || $support['WEBP Support'] === false) {
+ print 'skip webp support not available';
+}
+?>
+--FILE--
+<?php
+$image = imagecreate(1,1);// 1px image
+
+
+$tempdir = sys_get_temp_dir(). '/php-gdtest';
+if (!file_exists($tempdir) && !is_dir($tempdir)) {
+ mkdir ($tempdir, 0777, true);
+}
+
+$userinput = "1\0"; // from post or get data
+$temp = $tempdir. "/test" . $userinput .".tmp";
+
+echo "\nimagewebp TEST\n";
+imagewebp($image, $temp);
+var_dump(file_exists($tempdir. "/test1"));
+var_dump(file_exists($tempdir. "/test1.tmp"));
+foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
+
+--EXPECTF--
+imagewbmp TEST
+
+Warning: imagewebp(): Invalid 2nd parameter, filename must not contain null bytes in %s on line %d
+bool(false)
+bool(false)
diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c
index 1e07000c33..fa3032d4d8 100644
--- a/ext/gettext/gettext.c
+++ b/ext/gettext/gettext.c
@@ -226,7 +226,7 @@ PHP_NAMED_FUNCTION(zif_dcgettext)
{
char *domain, *msgid, *msgstr;
int domain_len, msgid_len;
- long category;
+ zend_long category;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &domain, &domain_len, &msgid, &msgid_len, &category) == FAILURE) {
return;
@@ -281,7 +281,7 @@ PHP_NAMED_FUNCTION(zif_ngettext)
{
char *msgid1, *msgid2, *msgstr;
int msgid1_len, msgid2_len;
- long count;
+ zend_long count;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &msgid1, &msgid1_len, &msgid2, &msgid2_len, &count) == FAILURE) {
return;
@@ -305,7 +305,7 @@ PHP_NAMED_FUNCTION(zif_dngettext)
{
char *domain, *msgid1, *msgid2, *msgstr = NULL;
int domain_len, msgid1_len, msgid2_len;
- long count;
+ zend_long count;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssl", &domain, &domain_len,
&msgid1, &msgid1_len, &msgid2, &msgid2_len, &count) == FAILURE) {
@@ -331,7 +331,7 @@ PHP_NAMED_FUNCTION(zif_dcngettext)
{
char *domain, *msgid1, *msgid2, *msgstr = NULL;
int domain_len, msgid1_len, msgid2_len;
- long count, category;
+ zend_long count, category;
RETVAL_FALSE;
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c
index 17ec39d087..18dd499fad 100644
--- a/ext/gmp/gmp.c
+++ b/ext/gmp/gmp.c
@@ -298,7 +298,7 @@ if (IS_GMP(zval)) { \
#define INIT_GMP_RETVAL(gmpnumber) \
gmp_create(return_value, &gmpnumber TSRMLS_CC)
-static void gmp_strval(zval *result, mpz_t gmpnum, long base);
+static void gmp_strval(zval *result, mpz_t gmpnum, zend_long base);
static int convert_to_gmp(mpz_t gmpnumber, zval *val, int base TSRMLS_DC);
static void gmp_cmp(zval *return_value, zval *a_arg, zval *b_arg TSRMLS_DC);
@@ -311,14 +311,14 @@ static void gmp_cmp(zval *return_value, zval *a_arg, zval *b_arg TSRMLS_DC);
typedef void (*gmp_unary_op_t)(mpz_ptr, mpz_srcptr);
typedef int (*gmp_unary_opl_t)(mpz_srcptr);
-typedef void (*gmp_unary_ui_op_t)(mpz_ptr, unsigned long);
+typedef void (*gmp_unary_ui_op_t)(mpz_ptr, zend_ulong);
typedef void (*gmp_binary_op_t)(mpz_ptr, mpz_srcptr, mpz_srcptr);
typedef int (*gmp_binary_opl_t)(mpz_srcptr, mpz_srcptr);
-typedef void (*gmp_binary_ui_op_t)(mpz_ptr, mpz_srcptr, unsigned long);
+typedef void (*gmp_binary_ui_op_t)(mpz_ptr, mpz_srcptr, zend_ulong);
typedef void (*gmp_binary_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);
-typedef void (*gmp_binary_ui_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long);
+typedef void (*gmp_binary_ui_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, zend_ulong);
static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval *b_arg, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op, int check_b_zero TSRMLS_DC);
static inline void gmp_zval_binary_ui_op2(zval *return_value, zval *a_arg, zval *b_arg, gmp_binary_op2_t gmp_op, gmp_binary_ui_op2_t gmp_ui_op, int check_b_zero TSRMLS_DC);
@@ -452,7 +452,7 @@ static zend_object *gmp_clone_obj(zval *obj TSRMLS_DC) /* {{{ */
/* }}} */
static void shift_operator_helper(gmp_binary_ui_op_t op, zval *return_value, zval *op1, zval *op2 TSRMLS_DC) {
- long shift = zval_get_long(op2);
+ zend_long shift = zval_get_long(op2);
if (shift < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Shift cannot be negative");
@@ -463,7 +463,7 @@ static void shift_operator_helper(gmp_binary_ui_op_t op, zval *return_value, zva
FETCH_GMP_ZVAL(gmpnum_op, op1, temp);
INIT_GMP_RETVAL(gmpnum_result);
- op(gmpnum_result, gmpnum_op, (unsigned long) shift);
+ op(gmpnum_result, gmpnum_op, (zend_ulong) shift);
FREE_GMP_TEMP(temp);
}
}
@@ -529,7 +529,7 @@ static int gmp_compare(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
}
/* }}} */
-static int gmp_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */
+static int gmp_serialize(zval *object, unsigned char **buffer, uint32_t *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */
{
mpz_ptr gmpnum = GET_GMP_FROM_ZVAL(object);
smart_str buf = {0};
@@ -550,13 +550,13 @@ static int gmp_serialize(zval *object, unsigned char **buffer, zend_uint *buf_le
PHP_VAR_SERIALIZE_DESTROY(serialize_data);
*buffer = (unsigned char *) estrndup(buf.s->val, buf.s->len);
*buf_len = buf.s->len;
- STR_RELEASE(buf.s);
+ zend_string_release(buf.s);
return SUCCESS;
}
/* }}} */
-static int gmp_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC) /* {{{ */
+static int gmp_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, uint32_t buf_len, zend_unserialize_data *data TSRMLS_DC) /* {{{ */
{
mpz_ptr gmpnum;
const unsigned char *p, *max;
@@ -719,7 +719,7 @@ static int convert_to_gmp(mpz_t gmpnumber, zval *val, int base TSRMLS_DC)
}
/* }}} */
-static void gmp_strval(zval *result, mpz_t gmpnum, long base) /* {{{ */
+static void gmp_strval(zval *result, mpz_t gmpnum, zend_long base) /* {{{ */
{
int num_len;
zend_string *str;
@@ -729,7 +729,7 @@ static void gmp_strval(zval *result, mpz_t gmpnum, long base) /* {{{ */
num_len++;
}
- str = STR_ALLOC(num_len, 0);
+ str = zend_string_alloc(num_len, 0);
mpz_get_str(str->val, base, gmpnum);
/*
@@ -755,7 +755,7 @@ static void gmp_cmp(zval *return_value, zval *a_arg, zval *b_arg TSRMLS_DC) /* {
mpz_ptr gmpnum_a, gmpnum_b;
gmp_temp_t temp_a, temp_b;
zend_bool use_si = 0;
- long res;
+ zend_long res;
FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a);
@@ -816,7 +816,7 @@ static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval *
INIT_GMP_RETVAL(gmpnum_result);
if (use_ui) {
- gmp_ui_op(gmpnum_result, gmpnum_a, (unsigned long) Z_LVAL_P(b_arg));
+ gmp_ui_op(gmpnum_result, gmpnum_a, (zend_ulong) Z_LVAL_P(b_arg));
} else {
gmp_op(gmpnum_result, gmpnum_a, gmpnum_b);
}
@@ -870,7 +870,7 @@ static inline void gmp_zval_binary_ui_op2(zval *return_value, zval *a_arg, zval
add_next_index_zval(return_value, &result2);
if (use_ui) {
- gmp_ui_op(gmpnum_result1, gmpnum_result2, gmpnum_a, (unsigned long) Z_LVAL_P(b_arg));
+ gmp_ui_op(gmpnum_result1, gmpnum_result2, gmpnum_a, (zend_ulong) Z_LVAL_P(b_arg));
} else {
gmp_op(gmpnum_result1, gmpnum_result2, gmpnum_a, gmpnum_b);
}
@@ -998,14 +998,14 @@ ZEND_FUNCTION(gmp_init)
{
zval *number_arg;
mpz_ptr gmpnumber;
- long base = 0;
+ zend_long base = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &number_arg, &base) == FAILURE) {
return;
}
if (base && (base < 2 || base > MAX_BASE)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and %d)", base, MAX_BASE);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %pd (should be between 2 and %d)", base, MAX_BASE);
RETURN_FALSE;
}
@@ -1040,7 +1040,7 @@ ZEND_FUNCTION(gmp_intval)
ZEND_FUNCTION(gmp_strval)
{
zval *gmpnumber_arg;
- long base = 10;
+ zend_long base = 10;
mpz_ptr gmpnum;
gmp_temp_t temp_a;
@@ -1052,10 +1052,10 @@ ZEND_FUNCTION(gmp_strval)
/* Although the maximum base in general in GMP >= 4.2 is 62, mpz_get_str()
* is explicitly limited to -36 when dealing with negative bases. */
if ((base < 2 && base > -2) || base > MAX_BASE || base < -36) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and %d or -2 and -36)", base, MAX_BASE);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %pd (should be between 2 and %d or -2 and -36)", base, MAX_BASE);
#else
if (base < 2 || base > MAX_BASE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and %d)", base, MAX_BASE);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %pd (should be between 2 and %d)", base, MAX_BASE);
#endif
RETURN_FALSE;
}
@@ -1097,7 +1097,7 @@ ZEND_FUNCTION(gmp_mul)
ZEND_FUNCTION(gmp_div_qr)
{
zval *a_arg, *b_arg;
- long round = GMP_ROUND_ZERO;
+ zend_long round = GMP_ROUND_ZERO;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|l", &a_arg, &b_arg, &round) == FAILURE) {
return;
@@ -1125,7 +1125,7 @@ ZEND_FUNCTION(gmp_div_qr)
ZEND_FUNCTION(gmp_div_r)
{
zval *a_arg, *b_arg;
- long round = GMP_ROUND_ZERO;
+ zend_long round = GMP_ROUND_ZERO;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|l", &a_arg, &b_arg, &round) == FAILURE) {
return;
@@ -1153,7 +1153,7 @@ ZEND_FUNCTION(gmp_div_r)
ZEND_FUNCTION(gmp_div_q)
{
zval *a_arg, *b_arg;
- long round = GMP_ROUND_ZERO;
+ zend_long round = GMP_ROUND_ZERO;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|l", &a_arg, &b_arg, &round) == FAILURE) {
return;
@@ -1243,7 +1243,7 @@ ZEND_FUNCTION(gmp_pow)
zval *base_arg;
mpz_ptr gmpnum_result, gmpnum_base;
gmp_temp_t temp_base;
- long exp;
+ zend_long exp;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &base_arg, &exp) == FAILURE) {
return;
@@ -1305,7 +1305,7 @@ ZEND_FUNCTION(gmp_powm)
INIT_GMP_RETVAL(gmpnum_result);
if (use_ui) {
- mpz_powm_ui(gmpnum_result, gmpnum_base, (unsigned long) Z_LVAL_P(exp_arg), gmpnum_mod);
+ mpz_powm_ui(gmpnum_result, gmpnum_base, (zend_ulong) Z_LVAL_P(exp_arg), gmpnum_mod);
} else {
mpz_powm(gmpnum_result, gmpnum_base, gmpnum_exp, gmpnum_mod);
FREE_GMP_TEMP(temp_exp);
@@ -1380,7 +1380,7 @@ ZEND_FUNCTION(gmp_sqrtrem)
ZEND_FUNCTION(gmp_root)
{
zval *a_arg;
- long nth;
+ zend_long nth;
mpz_ptr gmpnum_a, gmpnum_result;
gmp_temp_t temp_a;
@@ -1412,7 +1412,7 @@ ZEND_FUNCTION(gmp_root)
ZEND_FUNCTION(gmp_rootrem)
{
zval *a_arg;
- long nth;
+ zend_long nth;
mpz_ptr gmpnum_a, gmpnum_result1, gmpnum_result2;
gmp_temp_t temp_a;
zval result1, result2;
@@ -1479,7 +1479,7 @@ ZEND_FUNCTION(gmp_prob_prime)
{
zval *gmpnumber_arg;
mpz_ptr gmpnum_a;
- long reps = 10;
+ zend_long reps = 10;
gmp_temp_t temp_a;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &gmpnumber_arg, &reps) == FAILURE) {
@@ -1613,7 +1613,7 @@ ZEND_FUNCTION(gmp_sign)
Gets random number */
ZEND_FUNCTION(gmp_random)
{
- long limiter = 20;
+ zend_long limiter = 20;
mpz_ptr gmpnum_result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &limiter) == FAILURE) {
@@ -1684,7 +1684,7 @@ ZEND_FUNCTION(gmp_xor)
ZEND_FUNCTION(gmp_setbit)
{
zval *a_arg;
- long index;
+ zend_long index;
zend_bool set = 1;
mpz_ptr gmpnum_a;
@@ -1712,7 +1712,7 @@ ZEND_FUNCTION(gmp_setbit)
ZEND_FUNCTION(gmp_clrbit)
{
zval *a_arg;
- long index;
+ zend_long index;
mpz_ptr gmpnum_a;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ol", &a_arg, gmp_ce, &index) == FAILURE){
@@ -1734,7 +1734,7 @@ ZEND_FUNCTION(gmp_clrbit)
ZEND_FUNCTION(gmp_testbit)
{
zval *a_arg;
- long index;
+ zend_long index;
mpz_ptr gmpnum_a;
gmp_temp_t temp_a;
@@ -1776,7 +1776,7 @@ ZEND_FUNCTION(gmp_scan0)
zval *a_arg;
mpz_ptr gmpnum_a;
gmp_temp_t temp_a;
- long start;
+ zend_long start;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &a_arg, &start) == FAILURE){
return;
@@ -1801,7 +1801,7 @@ ZEND_FUNCTION(gmp_scan1)
zval *a_arg;
mpz_ptr gmpnum_a;
gmp_temp_t temp_a;
- long start;
+ zend_long start;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &a_arg, &start) == FAILURE){
return;
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index fe02cbe83f..ac03aa87ee 100644
--- a/ext/hash/hash.c
+++ b/ext/hash/hash.c
@@ -161,7 +161,7 @@ static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_
ops->hash_update(context, (unsigned char *) data, data_len);
}
- digest = STR_ALLOC(ops->digest_size, 0);
+ digest = zend_string_alloc(ops->digest_size, 0);
ops->hash_final((unsigned char *) digest->val, context);
efree(context);
@@ -169,11 +169,11 @@ static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_
digest->val[ops->digest_size] = 0;
RETURN_STR(digest);
} else {
- zend_string *hex_digest = STR_SAFE_ALLOC(ops->digest_size, 2, 0, 0);
+ zend_string *hex_digest = zend_string_safe_alloc(ops->digest_size, 2, 0, 0);
php_hash_bin2hex(hex_digest->val, (unsigned char *) digest->val, ops->digest_size);
hex_digest->val[2 * ops->digest_size] = 0;
- STR_RELEASE(digest);
+ zend_string_release(digest);
RETURN_STR(hex_digest);
}
}
@@ -225,7 +225,7 @@ static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops *
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) {
+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 zend_long data_size) {
ops->hash_init(context);
ops->hash_update(context, key, ops->block_size);
ops->hash_update(context, data, data_size);
@@ -264,7 +264,7 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename,
context = emalloc(ops->context_size);
K = emalloc(ops->block_size);
- digest = STR_ALLOC(ops->digest_size, 0);
+ digest = zend_string_alloc(ops->digest_size, 0);
php_hash_hmac_prep_key(K, ops, context, (unsigned char *) key, key_len);
@@ -295,11 +295,11 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename,
digest->val[ops->digest_size] = 0;
RETURN_STR(digest);
} else {
- zend_string *hex_digest = STR_SAFE_ALLOC(ops->digest_size, 2, 0, 0);
+ zend_string *hex_digest = zend_string_safe_alloc(ops->digest_size, 2, 0, 0);
php_hash_bin2hex(hex_digest->val, (unsigned char *) digest->val, ops->digest_size);
hex_digest->val[2 * ops->digest_size] = 0;
- STR_RELEASE(digest);
+ zend_string_release(digest);
RETURN_STR(hex_digest);
}
}
@@ -330,7 +330,7 @@ PHP_FUNCTION(hash_init)
{
char *algo, *key = NULL;
int algo_len, key_len = 0, argc = ZEND_NUM_ARGS();
- long options = 0;
+ zend_long options = 0;
void *context;
const php_hash_ops *ops;
php_hash_data *hash;
@@ -417,7 +417,7 @@ PHP_FUNCTION(hash_update_stream)
zval *zhash, *zstream;
php_hash_data *hash;
php_stream *stream = NULL;
- long length = -1, didread = 0;
+ zend_long length = -1, didread = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &zhash, &zstream, &length) == FAILURE) {
return;
@@ -428,7 +428,7 @@ PHP_FUNCTION(hash_update_stream)
while (length) {
char buf[1024];
- long n, toread = 1024;
+ zend_long n, toread = 1024;
if (length > 0 && toread > length) {
toread = length;
@@ -497,7 +497,7 @@ PHP_FUNCTION(hash_final)
ZEND_FETCH_RESOURCE(hash, php_hash_data*, zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
digest_len = hash->ops->digest_size;
- digest = STR_ALLOC(digest_len, 0);
+ digest = zend_string_alloc(digest_len, 0);
hash->ops->hash_final((unsigned char *) digest->val, hash->context);
if (hash->options & PHP_HASH_HMAC) {
int i;
@@ -534,11 +534,11 @@ PHP_FUNCTION(hash_final)
if (raw_output) {
RETURN_STR(digest);
} else {
- zend_string *hex_digest = STR_SAFE_ALLOC(digest_len, 2, 0, 0);
+ zend_string *hex_digest = zend_string_safe_alloc(digest_len, 2, 0, 0);
php_hash_bin2hex(hex_digest->val, (unsigned char *) digest->val, digest_len);
hex_digest->val[2 * digest_len] = 0;
- STR_RELEASE(digest);
+ zend_string_release(digest);
RETURN_STR(hex_digest);
}
}
@@ -589,7 +589,7 @@ PHP_FUNCTION(hash_algos)
array_init(return_value);
ZEND_HASH_FOREACH_STR_KEY(&php_hash_hashtable, str) {
- add_next_index_str(return_value, STR_COPY(str));
+ add_next_index_str(return_value, zend_string_copy(str));
} ZEND_HASH_FOREACH_END();
}
/* }}} */
@@ -602,7 +602,7 @@ PHP_FUNCTION(hash_pbkdf2)
zend_string *returnval;
char *algo, *salt, *pass = NULL;
unsigned char *computed_salt, *digest, *temp, *result, *K1, *K2 = NULL;
- long loops, i, j, algo_len, pass_len, iterations, length = 0, digest_length = 0;
+ zend_long loops, i, j, algo_len, pass_len, iterations, length = 0, digest_length = 0;
int salt_len = 0;
zend_bool raw_output = 0;
const php_hash_ops *ops;
@@ -619,12 +619,12 @@ PHP_FUNCTION(hash_pbkdf2)
}
if (iterations <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Iterations must be a positive integer: %ld", iterations);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Iterations must be a positive integer: " ZEND_LONG_FMT, 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);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to 0: " ZEND_LONG_FMT, length);
RETURN_FALSE;
}
@@ -655,10 +655,10 @@ PHP_FUNCTION(hash_pbkdf2)
}
digest_length = length;
if (!raw_output) {
- digest_length = (long) ceil((float) length / 2.0);
+ digest_length = (zend_long) ceil((float) length / 2.0);
}
- loops = (long) ceil((float) digest_length / (float) ops->digest_size);
+ loops = (zend_long) ceil((float) digest_length / (float) ops->digest_size);
result = safe_emalloc(loops, ops->digest_size, 0);
@@ -674,7 +674,7 @@ PHP_FUNCTION(hash_pbkdf2)
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, K1, computed_salt, (zend_long) salt_len + 4);
php_hash_hmac_round(digest, ops, context, K2, digest, ops->digest_size);
/* } */
@@ -707,7 +707,7 @@ PHP_FUNCTION(hash_pbkdf2)
efree(digest);
efree(temp);
- returnval = STR_ALLOC(length, 0);
+ returnval = zend_string_alloc(length, 0);
if (raw_output) {
memcpy(returnval->val, result, length);
} else {
@@ -829,14 +829,14 @@ static void mhash_init(INIT_FUNC_ARGS)
PHP_FUNCTION(mhash)
{
zval *z_algorithm;
- long algorithm;
+ zend_long algorithm;
if (zend_parse_parameters(1 TSRMLS_CC, "z", &z_algorithm) == FAILURE) {
return;
}
SEPARATE_ZVAL(z_algorithm);
- convert_to_long_ex(z_algorithm);
+ convert_to_int_ex(z_algorithm);
algorithm = Z_LVAL_P(z_algorithm);
/* need to convert the first parameter from int constant to string algorithm name */
@@ -861,7 +861,7 @@ PHP_FUNCTION(mhash)
Gets the name of hash */
PHP_FUNCTION(mhash_get_hash_name)
{
- long algorithm;
+ zend_long algorithm;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &algorithm) == FAILURE) {
return;
@@ -892,7 +892,7 @@ PHP_FUNCTION(mhash_count)
Gets the block size of hash */
PHP_FUNCTION(mhash_get_block_size)
{
- long algorithm;
+ zend_long algorithm;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &algorithm) == FAILURE) {
return;
@@ -917,7 +917,7 @@ PHP_FUNCTION(mhash_get_block_size)
Generates a key using hash functions */
PHP_FUNCTION(mhash_keygen_s2k)
{
- long algorithm, l_bytes;
+ zend_long algorithm, l_bytes;
int bytes;
char *password, *salt;
int password_len, salt_len;
diff --git a/ext/hash/php_hash.h b/ext/hash/php_hash.h
index c75b930936..42c559d971 100644
--- a/ext/hash/php_hash.h
+++ b/ext/hash/php_hash.h
@@ -55,7 +55,7 @@ typedef struct _php_hash_data {
const php_hash_ops *ops;
void *context;
- long options;
+ zend_long options;
unsigned char *key;
} php_hash_data;
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 39c5b314a8..d8d132578f 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -60,7 +60,7 @@
#include "ext/standard/quot_print.h"
#define _php_iconv_memequal(a, b, c) \
- ((c) == sizeof(unsigned long) ? *((unsigned long *)(a)) == *((unsigned long *)(b)) : ((c) == sizeof(unsigned int) ? *((unsigned int *)(a)) == *((unsigned int *)(b)) : memcmp(a, b, c) == 0))
+ ((c) == sizeof(zend_ulong) ? *((zend_ulong *)(a)) == *((zend_ulong *)(b)) : ((c) == sizeof(unsigned int) ? *((unsigned int *)(a)) == *((unsigned int *)(b)) : memcmp(a, b, c) == 0))
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_strlen, 0, 0, 1)
@@ -196,13 +196,13 @@ static php_iconv_err_t _php_iconv_appendc(smart_str *d, const char c, iconv_t cd
static void _php_iconv_show_error(php_iconv_err_t err, const char *out_charset, const char *in_charset TSRMLS_DC);
-static php_iconv_err_t _php_iconv_strlen(unsigned int *pretval, const char *str, size_t nbytes, const char *enc);
+static php_iconv_err_t _php_iconv_strlen(size_t *pretval, const char *str, size_t nbytes, const char *enc);
-static php_iconv_err_t _php_iconv_substr(smart_str *pretval, const char *str, size_t nbytes, int offset, int len, const char *enc);
+static php_iconv_err_t _php_iconv_substr(smart_str *pretval, const char *str, size_t nbytes, zend_long offset, zend_long len, const char *enc);
-static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval, const char *haystk, size_t haystk_nbytes, const char *ndl, size_t ndl_nbytes, int offset, const char *enc);
+static php_iconv_err_t _php_iconv_strpos(size_t *pretval, const char *haystk, size_t haystk_nbytes, const char *ndl, size_t ndl_nbytes, zend_long offset, const char *enc);
-static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fname, size_t fname_nbytes, const char *fval, size_t fval_nbytes, unsigned int max_line_len, const char *lfchars, php_iconv_enc_scheme_t enc_scheme, const char *out_charset, const char *enc);
+static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fname, size_t fname_nbytes, const char *fval, size_t fval_nbytes, size_t max_line_len, const char *lfchars, php_iconv_enc_scheme_t enc_scheme, const char *out_charset, const char *enc);
static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *str, size_t str_nbytes, const char *enc, const char **next_pos, int mode);
@@ -431,13 +431,13 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
}
if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) {
- int len;
+ zend_long len;
char *p = strstr(get_output_encoding(TSRMLS_C), "//");
if (p) {
- len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len ? mimetype_len : (int) strlen(mimetype), mimetype, (int)(p - get_output_encoding(TSRMLS_C)), get_output_encoding(TSRMLS_C));
+ len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len ? mimetype_len : (size_t) strlen(mimetype), mimetype, (size_t)(p - get_output_encoding(TSRMLS_C)), get_output_encoding(TSRMLS_C));
} else {
- len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%s", mimetype_len ? mimetype_len : (int) strlen(mimetype), mimetype, get_output_encoding(TSRMLS_C));
+ len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%s", mimetype_len ? mimetype_len : (size_t) strlen(mimetype), mimetype, get_output_encoding(TSRMLS_C));
}
if (content_type && SUCCESS == sapi_add_header(content_type, len, 0)) {
SG(sapi_headers).send_default_content_type = 0;
@@ -453,7 +453,7 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
if (out) {
output_context->out.data = estrndup(out->val, out->len);
output_context->out.used = out->len;
- STR_FREE(out);
+ zend_string_free(out);
} else {
output_context->out.data = NULL;
output_context->out.used = 0;
@@ -580,7 +580,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
return PHP_ICONV_ERR_UNKNOWN;
}
- out_buffer = STR_ALLOC(out_size, 0);
+ out_buffer = zend_string_alloc(out_size, 0);
out_p = out_buffer->val;
#ifdef NETWARE
@@ -591,13 +591,13 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
&out_p, &out_left);
if (result == (size_t)(-1)) {
- STR_FREE(out_buffer);
+ zend_string_free(out_buffer);
return PHP_ICONV_ERR_UNKNOWN;
}
if (out_left < 8) {
- size_t pos = out_p - out_buffer;
- out_buffer = STR_REALLOC(out_buffer, out_size + 8, 0);
+ size_t pos = out_p - out_buffer->val;
+ out_buffer = zend_string_realloc(out_buffer, out_size + 8, 0);
out_p = out_buffer->val + pos;
out_size += 7;
out_left += 7;
@@ -607,7 +607,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
result = iconv(cd, NULL, NULL, &out_p, &out_left);
if (result == (size_t)(-1)) {
- STR_FREE(out_buffer);
+ zend_string_free(out_buffer);
return PHP_ICONV_ERR_UNKNOWN;
}
@@ -645,7 +645,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
out_left = in_len + 32; /* Avoid realloc() most cases */
out_size = 0;
bsz = out_left;
- out_buf = STR_ALLOC(bsz, 0);
+ out_buf = zend_string_alloc(bsz, 0);
out_p = out_buf->val;
while (in_left > 0) {
@@ -656,7 +656,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
/* converted string is longer than out buffer */
bsz += in_len;
- out_buf = STR_REALLOC(out_buf, bsz, 0);
+ out_buf = zend_string_realloc(out_buf, bsz, 0);
out_p = out_buf->val;
out_p += out_size;
out_left = bsz - out_size;
@@ -678,7 +678,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
if (errno == E2BIG) {
bsz += 16;
- out_buf = STR_REALLOC(out_buf, bsz, 0);
+ out_buf = zend_string_realloc(out_buf, bsz, 0);
out_p = out_buf->val;
out_p += out_size;
out_left = bsz - out_size;
@@ -708,7 +708,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
default:
/* other error */
retval = PHP_ICONV_ERR_UNKNOWN;
- STR_FREE(out_buf);
+ zend_string_free(out_buf);
return PHP_ICONV_ERR_UNKNOWN;
}
}
@@ -721,7 +721,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
/* }}} */
/* {{{ _php_iconv_strlen() */
-static php_iconv_err_t _php_iconv_strlen(unsigned int *pretval, const char *str, size_t nbytes, const char *enc)
+static php_iconv_err_t _php_iconv_strlen(size_t *pretval, const char *str, size_t nbytes, const char *enc)
{
char buf[GENERIC_SUPERSET_NBYTES*2];
@@ -735,9 +735,9 @@ static php_iconv_err_t _php_iconv_strlen(unsigned int *pretval, const char *str,
char *out_p;
size_t out_left;
- unsigned int cnt;
+ size_t cnt;
- *pretval = (unsigned int)-1;
+ *pretval = (size_t)-1;
cd = iconv_open(GENERIC_SUPERSET_NAME, enc);
@@ -753,7 +753,8 @@ static php_iconv_err_t _php_iconv_strlen(unsigned int *pretval, const char *str,
#endif
}
- errno = out_left = 0;
+ errno = 0;
+ out_left = 0;
for (in_p = str, in_left = nbytes, cnt = 0; in_left > 0; cnt+=2) {
size_t prev_in_left;
@@ -805,7 +806,7 @@ static php_iconv_err_t _php_iconv_strlen(unsigned int *pretval, const char *str,
/* {{{ _php_iconv_substr() */
static php_iconv_err_t _php_iconv_substr(smart_str *pretval,
- const char *str, size_t nbytes, int offset, int len, const char *enc)
+ const char *str, size_t nbytes, zend_long offset, zend_long len, const char *enc)
{
char buf[GENERIC_SUPERSET_NBYTES];
@@ -819,8 +820,8 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval,
char *out_p;
size_t out_left;
- unsigned int cnt;
- int total_len;
+ size_t cnt;
+ zend_long total_len;
err = _php_iconv_strlen(&total_len, str, nbytes, enc);
if (err != PHP_ICONV_ERR_SUCCESS) {
@@ -889,7 +890,7 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval,
}
}
- if (cnt >= (unsigned int)offset) {
+ if ((zend_long)cnt >= offset) {
if (cd2 == (iconv_t)NULL) {
cd2 = iconv_open(enc, GENERIC_SUPERSET_NAME);
@@ -950,10 +951,10 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval,
/* }}} */
/* {{{ _php_iconv_strpos() */
-static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
+static php_iconv_err_t _php_iconv_strpos(size_t *pretval,
const char *haystk, size_t haystk_nbytes,
const char *ndl, size_t ndl_nbytes,
- int offset, const char *enc)
+ zend_long offset, const char *enc)
{
char buf[GENERIC_SUPERSET_NBYTES];
@@ -967,21 +968,21 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
char *out_p;
size_t out_left;
- unsigned int cnt;
+ size_t cnt;
zend_string *ndl_buf;
const char *ndl_buf_p;
size_t ndl_buf_left;
- unsigned int match_ofs;
+ size_t match_ofs;
- *pretval = (unsigned int)-1;
+ *pretval = (size_t)-1;
err = php_iconv_string(ndl, ndl_nbytes, &ndl_buf, GENERIC_SUPERSET_NAME, enc);
if (err != PHP_ICONV_ERR_SUCCESS) {
if (ndl_buf != NULL) {
- STR_FREE(ndl_buf);
+ zend_string_free(ndl_buf);
}
return err;
}
@@ -990,7 +991,7 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
if (cd == (iconv_t)(-1)) {
if (ndl_buf != NULL) {
- STR_FREE(ndl_buf);
+ zend_string_free(ndl_buf);
}
#if ICONV_SUPPORTS_ERRNO
if (errno == EINVAL) {
@@ -1005,7 +1006,7 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
ndl_buf_p = ndl_buf->val;
ndl_buf_left = ndl_buf->len;
- match_ofs = (unsigned int)-1;
+ match_ofs = (size_t)-1;
for (in_p = haystk, in_left = haystk_nbytes, cnt = 0; in_left > 0; ++cnt) {
size_t prev_in_left;
@@ -1038,9 +1039,9 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
}
}
if (offset >= 0) {
- if (cnt >= (unsigned int)offset) {
+ if (cnt >= (size_t)offset) {
if (_php_iconv_memequal(buf, ndl_buf_p, sizeof(buf))) {
- if (match_ofs == (unsigned int)-1) {
+ if (match_ofs == (size_t)-1) {
match_ofs = cnt;
}
ndl_buf_p += GENERIC_SUPERSET_NBYTES;
@@ -1050,11 +1051,11 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
break;
}
} else {
- unsigned int i, j, lim;
+ size_t i, j, lim;
i = 0;
j = GENERIC_SUPERSET_NBYTES;
- lim = (unsigned int)(ndl_buf_p - ndl_buf->val);
+ lim = (size_t)(ndl_buf_p - ndl_buf->val);
while (j < lim) {
if (_php_iconv_memequal(&ndl_buf->val[j], &ndl_buf->val[i],
@@ -1073,7 +1074,7 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
ndl_buf_p = &ndl_buf->val[i];
ndl_buf_left = ndl_buf->len - i;
} else {
- match_ofs = (unsigned int)-1;
+ match_ofs = (size_t)-1;
ndl_buf_p = ndl_buf->val;
ndl_buf_left = ndl_buf->len;
}
@@ -1081,7 +1082,7 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
}
} else {
if (_php_iconv_memequal(buf, ndl_buf_p, sizeof(buf))) {
- if (match_ofs == (unsigned int)-1) {
+ if (match_ofs == (size_t)-1) {
match_ofs = cnt;
}
ndl_buf_p += GENERIC_SUPERSET_NBYTES;
@@ -1093,11 +1094,11 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
match_ofs = -1;
}
} else {
- unsigned int i, j, lim;
+ size_t i, j, lim;
i = 0;
j = GENERIC_SUPERSET_NBYTES;
- lim = (unsigned int)(ndl_buf_p - ndl_buf->val);
+ lim = (size_t)(ndl_buf_p - ndl_buf->val);
while (j < lim) {
if (_php_iconv_memequal(&ndl_buf->val[j], &ndl_buf->val[i],
@@ -1116,7 +1117,7 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
ndl_buf_p = &ndl_buf->val[i];
ndl_buf_left = ndl_buf->len - i;
} else {
- match_ofs = (unsigned int)-1;
+ match_ofs = (size_t)-1;
ndl_buf_p = ndl_buf->val;
ndl_buf_left = ndl_buf->len;
}
@@ -1125,7 +1126,7 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
}
if (ndl_buf) {
- STR_FREE(ndl_buf);
+ zend_string_free(ndl_buf);
}
iconv_close(cd);
@@ -1135,11 +1136,11 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
/* }}} */
/* {{{ _php_iconv_mime_encode() */
-static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fname, size_t fname_nbytes, const char *fval, size_t fval_nbytes, unsigned int max_line_len, const char *lfchars, php_iconv_enc_scheme_t enc_scheme, const char *out_charset, const char *enc)
+static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fname, size_t fname_nbytes, const char *fval, size_t fval_nbytes, size_t max_line_len, const char *lfchars, php_iconv_enc_scheme_t enc_scheme, const char *out_charset, const char *enc)
{
php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS;
iconv_t cd = (iconv_t)(-1), cd_pl = (iconv_t)(-1);
- unsigned int char_cnt = 0;
+ size_t char_cnt = 0;
size_t out_charset_len;
size_t lfchars_len;
char *buf = NULL;
@@ -1321,7 +1322,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn
prev_in_left = in_left;
- encoded = php_base64_encode((unsigned char *) buf, (int)(out_size - out_left));
+ encoded = php_base64_encode((unsigned char *) buf, (out_size - out_left));
if (char_cnt < encoded->len) {
/* something went wrong! */
@@ -1334,7 +1335,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn
smart_str_appendl(pretval, "?=", sizeof("?=") - 1);
char_cnt -= 2;
- STR_RELEASE(encoded);
+ zend_string_release(encoded);
encoded = NULL;
} break; /* case PHP_ICONV_ENC_SCHEME_BASE64: */
@@ -1453,7 +1454,7 @@ out:
iconv_close(cd_pl);
}
if (encoded != NULL) {
- STR_RELEASE(encoded);
+ zend_string_release(encoded);
}
if (buf != NULL) {
efree(buf);
@@ -1803,11 +1804,11 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
switch (enc_scheme) {
case PHP_ICONV_ENC_SCHEME_BASE64:
- decoded_text = php_base64_decode((unsigned char*)encoded_text, (int)encoded_text_len);
+ decoded_text = php_base64_decode((unsigned char*)encoded_text, encoded_text_len);
break;
case PHP_ICONV_ENC_SCHEME_QPRINT:
- decoded_text = php_quot_print_decode((unsigned char*)encoded_text, (int)encoded_text_len, 1);
+ decoded_text = php_quot_print_decode((unsigned char*)encoded_text, encoded_text_len, 1);
break;
default:
decoded_text = NULL;
@@ -1835,7 +1836,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
}
err = _php_iconv_appendl(pretval, decoded_text->val, decoded_text->len, cd);
- STR_RELEASE(decoded_text);
+ zend_string_release(decoded_text);
if (err != PHP_ICONV_ERR_SUCCESS) {
if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {
@@ -2034,15 +2035,14 @@ PHP_FUNCTION(iconv_strlen)
{
char *charset = get_internal_encoding(TSRMLS_C);
int charset_len = 0;
- char *str;
- int str_len;
+ zend_string *str;
php_iconv_err_t err;
- unsigned int retval;
+ size_t retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
- &str, &str_len, &charset, &charset_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|s",
+ &str, &charset, &charset_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2051,7 +2051,7 @@ PHP_FUNCTION(iconv_strlen)
RETURN_FALSE;
}
- err = _php_iconv_strlen(&retval, str, str_len, charset);
+ err = _php_iconv_strlen(&retval, str->val, str->len, charset);
_php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);
if (err == PHP_ICONV_ERR_SUCCESS) {
RETVAL_LONG(retval);
@@ -2067,16 +2067,15 @@ PHP_FUNCTION(iconv_substr)
{
char *charset = get_internal_encoding(TSRMLS_C);
int charset_len = 0;
- char *str;
- int str_len;
- long offset, length = 0;
+ zend_string *str;
+ zend_long offset, length = 0;
php_iconv_err_t err;
smart_str retval = {0};
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|ls",
- &str, &str_len, &offset, &length,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl|ls",
+ &str, &offset, &length,
&charset, &charset_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2087,13 +2086,13 @@ PHP_FUNCTION(iconv_substr)
}
if (ZEND_NUM_ARGS() < 3) {
- length = str_len;
+ length = str->len;
}
- err = _php_iconv_substr(&retval, str, str_len, offset, length, charset);
+ err = _php_iconv_substr(&retval, str->val, str->len, offset, length, charset);
_php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);
- if (err == PHP_ICONV_ERR_SUCCESS && str != NULL && retval.s != NULL) {
+ if (err == PHP_ICONV_ERR_SUCCESS && str->val != NULL && retval.s != NULL) {
RETURN_STR(retval.s);
}
smart_str_free(&retval);
@@ -2107,18 +2106,16 @@ PHP_FUNCTION(iconv_strpos)
{
char *charset = get_internal_encoding(TSRMLS_C);
int charset_len = 0;
- char *haystk;
- int haystk_len;
- char *ndl;
- int ndl_len;
- long offset = 0;
+ zend_string *haystk;
+ zend_string *ndl;
+ zend_long offset = 0;
php_iconv_err_t err;
- unsigned int retval;
+ size_t retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ls",
- &haystk, &haystk_len, &ndl, &ndl_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|ls",
+ &haystk, &ndl,
&offset, &charset, &charset_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2133,16 +2130,16 @@ PHP_FUNCTION(iconv_strpos)
RETURN_FALSE;
}
- if (ndl_len < 1) {
+ if (ndl->len < 1) {
RETURN_FALSE;
}
- err = _php_iconv_strpos(&retval, haystk, haystk_len, ndl, ndl_len,
+ err = _php_iconv_strpos(&retval, haystk->val, haystk->len, ndl->val, ndl->len,
offset, charset);
_php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);
- if (err == PHP_ICONV_ERR_SUCCESS && retval != (unsigned int)-1) {
- RETVAL_LONG((long)retval);
+ if (err == PHP_ICONV_ERR_SUCCESS && retval != (size_t)-1) {
+ RETVAL_LONG((zend_long)retval);
} else {
RETVAL_FALSE;
}
@@ -2155,22 +2152,20 @@ PHP_FUNCTION(iconv_strrpos)
{
char *charset = get_internal_encoding(TSRMLS_C);
int charset_len = 0;
- char *haystk;
- int haystk_len;
- char *ndl;
- int ndl_len;
+ zend_string *haystk;
+ zend_string *ndl;
php_iconv_err_t err;
- unsigned int retval;
+ size_t retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s",
- &haystk, &haystk_len, &ndl, &ndl_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|s",
+ &haystk, &ndl,
&charset, &charset_len) == FAILURE) {
RETURN_FALSE;
}
- if (ndl_len < 1) {
+ if (ndl->len < 1) {
RETURN_FALSE;
}
@@ -2179,12 +2174,12 @@ PHP_FUNCTION(iconv_strrpos)
RETURN_FALSE;
}
- err = _php_iconv_strpos(&retval, haystk, haystk_len, ndl, ndl_len,
+ err = _php_iconv_strpos(&retval, haystk->val, haystk->len, ndl->val, ndl->len,
-1, charset);
_php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);
- if (err == PHP_ICONV_ERR_SUCCESS && retval != (unsigned int)-1) {
- RETVAL_LONG((long)retval);
+ if (err == PHP_ICONV_ERR_SUCCESS && retval != (size_t)-1) {
+ RETVAL_LONG((zend_long)retval);
} else {
RETVAL_FALSE;
}
@@ -2195,10 +2190,8 @@ PHP_FUNCTION(iconv_strrpos)
Composes a mime header field with field_name and field_value in a specified scheme */
PHP_FUNCTION(iconv_mime_encode)
{
- const char *field_name = NULL;
- int field_name_len;
- const char *field_value = NULL;
- int field_value_len;
+ zend_string *field_name = NULL;
+ zend_string *field_value = NULL;
zval *pref = NULL;
zval tmp_zv, *tmp_zv_p = NULL;
smart_str retval = {0};
@@ -2206,12 +2199,12 @@ PHP_FUNCTION(iconv_mime_encode)
const char *in_charset = get_internal_encoding(TSRMLS_C);
const char *out_charset = in_charset;
- long line_len = 76;
+ zend_long line_len = 76;
const char *lfchars = "\r\n";
php_iconv_enc_scheme_t scheme_id = PHP_ICONV_ENC_SCHEME_BASE64;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|a",
- &field_name, &field_name_len, &field_value, &field_value_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|a",
+ &field_name, &field_value,
&pref) == FAILURE) {
RETURN_FALSE;
@@ -2262,7 +2255,7 @@ PHP_FUNCTION(iconv_mime_encode)
if (Z_TYPE_P(pzval) != IS_LONG) {
ZVAL_DUP(&val, pzval);
- convert_to_long(&val);
+ convert_to_int(&val);
pzval = &val;
}
@@ -2283,8 +2276,8 @@ PHP_FUNCTION(iconv_mime_encode)
}
}
- err = _php_iconv_mime_encode(&retval, field_name, field_name_len,
- field_value, field_value_len, line_len, lfchars, scheme_id,
+ err = _php_iconv_mime_encode(&retval, field_name->val, field_name->len,
+ field_value->val, field_value->len, line_len, lfchars, scheme_id,
out_charset, in_charset);
_php_iconv_show_error(err, out_charset, in_charset TSRMLS_CC);
@@ -2309,18 +2302,17 @@ PHP_FUNCTION(iconv_mime_encode)
Decodes a mime header field */
PHP_FUNCTION(iconv_mime_decode)
{
- char *encoded_str;
- int encoded_str_len;
+ zend_string *encoded_str;
char *charset = get_internal_encoding(TSRMLS_C);
int charset_len = 0;
- long mode = 0;
+ zend_long mode = 0;
smart_str retval = {0};
php_iconv_err_t err;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",
- &encoded_str, &encoded_str_len, &mode, &charset, &charset_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|ls",
+ &encoded_str, &mode, &charset, &charset_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2330,7 +2322,7 @@ PHP_FUNCTION(iconv_mime_decode)
RETURN_FALSE;
}
- err = _php_iconv_mime_decode(&retval, encoded_str, encoded_str_len, charset, NULL, mode);
+ err = _php_iconv_mime_decode(&retval, encoded_str->val, encoded_str->len, charset, NULL, mode);
_php_iconv_show_error(err, charset, "???" TSRMLS_CC);
if (err == PHP_ICONV_ERR_SUCCESS) {
@@ -2350,16 +2342,17 @@ PHP_FUNCTION(iconv_mime_decode)
Decodes multiple mime header fields */
PHP_FUNCTION(iconv_mime_decode_headers)
{
- const char *encoded_str;
- int encoded_str_len;
+ zend_string *encoded_str;
char *charset = get_internal_encoding(TSRMLS_C);
int charset_len = 0;
- long mode = 0;
+ zend_long mode = 0;
+ char *enc_str_tmp;
+ size_t enc_str_len_tmp;
php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",
- &encoded_str, &encoded_str_len, &mode, &charset, &charset_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|ls",
+ &encoded_str, &mode, &charset, &charset_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2371,7 +2364,9 @@ PHP_FUNCTION(iconv_mime_decode_headers)
array_init(return_value);
- while (encoded_str_len > 0) {
+ enc_str_tmp = encoded_str->val;
+ enc_str_len_tmp = encoded_str->len;
+ while (enc_str_len_tmp > 0) {
smart_str decoded_header = {0};
char *header_name = NULL;
size_t header_name_len = 0;
@@ -2380,7 +2375,7 @@ PHP_FUNCTION(iconv_mime_decode_headers)
char *p, *limit;
const char *next_pos;
- if (PHP_ICONV_ERR_SUCCESS != (err = _php_iconv_mime_decode(&decoded_header, encoded_str, encoded_str_len, charset, &next_pos, mode))) {
+ if (PHP_ICONV_ERR_SUCCESS != (err = _php_iconv_mime_decode(&decoded_header, enc_str_tmp, enc_str_len_tmp, charset, &next_pos, mode))) {
smart_str_free(&decoded_header);
break;
}
@@ -2427,8 +2422,8 @@ PHP_FUNCTION(iconv_mime_decode_headers)
add_assoc_stringl_ex(return_value, header_name, header_name_len, header_value, header_value_len);
}
}
- encoded_str_len -= next_pos - encoded_str;
- encoded_str = next_pos;
+ enc_str_len_tmp -= next_pos - enc_str_tmp;
+ enc_str_tmp = next_pos;
smart_str_free(&decoded_header);
}
@@ -2445,13 +2440,14 @@ PHP_FUNCTION(iconv_mime_decode_headers)
Returns str converted to the out_charset character set */
PHP_NAMED_FUNCTION(php_if_iconv)
{
- char *in_charset, *out_charset, *in_buffer;
- int in_charset_len = 0, out_charset_len = 0, in_buffer_len;
+ char *in_charset, *out_charset;
+ zend_string *in_buffer;
+ int in_charset_len = 0, out_charset_len = 0;
php_iconv_err_t err;
zend_string *out_buffer;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss",
- &in_charset, &in_charset_len, &out_charset, &out_charset_len, &in_buffer, &in_buffer_len) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssS",
+ &in_charset, &in_charset_len, &out_charset, &out_charset_len, &in_buffer) == FAILURE)
return;
if (in_charset_len >= ICONV_CSNMAXLEN || out_charset_len >= ICONV_CSNMAXLEN) {
@@ -2459,13 +2455,13 @@ PHP_NAMED_FUNCTION(php_if_iconv)
RETURN_FALSE;
}
- err = php_iconv_string(in_buffer, (size_t)in_buffer_len, &out_buffer, out_charset, in_charset);
+ err = php_iconv_string(in_buffer->val, (size_t)in_buffer->len, &out_buffer, out_charset, in_charset);
_php_iconv_show_error(err, out_charset, in_charset TSRMLS_CC);
if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) {
RETVAL_STR(out_buffer);
} else {
if (out_buffer != NULL) {
- STR_FREE(out_buffer);
+ zend_string_free(out_buffer);
}
RETURN_FALSE;
}
@@ -2489,17 +2485,17 @@ PHP_FUNCTION(iconv_set_encoding)
}
if(!strcasecmp("input_encoding", type)) {
- name = STR_INIT("iconv.input_encoding", sizeof("iconv.input_encoding") - 1, 0);
+ name = zend_string_init("iconv.input_encoding", sizeof("iconv.input_encoding") - 1, 0);
} else if(!strcasecmp("output_encoding", type)) {
- name = STR_INIT("iconv.output_encoding", sizeof("iconv.output_encoding") - 1, 0);
+ name = zend_string_init("iconv.output_encoding", sizeof("iconv.output_encoding") - 1, 0);
} else if(!strcasecmp("internal_encoding", type)) {
- name = STR_INIT("iconv.internal_encoding", sizeof("iconv.internal_encoding") - 1, 0);
+ name = zend_string_init("iconv.internal_encoding", sizeof("iconv.internal_encoding") - 1, 0);
} else {
RETURN_FALSE;
}
retval = zend_alter_ini_entry(name, charset, charset_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(name);
+ zend_string_release(name);
if (retval == SUCCESS) {
RETURN_TRUE;
@@ -2514,7 +2510,7 @@ PHP_FUNCTION(iconv_set_encoding)
PHP_FUNCTION(iconv_get_encoding)
{
char *type = "all";
- int type_len = sizeof("all")-1;
+ size_t type_len = sizeof("all")-1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type, &type_len) == FAILURE)
return;
diff --git a/ext/iconv/tests/iconv_strpos_variation3_64bit.phpt b/ext/iconv/tests/iconv_strpos_variation3_64bit.phpt
index 1cc8a84f73..f1807ccd79 100644
--- a/ext/iconv/tests/iconv_strpos_variation3_64bit.phpt
+++ b/ext/iconv/tests/iconv_strpos_variation3_64bit.phpt
@@ -130,7 +130,7 @@ Warning: iconv_strpos(): Offset not contained in string. in %s on line %d
bool(false)
-- Iteration 7 --
-int(8)
+bool(false)
-- Iteration 8 --
int(8)
@@ -196,4 +196,4 @@ int(8)
Warning: iconv_strpos() expects parameter 3 to be long, resource given in %s on line %d
bool(false)
-Done \ No newline at end of file
+Done
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index 09295a87f3..7e56de668a 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -1326,16 +1326,16 @@ PHP_FUNCTION(imap_append)
return;
}
- regex = STR_INIT("/[0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/", sizeof("/[0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/") - 1, 0);
+ regex = zend_string_init("/[0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/", sizeof("/[0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/") - 1, 0);
if (internal_date) {
/* Make sure the given internal_date string matches the RFC specifiedformat */
if ((pce = pcre_get_compiled_regex_cache(regex TSRMLS_CC))== NULL) {
- STR_FREE(regex);
+ zend_string_free(regex);
RETURN_FALSE;
}
- STR_FREE(regex);
+ zend_string_free(regex);
php_pcre_match_impl(pce, internal_date, internal_date_len, return_value, subpats, global,
0, regex_flags, start_offset TSRMLS_CC);
@@ -2929,7 +2929,7 @@ PHP_FUNCTION(imap_utf7_encode)
}
/* allocate output buffer */
- out = STR_ALLOC(outlen, 0);
+ out = zend_string_alloc(outlen, 0);
/* encode input string */
outp = (unsigned char*)out->val;
@@ -3553,11 +3553,11 @@ PHP_FUNCTION(imap_mail_compose)
topbod = bod;
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "type", sizeof("type") - 1)) != NULL) {
- convert_to_long_ex(pvalue);
+ convert_to_int_ex(pvalue);
bod->type = (short) Z_LVAL_P(pvalue);
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "encoding", sizeof("encoding") - 1)) != NULL) {
- convert_to_long_ex(pvalue);
+ convert_to_int_ex(pvalue);
bod->encoding = (short) Z_LVAL_P(pvalue);
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "charset", sizeof("charset") - 1)) != NULL) {
@@ -3626,11 +3626,11 @@ PHP_FUNCTION(imap_mail_compose)
bod->contents.text.size = 0;
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "lines", sizeof("lines") - 1)) != NULL) {
- convert_to_long_ex(pvalue);
+ convert_to_int_ex(pvalue);
bod->size.lines = Z_LVAL_P(pvalue);
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "bytes", sizeof("bytes") - 1)) != NULL) {
- convert_to_long_ex(pvalue);
+ convert_to_int_ex(pvalue);
bod->size.bytes = Z_LVAL_P(pvalue);
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "md5", sizeof("md5") - 1)) != NULL) {
@@ -3640,7 +3640,7 @@ PHP_FUNCTION(imap_mail_compose)
} else if (Z_TYPE_P(data) == IS_ARRAY) {
short type = -1;
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "type", sizeof("type") - 1)) != NULL) {
- convert_to_long_ex(pvalue);
+ convert_to_int_ex(pvalue);
type = (short) Z_LVAL_P(pvalue);
}
@@ -3660,7 +3660,7 @@ PHP_FUNCTION(imap_mail_compose)
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "encoding", sizeof("encoding") - 1)) != NULL) {
- convert_to_long_ex(pvalue);
+ convert_to_int_ex(pvalue);
bod->encoding = (short) Z_LVAL_P(pvalue);
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "charset", sizeof("charset") - 1)) != NULL) {
@@ -3730,11 +3730,11 @@ PHP_FUNCTION(imap_mail_compose)
bod->contents.text.size = 0;
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "lines", sizeof("lines") - 1)) != NULL) {
- convert_to_long_ex(pvalue);
+ convert_to_int_ex(pvalue);
bod->size.lines = Z_LVAL_P(pvalue);
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "bytes", sizeof("bytes") - 1)) != NULL) {
- convert_to_long_ex(pvalue);
+ convert_to_int_ex(pvalue);
bod->size.bytes = Z_LVAL_P(pvalue);
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "md5", sizeof("md5") - 1)) != NULL) {
@@ -4390,7 +4390,7 @@ static zend_string* _php_rfc822_write_address(ADDRESS *addresslist TSRMLS_DC)
}
address[0] = 0;
rfc822_write_address(address, addresslist);
- return STR_INIT(address, strlen(address), 0);
+ return zend_string_init(address, strlen(address), 0);
}
/* }}} */
#endif
diff --git a/ext/interbase/ibase_blobs.c b/ext/interbase/ibase_blobs.c
index 8b8d731d7b..ac7d69363b 100644
--- a/ext/interbase/ibase_blobs.c
+++ b/ext/interbase/ibase_blobs.c
@@ -337,7 +337,7 @@ PHP_FUNCTION(ibase_blob_get)
RETURN_FALSE;
}
- convert_to_long_ex(len_arg);
+ convert_to_int_ex(len_arg);
if (_php_ibase_blob_get(return_value, ib_blob, Z_LVAL_P(len_arg) TSRMLS_CC) != SUCCESS) {
RETURN_FALSE;
diff --git a/ext/interbase/ibase_events.c b/ext/interbase/ibase_events.c
index ab1a791d37..150512faf4 100644
--- a/ext/interbase/ibase_events.c
+++ b/ext/interbase/ibase_events.c
@@ -178,7 +178,7 @@ PHP_FUNCTION(ibase_wait_event)
isc_event_counts(occurred_event, buffer_size, event_buffer, result_buffer);
for (i = 0; i < event_count; ++i) {
if (occurred_event[i]) {
- zend_string *result = STR_INIT(events[i], strlen(events[i]), 0);
+ zend_string *result = zend_string_init(events[i], strlen(events[i]), 0);
_php_ibase_event_free(event_buffer,result_buffer);
efree(args);
RETURN_STR(result);
@@ -297,7 +297,7 @@ PHP_FUNCTION(ibase_set_event_handler)
RETURN_FALSE;
}
- convert_to_long_ex(&args[0]);
+ convert_to_int_ex(&args[0]);
link_res_id = Z_LVAL(args[0]);
} else {
@@ -319,10 +319,10 @@ PHP_FUNCTION(ibase_set_event_handler)
/* get the callback */
if (!zend_is_callable(cb_arg, 0, &cb_name TSRMLS_CC)) {
_php_ibase_module_error("Callback argument %s is not a callable function" TSRMLS_CC, cb_name->val);
- STR_RELEASE(cb_name);
+ zend_string_release(cb_name);
RETURN_FALSE;
}
- STR_RELEASE(cb_name);
+ zend_string_release(cb_name);
/* allocate the event resource */
event = (ibase_event *) safe_emalloc(sizeof(ibase_event), 1, 0);
diff --git a/ext/interbase/ibase_query.c b/ext/interbase/ibase_query.c
index 1899e5aae1..66c66db6b4 100644
--- a/ext/interbase/ibase_query.c
+++ b/ext/interbase/ibase_query.c
@@ -534,7 +534,7 @@ static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, /
ISC_INT64 l;
case SQL_SHORT:
- convert_to_long(val);
+ convert_to_int(val);
if (Z_LVAL_P(val) > SHRT_MAX || Z_LVAL_P(val) < SHRT_MIN) {
_php_ibase_module_error("Array parameter exceeds field width" TSRMLS_CC);
return FAILURE;
@@ -542,7 +542,7 @@ static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, /
*(short *) buf = (short) Z_LVAL_P(val);
break;
case SQL_LONG:
- convert_to_long(val);
+ convert_to_int(val);
#if (SIZEOF_LONG > 4)
if (Z_LVAL_P(val) > ISC_LONG_MAX || Z_LVAL_P(val) < ISC_LONG_MIN) {
_php_ibase_module_error("Array parameter exceeds field width" TSRMLS_CC);
@@ -553,7 +553,7 @@ static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, /
break;
case SQL_INT64:
#if (SIZEOF_LONG >= 8)
- convert_to_long(val);
+ convert_to_int(val);
*(long *) buf = Z_LVAL_P(val);
#else
convert_to_string(val);
diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c
index c6c108f377..4df47392fa 100644
--- a/ext/interbase/interbase.c
+++ b/ext/interbase/interbase.c
@@ -1194,7 +1194,7 @@ PHP_FUNCTION(ibase_trans)
tpb_len = 0;
- convert_to_long_ex(&args[i]);
+ convert_to_int_ex(&args[i]);
trans_argl = Z_LVAL(args[i]);
if (trans_argl != PHP_IBASE_DEFAULT) {
diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp
index 7aa1eae0bc..ea3a305dd9 100644
--- a/ext/intl/breakiterator/breakiterator_class.cpp
+++ b/ext/intl/breakiterator/breakiterator_class.cpp
@@ -121,7 +121,7 @@ static zend_object *BreakIterator_clone_obj(zval *object TSRMLS_DC)
"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->val, 0 TSRMLS_CC);
- STR_FREE(err_msg);
+ zend_string_free(err_msg);
} else {
bio_new->biter = new_biter;
ZVAL_COPY(&bio_new->text, &bio_orig->text);
diff --git a/ext/intl/breakiterator/breakiterator_iterators.cpp b/ext/intl/breakiterator/breakiterator_iterators.cpp
index 7783235d8d..d8f18f99f3 100644
--- a/ext/intl/breakiterator/breakiterator_iterators.cpp
+++ b/ext/intl/breakiterator/breakiterator_iterators.cpp
@@ -67,7 +67,7 @@ static void _breakiterator_move_forward(zend_object_iterator *iter TSRMLS_DC)
int32_t pos = biter->next();
if (pos != BreakIterator::DONE) {
- ZVAL_LONG(&zoi_iter->current, (long)pos);
+ ZVAL_LONG(&zoi_iter->current, (zend_long)pos);
} //else we've reached the end of the enum, nothing more is required
}
@@ -77,7 +77,7 @@ static void _breakiterator_rewind(zend_object_iterator *iter TSRMLS_DC)
zoi_with_current *zoi_iter = (zoi_with_current*)iter;
int32_t pos = biter->first();
- ZVAL_LONG(&zoi_iter->current, (long)pos);
+ ZVAL_LONG(&zoi_iter->current, (zend_long)pos);
}
static zend_object_iterator_funcs breakiterator_iterator_funcs = {
@@ -175,7 +175,7 @@ static void _breakiterator_parts_move_forward(zend_object_iterator *iter TSRMLS_
next = slen;
}
assert(next <= slen && next >= cur);
- res = STR_ALLOC(next - cur, 0);
+ res = zend_string_alloc(next - cur, 0);
memcpy(res->val, &s[cur], res->len);
res->val[res->len] = '\0';
diff --git a/ext/intl/breakiterator/breakiterator_methods.cpp b/ext/intl/breakiterator/breakiterator_methods.cpp
index ed5944a3da..af380e44fd 100644
--- a/ext/intl/breakiterator/breakiterator_methods.cpp
+++ b/ext/intl/breakiterator/breakiterator_methods.cpp
@@ -208,7 +208,7 @@ static void _breakiter_no_args_ret_int32(
int32_t res = (bio->biter->*func)();
- RETURN_LONG((long)res);
+ RETURN_LONG((zend_long)res);
}
static void _breakiter_int32_ret_int32(
@@ -217,7 +217,7 @@ static void _breakiter_int32_ret_int32(
INTERNAL_FUNCTION_PARAMETERS)
{
char *msg;
- long arg;
+ zend_long arg;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
@@ -240,7 +240,7 @@ static void _breakiter_int32_ret_int32(
int32_t res = (bio->biter->*func)((int32_t)arg);
- RETURN_LONG((long)res);
+ RETURN_LONG((zend_long)res);
}
U_CFUNC PHP_FUNCTION(breakiter_first)
@@ -308,7 +308,7 @@ U_CFUNC PHP_FUNCTION(breakiter_current)
int32_t res = bio->biter->current();
- RETURN_LONG((long)res);
+ RETURN_LONG((zend_long)res);
}
U_CFUNC PHP_FUNCTION(breakiter_following)
@@ -327,7 +327,7 @@ U_CFUNC PHP_FUNCTION(breakiter_preceding)
U_CFUNC PHP_FUNCTION(breakiter_is_boundary)
{
- long offset;
+ zend_long offset;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
@@ -349,12 +349,12 @@ U_CFUNC PHP_FUNCTION(breakiter_is_boundary)
UBool res = bio->biter->isBoundary((int32_t)offset);
- RETURN_BOOL((long)res);
+ RETURN_BOOL((zend_long)res);
}
U_CFUNC PHP_FUNCTION(breakiter_get_locale)
{
- long locale_type;
+ zend_long locale_type;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
@@ -382,7 +382,7 @@ U_CFUNC PHP_FUNCTION(breakiter_get_locale)
U_CFUNC PHP_FUNCTION(breakiter_get_parts_iterator)
{
- long key_type = 0;
+ zend_long key_type = 0;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
@@ -422,7 +422,7 @@ U_CFUNC PHP_FUNCTION(breakiter_get_error_code)
if (bio == NULL)
RETURN_FALSE;
- RETURN_LONG((long)BREAKITER_ERROR_CODE(bio));
+ RETURN_LONG((zend_long)BREAKITER_ERROR_CODE(bio));
}
U_CFUNC PHP_FUNCTION(breakiter_get_error_message)
diff --git a/ext/intl/breakiterator/codepointiterator_internal.cpp b/ext/intl/breakiterator/codepointiterator_internal.cpp
index bf9239d531..bffd1ee5cf 100644
--- a/ext/intl/breakiterator/codepointiterator_internal.cpp
+++ b/ext/intl/breakiterator/codepointiterator_internal.cpp
@@ -18,9 +18,11 @@
#include <unicode/uchriter.h>
#include <typeinfo>
+#include "php.h"
+
//copied from cmemory.h, which is not public
typedef union {
- long t1;
+ zend_long t1;
double t2;
void *t3;
} UAlignedMemory;
diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
index 50df1a61ab..098f8ab3cc 100644
--- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
+++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
@@ -218,7 +218,7 @@ U_CFUNC PHP_FUNCTION(rbbi_get_binary_rules)
RETURN_FALSE;
}
- zend_string *ret_rules = STR_ALLOC(rules_len, 0);
+ zend_string *ret_rules = zend_string_alloc(rules_len, 0);
memcpy(ret_rules->val, rules, rules_len);
ret_rules->val[rules_len] = '\0';
diff --git a/ext/intl/calendar/calendar_class.cpp b/ext/intl/calendar/calendar_class.cpp
index a62ad7b9d9..58375f8196 100644
--- a/ext/intl/calendar/calendar_class.cpp
+++ b/ext/intl/calendar/calendar_class.cpp
@@ -102,7 +102,7 @@ static zend_object *Calendar_clone_obj(zval *object TSRMLS_DC)
"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->val, 0 TSRMLS_CC);
- STR_FREE(err_msg);
+ zend_string_free(err_msg);
} else {
co_new->ucal = newCalendar;
}
@@ -209,7 +209,7 @@ static HashTable *Calendar_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
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);
+ add_assoc_long(&zfields, name, (zend_long)res);
} else {
add_assoc_string(&zfields, name, const_cast<char*>(u_errorName(uec)));
}
diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp
index 3684c229a1..0d808f36fd 100644
--- a/ext/intl/calendar/calendar_methods.cpp
+++ b/ext/intl/calendar/calendar_methods.cpp
@@ -219,7 +219,7 @@ static void _php_intlcal_field_uec_ret_in32t_method(
const char *method_name,
INTERNAL_FUNCTION_PARAMETERS)
{
- long field;
+ zend_long field;
char *message;
CALENDAR_METHOD_INIT_VARS;
@@ -244,7 +244,7 @@ static void _php_intlcal_field_uec_ret_in32t_method(
(UCalendarDateFields)field, CALENDAR_ERROR_CODE(co));
INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed");
- RETURN_LONG((long)result);
+ RETURN_LONG((zend_long)result);
}
U_CFUNC PHP_FUNCTION(intlcal_get)
@@ -295,7 +295,7 @@ U_CFUNC PHP_FUNCTION(intlcal_set_time)
U_CFUNC PHP_FUNCTION(intlcal_add)
{
- long field,
+ zend_long field,
amount;
CALENDAR_METHOD_INIT_VARS;
@@ -399,7 +399,7 @@ U_CFUNC PHP_FUNCTION(intlcal_before)
U_CFUNC PHP_FUNCTION(intlcal_set)
{
- long arg1, arg2, arg3, arg4, arg5, arg6;
+ zend_long arg1, arg2, arg3, arg4, arg5, arg6;
zval args_a[7] = {0},
*args = args_a;
int i;
@@ -462,7 +462,7 @@ U_CFUNC PHP_FUNCTION(intlcal_set)
U_CFUNC PHP_FUNCTION(intlcal_roll)
{
- long field,
+ zend_long field,
value;
zval args_a[3] = {0},
*args = args_a;
@@ -524,7 +524,7 @@ U_CFUNC PHP_FUNCTION(intlcal_clear)
{
zval args_a[2] = {0},
*args = &args_a[0];
- long field;
+ zend_long field;
int variant;
CALENDAR_METHOD_INIT_VARS;
@@ -572,7 +572,7 @@ U_CFUNC PHP_FUNCTION(intlcal_clear)
U_CFUNC PHP_FUNCTION(intlcal_field_difference)
{
- long field;
+ zend_long field;
double when;
CALENDAR_METHOD_INIT_VARS;
@@ -596,7 +596,7 @@ U_CFUNC PHP_FUNCTION(intlcal_field_difference)
INTL_METHOD_CHECK_STATUS(co,
"intlcal_field_difference: Call to ICU method has failed");
- RETURN_LONG((long)result);
+ RETURN_LONG((zend_long)result);
}
U_CFUNC PHP_FUNCTION(intlcal_get_actual_maximum)
@@ -614,7 +614,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_actual_minimum)
#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;
+ zend_ulong dow;
CALENDAR_METHOD_INIT_VARS;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
@@ -637,7 +637,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_day_of_week_type)
INTL_METHOD_CHECK_STATUS(co,
"intlcal_get_day_of_week_type: Call to ICU method has failed");
- RETURN_LONG((long)result);
+ RETURN_LONG((zend_long)result);
}
#endif
@@ -658,7 +658,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_first_day_of_week)
INTL_METHOD_CHECK_STATUS(co,
"intlcal_get_first_day_of_week: Call to ICU method has failed");
- RETURN_LONG((long)result);
+ RETURN_LONG((zend_long)result);
}
static void _php_intlcal_field_ret_in32t_method(
@@ -666,7 +666,7 @@ static void _php_intlcal_field_ret_in32t_method(
const char *method_name,
INTERNAL_FUNCTION_PARAMETERS)
{
- long field;
+ zend_long field;
char *message;
CALENDAR_METHOD_INIT_VARS;
@@ -690,7 +690,7 @@ static void _php_intlcal_field_ret_in32t_method(
int32_t result = (co->ucal->*func)((UCalendarDateFields)field);
INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed");
- RETURN_LONG((long)result);
+ RETURN_LONG((zend_long)result);
}
U_CFUNC PHP_FUNCTION(intlcal_get_greatest_minimum)
@@ -707,7 +707,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_least_maximum)
U_CFUNC PHP_FUNCTION(intlcal_get_locale)
{
- long locale_type;
+ zend_long locale_type;
CALENDAR_METHOD_INIT_VARS;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
@@ -756,7 +756,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_minimal_days_in_first_week)
INTL_METHOD_CHECK_STATUS(co,
"intlcal_get_first_day_of_week: Call to ICU method has failed");
- RETURN_LONG((long)result);
+ RETURN_LONG((zend_long)result);
}
U_CFUNC PHP_FUNCTION(intlcal_get_minimum)
@@ -807,7 +807,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_type)
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
U_CFUNC PHP_FUNCTION(intlcal_get_weekend_transition)
{
- long dow;
+ zend_long dow;
CALENDAR_METHOD_INIT_VARS;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
@@ -830,7 +830,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_weekend_transition)
INTL_METHOD_CHECK_STATUS(co, "intlcal_get_weekend_transition: "
"Error calling ICU method");
- RETURN_LONG((long)res);
+ RETURN_LONG((zend_long)res);
}
#endif
@@ -898,7 +898,7 @@ U_CFUNC PHP_FUNCTION(intlcal_is_lenient)
U_CFUNC PHP_FUNCTION(intlcal_is_set)
{
- long field;
+ zend_long field;
CALENDAR_METHOD_INIT_VARS;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
@@ -953,7 +953,7 @@ U_CFUNC PHP_FUNCTION(intlcal_is_weekend)
U_CFUNC PHP_FUNCTION(intlcal_set_first_day_of_week)
{
- long dow;
+ zend_long dow;
CALENDAR_METHOD_INIT_VARS;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
@@ -997,7 +997,7 @@ U_CFUNC PHP_FUNCTION(intlcal_set_lenient)
U_CFUNC PHP_FUNCTION(intlcal_set_minimal_days_in_first_week)
{
- long num_days;
+ zend_long num_days;
CALENDAR_METHOD_INIT_VARS;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
@@ -1085,7 +1085,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_skipped_wall_time_option)
U_CFUNC PHP_FUNCTION(intlcal_set_repeated_wall_time_option)
{
- long option;
+ zend_long option;
CALENDAR_METHOD_INIT_VARS;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
@@ -1110,7 +1110,7 @@ U_CFUNC PHP_FUNCTION(intlcal_set_repeated_wall_time_option)
U_CFUNC PHP_FUNCTION(intlcal_set_skipped_wall_time_option)
{
- long option;
+ zend_long option;
CALENDAR_METHOD_INIT_VARS;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
@@ -1322,7 +1322,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_error_code)
if (co == NULL)
RETURN_FALSE;
- RETURN_LONG((long)CALENDAR_ERROR_CODE(co));
+ RETURN_LONG((zend_long)CALENDAR_ERROR_CODE(co));
}
U_CFUNC PHP_FUNCTION(intlcal_get_error_message)
diff --git a/ext/intl/calendar/gregoriancalendar_methods.cpp b/ext/intl/calendar/gregoriancalendar_methods.cpp
index e62164f7d6..9c243502fe 100644
--- a/ext/intl/calendar/gregoriancalendar_methods.cpp
+++ b/ext/intl/calendar/gregoriancalendar_methods.cpp
@@ -43,7 +43,7 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
*args = &args_a[0];
char *locale = NULL;
int locale_len;
- long largs[6];
+ zend_long largs[6];
UErrorCode status = U_ZERO_ERROR;
int variant;
intl_error_reset(NULL TSRMLS_CC);
@@ -242,7 +242,7 @@ U_CFUNC PHP_FUNCTION(intlgregcal_get_gregorian_change)
U_CFUNC PHP_FUNCTION(intlgregcal_is_leap_year)
{
- long year;
+ zend_long year;
CALENDAR_METHOD_INIT_VARS;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
diff --git a/ext/intl/collator/collator_attr.c b/ext/intl/collator/collator_attr.c
index 684e72cc58..72446f51a7 100644
--- a/ext/intl/collator/collator_attr.c
+++ b/ext/intl/collator/collator_attr.c
@@ -33,7 +33,7 @@
*/
PHP_FUNCTION( collator_get_attribute )
{
- long attribute, value;
+ zend_long attribute, value;
COLLATOR_METHOD_INIT_VARS
@@ -64,7 +64,7 @@ PHP_FUNCTION( collator_get_attribute )
*/
PHP_FUNCTION( collator_set_attribute )
{
- long attribute, value;
+ zend_long attribute, value;
COLLATOR_METHOD_INIT_VARS
@@ -123,7 +123,7 @@ PHP_FUNCTION( collator_get_strength )
*/
PHP_FUNCTION( collator_set_strength )
{
- long strength;
+ zend_long strength;
COLLATOR_METHOD_INIT_VARS
diff --git a/ext/intl/collator/collator_convert.c b/ext/intl/collator/collator_convert.c
index 7d8bf0bbc8..5a572067f6 100644
--- a/ext/intl/collator/collator_convert.c
+++ b/ext/intl/collator/collator_convert.c
@@ -41,7 +41,7 @@
/* {{{ collator_convert_hash_item_from_utf8_to_utf16 */
static void collator_convert_hash_item_from_utf8_to_utf16(
- HashTable* hash, zval *hashData, zend_string *hashKey, ulong hashIndex,
+ HashTable* hash, zval *hashData, zend_string *hashKey, zend_ulong hashIndex,
UErrorCode* status )
{
const char* old_val;
@@ -82,7 +82,7 @@ static void collator_convert_hash_item_from_utf8_to_utf16(
/* {{{ collator_convert_hash_item_from_utf16_to_utf8 */
static void collator_convert_hash_item_from_utf16_to_utf8(
- HashTable* hash, zval * hashData, zend_string* hashKey, ulong hashIndex,
+ HashTable* hash, zval * hashData, zend_string* hashKey, zend_ulong hashIndex,
UErrorCode* status )
{
const char* old_val;
@@ -125,7 +125,7 @@ static void collator_convert_hash_item_from_utf16_to_utf8(
*/
void collator_convert_hash_from_utf8_to_utf16( HashTable* hash, UErrorCode* status )
{
- ulong hashIndex;
+ zend_ulong hashIndex;
zval *hashData;
zend_string *hashKey;
@@ -144,7 +144,7 @@ void collator_convert_hash_from_utf8_to_utf16( HashTable* hash, UErrorCode* stat
*/
void collator_convert_hash_from_utf16_to_utf8( HashTable* hash, UErrorCode* status )
{
- ulong hashIndex;
+ zend_ulong hashIndex;
zend_string *hashKey;
zval *hashData;
@@ -359,7 +359,7 @@ zval* collator_convert_string_to_double( zval* str, zval *rv )
zval* collator_convert_string_to_number_if_possible( zval* str, zval *rv )
{
int is_numeric = 0;
- long lval = 0;
+ zend_long lval = 0;
double dval = 0;
if( Z_TYPE_P( str ) != IS_STRING )
diff --git a/ext/intl/collator/collator_is_numeric.c b/ext/intl/collator/collator_is_numeric.c
index a8abfac12b..db9e41f887 100644
--- a/ext/intl/collator/collator_is_numeric.c
+++ b/ext/intl/collator/collator_is_numeric.c
@@ -125,15 +125,15 @@ static double collator_u_strtod(const UChar *nptr, UChar **endptr) /* {{{ */
*
* Ignores `locale' stuff.
*/
-static long collator_u_strtol(nptr, endptr, base)
+static zend_long collator_u_strtol(nptr, endptr, base)
const UChar *nptr;
UChar **endptr;
register int base;
{
register const UChar *s = nptr;
- register unsigned long acc;
+ register zend_ulong acc;
register UChar c;
- register unsigned long cutoff;
+ register zend_ulong cutoff;
register int neg = 0, any, cutlim;
if (s == NULL) {
@@ -184,9 +184,9 @@ static long collator_u_strtol(nptr, endptr, base)
* Set any if any `digits' consumed; make it negative to indicate
* overflow.
*/
- cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
- cutlim = cutoff % (unsigned long)base;
- cutoff /= (unsigned long)base;
+ cutoff = neg ? -(zend_ulong)ZEND_LONG_MIN : ZEND_LONG_MAX;
+ cutlim = cutoff % (zend_ulong)base;
+ cutoff /= (zend_ulong)base;
for (acc = 0, any = 0;; c = *s++) {
if (c >= 0x30 /*'0'*/ && c <= 0x39 /*'9'*/)
c -= 0x30 /*'0'*/;
@@ -208,7 +208,7 @@ static long collator_u_strtol(nptr, endptr, base)
}
}
if (any < 0) {
- acc = neg ? LONG_MIN : LONG_MAX;
+ acc = neg ? ZEND_LONG_MIN : ZEND_LONG_MAX;
errno = ERANGE;
} else if (neg)
acc = -acc;
@@ -222,9 +222,9 @@ static long collator_u_strtol(nptr, endptr, base)
/* {{{ collator_is_numeric]
* Taken from PHP6:is_numeric_unicode()
*/
-zend_uchar collator_is_numeric( UChar *str, int length, long *lval, double *dval, int allow_errors )
+zend_uchar collator_is_numeric( UChar *str, int length, zend_long *lval, double *dval, int allow_errors )
{
- long local_lval;
+ zend_long local_lval;
double local_dval;
UChar *end_ptr_long, *end_ptr_double;
int conv_base=10;
diff --git a/ext/intl/collator/collator_is_numeric.h b/ext/intl/collator/collator_is_numeric.h
index 585d58917a..d7aa12ce46 100644
--- a/ext/intl/collator/collator_is_numeric.h
+++ b/ext/intl/collator/collator_is_numeric.h
@@ -21,6 +21,6 @@
#include <php.h>
#include <unicode/uchar.h>
-zend_uchar collator_is_numeric( UChar *str, int length, long *lval, double *dval, int allow_errors );
+zend_uchar collator_is_numeric( UChar *str, int length, zend_long *lval, double *dval, int allow_errors );
#endif // COLLATOR_IS_NUMERIC_H
diff --git a/ext/intl/collator/collator_locale.c b/ext/intl/collator/collator_locale.c
index e5640beca6..dd37cc75db 100644
--- a/ext/intl/collator/collator_locale.c
+++ b/ext/intl/collator/collator_locale.c
@@ -33,7 +33,7 @@
*/
PHP_FUNCTION( collator_get_locale )
{
- long type = 0;
+ zend_long type = 0;
char* locale_name = NULL;
COLLATOR_METHOD_INIT_VARS
diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c
index 43140b2f41..0856b580be 100644
--- a/ext/intl/collator/collator_sort.c
+++ b/ext/intl/collator/collator_sort.c
@@ -27,7 +27,7 @@
#include "intl_convert.h"
#if !defined(HAVE_PTRDIFF_T) && !defined(_PTRDIFF_T_DEFINED)
-typedef long ptrdiff_t;
+typedef zend_long ptrdiff_t;
#endif
/**
@@ -232,7 +232,7 @@ static int collator_compare_func( const void* a, const void* b TSRMLS_DC )
return 0;
}
- convert_to_long(&result);
+ convert_to_int(&result);
if( Z_LVAL(result) < 0 )
return -1;
@@ -258,7 +258,7 @@ static int collator_cmp_sort_keys( const void *p1, const void *p2 TSRMLS_DC )
/* {{{ collator_get_compare_function
* Choose compare function according to sort flags.
*/
-static collator_compare_func_t collator_get_compare_function( const long sort_flags )
+static collator_compare_func_t collator_get_compare_function( const zend_long sort_flags )
{
collator_compare_func_t func;
@@ -290,7 +290,7 @@ static void collator_sort_internal( int renumber, INTERNAL_FUNCTION_PARAMETERS )
zval saved_collator;
zval* array = NULL;
HashTable* hash = NULL;
- long sort_flags = COLLATOR_SORT_REGULAR;
+ zend_long sort_flags = COLLATOR_SORT_REGULAR;
COLLATOR_METHOD_INIT_VARS
diff --git a/ext/intl/common/common_date.cpp b/ext/intl/common/common_date.cpp
index 7c7510d554..783611e02f 100644
--- a/ext/intl/common/common_date.cpp
+++ b/ext/intl/common/common_date.cpp
@@ -174,7 +174,7 @@ U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz,
U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func TSRMLS_DC)
{
double rv = NAN;
- long lv;
+ zend_long lv;
int type;
char *message;
diff --git a/ext/intl/common/common_error.c b/ext/intl/common/common_error.c
index 2db688ac71..f7b739555e 100644
--- a/ext/intl/common/common_error.c
+++ b/ext/intl/common/common_error.c
@@ -48,7 +48,7 @@ PHP_FUNCTION( intl_get_error_message )
*/
PHP_FUNCTION( intl_is_failure )
{
- long err_code;
+ zend_long err_code;
/* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "l",
@@ -70,7 +70,7 @@ PHP_FUNCTION( intl_is_failure )
*/
PHP_FUNCTION( intl_error_name )
{
- long err_code;
+ zend_long err_code;
/* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "l",
diff --git a/ext/intl/config.m4 b/ext/intl/config.m4
index 4630a302ef..5afee4809e 100644
--- a/ext/intl/config.m4
+++ b/ext/intl/config.m4
@@ -85,7 +85,7 @@ if test "$PHP_INTL" != "no"; then
breakiterator/codepointiterator_internal.cpp \
breakiterator/codepointiterator_methods.cpp \
idn/idn.c \
- $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings)
+ $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS)
PHP_ADD_BUILD_DIR($ext_builddir/collator)
PHP_ADD_BUILD_DIR($ext_builddir/converter)
PHP_ADD_BUILD_DIR($ext_builddir/common)
diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c
index 0064497b41..aabb9c3400 100644
--- a/ext/intl/converter/converter.c
+++ b/ext/intl/converter/converter.c
@@ -62,7 +62,7 @@ static inline void php_converter_throw_failure(php_converter_object *objval, UEr
/* }}} */
/* {{{ php_converter_default_callback */
-static void php_converter_default_callback(zval *return_value, zval *zobj, long reason, zval *error TSRMLS_DC) {
+static void php_converter_default_callback(zval *return_value, zval *zobj, zend_long reason, zval *error TSRMLS_DC) {
ZVAL_DEREF(error);
zval_dtor(error);
ZVAL_LONG(error, U_ZERO_ERROR);
@@ -117,7 +117,7 @@ ZEND_BEGIN_ARG_INFO_EX(php_converter_toUCallback_arginfo, 0, ZEND_RETURN_VALUE,
ZEND_ARG_INFO(1, error)
ZEND_END_ARG_INFO();
static PHP_METHOD(UConverter, toUCallback) {
- long reason;
+ zend_long reason;
zval *source, *codeUnits, *error;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lzzz",
@@ -139,7 +139,7 @@ ZEND_BEGIN_ARG_INFO_EX(php_converter_fromUCallback_arginfo, 0, ZEND_RETURN_VALUE
ZEND_ARG_INFO(1, error)
ZEND_END_ARG_INFO();
static PHP_METHOD(UConverter, fromUCallback) {
- long reason;
+ zend_long reason;
zval *source, *codePoint, *error;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lzzz",
@@ -152,9 +152,9 @@ static PHP_METHOD(UConverter, fromUCallback) {
/* }}} */
/* {{{ php_converter_check_limits */
-static inline zend_bool php_converter_check_limits(php_converter_object *objval, long available, long needed TSRMLS_DC) {
+static inline zend_bool php_converter_check_limits(php_converter_object *objval, zend_long available, zend_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);
+ php_converter_throw_failure(objval, U_BUFFER_OVERFLOW_ERROR TSRMLS_CC, "Buffer overrun %pd bytes needed, %pd available", needed, available);
return 0;
}
return 1;
@@ -171,7 +171,7 @@ static void php_converter_append_toUnicode_target(zval *val, UConverterToUnicode
return;
case IS_LONG:
{
- long lval = Z_LVAL_P(val);
+ zend_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;
@@ -731,7 +731,7 @@ 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;
+ zend_long reason;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &reason) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -748,7 +748,7 @@ static PHP_METHOD(UConverter, reasonText) {
UCNV_REASON_CASE(CLOSE)
UCNV_REASON_CASE(CLONE)
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown UConverterCallbackReason: %ld", reason);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown UConverterCallbackReason: %pd", reason);
RETURN_FALSE;
}
}
@@ -1081,7 +1081,7 @@ static zend_object *php_converter_clone_object(zval *object TSRMLS_DC) {
err_msg = intl_error_get_message(&oldobj->error TSRMLS_CC);
zend_throw_exception(NULL, err_msg->val, 0 TSRMLS_CC);
- STR_RELEASE(err_msg);
+ zend_string_release(err_msg);
return retval;
}
diff --git a/ext/intl/dateformat/dateformat_attr.c b/ext/intl/dateformat/dateformat_attr.c
index e13b0f4cd2..b2f34b9c24 100644
--- a/ext/intl/dateformat/dateformat_attr.c
+++ b/ext/intl/dateformat/dateformat_attr.c
@@ -170,7 +170,7 @@ PHP_FUNCTION( datefmt_set_pattern )
PHP_FUNCTION( datefmt_get_locale )
{
char *loc;
- long loc_type =ULOC_ACTUAL_LOCALE;
+ zend_long loc_type =ULOC_ACTUAL_LOCALE;
DATE_FORMAT_METHOD_INIT_VARS;
diff --git a/ext/intl/dateformat/dateformat_attrcpp.cpp b/ext/intl/dateformat/dateformat_attrcpp.cpp
index 8ca880d956..5f63d33143 100644
--- a/ext/intl/dateformat/dateformat_attrcpp.cpp
+++ b/ext/intl/dateformat/dateformat_attrcpp.cpp
@@ -220,7 +220,7 @@ U_CFUNC PHP_FUNCTION(datefmt_set_calendar)
DATE_FORMAT_METHOD_FETCH_OBJECT;
Calendar *cal;
- long cal_type;
+ zend_long cal_type;
bool cal_owned;
Locale locale = Locale::createFromName(dfo->requested_locale);
// getting the actual locale from the DateFormat is not enough
diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp
index 856db16b1d..67b61bd067 100644
--- a/ext/intl/dateformat/dateformat_create.cpp
+++ b/ext/intl/dateformat/dateformat_create.cpp
@@ -43,11 +43,11 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
const char *locale_str;
int locale_len = 0;
Locale locale;
- long date_type = 0;
- long time_type = 0;
+ zend_long date_type = 0;
+ zend_long time_type = 0;
zval *calendar_zv = NULL;
Calendar *calendar = NULL;
- long calendar_type;
+ zend_long calendar_type;
bool calendar_owned;
zval *timezone_zv = NULL;
TimeZone *timezone = NULL;
diff --git a/ext/intl/dateformat/dateformat_format.c b/ext/intl/dateformat/dateformat_format.c
index 467053ef84..dd9b64d4ee 100644
--- a/ext/intl/dateformat/dateformat_format.c
+++ b/ext/intl/dateformat/dateformat_format.c
@@ -79,7 +79,7 @@ static int32_t internal_get_arr_ele(IntlDateFormatter_object *dfo,
} else {
if (Z_LVAL_P(ele_value) > INT32_MAX ||
Z_LVAL_P(ele_value) < INT32_MIN) {
- spprintf(&message, 0, "datefmt_format: value %ld is out of "
+ spprintf(&message, 0, "datefmt_format: value %pd is out of "
"bounds for a 32-bit integer in key '%s'",
Z_LVAL_P(ele_value), key_name);
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC);
diff --git a/ext/intl/dateformat/dateformat_format_object.cpp b/ext/intl/dateformat/dateformat_format_object.cpp
index ac8aa2fe4c..564867f017 100644
--- a/ext/intl/dateformat/dateformat_format_object.cpp
+++ b/ext/intl/dateformat/dateformat_format_object.cpp
@@ -47,9 +47,9 @@ static const DateFormat::EStyle valid_styles[] = {
static bool valid_format(zval *z) {
if (Z_TYPE_P(z) == IS_LONG) {
- long lval = Z_LVAL_P(z);
+ zend_long lval = Z_LVAL_P(z);
for (int i = 0; i < sizeof(valid_styles) / sizeof(*valid_styles); i++) {
- if ((long)valid_styles[i] == lval) {
+ if ((zend_long)valid_styles[i] == lval) {
return true;
}
}
diff --git a/ext/intl/dateformat/dateformat_helpers.cpp b/ext/intl/dateformat/dateformat_helpers.cpp
index 74758bbec9..92296be97a 100644
--- a/ext/intl/dateformat/dateformat_helpers.cpp
+++ b/ext/intl/dateformat/dateformat_helpers.cpp
@@ -33,7 +33,7 @@ int datefmt_process_calendar_arg(zval* calendar_zv,
const char *func_name,
intl_error *err,
Calendar*& cal,
- long& cal_int_type,
+ zend_long& cal_int_type,
bool& calendar_owned TSRMLS_DC)
{
char *msg;
@@ -49,8 +49,8 @@ int datefmt_process_calendar_arg(zval* calendar_zv,
} 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) {
+ zend_long v = Z_LVAL_P(calendar_zv);
+ if (v != (zend_long)UCAL_TRADITIONAL && v != (zend_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. "
@@ -59,7 +59,7 @@ int datefmt_process_calendar_arg(zval* calendar_zv,
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC);
efree(msg);
return FAILURE;
- } else if (v == (long)UCAL_TRADITIONAL) {
+ } else if (v == (zend_long)UCAL_TRADITIONAL) {
cal = Calendar::createInstance(locale, status);
} else { //UCAL_GREGORIAN
cal = new GregorianCalendar(locale, status);
diff --git a/ext/intl/dateformat/dateformat_helpers.h b/ext/intl/dateformat/dateformat_helpers.h
index bded0b7d78..ca88da008a 100644
--- a/ext/intl/dateformat/dateformat_helpers.h
+++ b/ext/intl/dateformat/dateformat_helpers.h
@@ -32,7 +32,7 @@ int datefmt_process_calendar_arg(zval* calendar_zv,
const char *func_name,
intl_error *err,
Calendar*& cal,
- long& cal_int_type,
+ zend_long& cal_int_type,
bool& calendar_owned TSRMLS_DC);
#endif /* DATEFORMAT_HELPERS_H */
diff --git a/ext/intl/dateformat/dateformat_parse.c b/ext/intl/dateformat/dateformat_parse.c
index fb3da3e053..79c2a2f7c0 100644
--- a/ext/intl/dateformat/dateformat_parse.c
+++ b/ext/intl/dateformat/dateformat_parse.c
@@ -57,14 +57,14 @@ static void internal_parse_to_timestamp(IntlDateFormatter_object *dfo, char* tex
if(result > LONG_MAX || result < -LONG_MAX) {
ZVAL_DOUBLE(return_value, result<0?ceil(result):floor(result));
} else {
- ZVAL_LONG(return_value, (long)result);
+ ZVAL_LONG(return_value, (zend_long)result);
}
}
/* }}} */
-static void add_to_localtime_arr( IntlDateFormatter_object *dfo, zval* return_value, const UCalendar *parsed_calendar, long calendar_field, char* key_name TSRMLS_DC)
+static void add_to_localtime_arr( IntlDateFormatter_object *dfo, zval* return_value, const UCalendar *parsed_calendar, zend_long calendar_field, char* key_name TSRMLS_DC)
{
- long calendar_field_val = ucal_get( parsed_calendar, calendar_field, &INTL_DATA_ERROR_CODE(dfo));
+ zend_long calendar_field_val = ucal_get( parsed_calendar, calendar_field, &INTL_DATA_ERROR_CODE(dfo));
INTL_METHOD_CHECK_STATUS( dfo, "Date parsing - localtime failed : could not get a field from calendar" );
if( strcmp(key_name, CALENDAR_YEAR )==0 ){
@@ -86,7 +86,7 @@ static void internal_parse_to_localtime(IntlDateFormatter_object *dfo, char* tex
UCalendar *parsed_calendar = NULL;
UChar* text_utf16 = NULL;
int32_t text_utf16_len = 0;
- long isInDST = 0;
+ zend_long isInDST = 0;
/* Convert timezone to UTF-16. */
intl_convert_utf8_to_utf16(&text_utf16, &text_utf16_len, text_to_parse, text_len, &INTL_DATA_ERROR_CODE(dfo));
@@ -146,7 +146,7 @@ PHP_FUNCTION(datefmt_parse)
if (z_parse_pos) {
ZVAL_DEREF(z_parse_pos);
- convert_to_long(z_parse_pos);
+ convert_to_int(z_parse_pos);
parse_pos = (int32_t)Z_LVAL_P(z_parse_pos);
if(parse_pos > text_len) {
RETURN_FALSE;
@@ -185,7 +185,7 @@ PHP_FUNCTION(datefmt_localtime)
if (z_parse_pos) {
ZVAL_DEREF(z_parse_pos);
- convert_to_long(z_parse_pos);
+ convert_to_int(z_parse_pos);
parse_pos = (int32_t)Z_LVAL_P(z_parse_pos);
if(parse_pos > text_len) {
RETURN_FALSE;
diff --git a/ext/intl/formatter/formatter_attr.c b/ext/intl/formatter/formatter_attr.c
index af58cfe37f..4869fdf294 100644
--- a/ext/intl/formatter/formatter_attr.c
+++ b/ext/intl/formatter/formatter_attr.c
@@ -32,7 +32,7 @@
*/
PHP_FUNCTION( numfmt_get_attribute )
{
- long attribute, value;
+ zend_long attribute, value;
FORMATTER_METHOD_INIT_VARS;
/* Parse parameters. */
@@ -101,7 +101,7 @@ PHP_FUNCTION( numfmt_get_attribute )
*/
PHP_FUNCTION( numfmt_get_text_attribute )
{
- long attribute;
+ zend_long attribute;
UChar value_buf[64];
int value_buf_size = USIZE( value_buf );
UChar* value = value_buf;
@@ -145,7 +145,7 @@ PHP_FUNCTION( numfmt_get_text_attribute )
*/
PHP_FUNCTION( numfmt_set_attribute )
{
- long attribute;
+ zend_long attribute;
zval *value;
FORMATTER_METHOD_INIT_VARS;
@@ -182,7 +182,7 @@ PHP_FUNCTION( numfmt_set_attribute )
case UNUM_MIN_SIGNIFICANT_DIGITS:
case UNUM_MAX_SIGNIFICANT_DIGITS:
case UNUM_LENIENT_PARSE:
- convert_to_long_ex(value);
+ convert_to_int_ex(value);
unum_setAttribute(FORMATTER_OBJECT(nfo), attribute, Z_LVAL_P(value));
break;
case UNUM_ROUNDING_INCREMENT:
@@ -209,7 +209,7 @@ PHP_FUNCTION( numfmt_set_text_attribute )
{
int slength = 0;
UChar *svalue = NULL;
- long attribute;
+ zend_long attribute;
char *value;
int len;
FORMATTER_METHOD_INIT_VARS;
@@ -249,7 +249,7 @@ PHP_FUNCTION( numfmt_set_text_attribute )
*/
PHP_FUNCTION( numfmt_get_symbol )
{
- long symbol;
+ zend_long symbol;
UChar value_buf[4];
UChar *value = value_buf;
int length = USIZE(value_buf);
@@ -297,7 +297,7 @@ PHP_FUNCTION( numfmt_get_symbol )
*/
PHP_FUNCTION( numfmt_set_symbol )
{
- long symbol;
+ zend_long symbol;
char* value = NULL;
int value_len = 0;
UChar* svalue = 0;
@@ -426,7 +426,7 @@ PHP_FUNCTION( numfmt_set_pattern )
*/
PHP_FUNCTION( numfmt_get_locale )
{
- long type = ULOC_ACTUAL_LOCALE;
+ zend_long type = ULOC_ACTUAL_LOCALE;
char* loc;
FORMATTER_METHOD_INIT_VARS;
diff --git a/ext/intl/formatter/formatter_format.c b/ext/intl/formatter/formatter_format.c
index 4b98f4fb17..abae435ca2 100644
--- a/ext/intl/formatter/formatter_format.c
+++ b/ext/intl/formatter/formatter_format.c
@@ -33,7 +33,7 @@
PHP_FUNCTION( numfmt_format )
{
zval *number;
- long type = FORMAT_TYPE_DEFAULT;
+ zend_long type = FORMAT_TYPE_DEFAULT;
UChar format_buf[32];
UChar* formatted = format_buf;
int formatted_len = USIZE(format_buf);
@@ -59,7 +59,7 @@ PHP_FUNCTION( numfmt_format )
if(Z_TYPE_P(number) == IS_LONG) {
/* take INT32 on 32-bit, int64 on 64-bit */
- type = (sizeof(long) == 8)?FORMAT_TYPE_INT64:FORMAT_TYPE_INT32;
+ type = (sizeof(zend_long) == 8)?FORMAT_TYPE_INT64:FORMAT_TYPE_INT32;
} else if(Z_TYPE_P(number) == IS_DOUBLE) {
type = FORMAT_TYPE_DOUBLE;
} else {
@@ -74,7 +74,7 @@ PHP_FUNCTION( numfmt_format )
switch(type) {
case FORMAT_TYPE_INT32:
- convert_to_long_ex(number);
+ convert_to_int_ex(number);
formatted_len = unum_format(FORMATTER_OBJECT(nfo), (int32_t)Z_LVAL_P(number),
formatted, formatted_len, NULL, &INTL_DATA_ERROR_CODE(nfo));
if (INTL_DATA_ERROR_CODE(nfo) == U_BUFFER_OVERFLOW_ERROR) {
@@ -120,7 +120,7 @@ PHP_FUNCTION( numfmt_format )
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported format type %ld", type);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported format type %pd", type);
RETURN_FALSE;
break;
}
diff --git a/ext/intl/formatter/formatter_main.c b/ext/intl/formatter/formatter_main.c
index 26473ebe78..5e790999e4 100644
--- a/ext/intl/formatter/formatter_main.c
+++ b/ext/intl/formatter/formatter_main.c
@@ -30,7 +30,7 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
const char* locale;
char* pattern = NULL;
int locale_len = 0, pattern_len = 0;
- long style;
+ zend_long style;
UChar* spattern = NULL;
int spattern_len = 0;
FORMATTER_METHOD_INIT_VARS;
diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.c
index 73b331302b..fa06648331 100644
--- a/ext/intl/formatter/formatter_parse.c
+++ b/ext/intl/formatter/formatter_parse.c
@@ -36,7 +36,7 @@
*/
PHP_FUNCTION( numfmt_parse )
{
- long type = FORMAT_TYPE_DOUBLE;
+ zend_long type = FORMAT_TYPE_DOUBLE;
UChar* sstr = NULL;
int sstr_len = 0;
char* str = NULL;
@@ -68,7 +68,7 @@ PHP_FUNCTION( numfmt_parse )
if(zposition) {
ZVAL_DEREF(zposition);
- convert_to_long(zposition);
+ convert_to_int(zposition);
position = (int32_t)Z_LVAL_P( zposition );
position_p = &position;
}
@@ -86,10 +86,10 @@ PHP_FUNCTION( numfmt_parse )
break;
case FORMAT_TYPE_INT64:
val64 = unum_parseInt64(FORMATTER_OBJECT(nfo), sstr, sstr_len, position_p, &INTL_DATA_ERROR_CODE(nfo));
- if(val64 > LONG_MAX || val64 < LONG_MIN) {
+ if(val64 > ZEND_LONG_MAX || val64 < ZEND_LONG_MIN) {
RETVAL_DOUBLE(val64);
} else {
- RETVAL_LONG((long)val64);
+ RETVAL_LONG((zend_long)val64);
}
break;
case FORMAT_TYPE_DOUBLE:
@@ -97,7 +97,7 @@ PHP_FUNCTION( numfmt_parse )
RETVAL_DOUBLE(val_double);
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported format type %ld", type);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported format type %pd", type);
RETVAL_FALSE;
break;
}
@@ -157,7 +157,7 @@ PHP_FUNCTION( numfmt_parse_currency )
if(zposition) {
ZVAL_DEREF(zposition);
- convert_to_long(zposition);
+ convert_to_int(zposition);
position = (int32_t)Z_LVAL_P( zposition );
position_p = &position;
}
diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c
index 5caacb4f28..f8dc9895e5 100644
--- a/ext/intl/grapheme/grapheme_string.c
+++ b/ext/intl/grapheme/grapheme_string.c
@@ -111,7 +111,7 @@ PHP_FUNCTION(grapheme_strpos)
unsigned char *haystack, *needle;
int haystack_len, needle_len;
unsigned char *found;
- long loffset = 0;
+ zend_long loffset = 0;
int32_t offset = 0;
int ret_pos;
@@ -178,7 +178,7 @@ PHP_FUNCTION(grapheme_stripos)
unsigned char *haystack, *needle, *haystack_dup, *needle_dup;
int haystack_len, needle_len;
unsigned char *found;
- long loffset = 0;
+ zend_long loffset = 0;
int32_t offset = 0;
int ret_pos;
int is_ascii;
@@ -252,7 +252,7 @@ PHP_FUNCTION(grapheme_strrpos)
{
unsigned char *haystack, *needle;
int haystack_len, needle_len;
- long loffset = 0;
+ zend_long loffset = 0;
int32_t offset = 0;
int32_t ret_pos;
int is_ascii;
@@ -322,7 +322,7 @@ PHP_FUNCTION(grapheme_strripos)
{
unsigned char *haystack, *needle;
int haystack_len, needle_len;
- long loffset = 0;
+ zend_long loffset = 0;
int32_t offset = 0;
int32_t ret_pos;
int is_ascii;
@@ -401,7 +401,7 @@ PHP_FUNCTION(grapheme_substr)
unsigned char *str, *sub_str;
UChar *ustr;
int str_len, sub_str_len, ustr_len;
- long lstart = 0, length = 0;
+ zend_long lstart = 0, length = 0;
int32_t start = 0;
int iter_val;
UErrorCode status;
@@ -816,10 +816,10 @@ PHP_FUNCTION(grapheme_extract)
unsigned char *str, *pstr;
UChar *ustr;
int str_len, ustr_len;
- long size; /* maximum number of grapheme clusters, bytes, or characters (based on extract_type) to return */
- long lstart = 0; /* starting position in str in bytes */
+ zend_long size; /* maximum number of grapheme clusters, bytes, or characters (based on extract_type) to return */
+ zend_long lstart = 0; /* starting position in str in bytes */
int32_t start = 0;
- long extract_type = GRAPHEME_EXTRACT_TYPE_COUNT;
+ zend_long extract_type = GRAPHEME_EXTRACT_TYPE_COUNT;
UErrorCode status;
unsigned char u_break_iterator_buffer[U_BRK_SAFECLONE_BUFFERSIZE];
UBreakIterator* bi = NULL;
@@ -898,7 +898,7 @@ PHP_FUNCTION(grapheme_extract)
*/
if ( -1 != grapheme_ascii_check(pstr, size + 1 < str_len ? size + 1 : str_len ) ) {
- long nsize = ( size < str_len ? size : str_len );
+ zend_long nsize = ( size < str_len ? size : str_len );
if ( NULL != next ) {
ZVAL_LONG(next, start+nsize);
}
diff --git a/ext/intl/grapheme/grapheme_util.h b/ext/intl/grapheme/grapheme_util.h
index 14f3f22c45..235d043818 100644
--- a/ext/intl/grapheme/grapheme_util.h
+++ b/ext/intl/grapheme/grapheme_util.h
@@ -44,6 +44,6 @@ int32_t grapheme_strrpos_ascii(unsigned char *haystack, int32_t haystack_len, un
UBreakIterator* grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status TSRMLS_DC );
/* OUTSIDE_STRING: check if (possibly negative) long offset is outside the string with int32_t length */
-#define OUTSIDE_STRING(offset, max_len) ( offset <= INT32_MIN || offset > INT32_MAX || (offset < 0 ? -offset > (long) max_len : offset >= (long) max_len) )
+#define OUTSIDE_STRING(offset, max_len) ( offset <= INT32_MIN || offset > INT32_MAX || (offset < 0 ? -offset > (zend_long) max_len : offset >= (zend_long) max_len) )
#endif // GRAPHEME_GRAPHEME_UTIL_H
diff --git a/ext/intl/idn/idn.c b/ext/intl/idn/idn.c
index 6bf187a068..8075c86124 100644
--- a/ext/intl/idn/idn.c
+++ b/ext/intl/idn/idn.c
@@ -140,14 +140,14 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
UIDNA *uts46;
int32_t len;
int32_t buffer_capac = 255; /* no domain name may exceed this */
- zend_string *buffer = STR_ALLOC(buffer_capac, 0);
+ zend_string *buffer = zend_string_alloc(buffer_capac, 0);
UIDNAInfo info = UIDNA_INFO_INITIALIZER;
int buffer_used = 0;
uts46 = uidna_openUTS46(option, &status);
if (php_intl_idn_check_status(status, "failed to open UIDNA instance",
mode TSRMLS_CC) == FAILURE) {
- STR_FREE(buffer);
+ zend_string_free(buffer);
RETURN_FALSE;
}
@@ -161,7 +161,7 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
if (php_intl_idn_check_status(status, "failed to convert name",
mode TSRMLS_CC) == FAILURE) {
uidna_close(uts46);
- STR_FREE(buffer);
+ zend_string_free(buffer);
RETURN_FALSE;
}
if (len >= 255) {
@@ -190,11 +190,11 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
}
add_assoc_bool_ex(idna_info, "isTransitionalDifferent",
sizeof("isTransitionalDifferent")-1, info.isTransitionalDifferent);
- add_assoc_long_ex(idna_info, "errors", sizeof("errors")-1, (long)info.errors);
+ add_assoc_long_ex(idna_info, "errors", sizeof("errors")-1, (zend_long)info.errors);
}
if (!buffer_used) {
- STR_FREE(buffer);
+ zend_string_free(buffer);
}
uidna_close(uts46);
@@ -265,7 +265,7 @@ static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
char *domain;
int domain_len;
- long option = 0,
+ zend_long option = 0,
variant = INTL_IDN_VARIANT_2003;
zval *idna_info = NULL;
diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c
index e692e5dc0d..5c082ce190 100644
--- a/ext/intl/intl_error.c
+++ b/ext/intl/intl_error.c
@@ -258,7 +258,7 @@ smart_str intl_parse_error_to_string( UParseError* pe )
if( pe->line > 0 )
{
smart_str_appends( &ret, "on line " );
- smart_str_append_long( &ret, (long ) pe->line );
+ smart_str_append_long( &ret, (zend_long ) pe->line );
any = 1;
}
if( pe->offset >= 0 ) {
@@ -268,7 +268,7 @@ smart_str intl_parse_error_to_string( UParseError* pe )
smart_str_appends( &ret, "at " );
smart_str_appends( &ret, "offset " );
- smart_str_append_long( &ret, (long ) pe->offset );
+ smart_str_append_long( &ret, (zend_long ) pe->offset );
any = 1;
}
diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c
index 01cbddd062..f1821a6ada 100644
--- a/ext/intl/locale/locale_methods.c
+++ b/ext/intl/locale/locale_methods.c
@@ -241,9 +241,9 @@ PHP_NAMED_FUNCTION(zif_locale_set_default)
len = strlen(locale_name);
}
- ini_name = STR_INIT(LOCALE_INI_NAME, sizeof(LOCALE_INI_NAME) - 1, 0);
+ ini_name = zend_string_init(LOCALE_INI_NAME, sizeof(LOCALE_INI_NAME) - 1, 0);
zend_alter_ini_entry(ini_name, locale_name, len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
RETURN_TRUE;
}
diff --git a/ext/intl/msgformat/msgformat_data.h b/ext/intl/msgformat/msgformat_data.h
index 51d7687a3a..3b7bdda78e 100644
--- a/ext/intl/msgformat/msgformat_data.h
+++ b/ext/intl/msgformat/msgformat_data.h
@@ -30,7 +30,7 @@ typedef struct {
// formatter handling
UMessageFormat* umsgf;
char* orig_format;
- ulong orig_format_len;
+ zend_ulong orig_format_len;
HashTable* arg_types;
int tz_set; /* if we've already the time zone in sub-formats */
} msgformat_data;
diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp
index ba5a5df001..466db01731 100644
--- a/ext/intl/msgformat/msgformat_helpers.cpp
+++ b/ext/intl/msgformat/msgformat_helpers.cpp
@@ -112,7 +112,7 @@ static HashTable *umsg_get_numeric_types(MessageFormatter_object *mfo,
for (int i = 0; i < parts_count; i++) {
const Formattable::Type t = types[i];
- if (zend_hash_index_update_mem(ret, (ulong)i, (void*)&t, sizeof(t)) == NULL) {
+ if (zend_hash_index_update_mem(ret, (zend_ulong)i, (void*)&t, sizeof(t)) == NULL) {
intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR,
"Write to argument types hash table failed", 0 TSRMLS_CC);
break;
@@ -200,10 +200,10 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
"Found part with negative number", 0 TSRMLS_CC);
continue;
}
- if ((storedType = (Formattable::Type*)zend_hash_index_find_ptr(ret, (ulong)argNumber)) == NULL) {
+ if ((storedType = (Formattable::Type*)zend_hash_index_find_ptr(ret, (zend_ulong)argNumber)) == NULL) {
/* not found already; create new entry in HT */
Formattable::Type bogusType = Formattable::kObject;
- if ((storedType = (Formattable::Type*)zend_hash_index_update_mem(ret, (ulong)argNumber, (void*)&bogusType, sizeof(bogusType))) == NULL) {
+ if ((storedType = (Formattable::Type*)zend_hash_index_update_mem(ret, (zend_ulong)argNumber, (void*)&bogusType, sizeof(bogusType))) == NULL) {
intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR,
"Write to argument types hash table failed", 0 TSRMLS_CC);
continue;
@@ -388,7 +388,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
// Key related variables
zend_string *str_index;
- ulong num_index;
+ zend_ulong num_index;
ZEND_HASH_FOREACH_KEY_VAL(args, num_index, str_index, elem) {
Formattable& formattable = fargs[argNum];
@@ -401,7 +401,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
/* Process key and retrieve type */
if (str_index == NULL) {
/* includes case where index < 0 because it's exposed as unsigned */
- if (num_index > (ulong)INT32_MAX) {
+ if (num_index > (zend_ulong)INT32_MAX) {
intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR,
"Found negative or too large array key", 0 TSRMLS_CC);
continue;
@@ -411,7 +411,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
int32_t len = u_sprintf(temp, "%u", (uint32_t)num_index);
key.append(temp, len);
- storedArgType = (Formattable::Type*)zend_hash_index_find_ptr(types, (ulong)num_index);
+ storedArgType = (Formattable::Type*)zend_hash_index_find_ptr(types, (zend_ulong)num_index);
} else { //string; assumed to be in UTF-8
intl_stringFromChar(key, str_index->val, str_index->len, &err.code);
@@ -567,7 +567,7 @@ retry_kint64:
break;
case IS_TRUE:
case IS_FALSE:
- convert_to_long_ex(elem);
+ convert_to_int_ex(elem);
/* Intentional fallthrough */
case IS_LONG:
formattable.setInt64((int64_t)Z_LVAL_P(elem));
@@ -663,10 +663,10 @@ U_CFUNC void umsg_parse_helper(UMessageFormat *fmt, int *count, zval **args, UCh
case Formattable::kInt64:
aInt64 = fargs[i].getInt64();
- if(aInt64 > LONG_MAX || aInt64 < -LONG_MAX) {
+ if(aInt64 > ZEND_LONG_MAX || aInt64 < -ZEND_LONG_MAX) {
ZVAL_DOUBLE(&(*args)[i], (double)aInt64);
} else {
- ZVAL_LONG(&(*args)[i], (long)aInt64);
+ ZVAL_LONG(&(*args)[i], (zend_long)aInt64);
}
break;
diff --git a/ext/intl/normalizer/normalizer_normalize.c b/ext/intl/normalizer/normalizer_normalize.c
index fe1d61e052..9eb8befa7f 100644
--- a/ext/intl/normalizer/normalizer_normalize.c
+++ b/ext/intl/normalizer/normalizer_normalize.c
@@ -34,7 +34,7 @@ PHP_FUNCTION( normalizer_normalize )
{
char* input = NULL;
/* form is optional, defaults to FORM_C */
- long form = NORMALIZER_DEFAULT;
+ zend_long form = NORMALIZER_DEFAULT;
int input_len = 0;
UChar* uinput = NULL;
@@ -174,7 +174,7 @@ PHP_FUNCTION( normalizer_is_normalized )
{
char* input = NULL;
/* form is optional, defaults to FORM_C */
- long form = NORMALIZER_DEFAULT;
+ zend_long form = NORMALIZER_DEFAULT;
int input_len = 0;
UChar* uinput = NULL;
diff --git a/ext/intl/php_intl.h b/ext/intl/php_intl.h
index f863f4bd47..86a75cb335 100644
--- a/ext/intl/php_intl.h
+++ b/ext/intl/php_intl.h
@@ -50,7 +50,7 @@ ZEND_BEGIN_MODULE_GLOBALS(intl)
collator_compare_func_t compare_func;
UBreakIterator* grapheme_iterator;
intl_error g_error;
- long error_level;
+ zend_long error_level;
zend_bool use_exceptions;
ZEND_END_MODULE_GLOBALS(intl)
diff --git a/ext/intl/resourcebundle/resourcebundle.c b/ext/intl/resourcebundle/resourcebundle.c
index 66978eb888..1232a42868 100644
--- a/ext/intl/resourcebundle/resourcebundle.c
+++ b/ext/intl/resourcebundle/resourcebundle.c
@@ -32,7 +32,7 @@ void resourcebundle_extract_value( zval *return_value, ResourceBundle_object *so
const int32_t* vfield;
int32_t ilen;
int i;
- long lfield;
+ zend_long lfield;
ResourceBundle_object* newrb;
restype = ures_getType( source->child );
diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c
index 77f2e90588..e2f821ef2c 100644
--- a/ext/intl/resourcebundle/resourcebundle_class.c
+++ b/ext/intl/resourcebundle/resourcebundle_class.c
@@ -259,7 +259,7 @@ PHP_FUNCTION( resourcebundle_get )
/* }}} */
/* {{{ resourcebundle_array_count */
-int resourcebundle_array_count(zval *object, long *count TSRMLS_DC)
+int resourcebundle_array_count(zval *object, zend_long *count TSRMLS_DC)
{
ResourceBundle_object *rb;
RESOURCEBUNDLE_METHOD_FETCH_OBJECT_NO_CHECK;
diff --git a/ext/intl/resourcebundle/resourcebundle_iterator.h b/ext/intl/resourcebundle/resourcebundle_iterator.h
index 01a66650b9..32818f847f 100644
--- a/ext/intl/resourcebundle/resourcebundle_iterator.h
+++ b/ext/intl/resourcebundle/resourcebundle_iterator.h
@@ -25,10 +25,10 @@ typedef struct {
zend_object_iterator intern;
ResourceBundle_object *subject;
zend_bool is_table;
- long length;
+ zend_long length;
zval current;
char *currentkey;
- long i;
+ zend_long i;
} ResourceBundle_iterator;
zend_object_iterator *resourcebundle_get_iterator( zend_class_entry *ce, zval *object, int byref TSRMLS_DC );
diff --git a/ext/intl/spoofchecker/spoofchecker_main.c b/ext/intl/spoofchecker/spoofchecker_main.c
index c37b9186a2..64c641ae10 100644
--- a/ext/intl/spoofchecker/spoofchecker_main.c
+++ b/ext/intl/spoofchecker/spoofchecker_main.c
@@ -115,7 +115,7 @@ PHP_METHOD(Spoofchecker, setAllowedLocales)
*/
PHP_METHOD(Spoofchecker, setChecks)
{
- long checks;
+ zend_long checks;
SPOOFCHECKER_METHOD_INIT_VARS;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &checks)) {
diff --git a/ext/intl/tests/dateformat_calendars.phpt b/ext/intl/tests/dateformat_calendars.phpt
index 2239af28df..7de6356455 100644
--- a/ext/intl/tests/dateformat_calendars.phpt
+++ b/ext/intl/tests/dateformat_calendars.phpt
@@ -5,7 +5,7 @@ date.timezone=Atlantic/Azores
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
diff --git a/ext/intl/tests/dateformat_create_cal_arg.phpt b/ext/intl/tests/dateformat_create_cal_arg.phpt
index a8f351247b..182ac9a3a0 100644
--- a/ext/intl/tests/dateformat_create_cal_arg.phpt
+++ b/ext/intl/tests/dateformat_create_cal_arg.phpt
@@ -3,7 +3,7 @@ IntlDateFormatter: several forms of the calendar arg
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
diff --git a/ext/intl/tests/dateformat_format.phpt b/ext/intl/tests/dateformat_format.phpt
index f9a90684dd..241c5f975a 100644
--- a/ext/intl/tests/dateformat_format.phpt
+++ b/ext/intl/tests/dateformat_format.phpt
@@ -2,7 +2,7 @@
datefmt_format_code()
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/dateformat_formatObject_calendar.phpt b/ext/intl/tests/dateformat_formatObject_calendar.phpt
index d3ab6260ff..9365387ce6 100644
--- a/ext/intl/tests/dateformat_formatObject_calendar.phpt
+++ b/ext/intl/tests/dateformat_formatObject_calendar.phpt
@@ -2,40 +2,40 @@
IntlDateFormatter::formatObject(): IntlCalendar tests
--SKIPIF--
<?php
-if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
-<?php
-ini_set("intl.error_level", E_WARNING);
-ini_set("intl.default_locale", "pt_PT");
-ini_set("date.timezone", "Europe/Lisbon");
-
-$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00'); //Europe/Lisbon
-echo IntlDateFormatter::formatObject($cal), "\n";
-echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
-echo IntlDateFormatter::formatObject($cal, null, "en-US"), "\n";
-echo IntlDateFormatter::formatObject($cal, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
-echo IntlDateFormatter::formatObject($cal, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
-
-$cal = IntlCalendar::fromDateTime('2012-01-01 05:00:00+03:00');
-echo datefmt_format_object($cal, IntlDateFormatter::FULL), "\n";
-
-$cal = IntlCalendar::createInstance(null,'en-US@calendar=islamic-civil');
-$cal->setTime(strtotime('2012-01-01 00:00:00')*1000.);
-echo IntlDateFormatter::formatObject($cal), "\n";
-echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n";
-
-?>
-==DONE==
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", "Europe/Lisbon");
+
+$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00'); //Europe/Lisbon
+echo IntlDateFormatter::formatObject($cal), "\n";
+echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
+echo IntlDateFormatter::formatObject($cal, null, "en-US"), "\n";
+echo IntlDateFormatter::formatObject($cal, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
+echo IntlDateFormatter::formatObject($cal, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
+
+$cal = IntlCalendar::fromDateTime('2012-01-01 05:00:00+03:00');
+echo datefmt_format_object($cal, IntlDateFormatter::FULL), "\n";
+
+$cal = IntlCalendar::createInstance(null,'en-US@calendar=islamic-civil');
+$cal->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==
+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
index d9ddb0e644..2c9e1e33be 100644
--- a/ext/intl/tests/dateformat_formatObject_datetime.phpt
+++ b/ext/intl/tests/dateformat_formatObject_datetime.phpt
@@ -2,33 +2,33 @@
IntlDateFormatter::formatObject(): DateTime tests
--SKIPIF--
<?php
-if (!extension_loaded('intl')) die('skip intl extension not enabled') ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+if (!extension_loaded('intl')) die('skip intl extension not enabled') ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
-<?php
-ini_set("intl.error_level", E_WARNING);
-ini_set("intl.default_locale", "pt_PT");
-ini_set("date.timezone", "Europe/Lisbon");
-
-$dt = new DateTime('2012-01-01 00:00:00'); //Europe/Lisbon
-echo IntlDateFormatter::formatObject($dt), "\n";
-echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
-echo IntlDateFormatter::formatObject($dt, null, "en-US"), "\n";
-echo IntlDateFormatter::formatObject($dt, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
-echo IntlDateFormatter::formatObject($dt, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
-
-$dt = new DateTime('2012-01-01 05:00:00+03:00');
-echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
-
-?>
-==DONE==
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", "Europe/Lisbon");
+
+$dt = new DateTime('2012-01-01 00:00:00'); //Europe/Lisbon
+echo IntlDateFormatter::formatObject($dt), "\n";
+echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
+echo IntlDateFormatter::formatObject($dt, null, "en-US"), "\n";
+echo IntlDateFormatter::formatObject($dt, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
+echo IntlDateFormatter::formatObject($dt, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
+
+$dt = new DateTime('2012-01-01 05:00:00+03:00');
+echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\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
-==DONE==
+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_format_parse.phpt b/ext/intl/tests/dateformat_format_parse.phpt
index dfb479e937..516951371a 100644
--- a/ext/intl/tests/dateformat_format_parse.phpt
+++ b/ext/intl/tests/dateformat_format_parse.phpt
@@ -2,7 +2,7 @@
datefmt_format_code() and datefmt_parse_code()
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/dateformat_get_set_calendar.phpt b/ext/intl/tests/dateformat_get_set_calendar.phpt
index f91fe5c775..73a26d0166 100644
--- a/ext/intl/tests/dateformat_get_set_calendar.phpt
+++ b/ext/intl/tests/dateformat_get_set_calendar.phpt
@@ -3,7 +3,7 @@ IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject()
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
diff --git a/ext/intl/tests/dateformat_get_set_timezone.phpt b/ext/intl/tests/dateformat_get_set_timezone.phpt
index 2a7ffa6c73..7973aee2e7 100644
--- a/ext/intl/tests/dateformat_get_set_timezone.phpt
+++ b/ext/intl/tests/dateformat_get_set_timezone.phpt
@@ -3,7 +3,7 @@ IntlDateFormatter: get/setTimeZone()
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
diff --git a/ext/intl/tests/dateformat_set_timezone_id2.phpt b/ext/intl/tests/dateformat_set_timezone_id2.phpt
index a1ee440e71..d59c8045e4 100644
--- a/ext/intl/tests/dateformat_set_timezone_id2.phpt
+++ b/ext/intl/tests/dateformat_set_timezone_id2.phpt
@@ -5,7 +5,7 @@ date.timezone=Atlantic/Azores
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/dateformat_timezone_arg_variations.phpt b/ext/intl/tests/dateformat_timezone_arg_variations.phpt
index 9fbb145c72..77d7caae3a 100644
--- a/ext/intl/tests/dateformat_timezone_arg_variations.phpt
+++ b/ext/intl/tests/dateformat_timezone_arg_variations.phpt
@@ -3,7 +3,7 @@ IntlDateFormatter: several forms of the timezone arg
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
diff --git a/ext/intl/tests/formatter_get_locale.phpt b/ext/intl/tests/formatter_get_locale.phpt
index 7474eabbba..a9c8af84a4 100644
--- a/ext/intl/tests/formatter_get_locale.phpt
+++ b/ext/intl/tests/formatter_get_locale.phpt
@@ -1,8 +1,8 @@
--TEST--
-numfmt_get_locale()
+numfmt_get_locale() icu >= 4.8 && icu < 50.1.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/locale_filter_matches2.phpt b/ext/intl/tests/locale_filter_matches2.phpt
index 12d247dc6b..46771b7c1a 100644
--- a/ext/intl/tests/locale_filter_matches2.phpt
+++ b/ext/intl/tests/locale_filter_matches2.phpt
@@ -1,9 +1,9 @@
--TEST--
-locale_filter_matches.phpt() icu >= 4.8 && icu < 51.2
+locale_filter_matches.phpt() icu >= 4.8 && icu < 50.1.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/locale_get_display_name2.phpt b/ext/intl/tests/locale_get_display_name2.phpt
index bd8cb50cd5..dcc996eca9 100644
--- a/ext/intl/tests/locale_get_display_name2.phpt
+++ b/ext/intl/tests/locale_get_display_name2.phpt
@@ -1,9 +1,9 @@
--TEST--
-locale_get_display_name() icu >= 4.8 && icu < 51.2
+locale_get_display_name() icu >= 4.8 && icu < 50.1.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/locale_get_display_region2.phpt b/ext/intl/tests/locale_get_display_region2.phpt
index 1d7354bd1b..82334db461 100644
--- a/ext/intl/tests/locale_get_display_region2.phpt
+++ b/ext/intl/tests/locale_get_display_region2.phpt
@@ -3,7 +3,7 @@ locale_get_display_region() icu >= 4.8 && icu < 51.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/locale_lookup.phpt b/ext/intl/tests/locale_lookup.phpt
index df5204f07d..ff8aab049d 100644
--- a/ext/intl/tests/locale_lookup.phpt
+++ b/ext/intl/tests/locale_lookup.phpt
@@ -1,8 +1,8 @@
--TEST--
-locale_lookup.phpt()
+locale_lookup.phpt() icu >= 4.8 && icu < 50.1.2
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
diff --git a/ext/intl/tests/msgfmt_format_intlcalendar.phpt b/ext/intl/tests/msgfmt_format_intlcalendar.phpt
index a6bff2ecdd..029f89ab9c 100644
--- a/ext/intl/tests/msgfmt_format_intlcalendar.phpt
+++ b/ext/intl/tests/msgfmt_format_intlcalendar.phpt
@@ -1,9 +1,9 @@
--TEST--
-MessageFormat accepts IntlCalendar args
+MessageFormat accepts IntlCalendar args icu >= 4.8 && icu < 50.1.2
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
diff --git a/ext/intl/tests/resourcebundle_null_mandatory_args.phpt b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt
index bbbc1b1e91..2eb8a240dd 100644
--- a/ext/intl/tests/resourcebundle_null_mandatory_args.phpt
+++ b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt
@@ -5,7 +5,7 @@ date.timezone=Atlantic/Azores
--SKIPIF--
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '4.8') < 0) die('skip ICU >= 4.8 only'); ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
diff --git a/ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt b/ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt
index 8f60f29040..706d8824ba 100644
--- a/ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt
+++ b/ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt
@@ -1,9 +1,9 @@
--TEST--
-IntlTimeZone::getDisplayName(): type parameter (ICU >= 49 && ICU < 51.2)
+IntlTimeZone::getDisplayName(): type parameter (ICU >= 49 && ICU < 50.1.2)
--SKIPIF--
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '49') < 0) die('skip for ICU 49+'); ?>
-<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
@@ -33,4 +33,4 @@ string(5) "+0000"
string(3) "GMT"
string(3) "GMT"
string(22) "Portugal Time (Lisbon)"
-==DONE==
+==DONE==
diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp
index be30c2d541..623a643c49 100644
--- a/ext/intl/timezone/timezone_class.cpp
+++ b/ext/intl/timezone/timezone_class.cpp
@@ -249,7 +249,7 @@ static zend_object *TimeZone_clone_obj(zval *object TSRMLS_DC)
"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->val, 0 TSRMLS_CC);
- STR_FREE(err_msg);
+ zend_string_free(err_msg);
} else {
to_new->utimezone = newTimeZone;
}
@@ -331,9 +331,9 @@ static HashTable *TimeZone_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
return debug_info;
}
- ZVAL_LONG(&zv, (long)rawOffset);
+ ZVAL_LONG(&zv, (zend_long)rawOffset);
zend_hash_str_update(debug_info,"rawOffset", sizeof("rawOffset") - 1, &zv);
- ZVAL_LONG(&zv, (long)(rawOffset + dstOffset));
+ ZVAL_LONG(&zv, (zend_long)(rawOffset + dstOffset));
zend_hash_str_update(debug_info,"currentOffset", sizeof("currentOffset") - 1, &zv);
return debug_info;
diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp
index a8332dbf7e..9bbd182dee 100644
--- a/ext/intl/timezone/timezone_methods.cpp
+++ b/ext/intl/timezone/timezone_methods.cpp
@@ -161,8 +161,8 @@ U_CFUNC PHP_FUNCTION(intltz_create_enumeration)
se = TimeZone::createEnumeration();
} else if (Z_TYPE_P(arg) == IS_LONG) {
int_offset:
- if (Z_LVAL_P(arg) < (long)INT32_MIN ||
- Z_LVAL_P(arg) > (long)INT32_MAX) {
+ if (Z_LVAL_P(arg) < (zend_long)INT32_MIN ||
+ Z_LVAL_P(arg) > (zend_long)INT32_MAX) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intltz_create_enumeration: value is out of range", 0 TSRMLS_CC);
RETURN_FALSE;
@@ -171,10 +171,10 @@ int_offset:
}
} else if (Z_TYPE_P(arg) == IS_DOUBLE) {
double_offset:
- convert_to_long_ex(arg);
+ convert_to_int_ex(arg);
goto int_offset;
} else if (Z_TYPE_P(arg) == IS_OBJECT || Z_TYPE_P(arg) == IS_STRING) {
- long lval;
+ zend_long lval;
double dval;
convert_to_string_ex(arg);
switch (is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &lval, &dval, 0)) {
@@ -228,13 +228,13 @@ U_CFUNC PHP_FUNCTION(intltz_count_equivalent_ids)
}
int32_t result = TimeZone::countEquivalentIDs(id);
- RETURN_LONG((long)result);
+ RETURN_LONG((zend_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,
+ zend_long zoneType,
offset_arg;
char *region = NULL;
int region_len = 0;
@@ -265,7 +265,7 @@ U_CFUNC PHP_FUNCTION(intltz_create_time_zone_id_enumeration)
}
if (ZEND_NUM_ARGS() == 3) {
- if (offset_arg < (long)INT32_MIN || offset_arg > (long)INT32_MAX) {
+ if (offset_arg < (zend_long)INT32_MIN || offset_arg > (zend_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;
@@ -383,12 +383,12 @@ U_CFUNC PHP_FUNCTION(intltz_get_equivalent_id)
{
char *str_id;
int str_id_len;
- long index;
+ zend_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) {
+ index < (zend_long)INT32_MIN || index > (zend_long)INT32_MAX) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intltz_get_equivalent_id: bad arguments", 0 TSRMLS_CC);
RETURN_FALSE;
@@ -545,7 +545,7 @@ static const TimeZone::EDisplayType display_types[] = {
U_CFUNC PHP_FUNCTION(intltz_get_display_name)
{
zend_bool daylight = 0;
- long display_type = TimeZone::LONG;
+ zend_long display_type = TimeZone::LONG;
const char *locale_str = NULL;
int dummy = 0;
TIMEZONE_METHOD_INIT_VARS;
@@ -603,7 +603,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_dst_savings)
TIMEZONE_METHOD_FETCH_OBJECT;
- RETURN_LONG((long)to->utimezone->getDSTSavings());
+ RETURN_LONG((zend_long)to->utimezone->getDSTSavings());
}
U_CFUNC PHP_FUNCTION(intltz_to_date_time_zone)
@@ -646,7 +646,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_error_code)
if (to == NULL)
RETURN_FALSE;
- RETURN_LONG((long)TIMEZONE_ERROR_CODE(to));
+ RETURN_LONG((zend_long)TIMEZONE_ERROR_CODE(to));
}
U_CFUNC PHP_FUNCTION(intltz_get_error_message)
diff --git a/ext/intl/transliterator/transliterator_class.c b/ext/intl/transliterator/transliterator_class.c
index 1373db0c5b..ff299a8f38 100644
--- a/ext/intl/transliterator/transliterator_class.c
+++ b/ext/intl/transliterator/transliterator_class.c
@@ -183,7 +183,7 @@ err:
err_msg = intl_error_get_message( TRANSLITERATOR_ERROR_P( to_orig ) TSRMLS_CC );
php_error_docref( NULL TSRMLS_CC, E_ERROR, "%s", err_msg->val );
- STR_FREE( err_msg ); /* if it's changed into a warning */
+ zend_string_free( err_msg ); /* if it's changed into a warning */
/* do not destroy tempz; we need to return something */
}
}
diff --git a/ext/intl/transliterator/transliterator_methods.c b/ext/intl/transliterator/transliterator_methods.c
index 4403de08aa..e2b1929216 100644
--- a/ext/intl/transliterator/transliterator_methods.c
+++ b/ext/intl/transliterator/transliterator_methods.c
@@ -27,7 +27,7 @@
#include <zend_exceptions.h>
-static int create_transliterator( char *str_id, int str_id_len, long direction, zval *object TSRMLS_DC )
+static int create_transliterator( char *str_id, int str_id_len, zend_long direction, zval *object TSRMLS_DC )
{
Transliterator_object *to;
UChar *ustr_id = NULL;
@@ -105,7 +105,7 @@ PHP_FUNCTION( transliterator_create )
{
char *str_id;
int str_id_len;
- long direction = TRANSLITERATOR_FORWARD;
+ zend_long direction = TRANSLITERATOR_FORWARD;
int res;
TRANSLITERATOR_METHOD_INIT_VARS;
@@ -139,7 +139,7 @@ PHP_FUNCTION( transliterator_create_from_rules )
int str_rules_len;
UChar *ustr_rules = NULL;
int32_t ustr_rules_len = 0;
- long direction = TRANSLITERATOR_FORWARD;
+ zend_long direction = TRANSLITERATOR_FORWARD;
UParseError parse_error = {0, -1};
UTransliterator *utrans;
UChar id[] = {0x52, 0x75, 0x6C, 0x65, 0x73, 0x54, 0x72,
@@ -307,7 +307,7 @@ PHP_FUNCTION( transliterator_transliterate )
int32_t ustr_len = 0,
capacity,
uresult_len;
- long start = 0,
+ zend_long start = 0,
limit = -1;
int success = 0;
zval tmp_object;
@@ -349,7 +349,7 @@ PHP_FUNCTION( transliterator_transliterate )
zend_string *message = intl_error_get_message( NULL TSRMLS_CC );
php_error_docref0( NULL TSRMLS_CC, E_WARNING, "Could not create "
"transliterator with ID \"%s\" (%s)", Z_STRVAL_P( arg1 ), message->val );
- STR_FREE( message );
+ zend_string_free( message );
/* don't set U_ILLEGAL_ARGUMENT_ERROR to allow fetching of inner error */
goto cleanup;
}
@@ -497,7 +497,7 @@ PHP_FUNCTION( transliterator_get_error_code )
if (to == NULL )
RETURN_FALSE;
- RETURN_LONG( (long) TRANSLITERATOR_ERROR_CODE( to ) );
+ RETURN_LONG( (zend_long) TRANSLITERATOR_ERROR_CODE( to ) );
}
/* }}} */
diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c
index 116fc0c9b6..a9f1b0a7ae 100644
--- a/ext/json/JSON_parser.c
+++ b/ext/json/JSON_parser.c
@@ -373,7 +373,7 @@ static void utf16_to_utf8(smart_str *buf, unsigned short utf16)
&& ((unsigned char) buf->s->val[buf->s->len - 1] & 0xc0) == 0x80)
{
/* found surrogate pair */
- unsigned long utf32;
+ zend_ulong utf32;
utf32 = (((buf->s->val[buf->s->len - 2] & 0xf) << 16)
| ((buf->s->val[buf->s->len - 1] & 0x3f) << 10)
diff --git a/ext/json/json.c b/ext/json/json.c
index bc0544808f..cbdec32d88 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -177,7 +177,7 @@ static int json_determine_array_type(zval *val TSRMLS_DC) /* {{{ */
i = myht ? zend_hash_num_elements(myht) : 0;
if (i > 0) {
zend_string *key;
- ulong index, idx;
+ zend_ulong index, idx;
idx = 0;
ZEND_HASH_FOREACH_KEY(myht, index, key) {
@@ -252,7 +252,7 @@ static void json_encode_array(smart_str *buf, zval *val, int options TSRMLS_DC)
if (i > 0) {
zend_string *key;
zval *data;
- ulong index;
+ zend_ulong index;
HashTable *tmp_ht;
ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, data) {
@@ -308,7 +308,7 @@ static void json_encode_array(smart_str *buf, zval *val, int options TSRMLS_DC)
json_pretty_print_indent(buf, options TSRMLS_CC);
smart_str_appendc(buf, '"');
- smart_str_append_long(buf, (long) index);
+ smart_str_append_long(buf, (zend_long) index);
smart_str_appendc(buf, '"');
smart_str_appendc(buf, ':');
@@ -395,7 +395,7 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR
if (options & PHP_JSON_NUMERIC_CHECK) {
double d;
int type;
- long p;
+ zend_long p;
if ((type = is_numeric_string(s, len, &p, &d, 0)) != 0) {
if (type == IS_LONG) {
@@ -651,7 +651,7 @@ again:
}
/* }}} */
-PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, int str_len, int options, long depth TSRMLS_DC) /* {{{ */
+PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, int str_len, int options, zend_long depth TSRMLS_DC) /* {{{ */
{
int utf16_len;
unsigned short *utf16;
@@ -678,7 +678,7 @@ PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, int str_len,
if (!parse_JSON_ex(jp, return_value, utf16, utf16_len, options TSRMLS_CC)) {
double d;
int type, overflow_info;
- long p;
+ zend_long p;
char *trim = str;
int trim_len = str_len;
@@ -758,8 +758,8 @@ static PHP_FUNCTION(json_encode)
{
zval *parameter;
smart_str buf = {0};
- long options = 0;
- long depth = JSON_PARSER_DEFAULT_DEPTH;
+ zend_long options = 0;
+ zend_long depth = JSON_PARSER_DEFAULT_DEPTH;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ll", &parameter, &options, &depth) == FAILURE) {
return;
@@ -788,8 +788,8 @@ static PHP_FUNCTION(json_decode)
char *str;
int str_len;
zend_bool assoc = 0; /* return JS objects as PHP objects by default */
- long depth = JSON_PARSER_DEFAULT_DEPTH;
- long options = 0;
+ zend_long depth = JSON_PARSER_DEFAULT_DEPTH;
+ zend_long options = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bll", &str, &str_len, &assoc, &depth, &options) == FAILURE) {
return;
diff --git a/ext/json/php_json.h b/ext/json/php_json.h
index e00de6a27b..59d65ec3c8 100644
--- a/ext/json/php_json.h
+++ b/ext/json/php_json.h
@@ -50,7 +50,7 @@ ZEND_END_MODULE_GLOBALS(json)
#endif
PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_DC);
-PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, int str_len, int options, long depth TSRMLS_DC);
+PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, int str_len, int options, zend_long depth TSRMLS_DC);
extern PHP_JSON_API zend_class_entry *php_json_serializable_ce;
@@ -74,7 +74,7 @@ extern PHP_JSON_API zend_class_entry *php_json_serializable_ce;
#define PHP_JSON_OBJECT_AS_ARRAY (1<<0)
#define PHP_JSON_BIGINT_AS_STRING (1<<1)
-static inline void php_json_decode(zval *return_value, char *str, int str_len, zend_bool assoc, long depth TSRMLS_DC)
+static inline void php_json_decode(zval *return_value, char *str, int str_len, zend_bool assoc, zend_long depth TSRMLS_DC)
{
php_json_decode_ex(return_value, str, str_len, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0, depth TSRMLS_CC);
}
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 8f52f1f3fb..b029a83f63 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -241,9 +241,9 @@ PHP_MINFO_FUNCTION(ldap)
php_info_print_table_row(2, "RCS Version", "$Id$");
if (LDAPG(max_links) == -1) {
- snprintf(tmp, 31, "%ld/unlimited", LDAPG(num_links));
+ snprintf(tmp, 31, ZEND_LONG_FMT "/unlimited", LDAPG(num_links));
} else {
- snprintf(tmp, 31, "%ld/%ld", LDAPG(num_links), LDAPG(max_links));
+ snprintf(tmp, 31, ZEND_LONG_FMT "/" ZEND_LONG_FMT, LDAPG(num_links), LDAPG(max_links));
}
php_info_print_table_row(2, "Total Links", tmp);
@@ -295,11 +295,11 @@ PHP_FUNCTION(ldap_connect)
{
char *host = NULL;
int hostlen;
- long port = 389; /* Default port */
+ zend_long port = 389; /* Default port */
#ifdef HAVE_ORALDAP
char *wallet = NULL, *walletpasswd = NULL;
int walletlen = 0, walletpasswdlen = 0;
- long authmode = GSLC_SSL_NO_AUTH;
+ zend_long authmode = GSLC_SSL_NO_AUTH;
int ssl=0;
#endif
ldap_linkdata *ld;
@@ -324,7 +324,7 @@ PHP_FUNCTION(ldap_connect)
#endif
if (LDAPG(max_links) != -1 && LDAPG(num_links) >= LDAPG(max_links)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%ld)", LDAPG(num_links));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%pd)", LDAPG(num_links));
RETURN_FALSE;
}
@@ -610,7 +610,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref, in
static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
{
zval *link, *base_dn, *filter, *attrs = NULL, *attr;
- long attrsonly, sizelimit, timelimit, deref;
+ zend_long attrsonly, sizelimit, timelimit, deref;
char *ldap_base_dn = NULL, *ldap_filter = NULL, **ldap_attrs = NULL;
ldap_linkdata *ld = NULL;
LDAPMessage *ldap_res;
@@ -1031,7 +1031,7 @@ PHP_FUNCTION(ldap_first_attribute)
ldap_linkdata *ld;
ldap_resultentry *resultentry;
char *attribute;
- long dummy_ber;
+ zend_long dummy_ber;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &link, &result_entry, &dummy_ber) != SUCCESS) {
return;
@@ -1059,7 +1059,7 @@ PHP_FUNCTION(ldap_next_attribute)
ldap_linkdata *ld;
ldap_resultentry *resultentry;
char *attribute;
- long dummy_ber;
+ zend_long dummy_ber;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &link, &result_entry, &dummy_ber) != SUCCESS) {
return;
@@ -1214,7 +1214,7 @@ PHP_FUNCTION(ldap_get_dn)
Splits DN into its component parts */
PHP_FUNCTION(ldap_explode_dn)
{
- long with_attrib;
+ zend_long with_attrib;
char *dn, **ldap_value;
int i, count, dn_len;
@@ -1280,7 +1280,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
int i, j, num_attribs, num_values, dn_len;
int *num_berval;
zend_string *attribute;
- ulong index;
+ zend_ulong index;
int is_full_add=0; /* flag for full add operation so ldap_mod_add can be put back into oper, gerrit THomson */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsa", &link, &dn, &dn_len, &entry) != SUCCESS) {
@@ -1539,10 +1539,10 @@ PHP_FUNCTION(ldap_modify_batch)
/* perform validation */
{
zend_string *modkey;
- long modtype;
+ zend_long modtype;
/* to store the wrongly-typed keys */
- ulong tmpUlong;
+ zend_ulong tmpUlong;
/* make sure the DN contains no NUL bytes */
if (_ldap_strlen_max(dn, dn_len) != dn_len) {
@@ -1808,7 +1808,7 @@ PHP_FUNCTION(ldap_errno)
Convert error number to error string */
PHP_FUNCTION(ldap_err2str)
{
- long perrno;
+ zend_long perrno;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &perrno) != SUCCESS) {
return;
@@ -1908,7 +1908,7 @@ PHP_FUNCTION(ldap_get_option)
{
zval *link, *retval;
ldap_linkdata *ld;
- long option;
+ zend_long option;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz/", &link, &option, &retval) != SUCCESS) {
return;
@@ -2013,7 +2013,7 @@ PHP_FUNCTION(ldap_set_option)
zval *link, *newval;
ldap_linkdata *ld;
LDAP *ldap;
- long option;
+ zend_long option;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zlz", &link, &option, &newval) != SUCCESS) {
return;
@@ -2039,7 +2039,7 @@ PHP_FUNCTION(ldap_set_option)
{
int val;
- convert_to_long_ex(newval);
+ convert_to_int_ex(newval);
val = Z_LVAL_P(newval);
if (ldap_set_option(ldap, option, &val)) {
RETURN_FALSE;
@@ -2050,7 +2050,7 @@ PHP_FUNCTION(ldap_set_option)
{
struct timeval timeout;
- convert_to_long_ex(newval);
+ convert_to_int_ex(newval);
timeout.tv_sec = Z_LVAL_P(newval);
timeout.tv_usec = 0;
if (ldap_set_option(ldap, LDAP_OPT_NETWORK_TIMEOUT, (void *) &timeout)) {
@@ -2062,7 +2062,7 @@ PHP_FUNCTION(ldap_set_option)
{
int timeout;
- convert_to_long_ex(newval);
+ convert_to_int_ex(newval);
timeout = 1000 * Z_LVAL_P(newval); /* Convert to milliseconds */
if (ldap_set_option(ldap, LDAP_X_OPT_CONNECT_TIMEOUT, &timeout)) {
RETURN_FALSE;
@@ -2424,7 +2424,7 @@ int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgi
ZVAL_COPY_VALUE(&cb_args[0], cb_link);
ZVAL_STRING(&cb_args[1], url);
if (call_user_function_ex(EG(function_table), NULL, &ld->rebindproc, &cb_retval, 2, cb_args, 0, NULL TSRMLS_CC) == SUCCESS && !Z_ISUNDEF(cb_retval)) {
- convert_to_long_ex(&cb_retval);
+ convert_to_int_ex(&cb_retval);
retval = Z_LVAL(cb_retval);
zval_ptr_dtor(&cb_retval);
} else {
@@ -2463,10 +2463,10 @@ PHP_FUNCTION(ldap_set_rebind_proc)
/* callable? */
if (!zend_is_callable(callback, 0, &callback_name TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Two arguments expected for '%s' to be a valid callback", callback_name->val);
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
RETURN_FALSE;
}
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
/* register rebind procedure */
if (Z_ISUNDEF(ld->rebindproc)) {
@@ -2522,7 +2522,7 @@ PHP_FUNCTION(ldap_escape)
char *value, *ignores, *result;
int valuelen = 0, ignoreslen = 0, i;
size_t resultlen;
- long flags = 0;
+ zend_long flags = 0;
zend_bool map[256] = {0}, havecharlist = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sl", &value, &valuelen, &ignores, &ignoreslen, &flags) != SUCCESS) {
@@ -2613,7 +2613,7 @@ PHP_FUNCTION(ldap_8859_to_t61)
Inject paged results control*/
PHP_FUNCTION(ldap_control_paged_result)
{
- long pagesize;
+ zend_long pagesize;
zend_bool iscritical;
zval *link;
char *cookie = NULL;
diff --git a/ext/ldap/php_ldap.h b/ext/ldap/php_ldap.h
index bd3731819d..944c3dd531 100644
--- a/ext/ldap/php_ldap.h
+++ b/ext/ldap/php_ldap.h
@@ -38,8 +38,8 @@ PHP_MSHUTDOWN_FUNCTION(ldap);
PHP_MINFO_FUNCTION(ldap);
ZEND_BEGIN_MODULE_GLOBALS(ldap)
- long num_links;
- long max_links;
+ zend_long num_links;
+ zend_long max_links;
ZEND_END_MODULE_GLOBALS(ldap)
#ifdef ZTS
diff --git a/ext/mbstring/mb_gpc.c b/ext/mbstring/mb_gpc.c
index a0aab076a5..92e7327787 100644
--- a/ext/mbstring/mb_gpc.c
+++ b/ext/mbstring/mb_gpc.c
@@ -197,7 +197,7 @@ const mbfl_encoding *_php_mb_encoding_handler_ex(const php_mb_encoding_handler_i
char *strtok_buf = NULL, **val_list = NULL;
zval *array_ptr = (zval *) arg;
int n, num, *len_list = NULL;
- unsigned int val_len, new_val_len;
+ size_t val_len, new_val_len;
mbfl_string string, resvar, resval;
const mbfl_encoding *from_encoding = NULL;
mbfl_encoding_detector *identd = NULL;
@@ -254,7 +254,7 @@ const mbfl_encoding *_php_mb_encoding_handler_ex(const php_mb_encoding_handler_i
}
if (n > (PG(max_input_vars) * 2)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %pd. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
goto out;
}
@@ -378,7 +378,7 @@ SAPI_POST_HANDLER_FUNC(php_mb_post_handler)
php_stream_rewind(SG(request_info).request_body);
post_data_str = php_stream_copy_to_mem(SG(request_info).request_body, PHP_STREAM_COPY_ALL, 0);
detected = _php_mb_encoding_handler_ex(&info, arg, post_data_str->val TSRMLS_CC);
- STR_RELEASE(post_data_str);
+ zend_string_release(post_data_str);
MBSTRG(http_input_identify) = detected;
if (detected) {
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 248bd98535..4c78788127 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -1738,14 +1738,14 @@ PHP_FUNCTION(mb_language)
if (name == NULL) {
RETVAL_STRING((char *)mbfl_no_language2name(MBSTRG(language)));
} else {
- zend_string *ini_name = STR_INIT("mbstring.language", sizeof("mbstring.language") - 1, 0);
+ zend_string *ini_name = zend_string_init("mbstring.language", sizeof("mbstring.language") - 1, 0);
if (FAILURE == zend_alter_ini_entry(ini_name, name, name_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown language \"%s\"", name);
RETVAL_FALSE;
} else {
RETVAL_TRUE;
}
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
}
/* }}} */
@@ -1993,7 +1993,7 @@ PHP_FUNCTION(mb_substitute_character)
} else if (strncasecmp("entity", Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)) == 0) {
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY;
} else {
- convert_to_long_ex(arg1);
+ convert_to_int_ex(arg1);
if (Z_LVAL_P(arg1) < 0xffff && Z_LVAL_P(arg1) > 0x0) {
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
@@ -2005,7 +2005,7 @@ PHP_FUNCTION(mb_substitute_character)
}
break;
default:
- convert_to_long_ex(arg1);
+ convert_to_int_ex(arg1);
if (Z_LVAL_P(arg1) < 0xffff && Z_LVAL_P(arg1) > 0x0) {
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
MBSTRG(current_filter_illegal_substchar) = Z_LVAL_P(arg1);
@@ -2106,7 +2106,7 @@ PHP_FUNCTION(mb_output_handler)
{
char *arg_string;
int arg_string_len;
- long arg_status;
+ zend_long arg_status;
mbfl_string string, result;
const char *charset;
char *p;
@@ -2244,7 +2244,7 @@ PHP_FUNCTION(mb_strlen)
PHP_FUNCTION(mb_strpos)
{
int n, reverse = 0;
- long offset;
+ zend_long offset;
mbfl_string haystack, needle;
char *enc_name = NULL;
int enc_name_len;
@@ -2356,14 +2356,14 @@ PHP_FUNCTION(mb_strrpos)
}
if (str_flg) {
- convert_to_long_ex(zoffset);
+ convert_to_int_ex(zoffset);
offset = Z_LVAL_P(zoffset);
} else {
enc_name = enc_name2;
enc_name_len = enc_name_len2;
}
} else {
- convert_to_long_ex(zoffset);
+ convert_to_int_ex(zoffset);
offset = Z_LVAL_P(zoffset);
}
}
@@ -2406,7 +2406,7 @@ PHP_FUNCTION(mb_strrpos)
PHP_FUNCTION(mb_stripos)
{
int n;
- long offset;
+ zend_long offset;
mbfl_string haystack, needle;
const char *from_encoding = MBSTRG(current_internal_encoding)->mime_name;
int from_encoding_len;
@@ -2435,7 +2435,7 @@ PHP_FUNCTION(mb_stripos)
PHP_FUNCTION(mb_strripos)
{
int n;
- long offset;
+ zend_long offset;
mbfl_string haystack, needle;
const char *from_encoding = MBSTRG(current_internal_encoding)->mime_name;
int from_encoding_len;
@@ -2750,7 +2750,7 @@ PHP_FUNCTION(mb_substr)
{
size_t argc = ZEND_NUM_ARGS();
char *str, *encoding;
- long from, len;
+ zend_long from, len;
int mblen, str_len, encoding_len;
zval *z_len = NULL;
mbfl_string string, result, *ret;
@@ -2777,7 +2777,7 @@ PHP_FUNCTION(mb_substr)
if (argc < 3 || Z_TYPE_P(z_len) == IS_NULL) {
len = str_len;
} else {
- convert_to_long_ex(z_len);
+ convert_to_int_ex(z_len);
len = Z_LVAL_P(z_len);
}
@@ -2829,7 +2829,7 @@ PHP_FUNCTION(mb_strcut)
{
size_t argc = ZEND_NUM_ARGS();
char *encoding;
- long from, len;
+ zend_long from, len;
int encoding_len;
zval *z_len = NULL;
mbfl_string string, result, *ret;
@@ -2853,7 +2853,7 @@ PHP_FUNCTION(mb_strcut)
if (argc < 3 || Z_TYPE_P(z_len) == IS_NULL) {
len = string.len;
} else {
- convert_to_long_ex(z_len);
+ convert_to_int_ex(z_len);
len = Z_LVAL_P(z_len);
}
@@ -2932,7 +2932,7 @@ PHP_FUNCTION(mb_strwidth)
PHP_FUNCTION(mb_strimwidth)
{
char *str, *trimmarker, *encoding;
- long from, width;
+ zend_long from, width;
int str_len, trimmarker_len, encoding_len;
mbfl_string string, result, marker, *ret;
@@ -3148,7 +3148,7 @@ PHP_FUNCTION(mb_convert_case)
const char *from_encoding = MBSTRG(current_internal_encoding)->mime_name;
char *str;
int str_len, from_encoding_len;
- long case_mode = 0;
+ zend_long case_mode = 0;
char *newstr;
size_t ret_len;
@@ -3356,7 +3356,7 @@ PHP_FUNCTION(mb_encode_mimeheader)
int trans_enc_name_len;
char *linefeed = "\r\n";
int linefeed_len;
- long indent = 0;
+ zend_long indent = 0;
mbfl_string_init(&string);
string.no_language = MBSTRG(language);
@@ -3814,7 +3814,7 @@ php_mb_numericentity_exec(INTERNAL_FUNCTION_PARAMETERS, int type)
mapelm = convmap;
mapsize = 0;
ZEND_HASH_FOREACH_VAL(target_hash, hash_entry) {
- convert_to_long_ex(hash_entry);
+ convert_to_int_ex(hash_entry);
*mapelm++ = Z_LVAL_P(hash_entry);
mapsize++;
} ZEND_HASH_FOREACH_END();
@@ -3907,7 +3907,7 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t
}
if (state == 0 || state == 1) {
- fld_name = STR_INIT(token, token_pos, 0);
+ fld_name = zend_string_init(token, token_pos, 0);
state = 2;
} else {
@@ -3972,7 +3972,7 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t
case 3:
if (crlf_state == -1) {
- fld_val = STR_INIT(token, token_pos, 0);
+ fld_val = zend_string_init(token, token_pos, 0);
if (fld_name != NULL && fld_val != NULL) {
zval val;
@@ -3983,7 +3983,7 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t
zend_hash_update(ht, fld_name, &val);
- STR_RELEASE(fld_name);
+ zend_string_release(fld_name);
}
fld_name = fld_val = NULL;
@@ -4019,7 +4019,7 @@ out:
state = 3;
}
if (state == 3) {
- fld_val = STR_INIT(token, 0, 0);
+ fld_val = zend_string_init(token, 0, 0);
if (fld_name != NULL && fld_val != NULL) {
zval val;
@@ -4030,7 +4030,7 @@ out:
zend_hash_update(ht, fld_name, &val);
- STR_RELEASE(fld_name);
+ zend_string_release(fld_name);
}
}
return state;
@@ -4297,7 +4297,7 @@ PHP_FUNCTION(mb_send_mail)
}
if (extra_cmd) {
- STR_RELEASE(extra_cmd);
+ zend_string_release(extra_cmd);
}
if (to_r != to) {
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index ab03306f14..2237a318fe 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -711,7 +711,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
if (Z_TYPE_P(arg_pattern) != IS_STRING) {
/* we convert numbers to integers and treat them as a string */
if (Z_TYPE_P(arg_pattern) == IS_DOUBLE) {
- convert_to_long_ex(arg_pattern); /* get rid of decimal places */
+ convert_to_int_ex(arg_pattern); /* get rid of decimal places */
}
convert_to_string_ex(arg_pattern);
/* don't bother doing an extended regex with just a number */
@@ -858,7 +858,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
arg_pattern_len = Z_STRLEN_P(arg_pattern_zval);
} else {
/* FIXME: this code is not multibyte aware! */
- convert_to_long_ex(arg_pattern_zval);
+ convert_to_int_ex(arg_pattern_zval);
pat_buf[0] = (char)Z_LVAL_P(arg_pattern_zval);
pat_buf[1] = '\0';
@@ -1060,7 +1060,7 @@ PHP_FUNCTION(mb_split)
int string_len;
int n, err;
- long count = -1;
+ zend_long count = -1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) {
RETURN_FALSE;
@@ -1397,7 +1397,7 @@ PHP_FUNCTION(mb_ereg_search_getpos)
Set search start position */
PHP_FUNCTION(mb_ereg_search_setpos)
{
- long position;
+ zend_long position;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &position) == FAILURE) {
return;
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c
index 84b0c9248c..01ee59f3d8 100644
--- a/ext/mcrypt/mcrypt.c
+++ b/ext/mcrypt/mcrypt.c
@@ -1138,9 +1138,9 @@ static char *php_mcrypt_get_key_size_str(
return str;
} else {
int i;
+ char *result = NULL;
smart_str str = {0};
smart_str_appends(&str, "Only keys of sizes ");
- char *result = NULL;
for (i = 0; i < key_size_count; ++i) {
if (i == key_size_count - 1) {
@@ -1341,7 +1341,7 @@ PHP_FUNCTION(mcrypt_ecb)
MCRYPT_GET_CRYPT_ARGS
- convert_to_long_ex(mode);
+ convert_to_int_ex(mode);
php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "ecb", iv, iv_len, Z_LVAL_P(mode), return_value TSRMLS_CC);
}
@@ -1357,7 +1357,7 @@ PHP_FUNCTION(mcrypt_cbc)
MCRYPT_GET_CRYPT_ARGS
- convert_to_long_ex(mode);
+ convert_to_int_ex(mode);
php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "cbc", iv, iv_len, Z_LVAL_P(mode), return_value TSRMLS_CC);
}
@@ -1373,7 +1373,7 @@ PHP_FUNCTION(mcrypt_cfb)
MCRYPT_GET_CRYPT_ARGS
- convert_to_long_ex(mode);
+ convert_to_int_ex(mode);
php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "cfb", iv, iv_len, Z_LVAL_P(mode), return_value TSRMLS_CC);
}
@@ -1389,7 +1389,7 @@ PHP_FUNCTION(mcrypt_ofb)
MCRYPT_GET_CRYPT_ARGS
- convert_to_long_ex(mode);
+ convert_to_int_ex(mode);
php_mcrypt_do_crypt(cipher, key, key_len, data, data_len, "ofb", iv, iv_len, Z_LVAL_P(mode), return_value TSRMLS_CC);
}
@@ -1400,8 +1400,8 @@ PHP_FUNCTION(mcrypt_ofb)
PHP_FUNCTION(mcrypt_create_iv)
{
char *iv;
- long source = URANDOM;
- long size;
+ zend_long source = URANDOM;
+ zend_long size;
int n = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &size, &source) == FAILURE) {
diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c
index 340f55b421..088166913e 100644
--- a/ext/mssql/php_mssql.c
+++ b/ext/mssql/php_mssql.c
@@ -285,7 +285,7 @@ static int php_mssql_message_handler(DBPROCESS *dbproc, DBINT msgno,int msgstate
php_error_docref(NULL TSRMLS_CC, E_WARNING, "message: %s (severity %d)", msgtext, severity);
}
if (MS_SQL_G(server_message)) {
- STR_FREE(MS_SQL_G(server_message));
+ zend_string_free(MS_SQL_G(server_message));
MS_SQL_G(server_message) = NULL;
}
MS_SQL_G(server_message) = estrdup(msgtext);
@@ -330,8 +330,8 @@ static void _free_result(mssql_result *result, int free_fields)
if (free_fields && result->fields) {
for (i=0; i<result->num_fields; i++) {
- STR_FREE(result->fields[i].name);
- STR_FREE(result->fields[i].column_source);
+ zend_string_free(result->fields[i].name);
+ zend_string_free(result->fields[i].column_source);
}
efree(result->fields);
}
@@ -507,10 +507,10 @@ PHP_RINIT_FUNCTION(mssql)
*/
PHP_RSHUTDOWN_FUNCTION(mssql)
{
- STR_FREE(MS_SQL_G(appname));
+ zend_string_free(MS_SQL_G(appname));
MS_SQL_G(appname) = NULL;
if (MS_SQL_G(server_message)) {
- STR_FREE(MS_SQL_G(server_message));
+ zend_string_free(MS_SQL_G(server_message));
MS_SQL_G(server_message) = NULL;
}
return SUCCESS;
@@ -1160,7 +1160,7 @@ static void _mssql_get_sp_result(mssql_link *mssql_ptr, mssql_statement *stateme
case SQLINT1:
case SQLINT2:
case SQLINT4:
- convert_to_long_ex(&bind->zval);
+ convert_to_int_ex(&bind->zval);
/* FIXME this works only on little endian machine !!! */
Z_LVAL_P(bind->zval) = *((int *)(dbretdata(mssql_ptr->link,i)));
break;
@@ -1195,7 +1195,7 @@ static void _mssql_get_sp_result(mssql_link *mssql_ptr, mssql_statement *stateme
if (statement->binds != NULL) { /* Maybe a non-parameter sp */
if (zend_hash_find(statement->binds, "RETVAL", 6, (void**)&bind)==SUCCESS) {
if (dbhasretstat(mssql_ptr->link)) {
- convert_to_long_ex(&bind->zval);
+ convert_to_int_ex(&bind->zval);
Z_LVAL_P(bind->zval)=dbretstatus(mssql_ptr->link);
}
else {
@@ -1518,7 +1518,7 @@ static void php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
ZEND_FETCH_RESOURCE(result, mssql_result *, &mssql_result_index, -1, "MS SQL-result", le_result);
if (MS_SQL_G(server_message)) {
- STR_FREE(MS_SQL_G(server_message));
+ zend_string_free(MS_SQL_G(server_message));
MS_SQL_G(server_message) = NULL;
}
@@ -1877,7 +1877,7 @@ PHP_FUNCTION(mssql_result)
break;
}
default:
- convert_to_long_ex(field);
+ convert_to_int_ex(field);
field_offset = Z_LVAL_PP(field);
if (field_offset<0 || field_offset>=result->num_fields) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad column offset specified");
@@ -2067,7 +2067,7 @@ PHP_FUNCTION(mssql_bind)
case SQLINT1:
case SQLINT2:
case SQLINT4:
- convert_to_long_ex(var);
+ convert_to_int_ex(var);
value=(LPBYTE)(&Z_LVAL_PP(var));
break;
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index f4124d306b..2bc488fe23 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -80,7 +80,7 @@ static int le_result, le_link, le_plink;
#define SAFE_STRING(s) ((s)?(s):"")
#if MYSQL_VERSION_ID > 32199 || defined(MYSQL_USE_MYSQLND)
-# define mysql_row_length_type unsigned long
+# define mysql_row_length_type zend_ulong
# define HAVE_MYSQL_ERRNO
#else
# define mysql_row_length_type unsigned int
@@ -662,7 +662,7 @@ PHP_RSHUTDOWN_FUNCTION(mysql)
if (MySG(trace_mode)) {
if (MySG(result_allocated)){
- php_error_docref("function.mysql-free-result" TSRMLS_CC, E_WARNING, "%lu result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query()", MySG(result_allocated));
+ php_error_docref("function.mysql-free-result" TSRMLS_CC, E_WARNING, "%pu result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query()", MySG(result_allocated));
}
}
@@ -686,9 +686,9 @@ PHP_MINFO_FUNCTION(mysql)
php_info_print_table_start();
php_info_print_table_header(2, "MySQL Support", "enabled");
- snprintf(buf, sizeof(buf), "%ld", MySG(num_persistent));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MySG(num_persistent));
php_info_print_table_row(2, "Active Persistent Links", buf);
- snprintf(buf, sizeof(buf), "%ld", MySG(num_links));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MySG(num_links));
php_info_print_table_row(2, "Active Links", buf);
php_info_print_table_row(2, "Client API version", mysql_get_client_info());
#if !defined (PHP_WIN32) && !defined (NETWARE) && !defined(MYSQL_USE_MYSQLND)
@@ -727,12 +727,12 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
char *tmp = NULL, *host = NULL;
int user_len = 0, passwd_len = 0, host_len = 0;
int port = MYSQL_PORT;
- long client_flags = 0;
+ zend_long client_flags = 0;
php_mysql_conn *mysql = NULL;
#if MYSQL_VERSION_ID <= 32230
void (*handler) (int);
#endif
- long connect_timeout;
+ zend_long connect_timeout;
zend_string *hashed_details = NULL;
zend_bool free_host = 0, new_link = 0;
@@ -774,7 +774,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "SQL safe mode in effect - ignoring host/user/password information");
}
user = php_get_current_user(TSRMLS_C);
- hashed_details = STR_ALLOC(sizeof("mysql___") + strlen(user) - 1, 0);
+ hashed_details = zend_string_alloc(sizeof("mysql___") + strlen(user) - 1, 0);
snprintf(hashed_details->val, hashed_details->len + 1, "mysql__%s_", user);
client_flags = CLIENT_INTERACTIVE;
} else {
@@ -819,9 +819,9 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
#ifdef CLIENT_MULTI_STATEMENTS
client_flags &= ~CLIENT_MULTI_STATEMENTS; /* don't allow multi_queries via connect parameter */
#endif
- hashed_details = STR_ALLOC(sizeof("mysql____") + (host_and_port? strlen(host_and_port) : 0)
+ hashed_details = zend_string_alloc(sizeof("mysql____") + (host_and_port? strlen(host_and_port) : 0)
+ (user? strlen(user) : 0) + (passwd? strlen(passwd) : 0) + MAX_LENGTH_OF_LONG - 1, 0);
- hashed_details->len = snprintf(hashed_details->val, hashed_details->len + 1, "mysql_%s_%s_%s_%ld", SAFE_STRING(host_and_port), SAFE_STRING(user), SAFE_STRING(passwd), client_flags);
+ hashed_details->len = snprintf(hashed_details->val, hashed_details->len + 1, "mysql_%s_%s_%s_" ZEND_LONG_FMT, SAFE_STRING(host_and_port), SAFE_STRING(user), SAFE_STRING(passwd), client_flags);
}
/* We cannot use mysql_port anymore in windows, need to use
@@ -862,14 +862,14 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
zval new_le;
if (MySG(max_links) != -1 && MySG(num_links) >= MySG(max_links)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%ld)", MySG(num_links));
- STR_RELEASE(hashed_details);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%pd)", MySG(num_links));
+ zend_string_release(hashed_details);
MYSQL_DO_CONNECT_RETURN_FALSE();
}
if (MySG(max_persistent) != -1 && MySG(num_persistent) >= MySG(max_persistent)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open persistent links (%ld)", MySG(num_persistent));
- STR_RELEASE(hashed_details);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open persistent links (%pd)", MySG(num_persistent));
+ zend_string_release(hashed_details);
MYSQL_DO_CONNECT_RETURN_FALSE();
}
/* create the link */
@@ -911,7 +911,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
MySG(connect_errno) = mysql_errno(mysql->conn);
#endif
free(mysql);
- STR_RELEASE(hashed_details);
+ zend_string_release(hashed_details);
MYSQL_DO_CONNECT_RETURN_FALSE();
}
mysql_options(mysql->conn, MYSQL_OPT_LOCAL_INFILE, (char *)&MySG(allow_local_infile));
@@ -920,14 +920,14 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
ZVAL_NEW_PERSISTENT_RES(&new_le, -1, mysql, le_plink);
/* avoid bogus memleak report */
- phashed = STR_INIT(hashed_details->val, hashed_details->len, 1);
+ phashed = zend_string_init(hashed_details->val, hashed_details->len, 1);
if (zend_hash_update(&EG(persistent_list), phashed, &new_le) == NULL) {
- STR_RELEASE(phashed);
+ zend_string_release(phashed);
free(mysql);
- STR_RELEASE(hashed_details);
+ zend_string_release(hashed_details);
MYSQL_DO_CONNECT_RETURN_FALSE();
}
- STR_RELEASE(phashed);
+ zend_string_release(phashed);
MySG(num_persistent)++;
MySG(num_links)++;
} else { /* The link is in our list of persistent connections */
@@ -955,7 +955,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Link to server lost, unable to reconnect");
zend_hash_del(&EG(persistent_list), hashed_details);
- STR_RELEASE(hashed_details);
+ zend_string_release(hashed_details);
MYSQL_DO_CONNECT_RETURN_FALSE();
}
mysql_options(mysql->conn, MYSQL_OPT_LOCAL_INFILE, (char *)&MySG(allow_local_infile));
@@ -988,7 +988,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
GC_REFCOUNT(link)++;
ZVAL_RES(return_value, link);
php_mysql_set_default_link(link TSRMLS_CC);
- STR_RELEASE(hashed_details);
+ zend_string_release(hashed_details);
MYSQL_DO_CONNECT_CLEANUP();
return;
} else {
@@ -997,8 +997,8 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
if (MySG(max_links) != -1 && MySG(num_links) >= MySG(max_links)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%ld)", MySG(num_links));
- STR_RELEASE(hashed_details);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%pd)", MySG(num_links));
+ zend_string_release(hashed_details);
MYSQL_DO_CONNECT_RETURN_FALSE();
}
@@ -1016,7 +1016,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
if (!mysql->conn) {
MySG(connect_error) = estrdup("OOM");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "OOM");
- STR_RELEASE(hashed_details);
+ zend_string_release(hashed_details);
efree(mysql);
MYSQL_DO_CONNECT_RETURN_FALSE();
}
@@ -1044,7 +1044,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
#ifdef MYSQL_USE_MYSQLND
mysqlnd_close(mysql->conn, MYSQLND_CLOSE_DISCONNECTED);
#endif
- STR_RELEASE(hashed_details);
+ zend_string_release(hashed_details);
efree(mysql);
MYSQL_DO_CONNECT_RETURN_FALSE();
}
@@ -1057,14 +1057,14 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
ZVAL_NEW_RES(&new_index_ptr, -1, Z_RES_P(return_value), le_index_ptr);
if (zend_hash_update(&EG(regular_list), hashed_details, &new_index_ptr) == NULL) {
zval_ptr_dtor(return_value);
- STR_RELEASE(hashed_details);
+ zend_string_release(hashed_details);
MYSQL_DO_CONNECT_RETURN_FALSE();
}
Z_ADDREF_P(return_value);
MySG(num_links)++;
}
- STR_RELEASE(hashed_details);
+ zend_string_release(hashed_details);
php_mysql_set_default_link(Z_RES_P(return_value) TSRMLS_CC);
MYSQL_DO_CONNECT_CLEANUP();
}
@@ -1857,7 +1857,7 @@ PHP_FUNCTION(mysql_escape_string)
* we don't realloc() down to the real size since it'd most probably not
* be worth it
*/
- escaped_str = STR_ALLOC(str_len * 2, 0);
+ escaped_str = zend_string_alloc(str_len * 2, 0);
escaped_str->len = mysql_escape_string(escaped_str->val, str, str_len);
php_error_docref("function.mysql-real-escape-string" TSRMLS_CC, E_DEPRECATED, "This function is deprecated; use mysql_real_escape_string() instead.");
@@ -1891,7 +1891,7 @@ PHP_FUNCTION(mysql_real_escape_string)
* we don't realloc() down to the real size since it'd most probably not
* be worth it
*/
- new_str = STR_ALLOC(str_len * 2, 0);
+ new_str = zend_string_alloc(str_len * 2, 0);
new_str->len = mysql_real_escape_string(mysql->conn, new_str->val, str, str_len);
RETURN_NEW_STR(new_str);
@@ -1927,7 +1927,7 @@ PHP_FUNCTION(mysql_insert_id)
PHP_FUNCTION(mysql_result)
{
zval *result, *field=NULL;
- long row;
+ zend_long row;
MYSQL_RES *mysql_result;
#ifndef MYSQL_USE_MYSQLND
MYSQL_ROW sql_row;
@@ -1947,7 +1947,7 @@ Q: String or long first?
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
if (row < 0 || row >= (int)mysql_num_rows(mysql_result)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %ld on MySQL result index %ld", row, Z_RES_P(result)->handle);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %pd on MySQL result index %pd", row, Z_RES_P(result)->handle);
RETURN_FALSE;
}
mysql_data_seek(mysql_result, row);
@@ -1977,7 +1977,7 @@ Q: String or long first?
i++;
}
if (!tmp_field) { /* no match found */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s%s%s not found in MySQL result index %ld",
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s%s%s not found in MySQL result index %pd",
(table_name?table_name:""), (table_name?".":""), field_name, Z_RES_P(result)->handle);
efree(field_name);
if (table_name) {
@@ -1992,7 +1992,7 @@ Q: String or long first?
}
break;
default:
- convert_to_long_ex(field);
+ convert_to_int_ex(field);
field_offset = Z_LVAL_P(field);
if (field_offset < 0 || field_offset >= (int)mysql_num_fields(mysql_result)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad column offset specified");
@@ -2063,7 +2063,7 @@ PHP_FUNCTION(mysql_num_fields)
/* {{{ php_mysql_fetch_hash
*/
-static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, int expected_args, int into_object)
+static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_type, int expected_args, int into_object)
{
MYSQL_RES *mysql_result;
zval *res, *ctor_params = NULL;
@@ -2271,7 +2271,7 @@ PHP_FUNCTION(mysql_fetch_assoc)
PHP_FUNCTION(mysql_data_seek)
{
zval *result;
- long offset;
+ zend_long offset;
MYSQL_RES *mysql_result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &result, &offset)) {
@@ -2281,7 +2281,7 @@ PHP_FUNCTION(mysql_data_seek)
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
if (offset < 0 || offset >= (int)mysql_num_rows(mysql_result)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset %ld is invalid for MySQL result index %ld (or the query data is unbuffered)", offset, Z_RES_P(result)->handle);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset %pd is invalid for MySQL result index %pd (or the query data is unbuffered)", offset, Z_RES_P(result)->handle);
RETURN_FALSE;
}
mysql_data_seek(mysql_result, offset);
@@ -2398,7 +2398,7 @@ static char *php_mysql_get_field_name(int field_type)
PHP_FUNCTION(mysql_fetch_field)
{
zval *result;
- long field=0;
+ zend_long field=0;
MYSQL_RES *mysql_result;
const MYSQL_FIELD *mysql_field;
@@ -2421,7 +2421,7 @@ PHP_FUNCTION(mysql_fetch_field)
object_init(return_value);
#if MYSQL_USE_MYSQLND
- add_property_str(return_value, "name", STR_COPY(mysql_field->sname));
+ add_property_str(return_value, "name", zend_string_copy(mysql_field->sname));
#else
add_property_stringl(return_value, "name", (mysql_field->name?mysql_field->name:""), mysql_field->name_length);
#endif
@@ -2445,7 +2445,7 @@ PHP_FUNCTION(mysql_fetch_field)
PHP_FUNCTION(mysql_field_seek)
{
zval *result;
- long offset;
+ zend_long offset;
MYSQL_RES *mysql_result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &result, &offset) == FAILURE) {
@@ -2454,7 +2454,7 @@ PHP_FUNCTION(mysql_field_seek)
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
if (offset < 0 || offset >= (int)mysql_num_fields(mysql_result)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field %ld is invalid for MySQL result index %ld", offset, Z_RES_P(result)->handle);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field %pd is invalid for MySQL result index %pd", offset, Z_RES_P(result)->handle);
RETURN_FALSE;
}
mysql_field_seek(mysql_result, offset);
@@ -2473,7 +2473,7 @@ PHP_FUNCTION(mysql_field_seek)
static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
{
zval *result;
- long field;
+ zend_long field;
MYSQL_RES *mysql_result;
const MYSQL_FIELD *mysql_field = {0};
char buf[512];
@@ -2486,7 +2486,7 @@ static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL result", le_result);
if (field < 0 || field >= (int)mysql_num_fields(mysql_result)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field %ld is invalid for MySQL result index %ld", field, Z_RES_P(result)->handle);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field %pd is invalid for MySQL result index %pd", field, Z_RES_P(result)->handle);
RETURN_FALSE;
}
mysql_field_seek(mysql_result, field);
@@ -2497,7 +2497,7 @@ static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
switch (entry_type) {
case PHP_MYSQL_FIELD_NAME:
#ifdef MYSQL_USE_MYSQLND
- RETVAL_STR(STR_COPY(mysql_field->sname));
+ RETVAL_STR(zend_string_copy(mysql_field->sname));
#else
RETVAL_STRING(mysql_field->name);
#endif
diff --git a/ext/mysql/php_mysql_structs.h b/ext/mysql/php_mysql_structs.h
index 0e8ab482a1..c39e5b25af 100644
--- a/ext/mysql/php_mysql_structs.h
+++ b/ext/mysql/php_mysql_structs.h
@@ -112,18 +112,18 @@ PHP_FUNCTION(mysql_set_charset);
ZEND_BEGIN_MODULE_GLOBALS(mysql)
zend_resource *default_link;
- long num_links,num_persistent;
- long max_links,max_persistent;
- long allow_persistent;
- long default_port;
+ zend_long num_links,num_persistent;
+ zend_long max_links,max_persistent;
+ zend_long allow_persistent;
+ zend_long default_port;
char *default_host, *default_user, *default_password;
char *default_socket;
char *connect_error;
- long connect_errno;
- long connect_timeout;
- long result_allocated;
- long trace_mode;
- long allow_local_infile;
+ zend_long connect_errno;
+ zend_long connect_timeout;
+ zend_long result_allocated;
+ zend_long trace_mode;
+ zend_long allow_local_infile;
ZEND_END_MODULE_GLOBALS(mysql)
#ifdef ZTS
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index 02e6898f7f..2c5a4bc662 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -185,7 +185,7 @@ void php_clear_stmt_bind(MY_STMT *stmt TSRMLS_DC)
/* {{{ php_clear_mysql */
void php_clear_mysql(MY_MYSQL *mysql) {
if (mysql->hash_key) {
- STR_RELEASE(mysql->hash_key);
+ zend_string_release(mysql->hash_key);
mysql->hash_key = NULL;
}
if (!Z_ISUNDEF(mysql->li_read)) {
@@ -375,11 +375,11 @@ void mysqli_write_property(zval *object, zval *member, zval *value, void **cache
void mysqli_add_property(HashTable *h, const char *pname, size_t pname_len, mysqli_read_t r_func, mysqli_write_t w_func TSRMLS_DC) {
mysqli_prop_handler p;
- p.name = STR_INIT(pname, pname_len, 1);
+ p.name = zend_string_init(pname, pname_len, 1);
p.read_func = (r_func) ? r_func : mysqli_read_na;
p.write_func = (w_func) ? w_func : mysqli_write_na;
zend_hash_add_mem(h, p.name, &p, sizeof(mysqli_prop_handler));
- STR_RELEASE(p.name);
+ zend_string_release(p.name);
}
/* }}} */
@@ -884,7 +884,7 @@ PHP_MSHUTDOWN_FUNCTION(mysqli)
#ifndef MYSQLI_USE_MYSQLND
#if MYSQL_VERSION_ID >= 40000
#ifdef PHP_WIN32
- unsigned long client_ver = mysql_get_client_version();
+ zend_ulong client_ver = mysql_get_client_version();
/*
Can't call mysql_server_end() multiple times prior to 5.0.46 on Windows.
PHP bug#41350 MySQL bug#25621
@@ -976,11 +976,11 @@ PHP_MINFO_FUNCTION(mysqli)
php_info_print_table_start();
php_info_print_table_header(2, "MysqlI Support", "enabled");
php_info_print_table_row(2, "Client API library version", mysql_get_client_info());
- snprintf(buf, sizeof(buf), "%ld", MyG(num_active_persistent));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MyG(num_active_persistent));
php_info_print_table_row(2, "Active Persistent Links", buf);
- snprintf(buf, sizeof(buf), "%ld", MyG(num_inactive_persistent));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MyG(num_inactive_persistent));
php_info_print_table_row(2, "Inactive Persistent Links", buf);
- snprintf(buf, sizeof(buf), "%ld", MyG(num_links));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MyG(num_links));
php_info_print_table_row(2, "Active Links", buf);
#if !defined(MYSQLI_USE_MYSQLND)
php_info_print_table_row(2, "Client API header version", MYSQL_SERVER_VERSION);
@@ -1105,7 +1105,7 @@ PHP_FUNCTION(mysqli_result_construct)
MYSQL_RES *result = NULL;
zval *mysql_link;
MYSQLI_RESOURCE *mysqli_resource;
- long resmode = MYSQLI_STORE_RESULT;
+ zend_long resmode = MYSQLI_STORE_RESULT;
switch (ZEND_NUM_ARGS()) {
case 1:
@@ -1149,13 +1149,13 @@ PHP_FUNCTION(mysqli_result_construct)
/* {{{ php_mysqli_fetch_into_hash_aux
*/
-void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, long fetchtype TSRMLS_DC)
+void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend_long fetchtype TSRMLS_DC)
{
#if !defined(MYSQLI_USE_MYSQLND)
MYSQL_ROW row;
unsigned int i;
MYSQL_FIELD *fields;
- unsigned long *field_len;
+ zend_ulong *field_len;
if (!(row = mysql_fetch_row(result))) {
RETURN_NULL();
@@ -1238,7 +1238,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
{
MYSQL_RES *result;
zval *mysql_result;
- long fetchtype;
+ zend_long fetchtype;
zval *ctor_params = NULL;
zend_class_entry *ce = NULL;
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 254bae1695..7b7f7e582b 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -154,7 +154,7 @@ PHP_FUNCTION(mysqli_affected_rows)
if (rc == (my_ulonglong) -1) {
RETURN_LONG(-1);
}
- MYSQLI_RETURN_LONG_LONG(rc);
+ MYSQLI_RETURN_LONG_INT(rc);
}
/* }}} */
@@ -213,9 +213,9 @@ int mysqli_stmt_bind_param_do_bind(MY_STMT *stmt, unsigned int argc, unsigned in
break;
case 'i': /* Integer */
-#if SIZEOF_LONG==8
+#if SIZEOF_ZEND_INT==8
bind[ofs].buffer_type = MYSQL_TYPE_LONGLONG;
-#elif SIZEOF_LONG==4
+#elif SIZEOF_ZEND_INT==4
bind[ofs].buffer_type = MYSQL_TYPE_LONG;
#endif
bind[ofs].buffer = &Z_LVAL_P(param);
@@ -284,9 +284,9 @@ int mysqli_stmt_bind_param_do_bind(MY_STMT *stmt, unsigned int argc, unsigned in
type = MYSQL_TYPE_DOUBLE;
break;
case 'i': /* Integer */
-#if SIZEOF_LONG==8
+#if SIZEOF_ZEND_INT==8
type = MYSQL_TYPE_LONGLONG;
-#elif SIZEOF_LONG==4
+#elif SIZEOF_ZEND_INT==4
type = MYSQL_TYPE_LONG;
#endif
break;
@@ -326,7 +326,7 @@ PHP_FUNCTION(mysqli_stmt_bind_param)
zval *mysql_stmt;
char *types;
int types_len;
- unsigned long rc;
+ zend_ulong rc;
/* calculate and check number of parameters */
if (argc < 2) {
@@ -391,8 +391,8 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval *args, unsigned int argc, un
MYSQL_BIND *bind;
int i, ofs;
int var_cnt = argc - start;
- long col_type;
- ulong rc;
+ zend_long col_type;
+ zend_ulong rc;
/* prevent leak if variables are already bound */
if (stmt->result.var_cnt) {
@@ -488,7 +488,7 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval *args, unsigned int argc, un
/* Changed to my_bool in MySQL 5.1. See MySQL Bug #16144 */
my_bool tmp;
#else
- ulong tmp = 0;
+ zend_ulong tmp = 0;
#endif
stmt->result.buf[ofs].type = IS_STRING;
/*
@@ -578,7 +578,7 @@ PHP_FUNCTION(mysqli_stmt_bind_result)
zval *args;
int argc = ZEND_NUM_ARGS();
int start = 1;
- ulong rc;
+ zend_ulong rc;
MY_STMT *stmt;
zval *mysql_stmt;
@@ -624,7 +624,7 @@ PHP_FUNCTION(mysqli_change_user)
zval *mysql_link = NULL;
char *user, *password, *dbname;
int user_len, password_len, dbname_len;
- ulong rc;
+ zend_ulong rc;
#if !defined(MYSQLI_USE_MYSQLND) && defined(HAVE_MYSQLI_SET_CHARSET)
const CHARSET_INFO * old_charset;
#endif
@@ -752,7 +752,7 @@ PHP_FUNCTION(mysqli_commit)
{
MY_MYSQL *mysql;
zval *mysql_link;
- long flags = TRANS_COR_NO_OPT;
+ zend_long flags = TRANS_COR_NO_OPT;
char * name = NULL;
int name_len = 0;
@@ -778,7 +778,7 @@ PHP_FUNCTION(mysqli_data_seek)
{
MYSQL_RES *result;
zval *mysql_result;
- long offset;
+ zend_long offset;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_result, mysqli_result_class_entry, &offset) == FAILURE) {
return;
@@ -919,7 +919,7 @@ PHP_FUNCTION(mysqli_stmt_execute)
break;
case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_LONG:
- convert_to_long_ex(param);
+ convert_to_int_ex(param);
stmt->stmt->params[i].buffer = &Z_LVAL_P(param);
break;
default:
@@ -951,7 +951,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
MY_STMT *stmt;
zval *mysql_stmt;
unsigned int i;
- ulong ret;
+ zend_ulong ret;
unsigned int uval;
my_ulonglong llval;
@@ -996,7 +996,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
{
/* unsigned int (11) */
uval= *(unsigned int *) stmt->result.buf[i].val;
-#if SIZEOF_LONG==4
+#if SIZEOF_ZEND_INT==4
if (uval > INT_MAX) {
char *tmp, *p;
int j = 10;
@@ -1047,9 +1047,9 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
{
llval= *(my_ulonglong *) stmt->result.buf[i].val;
}
-#if SIZEOF_LONG==8
+#if SIZEOF_ZEND_INT==8
if (uns && llval > 9223372036854775807L) {
-#elif SIZEOF_LONG==4
+#elif SIZEOF_ZEND_INT==4
if ((uns && llval > L64(2147483647)) ||
(!uns && (( L64(2147483647) < (my_longlong) llval) ||
(L64(-2147483648) > (my_longlong) llval))))
@@ -1149,7 +1149,7 @@ PHP_FUNCTION(mysqli_stmt_fetch)
static void php_add_field_properties(zval *value, const MYSQL_FIELD *field TSRMLS_DC)
{
#ifdef MYSQLI_USE_MYSQLND
- add_property_str(value, "name", STR_COPY(field->sname));
+ add_property_str(value, "name", zend_string_copy(field->sname));
#else
add_property_stringl(value, "name",(field->name ? field->name : ""), field->name_length);
#endif
@@ -1234,7 +1234,7 @@ PHP_FUNCTION(mysqli_fetch_field_direct)
MYSQL_RES *result;
zval *mysql_result;
const MYSQL_FIELD *field;
- long offset;
+ zend_long offset;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_result, mysqli_result_class_entry, &offset) == FAILURE) {
return;
@@ -1242,7 +1242,7 @@ PHP_FUNCTION(mysqli_fetch_field_direct)
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
- if (offset < 0 || offset >= (long) mysql_num_fields(result)) {
+ if (offset < 0 || offset >= (zend_long) mysql_num_fields(result)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field offset is invalid for resultset");
RETURN_FALSE;
}
@@ -1263,7 +1263,7 @@ PHP_FUNCTION(mysqli_fetch_lengths)
MYSQL_RES *result;
zval *mysql_result;
unsigned int i;
- unsigned long *ret;
+ zend_ulong *ret;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
return;
@@ -1315,7 +1315,7 @@ PHP_FUNCTION(mysqli_field_seek)
{
MYSQL_RES *result;
zval *mysql_result;
- long fieldnr;
+ zend_long fieldnr;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_result, mysqli_result_class_entry, &fieldnr) == FAILURE) {
return;
@@ -1380,7 +1380,7 @@ PHP_FUNCTION(mysqli_get_client_info)
Get MySQL client info */
PHP_FUNCTION(mysqli_get_client_version)
{
- RETURN_LONG((long)mysql_get_client_version());
+ RETURN_LONG((zend_long)mysql_get_client_version());
}
/* }}} */
@@ -1540,7 +1540,7 @@ PHP_FUNCTION(mysqli_insert_id)
}
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
rc = mysql_insert_id(mysql->mysql);
- MYSQLI_RETURN_LONG_LONG(rc)
+ MYSQLI_RETURN_LONG_INT(rc)
}
/* }}} */
@@ -1550,7 +1550,7 @@ PHP_FUNCTION(mysqli_kill)
{
MY_MYSQL *mysql;
zval *mysql_link;
- long processid;
+ zend_long processid;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_link, mysqli_link_class_entry, &processid) == FAILURE) {
return;
@@ -1679,7 +1679,7 @@ PHP_FUNCTION(mysqli_num_rows)
RETURN_LONG(0);
}
- MYSQLI_RETURN_LONG_LONG(mysql_num_rows(result));
+ MYSQLI_RETURN_LONG_INT(mysql_num_rows(result));
}
/* }}} */
@@ -1761,9 +1761,9 @@ PHP_FUNCTION(mysqli_options)
MY_MYSQL *mysql;
zval *mysql_link = NULL;
zval *mysql_value;
- long mysql_option;
+ zend_long mysql_option;
unsigned int l_value;
- long ret;
+ zend_long ret;
int expected_type;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olz", &mysql_link, mysqli_link_class_entry, &mysql_option, &mysql_value) == FAILURE) {
@@ -1787,7 +1787,7 @@ PHP_FUNCTION(mysqli_options)
convert_to_string_ex(mysql_value);
break;
case IS_LONG:
- convert_to_long_ex(mysql_value);
+ convert_to_int_ex(mysql_value);
break;
default:
break;
@@ -1816,7 +1816,7 @@ PHP_FUNCTION(mysqli_ping)
{
MY_MYSQL *mysql;
zval *mysql_link;
- long rc;
+ zend_long rc;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
@@ -1962,9 +1962,9 @@ PHP_FUNCTION(mysqli_real_escape_string) {
}
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
- newstr = STR_ALLOC(2 * escapestr_len, 0);
+ newstr = zend_string_alloc(2 * escapestr_len, 0);
newstr->len = mysql_real_escape_string(mysql->mysql, newstr->val, escapestr, escapestr_len);
- newstr = STR_REALLOC(newstr, newstr->len, 0);
+ newstr = zend_string_realloc(newstr, newstr->len, 0);
RETURN_STR(newstr);
}
@@ -1976,7 +1976,7 @@ PHP_FUNCTION(mysqli_rollback)
{
MY_MYSQL *mysql;
zval *mysql_link;
- long flags = TRANS_COR_NO_OPT;
+ zend_long flags = TRANS_COR_NO_OPT;
char * name = NULL;
int name_len = 0;
@@ -2003,7 +2003,7 @@ PHP_FUNCTION(mysqli_stmt_send_long_data)
MY_STMT *stmt;
zval *mysql_stmt;
char *data;
- long param_nr;
+ zend_long param_nr;
int data_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ols", &mysql_stmt, mysqli_stmt_class_entry, &param_nr, &data, &data_len) == FAILURE) {
@@ -2039,7 +2039,7 @@ PHP_FUNCTION(mysqli_stmt_affected_rows)
if (rc == (my_ulonglong) -1) {
RETURN_LONG(-1);
}
- MYSQLI_RETURN_LONG_LONG(rc)
+ MYSQLI_RETURN_LONG_INT(rc)
}
/* }}} */
@@ -2069,7 +2069,7 @@ PHP_FUNCTION(mysqli_stmt_data_seek)
{
MY_STMT *stmt;
zval *mysql_stmt;
- long offset;
+ zend_long offset;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_stmt, mysqli_stmt_class_entry, &offset) == FAILURE) {
return;
@@ -2131,7 +2131,7 @@ PHP_FUNCTION(mysqli_stmt_insert_id)
}
MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
rc = mysql_stmt_insert_id(stmt->stmt);
- MYSQLI_RETURN_LONG_LONG(rc)
+ MYSQLI_RETURN_LONG_INT(rc)
}
/* }}} */
@@ -2186,7 +2186,7 @@ PHP_FUNCTION(mysqli_stmt_num_rows)
MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
rc = mysql_stmt_num_rows(stmt->stmt);
- MYSQLI_RETURN_LONG_LONG(rc)
+ MYSQLI_RETURN_LONG_INT(rc)
}
/* }}} */
@@ -2296,7 +2296,7 @@ PHP_FUNCTION(mysqli_refresh)
{
MY_MYSQL *mysql;
zval *mysql_link = NULL;
- long options;
+ zend_long options;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_link, mysqli_link_class_entry, &options) == FAILURE) {
return;
@@ -2316,12 +2316,12 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
{
MY_STMT *stmt;
zval *mysql_stmt;
- long mode_in;
+ zend_long mode_in;
#if MYSQL_VERSION_ID >= 50107
my_bool mode_b;
#endif
- ulong mode;
- ulong attr;
+ zend_ulong mode;
+ zend_long attr;
void *mode_p;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll", &mysql_stmt, mysqli_stmt_class_entry, &attr, &mode_in) == FAILURE) {
@@ -2330,7 +2330,7 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
if (mode_in < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "mode should be non-negative, %ld passed", mode_in);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "mode should be non-negative, %pd passed", mode_in);
RETURN_FALSE;
}
@@ -2363,8 +2363,8 @@ PHP_FUNCTION(mysqli_stmt_attr_get)
{
MY_STMT *stmt;
zval *mysql_stmt;
- ulong value = 0;
- ulong attr;
+ zend_ulong value = 0;
+ zend_long attr;
int rc;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_stmt, mysqli_stmt_class_entry, &attr) == FAILURE) {
@@ -2380,7 +2380,7 @@ PHP_FUNCTION(mysqli_stmt_attr_get)
if (attr == STMT_ATTR_UPDATE_MAX_LENGTH)
value = *((my_bool *)&value);
#endif
- RETURN_LONG((long)value);
+ RETURN_LONG((zend_ulong)value);
}
/* }}} */
@@ -2580,7 +2580,7 @@ PHP_FUNCTION(mysqli_store_result)
MYSQL_RES *result;
zval *mysql_link;
MYSQLI_RESOURCE *mysqli_resource;
- long flags = 0;
+ zend_long flags = 0;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &mysql_link, mysqli_link_class_entry, &flags) == FAILURE) {
@@ -2619,7 +2619,7 @@ PHP_FUNCTION(mysqli_thread_id)
}
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
- RETURN_LONG((long) mysql_thread_id(mysql->mysql));
+ RETURN_LONG((zend_long) mysql_thread_id(mysql->mysql));
}
/* }}} */
diff --git a/ext/mysqli/mysqli_embedded.c b/ext/mysqli/mysqli_embedded.c
index e56e936f63..898287d3fb 100644
--- a/ext/mysqli/mysqli_embedded.c
+++ b/ext/mysqli/mysqli_embedded.c
@@ -32,7 +32,7 @@
PHP_FUNCTION(mysqli_embedded_server_start)
{
#ifdef HAVE_EMBEDDED_MYSQLI
- long start;
+ zend_long start;
zval *args;
zval *grps;
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index c274c98056..0acac7fa1f 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -42,7 +42,7 @@
/* {{{ php_mysqli_set_error
*/
-static void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC)
+static void php_mysqli_set_error(zend_long mysql_errno, char *mysql_err TSRMLS_DC)
{
MyG(error_no) = mysql_errno;
if (MyG(error_msg)) {
@@ -64,7 +64,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
char *hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL;
int hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0;
zend_bool persistent = FALSE;
- long port = 0, flags = 0;
+ zend_long port = 0, flags = 0;
zend_string *hash_key = NULL;
zend_bool new_connection = FALSE;
zend_resource *le;
@@ -200,14 +200,14 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
}
}
if (MyG(max_links) != -1 && MyG(num_links) >= MyG(max_links)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%ld)", MyG(num_links));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%pd)", MyG(num_links));
goto err;
}
if (persistent && MyG(max_persistent) != -1 &&
(MyG(num_active_persistent) + MyG(num_inactive_persistent))>= MyG(max_persistent))
{
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open persistent links (%ld)",
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open persistent links (%pd)",
MyG(num_active_persistent) + MyG(num_inactive_persistent));
goto err;
}
@@ -291,7 +291,7 @@ end:
err:
if (mysql->hash_key) {
- STR_RELEASE(mysql->hash_key);
+ zend_string_release(mysql->hash_key);
mysql->hash_key = NULL;
mysql->persistent = FALSE;
}
@@ -360,7 +360,7 @@ PHP_FUNCTION(mysqli_fetch_all)
{
MYSQL_RES *result;
zval *mysql_result;
- long mode = MYSQLND_FETCH_NUM;
+ zend_long mode = MYSQLND_FETCH_NUM;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &mode) == FAILURE) {
return;
@@ -549,7 +549,7 @@ PHP_FUNCTION(mysqli_query)
MYSQL_RES *result = NULL;
char *query = NULL;
int query_len;
- long resultmode = MYSQLI_STORE_RESULT;
+ zend_long resultmode = MYSQLI_STORE_RESULT;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &mysql_link, mysqli_link_class_entry, &query, &query_len, &resultmode) == FAILURE) {
return;
@@ -750,7 +750,7 @@ PHP_FUNCTION(mysqli_poll)
{
zval *r_array, *e_array, *dont_poll_array;
MYSQLND **new_r_array = NULL, **new_e_array = NULL, **new_dont_poll_array = NULL;
- long sec = 0, usec = 0;
+ zend_long sec = 0, usec = 0;
enum_func_status ret;
int desc_num;
@@ -1076,7 +1076,7 @@ PHP_FUNCTION(mysqli_begin_transaction)
{
MY_MYSQL *mysql;
zval *mysql_link;
- long flags = TRANS_START_NO_OPT;
+ zend_long flags = TRANS_START_NO_OPT;
char * name = NULL;
int name_len = -1;
zend_bool err = FALSE;
@@ -1086,7 +1086,7 @@ PHP_FUNCTION(mysqli_begin_transaction)
}
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
if (flags < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for parameter flags (%ld)", flags);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for parameter flags (%pd)", flags);
err = TRUE;
}
if (!name_len) {
diff --git a/ext/mysqli/mysqli_priv.h b/ext/mysqli/mysqli_priv.h
index f49236358e..b240cfab09 100644
--- a/ext/mysqli/mysqli_priv.h
+++ b/ext/mysqli/mysqli_priv.h
@@ -96,10 +96,10 @@ PHP_MYSQLI_EXPORT(zend_object *) mysqli_objects_new(zend_class_entry * TSRMLS_DC
mysql->multi_query = 1; \
}
-#define MYSQLI_RETURN_LONG_LONG(__val) \
+#define MYSQLI_RETURN_LONG_INT(__val) \
{ \
- if ((__val) < LONG_MAX) { \
- RETURN_LONG((long) (__val)); \
+ if ((__val) < ZEND_LONG_MAX) { \
+ RETURN_LONG((zend_long) (__val)); \
} else { \
/* always used with my_ulonglong -> %llu */ \
RETURN_STR(strpprintf(0, MYSQLI_LLU_SPEC, (__val))); \
diff --git a/ext/mysqli/mysqli_prop.c b/ext/mysqli/mysqli_prop.c
index cd0639d98f..c1fa0a17d6 100644
--- a/ext/mysqli/mysqli_prop.c
+++ b/ext/mysqli/mysqli_prop.c
@@ -81,8 +81,8 @@ static zval *__func(mysqli_object *obj, zval *retval TSRMLS_DC) \
ZVAL_NULL(retval);\
} else {\
l = (__ret_type)__int_func(p);\
- if (l < LONG_MAX) {\
- ZVAL_LONG(retval, (long) l);\
+ if (l < ZEND_LONG_MAX) {\
+ ZVAL_LONG(retval, (zend_long) l);\
} else { \
ZVAL_STR(retval, strpprintf(0, __ret_type_sprint_mod, l)); \
} \
@@ -128,7 +128,7 @@ static zval *link_client_info_read(mysqli_object *obj, zval *retval TSRMLS_DC)
/* {{{ property link_connect_errno_read */
static zval *link_connect_errno_read(mysqli_object *obj, zval *retval TSRMLS_DC)
{
- ZVAL_LONG(retval, (long)MyG(error_no));
+ ZVAL_LONG(retval, (zend_long)MyG(error_no));
return retval;
}
/* }}} */
@@ -167,8 +167,8 @@ static zval *link_affected_rows_read(mysqli_object *obj, zval *retval TSRMLS_DC)
return retval;
}
- if (rc < LONG_MAX) {
- ZVAL_LONG(retval, (long) rc);
+ if (rc < ZEND_LONG_MAX) {
+ ZVAL_LONG(retval, (zend_long) rc);
} else {
ZVAL_STR(retval, strpprintf(0, MYSQLI_LLU_SPEC, rc));
}
@@ -221,18 +221,18 @@ static zval *link_error_list_read(mysqli_object *obj, zval *retval TSRMLS_DC)
/* }}} */
/* link properties */
-MYSQLI_MAP_PROPERTY_FUNC_LONG(link_errno_read, mysql_errno, MYSQLI_GET_MYSQL(MYSQLI_STATUS_INITIALIZED), ulong, "%lu")
+MYSQLI_MAP_PROPERTY_FUNC_LONG(link_errno_read, mysql_errno, MYSQLI_GET_MYSQL(MYSQLI_STATUS_INITIALIZED), zend_ulong, ZEND_ULONG_FMT)
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_error_read, mysql_error, MYSQLI_GET_MYSQL(MYSQLI_STATUS_INITIALIZED))
-MYSQLI_MAP_PROPERTY_FUNC_LONG(link_field_count_read, mysql_field_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong, "%lu")
+MYSQLI_MAP_PROPERTY_FUNC_LONG(link_field_count_read, mysql_field_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_host_info_read, mysql_get_host_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID))
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_info_read, mysql_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID))
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_insert_id_read, mysql_insert_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), my_ulonglong, MYSQLI_LLU_SPEC)
-MYSQLI_MAP_PROPERTY_FUNC_LONG(link_protocol_version_read, mysql_get_proto_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong, "%lu")
+MYSQLI_MAP_PROPERTY_FUNC_LONG(link_protocol_version_read, mysql_get_proto_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_server_info_read, mysql_get_server_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID))
-MYSQLI_MAP_PROPERTY_FUNC_LONG(link_server_version_read, mysql_get_server_version, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong, "%lu")
+MYSQLI_MAP_PROPERTY_FUNC_LONG(link_server_version_read, mysql_get_server_version, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_sqlstate_read, mysql_sqlstate, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID))
-MYSQLI_MAP_PROPERTY_FUNC_LONG(link_thread_id_read, mysql_thread_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong, "%lu")
-MYSQLI_MAP_PROPERTY_FUNC_LONG(link_warning_count_read, mysql_warning_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong, "%lu")
+MYSQLI_MAP_PROPERTY_FUNC_LONG(link_thread_id_read, mysql_thread_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
+MYSQLI_MAP_PROPERTY_FUNC_LONG(link_warning_count_read, mysql_warning_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
/* {{{ property link_stat_read */
static zval *link_stat_read(mysqli_object *obj, zval *retval TSRMLS_DC)
@@ -289,7 +289,7 @@ static zval *result_type_read(mysqli_object *obj, zval *retval TSRMLS_DC)
static zval *result_lengths_read(mysqli_object *obj, zval *retval TSRMLS_DC)
{
MYSQL_RES *p;
- ulong *ret;
+ zend_ulong *ret;
uint field_count;
CHECK_STATUS(MYSQLI_STATUS_VALID);
@@ -298,7 +298,7 @@ static zval *result_lengths_read(mysqli_object *obj, zval *retval TSRMLS_DC)
if (!p || !field_count || !(ret = mysql_fetch_lengths(p))) {
ZVAL_NULL(retval);
} else {
- ulong i;
+ zend_ulong i;
array_init(retval);
@@ -310,8 +310,8 @@ static zval *result_lengths_read(mysqli_object *obj, zval *retval TSRMLS_DC)
}
/* }}} */
-MYSQLI_MAP_PROPERTY_FUNC_LONG(result_current_field_read, mysql_field_tell, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), ulong, "%lu")
-MYSQLI_MAP_PROPERTY_FUNC_LONG(result_field_count_read, mysql_num_fields, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), ulong, "%lu")
+MYSQLI_MAP_PROPERTY_FUNC_LONG(result_current_field_read, mysql_field_tell, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
+MYSQLI_MAP_PROPERTY_FUNC_LONG(result_field_count_read, mysql_num_fields, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
MYSQLI_MAP_PROPERTY_FUNC_LONG(result_num_rows_read, mysql_num_rows, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), my_ulonglong, MYSQLI_LLU_SPEC)
/* statement properties */
@@ -354,8 +354,8 @@ static zval *stmt_affected_rows_read(mysqli_object *obj, zval *retval TSRMLS_DC)
return retval;
}
- if (rc < LONG_MAX) {
- ZVAL_LONG(retval, (long) rc);
+ if (rc < ZEND_LONG_MAX) {
+ ZVAL_LONG(retval, (zend_long) rc);
} else {
ZVAL_STR(retval, strpprintf(0, MYSQLI_LLU_SPEC, rc));
}
@@ -407,9 +407,9 @@ static zval *stmt_error_list_read(mysqli_object *obj, zval *retval TSRMLS_DC)
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_insert_id_read, mysql_stmt_insert_id, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), my_ulonglong, MYSQLI_LLU_SPEC)
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_num_rows_read, mysql_stmt_num_rows, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), my_ulonglong, MYSQLI_LLU_SPEC)
-MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_param_count_read, mysql_stmt_param_count, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), ulong, "%lu")
-MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_field_count_read, mysql_stmt_field_count, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), ulong, "%lu")
-MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_errno_read, mysql_stmt_errno, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED), ulong, "%lu")
+MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_param_count_read, mysql_stmt_param_count, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
+MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_field_count_read, mysql_stmt_field_count, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
+MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_errno_read, mysql_stmt_errno, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED), zend_ulong, ZEND_ULONG_FMT)
MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_error_read, mysql_stmt_error, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED))
MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_sqlstate_read, mysql_stmt_sqlstate, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED))
diff --git a/ext/mysqli/mysqli_report.c b/ext/mysqli/mysqli_report.c
index bdd3adaf5f..7703465e21 100644
--- a/ext/mysqli/mysqli_report.c
+++ b/ext/mysqli/mysqli_report.c
@@ -33,7 +33,7 @@ extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC
sets report level */
PHP_FUNCTION(mysqli_report)
{
- long flags;
+ zend_long flags;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) {
diff --git a/ext/mysqli/mysqli_warning.c b/ext/mysqli/mysqli_warning.c
index afcc05c16f..0f39ba2edc 100644
--- a/ext/mysqli/mysqli_warning.c
+++ b/ext/mysqli/mysqli_warning.c
@@ -29,7 +29,7 @@
#include "mysqli_priv.h"
/* Define these in the PHP5 tree to make merging easy process */
-#define ZSTR_DUPLICATE (1<<0)
+#define Zzend_string_dupLICATE (1<<0)
#define ZSTR_AUTOFREE (1<<1)
#define ZVAL_UTF8_STRING(z, s, flags) ZVAL_STRING((z), (char*)(s))
@@ -59,9 +59,9 @@ MYSQLI_WARNING *php_new_warning(const char *reason, int errorno TSRMLS_DC)
w = (MYSQLI_WARNING *)ecalloc(1, sizeof(MYSQLI_WARNING));
- ZVAL_UTF8_STRING(&(w->reason), reason, ZSTR_DUPLICATE);
+ ZVAL_UTF8_STRING(&(w->reason), reason, Zzend_string_dupLICATE);
- ZVAL_UTF8_STRINGL(&(w->sqlstate), "HY000", sizeof("HY000") - 1, ZSTR_DUPLICATE);
+ ZVAL_UTF8_STRINGL(&(w->sqlstate), "HY000", sizeof("HY000") - 1, Zzend_string_dupLICATE);
w->errorno = errorno;
@@ -110,7 +110,7 @@ MYSQLI_WARNING *php_new_warning(const zval * reason, int errorno TSRMLS_DC)
//????ZVAL_UTF8_STRINGL(&(w->reason), Z_STRVAL(w->reason), Z_STRLEN(w->reason), ZSTR_AUTOFREE);
- ZVAL_UTF8_STRINGL(&(w->sqlstate), "HY000", sizeof("HY000") - 1, ZSTR_DUPLICATE);
+ ZVAL_UTF8_STRINGL(&(w->sqlstate), "HY000", sizeof("HY000") - 1, Zzend_string_dupLICATE);
w->errorno = errorno;
@@ -146,7 +146,7 @@ MYSQLI_WARNING * php_get_warnings(MYSQLND_CONN_DATA * mysql TSRMLS_DC)
/* 1. Here comes the error no */
entry = zend_hash_get_current_data(Z_ARRVAL(row));
- convert_to_long_ex(entry);
+ convert_to_int_ex(entry);
errno = Z_LVAL_P(entry);
zend_hash_move_forward(Z_ARRVAL(row));
diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h
index 8b0bf1faf9..9570952ec0 100644
--- a/ext/mysqli/php_mysqli_structs.h
+++ b/ext/mysqli/php_mysqli_structs.h
@@ -99,9 +99,9 @@ enum mysqli_status {
typedef struct {
char *val;
- ulong buflen;
- ulong output_len;
- ulong type;
+ zend_ulong buflen;
+ zend_ulong output_len;
+ zend_ulong type;
} VAR_BUFFER;
typedef struct {
@@ -214,7 +214,7 @@ extern void php_mysqli_close(MY_MYSQL * mysql, int close_type, int resource_stat
extern zend_object_iterator_funcs php_mysqli_result_iterator_funcs;
extern zend_object_iterator *php_mysqli_result_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
-extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, long fetchtype TSRMLS_DC);
+extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend_long fetchtype TSRMLS_DC);
#ifdef HAVE_SPL
extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
@@ -318,27 +318,27 @@ extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
ZEND_BEGIN_MODULE_GLOBALS(mysqli)
- long default_link;
- long num_links;
- long max_links;
- long num_active_persistent;
- long num_inactive_persistent;
- long max_persistent;
- long allow_persistent;
- unsigned long default_port;
+ zend_long default_link;
+ zend_long num_links;
+ zend_long max_links;
+ zend_long num_active_persistent;
+ zend_long num_inactive_persistent;
+ zend_long max_persistent;
+ zend_long allow_persistent;
+ zend_ulong default_port;
char *default_host;
char *default_user;
char *default_socket;
char *default_pw;
- long reconnect;
- long allow_local_infile;
- long strict;
- long error_no;
+ zend_long reconnect;
+ zend_long allow_local_infile;
+ zend_long strict;
+ zend_long error_no;
char *error_msg;
- long report_mode;
+ zend_long report_mode;
HashTable *report_ht;
- unsigned long multi_query;
- unsigned long embedded;
+ zend_ulong multi_query;
+ zend_ulong embedded;
zend_bool rollback_on_cached_plink;
ZEND_END_MODULE_GLOBALS(mysqli)
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c
index e05d6844bc..de7c8c7023 100644
--- a/ext/mysqlnd/mysqlnd.c
+++ b/ext/mysqlnd/mysqlnd.c
@@ -440,7 +440,7 @@ mysqlnd_switch_to_ssl_if_needed(
MYSQLND_CONN_DATA * conn,
const MYSQLND_PACKET_GREET * const greet_packet,
const MYSQLND_OPTIONS * const options,
- unsigned long mysql_flags
+ zend_ulong mysql_flags
TSRMLS_DC
)
{
@@ -546,7 +546,7 @@ mysqlnd_run_authentication(
const char * const auth_protocol,
unsigned int charset_no,
const MYSQLND_OPTIONS * const options,
- unsigned long mysql_flags,
+ zend_ulong mysql_flags,
zend_bool silent,
zend_bool is_change_user
TSRMLS_DC)
@@ -678,7 +678,7 @@ mysqlnd_connect_run_authentication(
size_t passwd_len,
const MYSQLND_PACKET_GREET * const greet_packet,
const MYSQLND_OPTIONS * const options,
- unsigned long mysql_flags
+ zend_ulong mysql_flags
TSRMLS_DC)
{
enum_func_status ret = FAIL;
@@ -1588,7 +1588,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, sqlstate)(const MYSQLND_CONN_DATA * const conn
/* {{{ mysqlnd_old_escape_string */
-PHPAPI ulong
+PHPAPI zend_ulong
mysqlnd_old_escape_string(char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC)
{
DBG_ENTER("mysqlnd_old_escape_string");
@@ -1622,11 +1622,11 @@ MYSQLND_METHOD(mysqlnd_conn_data, ssl_set)(MYSQLND_CONN_DATA * const conn, const
/* {{{ mysqlnd_conn_data::escape_string */
-static ulong
+static zend_ulong
MYSQLND_METHOD(mysqlnd_conn_data, escape_string)(MYSQLND_CONN_DATA * const conn, char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC)
{
size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, escape_string);
- ulong ret = FAIL;
+ zend_ulong ret = FAIL;
DBG_ENTER("mysqlnd_conn_data::escape_string");
DBG_INF_FMT("conn=%llu", conn->thread_id);
@@ -1750,7 +1750,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, statistic)(MYSQLND_CONN_DATA * conn, zend_stri
if (PASS == (ret = PACKET_READ(stats_header, conn))) {
/* will be freed by Zend, thus don't use the mnd_ allocator */
- *message = STR_INIT(stats_header->message, stats_header->message_len, 0);
+ *message = zend_string_init(stats_header->message, stats_header->message_len, 0);
DBG_INF((*message)->val);
}
PACKET_FREE(stats_header);
@@ -2114,23 +2114,23 @@ MYSQLND_METHOD(mysqlnd_conn_data, thread_id)(const MYSQLND_CONN_DATA * const con
/* {{{ mysqlnd_conn_data::get_server_version */
-static unsigned long
+static zend_ulong
MYSQLND_METHOD(mysqlnd_conn_data, get_server_version)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC)
{
- long major, minor, patch;
+ zend_long major, minor, patch;
char *p;
if (!(p = conn->server_version)) {
return 0;
}
- major = strtol(p, &p, 10);
+ major = ZEND_STRTOL(p, &p, 10);
p += 1; /* consume the dot */
- minor = strtol(p, &p, 10);
+ minor = ZEND_STRTOL(p, &p, 10);
p += 1; /* consume the dot */
- patch = strtol(p, &p, 10);
+ patch = ZEND_STRTOL(p, &p, 10);
- return (unsigned long)(major * 10000L + (unsigned long)(minor * 100L + patch));
+ return (zend_ulong)(major * Z_I(10000) + (zend_ulong)(minor * Z_I(100) + patch));
}
/* }}} */
@@ -2496,7 +2496,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option_2d)(MYSQLND_CONN_DATA * cons
DBG_INF_FMT("Adding [%s][%s]", key, value);
{
zval attrz;
- ZVAL_STR(&attrz, STR_INIT(value, strlen(value), 1));
+ ZVAL_STR(&attrz, zend_string_init(value, strlen(value), 1));
zend_hash_str_update(conn->options->connect_attr, key, strlen(key), &attrz);
}
break;
diff --git a/ext/mysqlnd/mysqlnd.h b/ext/mysqlnd/mysqlnd.h
index 94620d9369..c70934be4d 100644
--- a/ext/mysqlnd/mysqlnd.h
+++ b/ext/mysqlnd/mysqlnd.h
@@ -219,7 +219,7 @@ void mysqlnd_local_infile_default(MYSQLND_CONN_DATA * conn);
#define mysqlnd_escape_string(newstr, escapestr, escapestr_len) \
mysqlnd_old_escape_string((newstr), (escapestr), (escapestr_len) TSRMLS_CC)
-PHPAPI ulong mysqlnd_old_escape_string(char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC);
+PHPAPI zend_ulong mysqlnd_old_escape_string(char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC);
/* PS */
@@ -270,17 +270,17 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqlnd)
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;
- long net_read_timeout;
- long mempool_default_size;
- long debug_emalloc_fail_threshold;
- long debug_ecalloc_fail_threshold;
- long debug_erealloc_fail_threshold;
- long debug_malloc_fail_threshold;
- long debug_calloc_fail_threshold;
- long debug_realloc_fail_threshold;
+ zend_long net_cmd_buffer_size;
+ zend_long net_read_buffer_size;
+ zend_long log_mask;
+ zend_long net_read_timeout;
+ zend_long mempool_default_size;
+ zend_long debug_emalloc_fail_threshold;
+ zend_long debug_ecalloc_fail_threshold;
+ zend_long debug_erealloc_fail_threshold;
+ zend_long debug_malloc_fail_threshold;
+ zend_long debug_calloc_fail_threshold;
+ zend_long debug_realloc_fail_threshold;
char * sha256_server_public_key;
zend_bool fetch_data_copy;
ZEND_END_MODULE_GLOBALS(mysqlnd)
diff --git a/ext/mysqlnd/mysqlnd_alloc.c b/ext/mysqlnd/mysqlnd_alloc.c
index c3228aa4f1..9cc46dba4a 100644
--- a/ext/mysqlnd/mysqlnd_alloc.c
+++ b/ext/mysqlnd/mysqlnd_alloc.c
@@ -79,7 +79,7 @@ void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D)
void *ret;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
- long * threshold = &MYSQLND_G(debug_emalloc_fail_threshold);
+ zend_long * threshold = &MYSQLND_G(debug_emalloc_fail_threshold);
#endif
TRACE_ALLOC_ENTER(mysqlnd_emalloc_name);
@@ -119,7 +119,7 @@ void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D)
void *ret;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
- long * threshold = persistent? &MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold);
+ zend_long * threshold = persistent? &MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold);
#endif
TRACE_ALLOC_ENTER(mysqlnd_pemalloc_name);
@@ -162,7 +162,7 @@ void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
void *ret;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
- long * threshold = &MYSQLND_G(debug_ecalloc_fail_threshold);
+ zend_long * threshold = &MYSQLND_G(debug_ecalloc_fail_threshold);
#endif
TRACE_ALLOC_ENTER(mysqlnd_ecalloc_name);
@@ -203,7 +203,7 @@ void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent M
void *ret;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
- long * threshold = persistent? &MYSQLND_G(debug_calloc_fail_threshold):&MYSQLND_G(debug_ecalloc_fail_threshold);
+ zend_long * threshold = persistent? &MYSQLND_G(debug_calloc_fail_threshold):&MYSQLND_G(debug_ecalloc_fail_threshold);
#endif
TRACE_ALLOC_ENTER(mysqlnd_pecalloc_name);
#if PHP_DEBUG
@@ -246,7 +246,7 @@ void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D)
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
size_t old_size = collect_memory_statistics && ptr? *(size_t *) (((char*)ptr) - sizeof(size_t)) : 0;
#if PHP_DEBUG
- long * threshold = &MYSQLND_G(debug_erealloc_fail_threshold);
+ zend_long * threshold = &MYSQLND_G(debug_erealloc_fail_threshold);
#endif
TRACE_ALLOC_ENTER(mysqlnd_erealloc_name);
@@ -287,7 +287,7 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
size_t old_size = collect_memory_statistics && ptr? *(size_t *) (((char*)ptr) - sizeof(size_t)) : 0;
#if PHP_DEBUG
- long * threshold = persistent? &MYSQLND_G(debug_realloc_fail_threshold):&MYSQLND_G(debug_erealloc_fail_threshold);
+ zend_long * threshold = persistent? &MYSQLND_G(debug_realloc_fail_threshold):&MYSQLND_G(debug_erealloc_fail_threshold);
#endif
TRACE_ALLOC_ENTER(mysqlnd_perealloc_name);
@@ -393,7 +393,7 @@ void * _mysqlnd_malloc(size_t size MYSQLND_MEM_D)
void *ret;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
- long * threshold = &MYSQLND_G(debug_malloc_fail_threshold);
+ zend_long * threshold = &MYSQLND_G(debug_malloc_fail_threshold);
#endif
TRACE_ALLOC_ENTER(mysqlnd_malloc_name);
@@ -432,7 +432,7 @@ void * _mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
void *ret;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
- long * threshold = &MYSQLND_G(debug_calloc_fail_threshold);
+ zend_long * threshold = &MYSQLND_G(debug_calloc_fail_threshold);
#endif
TRACE_ALLOC_ENTER(mysqlnd_calloc_name);
@@ -471,7 +471,7 @@ void * _mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D)
void *ret;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
#if PHP_DEBUG
- long * threshold = &MYSQLND_G(debug_realloc_fail_threshold);
+ zend_long * threshold = &MYSQLND_G(debug_realloc_fail_threshold);
#endif
TRACE_ALLOC_ENTER(mysqlnd_realloc_name);
diff --git a/ext/mysqlnd/mysqlnd_auth.c b/ext/mysqlnd/mysqlnd_auth.c
index 1ac05930f7..985357e3bc 100644
--- a/ext/mysqlnd/mysqlnd_auth.c
+++ b/ext/mysqlnd/mysqlnd_auth.c
@@ -37,7 +37,7 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn,
const char * const db,
const size_t db_len,
const MYSQLND_OPTIONS * const options,
- unsigned long mysql_flags,
+ zend_ulong mysql_flags,
unsigned int server_charset_no,
zend_bool use_full_blown_auth_packet,
const char * const auth_protocol,
@@ -361,7 +361,7 @@ mysqlnd_native_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
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
+ zend_ulong mysql_flags
TSRMLS_DC)
{
zend_uchar * ret = NULL;
@@ -421,7 +421,7 @@ mysqlnd_pam_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
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
+ zend_ulong mysql_flags
TSRMLS_DC)
{
zend_uchar * ret = NULL;
@@ -553,7 +553,7 @@ mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn,
BIO_free(bio);
DBG_INF("Successfully loaded");
DBG_INF_FMT("Public key:%*.s", key_str->len, key_str->val);
- STR_RELEASE(key_str);
+ zend_string_release(key_str);
}
php_stream_free(stream, PHP_STREAM_FREE_CLOSE);
}
@@ -571,7 +571,7 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
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
+ zend_ulong mysql_flags
TSRMLS_DC)
{
RSA * server_public_key;
diff --git a/ext/mysqlnd/mysqlnd_charset.c b/ext/mysqlnd/mysqlnd_charset.c
index dfa90db255..bf67498eea 100644
--- a/ext/mysqlnd/mysqlnd_charset.c
+++ b/ext/mysqlnd/mysqlnd_charset.c
@@ -726,7 +726,7 @@ PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_name(const char * const name
/* {{{ mysqlnd_cset_escape_quotes */
-PHPAPI ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const cset, char *newstr,
+PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const cset, char *newstr,
const char * escapestr, size_t escapestr_len TSRMLS_DC)
{
const char *newstr_s = newstr;
@@ -780,7 +780,7 @@ PHPAPI ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const cset, char
/* {{{ mysqlnd_cset_escape_slashes */
-PHPAPI ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, char *newstr,
+PHPAPI zend_ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, char *newstr,
const char * escapestr, size_t escapestr_len TSRMLS_DC)
{
const char *newstr_s = newstr;
diff --git a/ext/mysqlnd/mysqlnd_charset.h b/ext/mysqlnd/mysqlnd_charset.h
index cf3eada8af..87f30d8ba5 100644
--- a/ext/mysqlnd/mysqlnd_charset.h
+++ b/ext/mysqlnd/mysqlnd_charset.h
@@ -21,10 +21,10 @@
#ifndef MYSQLND_CHARSET_H
#define MYSQLND_CHARSET_H
-PHPAPI ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const charset, char *newstr,
+PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const charset, char *newstr,
const char *escapestr, size_t escapestr_len TSRMLS_DC);
-PHPAPI ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, char *newstr,
+PHPAPI zend_ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, char *newstr,
const char *escapestr, size_t escapestr_len TSRMLS_DC);
struct st_mysqlnd_plugin_charsets
@@ -34,8 +34,8 @@ struct st_mysqlnd_plugin_charsets
{
const MYSQLND_CHARSET * (*const find_charset_by_nr)(unsigned int charsetnr);
const MYSQLND_CHARSET * (*const find_charset_by_name)(const char * const name);
- unsigned long (*const escape_quotes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC);
- unsigned long (*const escape_slashes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC);
+ zend_ulong (*const escape_quotes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC);
+ zend_ulong (*const escape_slashes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC);
} methods;
};
diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h
index 3212c778a8..0d6a25a419 100644
--- a/ext/mysqlnd/mysqlnd_enum_n_def.h
+++ b/ext/mysqlnd/mysqlnd_enum_n_def.h
@@ -606,7 +606,7 @@ enum php_mysqlnd_server_command
};
-#define MYSQLND_DEFAULT_PREFETCH_ROWS (ulong) 1
+#define MYSQLND_DEFAULT_PREFETCH_ROWS (zend_ulong) 1
#define MYSQLND_REFRESH_GRANT 1 /* Refresh grant tables */
#define MYSQLND_REFRESH_LOG 2 /* Start on new log file */
diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c
index 84757f88c1..6a243d5315 100644
--- a/ext/mysqlnd/mysqlnd_net.c
+++ b/ext/mysqlnd/mysqlnd_net.c
@@ -193,7 +193,7 @@ MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const cha
SET_CLIENT_ERROR(*error_info, errcode? errcode:CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, errstr->val);
if (errstr) {
/* no mnd_ since we don't allocate it */
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
}
DBG_RETURN(NULL);
}
@@ -676,7 +676,7 @@ MYSQLND_METHOD(mysqlnd_net, receive_ex)(MYSQLND_NET * const net, zend_uchar * co
}
net->compressed_envelope_packet_no++;
#ifdef MYSQLND_DUMP_HEADER_N_BODY
- DBG_INF_FMT("HEADER: hwd_packet_no=%u size=%3u", packet_no, (unsigned long) net_payload_size);
+ DBG_INF_FMT("HEADER: hwd_packet_no=%u size=%3u", packet_no, (zend_ulong) net_payload_size);
#endif
/* Now let's read from the wire, decompress it and fill the read buffer */
net->data->m.read_compressed_packet_from_stream_and_fill_read_buffer(net, net_payload_size, conn_stats, error_info TSRMLS_CC);
diff --git a/ext/mysqlnd/mysqlnd_portability.h b/ext/mysqlnd/mysqlnd_portability.h
index 72a156a795..424f52d1e6 100644
--- a/ext/mysqlnd/mysqlnd_portability.h
+++ b/ext/mysqlnd/mysqlnd_portability.h
@@ -194,13 +194,13 @@ This file is public domain and comes with NO WARRANTY of any kind */
(((uint32_t) (zend_uchar) (A)[2]) << 16) |\
(((uint32_t) (zend_uchar) (A)[1]) << 8) | \
((uint32_t) (zend_uchar) (A)[0])))
-#define sint4korr(A) (*((long *) (A)))
+#define sint4korr(A) (*((zend_long *) (A)))
#define uint2korr(A) (*((uint16_t *) (A)))
#define uint3korr(A) (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\
(((uint32_t) ((zend_uchar) (A)[1])) << 8) +\
(((uint32_t) ((zend_uchar) (A)[2])) << 16))
-#define uint4korr(A) (*((unsigned long *) (A)))
+#define uint4korr(A) (*((zend_ulong *) (A)))
@@ -211,7 +211,7 @@ This file is public domain and comes with NO WARRANTY of any kind */
*(T)= (zend_uchar) ((A));\
*(T+1)=(zend_uchar) (((uint32_t) (A) >> 8));\
*(T+2)=(zend_uchar) (((A) >> 16)); }
-#define int4store(T,A) *((long *) (T))= (long) (A)
+#define int4store(T,A) *((zend_long *) (T))= (zend_long) (A)
#define int5store(T,A) { \
*((zend_uchar *)(T))= (zend_uchar)((A));\
*(((zend_uchar *)(T))+1)=(zend_uchar) (((A) >> 8));\
@@ -232,12 +232,12 @@ This file is public domain and comes with NO WARRANTY of any kind */
typedef union {
double v;
- long m[2];
+ zend_long m[2];
} float8get_union;
-#define float8get(V,M) { ((float8get_union *)&(V))->m[0] = *((long*) (M)); \
- ((float8get_union *)&(V))->m[1] = *(((long*) (M))+1); }
-#define float8store(T,V) { *((long *) (T)) = ((float8get_union *)&(V))->m[0]; \
- *(((long *) (T))+1) = ((float8get_union *)&(V))->m[1]; }
+#define float8get(V,M) { ((float8get_union *)&(V))->m[0] = *((zend_long*) (M)); \
+ ((float8get_union *)&(V))->m[1] = *(((zend_long*) (M))+1); }
+#define float8store(T,V) { *((zend_long *) (T)) = ((float8get_union *)&(V))->m[0]; \
+ *(((zend_long *) (T))+1) = ((float8get_union *)&(V))->m[1]; }
#define float4get(V,M) { *((float *) &(V)) = *((float*) (M)); }
/* From Andrey Hristov based on float8get */
#define floatget(V,M) memcpy((char*) &(V),(char*) (M),sizeof(float))
diff --git a/ext/mysqlnd/mysqlnd_priv.h b/ext/mysqlnd/mysqlnd_priv.h
index 536b37caa7..79e67da464 100644
--- a/ext/mysqlnd/mysqlnd_priv.h
+++ b/ext/mysqlnd/mysqlnd_priv.h
@@ -209,7 +209,7 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn,
const char * const db,
const size_t db_len,
const MYSQLND_OPTIONS * const options,
- unsigned long mysql_flags,
+ zend_ulong mysql_flags,
unsigned int server_charset_no,
zend_bool use_full_blown_auth_packet,
const char * const auth_protocol,
diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c
index 986a664410..e2745d8729 100644
--- a/ext/mysqlnd/mysqlnd_ps.c
+++ b/ext/mysqlnd/mysqlnd_ps.c
@@ -776,7 +776,7 @@ mysqlnd_stmt_fetch_row_buffered(MYSQLND_RES * result, void * param, unsigned int
Thus for NULL and zero-length we are quite efficient.
*/
if (Z_TYPE(current_row[i]) == IS_STRING) {
- unsigned long len = Z_STRLEN(current_row[i]);
+ zend_ulong len = Z_STRLEN(current_row[i]);
if (meta->fields[i].max_length < len) {
meta->fields[i].max_length = len;
}
@@ -1302,7 +1302,7 @@ MYSQLND_METHOD(mysqlnd_stmt, flush)(MYSQLND_STMT * const s TSRMLS_DC)
/* {{{ mysqlnd_stmt::send_long_data */
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const s, unsigned int param_no,
- const char * const data, unsigned long length TSRMLS_DC)
+ const char * const data, zend_ulong length TSRMLS_DC)
{
MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
enum_func_status ret = FAIL;
@@ -1879,7 +1879,7 @@ MYSQLND_METHOD(mysqlnd_stmt, attr_set)(MYSQLND_STMT * const s,
}
case STMT_ATTR_CURSOR_TYPE: {
unsigned int ival = *(unsigned int *) value;
- if (ival > (unsigned long) CURSOR_TYPE_READ_ONLY) {
+ if (ival > (zend_ulong) CURSOR_TYPE_READ_ONLY) {
SET_STMT_ERROR(stmt, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
DBG_INF("FAIL");
DBG_RETURN(FAIL);
@@ -1927,10 +1927,10 @@ MYSQLND_METHOD(mysqlnd_stmt, attr_get)(const MYSQLND_STMT * const s,
*(zend_bool *) value= stmt->update_max_length;
break;
case STMT_ATTR_CURSOR_TYPE:
- *(unsigned long *) value= stmt->flags;
+ *(zend_ulong *) value= stmt->flags;
break;
case STMT_ATTR_PREFETCH_ROWS:
- *(unsigned long *) value= stmt->prefetch_rows;
+ *(zend_ulong *) value= stmt->prefetch_rows;
break;
default:
DBG_RETURN(FAIL);
diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c
index 746cf01a26..cfe6f26280 100644
--- a/ext/mysqlnd/mysqlnd_ps_codec.c
+++ b/ext/mysqlnd/mysqlnd_ps_codec.c
@@ -41,7 +41,7 @@ enum mysqlnd_timestamp_type
struct st_mysqlnd_time
{
unsigned int year, month, day, hour, minute, second;
- unsigned long second_part;
+ zend_ulong second_part;
zend_bool neg;
enum mysqlnd_timestamp_type time_type;
};
@@ -76,7 +76,7 @@ ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, unsigne
case 1:uval = (uint64_t) uint1korr(*row);break;
}
-#if SIZEOF_LONG==4
+#if SIZEOF_ZEND_INT==4
if (uval > INT_MAX) {
DBG_INF("stringify");
tmp_len = sprintf((char *)&tmp, MYSQLND_LLU_SPEC, uval);
@@ -84,7 +84,7 @@ ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, unsigne
#endif /* #if SIZEOF_LONG==4 */
{
if (byte_count < 8 || uval <= L64(9223372036854775807)) {
- ZVAL_LONG(zv, (long) uval); /* the cast is safe, we are in the range */
+ ZVAL_LONG(zv, (zend_long) uval); /* the cast is safe, we are in the range */
} else {
DBG_INF("stringify");
tmp_len = sprintf((char *)&tmp, MYSQLND_LLU_SPEC, uval);
@@ -105,14 +105,14 @@ ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, unsigne
case 1:lval = (int64_t) *(int8_t*)*row;break;
}
-#if SIZEOF_LONG==4
+#if SIZEOF_ZEND_INT==4
if ((L64(2147483647) < (int64_t) lval) || (L64(-2147483648) > (int64_t) lval)) {
DBG_INF("stringify");
tmp_len = sprintf((char *)&tmp, MYSQLND_LL_SPEC, lval);
} else
#endif /* SIZEOF */
{
- ZVAL_LONG(zv, (long) lval); /* the cast is safe, we are in the range */
+ ZVAL_LONG(zv, (zend_long) lval); /* the cast is safe, we are in the range */
}
}
@@ -246,7 +246,7 @@ 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 long length; /* First byte encodes the length*/
+ zend_ulong length; /* First byte encodes the length*/
char * value;
DBG_ENTER("ps_fetch_time");
@@ -256,11 +256,11 @@ ps_fetch_time(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_le
t.time_type = MYSQLND_TIMESTAMP_TIME;
t.neg = (zend_bool) to[0];
- t.day = (unsigned long) sint4korr(to+1);
+ t.day = (zend_ulong) sint4korr(to+1);
t.hour = (unsigned int) to[5];
t.minute = (unsigned int) to[6];
t.second = (unsigned int) to[7];
- t.second_part = (length > 8) ? (unsigned long) sint4korr(to+8) : 0;
+ t.second_part = (length > 8) ? (zend_ulong) sint4korr(to+8) : 0;
t.year = t.month= 0;
if (t.day) {
/* Convert days to hours at once */
@@ -289,7 +289,7 @@ 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 long length; /* First byte encodes the length*/
+ zend_ulong length; /* First byte encodes the length*/
char * value;
DBG_ENTER("ps_fetch_date");
@@ -326,7 +326,7 @@ 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 long length; /* First byte encodes the length*/
+ zend_ulong length; /* First byte encodes the length*/
char * value;
DBG_ENTER("ps_fetch_datetime");
@@ -347,7 +347,7 @@ ps_fetch_datetime(zval * zv, const MYSQLND_FIELD * const field, unsigned int pac
} else {
t.hour = t.minute = t.second= 0;
}
- t.second_part = (length > 7) ? (unsigned long) sint4korr(to+7) : 0;
+ t.second_part = (length > 7) ? (zend_ulong) sint4korr(to+7) : 0;
(*row)+= length;
} else {
@@ -373,7 +373,7 @@ ps_fetch_string(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_
For now just copy, before we make it possible
to write \0 to the row buffer
*/
- const unsigned long length = php_mysqlnd_net_field_length(row);
+ const zend_ulong length = php_mysqlnd_net_field_length(row);
DBG_ENTER("ps_fetch_string");
DBG_INF_FMT("len = %lu", length);
DBG_INF("copying from the row buffer");
@@ -389,7 +389,7 @@ ps_fetch_string(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_
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);
+ zend_ulong length = php_mysqlnd_net_field_length(row);
ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, length TSRMLS_CC);
}
/* }}} */
@@ -636,11 +636,11 @@ mysqlnd_stmt_execute_prepare_param_types(MYSQLND_STMT_DATA * stmt, zval ** copie
Check bug #52891 : Wrong data inserted with mysqli/mysqlnd when using bind_param, value > LONG_MAX
We do transformation here, which will be used later when sending types. The code later relies on this.
*/
- if (Z_DVAL(tmp_data_copy) > LONG_MAX || Z_DVAL(tmp_data_copy) < LONG_MIN) {
+ if (Z_DVAL(tmp_data_copy) > ZEND_LONG_MAX || Z_DVAL(tmp_data_copy) < ZEND_LONG_MIN) {
stmt->send_types_to_server = *resend_types_next_time = 1;
convert_to_string_ex(tmp_data);
} else {
- convert_to_long_ex(tmp_data);
+ convert_to_int_ex(tmp_data);
}
zval_ptr_dtor(&tmp_data_copy);
@@ -663,7 +663,7 @@ mysqlnd_stmt_execute_store_types(MYSQLND_STMT_DATA * stmt, zval * copies, zend_u
short current_type = stmt->param_bind[i].type;
zval *parameter = &stmt->param_bind[i].zv;
/* our types are not unsigned */
-#if SIZEOF_LONG==8
+#if SIZEOF_ZEND_INT==8
if (current_type == MYSQL_TYPE_LONG) {
current_type = MYSQL_TYPE_LONGLONG;
}
@@ -684,7 +684,7 @@ mysqlnd_stmt_execute_store_types(MYSQLND_STMT_DATA * stmt, zval * copies, zend_u
current_type = MYSQL_TYPE_VAR_STRING;
/*
don't change stmt->param_bind[i].type to MYSQL_TYPE_VAR_STRING
- we force convert_to_long_ex in all cases, thus the type will be right in the next switch.
+ we force convert_to_int_ex in all cases, thus the type will be right in the next switch.
if the type is however not long, then we will do a goto in the next switch.
We want to preserve the original bind type given by the user. Thus, we do these hacks.
*/
@@ -751,7 +751,7 @@ mysqlnd_stmt_execute_calculate_param_values_size(MYSQLND_STMT_DATA * stmt, zval
if (Z_TYPE_P(tmp_data) == IS_STRING) {
goto use_string;
}
- convert_to_long_ex(tmp_data);
+ convert_to_int_ex(tmp_data);
}
*data_size += 4 + is_longlong;
break;
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index 0641d504c6..ea275be192 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -71,7 +71,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered_zval, initialize_result_set_rest)(MYSQLND
Thus for NULL and zero-length we are quite efficient.
*/
if (Z_TYPE(data_cursor[i]) == IS_STRING) {
- unsigned long len = Z_STRLEN(data_cursor[i]);
+ zend_ulong len = Z_STRLEN(data_cursor[i]);
if (meta->fields[i].max_length < len) {
meta->fields[i].max_length = len;
}
@@ -126,7 +126,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered_c, initialize_result_set_rest)(MYSQLND_RE
Thus for NULL and zero-length we are quite efficient.
*/
if (Z_TYPE(current_row[i]) == IS_STRING) {
- unsigned long len = Z_STRLEN(current_row[i]);
+ zend_ulong len = Z_STRLEN(current_row[i]);
if (meta->fields[i].max_length < len) {
meta->fields[i].max_length = len;
}
@@ -599,7 +599,7 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s
of PHP, to be called as separate function. But let's have it for
completeness.
*/
-static unsigned long *
+static zend_ulong *
MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_lengths)(MYSQLND_RES_BUFFERED * const result TSRMLS_DC)
{
const MYSQLND_RES_BUFFERED_ZVAL * set = (MYSQLND_RES_BUFFERED_ZVAL *) result;
@@ -631,7 +631,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_lengths)(MYSQLND_RES_BUFFERED
of PHP, to be called as separate function. But let's have it for
completeness.
*/
-static unsigned long *
+static zend_ulong *
MYSQLND_METHOD(mysqlnd_result_buffered_c, fetch_lengths)(MYSQLND_RES_BUFFERED * const result TSRMLS_DC)
{
const MYSQLND_RES_BUFFERED_C * set = (MYSQLND_RES_BUFFERED_C *) result;
@@ -648,7 +648,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered_c, fetch_lengths)(MYSQLND_RES_BUFFERED *
/* {{{ mysqlnd_result_unbuffered::fetch_lengths */
-static unsigned long *
+static zend_ulong *
MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_lengths)(MYSQLND_RES_UNBUFFERED * const result TSRMLS_DC)
{
/* simulate output of libmysql */
@@ -658,10 +658,10 @@ MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_lengths)(MYSQLND_RES_UNBUFFERED
/* {{{ mysqlnd_res::fetch_lengths */
-static unsigned long *
+static zend_ulong *
MYSQLND_METHOD(mysqlnd_res, fetch_lengths)(MYSQLND_RES * const result TSRMLS_DC)
{
- unsigned long * ret;
+ zend_ulong * ret;
DBG_ENTER("mysqlnd_res::fetch_lengths");
ret = result->stored_data && result->stored_data->m.fetch_lengths ?
result->stored_data->m.fetch_lengths(result->stored_data TSRMLS_CC) :
@@ -731,7 +731,7 @@ MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_row_c)(MYSQLND_RES * result, voi
*row = mnd_malloc(field_count * sizeof(char *));
if (*row) {
MYSQLND_FIELD * field = meta->fields;
- unsigned long * lengths = result->unbuf->lengths;
+ zend_ulong * lengths = result->unbuf->lengths;
for (i = 0; i < field_count; i++, field++) {
zval * data = &result->unbuf->last_row_data[i];
@@ -849,7 +849,7 @@ MYSQLND_METHOD(mysqlnd_result_unbuffered, fetch_row)(MYSQLND_RES * result, void
{
HashTable * row_ht = Z_ARRVAL_P(row);
MYSQLND_FIELD * field = meta->fields;
- unsigned long * lengths = result->unbuf->lengths;
+ zend_ulong * lengths = result->unbuf->lengths;
for (i = 0; i < field_count; i++, field++) {
zval * data = &result->unbuf->last_row_data[i];
@@ -1002,7 +1002,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered, fetch_row_c)(MYSQLND_RES * result, void
Thus for NULL and zero-length we are quite efficient.
*/
if (Z_TYPE(current_row[i]) == IS_STRING) {
- unsigned long len = Z_STRLEN(current_row[i]);
+ zend_ulong len = Z_STRLEN(current_row[i]);
if (meta->fields[i].max_length < len) {
meta->fields[i].max_length = len;
}
@@ -1093,7 +1093,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_row)(MYSQLND_RES * result, vo
Thus for NULL and zero-length we are quite efficient.
*/
if (Z_TYPE(current_row[i]) == IS_STRING) {
- unsigned long len = Z_STRLEN(current_row[i]);
+ zend_ulong len = Z_STRLEN(current_row[i]);
if (meta->fields[i].max_length < len) {
meta->fields[i].max_length = len;
}
@@ -1188,7 +1188,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered_c, fetch_row)(MYSQLND_RES * result, void
Thus for NULL and zero-length we are quite efficient.
*/
if (Z_TYPE(current_row[i]) == IS_STRING) {
- unsigned long len = Z_STRLEN(current_row[i]);
+ zend_ulong len = Z_STRLEN(current_row[i]);
if (meta->fields[i].max_length < len) {
meta->fields[i].max_length = len;
}
@@ -1776,7 +1776,7 @@ static void
MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES * result, const unsigned int flags, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC)
{
zval row;
- ulong i = 0;
+ zend_ulong i = 0;
MYSQLND_RES_BUFFERED *set = result->stored_data;
DBG_ENTER("mysqlnd_res::fetch_all");
@@ -1927,7 +1927,7 @@ mysqlnd_result_unbuffered_init(unsigned int field_count, zend_bool ps, zend_bool
DBG_RETURN(NULL);
}
- if (!(ret->lengths = mnd_pecalloc(field_count, sizeof(unsigned long), persistent))) {
+ if (!(ret->lengths = mnd_pecalloc(field_count, sizeof(zend_ulong), persistent))) {
mnd_pefree(ret, persistent);
DBG_RETURN(NULL);
}
@@ -1967,7 +1967,7 @@ mysqlnd_result_buffered_zval_init(unsigned int field_count, zend_bool ps, zend_b
if (!ret) {
DBG_RETURN(NULL);
}
- if (!(ret->lengths = mnd_pecalloc(field_count, sizeof(unsigned long), persistent))) {
+ if (!(ret->lengths = mnd_pecalloc(field_count, sizeof(zend_ulong), persistent))) {
mnd_pefree(ret, persistent);
DBG_RETURN(NULL);
}
@@ -2010,7 +2010,7 @@ mysqlnd_result_buffered_c_init(unsigned int field_count, zend_bool ps, zend_bool
if (!ret) {
DBG_RETURN(NULL);
}
- if (!(ret->lengths = mnd_pecalloc(field_count, sizeof(unsigned long), persistent))) {
+ if (!(ret->lengths = mnd_pecalloc(field_count, sizeof(zend_ulong), persistent))) {
mnd_pefree(ret, persistent);
DBG_RETURN(NULL);
}
diff --git a/ext/mysqlnd/mysqlnd_result_meta.c b/ext/mysqlnd/mysqlnd_result_meta.c
index f6e38c809e..e29c077602 100644
--- a/ext/mysqlnd/mysqlnd_result_meta.c
+++ b/ext/mysqlnd/mysqlnd_result_meta.c
@@ -42,7 +42,7 @@ php_mysqlnd_free_field_metadata(MYSQLND_FIELD *meta, zend_bool persistent TSRMLS
meta->def = NULL;
}
if (meta->sname) {
- STR_RELEASE(meta->sname);
+ zend_string_release(meta->sname);
}
}
}
@@ -64,7 +64,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met
}
field_packet->persistent_alloc = meta->persistent;
for (;i < meta->field_count; i++) {
- long idx;
+ zend_long idx;
if (meta->fields[i].root) {
/* We re-read metadata for PS */
@@ -226,7 +226,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * co
memcpy(new_fields[i].root, orig_fields[i].root, new_fields[i].root_len);
if (orig_fields[i].sname) {
- new_fields[i].sname = STR_COPY(orig_fields[i].sname);
+ new_fields[i].sname = zend_string_copy(orig_fields[i].sname);
new_fields[i].name = new_fields[i].sname->val;
new_fields[i].name_length = new_fields[i].sname->len;
}
diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h
index 9ec924ead6..85e20a2c35 100644
--- a/ext/mysqlnd/mysqlnd_structs.h
+++ b/ext/mysqlnd/mysqlnd_structs.h
@@ -80,8 +80,8 @@ typedef struct st_mysqlnd_field
const char *db; /* Database for table */
const char *catalog; /* Catalog for table */
char *def; /* Default value (set by mysql_list_fields) */
- unsigned long length; /* Width of column (create length) */
- unsigned long max_length; /* Max width for selected set */
+ zend_ulong length; /* Width of column (create length) */
+ zend_ulong max_length; /* Max width for selected set */
unsigned int name_length;
unsigned int org_name_length;
unsigned int table_length;
@@ -414,7 +414,7 @@ struct st_mysqlnd_object_factory_methods
typedef enum_func_status (*func_mysqlnd_conn_data__init)(MYSQLND_CONN_DATA * conn TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_conn_data__connect)(MYSQLND_CONN_DATA * conn, const char * host, const char * user, const char * passwd, unsigned int passwd_len, const char * db, unsigned int db_len, unsigned int port, const char * socket_or_pipe, unsigned int mysql_flags TSRMLS_DC);
-typedef ulong (*func_mysqlnd_conn_data__escape_string)(MYSQLND_CONN_DATA * const conn, char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC);
+typedef zend_long (*func_mysqlnd_conn_data__escape_string)(MYSQLND_CONN_DATA * const conn, char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_conn_data__set_charset)(MYSQLND_CONN_DATA * const conn, const char * const charset TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_conn_data__query)(MYSQLND_CONN_DATA * conn, const char * query, unsigned int query_len TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_conn_data__send_query)(MYSQLND_CONN_DATA * conn, const char *query, unsigned int query_len TSRMLS_DC);
@@ -441,7 +441,7 @@ typedef const char * (*func_mysqlnd_conn_data__get_sqlstate)(const MYSQLND_CONN
typedef uint64_t (*func_mysqlnd_conn_data__get_thread_id)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC);
typedef void (*func_mysqlnd_conn_data__get_statistics)(const MYSQLND_CONN_DATA * const conn, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC);
-typedef unsigned long (*func_mysqlnd_conn_data__get_server_version)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC);
+typedef zend_ulong (*func_mysqlnd_conn_data__get_server_version)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC);
typedef const char * (*func_mysqlnd_conn_data__get_server_information)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_conn_data__get_server_statistics)(MYSQLND_CONN_DATA * conn, zend_string **message TSRMLS_DC);
typedef const char * (*func_mysqlnd_conn_data__get_host_information)(const MYSQLND_CONN_DATA * const conn TSRMLS_DC);
@@ -639,7 +639,7 @@ typedef const MYSQLND_FIELD *(*func_mysqlnd_res__fetch_field_direct)(MYSQLND_RES
typedef const MYSQLND_FIELD *(*func_mysqlnd_res__fetch_fields)(MYSQLND_RES * const result TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_res__read_result_metadata)(MYSQLND_RES * result, MYSQLND_CONN_DATA * conn TSRMLS_DC);
-typedef unsigned long * (*func_mysqlnd_res__fetch_lengths)(MYSQLND_RES * const result TSRMLS_DC);
+typedef zend_ulong * (*func_mysqlnd_res__fetch_lengths)(MYSQLND_RES * const result TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_res__store_result_fetch_data)(MYSQLND_CONN_DATA * const conn, MYSQLND_RES * result, MYSQLND_RES_METADATA * meta, MYSQLND_MEMORY_POOL_CHUNK *** row_buffers, zend_bool binary_protocol TSRMLS_DC);
typedef void (*func_mysqlnd_res__free_result_buffers)(MYSQLND_RES * result TSRMLS_DC); /* private */
@@ -690,7 +690,7 @@ struct st_mysqlnd_res_methods
typedef uint64_t (*func_mysqlnd_result_unbuffered__num_rows)(const MYSQLND_RES_UNBUFFERED * const result TSRMLS_DC);
-typedef unsigned long * (*func_mysqlnd_result_unbuffered__fetch_lengths)(MYSQLND_RES_UNBUFFERED * const result TSRMLS_DC);
+typedef zend_ulong * (*func_mysqlnd_result_unbuffered__fetch_lengths)(MYSQLND_RES_UNBUFFERED * const result TSRMLS_DC);
typedef void (*func_mysqlnd_result_unbuffered__free_last_data)(MYSQLND_RES_UNBUFFERED * result, MYSQLND_STATS * const global_stats TSRMLS_DC);
typedef void (*func_mysqlnd_result_unbuffered__free_result)(MYSQLND_RES_UNBUFFERED * const result, MYSQLND_STATS * const global_stats TSRMLS_DC);
@@ -707,7 +707,7 @@ struct st_mysqlnd_result_unbuffered_methods
typedef uint64_t (*func_mysqlnd_result_buffered__num_rows)(const MYSQLND_RES_BUFFERED * const result TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_result_buffered__initialize_result_set_rest)(MYSQLND_RES_BUFFERED * const result, MYSQLND_RES_METADATA * const meta,
MYSQLND_STATS * stats, zend_bool int_and_float_native TSRMLS_DC);
-typedef unsigned long * (*func_mysqlnd_result_buffered__fetch_lengths)(MYSQLND_RES_BUFFERED * const result TSRMLS_DC);
+typedef zend_ulong * (*func_mysqlnd_result_buffered__fetch_lengths)(MYSQLND_RES_BUFFERED * const result TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_result_buffered__data_seek)(MYSQLND_RES_BUFFERED * const result, const uint64_t row TSRMLS_DC);
typedef void (*func_mysqlnd_result_buffered__free_result)(MYSQLND_RES_BUFFERED * const result TSRMLS_DC);
@@ -763,7 +763,7 @@ typedef enum_func_status (*func_mysqlnd_stmt__bind_one_parameter)(MYSQLND_STMT *
typedef enum_func_status (*func_mysqlnd_stmt__refresh_bind_param)(MYSQLND_STMT * const stmt TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_stmt__bind_result)(MYSQLND_STMT * const stmt, MYSQLND_RESULT_BIND * const result_bind TSRMLS_DC);
typedef enum_func_status (*func_mysqlnd_stmt__bind_one_result)(MYSQLND_STMT * const stmt, unsigned int param_no TSRMLS_DC);
-typedef enum_func_status (*func_mysqlnd_stmt__send_long_data)(MYSQLND_STMT * const stmt, unsigned int param_num, const char * const data, unsigned long length TSRMLS_DC);
+typedef enum_func_status (*func_mysqlnd_stmt__send_long_data)(MYSQLND_STMT * const stmt, unsigned int param_num, const char * const data, zend_ulong length TSRMLS_DC);
typedef MYSQLND_RES * (*func_mysqlnd_stmt__get_parameter_metadata)(MYSQLND_STMT * const stmt TSRMLS_DC);
typedef MYSQLND_RES * (*func_mysqlnd_stmt__get_result_metadata)(MYSQLND_STMT * const stmt TSRMLS_DC);
typedef uint64_t (*func_mysqlnd_stmt__get_last_insert_id)(const MYSQLND_STMT * const stmt TSRMLS_DC);
@@ -923,10 +923,10 @@ struct st_mysqlnd_connection_data
unsigned int connect_or_select_db_len;
MYSQLND_INFILE infile;
unsigned int protocol_version;
- unsigned long max_packet_size;
+ zend_ulong max_packet_size;
unsigned int port;
- unsigned long client_flag;
- unsigned long server_capabilities;
+ zend_ulong client_flag;
+ zend_ulong server_capabilities;
/* For UPSERT queries */
MYSQLND_UPSERT_STATUS * upsert_status;
@@ -986,7 +986,7 @@ struct st_mysqlnd_connection
struct mysqlnd_field_hash_key
{
zend_bool is_numeric;
- unsigned long key;
+ zend_ulong key;
};
@@ -1011,7 +1011,7 @@ struct st_mysqlnd_result_metadata
uint64_t initialized_rows; \
\
/* Column lengths of current row - both buffered and unbuffered. For buffered results it duplicates the data found in **data */ \
- unsigned long *lengths; \
+ zend_ulong *lengths; \
\
MYSQLND_MEMORY_POOL *result_set_memory_pool; \
\
@@ -1064,7 +1064,7 @@ struct st_mysqlnd_unbuffered_result
Column lengths of current row - both buffered and unbuffered.
For buffered results it duplicates the data found in **data
*/
- unsigned long *lengths;
+ zend_ulong *lengths;
MYSQLND_MEMORY_POOL *result_set_memory_pool;
@@ -1117,8 +1117,8 @@ struct st_mysqlnd_result_bind
struct st_mysqlnd_stmt_data
{
MYSQLND_CONN_DATA *conn;
- unsigned long stmt_id;
- unsigned long flags;/* cursor is set here */
+ zend_ulong stmt_id;
+ zend_ulong flags;/* cursor is set here */
enum_mysqlnd_stmt_state state;
unsigned int warning_count;
MYSQLND_RES *result;
@@ -1137,7 +1137,7 @@ struct st_mysqlnd_stmt_data
MYSQLND_ERROR_INFO error_info_impl;
zend_bool update_max_length;
- unsigned long prefetch_rows;
+ zend_ulong prefetch_rows;
zend_bool cursor_exists;
mysqlnd_stmt_use_or_store_func default_rset_handler;
@@ -1166,7 +1166,7 @@ struct st_mysqlnd_plugin_header
{
unsigned int plugin_api_version;
const char * plugin_name;
- unsigned long plugin_version;
+ zend_ulong plugin_version;
const char * plugin_string_version;
const char * plugin_license;
const char * plugin_author;
@@ -1203,7 +1203,7 @@ typedef zend_uchar * (*func_auth_plugin__get_auth_data)(struct st_mysqlnd_authen
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
+ const MYSQLND_NET_OPTIONS * const net_options, zend_ulong mysql_flags
TSRMLS_DC);
struct st_mysqlnd_authentication_plugin
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
index 2aa7afde0d..5af676d02f 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
@@ -126,14 +126,14 @@ static enum_mysqlnd_collected_stats packet_type_to_statistic_packet_count[PROT_L
/* {{{ php_mysqlnd_net_field_length
Get next field's length */
-unsigned long
+zend_ulong
php_mysqlnd_net_field_length(zend_uchar **packet)
{
register zend_uchar *p= (zend_uchar *)*packet;
if (*p < 251) {
(*packet)++;
- return (unsigned long) *p;
+ return (zend_ulong) *p;
}
switch (*p) {
@@ -142,13 +142,13 @@ php_mysqlnd_net_field_length(zend_uchar **packet)
return MYSQLND_NULL_LENGTH;
case 252:
(*packet) += 3;
- return (unsigned long) uint2korr(p+1);
+ return (zend_ulong) uint2korr(p+1);
case 253:
(*packet) += 4;
- return (unsigned long) uint3korr(p+1);
+ return (zend_ulong) uint3korr(p+1);
default:
(*packet) += 9;
- return (unsigned long) uint4korr(p+1);
+ return (zend_ulong) uint4korr(p+1);
}
}
/* }}} */
@@ -201,7 +201,7 @@ php_mysqlnd_net_store_length(zend_uchar *packet, uint64_t length)
if (length < (uint64_t) L64(16777216)) {
*packet++ = 253;
- int3store(packet,(ulong) length);
+ int3store(packet,(zend_ulong) length);
return packet + 3;
}
*packet++ = 254;
@@ -567,7 +567,7 @@ size_t php_mysqlnd_auth_write(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC
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;
+ zend_ulong 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)) {
@@ -582,7 +582,7 @@ size_t php_mysqlnd_auth_write(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC
{
zend_string * key;
- unsigned long unused_num_key;
+ zend_ulong unused_num_key;
zval * entry_value;
ZEND_HASH_FOREACH_KEY_VAL(packet->connect_attr, unused_num_key, key, entry_value) {
if (key) { /* HASH_KEY_IS_STRING */
@@ -604,7 +604,7 @@ size_t php_mysqlnd_auth_write(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC
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;
+ zend_ulong 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 */
@@ -621,7 +621,7 @@ size_t php_mysqlnd_auth_write(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC
#else
{
zend_string * key;
- unsigned long unused_num_key;
+ zend_ulong unused_num_key;
zval * entry_value;
ZEND_HASH_FOREACH_KEY_VAL(packet->connect_attr, unused_num_key, key, entry_value) {
if (key) { /* HASH_KEY_IS_STRING */
@@ -685,7 +685,7 @@ php_mysqlnd_auth_response_read(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_D
zend_uchar *buf = conn->net->cmd_buffer.buffer? (zend_uchar *) conn->net->cmd_buffer.buffer : local_buf;
zend_uchar *p = buf;
zend_uchar *begin = buf;
- unsigned long i;
+ zend_ulong i;
register MYSQLND_PACKET_AUTH_RESPONSE * packet= (MYSQLND_PACKET_AUTH_RESPONSE *) _packet;
DBG_ENTER("php_mysqlnd_auth_response_read");
@@ -753,7 +753,7 @@ php_mysqlnd_auth_response_read(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_D
packet->message_len = 0;
}
- DBG_INF_FMT("OK packet: aff_rows=%lld last_ins_id=%ld server_status=%u warnings=%u",
+ DBG_INF_FMT("OK packet: aff_rows=%lld last_ins_id=%pd server_status=%u warnings=%u",
packet->affected_rows, packet->last_insert_id, packet->server_status,
packet->warning_count);
}
@@ -848,7 +848,7 @@ php_mysqlnd_ok_read(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC)
zend_uchar *buf = conn->net->cmd_buffer.buffer? (zend_uchar *) conn->net->cmd_buffer.buffer : local_buf;
zend_uchar *p = buf;
zend_uchar *begin = buf;
- unsigned long i;
+ zend_ulong i;
register MYSQLND_PACKET_OK *packet= (MYSQLND_PACKET_OK *) _packet;
DBG_ENTER("php_mysqlnd_ok_read");
@@ -1230,7 +1230,7 @@ php_mysqlnd_rset_field_read(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC)
zend_uchar *p = buf;
zend_uchar *begin = buf;
char *root_ptr;
- unsigned long len;
+ zend_ulong len;
MYSQLND_FIELD *meta;
unsigned int i, field_count = sizeof(rset_field_offsets)/sizeof(size_t);
@@ -1356,7 +1356,7 @@ php_mysqlnd_rset_field_read(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC)
meta->root_len = total_len;
if (meta->name != mysqlnd_empty_string) {
- meta->sname = STR_INIT(meta->name, meta->name_length, packet->persistent_alloc);
+ meta->sname = zend_string_init(meta->name, meta->name_length, packet->persistent_alloc);
} else {
meta->sname = STR_EMPTY_ALLOC();
}
@@ -1622,7 +1622,7 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
for (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {
/* php_mysqlnd_net_field_length() call should be after *this_field_len_pos = p; */
- unsigned long len = php_mysqlnd_net_field_length(&p);
+ zend_ulong len = php_mysqlnd_net_field_length(&p);
/* NULL or NOT NULL, this is the question! */
if (len == MYSQLND_NULL_LENGTH) {
@@ -1671,7 +1671,7 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
zend_uchar save = *(p + len);
/* We have to make it ASCIIZ temporarily */
*(p + len) = '\0';
- if (perm_bind.pack_len < SIZEOF_LONG) {
+ if (perm_bind.pack_len < SIZEOF_ZEND_INT) {
/* direct conversion */
int64_t v =
#ifndef PHP_WIN32
@@ -1679,7 +1679,7 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
#else
_atoi64((char *) p);
#endif
- ZVAL_LONG(current_field, (long) v); /* the cast is safe */
+ ZVAL_LONG(current_field, (zend_long) v); /* the cast is safe */
} else {
uint64_t v =
#ifndef PHP_WIN32
@@ -1689,9 +1689,9 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
#endif
zend_bool uns = fields_metadata[i].flags & UNSIGNED_FLAG? TRUE:FALSE;
/* We have to make it ASCIIZ temporarily */
-#if SIZEOF_LONG==8
+#if SIZEOF_ZEND_INT==8
if (uns == TRUE && v > 9223372036854775807L)
-#elif SIZEOF_LONG==4
+#elif SIZEOF_ZEND_INT==4
if ((uns == TRUE && v > L64(2147483647)) ||
(uns == FALSE && (( L64(2147483647) < (int64_t) v) ||
(L64(-2147483648) > (int64_t) v))))
@@ -1701,7 +1701,7 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
{
ZVAL_STRINGL(current_field, (char *)p, len);
} else {
- ZVAL_LONG(current_field, (long) v); /* the cast is safe */
+ ZVAL_LONG(current_field, (zend_long) v); /* the cast is safe */
}
}
*(p + len) = save;
@@ -1731,7 +1731,7 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
*/
p -= len;
if (Z_TYPE_P(current_field) == IS_LONG) {
- bit_area += 1 + sprintf((char *)start, "%ld", Z_LVAL_P(current_field));
+ bit_area += 1 + sprintf((char *)start, ZEND_LONG_FMT, Z_LVAL_P(current_field));
ZVAL_STRINGL(current_field, (char *) start, bit_area - start - 1);
} else if (Z_TYPE_P(current_field) == IS_STRING){
memcpy(bit_area, Z_STRVAL_P(current_field), Z_STRLEN_P(current_field));
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.h b/ext/mysqlnd/mysqlnd_wireprotocol.h
index bd87d9e757..b40808d595 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.h
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.h
@@ -28,7 +28,7 @@
#define MYSQLND_HEADER_SIZE 4
#define COMPRESSED_HEADER_SIZE 3
-#define MYSQLND_NULL_LENGTH (unsigned long) ~0
+#define MYSQLND_NULL_LENGTH (zend_ulong) ~0
/* Used in mysqlnd_debug.c */
PHPAPI extern const char mysqlnd_read_header_name[];
@@ -185,7 +185,7 @@ typedef struct st_mysqlnd_packet_rset_header {
error_no != 0 => error
others => result set -> Read res_field packets up to field_count
*/
- unsigned long field_count;
+ zend_ulong field_count;
/*
These are filled if no SELECT query. For SELECT warning_count
and server status are in the last row packet, the EOF packet.
@@ -258,7 +258,7 @@ typedef struct st_mysqlnd_packet_prepare_response {
MYSQLND_PACKET_HEADER header;
/* also known as field_count 0x00=OK , 0xFF=error */
unsigned char error_code;
- unsigned long stmt_id;
+ zend_ulong stmt_id;
unsigned int field_count;
unsigned int param_count;
unsigned int warning_count;
@@ -300,7 +300,7 @@ typedef struct st_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);
+zend_ulong php_mysqlnd_net_field_length(zend_uchar **packet);
zend_uchar * php_mysqlnd_net_store_length(zend_uchar *packet, uint64_t length);
size_t php_mysqlnd_net_store_length_size(uint64_t length);
diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c
index e0bc6d126d..15d572793b 100644
--- a/ext/mysqlnd/php_mysqlnd.c
+++ b/ext/mysqlnd/php_mysqlnd.c
@@ -138,11 +138,11 @@ PHP_MINFO_FUNCTION(mysqlnd)
#else
"not supported");
#endif
- snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_cmd_buffer_size));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MYSQLND_G(net_cmd_buffer_size));
php_info_print_table_row(2, "Command buffer size", buf);
- snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_buffer_size));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MYSQLND_G(net_read_buffer_size));
php_info_print_table_row(2, "Read buffer size", buf);
- snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_timeout));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MYSQLND_G(net_read_timeout));
php_info_print_table_row(2, "Read timeout", buf);
php_info_print_table_row(2, "Collecting statistics", MYSQLND_G(collect_statistics)? "Yes":"No");
php_info_print_table_row(2, "Collecting memory statistics", MYSQLND_G(collect_memory_statistics)? "Yes":"No");
@@ -206,7 +206,9 @@ static PHP_GINIT_FUNCTION(mysqlnd)
*/
static PHP_INI_MH(OnUpdateNetCmdBufferSize)
{
- long long_value = atol(new_value);
+ zend_long long_value;
+
+ ZEND_ATOL(long_value, new_value);
if (long_value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) {
return FAILURE;
}
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index f05c0e8109..3c63692533 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -2090,7 +2090,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
if (alloc_non_persistent) {
connection = (php_oci_connection *) ecalloc(1, sizeof(php_oci_connection));
- connection->hash_key = zend_str_dup(hashed_details.s, 0);
+ connection->hash_key = zend_string_dup(hashed_details.s, 0);
connection->is_persistent = 0;
#ifdef HAVE_OCI8_DTRACE
connection->client_id = NULL;
@@ -2100,7 +2100,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
if (connection == NULL) {
return NULL;
}
- connection->hash_key = zend_str_dup(hashed_details.s, 1);
+ connection->hash_key = zend_string_dup(hashed_details.s, 1);
if (connection->hash_key == NULL) {
free(connection);
return NULL;
@@ -2112,7 +2112,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
}
} else {
connection = (php_oci_connection *) ecalloc(1, sizeof(php_oci_connection));
- connection->hash_key = zend_str_dup(hashed_details.s, 0);
+ connection->hash_key = zend_string_dup(hashed_details.s, 0);
connection->is_persistent = 0;
#ifdef HAVE_OCI8_DTRACE
connection->client_id = NULL;
@@ -2849,7 +2849,7 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
/* Populate key if passed */
if (hash_key->val) {
- session_pool->spool_hash_key = zend_str_dup(hash_key, 1);
+ session_pool->spool_hash_key = zend_string_dup(hash_key, 1);
if (session_pool->spool_hash_key == NULL) {
iserror = 1;
goto exit_create_spool;
diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c
index f9d2a3a0ff..415961d4ca 100644
--- a/ext/oci8/oci8_statement.c
+++ b/ext/oci8/oci8_statement.c
@@ -1143,7 +1143,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
return 1;
}
- convert_to_long(var);
+ convert_to_int(var);
bind_data = (ub4 *)&Z_LVAL_P(var);
value_sz = sizeof(ub4);
mode = OCI_DEFAULT;
@@ -1463,7 +1463,7 @@ php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAME
/* NB: for PHP4 compat only, it should be using 'Z' instead */
tmp = *column_index;
zval_copy_ctor(&tmp);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
column = php_oci_statement_get_column(statement, Z_LVAL(tmp), NULL, 0 TSRMLS_CC);
if (!column) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid column index \"%ld\"", Z_LVAL(tmp));
@@ -1720,7 +1720,7 @@ php_oci_bind *php_oci_bind_array_helper_number(zval *var, long max_table_length
bind->array.element_lengths[i] = sizeof(ub4);
}
if ((i < bind->array.current_length) && (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE)) {
- convert_to_long_ex(entry);
+ convert_to_int_ex(entry);
((ub4 *)bind->array.elements)[i] = (ub4) Z_LVAL_PP(entry);
zend_hash_move_forward(hash);
} else {
diff --git a/ext/odbc/birdstep.c b/ext/odbc/birdstep.c
index 7bc3833d86..9148c71da9 100644
--- a/ext/odbc/birdstep.c
+++ b/ext/odbc/birdstep.c
@@ -291,7 +291,7 @@ PHP_FUNCTION(birdstep_connect)
RETCODE stat;
HDBC hdbc;
VConn *new;
- long ind;
+ zend_long ind;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &serv, &serv_len, &user, &user_len, &pass, &pass_len) == FAILURE) {
return;
@@ -324,7 +324,7 @@ PHP_FUNCTION(birdstep_connect)
*/
PHP_FUNCTION(birdstep_close)
{
- long id;
+ zend_long id;
VConn *conn;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) {
@@ -346,7 +346,7 @@ PHP_FUNCTION(birdstep_close)
PHP_FUNCTION(birdstep_exec)
{
char *query;
- long ind;
+ zend_long ind;
int query_len, indx;
VConn *conn;
Vresult *res;
@@ -426,7 +426,7 @@ PHP_FUNCTION(birdstep_exec)
*/
PHP_FUNCTION(birdstep_fetch)
{
- long ind;
+ zend_long ind;
Vresult *res;
RETCODE stat;
UDWORD row;
@@ -460,7 +460,7 @@ PHP_FUNCTION(birdstep_fetch)
PHP_FUNCTION(birdstep_result)
{
zval **col;
- long ind;
+ zend_long ind;
Vresult *res;
RETCODE stat;
int i,sql_c_type;
@@ -478,7 +478,7 @@ PHP_FUNCTION(birdstep_result)
if ( Z_TYPE_PP(col) == IS_STRING ) {
field = Z_STRVAL_PP(col);
} else {
- convert_to_long_ex(col);
+ convert_to_int_ex(col);
indx = Z_LVAL_PP(col);
}
if ( field ) {
@@ -553,7 +553,7 @@ l1:
*/
PHP_FUNCTION(birdstep_freeresult)
{
- long ind;
+ zend_long ind;
Vresult *res;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ind) == FAILURE) {
@@ -572,7 +572,7 @@ PHP_FUNCTION(birdstep_freeresult)
*/
PHP_FUNCTION(birdstep_autocommit)
{
- long id;
+ zend_long id;
RETCODE stat;
VConn *conn;
@@ -595,7 +595,7 @@ PHP_FUNCTION(birdstep_autocommit)
*/
PHP_FUNCTION(birdstep_off_autocommit)
{
- long id;
+ zend_long id;
RETCODE stat;
VConn *conn;
@@ -618,7 +618,7 @@ PHP_FUNCTION(birdstep_off_autocommit)
*/
PHP_FUNCTION(birdstep_commit)
{
- long id;
+zend_long
RETCODE stat;
VConn *conn;
@@ -641,7 +641,7 @@ PHP_FUNCTION(birdstep_commit)
*/
PHP_FUNCTION(birdstep_rollback)
{
- long id;
+ zend_long id;
RETCODE stat;
VConn *conn;
@@ -664,7 +664,7 @@ PHP_FUNCTION(birdstep_rollback)
*/
PHP_FUNCTION(birdstep_fieldname)
{
- long ind, col;
+ zend_long ind, col;
Vresult *res;
SWORD indx;
@@ -687,7 +687,7 @@ PHP_FUNCTION(birdstep_fieldname)
*/
PHP_FUNCTION(birdstep_fieldnum)
{
- long ind;
+ zend_long ind;
Vresult *res;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ind) == FAILURE) {
diff --git a/ext/odbc/php_birdstep.h b/ext/odbc/php_birdstep.h
index 90180d0641..eb694577fb 100644
--- a/ext/odbc/php_birdstep.h
+++ b/ext/odbc/php_birdstep.h
@@ -28,28 +28,28 @@
typedef struct VConn {
HDBC hdbc;
- long index;
+ zend_long index;
} VConn;
typedef struct {
char name[32];
char *value;
- long vallen;
+ zend_long vallen;
SDWORD valtype;
} VResVal;
typedef struct Vresult {
HSTMT hstmt;
VConn *conn;
- long index;
+ zend_long index;
VResVal *values;
- long numcols;
+ zend_long numcols;
int fetched;
} Vresult;
typedef struct {
- long num_links;
- long max_links;
+ zend_long num_links;
+ zend_long max_links;
int le_link,le_result;
} birdstep_module;
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 10384da2ad..0b873a0b33 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -841,9 +841,9 @@ PHP_MINFO_FUNCTION(odbc)
php_info_print_table_start();
php_info_print_table_header(2, "ODBC Support", "enabled");
- snprintf(buf, sizeof(buf), "%ld", ODBCG(num_persistent));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ODBCG(num_persistent));
php_info_print_table_row(2, "Active Persistent Links", buf);
- snprintf(buf, sizeof(buf), "%ld", ODBCG(num_links));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ODBCG(num_links));
php_info_print_table_row(2, "Active Links", buf);
php_info_print_table_row(2, "ODBC library", PHP_ODBC_TYPE);
#ifndef PHP_WIN32
@@ -911,7 +911,7 @@ void php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
odbc_result *result;
zval *pv_res;
- long flag;
+ zend_long flag;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &pv_res, &flag) == FAILURE) {
return;
@@ -1061,7 +1061,7 @@ void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
SQLLEN len;
#endif
zval *pv_res;
- long pv_num;
+ zend_long pv_num;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &pv_res, &pv_num) == FAILURE) {
return;
@@ -1518,7 +1518,7 @@ PHP_FUNCTION(odbc_cursor)
PHP_FUNCTION(odbc_data_source)
{
zval *zv_conn;
- long zv_fetch_type;
+ zend_long zv_fetch_type;
RETCODE rc = 0; /* assume all is good */
odbc_connection *conn;
UCHAR server_name[100], desc[200];
@@ -1573,7 +1573,7 @@ PHP_FUNCTION(odbc_data_source)
PHP_FUNCTION(odbc_exec)
{
zval *pv_conn;
- long pv_flags;
+ zend_long pv_flags;
char *query;
int numArgs, query_len;
odbc_result *result = NULL;
@@ -1668,7 +1668,7 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
SQLUSMALLINT RowStatus[1];
SQLLEN rownum;
zval *pv_res, tmp;
- long pv_row = -1;
+ zend_long pv_row = -1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &pv_res, &pv_row) == FAILURE) {
return;
@@ -1815,7 +1815,7 @@ PHP_FUNCTION(odbc_fetch_into)
char *buf = NULL;
zval *pv_res, *pv_res_arr, tmp;
#ifdef HAVE_SQL_EXTENDED_FETCH
- long pv_row = 0;
+ zend_long pv_row = 0;
SQLULEN crow;
SQLUSMALLINT RowStatus[1];
SQLLEN rownum = -1;
@@ -1964,7 +1964,7 @@ PHP_FUNCTION(odbc_fetch_row)
odbc_result *result;
RETCODE rc;
zval *pv_res;
- long pv_row = 1;
+ zend_long pv_row = 1;
#ifdef HAVE_SQL_EXTENDED_FETCH
SQLULEN crow;
SQLUSMALLINT RowStatus[1];
@@ -2035,7 +2035,7 @@ PHP_FUNCTION(odbc_result)
if (Z_TYPE_P(pv_field) == IS_STRING) {
field = Z_STRVAL_P(pv_field);
} else {
- convert_to_long_ex(pv_field);
+ convert_to_int_ex(pv_field);
field_ind = Z_LVAL_P(pv_field) - 1;
}
@@ -2501,7 +2501,7 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
char *db, *uid, *pwd;
int db_len, uid_len, pwd_len;
- long pv_opt = SQL_CUR_DEFAULT;
+ zend_long pv_opt = SQL_CUR_DEFAULT;
odbc_connection *db_conn;
char *hashed_details;
int hashed_len, cur_opt;
@@ -2784,7 +2784,7 @@ PHP_FUNCTION(odbc_field_name)
{
odbc_result *result;
zval *pv_res;
- long pv_num;
+ zend_long pv_num;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &pv_res, &pv_num) == FAILURE) {
return;
@@ -2819,7 +2819,7 @@ PHP_FUNCTION(odbc_field_type)
char tmp[32];
SQLSMALLINT tmplen;
zval *pv_res;
- long pv_num;
+ zend_long pv_num;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &pv_res, &pv_num) == FAILURE) {
return;
@@ -2905,7 +2905,7 @@ PHP_FUNCTION(odbc_autocommit)
odbc_connection *conn;
RETCODE rc;
zval *pv_conn;
- long pv_onoff = 0;
+ zend_long pv_onoff = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &pv_conn, &pv_onoff) == FAILURE) {
return;
@@ -2969,14 +2969,14 @@ static void php_odbc_lasterror(INTERNAL_FUNCTION_PARAMETERS, int mode)
if (ZEND_NUM_ARGS() == 1) {
ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_handle, -1, "ODBC-Link", le_conn, le_pconn);
- ptr = STR_ALLOC(len + 1, 0);
+ ptr = zend_string_alloc(len + 1, 0);
if (mode == 0) {
strlcpy(ptr->val, conn->laststate, len+1);
} else {
strlcpy(ptr->val, conn->lasterrormsg, len+1);
}
} else {
- ptr = STR_ALLOC(len, 0);
+ ptr = zend_string_alloc(len, 0);
if (mode == 0) {
strlcpy(ptr->val, ODBCG(laststate), len+1);
} else {
@@ -3017,7 +3017,7 @@ PHP_FUNCTION(odbc_setoption)
odbc_result *result;
RETCODE rc;
zval *pv_handle;
- long pv_which, pv_opt, pv_val;
+ zend_long pv_which, pv_opt, pv_val;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlll", &pv_handle, &pv_which, &pv_opt, &pv_val) == FAILURE) {
return;
@@ -3344,7 +3344,7 @@ PHP_FUNCTION(odbc_foreignkeys)
PHP_FUNCTION(odbc_gettypeinfo)
{
zval *pv_conn;
- long pv_data_type = SQL_ALL_TYPES;
+ zend_long pv_data_type = SQL_ALL_TYPES;
odbc_result *result = NULL;
odbc_connection *conn;
RETCODE rc;
@@ -3597,7 +3597,7 @@ PHP_FUNCTION(odbc_procedures)
PHP_FUNCTION(odbc_specialcolumns)
{
zval *pv_conn;
- long vtype, vscope, vnullable;
+ zend_long vtype, vscope, vnullable;
odbc_result *result = NULL;
odbc_connection *conn;
char *cat = NULL, *schema = NULL, *name = NULL;
@@ -3605,7 +3605,7 @@ PHP_FUNCTION(odbc_specialcolumns)
SQLUSMALLINT type, scope, nullable;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rls!ssll", &pv_conn, &vtype, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rls!ssl", &pv_conn, &vtype, &cat, &cat_len, &schema, &schema_len,
&name, &name_len, &vscope, &vnullable) == FAILURE) {
return;
}
@@ -3667,7 +3667,7 @@ PHP_FUNCTION(odbc_specialcolumns)
PHP_FUNCTION(odbc_statistics)
{
zval *pv_conn;
- long vunique, vreserved;
+ zend_long vunique, vreserved;
odbc_result *result = NULL;
odbc_connection *conn;
char *cat = NULL, *schema, *name;
diff --git a/ext/odbc/php_odbc_includes.h b/ext/odbc/php_odbc_includes.h
index 8e9eec0f8f..f44b897b9b 100644
--- a/ext/odbc/php_odbc_includes.h
+++ b/ext/odbc/php_odbc_includes.h
@@ -161,7 +161,7 @@ PHP_FUNCTION(solid_fetch_prev);
#define ODBC_TYPE "Birdstep"
#define UNIX
/*
- * Extended Fetch in the Birdstep ODBC API is incapable of returning long varchar (memo) fields.
+ * Extended Fetch in the Birdstep ODBC API is incapable of returning zend_long varchar (memo) fields.
* So the following line has been commented-out to accommodate. - KNS
*
* #define HAVE_SQL_EXTENDED_FETCH 1
@@ -247,7 +247,7 @@ typedef struct odbc_result {
# if HAVE_SQL_EXTENDED_FETCH
int fetch_abs;
# endif
- long longreadlen;
+ zend_long longreadlen;
int binmode;
int fetched;
odbc_connection *conn_ptr;
@@ -257,16 +257,16 @@ ZEND_BEGIN_MODULE_GLOBALS(odbc)
char *defDB;
char *defUser;
char *defPW;
- long allow_persistent;
- long check_persistent;
- long max_persistent;
- long max_links;
- long num_persistent;
- long num_links;
+ zend_long allow_persistent;
+ zend_long check_persistent;
+ zend_long max_persistent;
+ zend_long max_links;
+ zend_long num_persistent;
+ zend_long num_links;
int defConn;
- long defaultlrl;
- long defaultbinmode;
- long default_cursortype;
+ zend_long defaultlrl;
+ zend_long defaultbinmode;
+ zend_long default_cursortype;
char laststate[6];
char lasterrormsg[SQL_MAX_MESSAGE_LENGTH];
HashTable *resource_list;
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index 32800a1399..0276397393 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -106,7 +106,7 @@ static int find_code_blocks(zend_op_array *op_array, zend_cfg *cfg, zend_optimiz
zend_op *opline;
zend_op *end = op_array->opcodes + op_array->last;
zend_code_block *blocks, *cur_block;
- zend_uint opno = 0;
+ uint32_t opno = 0;
memset(cfg, 0, sizeof(zend_cfg));
blocks = cfg->blocks = zend_arena_calloc(&ctx->arena, op_array->last + 2, sizeof(zend_code_block));
@@ -906,11 +906,11 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
old_len = Z_STRLEN(ZEND_OP1_LITERAL(last_op));
l = old_len + Z_STRLEN(ZEND_OP1_LITERAL(opline));
if (IS_INTERNED(Z_STR(ZEND_OP1_LITERAL(last_op)))) {
- zend_string *tmp = STR_ALLOC(l, 0);
+ zend_string *tmp = zend_string_alloc(l, 0);
memcpy(tmp->val, Z_STRVAL(ZEND_OP1_LITERAL(last_op)), old_len);
Z_STR(ZEND_OP1_LITERAL(last_op)) = tmp;
} else {
- Z_STR(ZEND_OP1_LITERAL(last_op)) = STR_REALLOC(Z_STR(ZEND_OP1_LITERAL(last_op)), l, 0);
+ Z_STR(ZEND_OP1_LITERAL(last_op)) = zend_string_realloc(Z_STR(ZEND_OP1_LITERAL(last_op)), l, 0);
}
Z_TYPE_INFO(ZEND_OP1_LITERAL(last_op)) = IS_STRING_EX;
memcpy(Z_STRVAL(ZEND_OP1_LITERAL(last_op)) + old_len, Z_STRVAL(ZEND_OP1_LITERAL(opline)), Z_STRLEN(ZEND_OP1_LITERAL(opline)));
@@ -950,16 +950,16 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
old_len = Z_STRLEN(ZEND_OP2_LITERAL(src));
l = old_len + Z_STRLEN(ZEND_OP2_LITERAL(opline));
if (IS_INTERNED(Z_STR(ZEND_OP2_LITERAL(src)))) {
- zend_string *tmp = STR_ALLOC(l, 0);
+ zend_string *tmp = zend_string_alloc(l, 0);
memcpy(tmp->val, Z_STRVAL(ZEND_OP2_LITERAL(src)), old_len);
Z_STR(ZEND_OP2_LITERAL(last_op)) = tmp;
} else {
- Z_STR(ZEND_OP2_LITERAL(src)) = STR_REALLOC(Z_STR(ZEND_OP2_LITERAL(src)), l, 0);
+ Z_STR(ZEND_OP2_LITERAL(src)) = zend_string_realloc(Z_STR(ZEND_OP2_LITERAL(src)), l, 0);
}
Z_TYPE_INFO(ZEND_OP2_LITERAL(last_op)) = IS_STRING_EX;
memcpy(Z_STRVAL(ZEND_OP2_LITERAL(src)) + old_len, Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline)));
Z_STRVAL(ZEND_OP2_LITERAL(src))[l] = '\0';
- STR_RELEASE(Z_STR(ZEND_OP2_LITERAL(opline)));
+ zend_string_release(Z_STR(ZEND_OP2_LITERAL(opline)));
Z_STR(ZEND_OP2_LITERAL(opline)) = zend_new_interned_string(Z_STR(ZEND_OP2_LITERAL(src)) TSRMLS_CC);
if (IS_INTERNED(Z_STR(ZEND_OP2_LITERAL(opline)))) {
Z_TYPE_FLAGS(ZEND_OP2_LITERAL(opline)) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE);
@@ -1264,8 +1264,8 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array)
op_array->opcodes = erealloc(new_opcodes, op_array->last * sizeof(zend_op));
/* adjust early binding list */
- if (op_array->early_binding != (zend_uint)-1) {
- zend_uint *opline_num = &op_array->early_binding;
+ if (op_array->early_binding != (uint32_t)-1) {
+ uint32_t *opline_num = &op_array->early_binding;
zend_op *end;
opline = op_array->opcodes;
@@ -1441,7 +1441,7 @@ static void zend_jmp_optimization(zend_code_block *block, zend_op_array *op_arra
if (block->op2_to) {
zend_uchar same_type = ZEND_OP1_TYPE(last_op);
- zend_uint same_var = VAR_NUM_EX(last_op->op1);
+ uint32_t same_var = VAR_NUM_EX(last_op->op1);
zend_op *target;
zend_op *target_end;
zend_code_block *target_block = block->op2_to;;
diff --git a/ext/opcache/Optimizer/compact_literals.c b/ext/opcache/Optimizer/compact_literals.c
index 551f439041..87cae3b12c 100644
--- a/ext/opcache/Optimizer/compact_literals.c
+++ b/ext/opcache/Optimizer/compact_literals.c
@@ -44,7 +44,7 @@
#define LITERAL_NUM_SLOTS(info) ((info & LITERAL_NUM_SLOTS_MASK) >> LITERAL_NUM_SLOTS_SHIFT)
typedef struct _literal_info {
- zend_uint flags; /* bitmask (see defines above) */
+ uint32_t flags; /* bitmask (see defines above) */
union {
int num; /* variable number or class name literal number */
} u;
@@ -71,9 +71,9 @@ static void optimizer_literal_obj_info(literal_info *info,
zend_uchar op_type,
znode_op op,
int constant,
- zend_uint kind,
- zend_uint slots,
- zend_uint related,
+ uint32_t kind,
+ uint32_t slots,
+ uint32_t related,
zend_op_array *op_array)
{
/* For now we merge only $this object properties and methods.
@@ -92,9 +92,9 @@ static void optimizer_literal_class_info(literal_info *info,
zend_uchar op_type,
znode_op op,
int constant,
- zend_uint kind,
- zend_uint slots,
- zend_uint related,
+ uint32_t kind,
+ uint32_t slots,
+ uint32_t related,
zend_op_array *op_array)
{
if (op_type == IS_CONST) {
@@ -378,20 +378,20 @@ static void optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_c
if (info[i].flags & LITERAL_MAY_MERGE) {
if (info[i].flags & LITERAL_EX_OBJ) {
int key_len = MAX_LENGTH_OF_LONG + sizeof("->") + Z_STRLEN(op_array->literals[i]);
- key = STR_ALLOC(key_len, 0);
+ key = zend_string_alloc(key_len, 0);
key->len = snprintf(key->val, key->len-1, "%d->%s", info[i].u.num, Z_STRVAL(op_array->literals[i]));
} else if (info[i].flags & LITERAL_EX_CLASS) {
int key_len;
zval *class_name = &op_array->literals[(info[i].u.num < i) ? map[info[i].u.num] : info[i].u.num];
key_len = Z_STRLEN_P(class_name) + sizeof("::") + Z_STRLEN(op_array->literals[i]);
- key = STR_ALLOC(key_len, 0);
+ key = zend_string_alloc(key_len, 0);
memcpy(key->val, Z_STRVAL_P(class_name), Z_STRLEN_P(class_name));
memcpy(key->val + Z_STRLEN_P(class_name), "::", sizeof("::") - 1);
memcpy(key->val + Z_STRLEN_P(class_name) + sizeof("::") - 1,
Z_STRVAL(op_array->literals[i]),
Z_STRLEN(op_array->literals[i]) + 1);
} else {
- key = STR_INIT(Z_STRVAL(op_array->literals[i]), Z_STRLEN(op_array->literals[i]), 0);
+ key = zend_string_init(Z_STRVAL(op_array->literals[i]), Z_STRLEN(op_array->literals[i]), 0);
}
key->h = zend_hash_func(key->val, key->len);
key->h += info[i].flags;
@@ -401,7 +401,7 @@ static void optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_c
Z_TYPE(op_array->literals[i]) == Z_TYPE(op_array->literals[Z_LVAL_P(pos)]) &&
info[i].flags == info[Z_LVAL_P(pos)].flags) {
- STR_RELEASE(key);
+ zend_string_release(key);
map[i] = Z_LVAL_P(pos);
zval_dtor(&op_array->literals[i]);
n = LITERAL_NUM_RELATED(info[i].flags);
@@ -415,7 +415,7 @@ static void optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_c
if (info[i].flags & LITERAL_MAY_MERGE) {
ZVAL_LONG(&zv, j);
zend_hash_add(&hash, key, &zv);
- STR_RELEASE(key);
+ zend_string_release(key);
}
if (i != j) {
op_array->literals[j] = op_array->literals[i];
diff --git a/ext/opcache/Optimizer/nop_removal.c b/ext/opcache/Optimizer/nop_removal.c
index 80da02ce32..2d695c0495 100644
--- a/ext/opcache/Optimizer/nop_removal.c
+++ b/ext/opcache/Optimizer/nop_removal.c
@@ -26,12 +26,12 @@
static void nop_removal(zend_op_array *op_array)
{
zend_op *end, *opline;
- zend_uint new_count, i, shift;
+ uint32_t new_count, i, shift;
int j;
- zend_uint *shiftlist;
+ uint32_t *shiftlist;
ALLOCA_FLAG(use_heap);
- shiftlist = (zend_uint *)DO_ALLOCA(sizeof(zend_uint) * op_array->last);
+ shiftlist = (uint32_t *)DO_ALLOCA(sizeof(uint32_t) * op_array->last);
i = new_count = shift = 0;
end = op_array->opcodes + op_array->last;
for (opline = op_array->opcodes; opline < end; opline++) {
@@ -120,13 +120,13 @@ static void nop_removal(zend_op_array *op_array)
}
/* update early binding list */
- if (op_array->early_binding != (zend_uint)-1) {
- zend_uint *opline_num = &op_array->early_binding;
+ if (op_array->early_binding != (uint32_t)-1) {
+ uint32_t *opline_num = &op_array->early_binding;
do {
*opline_num -= shiftlist[*opline_num];
opline_num = &ZEND_RESULT(&op_array->opcodes[*opline_num]).opline_num;
- } while (*opline_num != (zend_uint)-1);
+ } while (*opline_num != (uint32_t)-1);
}
}
FREE_ALLOCA(shiftlist);
diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c
index 84ef9c236b..50611126f8 100644
--- a/ext/opcache/Optimizer/pass1_5.c
+++ b/ext/opcache/Optimizer/pass1_5.c
@@ -60,7 +60,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
ZEND_OP2_TYPE(opline) == IS_CONST) {
/* binary operation with constant operands */
int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC) = get_binary_op(opline->opcode);
- zend_uint tv = ZEND_RESULT(opline).var; /* temporary variable */
+ uint32_t tv = ZEND_RESULT(opline).var; /* temporary variable */
zval result;
int er;
@@ -92,7 +92,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
opline->extended_value != IS_OBJECT &&
opline->extended_value != IS_RESOURCE) {
/* cast of constant operand */
- zend_uint tv = ZEND_RESULT(opline).var; /* temporary variable */
+ uint32_t tv = ZEND_RESULT(opline).var; /* temporary variable */
zval res;
res = ZEND_OP1_LITERAL(opline);
zval_copy_ctor(&res);
@@ -104,7 +104,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
convert_to_boolean(&res);
break;
case IS_LONG:
- convert_to_long(&res);
+ convert_to_int(&res);
break;
case IS_DOUBLE:
convert_to_double(&res);
@@ -135,7 +135,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
/* unary operation on constant operand */
unary_op_type unary_op = get_unary_op(opline->opcode);
zval result;
- zend_uint tv = ZEND_RESULT(opline).var; /* temporary variable */
+ uint32_t tv = ZEND_RESULT(opline).var; /* temporary variable */
int er;
er = EG(error_reporting);
@@ -183,7 +183,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
}
last_op = next_op;
final_length += (requires_conversion? 1 : Z_STRLEN(ZEND_OP2_LITERAL(opline)));
- str = STR_ALLOC(final_length, 0);
+ str = zend_string_alloc(final_length, 0);
ptr = str->val;
ptr[final_length] = '\0';
if (requires_conversion) { /* ZEND_ADD_CHAR */
@@ -195,7 +195,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
ptr++;
} else { /* ZEND_ADD_STRING */
memcpy(ptr, Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline)));
- STR_RELEASE(Z_STR(ZEND_OP2_LITERAL(opline)));
+ zend_string_release(Z_STR(ZEND_OP2_LITERAL(opline)));
Z_STR(ZEND_OP2_LITERAL(opline)) = str;
ptr += Z_STRLEN(ZEND_OP2_LITERAL(opline));
}
@@ -238,7 +238,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
fake_execute_data.func = (zend_function*)op_array;
EG(current_execute_data) = &fake_execute_data;
if ((offset = zend_get_constant_str("__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__") - 1 TSRMLS_CC)) != NULL) {
- zend_uint tv = ZEND_RESULT(opline).var;
+ uint32_t tv = ZEND_RESULT(opline).var;
literal_dtor(&ZEND_OP2_LITERAL(opline));
MAKE_NOP(opline);
@@ -252,7 +252,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
ZEND_OP2_TYPE(opline) == IS_CONST &&
Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) {
/* substitute persistent constants */
- zend_uint tv = ZEND_RESULT(opline).var;
+ uint32_t tv = ZEND_RESULT(opline).var;
zval c;
if (!zend_get_persistent_constant(Z_STR(ZEND_OP2_LITERAL(opline)), &c, 1 TSRMLS_CC)) {
@@ -300,7 +300,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
}
if (ce) {
- zend_uint tv = ZEND_RESULT(opline).var;
+ uint32_t tv = ZEND_RESULT(opline).var;
zval *c, t;
if ((c = zend_hash_find(&ce->constants_table,
@@ -480,7 +480,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
case ZEND_DEFINED:
{
zval c;
- zend_uint tv = ZEND_RESULT(opline).var;
+ uint32_t tv = ZEND_RESULT(opline).var;
if (!zend_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(opline)), &c, 0 TSRMLS_CC)) {
break;
}
diff --git a/ext/opcache/Optimizer/pass2.c b/ext/opcache/Optimizer/pass2.c
index 083a7b961b..374c6d2426 100644
--- a/ext/opcache/Optimizer/pass2.c
+++ b/ext/opcache/Optimizer/pass2.c
@@ -62,7 +62,7 @@ if (ZEND_OPTIMIZER_PASS_2 & OPTIMIZATION_LEVEL) {
case ZEND_SR:
if (ZEND_OP1_TYPE(opline) == IS_CONST) {
if (Z_TYPE(ZEND_OP1_LITERAL(opline)) != IS_LONG) {
- convert_to_long(&ZEND_OP1_LITERAL(opline));
+ convert_to_int(&ZEND_OP1_LITERAL(opline));
}
}
/* break missing *intentionally - the assign_op's may only optimize op2 */
@@ -75,7 +75,7 @@ if (ZEND_OPTIMIZER_PASS_2 & OPTIMIZATION_LEVEL) {
}
if (ZEND_OP2_TYPE(opline) == IS_CONST) {
if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_LONG) {
- convert_to_long(&ZEND_OP2_LITERAL(opline));
+ convert_to_int(&ZEND_OP2_LITERAL(opline));
}
}
break;
@@ -183,7 +183,7 @@ if (ZEND_OPTIMIZER_PASS_2 & OPTIMIZATION_LEVEL) {
if (ZEND_OP2_TYPE(opline) != IS_CONST) {
break;
}
- convert_to_long(&ZEND_OP2_LITERAL(opline));
+ convert_to_int(&ZEND_OP2_LITERAL(opline));
nest_levels = ZEND_OP2_LITERAL(opline).value.lval;
array_offset = ZEND_OP1(opline).opline_num;
diff --git a/ext/opcache/Optimizer/pass3.c b/ext/opcache/Optimizer/pass3.c
index 810eedb646..1444fa6d3d 100644
--- a/ext/opcache/Optimizer/pass3.c
+++ b/ext/opcache/Optimizer/pass3.c
@@ -48,13 +48,13 @@
if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) {
zend_op *opline;
zend_op *end = op_array->opcodes + op_array->last;
- zend_uint *jmp_hitlist;
+ uint32_t *jmp_hitlist;
int jmp_hitlist_count;
int i;
- zend_uint opline_num = 0;
+ uint32_t opline_num = 0;
ALLOCA_FLAG(use_heap);
- jmp_hitlist = (zend_uint *)DO_ALLOCA(sizeof(zend_uint)*op_array->last);
+ jmp_hitlist = (uint32_t *)DO_ALLOCA(sizeof(uint32_t)*op_array->last);
opline = op_array->opcodes;
while (opline < end) {
diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c
index b783c3777b..9f14bac614 100644
--- a/ext/opcache/Optimizer/zend_optimizer.c
+++ b/ext/opcache/Optimizer/zend_optimizer.c
@@ -61,7 +61,7 @@ static int zend_optimizer_get_collected_constant(HashTable *constants, zval *nam
static int zend_optimizer_lookup_cv(zend_op_array *op_array, zend_string* name)
{
int i = 0;
- ulong hash_value = STR_HASH_VAL(name);
+ zend_ulong hash_value = zend_string_hash_val(name);
while (i < op_array->last_var) {
if (op_array->vars[i] == name ||
@@ -75,7 +75,7 @@ static int zend_optimizer_lookup_cv(zend_op_array *op_array, zend_string* name)
i = op_array->last_var;
op_array->last_var++;
op_array->vars = erealloc(op_array->vars, op_array->last_var * sizeof(zend_string*));
- op_array->vars[i] = STR_DUP(name, 0);
+ op_array->vars[i] = zend_string_dup(name, 0);
/* all IS_TMP_VAR and IS_VAR variable numbers have to be adjusted */
{
@@ -153,15 +153,15 @@ static void update_op1_const(zend_op_array *op_array,
case ZEND_FETCH_CONSTANT:
case ZEND_DEFINED:
opline->op1.constant = zend_optimizer_add_literal(op_array, val TSRMLS_CC);
- STR_HASH_VAL(Z_STR(ZEND_OP1_LITERAL(opline)));
+ zend_string_hash_val(Z_STR(ZEND_OP1_LITERAL(opline)));
Z_CACHE_SLOT(op_array->literals[opline->op1.constant]) = op_array->last_cache_slot++;
zend_str_tolower(Z_STRVAL_P(val), Z_STRLEN_P(val));
zend_optimizer_add_literal(op_array, val TSRMLS_CC);
- STR_HASH_VAL(Z_STR(op_array->literals[opline->op1.constant+1]));
+ zend_string_hash_val(Z_STR(op_array->literals[opline->op1.constant+1]));
break;
default:
opline->op1.constant = zend_optimizer_add_literal(op_array, val TSRMLS_CC);
- STR_HASH_VAL(Z_STR(ZEND_OP1_LITERAL(opline)));
+ zend_string_hash_val(Z_STR(ZEND_OP1_LITERAL(opline)));
break;
}
} else {
@@ -178,13 +178,13 @@ static void update_op2_const(zend_op_array *op_array,
if (opline->opcode == ZEND_INIT_FCALL) {
zend_str_tolower(Z_STRVAL_P(val), Z_STRLEN_P(val));
opline->op2.constant = zend_optimizer_add_literal(op_array, val TSRMLS_CC);
- STR_HASH_VAL(Z_STR(ZEND_OP2_LITERAL(opline)));
+ zend_string_hash_val(Z_STR(ZEND_OP2_LITERAL(opline)));
Z_CACHE_SLOT(op_array->literals[opline->op2.constant]) = op_array->last_cache_slot++;
return;
}
opline->op2.constant = zend_optimizer_add_literal(op_array, val TSRMLS_CC);
if (Z_TYPE_P(val) == IS_STRING) {
- STR_HASH_VAL(Z_STR(ZEND_OP2_LITERAL(opline)));
+ zend_string_hash_val(Z_STR(ZEND_OP2_LITERAL(opline)));
switch (opline->opcode) {
case ZEND_FETCH_R:
case ZEND_FETCH_W:
@@ -202,13 +202,13 @@ static void update_op2_const(zend_op_array *op_array,
Z_CACHE_SLOT(op_array->literals[opline->op2.constant]) = op_array->last_cache_slot++;
zend_str_tolower(Z_STRVAL_P(val), Z_STRLEN_P(val));
zend_optimizer_add_literal(op_array, val TSRMLS_CC);
- STR_HASH_VAL(Z_STR(op_array->literals[opline->op2.constant+1]));
+ zend_string_hash_val(Z_STR(op_array->literals[opline->op2.constant+1]));
break;
case ZEND_INIT_METHOD_CALL:
case ZEND_INIT_STATIC_METHOD_CALL:
zend_str_tolower(Z_STRVAL_P(val), Z_STRLEN_P(val));
zend_optimizer_add_literal(op_array, val TSRMLS_CC);
- STR_HASH_VAL(Z_STR(op_array->literals[opline->op2.constant+1]));
+ zend_string_hash_val(Z_STR(op_array->literals[opline->op2.constant+1]));
/* break missing intentionally */
/*case ZEND_FETCH_CONSTANT:*/
case ZEND_ASSIGN_OBJ:
@@ -273,7 +273,7 @@ static void update_op2_const(zend_op_array *op_array,
case ZEND_FETCH_DIM_TMP_VAR:
check_numeric:
{
- ulong index;
+ zend_ulong index;
if (ZEND_HANDLE_NUMERIC(Z_STR_P(val), index)) {
zval_dtor(val);
@@ -290,7 +290,7 @@ check_numeric:
static int replace_var_by_const(zend_op_array *op_array,
zend_op *opline,
- zend_uint var,
+ uint32_t var,
zval *val TSRMLS_DC)
{
zend_op *end = op_array->opcodes + op_array->last;
@@ -344,7 +344,7 @@ static int replace_var_by_const(zend_op_array *op_array,
static void replace_tmp_by_const(zend_op_array *op_array,
zend_op *opline,
- zend_uint var,
+ uint32_t var,
zval *val
TSRMLS_DC)
{
diff --git a/ext/opcache/Optimizer/zend_optimizer_internal.h b/ext/opcache/Optimizer/zend_optimizer_internal.h
index b0ba12abc7..1ac883b561 100644
--- a/ext/opcache/Optimizer/zend_optimizer_internal.h
+++ b/ext/opcache/Optimizer/zend_optimizer_internal.h
@@ -25,7 +25,7 @@
#include "ZendAccelerator.h"
#define VAR_NUM(v) EX_VAR_TO_NUM(v)
-#define NUM_VAR(v) ((zend_uint)(zend_uintptr_t)EX_VAR_NUM_2(0, v))
+#define NUM_VAR(v) ((uint32_t)(zend_uintptr_t)EX_VAR_NUM_2(0, v))
#define INV_COND(op) ((op) == ZEND_JMPZ ? ZEND_JMPNZ : ZEND_JMPZ)
#define INV_EX_COND(op) ((op) == ZEND_JMPZ_EX ? ZEND_JMPNZ : ZEND_JMPZ)
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index ebd3844e38..85adb20b50 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -107,8 +107,8 @@ static void (*orig_chdir)(INTERNAL_FUNCTION_PARAMETERS) = NULL;
static ZEND_INI_MH((*orig_include_path_on_modify)) = NULL;
#ifdef ZEND_WIN32
-# define INCREMENT(v) InterlockedIncrement(&ZCSG(v))
-# define DECREMENT(v) InterlockedDecrement(&ZCSG(v))
+# define INCREMENT(v) InterlockedIncrement64(&ZCSG(v))
+# define DECREMENT(v) InterlockedDecrement64(&ZCSG(v))
# define LOCKVAL(v) (ZCSG(v))
#endif
@@ -299,7 +299,7 @@ zend_string *accel_new_interned_string(zend_string *str TSRMLS_DC)
{
/* for now interned strings are supported only for non-ZTS build */
#ifndef ZTS
- ulong h;
+ zend_ulong h;
uint nIndex;
uint idx;
Bucket *p;
@@ -309,7 +309,7 @@ zend_string *accel_new_interned_string(zend_string *str TSRMLS_DC)
return str;
}
- h = STR_HASH_VAL(str);
+ h = zend_string_hash_val(str);
nIndex = h & ZCSG(interned_strings).nTableMask;
/* check for existing interned string */
@@ -318,7 +318,7 @@ zend_string *accel_new_interned_string(zend_string *str TSRMLS_DC)
p = ZCSG(interned_strings).arData + idx;
if ((p->h == h) && (p->key->len == str->len)) {
if (!memcmp(p->key->val, str->val, str->len)) {
- STR_RELEASE(str);
+ zend_string_release(str);
return p->key;
}
}
@@ -354,7 +354,7 @@ zend_string *accel_new_interned_string(zend_string *str TSRMLS_DC)
ZVAL_STR(&p->val, p->key);
Z_NEXT(p->val) = ZCSG(interned_strings).arHash[nIndex];
ZCSG(interned_strings).arHash[nIndex] = idx;
- STR_RELEASE(str);
+ zend_string_release(str);
return p->key;
#else
return str;
@@ -374,7 +374,7 @@ static void accel_use_shm_interned_strings(TSRMLS_D)
char s[2];
s[0] = j;
s[1] = 0;
- CG(one_char_string)[j] = accel_new_interned_string(STR_INIT(s, 1, 0) TSRMLS_CC);
+ CG(one_char_string)[j] = accel_new_interned_string(zend_string_init(s, 1, 0) TSRMLS_CC);
}
/* function table hash keys */
@@ -632,7 +632,7 @@ static inline int accel_is_inactive(TSRMLS_D)
return FAILURE;
}
-static int zend_get_stream_timestamp(const char *filename, struct stat *statbuf TSRMLS_DC)
+static int zend_get_stream_timestamp(const char *filename, zend_stat_t *statbuf TSRMLS_DC)
{
php_stream_wrapper *wrapper;
php_stream_statbuf stream_statbuf;
@@ -715,7 +715,7 @@ static accel_time_t zend_get_file_handle_timestamp_win(zend_file_handle *file_ha
static accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_t *size TSRMLS_DC)
{
- struct stat statbuf;
+ zend_stat_t statbuf;
#ifdef ZEND_WIN32
accel_time_t res;
#endif
@@ -724,7 +724,7 @@ static accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle
!EG(current_execute_data) &&
file_handle->filename == SG(request_info).path_translated) {
- struct stat *tmpbuf = sapi_module.get_stat(TSRMLS_C);
+ zend_stat_t *tmpbuf = sapi_module.get_stat(TSRMLS_C);
if (tmpbuf) {
if (size) {
@@ -743,12 +743,12 @@ static accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle
switch (file_handle->type) {
case ZEND_HANDLE_FD:
- if (fstat(file_handle->handle.fd, &statbuf) == -1) {
+ if (zend_fstat(file_handle->handle.fd, &statbuf) == -1) {
return 0;
}
break;
case ZEND_HANDLE_FP:
- if (fstat(fileno(file_handle->handle.fp), &statbuf) == -1) {
+ if (zend_fstat(fileno(file_handle->handle.fp), &statbuf) == -1) {
if (zend_get_stream_timestamp(file_handle->filename, &statbuf TSRMLS_CC) != SUCCESS) {
return 0;
}
@@ -1268,8 +1268,8 @@ static void zend_accel_init_auto_globals(TSRMLS_D)
int i, ag_size = (sizeof(jit_auto_globals_info) / sizeof(jit_auto_globals_info[0]));
for (i = 0; i < ag_size ; i++) {
- jit_auto_globals_str[i] = STR_INIT(jit_auto_globals_info[i].name, jit_auto_globals_info[i].len, 1);
- STR_HASH_VAL(jit_auto_globals_str[i]);
+ jit_auto_globals_str[i] = zend_string_init(jit_auto_globals_info[i].name, jit_auto_globals_info[i].len, 1);
+ zend_string_hash_val(jit_auto_globals_str[i]);
jit_auto_globals_str[i] = accel_new_interned_string(jit_auto_globals_str[i] TSRMLS_CC);
}
}
@@ -1283,7 +1283,7 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han
zend_op_array *op_array;
int do_bailout = 0;
accel_time_t timestamp = 0;
- zend_uint orig_compiler_options = 0;
+ uint32_t orig_compiler_options = 0;
/* Try to open file */
if (file_handle->type == ZEND_HANDLE_FILENAME) {
@@ -1427,11 +1427,11 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han
}
if (file_handle->opened_path) {
- new_persistent_script->full_path = STR_INIT(file_handle->opened_path, strlen(file_handle->opened_path), 0);
+ new_persistent_script->full_path = zend_string_init(file_handle->opened_path, strlen(file_handle->opened_path), 0);
} else {
- new_persistent_script->full_path = STR_INIT(file_handle->filename, strlen(file_handle->filename), 0);
+ new_persistent_script->full_path = zend_string_init(file_handle->filename, strlen(file_handle->filename), 0);
}
- STR_HASH_VAL(new_persistent_script->full_path);
+ zend_string_hash_val(new_persistent_script->full_path);
/* Now persistent_script structure is ready in process memory */
return cache_script_in_shared_memory(new_persistent_script, key, key_length, from_shared_memory TSRMLS_CC);
@@ -1581,7 +1581,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T
/* If script was not found or invalidated by validate_timestamps */
if (!persistent_script) {
- zend_uint old_const_num = zend_hash_next_free_element(EG(zend_constants));
+ uint32_t old_const_num = zend_hash_next_free_element(EG(zend_constants));
zend_op_array *op_array;
/* Cache miss.. */
@@ -1608,7 +1608,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T
}
if (from_shared_memory) {
/* Delete immutable arrays moved into SHM */
- zend_uint new_const_num = zend_hash_next_free_element(EG(zend_constants));
+ uint32_t new_const_num = zend_hash_next_free_element(EG(zend_constants));
while (new_const_num > old_const_num) {
new_const_num--;
zend_hash_index_del(EG(zend_constants), new_const_num);
@@ -1620,8 +1620,8 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T
ZCSG(hits)++; /* TBFixed: may lose one hit */
persistent_script->dynamic_members.hits++; /* see above */
#else
- InterlockedIncrement(&ZCSG(hits));
- InterlockedIncrement(&persistent_script->dynamic_members.hits);
+ INCREMENT(hits);
+ InterlockedIncrement64(&persistent_script->dynamic_members.hits);
#endif
/* see bug #15471 (old BTS) */
@@ -2185,13 +2185,13 @@ static int zend_accel_init_shm(TSRMLS_D)
if (ZCG(accel_directives).interned_strings_buffer) {
ZCSG(interned_strings).nTableMask = ZCSG(interned_strings).nTableSize - 1;
ZCSG(interned_strings).arData = zend_shared_alloc(ZCSG(interned_strings).nTableSize * sizeof(Bucket));
- ZCSG(interned_strings).arHash = (zend_uint*)zend_shared_alloc(ZCSG(interned_strings).nTableSize * sizeof(zend_uint));
+ ZCSG(interned_strings).arHash = (uint32_t*)zend_shared_alloc(ZCSG(interned_strings).nTableSize * sizeof(uint32_t));
ZCSG(interned_strings_start) = zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * 1024));
if (!ZCSG(interned_strings).arData || !ZCSG(interned_strings_start)) {
zend_accel_error(ACCEL_LOG_FATAL, ACCELERATOR_PRODUCT_NAME " cannot allocate buffer for interned strings");
return FAILURE;
}
- memset(ZCSG(interned_strings).arHash, INVALID_IDX, ZCSG(interned_strings).nTableSize * sizeof(zend_uint));
+ memset(ZCSG(interned_strings).arHash, INVALID_IDX, ZCSG(interned_strings).nTableSize * sizeof(uint32_t));
ZCSG(interned_strings_end) = ZCSG(interned_strings_start) + (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024);
ZCSG(interned_strings_top) = ZCSG(interned_strings_start);
diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h
index 94c467e5fb..29b796698c 100644
--- a/ext/opcache/ZendAccelerator.h
+++ b/ext/opcache/ZendAccelerator.h
@@ -157,7 +157,7 @@ typedef struct _zend_persistent_script {
zend_op_array main_op_array;
HashTable function_table;
HashTable class_table;
- long compiler_halt_offset; /* position of __HALT_COMPILER or -1 */
+ zend_long compiler_halt_offset; /* position of __HALT_COMPILER or -1 */
int ping_auto_globals_mask; /* which autoglobals are used by the script */
accel_time_t timestamp; /* the script modification time */
zend_bool corrupted;
@@ -170,7 +170,11 @@ typedef struct _zend_persistent_script {
*/
struct zend_persistent_script_dynamic_members {
time_t last_used;
- ulong hits;
+#ifdef ZEND_WIN32
+ LONGLONG hits;
+#else
+ zend_ulong hits;
+#endif
unsigned int memory_consumption;
unsigned int checksum;
time_t revalidate;
@@ -178,12 +182,12 @@ typedef struct _zend_persistent_script {
} zend_persistent_script;
typedef struct _zend_accel_directives {
- long memory_consumption;
- long max_accelerated_files;
+ zend_long memory_consumption;
+ zend_long max_accelerated_files;
double max_wasted_percentage;
char *user_blacklist_filename;
- long consistency_checks;
- long force_restart_timeout;
+ zend_long consistency_checks;
+ zend_long force_restart_timeout;
zend_bool use_cwd;
zend_bool ignore_dups;
zend_bool validate_timestamps;
@@ -195,18 +199,18 @@ typedef struct _zend_accel_directives {
zend_bool file_override_enabled;
zend_bool inherited_hack;
zend_bool enable_cli;
- unsigned long revalidate_freq;
- unsigned long file_update_protection;
+ zend_ulong revalidate_freq;
+ zend_ulong file_update_protection;
char *error_log;
#ifdef ZEND_WIN32
char *mmap_base;
#endif
char *memory_model;
- long log_verbosity_level;
+ zend_long log_verbosity_level;
- long optimization_level;
- long max_file_size;
- long interned_strings_buffer;
+ zend_long optimization_level;
+ zend_long max_file_size;
+ zend_long interned_strings_buffer;
char *restrict_api;
} zend_accel_directives;
@@ -240,12 +244,12 @@ typedef struct _zend_accel_globals {
typedef struct _zend_accel_shared_globals {
/* Cache Data Structures */
- unsigned long hits;
- unsigned long misses;
- unsigned long blacklist_misses;
- unsigned long oom_restarts; /* number of restarts because of out of memory */
- unsigned long hash_restarts; /* number of restarts because of hash overflow */
- unsigned long manual_restarts; /* number of restarts scheduled by opcache_reset() */
+ zend_ulong hits;
+ zend_ulong misses;
+ zend_ulong blacklist_misses;
+ zend_ulong oom_restarts; /* number of restarts because of out of memory */
+ zend_ulong hash_restarts; /* number of restarts because of hash overflow */
+ zend_ulong manual_restarts; /* number of restarts scheduled by opcache_reset() */
zend_accel_hash hash; /* hash table for cached scripts */
zend_accel_hash include_paths; /* used "include_path" values */
@@ -258,8 +262,8 @@ typedef struct _zend_accel_shared_globals {
zend_accel_restart_reason restart_reason;
zend_bool cache_status_before_restart;
#ifdef ZEND_WIN32
- unsigned long mem_usage;
- unsigned long restart_in;
+ LONGLONG mem_usage;
+ LONGLONG restart_in;
#endif
zend_bool restart_in_progress;
time_t revalidate_at;
diff --git a/ext/opcache/zend_accelerator_debug.c b/ext/opcache/zend_accelerator_debug.c
index d0198dccb3..2a386b812b 100644
--- a/ext/opcache/zend_accelerator_debug.c
+++ b/ext/opcache/zend_accelerator_debug.c
@@ -57,7 +57,7 @@ void zend_accel_error(int type, const char *format, ...)
}
#ifdef ZTS
- fprintf(fLog, "%s (%lu): ", time_string, (unsigned long)tsrm_thread_id());
+ fprintf(fLog, "%s (" ZEND_ULONG_FMT "): ", time_string, (zend_ulong)tsrm_thread_id());
#else
fprintf(fLog, "%s (%d): ", time_string, getpid());
#endif
diff --git a/ext/opcache/zend_accelerator_hash.c b/ext/opcache/zend_accelerator_hash.c
index b75377d61b..671792239b 100644
--- a/ext/opcache/zend_accelerator_hash.c
+++ b/ext/opcache/zend_accelerator_hash.c
@@ -36,7 +36,7 @@ void zend_accel_hash_clean(zend_accel_hash *accel_hash)
memset(accel_hash->hash_table, 0, sizeof(zend_accel_hash_entry *)*accel_hash->max_num_entries);
}
-void zend_accel_hash_init(zend_accel_hash *accel_hash, zend_uint hash_size)
+void zend_accel_hash_init(zend_accel_hash *accel_hash, uint32_t hash_size)
{
uint i;
@@ -71,7 +71,7 @@ void zend_accel_hash_init(zend_accel_hash *accel_hash, zend_uint hash_size)
* Returns pointer the actual hash entry on success
* key needs to be already allocated as it is not copied
*/
-zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, char *key, zend_uint key_length, zend_bool indirect, void *data)
+zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, char *key, uint32_t key_length, zend_bool indirect, void *data)
{
zend_ulong hash_value;
zend_ulong index;
@@ -140,7 +140,7 @@ zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, char
/* Returns the data associated with key on success
* Returns NULL if data doesn't exist
*/
-void* zend_accel_hash_find(zend_accel_hash *accel_hash, char *key, zend_uint key_length)
+void* zend_accel_hash_find(zend_accel_hash *accel_hash, char *key, uint32_t key_length)
{
zend_ulong hash_value;
zend_ulong index;
@@ -168,7 +168,7 @@ void* zend_accel_hash_find(zend_accel_hash *accel_hash, char *key, zend_uint key
/* Returns the hash entry associated with key on success
* Returns NULL if it doesn't exist
*/
-zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, char *key, zend_uint key_length)
+zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, char *key, uint32_t key_length)
{
zend_ulong hash_value;
zend_ulong index;
@@ -193,9 +193,9 @@ zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, c
return NULL;
}
-int zend_accel_hash_unlink(zend_accel_hash *accel_hash, char *key, zend_uint key_length)
+int zend_accel_hash_unlink(zend_accel_hash *accel_hash, char *key, uint32_t key_length)
{
- zend_ulong hash_value;
+ zend_ulong hash_value;
zend_ulong index;
zend_accel_hash_entry *entry, *last_entry=NULL;
diff --git a/ext/opcache/zend_accelerator_hash.h b/ext/opcache/zend_accelerator_hash.h
index 2de28bffa7..5c995b43ee 100644
--- a/ext/opcache/zend_accelerator_hash.h
+++ b/ext/opcache/zend_accelerator_hash.h
@@ -47,7 +47,7 @@ typedef struct _zend_accel_hash_entry zend_accel_hash_entry;
struct _zend_accel_hash_entry {
zend_ulong hash_value;
char *key;
- zend_uint key_length;
+ uint32_t key_length;
zend_accel_hash_entry *next;
void *data;
zend_bool indirect;
@@ -56,35 +56,35 @@ struct _zend_accel_hash_entry {
typedef struct _zend_accel_hash {
zend_accel_hash_entry **hash_table;
zend_accel_hash_entry *hash_entries;
- zend_uint num_entries;
- zend_uint max_num_entries;
- zend_uint num_direct_entries;
+ uint32_t num_entries;
+ uint32_t max_num_entries;
+ uint32_t num_direct_entries;
} zend_accel_hash;
-void zend_accel_hash_init(zend_accel_hash *accel_hash, zend_uint hash_size);
+void zend_accel_hash_init(zend_accel_hash *accel_hash, uint32_t hash_size);
void zend_accel_hash_clean(zend_accel_hash *accel_hash);
zend_accel_hash_entry* zend_accel_hash_update(
zend_accel_hash *accel_hash,
char *key,
- zend_uint key_length,
+ uint32_t key_length,
zend_bool indirect,
void *data);
void* zend_accel_hash_find(
zend_accel_hash *accel_hash,
char *key,
- zend_uint key_length);
+ uint32_t key_length);
zend_accel_hash_entry* zend_accel_hash_find_entry(
zend_accel_hash *accel_hash,
char *key,
- zend_uint key_length);
+ uint32_t key_length);
int zend_accel_hash_unlink(
zend_accel_hash *accel_hash,
char *key,
- zend_uint key_length);
+ uint32_t key_length);
static inline zend_bool zend_accel_hash_is_full(zend_accel_hash *accel_hash)
{
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index ff8ace863b..86411af7be 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -100,8 +100,8 @@ static int validate_api_restriction(TSRMLS_D)
static ZEND_INI_MH(OnUpdateMemoryConsumption)
{
- long *p;
- long memsize;
+ zend_long *p;
+ zend_long memsize;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
@@ -111,7 +111,7 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
/* keep the compiler happy */
(void)entry; (void)new_value_length; (void)mh_arg2; (void)mh_arg3; (void)stage;
- p = (long *) (base + (size_t)mh_arg1);
+ p = (zend_long *) (base + (size_t)mh_arg1);
memsize = atoi(new_value);
/* sanity check we must use at least 8 MB */
if (memsize < 8) {
@@ -137,8 +137,8 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
{
- long *p;
- long size;
+ zend_long *p;
+ zend_long size;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
@@ -148,7 +148,7 @@ static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
/* keep the compiler happy */
(void)entry; (void)new_value_length; (void)mh_arg2; (void)mh_arg3; (void)stage;
- p = (long *) (base + (size_t)mh_arg1);
+ p = (zend_long *) (base + (size_t)mh_arg1);
size = atoi(new_value);
/* sanity check we must use a value between MIN_ACCEL_FILES and MAX_ACCEL_FILES */
@@ -183,7 +183,7 @@ static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
static ZEND_INI_MH(OnUpdateMaxWastedPercentage)
{
double *p;
- long percentage;
+ zend_long percentage;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
@@ -407,33 +407,33 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
char buf[32];
php_info_print_table_row(2, "Startup", "OK");
php_info_print_table_row(2, "Shared memory model", zend_accel_get_shared_model());
- snprintf(buf, sizeof(buf), "%ld", ZCSG(hits));
+ snprintf(buf, sizeof(buf), "%pd", (zend_ulong)ZCSG(hits));
php_info_print_table_row(2, "Cache hits", buf);
- snprintf(buf, sizeof(buf), "%ld", ZSMMG(memory_exhausted)?ZCSG(misses):ZCSG(misses)-ZCSG(blacklist_misses));
+ snprintf(buf, sizeof(buf), "%pd", ZSMMG(memory_exhausted)?ZCSG(misses):ZCSG(misses)-ZCSG(blacklist_misses));
php_info_print_table_row(2, "Cache misses", buf);
- snprintf(buf, sizeof(buf), "%ld", ZCG(accel_directives).memory_consumption-zend_shared_alloc_get_free_memory()-ZSMMG(wasted_shared_memory));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCG(accel_directives).memory_consumption-zend_shared_alloc_get_free_memory()-ZSMMG(wasted_shared_memory));
php_info_print_table_row(2, "Used memory", buf);
- snprintf(buf, sizeof(buf), "%ld", zend_shared_alloc_get_free_memory());
+ snprintf(buf, sizeof(buf), "%pd", zend_shared_alloc_get_free_memory());
php_info_print_table_row(2, "Free memory", buf);
- snprintf(buf, sizeof(buf), "%ld", ZSMMG(wasted_shared_memory));
+ snprintf(buf, sizeof(buf), "%pd", ZSMMG(wasted_shared_memory));
php_info_print_table_row(2, "Wasted memory", buf);
if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) && ZCSG(interned_strings_top)) {
- snprintf(buf, sizeof(buf), "%ld", ZCSG(interned_strings_top) - ZCSG(interned_strings_start));
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(interned_strings_top) - ZCSG(interned_strings_start));
php_info_print_table_row(2, "Interned Strings Used memory", buf);
- snprintf(buf, sizeof(buf), "%ld", ZCSG(interned_strings_end) - ZCSG(interned_strings_top));
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(interned_strings_end) - ZCSG(interned_strings_top));
php_info_print_table_row(2, "Interned Strings Free memory", buf);
}
snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).num_direct_entries);
php_info_print_table_row(2, "Cached scripts", buf);
snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).num_entries);
php_info_print_table_row(2, "Cached keys", buf);
- snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).max_num_entries);
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(hash).max_num_entries);
php_info_print_table_row(2, "Max keys", buf);
- snprintf(buf, sizeof(buf), "%ld", ZCSG(oom_restarts));
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(oom_restarts));
php_info_print_table_row(2, "OOM restarts", buf);
- snprintf(buf, sizeof(buf), "%ld", ZCSG(hash_restarts));
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(hash_restarts));
php_info_print_table_row(2, "Hash keys restarts", buf);
- snprintf(buf, sizeof(buf), "%ld", ZCSG(manual_restarts));
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(manual_restarts));
php_info_print_table_row(2, "Manual restarts", buf);
}
}
@@ -487,8 +487,8 @@ static int accelerator_get_scripts(zval *return_value TSRMLS_DC)
script = (zend_persistent_script *)cache_entry->data;
array_init(&persistent_script_report);
- add_assoc_str(&persistent_script_report, "full_path", STR_DUP(script->full_path, 0));
- add_assoc_long(&persistent_script_report, "hits", script->dynamic_members.hits);
+ add_assoc_str(&persistent_script_report, "full_path", zend_string_dup(script->full_path, 0));
+ add_assoc_long(&persistent_script_report, "hits", (zend_long)script->dynamic_members.hits);
add_assoc_long(&persistent_script_report, "memory_consumption", script->dynamic_members.memory_consumption);
ta = localtime(&script->dynamic_members.last_used);
str = asctime(ta);
@@ -497,7 +497,7 @@ static int accelerator_get_scripts(zval *return_value TSRMLS_DC)
add_assoc_stringl(&persistent_script_report, "last_used", str, len);
add_assoc_long(&persistent_script_report, "last_used_timestamp", script->dynamic_members.last_used);
if (ZCG(accel_directives).validate_timestamps) {
- add_assoc_long(&persistent_script_report, "timestamp", (long)script->timestamp);
+ add_assoc_long(&persistent_script_report, "timestamp", (zend_long)script->timestamp);
}
timerclear(&exec_time);
timerclear(&fetch_time);
@@ -514,7 +514,7 @@ static int accelerator_get_scripts(zval *return_value TSRMLS_DC)
Obtain statistics information regarding code acceleration */
static ZEND_FUNCTION(opcache_get_status)
{
- long reqs;
+ zend_long reqs;
zval memory_usage, statistics, scripts;
zend_bool fetch_scripts = 1;
@@ -562,7 +562,7 @@ static ZEND_FUNCTION(opcache_get_status)
add_assoc_long(&statistics, "num_cached_scripts", ZCSG(hash).num_direct_entries);
add_assoc_long(&statistics, "num_cached_keys", ZCSG(hash).num_entries);
add_assoc_long(&statistics, "max_cached_keys", ZCSG(hash).max_num_entries);
- add_assoc_long(&statistics, "hits", ZCSG(hits));
+ add_assoc_long(&statistics, "hits", (zend_long)ZCSG(hits));
add_assoc_long(&statistics, "start_time", ZCSG(start_time));
add_assoc_long(&statistics, "last_restart_time", ZCSG(last_restart_time));
add_assoc_long(&statistics, "oom_restarts", ZCSG(oom_restarts));
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index 0639e353cd..e9bb7a15e9 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -27,21 +27,21 @@
#define ZEND_PROTECTED_REFCOUNT (1<<30)
-static zend_uint zend_accel_refcount = ZEND_PROTECTED_REFCOUNT;
+static uint32_t zend_accel_refcount = ZEND_PROTECTED_REFCOUNT;
-#if SIZEOF_SIZE_T <= SIZEOF_LONG
+#if SIZEOF_SIZE_T <= SIZEOF_ZEND_INT
/* If sizeof(void*) == sizeof(ulong) we can use zend_hash index functions */
-# define accel_xlat_set(old, new) zend_hash_index_update_ptr(&ZCG(bind_hash), (ulong)(zend_uintptr_t)(old), (new))
-# define accel_xlat_get(old) zend_hash_index_find_ptr(&ZCG(bind_hash), (ulong)(zend_uintptr_t)(old))
+# define accel_xlat_set(old, new) zend_hash_index_update_ptr(&ZCG(bind_hash), (zend_ulong)(zend_uintptr_t)(old), (new))
+# define accel_xlat_get(old) zend_hash_index_find_ptr(&ZCG(bind_hash), (zend_ulong)(zend_uintptr_t)(old))
#else
-# define accel_xlat_set(old, new) (zend_hash_str_add_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (ulong)(zend_uintptr_t)(old), (void**)&(new))
-# define accel_xlat_get(old, new) ((new) = zend_hash_str_find_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (ulong)(zend_uintptr_t)(old), (void**)&(new)))
+# define accel_xlat_set(old, new) (zend_hash_str_add_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (zend_ulong)(zend_uintptr_t)(old), (void**)&(new))
+# define accel_xlat_get(old, new) ((new) = zend_hash_str_find_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (zend_ulong)(zend_uintptr_t)(old), (void**)&(new)))
#endif
typedef int (*id_function_t)(void *, void *);
typedef void (*unique_copy_ctor_func_t)(void *pElement);
-static const zend_uint uninitialized_bucket = {INVALID_IDX};
+static const uint32_t uninitialized_bucket = {INVALID_IDX};
static int zend_prepare_function_for_execution(zend_op_array *op_array);
static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind);
@@ -113,7 +113,7 @@ static int compact_hash_table(HashTable *ht)
return 1;
}
- d = (Bucket *)pemalloc(nSize * (sizeof(Bucket) + sizeof(zend_uint)), ht->u.flags & HASH_FLAG_PERSISTENT);
+ d = (Bucket *)pemalloc(nSize * (sizeof(Bucket) + sizeof(uint32_t)), ht->u.flags & HASH_FLAG_PERSISTENT);
if (!d) {
return 0;
}
@@ -129,7 +129,7 @@ static int compact_hash_table(HashTable *ht)
pefree(ht->arData, ht->u.flags & HASH_FLAG_PERSISTENT);
ht->arData = d;
- ht->arHash = (zend_uint *)(d + nSize);
+ ht->arHash = (uint32_t *)(d + nSize);
ht->nTableSize = nSize;
ht->nTableMask = ht->nTableSize - 1;
zend_hash_rehash(ht);
@@ -220,9 +220,9 @@ static void zend_destroy_property_info(zval *zv)
{
zend_property_info *property_info = Z_PTR_P(zv);
- STR_RELEASE(property_info->name);
+ zend_string_release(property_info->name);
if (property_info->doc_comment) {
- STR_RELEASE(property_info->doc_comment);
+ zend_string_release(property_info->doc_comment);
}
}
@@ -232,14 +232,14 @@ static inline zend_string *zend_clone_str(zend_string *str TSRMLS_DC)
if (IS_INTERNED(str)) {
ret = str;
- } else if (STR_REFCOUNT(str) <= 1 || (ret = accel_xlat_get(str)) == NULL) {
- ret = STR_DUP(str, 0);
+ } else if (zend_string_refcount(str) <= 1 || (ret = accel_xlat_get(str)) == NULL) {
+ ret = zend_string_dup(str, 0);
GC_FLAGS(ret) = GC_FLAGS(str);
- if (STR_REFCOUNT(str) > 1) {
+ if (zend_string_refcount(str) > 1) {
accel_xlat_set(str, ret);
}
} else {
- STR_ADDREF(ret);
+ zend_string_addref(ret);
}
return ret;
}
@@ -305,7 +305,7 @@ static inline void zend_clone_zval(zval *src, int bind TSRMLS_DC)
static zend_ast *zend_ast_clone(zend_ast *ast TSRMLS_DC)
{
- zend_uint i;
+ uint32_t i;
if (ast->kind == ZEND_AST_ZVAL) {
zend_ast_zval *copy = emalloc(sizeof(zend_ast_zval));
@@ -330,7 +330,7 @@ static zend_ast *zend_ast_clone(zend_ast *ast TSRMLS_DC)
}
return (zend_ast *) copy;
} else {
- zend_uint children = zend_ast_get_num_children(ast);
+ uint32_t children = zend_ast_get_num_children(ast);
zend_ast *copy = emalloc(sizeof(zend_ast) + sizeof(zend_ast *) * (children - 1));
copy->kind = ast->kind;
copy->attr = ast->attr;
@@ -349,7 +349,7 @@ static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind)
{
uint idx;
Bucket *p, *q, *r;
- ulong nIndex;
+ zend_ulong nIndex;
TSRMLS_FETCH();
ht->nTableSize = source->nTableSize;
@@ -364,14 +364,14 @@ static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind)
ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX;
if (!ht->nTableMask) {
- ht->arHash = (zend_uint*)&uninitialized_bucket;
+ ht->arHash = (uint32_t*)&uninitialized_bucket;
return;
}
if (source->u.flags & HASH_FLAG_PACKED) {
ht->u.flags |= HASH_FLAG_PACKED;
ht->arData = (Bucket *) emalloc(ht->nTableSize * sizeof(Bucket));
- ht->arHash = (zend_uint*)&uninitialized_bucket;
+ ht->arHash = (uint32_t*)&uninitialized_bucket;
for (idx = 0; idx < source->nNumUsed; idx++) {
p = source->arData + idx;
@@ -395,9 +395,9 @@ static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind)
zend_clone_zval(&q->val, bind TSRMLS_CC);
}
} else {
- ht->arData = (Bucket *) emalloc(ht->nTableSize * (sizeof(Bucket) + sizeof(zend_uint)));
- ht->arHash = (zend_uint*)(ht->arData + ht->nTableSize);
- memset(ht->arHash, INVALID_IDX, sizeof(zend_uint) * ht->nTableSize);
+ ht->arData = (Bucket *) emalloc(ht->nTableSize * (sizeof(Bucket) + sizeof(uint32_t)));
+ ht->arHash = (uint32_t*)(ht->arData + ht->nTableSize);
+ memset(ht->arHash, INVALID_IDX, sizeof(uint32_t) * ht->nTableSize);
for (idx = 0; idx < source->nNumUsed; idx++) {
p = source->arData + idx;
@@ -428,7 +428,7 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class
{
uint idx;
Bucket *p, *q;
- ulong nIndex;
+ zend_ulong nIndex;
zend_class_entry *new_ce;
zend_function *new_prototype;
zend_op_array *new_entry;
@@ -443,14 +443,14 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class
ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX;
if (!ht->nTableMask) {
- ht->arHash = (zend_uint*)&uninitialized_bucket;
+ ht->arHash = (uint32_t*)&uninitialized_bucket;
return;
}
ZEND_ASSERT(!(source->u.flags & HASH_FLAG_PACKED));
- ht->arData = (Bucket *) emalloc(ht->nTableSize * (sizeof(Bucket) + sizeof(zend_uint)));
- ht->arHash = (zend_uint *)(ht->arData + ht->nTableSize);
- memset(ht->arHash, INVALID_IDX, sizeof(zend_uint) * ht->nTableSize);
+ ht->arData = (Bucket *) emalloc(ht->nTableSize * (sizeof(Bucket) + sizeof(uint32_t)));
+ ht->arHash = (uint32_t *)(ht->arData + ht->nTableSize);
+ memset(ht->arHash, INVALID_IDX, sizeof(uint32_t) * ht->nTableSize);
for (idx = 0; idx < source->nNumUsed; idx++) {
p = source->arData + idx;
@@ -506,7 +506,7 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
{
uint idx;
Bucket *p, *q;
- ulong nIndex;
+ zend_ulong nIndex;
zend_class_entry *new_ce;
zend_property_info *prop_info;
@@ -520,14 +520,14 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX;
if (!ht->nTableMask) {
- ht->arHash = (zend_uint*)&uninitialized_bucket;
+ ht->arHash = (uint32_t*)&uninitialized_bucket;
return;
}
ZEND_ASSERT(!(source->u.flags & HASH_FLAG_PACKED));
- ht->arData = (Bucket *) emalloc(ht->nTableSize * (sizeof(Bucket) + sizeof(zend_uint)));
- ht->arHash = (zend_uint*)(ht->arData + ht->nTableSize);
- memset(ht->arHash, INVALID_IDX, sizeof(zend_uint) * ht->nTableSize);
+ ht->arData = (Bucket *) emalloc(ht->nTableSize * (sizeof(Bucket) + sizeof(uint32_t)));
+ ht->arHash = (uint32_t*)(ht->arData + ht->nTableSize);
+ memset(ht->arHash, INVALID_IDX, sizeof(uint32_t) * ht->nTableSize);
for (idx = 0; idx < source->nNumUsed; idx++) {
p = source->arData + idx;
@@ -554,7 +554,7 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
prop_info->name = zend_clone_str(prop_info->name TSRMLS_CC);
if (prop_info->doc_comment) {
if (ZCG(accel_directives).load_comments) {
- prop_info->doc_comment = STR_DUP(prop_info->doc_comment, 0);
+ prop_info->doc_comment = zend_string_dup(prop_info->doc_comment, 0);
} else {
prop_info->doc_comment = NULL;
}
@@ -658,7 +658,7 @@ static void zend_class_copy_ctor(zend_class_entry **pce)
}
if (ZEND_CE_DOC_COMMENT(ce)) {
if (ZCG(accel_directives).load_comments) {
- ZEND_CE_DOC_COMMENT(ce) = STR_DUP(ZEND_CE_DOC_COMMENT(ce), 0);
+ ZEND_CE_DOC_COMMENT(ce) = zend_string_dup(ZEND_CE_DOC_COMMENT(ce), 0);
} else {
ZEND_CE_DOC_COMMENT(ce) = NULL;
}
@@ -901,7 +901,7 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
if (!zend_hash_exists(EG(zend_constants), name)) {
zend_register_long_constant(name->val, name->len, persistent_script->compiler_halt_offset, CONST_CS, 0 TSRMLS_CC);
}
- STR_RELEASE(name);
+ zend_string_release(name);
}
zend_hash_destroy(&ZCG(bind_hash));
@@ -914,7 +914,7 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
}
}
- if (op_array->early_binding != (zend_uint)-1) {
+ if (op_array->early_binding != (uint32_t)-1) {
zend_string *orig_compiled_filename = CG(compiled_filename);
CG(compiled_filename) = persistent_script->full_path;
zend_do_delayed_early_binding(op_array TSRMLS_CC);
diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c
index cbe7d4dcca..5e290745bd 100644
--- a/ext/opcache/zend_persist.c
+++ b/ext/opcache/zend_persist.c
@@ -36,19 +36,19 @@
#define zend_accel_store_string(str) do { \
zend_string *new_str = zend_shared_alloc_get_xlat_entry(str); \
if (new_str) { \
- STR_RELEASE(str); \
+ zend_string_release(str); \
str = new_str; \
} else { \
new_str = zend_accel_memdup((void*)str, _STR_HEADER_SIZE + (str)->len + 1); \
- STR_RELEASE(str); \
+ zend_string_release(str); \
str = new_str; \
- STR_HASH_VAL(str); \
+ zend_string_hash_val(str); \
GC_FLAGS(str) = IS_STR_INTERNED | IS_STR_PERMANENT; \
} \
} while (0)
#define zend_accel_memdup_string(str) do { \
str = zend_accel_memdup(str, _STR_HEADER_SIZE + (str)->len + 1); \
- STR_HASH_VAL(str); \
+ zend_string_hash_val(str); \
GC_FLAGS(str) = IS_STR_INTERNED | IS_STR_PERMANENT; \
} while (0)
#define zend_accel_store_interned_string(str) do { \
@@ -67,7 +67,7 @@ typedef void (*zend_persist_func_t)(zval* TSRMLS_DC);
static void zend_persist_zval(zval *z TSRMLS_DC);
static void zend_persist_zval_const(zval *z TSRMLS_DC);
-static const zend_uint uninitialized_bucket = {INVALID_IDX};
+static const uint32_t uninitialized_bucket = {INVALID_IDX};
static void zend_hash_persist(HashTable *ht, zend_persist_func_t pPersistElement TSRMLS_DC)
{
@@ -75,19 +75,19 @@ static void zend_hash_persist(HashTable *ht, zend_persist_func_t pPersistElement
Bucket *p;
if (!ht->nTableMask) {
- ht->arHash = (zend_uint*)&uninitialized_bucket;
+ ht->arHash = (uint32_t*)&uninitialized_bucket;
return;
}
if (ht->u.flags & HASH_FLAG_PACKED) {
zend_accel_store(ht->arData, sizeof(Bucket) * ht->nNumUsed);
- ht->arHash = (zend_uint*)&uninitialized_bucket;
+ ht->arHash = (uint32_t*)&uninitialized_bucket;
} else {
Bucket *d = (Bucket*)ZCG(mem);
- zend_uint *h = (zend_uint*)(d + ht->nNumUsed);
+ uint32_t *h = (uint32_t*)(d + ht->nNumUsed);
ZCG(mem) = (void*)(h + ht->nTableSize);
memcpy(d, ht->arData, sizeof(Bucket) * ht->nNumUsed);
- memcpy(h, ht->arHash, sizeof(zend_uint) * ht->nTableSize);
+ memcpy(h, ht->arHash, sizeof(uint32_t) * ht->nTableSize);
efree(ht->arData);
ht->arData = d;
ht->arHash = h;
@@ -112,19 +112,19 @@ static void zend_hash_persist_immutable(HashTable *ht TSRMLS_DC)
Bucket *p;
if (!ht->nTableMask) {
- ht->arHash = (zend_uint*)&uninitialized_bucket;
+ ht->arHash = (uint32_t*)&uninitialized_bucket;
return;
}
if (ht->u.flags & HASH_FLAG_PACKED) {
ht->arData = zend_accel_memdup(ht->arData, sizeof(Bucket) * ht->nNumUsed);
- ht->arHash = (zend_uint*)&uninitialized_bucket;
+ ht->arHash = (uint32_t*)&uninitialized_bucket;
} else {
Bucket *d = (Bucket*)ZCG(mem);
- zend_uint *h = (zend_uint*)(d + ht->nNumUsed);
+ uint32_t *h = (uint32_t*)(d + ht->nNumUsed);
ZCG(mem) = (void*)(h + ht->nTableSize);
memcpy(d, ht->arData, sizeof(Bucket) * ht->nNumUsed);
- memcpy(h, ht->arHash, sizeof(zend_uint) * ht->nTableSize);
+ memcpy(h, ht->arHash, sizeof(uint32_t) * ht->nTableSize);
ht->arData = d;
ht->arHash = h;
}
@@ -144,7 +144,7 @@ static void zend_hash_persist_immutable(HashTable *ht TSRMLS_DC)
static zend_ast *zend_persist_ast(zend_ast *ast TSRMLS_DC)
{
- zend_uint i;
+ uint32_t i;
zend_ast *node;
if (ast->kind == ZEND_AST_ZVAL) {
@@ -162,7 +162,7 @@ static zend_ast *zend_persist_ast(zend_ast *ast TSRMLS_DC)
}
node = (zend_ast *) copy;
} else {
- zend_uint children = zend_ast_get_num_children(ast);
+ uint32_t children = zend_ast_get_num_children(ast);
node = zend_accel_memdup(ast, sizeof(zend_ast) + sizeof(zend_ast *) * (children - 1));
for (i = 0; i < children; i++) {
if (node->child[i]) {
@@ -412,7 +412,7 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc
ZEND_ASSERT(new_ptr != NULL);
op_array->arg_info = new_ptr;
} else {
- zend_uint i;
+ uint32_t i;
zend_accel_store(op_array->arg_info, sizeof(zend_arg_info) * op_array->num_args);
for (i = 0; i < op_array->num_args; i++) {
@@ -446,7 +446,7 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc
}
} else {
if (!already_stored) {
- STR_RELEASE(op_array->doc_comment);
+ zend_string_release(op_array->doc_comment);
}
op_array->doc_comment = NULL;
}
@@ -501,7 +501,7 @@ static void zend_persist_property_info(zval *zv TSRMLS_DC)
if (!zend_shared_alloc_get_xlat_entry(prop->doc_comment)) {
zend_shared_alloc_register_xlat_entry(prop->doc_comment, prop->doc_comment);
}
- STR_RELEASE(prop->doc_comment);
+ zend_string_release(prop->doc_comment);
prop->doc_comment = NULL;
}
}
@@ -545,7 +545,7 @@ static void zend_persist_class_entry(zval *zv TSRMLS_DC)
} else {
if (!zend_shared_alloc_get_xlat_entry(ZEND_CE_DOC_COMMENT(ce))) {
zend_shared_alloc_register_xlat_entry(ZEND_CE_DOC_COMMENT(ce), ZEND_CE_DOC_COMMENT(ce));
- STR_RELEASE(ZEND_CE_DOC_COMMENT(ce));
+ zend_string_release(ZEND_CE_DOC_COMMENT(ce));
}
ZEND_CE_DOC_COMMENT(ce) = NULL;
}
diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c
index b1f90c9ff5..989195119c 100644
--- a/ext/opcache/zend_persist_calc.c
+++ b/ext/opcache/zend_persist_calc.c
@@ -38,7 +38,7 @@
zend_string *tmp = accel_new_interned_string(str TSRMLS_CC); \
if (tmp != (str)) { \
if (do_free) { \
- /*STR_RELEASE(str);*/ \
+ /*zend_string_release(str);*/ \
} \
(str) = tmp; \
} else { \
@@ -61,7 +61,7 @@ static uint zend_hash_persist_calc(HashTable *ht, uint (*pPersistElement)(zval *
if (ht->u.flags & HASH_FLAG_PACKED) {
ADD_SIZE(sizeof(Bucket) * ht->nNumUsed);
} else {
- ADD_SIZE(sizeof(Bucket) * ht->nNumUsed + sizeof(zend_uint) * ht->nTableSize);
+ ADD_SIZE(sizeof(Bucket) * ht->nNumUsed + sizeof(uint32_t) * ht->nTableSize);
}
for (idx = 0; idx < ht->nNumUsed; idx++) {
@@ -83,7 +83,7 @@ static uint zend_hash_persist_calc(HashTable *ht, uint (*pPersistElement)(zval *
static uint zend_persist_ast_calc(zend_ast *ast TSRMLS_DC)
{
- zend_uint i;
+ uint32_t i;
START_SIZE();
if (ast->kind == ZEND_AST_ZVAL) {
@@ -98,7 +98,7 @@ static uint zend_persist_ast_calc(zend_ast *ast TSRMLS_DC)
}
}
} else {
- zend_uint children = zend_ast_get_num_children(ast);
+ uint32_t children = zend_ast_get_num_children(ast);
ADD_SIZE(sizeof(zend_ast) + sizeof(zend_ast *) * (children - 1));
for (i = 0; i < children; i++) {
if (ast->child[i]) {
@@ -203,7 +203,7 @@ static uint zend_persist_op_array_calc_ex(zend_op_array *op_array TSRMLS_DC)
}
if (op_array->arg_info) {
- zend_uint i;
+ uint32_t i;
ADD_DUP_SIZE(op_array->arg_info, sizeof(zend_arg_info) * op_array->num_args);
for (i = 0; i < op_array->num_args; i++) {
diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c
index 0faabee8b2..981829f5b7 100644
--- a/ext/opcache/zend_shared_alloc.c
+++ b/ext/opcache/zend_shared_alloc.c
@@ -288,7 +288,7 @@ static size_t zend_shared_alloc_get_largest_free_block(void)
#define MIN_FREE_MEMORY 64*1024
#define SHARED_ALLOC_FAILED() do { \
- zend_accel_error(ACCEL_LOG_WARNING, "Not enough free shared space to allocate %ld bytes (%ld bytes free)", (long)size, (long)ZSMMG(shared_free)); \
+ zend_accel_error(ACCEL_LOG_WARNING, "Not enough free shared space to allocate %pd bytes (%pd bytes free)", (zend_long)size, (zend_long)ZSMMG(shared_free)); \
if (zend_shared_alloc_get_largest_free_block() < MIN_FREE_MEMORY) { \
ZSMMG(memory_exhausted) = 1; \
} \
@@ -327,7 +327,7 @@ int zend_shared_memdup_size(void *source, size_t size)
{
void *old_p;
- if ((old_p = zend_hash_index_find_ptr(&xlat_table, (ulong)source)) != NULL) {
+ if ((old_p = zend_hash_index_find_ptr(&xlat_table, (zend_ulong)source)) != NULL) {
/* we already duplicated this pointer */
return 0;
}
@@ -339,7 +339,7 @@ void *_zend_shared_memdup(void *source, size_t size, zend_bool free_source TSRML
{
void *old_p, *retval;
- if ((old_p = zend_hash_index_find_ptr(&xlat_table, (ulong)source)) != NULL) {
+ if ((old_p = zend_hash_index_find_ptr(&xlat_table, (zend_ulong)source)) != NULL) {
/* we already duplicated this pointer */
return old_p;
}
@@ -431,14 +431,14 @@ void zend_shared_alloc_clear_xlat_table(void)
void zend_shared_alloc_register_xlat_entry(const void *old, const void *new)
{
- zend_hash_index_update_ptr(&xlat_table, (ulong)old, (void*)new);
+ zend_hash_index_update_ptr(&xlat_table, (zend_ulong)old, (void*)new);
}
void *zend_shared_alloc_get_xlat_entry(const void *old)
{
void *retval;
- if ((retval = zend_hash_index_find_ptr(&xlat_table, (ulong)old)) == NULL) {
+ if ((retval = zend_hash_index_find_ptr(&xlat_table, (zend_ulong)old)) == NULL) {
return NULL;
}
return retval;
diff --git a/ext/opcache/zend_shared_alloc.h b/ext/opcache/zend_shared_alloc.h
index 57ea8d3fdd..ec7cc14d07 100644
--- a/ext/opcache/zend_shared_alloc.h
+++ b/ext/opcache/zend_shared_alloc.h
@@ -130,7 +130,7 @@ int zend_shared_memdup_size(void *p, size_t size);
typedef union _align_test {
void *ptr;
double dbl;
- long lng;
+ zend_long lng;
} align_test;
#if ZEND_GCC_VERSION >= 2000
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 1d75ff08fc..584b87d68e 100755
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -669,7 +669,7 @@ static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int s
add_next_index_stringl(data, (char *)to_add, to_add_len);
} else if (Z_TYPE_P(data) == IS_STRING) {
array_init(&tmp);
- add_next_index_str(&tmp, STR_COPY(Z_STR_P(data)));
+ add_next_index_str(&tmp, zend_string_copy(Z_STR_P(data)));
add_next_index_stringl(&tmp, (char *)to_add, to_add_len);
zend_hash_str_update(Z_ARRVAL(subitem), sname, strlen(sname), &tmp);
}
@@ -849,7 +849,7 @@ static int add_oid_section(struct php_x509_request * req TSRMLS_DC) /* {{{ */
else \
varname = defval
-static const EVP_CIPHER * php_openssl_get_evp_cipher_from_algo(long algo);
+static const EVP_CIPHER * php_openssl_get_evp_cipher_from_algo(zend_long algo);
int openssl_spki_cleanup(const char *src, char *dest);
@@ -906,7 +906,7 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
if (req->priv_key_encrypt && optional_args && (item = zend_hash_str_find(Z_ARRVAL_P(optional_args), "encrypt_key_cipher", sizeof("encrypt_key_cipher")-1)) != NULL
&& Z_TYPE_P(item) == IS_LONG) {
- long cipher_algo = Z_LVAL_P(item);
+ zend_long cipher_algo = Z_LVAL_P(item);
const EVP_CIPHER* cipher = php_openssl_get_evp_cipher_from_algo(cipher_algo);
if (cipher == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown cipher algorithm for private key.");
@@ -1012,7 +1012,7 @@ static int php_openssl_write_rand_file(const char * file, int egdsocket, int see
}
/* }}} */
-static EVP_MD * php_openssl_get_evp_md_from_algo(long algo) { /* {{{ */
+static EVP_MD * php_openssl_get_evp_md_from_algo(zend_long algo) { /* {{{ */
EVP_MD *mdtype;
switch (algo) {
@@ -1058,7 +1058,7 @@ static EVP_MD * php_openssl_get_evp_md_from_algo(long algo) { /* {{{ */
}
/* }}} */
-static const EVP_CIPHER * php_openssl_get_evp_cipher_from_algo(long algo) { /* {{{ */
+static const EVP_CIPHER * php_openssl_get_evp_cipher_from_algo(zend_long algo) { /* {{{ */
switch (algo) {
#ifndef OPENSSL_NO_RC2
case PHP_OPENSSL_CIPHER_RC2_40:
@@ -1453,7 +1453,7 @@ PHP_FUNCTION(openssl_spki_new)
zend_string * s = NULL;
zend_resource *keyresource = NULL;
const char *spkac = "SPKAC=";
- long algo = OPENSSL_ALGO_MD5;
+ zend_long algo = OPENSSL_ALGO_MD5;
zval *method = NULL;
zval * zpkey = NULL;
@@ -1513,7 +1513,7 @@ PHP_FUNCTION(openssl_spki_new)
goto cleanup;
}
- s = STR_ALLOC(strlen(spkac) + strlen(spkstr), 0);
+ s = zend_string_alloc(strlen(spkac) + strlen(spkstr), 0);
sprintf(s->val, "%s%s", spkac, spkstr);
s->len = strlen(s->val);
@@ -1537,7 +1537,7 @@ cleanup:
}
if (keyresource == NULL && s != NULL) {
- STR_RELEASE(s);
+ zend_string_release(s);
}
}
/* }}} */
@@ -1776,9 +1776,9 @@ zend_string* php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_b
}
if (raw) {
- ret = STR_INIT((char*)md, n, 0);
+ ret = zend_string_init((char*)md, n, 0);
} else {
- ret = STR_ALLOC(n * 2, 0);
+ ret = zend_string_alloc(n * 2, 0);
make_digest_ex(ret->val, md, n);
ret->val[n * 2] = '\0';
}
@@ -2137,7 +2137,7 @@ PHP_FUNCTION(openssl_x509_checkpurpose)
X509 * cert = NULL;
zend_resource *certresource = NULL;
STACK_OF(X509) * untrustedchain = NULL;
- long purpose;
+ zend_long purpose;
char * untrusted = NULL;
int untrusted_len = 0, ret;
@@ -2193,7 +2193,7 @@ static X509_STORE * setup_verify(zval * calist TSRMLS_DC)
X509_LOOKUP * dir_lookup, * file_lookup;
int ndirs = 0, nfiles = 0;
zval * item;
- struct stat sb;
+ zend_stat_t sb;
store = X509_STORE_new();
@@ -2881,8 +2881,8 @@ PHP_FUNCTION(openssl_csr_export)
PHP_FUNCTION(openssl_csr_sign)
{
zval * zcert = NULL, *zcsr, *zpkey, *args = NULL;
- long num_days;
- long serial = 0L;
+ zend_long num_days;
+ zend_long serial = Z_I(0);
X509 * cert = NULL, *new_cert = NULL;
X509_REQ * csr;
EVP_PKEY * key = NULL, *priv_key = NULL;
@@ -2949,6 +2949,7 @@ PHP_FUNCTION(openssl_csr_sign)
if (!X509_set_version(new_cert, 2))
goto cleanup;
+
ASN1_INTEGER_set(X509_get_serialNumber(new_cert), serial);
X509_set_subject_name(new_cert, X509_REQ_get_subject_name(csr));
@@ -3454,7 +3455,7 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey TSRMLS_DC)
#define OPENSSL_PKEY_GET_BN(_type, _name) do { \
if (pkey->pkey._type->_name != NULL) { \
int len = BN_num_bytes(pkey->pkey._type->_name); \
- zend_string *str = STR_ALLOC(len, 0); \
+ zend_string *str = zend_string_alloc(len, 0); \
BN_bn2bin(pkey->pkey._type->_name, (unsigned char*)str->val); \
str->val[len] = 0; \
add_assoc_str(&_type, #_name, str); \
@@ -3770,7 +3771,7 @@ PHP_FUNCTION(openssl_pkey_get_details)
BIO *out;
unsigned int pbio_len;
char *pbio;
- long ktype;
+ zend_long ktype;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &key) == FAILURE) {
return;
@@ -3867,7 +3868,7 @@ PHP_FUNCTION(openssl_pkey_get_details)
Generates a PKCS5 v2 PBKDF2 string, defaults to sha1 */
PHP_FUNCTION(openssl_pbkdf2)
{
- long key_length = 0, iterations = 0;
+ zend_long key_length = 0, iterations = 0;
char *password; int password_len;
char *salt; int salt_len;
char *method; int method_len = 0;
@@ -3898,13 +3899,13 @@ PHP_FUNCTION(openssl_pbkdf2)
RETURN_FALSE;
}
- out_buffer = STR_ALLOC(key_length, 0);
+ out_buffer = zend_string_alloc(key_length, 0);
if (PKCS5_PBKDF2_HMAC(password, password_len, (unsigned char *)salt, salt_len, iterations, digest, key_length, (unsigned char*)out_buffer->val) == 1) {
out_buffer->val[key_length] = 0;
RETURN_STR(out_buffer);
} else {
- STR_RELEASE(out_buffer);
+ zend_string_release(out_buffer);
RETURN_FALSE;
}
}
@@ -3924,7 +3925,7 @@ PHP_FUNCTION(openssl_pkcs7_verify)
STACK_OF(X509) *others = NULL;
PKCS7 * p7 = NULL;
BIO * in = NULL, * datain = NULL, * dataout = NULL;
- long flags = 0;
+ zend_long flags = 0;
char * filename; int filename_len;
char * extracerts = NULL; int extracerts_len = 0;
char * signersfilename = NULL; int signersfilename_len = 0;
@@ -4030,12 +4031,12 @@ PHP_FUNCTION(openssl_pkcs7_encrypt)
zval * zrecipcerts, * zheaders = NULL;
STACK_OF(X509) * recipcerts = NULL;
BIO * infile = NULL, * outfile = NULL;
- long flags = 0;
+ zend_long flags = 0;
PKCS7 * p7 = NULL;
zval * zcertval;
X509 * cert;
const EVP_CIPHER *cipher = NULL;
- long cipherid = PHP_OPENSSL_CIPHER_DEFAULT;
+ zend_long cipherid = PHP_OPENSSL_CIPHER_DEFAULT;
zend_string * strindex;
char * infilename = NULL; int infilename_len;
char * outfilename = NULL; int outfilename_len;
@@ -4156,7 +4157,7 @@ PHP_FUNCTION(openssl_pkcs7_sign)
zval * hval;
X509 * cert = NULL;
EVP_PKEY * privkey = NULL;
- long flags = PKCS7_DETACHED;
+ zend_long flags = PKCS7_DETACHED;
PKCS7 * p7 = NULL;
BIO * infile = NULL, * outfile = NULL;
STACK_OF(X509) *others = NULL;
@@ -4333,7 +4334,7 @@ PHP_FUNCTION(openssl_private_encrypt)
zend_resource *keyresource = NULL;
char * data;
int data_len;
- long padding = RSA_PKCS1_PADDING;
+ zend_long padding = RSA_PKCS1_PADDING;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/z|l", &data, &data_len, &crypted, &key, &padding) == FAILURE) {
return;
@@ -4348,7 +4349,7 @@ PHP_FUNCTION(openssl_private_encrypt)
}
cryptedlen = EVP_PKEY_size(pkey);
- cryptedbuf = STR_ALLOC(cryptedlen, 0);
+ cryptedbuf = zend_string_alloc(cryptedlen, 0);
switch (pkey->type) {
case EVP_PKEY_RSA:
@@ -4371,7 +4372,7 @@ PHP_FUNCTION(openssl_private_encrypt)
RETVAL_TRUE;
}
if (cryptedbuf) {
- STR_RELEASE(cryptedbuf);
+ zend_string_release(cryptedbuf);
}
if (keyresource == NULL) {
EVP_PKEY_free(pkey);
@@ -4389,7 +4390,7 @@ PHP_FUNCTION(openssl_private_decrypt)
zend_string *cryptedbuf = NULL;
unsigned char *crypttemp;
int successful = 0;
- long padding = RSA_PKCS1_PADDING;
+ zend_long padding = RSA_PKCS1_PADDING;
zend_resource *keyresource = NULL;
char * data;
int data_len;
@@ -4417,7 +4418,7 @@ PHP_FUNCTION(openssl_private_decrypt)
pkey->pkey.rsa,
padding);
if (cryptedlen != -1) {
- cryptedbuf = STR_ALLOC(cryptedlen, 0);
+ cryptedbuf = zend_string_alloc(cryptedlen, 0);
memcpy(cryptedbuf->val, crypttemp, cryptedlen);
successful = 1;
}
@@ -4440,7 +4441,7 @@ PHP_FUNCTION(openssl_private_decrypt)
EVP_PKEY_free(pkey);
}
if (cryptedbuf) {
- STR_RELEASE(cryptedbuf);
+ zend_string_release(cryptedbuf);
}
}
/* }}} */
@@ -4455,7 +4456,7 @@ PHP_FUNCTION(openssl_public_encrypt)
zend_string *cryptedbuf;
int successful = 0;
zend_resource *keyresource = NULL;
- long padding = RSA_PKCS1_PADDING;
+ zend_long padding = RSA_PKCS1_PADDING;
char * data;
int data_len;
@@ -4470,7 +4471,7 @@ PHP_FUNCTION(openssl_public_encrypt)
}
cryptedlen = EVP_PKEY_size(pkey);
- cryptedbuf = STR_ALLOC(cryptedlen, 0);
+ cryptedbuf = zend_string_alloc(cryptedlen, 0);
switch (pkey->type) {
case EVP_PKEY_RSA:
@@ -4497,7 +4498,7 @@ PHP_FUNCTION(openssl_public_encrypt)
EVP_PKEY_free(pkey);
}
if (cryptedbuf) {
- STR_RELEASE(cryptedbuf);
+ zend_string_release(cryptedbuf);
}
}
/* }}} */
@@ -4513,7 +4514,7 @@ PHP_FUNCTION(openssl_public_decrypt)
unsigned char *crypttemp;
int successful = 0;
zend_resource *keyresource = NULL;
- long padding = RSA_PKCS1_PADDING;
+ zend_long padding = RSA_PKCS1_PADDING;
char * data;
int data_len;
@@ -4540,7 +4541,7 @@ PHP_FUNCTION(openssl_public_decrypt)
pkey->pkey.rsa,
padding);
if (cryptedlen != -1) {
- cryptedbuf = STR_ALLOC(cryptedlen, 0);
+ cryptedbuf = zend_string_alloc(cryptedlen, 0);
memcpy(cryptedbuf->val, crypttemp, cryptedlen);
successful = 1;
}
@@ -4562,7 +4563,7 @@ PHP_FUNCTION(openssl_public_decrypt)
}
if (cryptedbuf) {
- STR_RELEASE(cryptedbuf);
+ zend_string_release(cryptedbuf);
}
if (keyresource == NULL) {
EVP_PKEY_free(pkey);
@@ -4603,7 +4604,7 @@ PHP_FUNCTION(openssl_sign)
int data_len;
EVP_MD_CTX md_ctx;
zval *method = NULL;
- long signature_algo = OPENSSL_ALGO_SHA1;
+ zend_long signature_algo = OPENSSL_ALGO_SHA1;
const EVP_MD *mdtype;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/z|z", &data, &data_len, &signature, &key, &method) == FAILURE) {
@@ -4632,7 +4633,7 @@ PHP_FUNCTION(openssl_sign)
}
siglen = EVP_PKEY_size(pkey);
- sigbuf = STR_ALLOC(siglen, 0);
+ sigbuf = zend_string_alloc(siglen, 0);
EVP_SignInit(&md_ctx, mdtype);
EVP_SignUpdate(&md_ctx, data, data_len);
@@ -4666,7 +4667,7 @@ PHP_FUNCTION(openssl_verify)
char * data; int data_len;
char * signature; int signature_len;
zval *method = NULL;
- long signature_algo = OPENSSL_ALGO_SHA1;
+ zend_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;
@@ -4789,7 +4790,7 @@ PHP_FUNCTION(openssl_seal)
if (len1 + len2 > 0) {
zval_dtor(sealdata);
buf[len1 + len2] = '\0';
- ZVAL_STR(sealdata, STR_INIT((char*)buf, len1 + len2, 0));
+ ZVAL_STR(sealdata, zend_string_init((char*)buf, len1 + len2, 0));
efree(buf);
zval_dtor(ekeys);
@@ -4878,7 +4879,7 @@ PHP_FUNCTION(openssl_open)
} else {
zval_dtor(opendata);
buf[len1 + len2] = '\0';
- ZVAL_STR(opendata, STR_INIT((char*)buf, len1 + len2, 0));
+ ZVAL_STR(opendata, zend_string_init((char*)buf, len1 + len2, 0));
efree(buf);
RETVAL_TRUE;
}
@@ -4961,7 +4962,7 @@ PHP_FUNCTION(openssl_digest)
}
siglen = EVP_MD_size(mdtype);
- sigbuf = STR_ALLOC(siglen, 0);
+ sigbuf = zend_string_alloc(siglen, 0);
EVP_DigestInit(&md_ctx, mdtype);
EVP_DigestUpdate(&md_ctx, (unsigned char *)data, data_len);
@@ -4972,15 +4973,15 @@ PHP_FUNCTION(openssl_digest)
RETVAL_STR(sigbuf);
} else {
int digest_str_len = siglen * 2;
- zend_string *digest_str = STR_ALLOC(digest_str_len, 0);
+ zend_string *digest_str = zend_string_alloc(digest_str_len, 0);
make_digest_ex(digest_str->val, (unsigned char*)sigbuf->val, siglen);
digest_str->val[digest_str_len] = '\0';
- STR_RELEASE(sigbuf);
+ zend_string_release(sigbuf);
RETVAL_STR(digest_str);
}
} else {
- STR_RELEASE(sigbuf);
+ zend_string_release(sigbuf);
RETVAL_FALSE;
}
}
@@ -5024,7 +5025,7 @@ static zend_bool php_openssl_validate_iv(char **piv, int *piv_len, int iv_requir
Encrypts given data with given method and key, returns raw or base64 encoded string */
PHP_FUNCTION(openssl_encrypt)
{
- long options = 0;
+ zend_long options = 0;
char *data, *method, *password, *iv = "";
int data_len, method_len, password_len, iv_len = 0, max_iv_len;
const EVP_CIPHER *cipher_type;
@@ -5059,7 +5060,7 @@ PHP_FUNCTION(openssl_encrypt)
free_iv = php_openssl_validate_iv(&iv, &iv_len, max_iv_len TSRMLS_CC);
outlen = data_len + EVP_CIPHER_block_size(cipher_type);
- outbuf = STR_ALLOC(outlen, 0);
+ outbuf = zend_string_alloc(outlen, 0);
EVP_EncryptInit(&cipher_ctx, cipher_type, NULL, NULL);
if (password_len > keylen) {
@@ -5083,11 +5084,11 @@ PHP_FUNCTION(openssl_encrypt)
zend_string *base64_str;
base64_str = php_base64_encode((unsigned char*)outbuf->val, outlen);
- STR_RELEASE(outbuf);
+ zend_string_release(outbuf);
RETVAL_STR(base64_str);
}
} else {
- STR_RELEASE(outbuf);
+ zend_string_release(outbuf);
RETVAL_FALSE;
}
if (key != (unsigned char*)password) {
@@ -5104,7 +5105,7 @@ PHP_FUNCTION(openssl_encrypt)
Takes raw or base64 encoded string and dectupt it using given method and key */
PHP_FUNCTION(openssl_decrypt)
{
- long options = 0;
+ zend_long options = 0;
char *data, *method, *password, *iv = "";
int data_len, method_len, password_len, iv_len = 0;
const EVP_CIPHER *cipher_type;
@@ -5152,7 +5153,7 @@ PHP_FUNCTION(openssl_decrypt)
free_iv = php_openssl_validate_iv(&iv, &iv_len, EVP_CIPHER_iv_length(cipher_type) TSRMLS_CC);
outlen = data_len + EVP_CIPHER_block_size(cipher_type);
- outbuf = STR_ALLOC(outlen, 0);
+ outbuf = zend_string_alloc(outlen, 0);
EVP_DecryptInit(&cipher_ctx, cipher_type, NULL, NULL);
if (password_len > keylen) {
@@ -5170,7 +5171,7 @@ PHP_FUNCTION(openssl_decrypt)
outbuf->len = outlen;
RETVAL_STR(outbuf);
} else {
- STR_RELEASE(outbuf);
+ zend_string_release(outbuf);
RETVAL_FALSE;
}
if (key != (unsigned char*)password) {
@@ -5180,7 +5181,7 @@ PHP_FUNCTION(openssl_decrypt)
efree(iv);
}
if (base64_str) {
- STR_RELEASE(base64_str);
+ zend_string_release(base64_str);
}
EVP_CIPHER_CTX_cleanup(&cipher_ctx);
}
@@ -5235,7 +5236,7 @@ PHP_FUNCTION(openssl_dh_compute_key)
pub = BN_bin2bn((unsigned char*)pub_str, pub_len, NULL);
- data = STR_ALLOC(DH_size(pkey->pkey.dh), 0);
+ data = zend_string_alloc(DH_size(pkey->pkey.dh), 0);
len = DH_compute_key((unsigned char*)data->val, pub, pkey->pkey.dh);
if (len >= 0) {
@@ -5243,7 +5244,7 @@ PHP_FUNCTION(openssl_dh_compute_key)
data->val[len] = 0;
RETVAL_STR(data);
} else {
- STR_RELEASE(data);
+ zend_string_release(data);
RETVAL_FALSE;
}
@@ -5255,7 +5256,7 @@ PHP_FUNCTION(openssl_dh_compute_key)
Returns a string of the length specified filled with random pseudo bytes */
PHP_FUNCTION(openssl_random_pseudo_bytes)
{
- long buffer_length;
+ zend_long buffer_length;
zend_string *buffer = NULL;
zval *zstrong_result_returned = NULL;
int strong_result = 0;
@@ -5273,13 +5274,13 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
ZVAL_BOOL(zstrong_result_returned, 0);
}
- buffer = STR_ALLOC(buffer_length, 0);
+ buffer = zend_string_alloc(buffer_length, 0);
#ifdef PHP_WIN32
strong_result = 1;
/* random/urandom equivalent on Windows */
if (php_win32_get_random_bytes((unsigned char*)buffer->val, (size_t) buffer_length) == FAILURE){
- STR_RELEASE(buffer);
+ zend_string_release(buffer);
if (zstrong_result_returned) {
ZVAL_BOOL(zstrong_result_returned, 0);
}
@@ -5287,7 +5288,7 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
}
#else
if ((strong_result = RAND_pseudo_bytes((unsigned char*)buffer->val, buffer_length)) < 0) {
- STR_RELEASE(buffer);
+ zend_string_release(buffer);
if (zstrong_result_returned) {
ZVAL_BOOL(zstrong_result_returned, 0);
}
diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c
index f706e0d5a2..b0f6d4deca 100644
--- a/ext/openssl/xp_ssl.c
+++ b/ext/openssl/xp_ssl.c
@@ -69,7 +69,7 @@
/* Simplify ssl context option retrieval */
#define GET_VER_OPT(name) (PHP_STREAM_CONTEXT(stream) && (val = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "ssl", name)) != NULL)
#define GET_VER_OPT_STRING(name, str) if (GET_VER_OPT(name)) { convert_to_string_ex(val); str = Z_STRVAL_P(val); }
-#define GET_VER_OPT_LONG(name, num) if (GET_VER_OPT(name)) { convert_to_long_ex(val); num = Z_LVAL_P(val); }
+#define GET_VER_OPT_LONG(name, num) if (GET_VER_OPT(name)) { convert_to_int_ex(val); num = Z_LVAL_P(val); }
/* Used for peer verification in windows */
#define PHP_X509_NAME_ENTRY_TO_UTF8(ne, i, out) ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(X509_NAME_get_entry(ne, i)))
@@ -89,9 +89,9 @@ typedef struct _php_openssl_sni_cert_t {
/* Provides leaky bucket handhsake renegotiation rate-limiting */
typedef struct _php_openssl_handshake_bucket_t {
- long prev_handshake;
- long limit;
- long window;
+ zend_long prev_handshake;
+ zend_long limit;
+ zend_long window;
float tokens;
unsigned should_close;
} php_openssl_handshake_bucket_t;
@@ -146,7 +146,7 @@ static int handle_ssl_error(php_stream *stream, int nr_bytes, zend_bool is_init
int err = SSL_get_error(sslsock->ssl_handle, nr_bytes);
char esbuf[512];
smart_str ebuf = {0};
- unsigned long ecode;
+ zend_ulong ecode;
int retry = 1;
switch(err) {
@@ -230,7 +230,7 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) /* {{{ */
SSL *ssl;
int err, depth, ret;
zval *val;
- unsigned long allowed_depth = OPENSSL_DEFAULT_STREAM_VERIFY_DEPTH;
+ zend_ulong allowed_depth = OPENSSL_DEFAULT_STREAM_VERIFY_DEPTH;
TSRMLS_FETCH();
@@ -254,7 +254,7 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) /* {{{ */
/* check the depth */
GET_VER_OPT_LONG("verify_depth", allowed_depth);
- if ((unsigned long)depth > allowed_depth) {
+ if ((zend_ulong)depth > allowed_depth) {
ret = 0;
X509_STORE_CTX_set_error(ctx, X509_V_ERR_CERT_CHAIN_TOO_LONG);
}
@@ -271,7 +271,7 @@ static int php_x509_fingerprint_cmp(X509 *peer, const char *method, const char *
fingerprint = php_openssl_x509_fingerprint(peer, method, 0 TSRMLS_CC);
if (fingerprint) {
result = strcmp(expected, fingerprint->val);
- STR_RELEASE(fingerprint);
+ zend_string_release(fingerprint);
}
return result;
@@ -531,7 +531,7 @@ static int win_cert_verify_callback(X509_STORE_CTX *x509_store_ctx, void *arg) /
php_stream *stream;
php_openssl_netstream_data_t *sslsock;
- zval **val;
+ zval *val;
zend_bool is_self_signed = 0;
TSRMLS_FETCH();
@@ -673,7 +673,7 @@ static int win_cert_verify_callback(X509_STORE_CTX *x509_store_ctx, void *arg) /
if (chain_policy_status.dwError != 0) {
/* The chain does not match the policy */
if (is_self_signed && chain_policy_status.dwError == CERT_E_UNTRUSTEDROOT
- && GET_VER_OPT("allow_self_signed") && zend_is_true(*val TSRMLS_CC)) {
+ && GET_VER_OPT("allow_self_signed") && zend_is_true(val TSRMLS_CC)) {
/* allow self-signed certs */
X509_STORE_CTX_set_error(x509_store_ctx, X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT);
} else {
@@ -880,7 +880,7 @@ static int set_local_cert(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{ */
}
/* }}} */
-static const SSL_METHOD *php_select_crypto_method(long method_value, int is_client TSRMLS_DC) /* {{{ */
+static const SSL_METHOD *php_select_crypto_method(zend_long method_value, int is_client TSRMLS_DC) /* {{{ */
{
if (method_value == STREAM_CRYPTO_METHOD_SSLv2) {
#ifndef OPENSSL_NO_SSL2
@@ -891,7 +891,13 @@ static const SSL_METHOD *php_select_crypto_method(long method_value, int is_clie
return NULL;
#endif
} else if (method_value == STREAM_CRYPTO_METHOD_SSLv3) {
+#ifndef OPENSSL_NO_SSL3
return is_client ? SSLv3_client_method() : SSLv3_server_method();
+#else
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
+ "SSLv3 support is not compiled into the OpenSSL library PHP is linked against");
+ return NULL;
+#endif
} else if (method_value == STREAM_CRYPTO_METHOD_TLSv1_0) {
return is_client ? TLSv1_client_method() : TLSv1_server_method();
} else if (method_value == STREAM_CRYPTO_METHOD_TLSv1_1) {
@@ -918,9 +924,9 @@ static const SSL_METHOD *php_select_crypto_method(long method_value, int is_clie
}
/* }}} */
-static long php_get_crypto_method_ctx_flags(long method_flags TSRMLS_DC) /* {{{ */
+static zend_long php_get_crypto_method_ctx_flags(zend_long method_flags TSRMLS_DC) /* {{{ */
{
- long ssl_ctx_options = SSL_OP_ALL;
+ zend_long ssl_ctx_options = SSL_OP_ALL;
#ifndef OPENSSL_NO_SSL2
if (!(method_flags & STREAM_CRYPTO_METHOD_SSLv2)) {
@@ -956,7 +962,7 @@ static void limit_handshake_reneg(const SSL *ssl) /* {{{ */
php_stream *stream;
php_openssl_netstream_data_t *sslsock;
struct timeval now;
- long elapsed_time;
+ zend_long elapsed_time;
stream = php_openssl_get_stream_from_ssl_handle(ssl);
sslsock = (php_openssl_netstream_data_t*)stream->abstract;
@@ -1025,14 +1031,14 @@ static void info_callback(const SSL *ssl, int where, int ret) /* {{{ */
static void init_server_reneg_limit(php_stream *stream, php_openssl_netstream_data_t *sslsock) /* {{{ */
{
zval *val;
- long limit = OPENSSL_DEFAULT_RENEG_LIMIT;
- long window = OPENSSL_DEFAULT_RENEG_WINDOW;
+ zend_long limit = OPENSSL_DEFAULT_RENEG_LIMIT;
+ zend_long window = OPENSSL_DEFAULT_RENEG_WINDOW;
if (PHP_STREAM_CONTEXT(stream) &&
NULL != (val = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream),
"ssl", "reneg_limit"))
) {
- convert_to_long(val);
+ convert_to_int(val);
limit = Z_LVAL_P(val);
}
@@ -1045,7 +1051,7 @@ static void init_server_reneg_limit(php_stream *stream, php_openssl_netstream_da
NULL != (val = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream),
"ssl", "reneg_window"))
) {
- convert_to_long(val);
+ convert_to_int(val);
window = Z_LVAL_P(val);
}
@@ -1255,7 +1261,7 @@ static int enable_server_sni(php_stream *stream, php_openssl_netstream_data_t *s
zval *val;
zval *current;
zend_string *key;
- ulong key_index;
+ zend_ulong key_index;
int i = 0;
char resolved_path_buff[MAXPATHLEN];
SSL_CTX *ctx;
@@ -2167,13 +2173,13 @@ php_stream_ops php_openssl_socket_ops = {
php_openssl_sockop_set_option,
};
-static long get_crypto_method(php_stream_context *ctx, long crypto_method)
+static zend_long get_crypto_method(php_stream_context *ctx, zend_long crypto_method)
{
zval *val;
if (ctx && (val = php_stream_context_get_option(ctx, "ssl", "crypto_method")) != NULL) {
- convert_to_long_ex(val);
- crypto_method = (long)Z_LVAL_P(val);
+ convert_to_int_ex(val);
+ crypto_method = (zend_long)Z_LVAL_P(val);
crypto_method |= STREAM_CRYPTO_IS_CLIENT;
}
@@ -2262,8 +2268,13 @@ php_stream *php_openssl_ssl_socket_factory(const char *proto, size_t protolen,
sslsock->method = STREAM_CRYPTO_METHOD_SSLv2_CLIENT;
#endif
} else if (strncmp(proto, "sslv3", protolen) == 0) {
+#ifdef OPENSSL_NO_SSL3
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSLv3 support is not compiled into the OpenSSL library PHP is linked against");
+ return NULL;
+#else
sslsock->enable_on_connect = 1;
sslsock->method = STREAM_CRYPTO_METHOD_SSLv3_CLIENT;
+#endif
} else if (strncmp(proto, "tls", protolen) == 0) {
sslsock->enable_on_connect = 1;
sslsock->method = get_crypto_method(context, STREAM_CRYPTO_METHOD_TLS_CLIENT);
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 448e34b5cc..7ead941de0 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -204,64 +204,64 @@ void php_register_signal_constants(INIT_FUNC_ARGS)
/* Wait Constants */
#ifdef WNOHANG
- REGISTER_LONG_CONSTANT("WNOHANG", (long) WNOHANG, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("WNOHANG", (zend_long) WNOHANG, CONST_CS | CONST_PERSISTENT);
#endif
#ifdef WUNTRACED
- REGISTER_LONG_CONSTANT("WUNTRACED", (long) WUNTRACED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("WUNTRACED", (zend_long) WUNTRACED, CONST_CS | CONST_PERSISTENT);
#endif
/* Signal Constants */
- REGISTER_LONG_CONSTANT("SIG_IGN", (long) SIG_IGN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIG_DFL", (long) SIG_DFL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIG_ERR", (long) SIG_ERR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGHUP", (long) SIGHUP, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGINT", (long) SIGINT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGQUIT", (long) SIGQUIT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGILL", (long) SIGILL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGTRAP", (long) SIGTRAP, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGABRT", (long) SIGABRT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIG_IGN", (zend_long) SIG_IGN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIG_DFL", (zend_long) SIG_DFL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIG_ERR", (zend_long) SIG_ERR, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGHUP", (zend_long) SIGHUP, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGINT", (zend_long) SIGINT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGQUIT", (zend_long) SIGQUIT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGILL", (zend_long) SIGILL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGTRAP", (zend_long) SIGTRAP, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGABRT", (zend_long) SIGABRT, CONST_CS | CONST_PERSISTENT);
#ifdef SIGIOT
- REGISTER_LONG_CONSTANT("SIGIOT", (long) SIGIOT, CONST_CS | CONST_PERSISTENT);
-#endif
- REGISTER_LONG_CONSTANT("SIGBUS", (long) SIGBUS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGFPE", (long) SIGFPE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGKILL", (long) SIGKILL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGUSR1", (long) SIGUSR1, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGSEGV", (long) SIGSEGV, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGUSR2", (long) SIGUSR2, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGPIPE", (long) SIGPIPE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGALRM", (long) SIGALRM, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGTERM", (long) SIGTERM, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGIOT", (zend_long) SIGIOT, CONST_CS | CONST_PERSISTENT);
+#endif
+ REGISTER_LONG_CONSTANT("SIGBUS", (zend_long) SIGBUS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGFPE", (zend_long) SIGFPE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGKILL", (zend_long) SIGKILL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGUSR1", (zend_long) SIGUSR1, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGSEGV", (zend_long) SIGSEGV, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGUSR2", (zend_long) SIGUSR2, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGPIPE", (zend_long) SIGPIPE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGALRM", (zend_long) SIGALRM, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGTERM", (zend_long) SIGTERM, CONST_CS | CONST_PERSISTENT);
#ifdef SIGSTKFLT
- REGISTER_LONG_CONSTANT("SIGSTKFLT",(long) SIGSTKFLT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGSTKFLT",(zend_long) SIGSTKFLT, CONST_CS | CONST_PERSISTENT);
#endif
#ifdef SIGCLD
- REGISTER_LONG_CONSTANT("SIGCLD", (long) SIGCLD, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGCLD", (zend_long) SIGCLD, CONST_CS | CONST_PERSISTENT);
#endif
#ifdef SIGCHLD
- REGISTER_LONG_CONSTANT("SIGCHLD", (long) SIGCHLD, CONST_CS | CONST_PERSISTENT);
-#endif
- REGISTER_LONG_CONSTANT("SIGCONT", (long) SIGCONT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGSTOP", (long) SIGSTOP, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGTSTP", (long) SIGTSTP, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGTTIN", (long) SIGTTIN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGTTOU", (long) SIGTTOU, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGURG", (long) SIGURG , CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGXCPU", (long) SIGXCPU, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGXFSZ", (long) SIGXFSZ, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGVTALRM",(long) SIGVTALRM, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGPROF", (long) SIGPROF, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGWINCH", (long) SIGWINCH, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGCHLD", (zend_long) SIGCHLD, CONST_CS | CONST_PERSISTENT);
+#endif
+ REGISTER_LONG_CONSTANT("SIGCONT", (zend_long) SIGCONT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGSTOP", (zend_long) SIGSTOP, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGTSTP", (zend_long) SIGTSTP, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGTTIN", (zend_long) SIGTTIN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGTTOU", (zend_long) SIGTTOU, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGURG", (zend_long) SIGURG , CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGXCPU", (zend_long) SIGXCPU, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGXFSZ", (zend_long) SIGXFSZ, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGVTALRM",(zend_long) SIGVTALRM, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGPROF", (zend_long) SIGPROF, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGWINCH", (zend_long) SIGWINCH, CONST_CS | CONST_PERSISTENT);
#ifdef SIGPOLL
- REGISTER_LONG_CONSTANT("SIGPOLL", (long) SIGPOLL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGPOLL", (zend_long) SIGPOLL, CONST_CS | CONST_PERSISTENT);
#endif
- REGISTER_LONG_CONSTANT("SIGIO", (long) SIGIO, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGIO", (zend_long) SIGIO, CONST_CS | CONST_PERSISTENT);
#ifdef SIGPWR
- REGISTER_LONG_CONSTANT("SIGPWR", (long) SIGPWR, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGPWR", (zend_long) SIGPWR, CONST_CS | CONST_PERSISTENT);
#endif
#ifdef SIGSYS
- REGISTER_LONG_CONSTANT("SIGSYS", (long) SIGSYS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("SIGBABY", (long) SIGSYS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGSYS", (zend_long) SIGSYS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SIGBABY", (zend_long) SIGSYS, CONST_CS | CONST_PERSISTENT);
#endif
#if HAVE_GETPRIORITY || HAVE_SETPRIORITY
@@ -556,12 +556,12 @@ PHP_FUNCTION(pcntl_fork)
Set an alarm clock for delivery of a signal*/
PHP_FUNCTION(pcntl_alarm)
{
- long seconds;
+ zend_long seconds;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &seconds) == FAILURE)
return;
- RETURN_LONG ((long) alarm(seconds));
+ RETURN_LONG ((zend_long) alarm(seconds));
}
/* }}} */
@@ -569,7 +569,7 @@ PHP_FUNCTION(pcntl_alarm)
Waits on or returns the status of a forked child as defined by the waitpid() system call */
PHP_FUNCTION(pcntl_waitpid)
{
- long pid, options = 0;
+ zend_long pid, options = 0;
zval *z_status = NULL;
int status;
pid_t child_id;
@@ -577,7 +577,7 @@ PHP_FUNCTION(pcntl_waitpid)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz/|l", &pid, &z_status, &options) == FAILURE)
return;
- convert_to_long_ex(z_status);
+ convert_to_int_ex(z_status);
status = Z_LVAL_P(z_status);
@@ -589,7 +589,7 @@ PHP_FUNCTION(pcntl_waitpid)
Z_LVAL_P(z_status) = status;
- RETURN_LONG((long) child_id);
+ RETURN_LONG((zend_long) child_id);
}
/* }}} */
@@ -597,7 +597,7 @@ PHP_FUNCTION(pcntl_waitpid)
Waits on or returns the status of a forked child as defined by the waitpid() system call */
PHP_FUNCTION(pcntl_wait)
{
- long options = 0;
+ zend_long options = 0;
zval *z_status = NULL;
int status;
pid_t child_id;
@@ -605,7 +605,7 @@ PHP_FUNCTION(pcntl_wait)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/|l", &z_status, &options) == FAILURE)
return;
- convert_to_long_ex(z_status);
+ convert_to_int_ex(z_status);
status = Z_LVAL_P(z_status);
#ifdef HAVE_WAIT3
@@ -624,7 +624,7 @@ PHP_FUNCTION(pcntl_wait)
Z_LVAL_P(z_status) = status;
- RETURN_LONG((long) child_id);
+ RETURN_LONG((zend_long) child_id);
}
/* }}} */
@@ -633,7 +633,7 @@ PHP_FUNCTION(pcntl_wait)
PHP_FUNCTION(pcntl_wifexited)
{
#ifdef WIFEXITED
- long status_word;
+ zend_long status_word;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &status_word) == FAILURE) {
return;
@@ -651,7 +651,7 @@ PHP_FUNCTION(pcntl_wifexited)
PHP_FUNCTION(pcntl_wifstopped)
{
#ifdef WIFSTOPPED
- long status_word;
+ zend_long status_word;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &status_word) == FAILURE) {
return;
@@ -669,7 +669,7 @@ PHP_FUNCTION(pcntl_wifstopped)
PHP_FUNCTION(pcntl_wifsignaled)
{
#ifdef WIFSIGNALED
- long status_word;
+ zend_long status_word;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &status_word) == FAILURE) {
return;
@@ -687,7 +687,7 @@ PHP_FUNCTION(pcntl_wifsignaled)
PHP_FUNCTION(pcntl_wexitstatus)
{
#ifdef WEXITSTATUS
- long status_word;
+ zend_long status_word;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &status_word) == FAILURE) {
return;
@@ -705,7 +705,7 @@ PHP_FUNCTION(pcntl_wexitstatus)
PHP_FUNCTION(pcntl_wtermsig)
{
#ifdef WTERMSIG
- long status_word;
+ zend_long status_word;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &status_word) == FAILURE) {
return;
@@ -723,7 +723,7 @@ PHP_FUNCTION(pcntl_wtermsig)
PHP_FUNCTION(pcntl_wstopsig)
{
#ifdef WSTOPSIG
- long status_word;
+ zend_long status_word;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &status_word) == FAILURE) {
return;
@@ -751,7 +751,7 @@ PHP_FUNCTION(pcntl_exec)
zend_string *key;
char *path;
int path_len;
- ulong key_num;
+ zend_ulong key_num;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|aa", &path, &path_len, &args, &envs) == FAILURE) {
return;
@@ -788,9 +788,9 @@ PHP_FUNCTION(pcntl_exec)
ZEND_HASH_FOREACH_KEY_VAL(envs_hash, key_num, key, element) {
if (envi >= envc) break;
if (!key) {
- key = zend_long_to_str(key_num);
+ key = zend_longo_str(key_num);
} else {
- STR_ADDREF(key);
+ zend_string_addref(key);
}
convert_to_string_ex(element);
@@ -803,7 +803,7 @@ PHP_FUNCTION(pcntl_exec)
strlcat(*pair, Z_STRVAL_P(element), pair_length);
/* Cleanup */
- STR_RELEASE(key);
+ zend_string_release(key);
envi++;
pair++;
} ZEND_HASH_FOREACH_END();
@@ -837,7 +837,7 @@ PHP_FUNCTION(pcntl_signal)
{
zval *handle;
zend_string *func_name;
- long signo;
+ zend_long signo;
zend_bool restart_syscalls = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz|b", &signo, &handle, &restart_syscalls) == FAILURE) {
@@ -864,7 +864,7 @@ PHP_FUNCTION(pcntl_signal)
/* Special long value case for SIG_DFL and SIG_IGN */
if (Z_TYPE_P(handle) == IS_LONG) {
- if (Z_LVAL_P(handle) != (long) SIG_DFL && Z_LVAL_P(handle) != (long) SIG_IGN) {
+ if (Z_LVAL_P(handle) != (zend_long) SIG_DFL && Z_LVAL_P(handle) != (zend_long) SIG_IGN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for handle argument specified");
RETURN_FALSE;
}
@@ -879,10 +879,10 @@ PHP_FUNCTION(pcntl_signal)
if (!zend_is_callable(handle, 0, &func_name TSRMLS_CC)) {
PCNTL_G(last_error) = EINVAL;
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not a callable function name error", func_name->val);
- STR_RELEASE(func_name);
+ zend_string_release(func_name);
RETURN_FALSE;
}
- STR_RELEASE(func_name);
+ zend_string_release(func_name);
/* Add the function name to our signal table */
if (zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle)) {
@@ -912,7 +912,7 @@ PHP_FUNCTION(pcntl_signal_dispatch)
Examine and change blocked signals */
PHP_FUNCTION(pcntl_sigprocmask)
{
- long how, signo;
+ zend_long how, signo;
zval *user_set, *user_oldset = NULL, *user_signo;
sigset_t set, oldset;
@@ -929,7 +929,7 @@ PHP_FUNCTION(pcntl_sigprocmask)
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(user_set), user_signo) {
if (Z_TYPE_P(user_signo) != IS_LONG) {
SEPARATE_ZVAL(user_signo);
- convert_to_long_ex(user_signo);
+ convert_to_int_ex(user_signo);
}
signo = Z_LVAL_P(user_signo);
if (sigaddset(&set, signo) != 0) {
@@ -969,7 +969,7 @@ PHP_FUNCTION(pcntl_sigprocmask)
static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{{ */
{
zval *user_set, *user_signo, *user_siginfo = NULL;
- long tv_sec = 0, tv_nsec = 0;
+ zend_long tv_sec = 0, tv_nsec = 0;
sigset_t set;
int signo;
siginfo_t siginfo;
@@ -994,7 +994,7 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(user_set), user_signo) {
if (Z_TYPE_P(user_signo) != IS_LONG) {
SEPARATE_ZVAL(user_signo);
- convert_to_long_ex(user_signo);
+ convert_to_int_ex(user_signo);
}
signo = Z_LVAL_P(user_signo);
if (sigaddset(&set, signo) != 0) {
@@ -1052,7 +1052,7 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
case SIGFPE:
case SIGSEGV:
case SIGBUS:
- add_assoc_double_ex(user_siginfo, "addr", sizeof("addr")-1, (long)siginfo.si_addr);
+ add_assoc_double_ex(user_siginfo, "addr", sizeof("addr")-1, (zend_long)siginfo.si_addr);
break;
#ifdef SIGPOLL
case SIGPOLL:
@@ -1091,8 +1091,8 @@ PHP_FUNCTION(pcntl_sigtimedwait)
Get the priority of any process */
PHP_FUNCTION(pcntl_getpriority)
{
- long who = PRIO_PROCESS;
- long pid = getpid();
+ zend_long who = PRIO_PROCESS;
+ zend_long pid = getpid();
int pri;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &pid, &who) == FAILURE) {
@@ -1130,9 +1130,9 @@ PHP_FUNCTION(pcntl_getpriority)
Change the priority of any process */
PHP_FUNCTION(pcntl_setpriority)
{
- long who = PRIO_PROCESS;
- long pid = getpid();
- long pri;
+ zend_long who = PRIO_PROCESS;
+ zend_long pid = getpid();
+ zend_long pri;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|ll", &pri, &pid, &who) == FAILURE) {
RETURN_FALSE;
@@ -1177,7 +1177,7 @@ PHP_FUNCTION(pcntl_get_last_error)
Retrieve the system error message associated with the given errno. */
PHP_FUNCTION(pcntl_strerror)
{
- long error;
+ zend_long error;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error) == FAILURE) {
RETURN_FALSE;
diff --git a/ext/pcntl/php_pcntl.h b/ext/pcntl/php_pcntl.h
index caafc10d19..05c7f45566 100644
--- a/ext/pcntl/php_pcntl.h
+++ b/ext/pcntl/php_pcntl.h
@@ -61,7 +61,7 @@ PHP_FUNCTION(pcntl_setpriority);
struct php_pcntl_pending_signal {
struct php_pcntl_pending_signal *next;
- long signo;
+ zend_long signo;
};
ZEND_BEGIN_MODULE_GLOBALS(pcntl)
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 4731db21fb..9be65164cd 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -541,22 +541,21 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ *
{
/* parameters */
zend_string *regex; /* Regular expression */
- char *subject; /* String to match against */
- int subject_len;
+ zend_string *subject; /* String to match against */
pcre_cache_entry *pce; /* Compiled regular expression */
zval *subpats = NULL; /* Array for subpatterns */
- long flags = 0; /* Match control flags */
- long start_offset = 0; /* Where the new search starts */
+ zend_long flags = 0; /* Match control flags */
+ zend_long start_offset = 0; /* Where the new search starts */
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ss|z/ll", &regex,
- &subject, &subject_len, &subpats, &flags, &start_offset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|z/ll", &regex,
+ &subject, &subpats, &flags, &start_offset) == FAILURE) {
RETURN_FALSE;
}
#else
ZEND_PARSE_PARAMETERS_START(2, 5)
Z_PARAM_STR(regex)
- Z_PARAM_STRING(subject, subject_len)
+ Z_PARAM_STR(subject)
Z_PARAM_OPTIONAL
Z_PARAM_ZVAL_EX(subpats, 0, 1)
Z_PARAM_LONG(flags)
@@ -569,7 +568,7 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ *
RETURN_FALSE;
}
- php_pcre_match_impl(pce, subject, subject_len, return_value, subpats,
+ php_pcre_match_impl(pce, subject->val, subject->len, return_value, subpats,
global, ZEND_NUM_ARGS() >= 4, flags, start_offset TSRMLS_CC);
}
/* }}} */
@@ -984,7 +983,7 @@ static zend_string *preg_do_repl_func(zval *function, char *subject, int *offset
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call custom replacement function");
}
- result_str = STR_INIT(&subject[offsets[0]], offsets[1] - offsets[0], 0);
+ result_str = zend_string_init(&subject[offsets[0]], offsets[1] - offsets[0], 0);
}
zval_ptr_dtor(&args[0]);
@@ -1035,7 +1034,7 @@ static zend_string *preg_do_eval(char *eval_str, int eval_str_len, char *subject
if (match_len) {
esc_match = php_addslashes(match, match_len, 0 TSRMLS_CC);
} else {
- esc_match = STR_INIT(match, match_len, 0);
+ esc_match = zend_string_init(match, match_len, 0);
}
} else {
esc_match = STR_EMPTY_ALLOC();
@@ -1045,7 +1044,7 @@ static zend_string *preg_do_eval(char *eval_str, int eval_str_len, char *subject
segment = walk;
/* Clean up and reassign */
- STR_RELEASE(esc_match);
+ zend_string_release(esc_match);
continue;
}
}
@@ -1172,7 +1171,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject,
}
alloc_len = 2 * subject_len;
- result = STR_ALLOC(alloc_len * sizeof(char), 0);
+ result = zend_string_alloc(alloc_len * sizeof(char), 0);
/* Initialize */
match = NULL;
@@ -1242,7 +1241,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject,
if (new_len > alloc_len) {
alloc_len = alloc_len + 2 * new_len;
- result = STR_REALLOC(result, alloc_len, 0);
+ result = zend_string_realloc(result, alloc_len, 0);
}
/* copy the part of the string before the match */
memcpy(&result->val[result_len], piece, match-piece);
@@ -1256,7 +1255,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject,
if (eval || is_callable_replace) {
memcpy(walkbuf, eval_result->val, eval_result->len);
result_len += eval_result->len;
- if (eval_result) STR_RELEASE(eval_result);
+ if (eval_result) zend_string_release(eval_result);
} else { /* do regular backreference copying */
walk = replace;
walk_last = 0;
@@ -1301,7 +1300,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject,
new_len = result_len + subject_len - start_offset;
if (new_len > alloc_len) {
alloc_len = new_len; /* now we know exactly how long it is */
- result = STR_REALLOC(result, alloc_len, 0);
+ result = zend_string_realloc(result, alloc_len, 0);
}
/* stick that last bit of string on our output */
memcpy(&result->val[result_len], piece, subject_len - start_offset);
@@ -1311,7 +1310,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject,
}
} else {
pcre_handle_exec_error(count TSRMLS_CC);
- STR_FREE(result);
+ zend_string_free(result);
result = NULL;
break;
}
@@ -1352,7 +1351,7 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub
empty_replace;
zend_string *result;
zend_string *subject_str = zval_get_string(subject);
- zend_uint replace_idx;
+ uint32_t replace_idx;
/* FIXME: This might need to be changed to STR_EMPTY_ALLOC(). Check if this zval could be dtor()'ed somehow */
ZVAL_EMPTY_STRING(&empty_replace);
@@ -1399,15 +1398,15 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub
is_callable_replace,
limit,
replace_count TSRMLS_CC)) != NULL) {
- STR_RELEASE(subject_str);
+ zend_string_release(subject_str);
subject_str = result;
} else {
- STR_RELEASE(subject_str);
- STR_RELEASE(regex_str);
+ zend_string_release(subject_str);
+ zend_string_release(regex_str);
return NULL;
}
- STR_RELEASE(regex_str);
+ zend_string_release(regex_str);
} ZEND_HASH_FOREACH_END();
return subject_str;
@@ -1419,7 +1418,7 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub
is_callable_replace,
limit,
replace_count TSRMLS_CC);
- STR_RELEASE(subject_str);
+ zend_string_release(subject_str);
return result;
}
}
@@ -1435,13 +1434,13 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
*subject_entry,
*zcount = NULL;
int limit_val = -1;
- long limit = -1;
+ zend_long limit = -1;
zend_string *result;
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
zend_string *callback_name;
int replace_count=0, old_replace_count;
-
+
#ifndef FAST_ZPP
/* Get function parameters and do error-checking. */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|lz/", &regex, &replace, &subject, &limit, &zcount) == FAILURE) {
@@ -1470,11 +1469,11 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
if (is_callable_replace) {
if (!zend_is_callable(replace, 0, &callback_name TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires argument 2, '%s', to be a valid callback", callback_name->val);
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
ZVAL_DUP(return_value, subject);
return;
}
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
}
if (ZEND_NUM_ARGS() > 3) {
@@ -1503,7 +1502,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
add_index_str(return_value, num_key, result);
}
} else {
- STR_RELEASE(result);
+ zend_string_release(result);
}
}
} ZEND_HASH_FOREACH_END();
@@ -1513,7 +1512,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
if (!is_filter || replace_count > old_replace_count) {
RETVAL_STR(result);
} else {
- STR_RELEASE(result);
+ zend_string_release(result);
}
}
}
@@ -1554,22 +1553,21 @@ static PHP_FUNCTION(preg_filter)
static PHP_FUNCTION(preg_split)
{
zend_string *regex; /* Regular expression */
- char *subject; /* String to match against */
- int subject_len;
- long limit_val = -1;/* Integer value of limit */
- long flags = 0; /* Match control flags */
+ zend_string *subject; /* String to match against */
+ zend_long limit_val = -1;/* Integer value of limit */
+ zend_long flags = 0; /* Match control flags */
pcre_cache_entry *pce; /* Compiled regular expression */
/* Get function parameters and do error checking */
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ss|ll", &regex,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|ll", &regex,
&subject, &subject_len, &limit_val, &flags) == FAILURE) {
RETURN_FALSE;
}
#else
ZEND_PARSE_PARAMETERS_START(2, 4)
Z_PARAM_STR(regex)
- Z_PARAM_STRING(subject, subject_len)
+ Z_PARAM_STR(subject)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(limit_val)
Z_PARAM_LONG(flags)
@@ -1581,7 +1579,7 @@ static PHP_FUNCTION(preg_split)
RETURN_FALSE;
}
- php_pcre_split_impl(pce, subject, subject_len, return_value, limit_val, flags TSRMLS_CC);
+ php_pcre_split_impl(pce, subject->val, subject->len, return_value, limit_val, flags TSRMLS_CC);
}
/* }}} */
@@ -1703,9 +1701,9 @@ PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, int subjec
if (pce->compile_options & PCRE_UTF8) {
if (re_bump == NULL) {
int dummy;
- zend_string *regex = STR_INIT("/./us", sizeof("/./us")-1, 0);
+ zend_string *regex = zend_string_init("/./us", sizeof("/./us")-1, 0);
re_bump = pcre_get_compiled_regex(regex, &extra_bump, &dummy TSRMLS_CC);
- STR_RELEASE(regex);
+ zend_string_release(regex);
if (re_bump == NULL) {
RETURN_FALSE;
}
@@ -1806,7 +1804,7 @@ static PHP_FUNCTION(preg_quote)
/* Allocate enough memory so that even if each character
is quoted, we won't run out of room */
- out_str = STR_SAFE_ALLOC(4, in_str_len, 0, 0);
+ out_str = zend_string_safe_alloc(4, in_str_len, 0, 0);
/* Go through the string and quote necessary characters */
for (p = in_str, q = out_str->val; p != in_str_end; p++) {
@@ -1853,7 +1851,7 @@ static PHP_FUNCTION(preg_quote)
*q = '\0';
/* Reallocate string and return it */
- out_str = STR_REALLOC(out_str, q - out_str->val, 0);
+ out_str = zend_string_realloc(out_str, q - out_str->val, 0);
RETURN_STR(out_str);
}
/* }}} */
@@ -1864,7 +1862,7 @@ static PHP_FUNCTION(preg_grep)
{
zend_string *regex; /* Regular expression */
zval *input; /* Input array */
- long flags = 0; /* Match control flags */
+ zend_long flags = 0; /* Match control flags */
pcre_cache_entry *pce; /* Compiled regular expression */
/* Get arguments and do error checking */
@@ -1900,7 +1898,7 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
int size_offsets; /* Size of the offsets array */
int count = 0; /* Count of matched subpatterns */
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
zend_bool invert; /* Whether to return non-matching
entries */
ALLOCA_FLAG(use_heap);
@@ -1945,7 +1943,7 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
count = size_offsets/3;
} else if (count < 0 && count != PCRE_ERROR_NOMATCH) {
pcre_handle_exec_error(count TSRMLS_CC);
- STR_RELEASE(subject_str);
+ zend_string_release(subject_str);
break;
}
@@ -1963,7 +1961,7 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
}
}
- STR_RELEASE(subject_str);
+ zend_string_release(subject_str);
} ZEND_HASH_FOREACH_END();
/* Clean up */
diff --git a/ext/pcre/tests/bug47662.phpt b/ext/pcre/tests/bug47662.phpt
index d6056746cb..abf65e6ca9 100644
--- a/ext/pcre/tests/bug47662.phpt
+++ b/ext/pcre/tests/bug47662.phpt
@@ -4,9 +4,10 @@ Bug #47662 (support more than 127 named subpatterns)
<?php
$regex = '@';
-for($bar=0; $bar<1027; $bar++) {
+for($bar=0; $bar<129; $bar++) {
$regex .= '((?P<x'.$bar.'>))';
}
+
$regex .= 'fo+bar@';
var_dump(preg_match($regex, 'foobar'));
diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c
index 3e10a6d003..936428ad7b 100644
--- a/ext/pdo/pdo.c
+++ b/ext/pdo/pdo.c
@@ -208,7 +208,7 @@ pdo_driver_t *pdo_find_driver(const char *name, int namelen) /* {{{ */
}
/* }}} */
-PDO_API int php_pdo_parse_data_source(const char *data_source, unsigned long data_source_len, struct pdo_data_src_parser *parsed, int nparams) /* {{{ */
+PDO_API int php_pdo_parse_data_source(const char *data_source, zend_ulong data_source_len, struct pdo_data_src_parser *parsed, int nparams) /* {{{ */
{
int i, j;
int valstart = -1;
@@ -314,7 +314,7 @@ PDO_API char *php_pdo_int64_to_str(pdo_int64_t i64 TSRMLS_DC) /* {{{ */
char buffer[65];
char outbuf[65] = "";
register char *p;
- long long_val;
+ zend_long long_val;
char *dst = outbuf;
if (i64 < 0) {
@@ -331,15 +331,15 @@ PDO_API char *php_pdo_int64_to_str(pdo_int64_t i64 TSRMLS_DC) /* {{{ */
p = &buffer[sizeof(buffer)-1];
*p = '\0';
- while ((pdo_uint64_t)i64 > (pdo_uint64_t)LONG_MAX) {
+ while ((pdo_uint64_t)i64 > (pdo_uint64_t)ZEND_LONG_MAX) {
pdo_uint64_t quo = (pdo_uint64_t)i64 / (unsigned int)10;
unsigned int rem = (unsigned int)(i64 - quo*10U);
*--p = digit_vec[rem];
i64 = (pdo_int64_t)quo;
}
- long_val = (long)i64;
+ long_val = (zend_long)i64;
while (long_val != 0) {
- long quo = long_val / 10;
+ zend_long quo = long_val / 10;
*--p = digit_vec[(unsigned int)(long_val - quo * 10)];
long_val = quo;
}
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index cdf639a72d..06d8c71235 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -36,7 +36,7 @@
#include "zend_object_handlers.h"
#include "zend_hash.h"
-static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_DC);
+static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value TSRMLS_DC);
void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate, const char *supp TSRMLS_DC) /* {{{ */
{
@@ -103,7 +103,7 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC) /* {{{
pdo_error_type *pdo_err = &dbh->error_code;
const char *msg = "<<Unknown>>";
char *supp = NULL;
- long native_code = 0;
+ zend_long native_code = 0;
zend_string *message = NULL;
zval info;
@@ -169,7 +169,7 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC) /* {{{
}
if (message) {
- STR_RELEASE(message);
+ zend_string_release(message);
}
if (supp) {
@@ -285,7 +285,7 @@ static PHP_METHOD(PDO, dbh_constructor)
Z_STRVAL_P(v));
is_persistent = 1;
} else {
- convert_to_long_ex(v);
+ convert_to_int_ex(v);
is_persistent = Z_LVAL_P(v) ? 1 : 0;
plen = spprintf(&hashkey, 0, "PDO:DBH:DSN=%s:%s:%s", data_source,
username ? username : "",
@@ -385,7 +385,7 @@ static PHP_METHOD(PDO, dbh_constructor)
options:
if (options) {
zval *attr_value;
- ulong long_key;
+ zend_ulong long_key;
zend_string *str_key = NULL;
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(options), long_key, str_key, attr_value) {
@@ -675,7 +675,7 @@ static PHP_METHOD(PDO, inTransaction)
}
/* }}} */
-static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_DC) /* {{{ */
+static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value TSRMLS_DC) /* {{{ */
{
#define PDO_LONG_PARAM_CHECK \
@@ -688,7 +688,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D
switch (attr) {
case PDO_ATTR_ERRMODE:
PDO_LONG_PARAM_CHECK;
- convert_to_long(value);
+ convert_to_int(value);
switch (Z_LVAL_P(value)) {
case PDO_ERRMODE_SILENT:
case PDO_ERRMODE_WARNING:
@@ -704,7 +704,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D
case PDO_ATTR_CASE:
PDO_LONG_PARAM_CHECK;
- convert_to_long(value);
+ convert_to_int(value);
switch (Z_LVAL_P(value)) {
case PDO_CASE_NATURAL:
case PDO_CASE_UPPER:
@@ -720,7 +720,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D
case PDO_ATTR_ORACLE_NULLS:
PDO_LONG_PARAM_CHECK;
- convert_to_long(value);
+ convert_to_int(value);
dbh->oracle_nulls = Z_LVAL_P(value);
return SUCCESS;
@@ -736,7 +736,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D
} else {
PDO_LONG_PARAM_CHECK;
}
- convert_to_long(value);
+ convert_to_int(value);
if (Z_LVAL_P(value) == PDO_FETCH_USE_DEFAULT) {
pdo_raise_impl_error(dbh, NULL, "HY000", "invalid fetch mode type" TSRMLS_CC);
return FAILURE;
@@ -746,7 +746,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D
case PDO_ATTR_STRINGIFY_FETCHES:
PDO_LONG_PARAM_CHECK;
- convert_to_long(value);
+ convert_to_int(value);
dbh->stringify = Z_LVAL_P(value) ? 1 : 0;
return SUCCESS;
@@ -835,7 +835,7 @@ fail:
static PHP_METHOD(PDO, setAttribute)
{
pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis());
- long attr;
+ zend_long attr;
zval *value;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz", &attr, &value)) {
@@ -857,7 +857,7 @@ static PHP_METHOD(PDO, setAttribute)
static PHP_METHOD(PDO, getAttribute)
{
pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis());
- long attr;
+ zend_long attr;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &attr)) {
RETURN_FALSE;
@@ -885,7 +885,7 @@ static PHP_METHOD(PDO, getAttribute)
case PDO_ATTR_STATEMENT_CLASS:
array_init(return_value);
- add_next_index_str(return_value, STR_COPY(dbh->def_stmt_ce->name));
+ add_next_index_str(return_value, zend_string_copy(dbh->def_stmt_ce->name));
if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) {
if (Z_REFCOUNTED(dbh->def_stmt_ctor_args)) Z_ADDREF(dbh->def_stmt_ctor_args);
add_next_index_zval(return_value, &dbh->def_stmt_ctor_args);
@@ -924,7 +924,7 @@ static PHP_METHOD(PDO, exec)
pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis());
char *statement;
int statement_len;
- long ret;
+ zend_long ret;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &statement, &statement_len)) {
RETURN_FALSE;
@@ -1136,7 +1136,7 @@ static PHP_METHOD(PDO, quote)
pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis());
char *str;
int str_len;
- long paramtype = PDO_PARAM_STR;
+ zend_long paramtype = PDO_PARAM_STR;
char *qstr;
int qlen;
@@ -1259,7 +1259,7 @@ const zend_function_entry pdo_dbh_functions[] = /* {{{ */ {
static void cls_method_dtor(zval *el) /* {{{ */ {
zend_function *func = (zend_function*)Z_PTR_P(el);
if (func->common.function_name) {
- STR_RELEASE(func->common.function_name);
+ zend_string_release(func->common.function_name);
}
efree(func);
}
@@ -1291,7 +1291,7 @@ int pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind TSRMLS_DC)
while (funcs->fname) {
ifunc->type = ZEND_INTERNAL_FUNCTION;
ifunc->handler = funcs->handler;
- ifunc->function_name = STR_INIT(funcs->fname, strlen(funcs->fname), 0);
+ ifunc->function_name = zend_string_init(funcs->fname, strlen(funcs->fname), 0);
ifunc->scope = dbh_obj->std.ce;
ifunc->prototype = NULL;
if (funcs->flags) {
@@ -1337,7 +1337,7 @@ static union _zend_function *dbh_method_get(zend_object **object, zend_string *m
pdo_dbh_object_t *dbh_obj = php_pdo_dbh_fetch_object(*object);
zend_string *lc_method_name;
- lc_method_name = STR_INIT(method_name->val, method_name->len, 0);
+ lc_method_name = zend_string_init(method_name->val, method_name->len, 0);
zend_str_tolower_copy(lc_method_name->val, method_name->val, method_name->len);
if ((fbc = std_object_handlers.get_method(object, method_name, key TSRMLS_CC)) == NULL) {
@@ -1355,7 +1355,7 @@ static union _zend_function *dbh_method_get(zend_object **object, zend_string *m
}
out:
- STR_RELEASE(lc_method_name);
+ zend_string_release(lc_method_name);
return fbc;
}
@@ -1382,99 +1382,100 @@ void pdo_dbh_init(TSRMLS_D)
pdo_dbh_object_handlers.get_method = dbh_method_get;
pdo_dbh_object_handlers.compare_objects = dbh_compare;
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_BOOL", (long)PDO_PARAM_BOOL);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_NULL", (long)PDO_PARAM_NULL);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_INT", (long)PDO_PARAM_INT);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_STR", (long)PDO_PARAM_STR);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_LOB", (long)PDO_PARAM_LOB);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_STMT", (long)PDO_PARAM_STMT);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_INPUT_OUTPUT", (long)PDO_PARAM_INPUT_OUTPUT);
-
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_ALLOC", (long)PDO_PARAM_EVT_ALLOC);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FREE", (long)PDO_PARAM_EVT_FREE);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_EXEC_PRE", (long)PDO_PARAM_EVT_EXEC_PRE);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_EXEC_POST", (long)PDO_PARAM_EVT_EXEC_POST);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_PRE", (long)PDO_PARAM_EVT_FETCH_PRE);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_POST", (long)PDO_PARAM_EVT_FETCH_POST);
- REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_NORMALIZE", (long)PDO_PARAM_EVT_NORMALIZE);
-
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_LAZY", (long)PDO_FETCH_LAZY);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_ASSOC",(long)PDO_FETCH_ASSOC);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_NUM", (long)PDO_FETCH_NUM);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_BOTH", (long)PDO_FETCH_BOTH);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_OBJ", (long)PDO_FETCH_OBJ);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_BOUND",(long)PDO_FETCH_BOUND);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_COLUMN",(long)PDO_FETCH_COLUMN);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_CLASS",(long)PDO_FETCH_CLASS);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_INTO", (long)PDO_FETCH_INTO);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_FUNC", (long)PDO_FETCH_FUNC);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_GROUP",(long)PDO_FETCH_GROUP);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_UNIQUE",(long)PDO_FETCH_UNIQUE);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_KEY_PAIR",(long)PDO_FETCH_KEY_PAIR);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_CLASSTYPE",(long)PDO_FETCH_CLASSTYPE);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_BOOL", (zend_long)PDO_PARAM_BOOL);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_NULL", (zend_long)PDO_PARAM_NULL);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_INT", (zend_long)PDO_PARAM_INT);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_STR", (zend_long)PDO_PARAM_STR);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_LOB", (zend_long)PDO_PARAM_LOB);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_STMT", (zend_long)PDO_PARAM_STMT);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_INPUT_OUTPUT", (zend_long)PDO_PARAM_INPUT_OUTPUT);
+
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_ALLOC", (zend_long)PDO_PARAM_EVT_ALLOC);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FREE", (zend_long)PDO_PARAM_EVT_FREE);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_EXEC_PRE", (zend_long)PDO_PARAM_EVT_EXEC_PRE);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_EXEC_POST", (zend_long)PDO_PARAM_EVT_EXEC_POST);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_PRE", (zend_long)PDO_PARAM_EVT_FETCH_PRE);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_POST", (zend_long)PDO_PARAM_EVT_FETCH_POST);
+ REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_NORMALIZE", (zend_long)PDO_PARAM_EVT_NORMALIZE);
+
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_LAZY", (zend_long)PDO_FETCH_LAZY);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_ASSOC", (zend_long)PDO_FETCH_ASSOC);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_NUM", (zend_long)PDO_FETCH_NUM);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_BOTH", (zend_long)PDO_FETCH_BOTH);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_OBJ", (zend_long)PDO_FETCH_OBJ);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_BOUND", (zend_long)PDO_FETCH_BOUND);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_COLUMN", (zend_long)PDO_FETCH_COLUMN);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_CLASS", (zend_long)PDO_FETCH_CLASS);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_INTO", (zend_long)PDO_FETCH_INTO);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_FUNC", (zend_long)PDO_FETCH_FUNC);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_GROUP", (zend_long)PDO_FETCH_GROUP);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_UNIQUE", (zend_long)PDO_FETCH_UNIQUE);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_KEY_PAIR", (zend_long)PDO_FETCH_KEY_PAIR);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_CLASSTYPE", (zend_long)PDO_FETCH_CLASSTYPE);
+
#if PHP_VERSION_ID >= 50100
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_SERIALIZE",(long)PDO_FETCH_SERIALIZE);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_SERIALIZE",(zend_long)PDO_FETCH_SERIALIZE);
#endif
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_PROPS_LATE",(long)PDO_FETCH_PROPS_LATE);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_NAMED",(long)PDO_FETCH_NAMED);
-
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_AUTOCOMMIT", (long)PDO_ATTR_AUTOCOMMIT);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_PREFETCH", (long)PDO_ATTR_PREFETCH);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_TIMEOUT", (long)PDO_ATTR_TIMEOUT);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_ERRMODE", (long)PDO_ATTR_ERRMODE);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_SERVER_VERSION", (long)PDO_ATTR_SERVER_VERSION);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_CLIENT_VERSION", (long)PDO_ATTR_CLIENT_VERSION);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_SERVER_INFO", (long)PDO_ATTR_SERVER_INFO);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_CONNECTION_STATUS", (long)PDO_ATTR_CONNECTION_STATUS);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_CASE", (long)PDO_ATTR_CASE);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_CURSOR_NAME", (long)PDO_ATTR_CURSOR_NAME);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_CURSOR", (long)PDO_ATTR_CURSOR);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_ORACLE_NULLS", (long)PDO_ATTR_ORACLE_NULLS);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_PERSISTENT", (long)PDO_ATTR_PERSISTENT);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_STATEMENT_CLASS", (long)PDO_ATTR_STATEMENT_CLASS);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_FETCH_TABLE_NAMES", (long)PDO_ATTR_FETCH_TABLE_NAMES);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_FETCH_CATALOG_NAMES", (long)PDO_ATTR_FETCH_CATALOG_NAMES);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_DRIVER_NAME", (long)PDO_ATTR_DRIVER_NAME);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_STRINGIFY_FETCHES",(long)PDO_ATTR_STRINGIFY_FETCHES);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_MAX_COLUMN_LEN",(long)PDO_ATTR_MAX_COLUMN_LEN);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_EMULATE_PREPARES",(long)PDO_ATTR_EMULATE_PREPARES);
- REGISTER_PDO_CLASS_CONST_LONG("ATTR_DEFAULT_FETCH_MODE",(long)PDO_ATTR_DEFAULT_FETCH_MODE);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_PROPS_LATE", (zend_long)PDO_FETCH_PROPS_LATE);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_NAMED", (zend_long)PDO_FETCH_NAMED);
+
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_AUTOCOMMIT", (zend_long)PDO_ATTR_AUTOCOMMIT);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_PREFETCH", (zend_long)PDO_ATTR_PREFETCH);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_TIMEOUT", (zend_long)PDO_ATTR_TIMEOUT);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_ERRMODE", (zend_long)PDO_ATTR_ERRMODE);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_SERVER_VERSION", (zend_long)PDO_ATTR_SERVER_VERSION);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_CLIENT_VERSION", (zend_long)PDO_ATTR_CLIENT_VERSION);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_SERVER_INFO", (zend_long)PDO_ATTR_SERVER_INFO);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_CONNECTION_STATUS", (zend_long)PDO_ATTR_CONNECTION_STATUS);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_CASE", (zend_long)PDO_ATTR_CASE);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_CURSOR_NAME", (zend_long)PDO_ATTR_CURSOR_NAME);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_CURSOR", (zend_long)PDO_ATTR_CURSOR);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_ORACLE_NULLS", (zend_long)PDO_ATTR_ORACLE_NULLS);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_PERSISTENT", (zend_long)PDO_ATTR_PERSISTENT);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_STATEMENT_CLASS", (zend_long)PDO_ATTR_STATEMENT_CLASS);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_FETCH_TABLE_NAMES", (zend_long)PDO_ATTR_FETCH_TABLE_NAMES);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_FETCH_CATALOG_NAMES", (zend_long)PDO_ATTR_FETCH_CATALOG_NAMES);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_DRIVER_NAME", (zend_long)PDO_ATTR_DRIVER_NAME);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_STRINGIFY_FETCHES", (zend_long)PDO_ATTR_STRINGIFY_FETCHES);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_MAX_COLUMN_LEN", (zend_long)PDO_ATTR_MAX_COLUMN_LEN);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_EMULATE_PREPARES", (zend_long)PDO_ATTR_EMULATE_PREPARES);
+ REGISTER_PDO_CLASS_CONST_LONG("ATTR_DEFAULT_FETCH_MODE", (zend_long)PDO_ATTR_DEFAULT_FETCH_MODE);
- REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_SILENT", (long)PDO_ERRMODE_SILENT);
- REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_WARNING", (long)PDO_ERRMODE_WARNING);
- REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_EXCEPTION", (long)PDO_ERRMODE_EXCEPTION);
+ REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_SILENT", (zend_long)PDO_ERRMODE_SILENT);
+ REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_WARNING", (zend_long)PDO_ERRMODE_WARNING);
+ REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_EXCEPTION", (zend_long)PDO_ERRMODE_EXCEPTION);
- REGISTER_PDO_CLASS_CONST_LONG("CASE_NATURAL", (long)PDO_CASE_NATURAL);
- REGISTER_PDO_CLASS_CONST_LONG("CASE_LOWER", (long)PDO_CASE_LOWER);
- REGISTER_PDO_CLASS_CONST_LONG("CASE_UPPER", (long)PDO_CASE_UPPER);
+ REGISTER_PDO_CLASS_CONST_LONG("CASE_NATURAL", (zend_long)PDO_CASE_NATURAL);
+ REGISTER_PDO_CLASS_CONST_LONG("CASE_LOWER", (zend_long)PDO_CASE_LOWER);
+ REGISTER_PDO_CLASS_CONST_LONG("CASE_UPPER", (zend_long)PDO_CASE_UPPER);
- REGISTER_PDO_CLASS_CONST_LONG("NULL_NATURAL", (long)PDO_NULL_NATURAL);
- REGISTER_PDO_CLASS_CONST_LONG("NULL_EMPTY_STRING", (long)PDO_NULL_EMPTY_STRING);
- REGISTER_PDO_CLASS_CONST_LONG("NULL_TO_STRING", (long)PDO_NULL_TO_STRING);
+ REGISTER_PDO_CLASS_CONST_LONG("NULL_NATURAL", (zend_long)PDO_NULL_NATURAL);
+ REGISTER_PDO_CLASS_CONST_LONG("NULL_EMPTY_STRING", (zend_long)PDO_NULL_EMPTY_STRING);
+ REGISTER_PDO_CLASS_CONST_LONG("NULL_TO_STRING", (zend_long)PDO_NULL_TO_STRING);
REGISTER_PDO_CLASS_CONST_STRING("ERR_NONE", PDO_ERR_NONE);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_NEXT", (long)PDO_FETCH_ORI_NEXT);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_PRIOR", (long)PDO_FETCH_ORI_PRIOR);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_FIRST", (long)PDO_FETCH_ORI_FIRST);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_LAST", (long)PDO_FETCH_ORI_LAST);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_ABS", (long)PDO_FETCH_ORI_ABS);
- REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_REL", (long)PDO_FETCH_ORI_REL);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_NEXT", (zend_long)PDO_FETCH_ORI_NEXT);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_PRIOR", (zend_long)PDO_FETCH_ORI_PRIOR);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_FIRST", (zend_long)PDO_FETCH_ORI_FIRST);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_LAST", (zend_long)PDO_FETCH_ORI_LAST);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_ABS", (zend_long)PDO_FETCH_ORI_ABS);
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_REL", (zend_long)PDO_FETCH_ORI_REL);
- REGISTER_PDO_CLASS_CONST_LONG("CURSOR_FWDONLY", (long)PDO_CURSOR_FWDONLY);
- REGISTER_PDO_CLASS_CONST_LONG("CURSOR_SCROLL", (long)PDO_CURSOR_SCROLL);
+ REGISTER_PDO_CLASS_CONST_LONG("CURSOR_FWDONLY", (zend_long)PDO_CURSOR_FWDONLY);
+ REGISTER_PDO_CLASS_CONST_LONG("CURSOR_SCROLL", (zend_long)PDO_CURSOR_SCROLL);
#if 0
- REGISTER_PDO_CLASS_CONST_LONG("ERR_CANT_MAP", (long)PDO_ERR_CANT_MAP);
- REGISTER_PDO_CLASS_CONST_LONG("ERR_SYNTAX", (long)PDO_ERR_SYNTAX);
- REGISTER_PDO_CLASS_CONST_LONG("ERR_CONSTRAINT", (long)PDO_ERR_CONSTRAINT);
- REGISTER_PDO_CLASS_CONST_LONG("ERR_NOT_FOUND", (long)PDO_ERR_NOT_FOUND);
- REGISTER_PDO_CLASS_CONST_LONG("ERR_ALREADY_EXISTS", (long)PDO_ERR_ALREADY_EXISTS);
- REGISTER_PDO_CLASS_CONST_LONG("ERR_NOT_IMPLEMENTED", (long)PDO_ERR_NOT_IMPLEMENTED);
- REGISTER_PDO_CLASS_CONST_LONG("ERR_MISMATCH", (long)PDO_ERR_MISMATCH);
- REGISTER_PDO_CLASS_CONST_LONG("ERR_TRUNCATED", (long)PDO_ERR_TRUNCATED);
- REGISTER_PDO_CLASS_CONST_LONG("ERR_DISCONNECTED", (long)PDO_ERR_DISCONNECTED);
- REGISTER_PDO_CLASS_CONST_LONG("ERR_NO_PERM", (long)PDO_ERR_NO_PERM);
+ REGISTER_PDO_CLASS_CONST_LONG("ERR_CANT_MAP", (zend_long)PDO_ERR_CANT_MAP);
+ REGISTER_PDO_CLASS_CONST_LONG("ERR_SYNTAX", (zend_long)PDO_ERR_SYNTAX);
+ REGISTER_PDO_CLASS_CONST_LONG("ERR_CONSTRAINT", (zend_long)PDO_ERR_CONSTRAINT);
+ REGISTER_PDO_CLASS_CONST_LONG("ERR_NOT_FOUND", (zend_long)PDO_ERR_NOT_FOUND);
+ REGISTER_PDO_CLASS_CONST_LONG("ERR_ALREADY_EXISTS", (zend_long)PDO_ERR_ALREADY_EXISTS);
+ REGISTER_PDO_CLASS_CONST_LONG("ERR_NOT_IMPLEMENTED", (zend_long)PDO_ERR_NOT_IMPLEMENTED);
+ REGISTER_PDO_CLASS_CONST_LONG("ERR_MISMATCH", (zend_long)PDO_ERR_MISMATCH);
+ REGISTER_PDO_CLASS_CONST_LONG("ERR_TRUNCATED", (zend_long)PDO_ERR_TRUNCATED);
+ REGISTER_PDO_CLASS_CONST_LONG("ERR_DISCONNECTED", (zend_long)PDO_ERR_DISCONNECTED);
+ REGISTER_PDO_CLASS_CONST_LONG("ERR_NO_PERM", (zend_long)PDO_ERR_NO_PERM);
#endif
}
diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c
index 9cd205f4eb..61fba9f131 100644
--- a/ext/pdo/pdo_sql_parser.c
+++ b/ext/pdo/pdo_sql_parser.c
@@ -1,5 +1,4 @@
/* Generated by re2c 0.13.5 */
-#line 1 "ext/pdo/pdo_sql_parser.re"
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
@@ -47,11 +46,9 @@ static int scan(Scanner *s)
char *cursor = s->cur;
s->tok = cursor;
- #line 55 "ext/pdo/pdo_sql_parser.re"
-#line 55 "ext/pdo/pdo_sql_parser.c"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
@@ -79,9 +76,7 @@ yy3:
yych = *(YYMARKER = ++YYCURSOR);
if (yych >= 0x01) goto yy43;
yy4:
-#line 63 "ext/pdo/pdo_sql_parser.re"
{ SKIP_ONE(PDO_PARSER_TEXT); }
-#line 85 "ext/pdo/pdo_sql_parser.c"
yy5:
yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
@@ -163,9 +158,7 @@ yy7:
default: goto yy8;
}
yy8:
-#line 62 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_BIND_POS); }
-#line 169 "ext/pdo/pdo_sql_parser.c"
yy9:
++YYCURSOR;
switch ((yych = *YYCURSOR)) {
@@ -173,9 +166,7 @@ yy9:
default: goto yy13;
}
yy10:
-#line 65 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
-#line 179 "ext/pdo/pdo_sql_parser.c"
yy11:
yych = *++YYCURSOR;
switch (yych) {
@@ -210,9 +201,7 @@ yy14:
default: goto yy14;
}
yy16:
-#line 64 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
-#line 216 "ext/pdo/pdo_sql_parser.c"
yy17:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -290,9 +279,7 @@ yy29:
default: goto yy31;
}
yy31:
-#line 60 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
-#line 296 "ext/pdo/pdo_sql_parser.c"
yy32:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -364,9 +351,7 @@ yy32:
default: goto yy34;
}
yy34:
-#line 61 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_BIND); }
-#line 370 "ext/pdo/pdo_sql_parser.c"
yy35:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -394,9 +379,7 @@ yy39:
goto yy37;
yy40:
++YYCURSOR;
-#line 59 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
-#line 400 "ext/pdo/pdo_sql_parser.c"
yy42:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -416,11 +399,8 @@ yy44:
goto yy42;
yy45:
++YYCURSOR;
-#line 58 "ext/pdo/pdo_sql_parser.re"
{ RET(PDO_PARSER_TEXT); }
-#line 422 "ext/pdo/pdo_sql_parser.c"
}
-#line 66 "ext/pdo/pdo_sql_parser.re"
}
@@ -581,12 +561,12 @@ safe:
ret = -1;
strncpy(stmt->error_code, stmt->dbh->error_code, 6);
if (buf) {
- STR_RELEASE(buf);
+ zend_string_release(buf);
}
goto clean_up;
}
if (buf) {
- STR_RELEASE(buf);
+ zend_string_release(buf);
}
} else {
pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource" TSRMLS_CC);
@@ -606,7 +586,7 @@ safe:
case IS_FALSE:
case IS_TRUE:
- convert_to_long(&tmp_param);
+ convert_to_int(&tmp_param);
/* fall through */
case IS_LONG:
case IS_DOUBLE:
diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re
index 76ac3d115a..e2723bb883 100644
--- a/ext/pdo/pdo_sql_parser.re
+++ b/ext/pdo/pdo_sql_parser.re
@@ -223,12 +223,12 @@ safe:
ret = -1;
strncpy(stmt->error_code, stmt->dbh->error_code, 6);
if (buf) {
- STR_RELEASE(buf);
+ zend_string_release(buf);
}
goto clean_up;
}
if (buf) {
- STR_RELEASE(buf);
+ zend_string_release(buf);
}
} else {
pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource" TSRMLS_CC);
@@ -248,7 +248,7 @@ safe:
case IS_FALSE:
case IS_TRUE:
- convert_to_long(&tmp_param);
+ convert_to_int(&tmp_param);
/* fall through */
case IS_LONG:
case IS_DOUBLE:
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index c4ae2f6fe1..175e52885d 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -138,7 +138,7 @@ static inline int rewrite_name_to_position(pdo_stmt_t *stmt, struct pdo_bound_pa
if (!param->name) {
/* do the reverse; map the parameter number to the name */
if ((name = zend_hash_index_find_ptr(stmt->bound_param_map, param->paramno)) != NULL) {
- param->name = STR_INIT(name, strlen(name), 0);
+ param->name = zend_string_init(name, strlen(name), 0);
return 1;
}
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined" TSRMLS_CC);
@@ -279,7 +279,7 @@ static void param_dtor(zval *el) /* {{{ */
}
if (param->name) {
- STR_RELEASE(param->name);
+ zend_string_release(param->name);
}
if (!Z_ISUNDEF(param->parameter)) {
@@ -328,7 +328,7 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
convert_to_string(parameter);
}
} else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_INT && (Z_TYPE_P(parameter) == IS_FALSE || Z_TYPE_P(parameter) == IS_TRUE)) {
- convert_to_long(parameter);
+ convert_to_int(parameter);
} else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL && Z_TYPE_P(parameter) == IS_LONG) {
convert_to_boolean(parameter);
}
@@ -363,18 +363,18 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
if (param->name) {
if (is_param && param->name->val[0] != ':') {
- zend_string *temp = STR_ALLOC(param->name->len + 1, 0);
+ zend_string *temp = zend_string_alloc(param->name->len + 1, 0);
temp->val[0] = ':';
memmove(temp->val + 1, param->name->val, param->name->len + 1);
param->name = temp;
} else {
- param->name = STR_INIT(param->name->val, param->name->len, 0);
+ param->name = zend_string_init(param->name->val, param->name->len, 0);
}
}
if (is_param && !rewrite_name_to_position(stmt, param TSRMLS_CC)) {
if (param->name) {
- STR_RELEASE(param->name);
+ zend_string_release(param->name);
param->name = NULL;
}
return 0;
@@ -388,7 +388,7 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
if (!stmt->methods->param_hook(stmt, param, PDO_PARAM_EVT_NORMALIZE
TSRMLS_CC)) {
if (param->name) {
- STR_RELEASE(param->name);
+ zend_string_release(param->name);
param->name = NULL;
}
return 0;
@@ -447,7 +447,7 @@ static PHP_METHOD(PDOStatement, execute)
struct pdo_bound_param_data param;
zval *tmp;
zend_string *key = NULL;
- ulong num_index;
+ zend_ulong num_index;
if (stmt->bound_params) {
zend_hash_destroy(stmt->bound_params);
@@ -544,7 +544,7 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ
{
struct pdo_column_data *col;
char *value = NULL;
- unsigned long value_len = 0;
+ size_t value_len = 0;
int caller_frees = 0;
int type, new_type;
@@ -571,8 +571,8 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ
break;
case PDO_PARAM_INT:
- if (value && value_len == sizeof(long)) {
- ZVAL_LONG(dest, *(long*)value);
+ if (value && value_len == sizeof(zend_long)) {
+ ZVAL_LONG(dest, *(zend_long*)value);
break;
}
ZVAL_NULL(dest);
@@ -639,7 +639,7 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ
if (type != new_type) {
switch (new_type) {
case PDO_PARAM_INT:
- convert_to_long_ex(dest);
+ convert_to_int_ex(dest);
break;
case PDO_PARAM_BOOL:
convert_to_boolean_ex(dest);
@@ -674,7 +674,7 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ
}
/* }}} */
-static int do_fetch_common(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, long offset, int do_bind TSRMLS_DC) /* {{{ */
+static int do_fetch_common(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset, int do_bind TSRMLS_DC) /* {{{ */
{
if (!stmt->executed) {
return 0;
@@ -748,7 +748,7 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
fci->params = NULL;
fci->no_separation = 1;
- zend_fcall_info_args(fci, &stmt->fetch.cls.ctor_args TSRMLS_CC);
+ zend_fcall_info_args_ex(fci, ce->constructor, &stmt->fetch.cls.ctor_args TSRMLS_CC);
fcc->initialized = 1;
fcc->function_handler = ce->constructor;
@@ -832,7 +832,7 @@ static int do_fetch_opt_finish(pdo_stmt_t *stmt, int free_ctor_agrs TSRMLS_DC) /
/* perform a fetch. If do_bind is true, update any bound columns.
* If return_value is not null, store values into it according to HOW. */
-static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_fetch_type how, enum pdo_fetch_orientation ori, long offset, zval *return_all TSRMLS_DC) /* {{{ */
+static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_fetch_type how, enum pdo_fetch_orientation ori, zend_long offset, zval *return_all TSRMLS_DC) /* {{{ */
{
int flags, idx, old_arg_count = 0;
zend_class_entry *ce = NULL, *old_ce = NULL;
@@ -1213,7 +1213,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
}
/* }}} */
-static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, long mode, int fetch_all TSRMLS_DC) /* {{{ */
+static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, zend_long mode, int fetch_all TSRMLS_DC) /* {{{ */
{
int flags = mode & PDO_FETCH_FLAGS;
@@ -1269,9 +1269,9 @@ static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, long mode, int fetch_all TSRML
Fetches the next row and returns it, or false if there are no more rows */
static PHP_METHOD(PDOStatement, fetch)
{
- long how = PDO_FETCH_USE_DEFAULT;
- long ori = PDO_FETCH_ORI_NEXT;
- long off = 0;
+ zend_long how = PDO_FETCH_USE_DEFAULT;
+ zend_long ori = PDO_FETCH_ORI_NEXT;
+ zend_long off = 0;
PHP_STMT_GET_OBJ;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lll", &how,
@@ -1296,9 +1296,9 @@ static PHP_METHOD(PDOStatement, fetch)
Fetches the next row and returns it as an object. */
static PHP_METHOD(PDOStatement, fetchObject)
{
- long how = PDO_FETCH_CLASS;
- long ori = PDO_FETCH_ORI_NEXT;
- long off = 0;
+ zend_long how = PDO_FETCH_CLASS;
+ zend_long ori = PDO_FETCH_ORI_NEXT;
+ zend_long off = 0;
zend_string *class_name = NULL;
zend_class_entry *old_ce;
zval old_ctor_args, *ctor_args = NULL;
@@ -1361,7 +1361,7 @@ static PHP_METHOD(PDOStatement, fetchObject)
Returns a data of the specified column in the result set. */
static PHP_METHOD(PDOStatement, fetchColumn)
{
- long col_n = 0;
+ zend_long col_n = 0;
PHP_STMT_GET_OBJ;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &col_n)) {
@@ -1383,7 +1383,7 @@ static PHP_METHOD(PDOStatement, fetchColumn)
Returns an array of all of the results. */
static PHP_METHOD(PDOStatement, fetchAll)
{
- long how = PDO_FETCH_USE_DEFAULT;
+ zend_long how = PDO_FETCH_USE_DEFAULT;
zval data, *return_all;
zval *arg2;
zend_class_entry *old_ce;
@@ -1470,7 +1470,7 @@ static PHP_METHOD(PDOStatement, fetchAll)
stmt->fetch.column = how & PDO_FETCH_GROUP ? -1 : 0;
break;
case 2:
- convert_to_long(arg2);
+ convert_to_int(arg2);
stmt->fetch.column = Z_LVAL_P(arg2);
break;
case 3:
@@ -1545,7 +1545,7 @@ static PHP_METHOD(PDOStatement, fetchAll)
static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int is_param) /* {{{ */
{
struct pdo_bound_param_data param = {0};
- long param_type = PDO_PARAM_STR;
+ zend_long param_type = PDO_PARAM_STR;
zval *parameter;
param.paramno = -1;
@@ -1584,7 +1584,7 @@ static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt,
static PHP_METHOD(PDOStatement, bindValue)
{
struct pdo_bound_param_data param = {0};
- long param_type = PDO_PARAM_STR;
+ zend_long param_type = PDO_PARAM_STR;
zval *parameter;
PHP_STMT_GET_OBJ;
@@ -1703,7 +1703,7 @@ static PHP_METHOD(PDOStatement, errorInfo)
Set an attribute */
static PHP_METHOD(PDOStatement, setAttribute)
{
- long attr;
+ zend_long attr;
zval *value = NULL;
PHP_STMT_GET_OBJ;
@@ -1733,7 +1733,7 @@ fail:
/* {{{ proto mixed PDOStatement::getAttribute(long attribute)
Get an attribute */
-static int generic_stmt_attr_get(pdo_stmt_t *stmt, zval *return_value, long attr)
+static int generic_stmt_attr_get(pdo_stmt_t *stmt, zval *return_value, zend_long attr)
{
switch (attr) {
case PDO_ATTR_EMULATE_PREPARES:
@@ -1745,7 +1745,7 @@ static int generic_stmt_attr_get(pdo_stmt_t *stmt, zval *return_value, long attr
static PHP_METHOD(PDOStatement, getAttribute)
{
- long attr;
+ zend_long attr;
PHP_STMT_GET_OBJ;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &attr)) {
@@ -1798,7 +1798,7 @@ static PHP_METHOD(PDOStatement, columnCount)
Returns meta data for a numbered column */
static PHP_METHOD(PDOStatement, getColumnMeta)
{
- long colno;
+ zend_long colno;
struct pdo_column_data *col;
PHP_STMT_GET_OBJ;
@@ -1838,7 +1838,7 @@ static PHP_METHOD(PDOStatement, getColumnMeta)
int pdo_stmt_setup_fetch_mode(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int skip)
{
- long mode = PDO_FETCH_BOTH;
+ zend_long mode = PDO_FETCH_BOTH;
int flags = 0, argc = ZEND_NUM_ARGS() - skip;
zval *args;
zend_class_entry *cep;
@@ -2119,13 +2119,13 @@ static PHP_METHOD(PDOStatement, debugDumpParams)
stmt->bound_params ? zend_hash_num_elements(stmt->bound_params) : 0);
if (stmt->bound_params) {
- ulong num;
+ zend_ulong num;
zend_string *key = NULL;
ZEND_HASH_FOREACH_KEY_PTR(stmt->bound_params, num, key, param) {
if (key) {
php_stream_printf(out TSRMLS_CC, "Key: Name: [%d] %.*s\n", key->len, key->len, key->val);
} else {
- php_stream_printf(out TSRMLS_CC, "Key: Position #%ld:\n", num);
+ php_stream_printf(out TSRMLS_CC, "Key: Position #%pd:\n", num);
}
php_stream_printf(out TSRMLS_CC, "paramno=%ld\nname=[%d] \"%.*s\"\nis_param=%d\nparam_type=%d\n",
@@ -2215,7 +2215,7 @@ static union _zend_function *dbstmt_method_get(zend_object **object_pp, zend_str
zend_string *lc_method_name;
zend_object *object = *object_pp;
- lc_method_name = STR_ALLOC(method_name->len, 0);
+ lc_method_name = zend_string_alloc(method_name->len, 0);
zend_str_tolower_copy(lc_method_name->val, method_name->val, method_name->len);
if ((fbc = zend_hash_find_ptr(&object->ce->function_table, lc_method_name)) == NULL) {
@@ -2241,7 +2241,7 @@ static union _zend_function *dbstmt_method_get(zend_object **object_pp, zend_str
}
out:
- STR_RELEASE(lc_method_name);
+ zend_string_release(lc_method_name);
return fbc;
}
@@ -2267,7 +2267,7 @@ static zend_object *dbstmt_clone_obj(zval *zobject TSRMLS_DC)
}
zend_object_handlers pdo_dbstmt_object_handlers;
-static int pdo_row_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
+static int pdo_row_serialize(zval *object, unsigned char **buffer, uint32_t *buf_len, zend_serialize_data *data TSRMLS_DC);
void pdo_stmt_init(TSRMLS_D)
{
@@ -2372,7 +2372,7 @@ zend_object *pdo_dbstmt_new(zend_class_entry *ce TSRMLS_DC)
struct php_pdo_iterator {
zend_object_iterator iter;
- ulong key;
+ zend_ulong key;
zval fetch_ahead;
};
@@ -2606,15 +2606,15 @@ static union _zend_function *row_method_get(
zend_function *fbc;
zend_string *lc_method_name;
- lc_method_name = STR_ALLOC(method_name->len, 0);
+ lc_method_name = zend_string_alloc(method_name->len, 0);
zend_str_tolower_copy(lc_method_name->val, method_name->val, method_name->len);
if ((fbc = zend_hash_find_ptr(&pdo_row_ce->function_table, lc_method_name)) == NULL) {
- STR_RELEASE(lc_method_name);
+ zend_string_release(lc_method_name);
return NULL;
}
- STR_RELEASE(lc_method_name);
+ zend_string_release(lc_method_name);
return fbc;
}
@@ -2628,7 +2628,7 @@ static union _zend_function *row_get_ctor(zend_object *object TSRMLS_DC)
static zend_internal_function ctor = {0};
ctor.type = ZEND_INTERNAL_FUNCTION;
- ctor.function_name = STR_INIT("__construct", sizeof("__construct") - 1, 0);
+ ctor.function_name = zend_string_init("__construct", sizeof("__construct") - 1, 0);
ctor.scope = pdo_row_ce;
ctor.handler = ZEND_FN(dbstmt_constructor);
ctor.fn_flags = ZEND_ACC_PUBLIC;
@@ -2646,7 +2646,7 @@ static zend_string *row_get_classname(const zend_object *object, int parent TSRM
if (parent) {
return NULL;
} else {
- return STR_INIT("PDORow", sizeof("PDORow") - 1, 0);
+ return zend_string_init("PDORow", sizeof("PDORow") - 1, 0);
}
}
@@ -2700,7 +2700,7 @@ zend_object *pdo_row_new(zend_class_entry *ce TSRMLS_DC)
return &row->std;
}
-static int pdo_row_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC)
+static int pdo_row_serialize(zval *object, unsigned char **buffer, uint32_t *buf_len, zend_serialize_data *data TSRMLS_DC)
{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PDORow instances may not be serialized");
return FAILURE;
diff --git a/ext/pdo/php_pdo.h b/ext/pdo/php_pdo.h
index 0de6743ad4..0dca85779a 100644
--- a/ext/pdo/php_pdo.h
+++ b/ext/pdo/php_pdo.h
@@ -49,7 +49,7 @@ PHP_MSHUTDOWN_FUNCTION(pdo);
PHP_MINFO_FUNCTION(pdo);
ZEND_BEGIN_MODULE_GLOBALS(pdo)
- long global_value;
+ zend_long global_value;
ZEND_END_MODULE_GLOBALS(pdo)
#ifdef ZTS
@@ -59,12 +59,12 @@ ZEND_END_MODULE_GLOBALS(pdo)
#endif
#define REGISTER_PDO_CLASS_CONST_LONG(const_name, value) \
- zend_declare_class_constant_long(php_pdo_get_dbh_ce(), const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
+ zend_declare_class_constant_long(php_pdo_get_dbh_ce(), const_name, sizeof(const_name)-1, (zend_long)value TSRMLS_CC);
#define REGISTER_PDO_CONST_LONG(const_name, value) { \
zend_class_entry **pce; \
if (zend_hash_find(CG(class_table), "pdo", sizeof("pdo"), (void **) &pce) != FAILURE) \
- zend_declare_class_constant_long(*pce, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); \
+ zend_declare_class_constant_long(*pce, const_name, sizeof(const_name)-1, (zend_long)value TSRMLS_CC); \
} \
#define REGISTER_PDO_CLASS_CONST_STRING(const_name, value) \
diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h
index 4818bc6232..7368a07126 100644
--- a/ext/pdo/php_pdo_driver.h
+++ b/ext/pdo/php_pdo_driver.h
@@ -194,12 +194,12 @@ enum pdo_null_handling {
};
/* {{{ utils for reading attributes set as driver_options */
-static inline long pdo_attr_lval(zval *options, enum pdo_attribute_type option_name, long defval TSRMLS_DC)
+static inline zend_long pdo_attr_lval(zval *options, enum pdo_attribute_type option_name, zend_long defval TSRMLS_DC)
{
zval *v;
if (options && (v = zend_hash_index_find(Z_ARRVAL_P(options), option_name))) {
- convert_to_long_ex(v);
+ convert_to_int_ex(v);
return Z_LVAL_P(v);
}
return defval;
@@ -220,8 +220,8 @@ static inline char *pdo_attr_strval(zval *options, enum pdo_attribute_type optio
* initialized */
typedef struct {
const char *driver_name;
- unsigned long driver_name_len;
- unsigned long api_version; /* needs to be compatible with PDO */
+ zend_ulong driver_name_len;
+ zend_ulong api_version; /* needs to be compatible with PDO */
#define PDO_DRIVER_HEADER(name) \
#name, sizeof(#name)-1, \
@@ -244,10 +244,10 @@ typedef struct {
typedef int (*pdo_dbh_close_func)(pdo_dbh_t *dbh TSRMLS_DC);
/* prepare a statement and stash driver specific portion into stmt */
-typedef int (*pdo_dbh_prepare_func)(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC);
+typedef int (*pdo_dbh_prepare_func)(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC);
/* execute a statement (that does not return a result set) */
-typedef long (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC);
+typedef zend_long (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const char *sql, zend_long sql_len TSRMLS_DC);
/* quote a string */
typedef int (*pdo_dbh_quote_func)(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC);
@@ -256,7 +256,7 @@ typedef int (*pdo_dbh_quote_func)(pdo_dbh_t *dbh, const char *unquoted, int unqu
typedef int (*pdo_dbh_txn_func)(pdo_dbh_t *dbh TSRMLS_DC);
/* setting of attributes */
-typedef int (*pdo_dbh_set_attr_func)(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC);
+typedef int (*pdo_dbh_set_attr_func)(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC);
/* return last insert id. NULL indicates error condition, otherwise, the return value
* MUST be an emalloc'd NULL terminated string. */
@@ -271,7 +271,7 @@ typedef char *(*pdo_dbh_last_id_func)(pdo_dbh_t *dbh, const char *name, unsigned
typedef int (*pdo_dbh_fetch_error_func)(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS_DC);
/* fetching of attributes */
-typedef int (*pdo_dbh_get_attr_func)(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC);
+typedef int (*pdo_dbh_get_attr_func)(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC);
/* checking/pinging persistent connections; return SUCCESS if the connection
* is still alive and ready to be used, FAILURE otherwise.
@@ -329,7 +329,7 @@ typedef int (*pdo_stmt_execute_func)(pdo_stmt_t *stmt TSRMLS_DC);
* more rows. The ori and offset params modify which row should be returned,
* if the stmt represents a scrollable cursor */
typedef int (*pdo_stmt_fetch_func)(pdo_stmt_t *stmt,
- enum pdo_fetch_orientation ori, long offset TSRMLS_DC);
+ enum pdo_fetch_orientation ori, zend_long offset TSRMLS_DC);
/* queries information about the type of a column, by index (0 based).
* Driver should populate stmt->columns[colno] with appropriate info */
@@ -341,7 +341,7 @@ typedef int (*pdo_stmt_describe_col_func)(pdo_stmt_t *stmt, int colno TSRMLS_DC)
* If the driver sets caller_frees, ptr should point to emalloc'd memory
* and PDO will free it as soon as it is done using it.
*/
-typedef int (*pdo_stmt_get_col_data_func)(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len, int *caller_frees TSRMLS_DC);
+typedef int (*pdo_stmt_get_col_data_func)(pdo_stmt_t *stmt, int colno, char **ptr, zend_ulong *len, int *caller_frees TSRMLS_DC);
/* hook for bound params */
enum pdo_param_event {
@@ -357,10 +357,10 @@ enum pdo_param_event {
typedef int (*pdo_stmt_param_hook_func)(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo_param_event event_type TSRMLS_DC);
/* setting of attributes */
-typedef int (*pdo_stmt_set_attr_func)(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC);
+typedef int (*pdo_stmt_set_attr_func)(pdo_stmt_t *stmt, zend_long attr, zval *val TSRMLS_DC);
/* fetching of attributes */
-typedef int (*pdo_stmt_get_attr_func)(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC);
+typedef int (*pdo_stmt_get_attr_func)(pdo_stmt_t *stmt, zend_long attr, zval *val TSRMLS_DC);
/* retrieves meta data for a numbered column.
* Returns SUCCESS/FAILURE.
@@ -390,7 +390,7 @@ typedef int (*pdo_stmt_get_attr_func)(pdo_stmt_t *stmt, long attr, zval *val TSR
* or
* 'flags' => array('not_null', 'mysql:some_flag'); // to add data to an existing key
*/
-typedef int (*pdo_stmt_get_column_meta_func)(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC);
+typedef int (*pdo_stmt_get_column_meta_func)(pdo_stmt_t *stmt, zend_long colno, zval *return_value TSRMLS_DC);
/* advances the statement to the next rowset of the batch.
* If it returns 1, PDO will tear down its idea of columns
@@ -469,7 +469,7 @@ struct _pdo_dbh_t {
/* data source string used to open this handle */
const char *data_source;
- unsigned long data_source_len;
+ zend_ulong data_source_len;
/* the global error code. */
pdo_error_type error_code;
@@ -529,9 +529,9 @@ static inline pdo_dbh_object_t *php_pdo_dbh_fetch_object(zend_object *obj) {
struct pdo_column_data {
char *name;
int namelen;
- unsigned long maxlen;
+ zend_ulong maxlen;
enum pdo_param_type param_type;
- unsigned long precision;
+ zend_ulong precision;
/* don't touch this unless your name is dbdo */
void *dbdo_data;
@@ -539,10 +539,10 @@ struct pdo_column_data {
/* describes a bound parameter */
struct pdo_bound_param_data {
- long paramno; /* if -1, then it has a name, and we don't know the index *yet* */
+ zend_long paramno; /* if -1, then it has a name, and we don't know the index *yet* */
zend_string *name;
- long max_value_len; /* as a hint for pre-allocation */
+ zend_long max_value_len; /* as a hint for pre-allocation */
zval parameter; /* the variable itself */
enum pdo_param_type param_type; /* desired or suggested type */
@@ -591,7 +591,7 @@ struct _pdo_stmt_t {
HashTable *bound_columns;
/* not always meaningful */
- long row_count;
+ zend_long row_count;
/* used to hold the statement's current query */
char *query_string;
@@ -607,7 +607,7 @@ struct _pdo_stmt_t {
/* for lazy fetches, we always return the same lazy object handle.
* Let's keep it here. */
zval lazy_object_ref;
- unsigned long refcount;
+ zend_ulong refcount;
/* defaults for fetches */
enum pdo_fetch_type default_fetch_type;
@@ -669,7 +669,7 @@ struct pdo_data_src_parser {
};
PDO_API int php_pdo_parse_data_source(const char *data_source,
- unsigned long data_source_len, struct pdo_data_src_parser *parsed,
+ zend_ulong data_source_len, struct pdo_data_src_parser *parsed,
int nparams);
PDO_API zend_class_entry *php_pdo_get_dbh_ce(void);
diff --git a/ext/pdo/tests/pdo_005.phpt b/ext/pdo/tests/pdo_005.phpt
index cebb5873ec..c7c18a91a5 100644
--- a/ext/pdo/tests/pdo_005.phpt
+++ b/ext/pdo/tests/pdo_005.phpt
@@ -46,7 +46,7 @@ $stmt->execute();
var_dump($stmt->fetchAll(PDO::FETCH_CLASS, 'TestBase'));
$stmt->execute();
-var_dump($stmt->fetchAll(PDO::FETCH_CLASS, 'TestDerived', array("")));
+var_dump($stmt->fetchAll(PDO::FETCH_CLASS, 'TestDerived', array(0)));
?>
--EXPECTF--
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index 350a3c670d..ddf182b190 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -93,7 +93,7 @@ static int dblib_handle_closer(pdo_dbh_t *dbh TSRMLS_DC)
return 0;
}
-static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
+static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
pdo_dblib_stmt *S = ecalloc(1, sizeof(*S));
@@ -107,7 +107,7 @@ static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
return 1;
}
-static long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC)
+static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len TSRMLS_DC)
{
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
RETCODE ret, resret;
diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c
index c13d58bd57..6bd2a5976e 100644
--- a/ext/pdo_dblib/dblib_stmt.c
+++ b/ext/pdo_dblib/dblib_stmt.c
@@ -171,7 +171,7 @@ static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
}
static int pdo_dblib_stmt_fetch(pdo_stmt_t *stmt,
- enum pdo_fetch_orientation ori, long offset TSRMLS_DC)
+ enum pdo_fetch_orientation ori, zend_long offset TSRMLS_DC)
{
RETCODE ret;
@@ -213,7 +213,7 @@ static int pdo_dblib_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
}
static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr,
- unsigned long *len, int *caller_frees TSRMLS_DC)
+ zend_ulong *len, int *caller_frees TSRMLS_DC)
{
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
@@ -287,7 +287,7 @@ static int pdo_dblib_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
return 1;
}
-static int pdo_dblib_stmt_get_column_meta(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC)
+static int pdo_dblib_stmt_get_column_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value TSRMLS_DC)
{
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
pdo_dblib_db_handle *H = S->H;
diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c
index 20a41bbb9b..ab4612a119 100644
--- a/ext/pdo_firebird/firebird_driver.c
+++ b/ext/pdo_firebird/firebird_driver.c
@@ -33,11 +33,11 @@
#include "php_pdo_firebird.h"
#include "php_pdo_firebird_int.h"
-static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, long, XSQLDA*, isc_stmt_handle*,
+static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, zend_long, XSQLDA*, isc_stmt_handle*,
HashTable* TSRMLS_DC);
/* map driver specific error message to PDO error */
-void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC) /* {{{ */
+void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, zend_long line TSRMLS_DC) /* {{{ */
{
#if 0
pdo_firebird_db_handle *H = stmt ? ((pdo_firebird_stmt *)stmt->driver_data)->H
@@ -132,7 +132,7 @@ static int firebird_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
/* }}} */
/* called by PDO to prepare an SQL query */
-static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, /* {{{ */
+static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, /* {{{ */
pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
@@ -218,7 +218,7 @@ static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_le
/* }}} */
/* called by PDO to execute a statement that doesn't produce a result set */
-static long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC) /* {{{ */
+static zend_long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
isc_stmt_handle stmt = NULL;
@@ -391,12 +391,12 @@ static int firebird_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
/* }}} */
/* used by prepare and exec to allocate a statement handle and prepare the SQL */
-static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, long sql_len, /* {{{ */
+static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, /* {{{ */
XSQLDA *out_sqlda, isc_stmt_handle *s, HashTable *named_params TSRMLS_DC)
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
char *c, *new_sql, in_quote, in_param, pname[64], *ppname;
- long l, pindex = -1;
+ zend_long l, pindex = -1;
/* Firebird allows SQL statements up to 64k, so bail if it doesn't fit */
if (sql_len > 65536) {
@@ -470,7 +470,7 @@ static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, long sql
/* }}} */
/* called by PDO to set a driver-specific dbh attribute */
-static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */
+static int firebird_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
@@ -545,7 +545,7 @@ static void firebird_info_cb(void *arg, char const *s) /* {{{ */
/* }}} */
/* called by PDO to get a driver-specific dbh attribute */
-static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */
+static int firebird_handle_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
@@ -606,7 +606,7 @@ static int pdo_firebird_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
const ISC_STATUS *s = H->isc_status;
char buf[400];
- long i = 0, l, sqlcode = isc_sqlcode(s);
+ zend_long i = 0, l, sqlcode = isc_sqlcode(s);
if (sqlcode) {
add_next_index_long(info, sqlcode);
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index d21273366b..622cbc39a3 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -88,7 +88,7 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H;
- unsigned long affected_rows = 0;
+ zend_ulong affected_rows = 0;
static char info_count[] = {isc_info_sql_records};
char result[64];
@@ -153,7 +153,7 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
/* called by PDO to fetch the next row from a statement */
static int firebird_stmt_fetch(pdo_stmt_t *stmt, /* {{{ */
- enum pdo_fetch_orientation ori, long offset TSRMLS_DC)
+ enum pdo_fetch_orientation ori, zend_long offset TSRMLS_DC)
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H;
@@ -219,7 +219,7 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{
/* fetch a blob into a fetch buffer */
static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */
- unsigned long *len, ISC_QUAD *blob_id TSRMLS_DC)
+ zend_ulong *len, ISC_QUAD *blob_id TSRMLS_DC)
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H;
@@ -263,7 +263,7 @@ static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ *
/* we've found the blob's length, now fetch! */
if (*len) {
- unsigned long cur_len;
+ zend_ulong cur_len;
unsigned short seg_len;
ISC_STATUS stat;
@@ -296,7 +296,7 @@ fetch_blob_end:
/* }}} */
static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */
- unsigned long *len, int *caller_frees TSRMLS_DC)
+ zend_ulong *len, int *caller_frees TSRMLS_DC)
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
XSQLVAR const *var = &S->out_sqlda.sqlvar[colno];
@@ -413,7 +413,7 @@ static int firebird_bind_blob(pdo_stmt_t *stmt, ISC_QUAD *blob_id, zval *param T
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H;
isc_blob_handle h = NULL;
- unsigned long put_cnt = 0, rem_cnt;
+ zend_ulong put_cnt = 0, rem_cnt;
unsigned short chunk_size;
int result = 1;
@@ -495,7 +495,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
switch (event_type) {
char *value;
- unsigned long value_len;
+ zend_ulong value_len;
int caller_frees;
zval *parameter;
@@ -551,9 +551,9 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
case IS_LONG:
/* keep the allow-NULL flag */
- var->sqltype = (sizeof(long) == 8 ? SQL_INT64 : SQL_LONG) | (var->sqltype & 1);
+ var->sqltype = (sizeof(zend_long) == 8 ? SQL_INT64 : SQL_LONG) | (var->sqltype & 1);
var->sqldata = (void*)&Z_LVAL_P(parameter);
- var->sqllen = sizeof(long);
+ var->sqllen = sizeof(zend_long);
break;
case IS_DOUBLE:
/* keep the allow-NULL flag */
@@ -626,7 +626,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
}
case PDO_PARAM_INT:
if (value) {
- ZVAL_LONG(parameter, *(long*)value);
+ ZVAL_LONG(parameter, *(zend_long*)value);
break;
}
case PDO_PARAM_EVT_NORMALIZE:
@@ -654,7 +654,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
}
/* }}} */
-static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC) /* {{{ */
+static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, zend_long attr, zval *val TSRMLS_DC) /* {{{ */
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
@@ -675,7 +675,7 @@ static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, long attr, zval *val TS
}
/* }}} */
-static int firebird_stmt_get_attribute(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC) /* {{{ */
+static int firebird_stmt_get_attribute(pdo_stmt_t *stmt, zend_long attr, zval *val TSRMLS_DC) /* {{{ */
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
diff --git a/ext/pdo_firebird/pdo_firebird.c b/ext/pdo_firebird/pdo_firebird.c
index d59aa53fa3..4eea0b69de 100644
--- a/ext/pdo_firebird/pdo_firebird.c
+++ b/ext/pdo_firebird/pdo_firebird.c
@@ -62,9 +62,9 @@ ZEND_GET_MODULE(pdo_firebird)
PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
{
- REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_DATE_FORMAT", (long) PDO_FB_ATTR_DATE_FORMAT);
- REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIME_FORMAT", (long) PDO_FB_ATTR_TIME_FORMAT);
- REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIMESTAMP_FORMAT", (long) PDO_FB_ATTR_TIMESTAMP_FORMAT);
+ REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_DATE_FORMAT", (zend_long) PDO_FB_ATTR_DATE_FORMAT);
+ REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIME_FORMAT", (zend_long) PDO_FB_ATTR_TIME_FORMAT);
+ REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIMESTAMP_FORMAT", (zend_long) PDO_FB_ATTR_TIMESTAMP_FORMAT);
php_pdo_register_driver(&pdo_firebird_driver);
diff --git a/ext/pdo_firebird/php_pdo_firebird_int.h b/ext/pdo_firebird/php_pdo_firebird_int.h
index 15004b8d33..20baebacaa 100644
--- a/ext/pdo_firebird/php_pdo_firebird_int.h
+++ b/ext/pdo_firebird/php_pdo_firebird_int.h
@@ -35,7 +35,7 @@
#define SHORT_MAX (1 << (8*sizeof(short)-1))
-#if SIZEOF_LONG == 8
+#if SIZEOF_ZEND_INT == 8 && !defined(PHP_WIN32)
# define LL_MASK "l"
# define LL_LIT(lit) lit ## L
#else
@@ -128,7 +128,7 @@ extern pdo_driver_t pdo_firebird_driver;
extern struct pdo_stmt_methods firebird_stmt_methods;
-void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC);
+void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, zend_long line TSRMLS_DC);
enum {
PDO_FB_ATTR_DATE_FORMAT = PDO_ATTR_DRIVER_SPECIFIC,
diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c
index b39fdfaaa2..6243a47e07 100644
--- a/ext/pdo_mysql/mysql_driver.c
+++ b/ext/pdo_mysql/mysql_driver.c
@@ -161,7 +161,7 @@ static int mysql_handle_closer(pdo_dbh_t *dbh TSRMLS_DC)
/* }}} */
/* {{{ mysql_handle_preparer */
-static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
+static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
pdo_mysql_stmt *S = ecalloc(1, sizeof(pdo_mysql_stmt));
@@ -235,7 +235,7 @@ static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
#else
S->params = ecalloc(S->num_params, sizeof(MYSQL_BIND));
S->in_null = ecalloc(S->num_params, sizeof(my_bool));
- S->in_length = ecalloc(S->num_params, sizeof(unsigned long));
+ S->in_length = ecalloc(S->num_params, sizeof(zend_ulong));
#endif
}
dbh->alloc_own_columns = 1;
@@ -253,7 +253,7 @@ end:
/* }}} */
/* {{{ mysql_handle_doer */
-static long mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC)
+static zend_long mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len TSRMLS_DC)
{
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
PDO_DBG_ENTER("mysql_handle_doer");
@@ -368,7 +368,7 @@ static inline int mysql_handle_autocommit(pdo_dbh_t *dbh TSRMLS_DC)
/* }}} */
/* {{{ pdo_mysql_set_attribute */
-static int pdo_mysql_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC)
+static int pdo_mysql_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC)
{
PDO_DBG_ENTER("pdo_mysql_set_attribute");
PDO_DBG_INF_FMT("dbh=%p", dbh);
@@ -400,7 +400,7 @@ static int pdo_mysql_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_D
PDO_DBG_RETURN(1);
#ifndef PDO_USE_MYSQLND
case PDO_MYSQL_ATTR_MAX_BUFFER_SIZE:
- convert_to_long(val);
+ convert_to_int(val);
if (Z_LVAL_P(val) < 0) {
/* TODO: Johannes, can we throw a warning here? */
((pdo_mysql_db_handle *)dbh->driver_data)->max_buffer_size = 1024*1024;
@@ -419,7 +419,7 @@ static int pdo_mysql_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_D
/* }}} */
/* {{{ pdo_mysql_get_attribute */
-static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value TSRMLS_DC)
+static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_value TSRMLS_DC)
{
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
@@ -596,13 +596,13 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
/* handle MySQL options */
if (driver_options) {
- long connect_timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
- long local_infile = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0 TSRMLS_CC);
+ zend_long connect_timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
+ zend_long local_infile = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0 TSRMLS_CC);
char *init_cmd = NULL;
#ifndef PDO_USE_MYSQLND
char *default_file = NULL, *default_group = NULL;
#endif
- long compress = 0;
+ zend_long compress = 0;
char *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, *ssl_capath = NULL, *ssl_cipher = NULL;
H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);
@@ -648,7 +648,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
* mysqlnd doesn't support reconnect, thus we don't have "|| defined(PDO_USE_MYSQLND)"
*/
{
- long reconnect = 1;
+ zend_long reconnect = 1;
mysql_options(H->server, MYSQL_OPT_RECONNECT, (const char*)&reconnect);
}
#endif
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c
index 30a2f04f98..909527eed2 100644
--- a/ext/pdo_mysql/mysql_statement.c
+++ b/ext/pdo_mysql/mysql_statement.c
@@ -116,10 +116,10 @@ static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
static void pdo_mysql_stmt_set_row_count(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
{
- long row_count;
+ zend_long row_count;
pdo_mysql_stmt *S = stmt->driver_data;
- row_count = (long) mysql_stmt_affected_rows(S->stmt);
- if (row_count != (long)-1) {
+ row_count = (zend_long) mysql_stmt_affected_rows(S->stmt);
+ if (row_count != (zend_long)-1) {
stmt->row_count = row_count;
}
}
@@ -146,12 +146,12 @@ static int pdo_mysql_fill_stmt_from_result(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
PDO_DBG_RETURN(0);
}
- stmt->row_count = (long) mysql_num_rows(S->result);
+ stmt->row_count = (zend_long) mysql_num_rows(S->result);
stmt->column_count = (int) mysql_num_fields(S->result);
S->fields = mysql_fetch_fields(S->result);
} else {
/* this was a DML or DDL query (INSERT, UPDATE, DELETE, ... */
- stmt->row_count = (long) row_count;
+ stmt->row_count = (zend_long) row_count;
}
PDO_DBG_RETURN(1);
@@ -200,7 +200,7 @@ static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt TSRMLS_DC)
stmt->column_count = (int)mysql_num_fields(S->result);
S->bound_result = ecalloc(stmt->column_count, sizeof(MYSQL_BIND));
S->out_null = ecalloc(stmt->column_count, sizeof(my_bool));
- S->out_length = ecalloc(stmt->column_count, sizeof(unsigned long));
+ S->out_length = ecalloc(stmt->column_count, sizeof(zend_ulong));
/* summon memory to hold the row */
for (i = 0; i < stmt->column_count; i++) {
@@ -343,7 +343,7 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
pdo_mysql_db_handle *H = S->H;
#if PDO_USE_MYSQLND
- long row_count;
+ zend_long row_count;
#endif
PDO_DBG_ENTER("pdo_mysql_stmt_next_rowset");
PDO_DBG_INF_FMT("stmt=%p", S->stmt);
@@ -393,8 +393,8 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
}
}
}
- row_count = (long) mysql_stmt_affected_rows(S->stmt);
- if (row_count != (long)-1) {
+ row_count = (zend_long) mysql_stmt_affected_rows(S->stmt);
+ if (row_count != (zend_long)-1) {
stmt->row_count = row_count;
}
PDO_DBG_RETURN(1);
@@ -551,9 +551,9 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_VAR_STRING);
break;
case IS_LONG:
-#if SIZEOF_LONG==8
+#if SIZEOF_ZEND_INT==8
mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONGLONG);
-#elif SIZEOF_LONG==4
+#elif SIZEOF_ZEND_INT==4
mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONG);
#endif /* SIZEOF_LONG */
break;
@@ -608,7 +608,7 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
}
/* }}} */
-static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, long offset TSRMLS_DC) /* {{{ */
+static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset TSRMLS_DC) /* {{{ */
{
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
#if PDO_USE_MYSQLND
@@ -722,7 +722,7 @@ static int pdo_mysql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{
}
/* }}} */
-static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len, int *caller_frees TSRMLS_DC) /* {{{ */
+static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, zend_ulong *len, int *caller_frees TSRMLS_DC) /* {{{ */
{
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
@@ -823,7 +823,7 @@ static char *type_to_name_native(int type) /* {{{ */
#undef PDO_MYSQL_NATIVE_TYPE_NAME
} /* }}} */
-static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC) /* {{{ */
+static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value TSRMLS_DC) /* {{{ */
{
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
const MYSQL_FIELD *F;
diff --git a/ext/pdo_mysql/pdo_mysql.c b/ext/pdo_mysql/pdo_mysql.c
index c3a90fedac..3a06741a05 100644
--- a/ext/pdo_mysql/pdo_mysql.c
+++ b/ext/pdo_mysql/pdo_mysql.c
@@ -106,25 +106,25 @@ static PHP_MINIT_FUNCTION(pdo_mysql)
{
REGISTER_INI_ENTRIES();
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY);
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE", (long)PDO_MYSQL_ATTR_LOCAL_INFILE);
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_USE_BUFFERED_QUERY", (zend_long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE", (zend_long)PDO_MYSQL_ATTR_LOCAL_INFILE);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (zend_long)PDO_MYSQL_ATTR_INIT_COMMAND);
#ifndef PDO_USE_MYSQLND
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_MAX_BUFFER_SIZE", (long)PDO_MYSQL_ATTR_MAX_BUFFER_SIZE);
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_FILE", (long)PDO_MYSQL_ATTR_READ_DEFAULT_FILE);
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_GROUP", (long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_MAX_BUFFER_SIZE", (zend_long)PDO_MYSQL_ATTR_MAX_BUFFER_SIZE);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_FILE", (zend_long)PDO_MYSQL_ATTR_READ_DEFAULT_FILE);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_GROUP", (zend_long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP);
#endif
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_COMPRESS", (long)PDO_MYSQL_ATTR_COMPRESS);
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_DIRECT_QUERY", (long)PDO_MYSQL_ATTR_DIRECT_QUERY);
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_FOUND_ROWS", (long)PDO_MYSQL_ATTR_FOUND_ROWS);
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_IGNORE_SPACE", (long)PDO_MYSQL_ATTR_IGNORE_SPACE);
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_KEY", (long)PDO_MYSQL_ATTR_SSL_KEY);
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CERT", (long)PDO_MYSQL_ATTR_SSL_CERT);
- 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);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_COMPRESS", (zend_long)PDO_MYSQL_ATTR_COMPRESS);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_DIRECT_QUERY", (zend_long)PDO_MYSQL_ATTR_DIRECT_QUERY);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_FOUND_ROWS", (zend_long)PDO_MYSQL_ATTR_FOUND_ROWS);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_IGNORE_SPACE", (zend_long)PDO_MYSQL_ATTR_IGNORE_SPACE);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_KEY", (zend_long)PDO_MYSQL_ATTR_SSL_KEY);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CERT", (zend_long)PDO_MYSQL_ATTR_SSL_CERT);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CA", (zend_long)PDO_MYSQL_ATTR_SSL_CA);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CAPATH", (zend_long)PDO_MYSQL_ATTR_SSL_CAPATH);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CIPHER", (zend_long)PDO_MYSQL_ATTR_SSL_CIPHER);
#if MYSQL_VERSION_ID > 50605 || defined(PDO_USE_MYSQLND)
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SERVER_PUBLIC_KEY", (long)PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SERVER_PUBLIC_KEY", (zend_long)PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY);
#endif
diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h
index 4455dcbeb6..31ccb5d02a 100644
--- a/ext/pdo_mysql/php_pdo_mysql_int.h
+++ b/ext/pdo_mysql/php_pdo_mysql_int.h
@@ -106,7 +106,7 @@ typedef struct {
unsigned fetch_table_names:1;
unsigned _reserved:31;
#if !PDO_USE_MYSQLND
- unsigned long max_buffer_size;
+ zend_ulong max_buffer_size;
#endif
pdo_mysql_error_info einfo;
@@ -122,9 +122,9 @@ typedef struct {
const MYSQL_FIELD *fields;
MYSQL_ROW current_data;
#if PDO_USE_MYSQLND
- unsigned long *current_lengths;
+ zend_ulong *current_lengths;
#else
- long *current_lengths;
+ zend_long *current_lengths;
#endif
pdo_mysql_error_info einfo;
#if PDO_USE_MYSQLND
@@ -136,11 +136,11 @@ typedef struct {
PDO_MYSQL_PARAM_BIND *params;
#ifndef PDO_USE_MYSQLND
my_bool *in_null;
- unsigned long *in_length;
+ zend_ulong *in_length;
#endif
PDO_MYSQL_PARAM_BIND *bound_result;
my_bool *out_null;
- unsigned long *out_length;
+ zend_ulong *out_length;
unsigned int params_given;
unsigned max_length:1;
} pdo_mysql_stmt;
diff --git a/ext/pdo_oci/oci_driver.c b/ext/pdo_oci/oci_driver.c
index a8e7913fa7..e9d297cab8 100644
--- a/ext/pdo_oci/oci_driver.c
+++ b/ext/pdo_oci/oci_driver.c
@@ -456,7 +456,7 @@ static int oci_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_
dbh->in_txn = 0;
}
- convert_to_long(val);
+ convert_to_int(val);
dbh->auto_commit = Z_LVAL_P(val);
return 1;
diff --git a/ext/pdo_odbc/odbc_driver.c b/ext/pdo_odbc/odbc_driver.c
index 2828b96e81..e99463de58 100644
--- a/ext/pdo_odbc/odbc_driver.c
+++ b/ext/pdo_odbc/odbc_driver.c
@@ -142,7 +142,7 @@ static int odbc_handle_closer(pdo_dbh_t *dbh TSRMLS_DC)
return 0;
}
-static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
+static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{
RETCODE rc;
pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
@@ -220,7 +220,7 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, p
return 1;
}
-static long odbc_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC)
+static zend_long odbc_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len TSRMLS_DC)
{
pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
RETCODE rc;
@@ -336,7 +336,7 @@ static int odbc_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC)
return 1;
}
-static int odbc_handle_set_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC)
+static int odbc_handle_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC)
{
pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
switch (attr) {
@@ -351,7 +351,7 @@ static int odbc_handle_set_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC)
}
}
-static int odbc_handle_get_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC)
+static int odbc_handle_get_attr(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC)
{
pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
switch (attr) {
diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c
index ea5650923c..274ce9b0d6 100644
--- a/ext/pdo_odbc/odbc_stmt.c
+++ b/ext/pdo_odbc/odbc_stmt.c
@@ -58,7 +58,7 @@ static int pdo_odbc_sqltype_is_unicode(pdo_odbc_stmt *S, SWORD sqltype)
}
static int pdo_odbc_utf82ucs2(pdo_stmt_t *stmt, int is_unicode, const char *buf,
- unsigned long buflen, unsigned long *outlen)
+ zend_ulong buflen, zend_ulong *outlen)
{
#ifdef PHP_WIN32
if (is_unicode && buflen) {
@@ -93,7 +93,7 @@ static int pdo_odbc_utf82ucs2(pdo_stmt_t *stmt, int is_unicode, const char *buf,
}
static int pdo_odbc_ucs22utf8(pdo_stmt_t *stmt, int is_unicode, const char *buf,
- unsigned long buflen, unsigned long *outlen)
+ zend_ulong buflen, zend_ulong *outlen)
{
#ifdef PHP_WIN32
if (is_unicode && buflen) {
@@ -190,7 +190,7 @@ static int odbc_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
}
if (Z_TYPE_P(parameter) != IS_RESOURCE) {
/* they passed in a string */
- unsigned long ulen;
+ zend_ulong ulen;
convert_to_string(parameter);
switch (pdo_odbc_utf82ucs2(stmt, P->is_unicode,
@@ -458,7 +458,7 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p
} else {
convert_to_string(parameter);
if (P->outbuf) {
- unsigned long ulen;
+ zend_ulong ulen;
switch (pdo_odbc_utf82ucs2(stmt, P->is_unicode,
Z_STRVAL_P(parameter),
Z_STRLEN_P(parameter),
@@ -483,9 +483,9 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p
P = param->driver_data;
if (P->outbuf) {
- unsigned long ulen;
+ zend_ulong ulen;
char *srcbuf;
- unsigned long srclen = 0;
+ zend_ulong srclen = 0;
if (Z_ISREF(param->parameter)) {
parameter = Z_REFVAL(param->parameter);
@@ -512,7 +512,7 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p
break;
}
- ZVAL_NEW_STR(parameter, STR_ALLOC(srclen, 0));
+ ZVAL_NEW_STR(parameter, zend_string_alloc(srclen, 0));
memcpy(Z_STRVAL_P(parameter), srcbuf, srclen);
Z_STRVAL_P(parameter)[Z_STRLEN_P(parameter)] = '\0';
}
@@ -524,7 +524,7 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p
}
static int odbc_stmt_fetch(pdo_stmt_t *stmt,
- enum pdo_fetch_orientation ori, long offset TSRMLS_DC)
+ enum pdo_fetch_orientation ori, zend_long offset TSRMLS_DC)
{
RETCODE rc;
SQLSMALLINT odbcori;
@@ -628,15 +628,15 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
return 1;
}
-static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len, int *caller_frees TSRMLS_DC)
+static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, zend_ulong *len, int *caller_frees TSRMLS_DC)
{
pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;
pdo_odbc_column *C = &S->cols[colno];
- unsigned long ulen;
+ zend_ulong ulen;
/* if it is a column containing "long" data, perform late binding now */
if (C->is_long) {
- unsigned long used = 0;
+ zend_ulong used = 0;
char *buf;
RETCODE rc;
@@ -755,7 +755,7 @@ in_data:
return 1;
}
-static int odbc_stmt_set_param(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC)
+static int odbc_stmt_set_param(pdo_stmt_t *stmt, zend_long attr, zval *val TSRMLS_DC)
{
SQLRETURN rc;
pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;
@@ -782,7 +782,7 @@ static int odbc_stmt_set_param(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC)
}
}
-static int odbc_stmt_get_attr(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC)
+static int odbc_stmt_get_attr(pdo_stmt_t *stmt, zend_long attr, zval *val TSRMLS_DC)
{
SQLRETURN rc;
pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;
diff --git a/ext/pdo_odbc/php_pdo_odbc_int.h b/ext/pdo_odbc/php_pdo_odbc_int.h
index 5e42951f86..90d9d5d505 100644
--- a/ext/pdo_odbc/php_pdo_odbc_int.h
+++ b/ext/pdo_odbc/php_pdo_odbc_int.h
@@ -135,7 +135,7 @@ typedef struct {
typedef struct {
char *data;
- unsigned long datalen;
+ zend_ulong datalen;
SQLLEN fetched_len;
SWORD coltype;
char colname[128];
@@ -150,7 +150,7 @@ typedef struct {
pdo_odbc_db_handle *H;
pdo_odbc_errinfo einfo;
char *convbuf;
- unsigned long convbufsize;
+ zend_ulong convbufsize;
unsigned going_long:1;
unsigned assume_utf8:1;
unsigned _spare:30;
diff --git a/ext/pdo_pgsql/pdo_pgsql.c b/ext/pdo_pgsql/pdo_pgsql.c
index fe003f8ab9..5fbad7d4a0 100644
--- a/ext/pdo_pgsql/pdo_pgsql.c
+++ b/ext/pdo_pgsql/pdo_pgsql.c
@@ -87,11 +87,11 @@ PHP_MINIT_FUNCTION(pdo_pgsql)
{
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT", PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT);
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_ATTR_DISABLE_PREPARES", PDO_PGSQL_ATTR_DISABLE_PREPARES);
- REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_IDLE", (long)PGSQL_TRANSACTION_IDLE);
- REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_ACTIVE", (long)PGSQL_TRANSACTION_ACTIVE);
- REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INTRANS", (long)PGSQL_TRANSACTION_INTRANS);
- REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INERROR", (long)PGSQL_TRANSACTION_INERROR);
- REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_UNKNOWN", (long)PGSQL_TRANSACTION_UNKNOWN);
+ REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_IDLE", (zend_long)PGSQL_TRANSACTION_IDLE);
+ REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_ACTIVE", (zend_long)PGSQL_TRANSACTION_ACTIVE);
+ REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INTRANS", (zend_long)PGSQL_TRANSACTION_INTRANS);
+ REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INERROR", (zend_long)PGSQL_TRANSACTION_INERROR);
+ REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_UNKNOWN", (zend_long)PGSQL_TRANSACTION_UNKNOWN);
php_pdo_register_driver(&pdo_pgsql_driver);
return SUCCESS;
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c
index 4ab3bdb6d6..fe23e5fac2 100644
--- a/ext/pdo_pgsql/pgsql_driver.c
+++ b/ext/pdo_pgsql/pgsql_driver.c
@@ -151,8 +151,8 @@ static int pgsql_lob_flush(php_stream *stream TSRMLS_DC)
return 0;
}
-static int pgsql_lob_seek(php_stream *stream, off_t offset, int whence,
- off_t *newoffset TSRMLS_DC)
+static int pgsql_lob_seek(php_stream *stream, zend_off_t offset, int whence,
+ zend_off_t *newoffset TSRMLS_DC)
{
struct pdo_pgsql_lob_self *self = (struct pdo_pgsql_lob_self*)stream->abstract;
int pos = lo_lseek(self->conn, self->lfd, offset, whence);
@@ -214,7 +214,7 @@ static int pgsql_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
}
/* }}} */
-static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
+static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
pdo_pgsql_stmt *S = ecalloc(1, sizeof(pdo_pgsql_stmt));
@@ -287,11 +287,11 @@ static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
return 1;
}
-static long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC)
+static zend_long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len TSRMLS_DC)
{
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
PGresult *res;
- long ret = 1;
+ zend_long ret = 1;
ExecStatusType qs;
if (!(res = PQexec(H->server, sql))) {
@@ -306,7 +306,11 @@ static long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM
return -1;
}
H->pgoid = PQoidValue(res);
- ret = (qs == PGRES_COMMAND_OK) ? atol(PQcmdTuples(res)) : 0L;
+ if (qs == PGRES_COMMAND_OK) {
+ ZEND_ATOL(ret, PQcmdTuples(res));
+ } else {
+ ret = Z_I(0);
+ }
PQclear(res);
return ret;
@@ -350,7 +354,7 @@ static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned
if (H->pgoid == InvalidOid) {
return NULL;
}
- *len = spprintf(&id, 0, "%ld", (long) H->pgoid);
+ *len = spprintf(&id, 0, ZEND_LONG_FMT, (zend_long) H->pgoid);
} else {
PGresult *res;
ExecStatusType status;
@@ -373,7 +377,7 @@ static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned
return id;
}
-static int pdo_pgsql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value TSRMLS_DC)
+static int pdo_pgsql_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_value TSRMLS_DC)
{
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
@@ -906,7 +910,7 @@ static PHP_METHOD(PDO, pgsqlLOBCreate)
lfd = lo_creat(H->server, INV_READ|INV_WRITE);
if (lfd != InvalidOid) {
- zend_string *buf = strpprintf(0, "%lu", (long) lfd);
+ zend_string *buf = strpprintf(0, ZEND_ULONG_FMT, (zend_long) lfd);
RETURN_STR(buf);
}
@@ -1011,8 +1015,8 @@ static PHP_METHOD(PDO, pgsqlGetNotify)
{
pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H;
- long result_type = PDO_FETCH_USE_DEFAULT;
- long ms_timeout = 0;
+ zend_long result_type = PDO_FETCH_USE_DEFAULT;
+ zend_long ms_timeout = 0;
PGnotify *pgsql_notify;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll",
@@ -1107,22 +1111,22 @@ static const zend_function_entry *pdo_pgsql_get_driver_methods(pdo_dbh_t *dbh, i
}
}
-static int pdo_pgsql_set_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC)
+static int pdo_pgsql_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC)
{
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
switch (attr) {
case PDO_ATTR_EMULATE_PREPARES:
- convert_to_long(val);
+ convert_to_int(val);
H->emulate_prepares = Z_LVAL_P(val);
return 1;
case PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT:
- convert_to_long(val);
+ convert_to_int(val);
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead");
H->disable_native_prepares = Z_LVAL_P(val);
return 1;
case PDO_PGSQL_ATTR_DISABLE_PREPARES:
- convert_to_long(val);
+ convert_to_int(val);
H->disable_prepares = Z_LVAL_P(val);
return 1;
default:
@@ -1154,7 +1158,7 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
int ret = 0;
char *conn_str, *p, *e;
char *tmp_pass;
- long connect_timeout = 30;
+ zend_long connect_timeout = 30;
H = pecalloc(1, sizeof(pdo_pgsql_db_handle), dbh->is_persistent);
dbh->driver_data = H;
@@ -1200,13 +1204,13 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
/* support both full connection string & connection string + login and/or password */
if (dbh->username && dbh->password) {
- spprintf(&conn_str, 0, "%s user=%s password=%s connect_timeout=%ld", dbh->data_source, dbh->username, tmp_pass, connect_timeout);
+ spprintf(&conn_str, 0, "%s user=%s password=%s connect_timeout=%pd", dbh->data_source, dbh->username, tmp_pass, connect_timeout);
} else if (dbh->username) {
- spprintf(&conn_str, 0, "%s user=%s connect_timeout=%ld", dbh->data_source, dbh->username, connect_timeout);
+ spprintf(&conn_str, 0, "%s user=%s connect_timeout=%pd", dbh->data_source, dbh->username, connect_timeout);
} else if (dbh->password) {
- spprintf(&conn_str, 0, "%s password=%s connect_timeout=%ld", dbh->data_source, tmp_pass, connect_timeout);
+ spprintf(&conn_str, 0, "%s password=%s connect_timeout=%pd", dbh->data_source, tmp_pass, connect_timeout);
} else {
- spprintf(&conn_str, 0, "%s connect_timeout=%ld", (char *) dbh->data_source, connect_timeout);
+ spprintf(&conn_str, 0, "%s connect_timeout=%pd", (char *) dbh->data_source, connect_timeout);
}
H->server = PQconnectdb(conn_str);
diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c
index 10e775d899..7a315c7f08 100644
--- a/ext/pdo_pgsql/pgsql_statement.c
+++ b/ext/pdo_pgsql/pgsql_statement.c
@@ -230,10 +230,10 @@ stmt_retry:
}
if (status == PGRES_COMMAND_OK) {
- stmt->row_count = (long)atoi(PQcmdTuples(S->result));
+ ZEND_ATOL(stmt->row_count, PQcmdTuples(S->result));
H->pgoid = PQoidValue(S->result);
} else {
- stmt->row_count = (long)PQntuples(S->result);
+ stmt->row_count = (zend_long)PQntuples(S->result);
}
return 1;
@@ -256,14 +256,15 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
/* decode name from $1, $2 into 0, 1 etc. */
if (param->name) {
if (param->name->val[0] == '$') {
- param->paramno = atoi(param->name->val + 1);
+ ZEND_ATOL(param->paramno, param->name->val + 1);
} else {
/* resolve parameter name to rewritten name */
char *namevar;
if (stmt->bound_param_map && (namevar = zend_hash_find_ptr(stmt->bound_param_map,
param->name)) != NULL) {
- param->paramno = atoi(namevar + 1) - 1;
+ ZEND_ATOL(param->paramno, namevar + 1);
+ param->paramno--;
} else {
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", param->name->val TSRMLS_CC);
return 0;
@@ -390,7 +391,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
}
static int pgsql_stmt_fetch(pdo_stmt_t *stmt,
- enum pdo_fetch_orientation ori, long offset TSRMLS_DC)
+ enum pdo_fetch_orientation ori, zend_long offset TSRMLS_DC)
{
pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data;
@@ -404,8 +405,8 @@ static int pgsql_stmt_fetch(pdo_stmt_t *stmt,
case PDO_FETCH_ORI_PRIOR: spprintf(&ori_str, 0, "BACKWARD"); break;
case PDO_FETCH_ORI_FIRST: spprintf(&ori_str, 0, "FIRST"); break;
case PDO_FETCH_ORI_LAST: spprintf(&ori_str, 0, "LAST"); break;
- case PDO_FETCH_ORI_ABS: spprintf(&ori_str, 0, "ABSOLUTE %ld", offset); break;
- case PDO_FETCH_ORI_REL: spprintf(&ori_str, 0, "RELATIVE %ld", offset); break;
+ case PDO_FETCH_ORI_ABS: spprintf(&ori_str, 0, "ABSOLUTE %pd", offset); break;
+ case PDO_FETCH_ORI_REL: spprintf(&ori_str, 0, "RELATIVE %pd", offset); break;
default:
return 0;
}
@@ -479,7 +480,7 @@ static int pgsql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
break;
case INT8OID:
- if (sizeof(long)>=8) {
+ if (sizeof(zend_long)>=8) {
cols[colno].param_type = PDO_PARAM_INT;
} else {
cols[colno].param_type = PDO_PARAM_STR;
@@ -497,7 +498,7 @@ static int pgsql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
return 1;
}
-static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len, int *caller_frees TSRMLS_DC)
+static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, zend_ulong *len, int *caller_frees TSRMLS_DC)
{
pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data;
struct pdo_column_data *cols = stmt->columns;
@@ -518,9 +519,9 @@ static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned
switch (cols[colno].param_type) {
case PDO_PARAM_INT:
- S->cols[colno].intval = atol(*ptr);
+ ZEND_ATOL(S->cols[colno].intval, *ptr);
*ptr = (char *) &(S->cols[colno].intval);
- *len = sizeof(long);
+ *len = sizeof(zend_long);
break;
case PDO_PARAM_BOOL:
@@ -576,7 +577,7 @@ static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned
return 1;
}
-static int pgsql_stmt_get_column_meta(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC)
+static int pgsql_stmt_get_column_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value TSRMLS_DC)
{
pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data;
PGresult *res;
diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h
index 4d0652049e..d6f7ad48aa 100644
--- a/ext/pdo_pgsql/php_pdo_pgsql_int.h
+++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h
@@ -54,7 +54,7 @@ typedef struct {
typedef struct {
char *def;
Oid pgsql_type;
- long intval;
+ zend_long intval;
zend_bool boolval;
} pdo_pgsql_column;
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c
index 9b47af562c..da69448d5d 100644
--- a/ext/pdo_sqlite/sqlite_driver.c
+++ b/ext/pdo_sqlite/sqlite_driver.c
@@ -175,7 +175,7 @@ static int sqlite_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
}
/* }}} */
-static int sqlite_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
+static int sqlite_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{
pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
pdo_sqlite_stmt *S = ecalloc(1, sizeof(pdo_sqlite_stmt));
@@ -203,7 +203,7 @@ static int sqlite_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
return 0;
}
-static long sqlite_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC)
+static zend_long sqlite_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len TSRMLS_DC)
{
pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
char *errmsg = NULL;
@@ -280,7 +280,7 @@ static int sqlite_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC)
return 1;
}
-static int pdo_sqlite_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value TSRMLS_DC)
+static int pdo_sqlite_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_value TSRMLS_DC)
{
switch (attr) {
case PDO_ATTR_CLIENT_VERSION:
@@ -295,13 +295,13 @@ static int pdo_sqlite_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_valu
return 1;
}
-static int pdo_sqlite_set_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC)
+static int pdo_sqlite_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC)
{
pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
switch (attr) {
case PDO_ATTR_TIMEOUT:
- convert_to_long(val);
+ convert_to_int(val);
sqlite3_busy_timeout(H->db, Z_LVAL_P(val) * 1000);
return 1;
}
@@ -497,7 +497,7 @@ static int php_sqlite3_collation_callback(void *context,
php_error_docref(NULL TSRMLS_CC, E_WARNING, "An error occurred while invoking the callback");
} else if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
- convert_to_long_ex(&retval);
+ convert_to_int_ex(&retval);
}
ret = 0;
if (Z_LVAL(retval) > 0) {
@@ -522,7 +522,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
zval *callback;
char *func_name;
int func_name_len;
- long argc = -1;
+ zend_long argc = -1;
zend_string *cbname = NULL;
pdo_dbh_t *dbh;
pdo_sqlite_db_handle *H;
@@ -538,10 +538,10 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
if (!zend_is_callable(callback, 0, &cbname TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname->val);
- STR_RELEASE(cbname);
+ zend_string_release(cbname);
RETURN_FALSE;
}
- STR_RELEASE(cbname);
+ zend_string_release(cbname);
H = (pdo_sqlite_db_handle *)dbh->driver_data;
@@ -592,7 +592,7 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
zval *step_callback, *fini_callback;
char *func_name;
int func_name_len;
- long argc = -1;
+ zend_long argc = -1;
zend_string *cbname = NULL;
pdo_dbh_t *dbh;
pdo_sqlite_db_handle *H;
@@ -608,16 +608,16 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
if (!zend_is_callable(step_callback, 0, &cbname TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname->val);
- STR_RELEASE(cbname);
+ zend_string_release(cbname);
RETURN_FALSE;
}
- STR_RELEASE(cbname);
+ zend_string_release(cbname);
if (!zend_is_callable(fini_callback, 0, &cbname TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname->val);
- STR_RELEASE(cbname);
+ zend_string_release(cbname);
RETURN_FALSE;
}
- STR_RELEASE(cbname);
+ zend_string_release(cbname);
H = (pdo_sqlite_db_handle *)dbh->driver_data;
@@ -668,10 +668,10 @@ static PHP_METHOD(SQLite, sqliteCreateCollation)
if (!zend_is_callable(callback, 0, &cbname TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname->val);
- STR_RELEASE(cbname);
+ zend_string_release(cbname);
RETURN_FALSE;
}
- STR_RELEASE(cbname);
+ zend_string_release(cbname);
H = (pdo_sqlite_db_handle *)dbh->driver_data;
@@ -792,7 +792,7 @@ static int pdo_sqlite_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS
{
pdo_sqlite_db_handle *H;
int i, ret = 0;
- long timeout = 60;
+ zend_long timeout = 60;
char *filename;
H = pecalloc(1, sizeof(pdo_sqlite_db_handle), dbh->is_persistent);
diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c
index 5f18c8a0cf..feaff73b94 100644
--- a/ext/pdo_sqlite/sqlite_statement.c
+++ b/ext/pdo_sqlite/sqlite_statement.c
@@ -117,8 +117,8 @@ static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_d
return 1;
}
} else {
- convert_to_long(parameter);
-#if LONG_MAX > 2147483647
+ convert_to_int(parameter);
+#if ZEND_LONG_MAX > 2147483647
if (SQLITE_OK == sqlite3_bind_int64(S->stmt, param->paramno + 1, Z_LVAL_P(parameter))) {
return 1;
}
@@ -198,7 +198,7 @@ static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_d
}
static int pdo_sqlite_stmt_fetch(pdo_stmt_t *stmt,
- enum pdo_fetch_orientation ori, long offset TSRMLS_DC)
+ enum pdo_fetch_orientation ori, zend_long offset TSRMLS_DC)
{
pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
int i;
@@ -259,7 +259,7 @@ static int pdo_sqlite_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
return 1;
}
-static int pdo_sqlite_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len, int *caller_frees TSRMLS_DC)
+static int pdo_sqlite_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, zend_ulong *len, int *caller_frees TSRMLS_DC)
{
pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
if (!S->stmt) {
@@ -288,7 +288,7 @@ static int pdo_sqlite_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsi
}
}
-static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC)
+static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value TSRMLS_DC)
{
pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
const char *str;
diff --git a/ext/pgsql/config.w32 b/ext/pgsql/config.w32
index ee5fd8bb31..d38048d90b 100644
--- a/ext/pgsql/config.w32
+++ b/ext/pgsql/config.w32
@@ -8,7 +8,7 @@ if (PHP_PGSQL != "no") {
CHECK_HEADER_ADD_INCLUDE("libpq-fe.h", "CFLAGS_PGSQL", PHP_PGSQL + "\\include;" + PHP_PHP_BUILD + "\\include\\pgsql;" + PHP_PHP_BUILD + "\\include\\libpq;" + PHP_PGSQL)) {
EXTENSION("pgsql", "pgsql.c");
AC_DEFINE('HAVE_PGSQL', 1, 'Have PostgreSQL library');
- ADD_FLAG("CFLAGS_PGSQL", "/D HAVE_PG_CONFIG_H /D PGSQL_EXPORTS /D HAVE_PQSETNONBLOCKING /D HAVE_PQCMDTUPLES /D HAVE_PQCLIENTENCODING /D HAVE_PQESCAPE /D HAVE_PQPARAMETERSTATUS /D HAVE_PGTRANSACTIONSTATUS /D HAVE_PQEXECPARAMS /D HAVE_PQPREPARE /D HAVE_PQEXECPREPARED /D HAVE_PQRESULTERRORFIELD /D HAVE_PQSENDQUERYPARAMS /D HAVE_PQSENDPREPARE /D HAVE_PQSENDQUERYPREPARED /D HAVE_PQPUTCOPYDATA /D HAVE_PQPUTCOPYEND /D HAVE_PQGETCOPYDATA /D HAVE_PQSETERRORVERBOSITY /D HAVE_PQUNESCAPEBYTEA /D HAVE_PQFTABLE /D HAVE_PQESCAPE_CONN /D HAVE_PQESCAPE_BYTEA_CONN /D HAVE_PQFREEMEM /D HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT /D HAVE_PQPROTOCOLVERSION /D HAVE_PG_LO_CREATE /D HAVE_PG_LO_IMPORT_WITH_OID /D HAVE_PG_LO_TRUNCATE /D HAVE_PG_LO64 /D HAVE_PQESCAPELITERAL");
+ ADD_FLAG("CFLAGS_PGSQL", "/D HAVE_PG_CONFIG_H /D PGSQL_EXPORTS /D HAVE_PQSETNONBLOCKING /D HAVE_PQCMDTUPLES /D HAVE_PQCLIENTENCODING /D HAVE_PQESCAPE /D HAVE_PQPARAMETERSTATUS /D HAVE_PGTRANSACTIONSTATUS /D HAVE_PQEXECPARAMS /D HAVE_PQPREPARE /D HAVE_PQEXECPREPARED /D HAVE_PQRESULTERRORFIELD /D HAVE_PQSENDQUERYPARAMS /D HAVE_PQSENDPREPARE /D HAVE_PQSENDQUERYPREPARED /D HAVE_PQPUTCOPYDATA /D HAVE_PQPUTCOPYEND /D HAVE_PQGETCOPYDATA /D HAVE_PQSETERRORVERBOSITY /D HAVE_PQUNESCAPEBYTEA /D HAVE_PQFTABLE /D HAVE_PQESCAPE_CONN /D HAVE_PQESCAPE_BYTEA_CONN /D HAVE_PQFREEMEM /D HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT /D HAVE_PQPROTOCOLVERSION /D HAVE_PG_LO_CREATE /D HAVE_PG_LO_IMPORT_WITH_OID /D HAVE_PG_LO_TRUNCATE /D HAVE_PG_LO64 /D HAVE_PQESCAPELITERAL /D HAVE_PQOIDVALUE");
} else {
WARNING("pgsql not enabled; libraries and headers not found");
}
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 40f24ff940..03a4051efb 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -66,18 +66,18 @@
#define PGSQL_MAX_LENGTH_OF_LONG 30
#define PGSQL_MAX_LENGTH_OF_DOUBLE 60
-#if LONG_MAX < UINT_MAX
+#if ZEND_LONG_MAX < UINT_MAX
#define PGSQL_RETURN_OID(oid) do { \
- if (oid > LONG_MAX) { \
+ if (oid > ZEND_LONG_MAX) { \
smart_str s = {0}; \
smart_str_append_unsigned(&s, oid); \
smart_str_0(&s); \
RETURN_STR(s.s); \
} \
- RETURN_LONG((long)oid); \
+ RETURN_LONG((zend_long)oid); \
} while(0)
#else
-#define PGSQL_RETURN_OID(oid) (RETURN_LONG((long)oid))
+#define PGSQL_RETURN_OID(oid) RETURN_LONG((zend_long)oid)
#endif
#if HAVE_PQSETNONBLOCKING
@@ -968,7 +968,7 @@ static void _php_pgsql_notice_handler(void *resource_id, const char *message)
if (PGG(log_notices)) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s", notice->message);
}
- zend_hash_index_update_ptr(&PGG(notices), (ulong)resource_id, notice);
+ zend_hash_index_update_ptr(&PGG(notices), (zend_ulong)resource_id, notice);
}
}
/* }}} */
@@ -1254,9 +1254,9 @@ PHP_MINFO_FUNCTION(pgsql)
php_info_print_table_row(2, "SSL support", "disabled");
#endif
#endif /* HAVE_PG_CONFIG_H */
- snprintf(buf, sizeof(buf), "%ld", PGG(num_persistent));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, PGG(num_persistent));
php_info_print_table_row(2, "Active Persistent Links", buf);
- snprintf(buf, sizeof(buf), "%ld", PGG(num_links));
+ snprintf(buf, sizeof(buf), ZEND_LONG_FMT, PGG(num_links));
php_info_print_table_row(2, "Active Links", buf);
php_info_print_table_end();
@@ -1306,7 +1306,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
connstring = Z_STRVAL(args[0]);
} else if (ZEND_NUM_ARGS() == 2 ) { /* Safe to add conntype_option, since 2 args was illegal */
connstring = Z_STRVAL(args[0]);
- convert_to_long_ex(&args[1]);
+ convert_to_int_ex(&args[1]);
connect_type = Z_LVAL(args[1]);
} else {
host = Z_STRVAL(args[0]);
@@ -1333,12 +1333,12 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
if (PGG(max_links) != -1 && PGG(num_links) >= PGG(max_links)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
- "Cannot create new link. Too many open links (%ld)", PGG(num_links));
+ "Cannot create new link. Too many open links (%pd)", PGG(num_links));
goto err;
}
if (PGG(max_persistent) != -1 && PGG(num_persistent) >= PGG(max_persistent)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
- "Cannot create new link. Too many open persistent links (%ld)", PGG(num_persistent));
+ "Cannot create new link. Too many open persistent links (%pd)", PGG(num_persistent));
goto err;
}
@@ -1431,7 +1431,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
}
if (PGG(max_links) != -1 && PGG(num_links) >= PGG(max_links)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create new link. Too many open links (%ld)", PGG(num_links));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create new link. Too many open links (%pd)", PGG(num_links));
goto err;
}
@@ -2387,7 +2387,7 @@ PHP_FUNCTION(pg_field_table)
{
zval *result;
pgsql_result_handle *pg_result;
- long fnum = -1;
+ zend_long fnum = -1;
zend_bool return_oid = 0;
Oid oid;
smart_str hash_key = {0};
@@ -2412,15 +2412,15 @@ PHP_FUNCTION(pg_field_table)
}
if (return_oid) {
-#if UINT_MAX > LONG_MAX /* Oid is unsigned int, we don't need this code, where LONG is wider */
- if (oid > LONG_MAX) {
+#if UINT_MAX > ZEND_LONG_MAX /* Oid is unsigned int, we don't need this code, where LONG is wider */
+ if (oid > ZEND_LONG_MAX) {
smart_str oidstr = {0};
smart_str_append_unsigned(&oidstr, oid);
smart_str_0(&oidstr);
RETURN_STR(oidstr.s);
} else
#endif
- RETURN_LONG((long)oid);
+ RETURN_LONG((zend_long)oid);
}
/* try to lookup the table name in the resource list */
@@ -2480,7 +2480,7 @@ PHP_FUNCTION(pg_field_table)
static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
{
zval *result;
- long field;
+ zend_long field;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
Oid oid;
@@ -2514,8 +2514,8 @@ static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_typ
case PHP_PG_FIELD_TYPE_OID:
oid = PQftype(pgsql_result, field);
-#if UINT_MAX > LONG_MAX
- if (oid > LONG_MAX) {
+#if UINT_MAX > ZEND_LONG_MAX
+ if (oid > ZEND_LONG_MAX) {
smart_str s = {0};
smart_str_append_unsigned(&s, oid);
smart_str_0(&s);
@@ -2591,7 +2591,7 @@ PHP_FUNCTION(pg_field_num)
PHP_FUNCTION(pg_fetch_result)
{
zval *result, *field=NULL;
- long row;
+ zend_long row;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
int field_offset, pgsql_row, argc = ZEND_NUM_ARGS();
@@ -2620,7 +2620,7 @@ PHP_FUNCTION(pg_fetch_result)
} else {
pgsql_row = row;
if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %ld on PostgreSQL result index %ld",
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %pd on PostgreSQL result index %pd",
row, Z_LVAL_P(result));
RETURN_FALSE;
}
@@ -2630,7 +2630,7 @@ PHP_FUNCTION(pg_fetch_result)
field_offset = PQfnumber(pgsql_result, Z_STRVAL_P(field));
break;
default:
- convert_to_long_ex(field);
+ convert_to_int_ex(field);
field_offset = Z_LVAL_P(field);
break;
}
@@ -2649,13 +2649,13 @@ PHP_FUNCTION(pg_fetch_result)
/* }}} */
/* {{{ void php_pgsql_fetch_hash */
-static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, int into_object)
+static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_type, int into_object)
{
zval *result, *zrow = NULL;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
int i, num_fields, pgsql_row, use_row;
- long row = -1;
+ zend_long row = -1;
char *field_name;
zval *ctor_params = NULL;
zend_class_entry *ce = NULL;
@@ -2684,7 +2684,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type,
if (zrow == NULL) {
row = -1;
} else {
- convert_to_long(zrow);
+ convert_to_int(zrow);
row = Z_LVAL_P(zrow);
if (row < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The row parameter must be greater or equal to zero");
@@ -2706,7 +2706,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type,
pgsql_row = row;
pg_result->row = pgsql_row;
if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %ld on PostgreSQL result index %ld",
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %pd on PostgreSQL result index %pd",
row, Z_LVAL_P(result));
RETURN_FALSE;
}
@@ -2876,7 +2876,7 @@ PHP_FUNCTION(pg_fetch_all_columns)
zval *result;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
- unsigned long colno=0;
+ zend_long colno=0;
int pg_numrows, pg_row;
size_t num_fields;
@@ -2890,7 +2890,7 @@ PHP_FUNCTION(pg_fetch_all_columns)
num_fields = PQnfields(pgsql_result);
if (colno >= num_fields || colno < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid column number '%ld'", colno);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid column number '%pd'", colno);
RETURN_FALSE;
}
@@ -2915,7 +2915,7 @@ PHP_FUNCTION(pg_fetch_all_columns)
PHP_FUNCTION(pg_result_seek)
{
zval *result;
- long row;
+ zend_long row;
pgsql_result_handle *pg_result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &result, &row) == FAILURE) {
@@ -2942,7 +2942,7 @@ PHP_FUNCTION(pg_result_seek)
static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
{
zval *result, *field;
- long row;
+ zend_long row;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
int field_offset, pgsql_row, argc = ZEND_NUM_ARGS();
@@ -2971,7 +2971,7 @@ static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
} else {
pgsql_row = row;
if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %ld on PostgreSQL result index %ld",
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %pd on PostgreSQL result index %pd",
row, Z_LVAL_P(result));
RETURN_FALSE;
}
@@ -2983,7 +2983,7 @@ static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
field_offset = PQfnumber(pgsql_result, Z_STRVAL_P(field));
break;
default:
- convert_to_long_ex(field);
+ convert_to_int_ex(field);
field_offset = Z_LVAL_P(field);
break;
}
@@ -3187,7 +3187,7 @@ PHP_FUNCTION(pg_lo_create)
}
break;
case IS_LONG:
- if (Z_LVAL_P(oid) < (long)InvalidOid) {
+ if (Z_LVAL_P(oid) < (zend_long)InvalidOid) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
@@ -3220,7 +3220,7 @@ PHP_FUNCTION(pg_lo_create)
PHP_FUNCTION(pg_lo_unlink)
{
zval *pgsql_link = NULL;
- long oid_long;
+ zend_long oid_long;
char *oid_string, *end_ptr;
int oid_strlen;
PGconn *pgsql;
@@ -3290,7 +3290,7 @@ PHP_FUNCTION(pg_lo_unlink)
PHP_FUNCTION(pg_lo_open)
{
zval *pgsql_link = NULL;
- long oid_long;
+ zend_long oid_long;
char *oid_string, *end_ptr, *mode_string;
int oid_strlen, mode_strlen;
PGconn *pgsql;
@@ -3437,7 +3437,7 @@ PHP_FUNCTION(pg_lo_close)
PHP_FUNCTION(pg_lo_read)
{
zval *pgsql_id;
- long len;
+ zend_long len;
int buf_len = PGSQL_LO_READ_BUF_SIZE, nbytes, argc = ZEND_NUM_ARGS();
zend_string *buf;
pgLofp *pgsql;
@@ -3452,9 +3452,9 @@ PHP_FUNCTION(pg_lo_read)
buf_len = len;
}
- buf = STR_ALLOC(buf_len, 0);
+ buf = zend_string_alloc(buf_len, 0);
if ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf->val, buf->len))<0) {
- STR_FREE(buf);
+ zend_string_free(buf);
RETURN_FALSE;
}
@@ -3470,7 +3470,7 @@ PHP_FUNCTION(pg_lo_write)
{
zval *pgsql_id;
char *str;
- long z_len;
+ zend_long z_len;
int str_len, nbytes;
int len;
pgLofp *pgsql;
@@ -3482,11 +3482,11 @@ PHP_FUNCTION(pg_lo_write)
if (argc > 2) {
if (z_len > str_len) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot write more than buffer size %d. Tried to write %ld", str_len, z_len);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot write more than buffer size %d. Tried to write %pd", str_len, z_len);
RETURN_FALSE;
}
if (z_len < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Buffer size must be larger than 0, but %ld was specified", z_len);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Buffer size must be larger than 0, but %pd was specified", z_len);
RETURN_FALSE;
}
len = z_len;
@@ -3587,7 +3587,7 @@ PHP_FUNCTION(pg_lo_import)
}
break;
case IS_LONG:
- if (Z_LVAL_P(oid) < (long)InvalidOid) {
+ if (Z_LVAL_P(oid) < (zend_long)InvalidOid) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
@@ -3625,7 +3625,7 @@ PHP_FUNCTION(pg_lo_export)
char *file_out, *oid_string, *end_ptr;
int oid_strlen;
int id = -1, name_len;
- long oid_long;
+ zend_long oid_long;
Oid oid;
PGconn *pgsql;
int argc = ZEND_NUM_ARGS();
@@ -3714,7 +3714,7 @@ PHP_FUNCTION(pg_lo_export)
PHP_FUNCTION(pg_lo_seek)
{
zval *pgsql_id = NULL;
- long result, offset = 0, whence = SEEK_CUR;
+ zend_long result, offset = 0, whence = SEEK_CUR;
pgLofp *pgsql;
int argc = ZEND_NUM_ARGS();
@@ -3814,7 +3814,7 @@ PHP_FUNCTION(pg_lo_truncate)
PHP_FUNCTION(pg_set_error_verbosity)
{
zval *pgsql_link = NULL;
- long verbosity;
+ zend_long verbosity;
int id = -1, argc = ZEND_NUM_ARGS();
PGconn *pgsql;
@@ -4268,7 +4268,7 @@ PHP_FUNCTION(pg_escape_string)
break;
}
- to = STR_ALLOC(from->len * 2, 0);
+ to = zend_string_alloc(from->len * 2, 0);
#ifdef HAVE_PQESCAPE_CONN
if (pgsql_link != NULL || id != -1) {
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
@@ -4279,7 +4279,7 @@ PHP_FUNCTION(pg_escape_string)
to->len = (int) PQescapeString(to->val, from->val, (size_t)from->len);
}
- to = STR_REALLOC(to, to->len, 0);
+ to = zend_string_realloc(to, to->len, 0);
RETURN_STR(to);
}
/* }}} */
@@ -4559,7 +4559,7 @@ PHP_FUNCTION(pg_result_error)
PHP_FUNCTION(pg_result_error_field)
{
zval *result;
- long fieldcode;
+ zend_long fieldcode;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
char *field = NULL;
@@ -5144,7 +5144,7 @@ PHP_FUNCTION(pg_get_result)
PHP_FUNCTION(pg_result_status)
{
zval *result;
- long result_type = PGSQL_STATUS_LONG;
+ zend_long result_type = PGSQL_STATUS_LONG;
ExecStatusType status;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
@@ -5177,7 +5177,7 @@ PHP_FUNCTION(pg_get_notify)
{
zval *pgsql_link;
int id = -1;
- long result_type = PGSQL_ASSOC;
+ zend_long result_type = PGSQL_ASSOC;
PGconn *pgsql;
PGnotify *pgsql_notify;
@@ -5708,10 +5708,10 @@ static int php_pgsql_add_quotes(zval *src, zend_bool should_free TSRMLS_DC)
/* {{{ php_pgsql_convert
* check and convert array values (fieldname=>vlaue pair) for sql
*/
-PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval *values, zval *result, ulong opt TSRMLS_DC)
+PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval *values, zval *result, zend_ulong opt TSRMLS_DC)
{
zend_string *field = NULL;
- ulong num_idx = -1;
+ zend_ulong num_idx = -1;
zval meta, *def, *type, *not_null, *has_default, *is_enum, *val, new_val;
int err = 0, skip_field;
php_pgsql_data_type data_type;
@@ -5859,7 +5859,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
case IS_DOUBLE:
ZVAL_DOUBLE(&new_val, Z_DVAL_P(val));
- convert_to_long_ex(&new_val);
+ convert_to_int_ex(&new_val);
break;
case IS_LONG:
@@ -5951,10 +5951,10 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
else {
zend_string *str;
/* PostgreSQL ignores \0 */
- str = STR_ALLOC(Z_STRLEN_P(val) * 2, 0);
+ str = zend_string_alloc(Z_STRLEN_P(val) * 2, 0);
/* better to use PGSQLescapeLiteral since PGescapeStringConn does not handle special \ */
str->len = (int)PQescapeStringConn(pg_link, str->val, Z_STRVAL_P(val), Z_STRLEN_P(val), NULL);
- str = STR_REALLOC(str, str->len, 0);
+ str = zend_string_realloc(str, str->len, 0);
ZVAL_STR(&new_val, str);
php_pgsql_add_quotes(&new_val, 1 TSRMLS_CC);
}
@@ -5998,14 +5998,14 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
}
else {
ZVAL_STRINGL(&new_val, Z_STRVAL_P(val), Z_STRLEN_P(val));
- convert_to_long_ex(&new_val);
+ convert_to_int_ex(&new_val);
}
}
break;
case IS_DOUBLE:
ZVAL_DOUBLE(&new_val, Z_DVAL_P(val));
- convert_to_long_ex(&new_val);
+ convert_to_int_ex(&new_val);
break;
case IS_LONG:
@@ -6352,7 +6352,7 @@ PHP_FUNCTION(pg_convert)
zval *pgsql_link, *values;
char *table_name;
int table_name_len;
- ulong option = 0;
+ zend_ulong option = 0;
PGconn *pg_link;
int id = -1;
@@ -6382,7 +6382,7 @@ PHP_FUNCTION(pg_convert)
}
/* }}} */
-static int do_exec(smart_str *querystr, int expect, PGconn *pg_link, ulong opt TSRMLS_DC) /* {{{ */
+static int do_exec(smart_str *querystr, int expect, PGconn *pg_link, zend_ulong opt TSRMLS_DC) /* {{{ */
{
if (opt & PGSQL_DML_ASYNC) {
if (PQsendQuery(pg_link, querystr->s->val)) {
@@ -6441,14 +6441,14 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* {{{ php_pgsql_insert
*/
-PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var_array, ulong opt, zend_string **sql TSRMLS_DC)
+PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var_array, zend_ulong opt, zend_string **sql TSRMLS_DC)
{
zval *val, converted;
char buf[256];
char *tmp;
smart_str querystr = {0};
int ret = FAILURE;
- ulong num_idx;
+ zend_ulong num_idx;
zend_string *fld;
assert(pg_link != NULL);
@@ -6563,7 +6563,7 @@ PHP_FUNCTION(pg_insert)
zval *pgsql_link, *values;
char *table;
int table_len;
- ulong option = PGSQL_DML_EXEC, return_sql;
+ zend_ulong option = PGSQL_DML_EXEC, return_sql;
PGconn *pg_link;
PGresult *pg_result;
ExecStatusType status;
@@ -6641,11 +6641,11 @@ PHP_FUNCTION(pg_insert)
}
/* }}} */
-static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr, HashTable *ht, int where_cond, const char *pad, int pad_len, ulong opt TSRMLS_DC) /* {{{ */
+static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr, HashTable *ht, int where_cond, const char *pad, int pad_len, zend_ulong opt TSRMLS_DC) /* {{{ */
{
char *tmp;
char buf[256];
- ulong num_idx;
+ zend_ulong num_idx;
zend_string *fld;
zval *val;
@@ -6706,7 +6706,7 @@ static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr,
/* {{{ php_pgsql_update
*/
-PHP_PGSQL_API int php_pgsql_update(PGconn *pg_link, const char *table, zval *var_array, zval *ids_array, ulong opt, zend_string **sql TSRMLS_DC)
+PHP_PGSQL_API int php_pgsql_update(PGconn *pg_link, const char *table, zval *var_array, zval *ids_array, zend_ulong opt, zend_string **sql TSRMLS_DC)
{
zval var_converted, ids_converted;
smart_str querystr = {0};
@@ -6779,7 +6779,7 @@ PHP_FUNCTION(pg_update)
zval *pgsql_link, *values, *ids;
char *table;
int table_len;
- ulong option = PGSQL_DML_EXEC;
+ zend_ulong option = PGSQL_DML_EXEC;
PGconn *pg_link;
zend_string *sql = NULL;
int id = -1, argc = ZEND_NUM_ARGS();
@@ -6810,7 +6810,7 @@ PHP_FUNCTION(pg_update)
/* {{{ php_pgsql_delete
*/
-PHP_PGSQL_API int php_pgsql_delete(PGconn *pg_link, const char *table, zval *ids_array, ulong opt, zend_string **sql TSRMLS_DC)
+PHP_PGSQL_API int php_pgsql_delete(PGconn *pg_link, const char *table, zval *ids_array, zend_ulong opt, zend_string **sql TSRMLS_DC)
{
zval ids_converted;
smart_str querystr = {0};
@@ -6869,7 +6869,7 @@ PHP_FUNCTION(pg_delete)
zval *pgsql_link, *ids;
char *table;
int table_len;
- ulong option = PGSQL_DML_EXEC;
+ zend_ulong option = PGSQL_DML_EXEC;
PGconn *pg_link;
zend_string *sql;
int id = -1, argc = ZEND_NUM_ARGS();
@@ -6936,7 +6936,7 @@ PHP_PGSQL_API int php_pgsql_result2array(PGresult *pg_result, zval *ret_array TS
/* {{{ php_pgsql_select
*/
-PHP_PGSQL_API int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids_array, zval *ret_array, ulong opt, zend_string **sql TSRMLS_DC)
+PHP_PGSQL_API int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids_array, zval *ret_array, zend_ulong opt, zend_string **sql TSRMLS_DC)
{
zval ids_converted;
smart_str querystr = {0};
@@ -6999,7 +6999,7 @@ PHP_FUNCTION(pg_select)
zval *pgsql_link, *ids;
char *table;
int table_len;
- ulong option = PGSQL_DML_EXEC;
+ zend_ulong option = PGSQL_DML_EXEC;
PGconn *pg_link;
zend_string *sql = NULL;
int id = -1, argc = ZEND_NUM_ARGS();
diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h
index cfbe67fd9d..9bfbf142f9 100644
--- a/ext/pgsql/php_pgsql.h
+++ b/ext/pgsql/php_pgsql.h
@@ -211,11 +211,11 @@ PHP_FUNCTION(pg_select);
/* exported functions */
PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, zval *meta, zend_bool extended TSRMLS_DC);
-PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval *values, zval *result, ulong opt TSRMLS_DC);
-PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *values, ulong opt, zend_string **sql TSRMLS_DC);
-PHP_PGSQL_API int php_pgsql_update(PGconn *pg_link, const char *table, zval *values, zval *ids, ulong opt , zend_string **sql TSRMLS_DC);
-PHP_PGSQL_API int php_pgsql_delete(PGconn *pg_link, const char *table, zval *ids, ulong opt, zend_string **sql TSRMLS_DC);
-PHP_PGSQL_API int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids, zval *ret_array, ulong opt, zend_string **sql TSRMLS_DC);
+PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval *values, zval *result, zend_ulong opt TSRMLS_DC);
+PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *values, zend_ulong opt, zend_string **sql TSRMLS_DC);
+PHP_PGSQL_API int php_pgsql_update(PGconn *pg_link, const char *table, zval *values, zval *ids, zend_ulong opt , zend_string **sql TSRMLS_DC);
+PHP_PGSQL_API int php_pgsql_delete(PGconn *pg_link, const char *table, zval *ids, zend_ulong opt, zend_string **sql TSRMLS_DC);
+PHP_PGSQL_API int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids, zval *ret_array, zend_ulong opt, zend_string **sql TSRMLS_DC);
PHP_PGSQL_API int php_pgsql_result2array(PGresult *pg_result, zval *ret_array TSRMLS_DC);
/* internal functions */
@@ -309,10 +309,10 @@ static php_stream_ops php_stream_pgsql_fd_ops = {
};
ZEND_BEGIN_MODULE_GLOBALS(pgsql)
- long num_links,num_persistent;
- long max_links,max_persistent;
- long allow_persistent;
- long auto_reset_persistent;
+ zend_long num_links,num_persistent;
+ zend_long max_links,max_persistent;
+ zend_long allow_persistent;
+ zend_long auto_reset_persistent;
int le_lofp,le_string;
int ignore_notices,log_notices;
HashTable notices; /* notice message for each connection */
diff --git a/ext/pgsql/tests/config.inc b/ext/pgsql/tests/config.inc
index 367f1ef9ba..be652b2507 100644
--- a/ext/pgsql/tests/config.inc
+++ b/ext/pgsql/tests/config.inc
@@ -4,7 +4,7 @@
// "test" database must be existed. i.e. "createdb test" before testing
// PostgreSQL uses login name as username, user must have access to "test" database.
-$conn_str = "host=localhost dbname=test port=5432"; // connection string
+$conn_str = "user=test password=test host=localhost dbname=test port=5432"; // connection string
$table_name = "php_pgsql_test"; // test table that will be created
$table_name_92 = "php_pgsql_test_92"; // test table that will be created
$num_test_record = 1000; // Number of records to create
diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c
index d24a4c76da..b8875891b0 100644
--- a/ext/phar/dirstream.c
+++ b/ext/phar/dirstream.c
@@ -58,7 +58,7 @@ static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{
/**
* Used for seeking on a phar directory handle
*/
-static int phar_dir_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
+static int phar_dir_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset TSRMLS_DC) /* {{{ */
{
HashTable *data = (HashTable *)stream->abstract;
@@ -95,7 +95,7 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_D
size_t to_read;
HashTable *data = (HashTable *)stream->abstract;
zend_string *str_key;
- ulong unused;
+ zend_ulong unused;
if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(data, &str_key, &unused, 0, &data->nInternalPointer)) {
return 0;
@@ -184,7 +184,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
char *entry, *found, *save;
zend_string *str_key;
uint keylen;
- ulong unused;
+ zend_ulong unused;
ALLOC_HASHTABLE(data);
zend_hash_init(data, 64, NULL, NULL, 0);
@@ -306,7 +306,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path,
php_stream *ret;
char *internal_file, *error;
zend_string *str_key;
- ulong unused;
+ zend_ulong unused;
phar_archive_data *phar;
phar_entry_info *entry = NULL;
uint host_len;
@@ -550,7 +550,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
php_url *resource = NULL;
uint host_len;
zend_string *str_key;
- ulong unused;
+ zend_ulong unused;
uint path_len;
/* pre-readonly check, we need to know if this is a data phar */
diff --git a/ext/phar/dirstream.h b/ext/phar/dirstream.h
index fd12ea1698..f9a300a63c 100644
--- a/ext/phar/dirstream.h
+++ b/ext/phar/dirstream.h
@@ -31,7 +31,7 @@ static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count T
static size_t phar_dir_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC);
static int phar_dir_flush(php_stream *stream TSRMLS_DC);
-static int phar_dir_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
+static int phar_dir_seek( php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset TSRMLS_DC);
#else
php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
#endif
diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c
index 392f7d73ab..6347c72f40 100644
--- a/ext/phar/func_interceptors.c
+++ b/ext/phar/func_interceptors.c
@@ -98,8 +98,8 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */
zend_string *contents;
zend_bool use_include_path = 0;
php_stream *stream;
- long offset = -1;
- long maxlen = PHP_STREAM_COPY_ALL;
+ zend_long offset = -1;
+ zend_long maxlen = PHP_STREAM_COPY_ALL;
zval *zcontext = NULL;
if (!PHAR_G(intercepted)) {
@@ -195,7 +195,7 @@ phar_it:
}
if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %pd in the stream", offset);
php_stream_close(stream);
RETURN_FALSE;
}
@@ -205,7 +205,7 @@ phar_it:
if (contents && contents->len > 0) {
RETVAL_STR(contents);
} else if (contents) {
- STR_RELEASE(contents);
+ zend_string_release(contents);
RETVAL_EMPTY_STRING();
} else {
RETVAL_FALSE;
@@ -433,7 +433,7 @@ skip_phar:
/* {{{ php_stat
*/
-static void phar_fancy_stat(struct stat *stat_sb, int type, zval *return_value TSRMLS_DC)
+static void phar_fancy_stat(zend_stat_t *stat_sb, int type, zval *return_value TSRMLS_DC)
{
zval stat_dev, stat_ino, stat_mode, stat_nlink, stat_uid, stat_gid, stat_rdev,
stat_size, stat_atime, stat_mtime, stat_ctime, stat_blksize, stat_blocks;
@@ -477,32 +477,32 @@ static void phar_fancy_stat(struct stat *stat_sb, int type, zval *return_value T
switch (type) {
case FS_PERMS:
- RETURN_LONG((long)stat_sb->st_mode);
+ RETURN_LONG((zend_long)stat_sb->st_mode);
case FS_INODE:
- RETURN_LONG((long)stat_sb->st_ino);
+ RETURN_LONG((zend_long)stat_sb->st_ino);
case FS_SIZE:
- RETURN_LONG((long)stat_sb->st_size);
+ RETURN_LONG((zend_long)stat_sb->st_size);
case FS_OWNER:
- RETURN_LONG((long)stat_sb->st_uid);
+ RETURN_LONG((zend_long)stat_sb->st_uid);
case FS_GROUP:
- RETURN_LONG((long)stat_sb->st_gid);
+ RETURN_LONG((zend_long)stat_sb->st_gid);
case FS_ATIME:
#ifdef NETWARE
- RETURN_LONG((long)stat_sb->st_atime.tv_sec);
+ RETURN_LONG((zend_long)stat_sb->st_atime.tv_sec);
#else
- RETURN_LONG((long)stat_sb->st_atime);
+ RETURN_LONG((zend_long)stat_sb->st_atime);
#endif
case FS_MTIME:
#ifdef NETWARE
- RETURN_LONG((long)stat_sb->st_mtime.tv_sec);
+ RETURN_LONG((zend_long)stat_sb->st_mtime.tv_sec);
#else
- RETURN_LONG((long)stat_sb->st_mtime);
+ RETURN_LONG((zend_long)stat_sb->st_mtime);
#endif
case FS_CTIME:
#ifdef NETWARE
- RETURN_LONG((long)stat_sb->st_ctime.tv_sec);
+ RETURN_LONG((zend_long)stat_sb->st_ctime.tv_sec);
#else
- RETURN_LONG((long)stat_sb->st_ctime);
+ RETURN_LONG((zend_long)stat_sb->st_ctime);
#endif
case FS_TYPE:
if (S_ISLNK(stat_sb->st_mode)) {
@@ -611,7 +611,7 @@ static void phar_file_stat(const char *filename, php_stat_len filename_length, i
if (!IS_ABSOLUTE_PATH(filename, filename_length) && !strstr(filename, "://")) {
char *arch, *entry, *fname;
int arch_len, entry_len, fname_len;
- struct stat sb = {0};
+ zend_stat_t sb = {0};
phar_entry_info *data = NULL;
phar_archive_data *phar;
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index 62b08cc642..2fd46b9621 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -662,14 +662,14 @@ int phar_parse_metadata(char **buffer, zval *metadata, int zip_metadata_len TSRM
* This is used by phar_open_from_filename to process the manifest, but can be called
* directly.
*/
-static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, long halt_offset, phar_archive_data** pphar, php_uint32 compression, char **error TSRMLS_DC) /* {{{ */
+static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, zend_long halt_offset, phar_archive_data** pphar, php_uint32 compression, char **error TSRMLS_DC) /* {{{ */
{
char b32[4], *buffer, *endbuffer, *savebuf;
phar_archive_data *mydata = NULL;
phar_entry_info entry;
php_uint32 manifest_len, manifest_count, manifest_flags, manifest_index, tmp_len, sig_flags;
php_uint16 manifest_ver;
- long offset;
+ zend_long offset;
int sig_len, register_alias = 0, temp_alias = 0;
char *signature = NULL;
@@ -771,7 +771,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
/* be ignored on reading because it is being generated anyways. */
if (manifest_flags & PHAR_HDR_SIGNATURE) {
char sig_buf[8], *sig_ptr = sig_buf;
- off_t read_len;
+ zend_off_t read_len;
size_t end_of_phar;
if (-1 == php_stream_seek(fp, -8, SEEK_END)
@@ -792,7 +792,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
case PHAR_SIG_OPENSSL: {
php_uint32 signature_len;
char *sig;
- off_t whence;
+ zend_off_t whence;
/* we store the signature followed by the signature length */
if (-1 == php_stream_seek(fp, -12, SEEK_CUR)
@@ -1535,7 +1535,7 @@ int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_l
static inline char *phar_strnstr(const char *buf, int buf_len, const char *search, int search_len) /* {{{ */
{
const char *c;
- int so_far = 0;
+ ptrdiff_t so_far = 0;
if (buf_len < search_len) {
return NULL;
@@ -1575,9 +1575,9 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
char *pos, test = '\0';
const int window_size = 1024;
char buffer[1024 + sizeof(token)]; /* a 1024 byte window + the size of the halt_compiler token (moving window) */
- const long readsize = sizeof(buffer) - sizeof(token);
- const long tokenlen = sizeof(token) - 1;
- long halt_offset;
+ const zend_long readsize = sizeof(buffer) - sizeof(token);
+ const zend_long tokenlen = sizeof(token) - 1;
+ zend_long halt_offset;
size_t got;
php_uint32 compression = PHAR_FILE_COMPRESSED_NONE;
@@ -1960,7 +1960,7 @@ woohoo:
}
} else {
zend_string *str_key;
- ulong unused;
+ zend_ulong unused;
for (zend_hash_internal_pointer_reset(&(PHAR_GLOBALS->phar_fname_map));
HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &str_key, &unused, 0, &PHAR_GLOBALS->phar_fname_map.nInternalPointer);
@@ -2534,7 +2534,7 @@ char *phar_create_default_stub(const char *index_php, const char *web_index, siz
* user_stub contains either a string, or a resource pointer, if len is a negative length.
* user_stub and len should be both 0 if the default or existing stub should be used
*/
-int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, char **error TSRMLS_DC) /* {{{ */
+int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int convert, char **error TSRMLS_DC) /* {{{ */
{
char halt_stub[] = "__HALT_COMPILER();";
char *newstub, *tmp;
@@ -2542,8 +2542,8 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
int halt_offset, restore_alias_len, global_flags = 0, closeoldfile;
char *pos, has_dirs = 0;
char manifest[18], entry_buffer[24];
- off_t manifest_ftell;
- long offset;
+ zend_off_t manifest_ftell;
+ zend_long offset;
size_t wrote;
php_uint32 manifest_len, mytime, loc, new_manifest_count;
php_uint32 newcrc32;
@@ -2650,7 +2650,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
spprintf(error, 0, "illegal stub for phar \"%s\"", phar->fname);
}
if (free_user_stub) {
- STR_FREE(suser_stub);
+ zend_string_free(suser_stub);
}
return EOF;
}
@@ -2667,13 +2667,13 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
spprintf(error, 0, "unable to create stub from string in new phar \"%s\"", phar->fname);
}
if (free_user_stub) {
- STR_FREE(suser_stub);
+ zend_string_free(suser_stub);
}
return EOF;
}
phar->halt_offset = len + 5;
if (free_user_stub) {
- STR_FREE(suser_stub);
+ zend_string_free(suser_stub);
}
} else {
size_t written;
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
index b7dc155a96..77df0a71c2 100644
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@ -249,11 +249,11 @@ typedef struct _phar_entry_info {
char *filename;
enum phar_fp_type fp_type;
/* offset within original phar file of the file contents */
- long offset_abs;
+ zend_long offset_abs;
/* offset within fp of the file contents */
- long offset;
+ zend_long offset;
/* offset within original phar file of the file header (for zip-based/tar-based) */
- long header_offset;
+ zend_long header_offset;
php_stream *fp;
php_stream *cfp;
int fp_refcount;
@@ -334,7 +334,7 @@ struct _phar_archive_data {
typedef struct _phar_entry_fp_info {
enum phar_fp_type fp_type;
/* offset within fp of the file contents */
- long offset;
+ zend_long offset;
} phar_entry_fp_info;
struct _phar_entry_fp {
@@ -415,7 +415,7 @@ static inline void phar_set_pharufp(phar_archive_data *phar, php_stream *fp TSRM
PHAR_GLOBALS->cached_fp[phar->phar_pos].ufp = fp;
}
-static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, off_t offset TSRMLS_DC)
+static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, zend_off_t offset TSRMLS_DC)
{
phar_entry_fp_info *data;
@@ -437,7 +437,7 @@ static inline enum phar_fp_type phar_get_fp_type(phar_entry_info *entry TSRMLS_D
return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type;
}
-static inline off_t phar_get_fp_offset(phar_entry_info *entry TSRMLS_DC)
+static inline zend_off_t phar_get_fp_offset(phar_entry_info *entry TSRMLS_DC)
{
if (!entry->is_persistent) {
return entry->offset;
@@ -466,9 +466,9 @@ typedef struct _phar_entry_data {
phar_archive_data *phar;
php_stream *fp;
/* stream position proxy, allows multiple open streams referring to the same fp */
- off_t position;
+ zend_off_t position;
/* for copies of the phar fp, defines where 0 is */
- off_t zero;
+ zend_off_t zero;
unsigned int for_write:1;
unsigned int is_zip:1;
unsigned int is_tar:1;
@@ -564,7 +564,7 @@ char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC);
phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC);
int phar_parse_metadata(char **buffer, zval *metadata, int zip_metadata_len TSRMLS_DC);
void destroy_phar_manifest_entry(zval *zv);
-int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_links TSRMLS_DC);
+int phar_seek_efp(phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, int follow_links TSRMLS_DC);
php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC);
int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error TSRMLS_DC);
int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TSRMLS_DC);
@@ -578,12 +578,12 @@ int phar_copy_on_write(phar_archive_data **pphar TSRMLS_DC);
int phar_is_tar(char *buf, char *fname);
int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32 compression, char **error TSRMLS_DC);
int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC);
+int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int defaultstub, char **error TSRMLS_DC);
/* zip functions in zip.c */
int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, char **error TSRMLS_DC);
int phar_open_or_create_zip(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_zip_flush(phar_archive_data *archive, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC);
+int phar_zip_flush(phar_archive_data *archive, char *user_stub, zend_long len, int defaultstub, char **error TSRMLS_DC);
#ifdef PHAR_MAIN
static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, int is_data, char **error TSRMLS_DC);
@@ -600,7 +600,7 @@ phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int pa
phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security TSRMLS_DC);
phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC);
int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC);
-int phar_flush(phar_archive_data *archive, char *user_stub, long len, int convert, char **error TSRMLS_DC);
+int phar_flush(phar_archive_data *archive, char *user_stub, zend_long len, int convert, char **error TSRMLS_DC);
int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete TSRMLS_DC);
int phar_split_fname(const char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC);
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index e9acfe435b..b0123f30df 100755
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -155,7 +155,7 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
zend_op_array *new_op_array;
zval result;
php_stream *fp;
- off_t position;
+ zend_off_t position;
switch (code) {
case PHAR_MIME_PHPS:
@@ -211,7 +211,7 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
if (got > 0) {
PHPWRITE(buf, got);
position += got;
- if (position == (off_t) info->uncompressed_filesize) {
+ if (position == (zend_off_t) info->uncompressed_filesize) {
break;
}
}
@@ -947,7 +947,7 @@ PHP_METHOD(Phar, mapPhar)
{
char *alias = NULL, *error;
int alias_len = 0;
- long dataoffset = 0;
+ zend_long dataoffset = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!l", &alias, &alias_len, &dataoffset) == FAILURE) {
return;
@@ -999,7 +999,7 @@ PHP_METHOD(Phar, apiVersion)
* Returns whether phar extension supports compression using zlib/bzip2 */
PHP_METHOD(Phar, canCompress)
{
- long method = 0;
+ zend_long method = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
return;
@@ -1109,8 +1109,8 @@ PHP_METHOD(Phar, __construct)
#else
char *fname, *alias = NULL, *error, *arch = NULL, *entry = NULL, *save_fname;
int fname_len, alias_len = 0, arch_len, entry_len, is_data;
- long flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS;
- long format = 0;
+ zend_long flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS;
+ zend_long format = 0;
phar_archive_object *phar_obj;
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1, arg2;
@@ -1900,7 +1900,7 @@ PHP_METHOD(Phar, buildFromIterator)
PHP_METHOD(Phar, count)
{
/* mode can be ignored, maximum depth is 1 */
- long mode;
+ zend_long mode;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &mode) == FAILURE) {
@@ -1917,7 +1917,7 @@ PHP_METHOD(Phar, count)
*/
PHP_METHOD(Phar, isFileFormat)
{
- long type;
+ zend_long type;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) {
@@ -1940,7 +1940,7 @@ PHP_METHOD(Phar, isFileFormat)
static int phar_copy_file_contents(phar_entry_info *entry, php_stream *fp TSRMLS_DC) /* {{{ */
{
char *error;
- off_t offset;
+ zend_off_t offset;
phar_entry_info *link;
if (FAILURE == phar_open_entry_fp(entry, &error, 1 TSRMLS_CC)) {
@@ -2300,7 +2300,7 @@ PHP_METHOD(Phar, convertToExecutable)
php_uint32 flags;
zend_object *ret;
/* a number that is not 0, 1 or 2 (Which is also Greg's birthday, so there) */
- long format = 9021976, method = 9021976;
+ zend_long format = 9021976, method = 9021976;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
@@ -2403,7 +2403,7 @@ PHP_METHOD(Phar, convertToData)
php_uint32 flags;
zend_object *ret;
/* a number that is not 0, 1 or 2 (Which is also Greg's birthday so there) */
- long format = 9021976, method = 9021976;
+ zend_long format = 9021976, method = 9021976;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
@@ -2812,7 +2812,7 @@ PHP_METHOD(Phar, setStub)
zval *zstub;
char *stub, *error;
int stub_len;
- long len = -1;
+ zend_long len = -1;
php_stream *stream;
PHAR_ARCHIVE_OBJECT();
@@ -2962,7 +2962,7 @@ PHP_METHOD(Phar, setDefaultStub)
*/
PHP_METHOD(Phar, setSignatureAlgorithm)
{
- long algo;
+ zend_long algo;
char *error, *key = NULL;
int key_len = 0;
@@ -3133,7 +3133,7 @@ static int pharobj_cancompress(HashTable *manifest TSRMLS_DC) /* {{{ */
*/
PHP_METHOD(Phar, compress)
{
- long method;
+ zend_long method;
char *ext = NULL;
int ext_len = 0;
php_uint32 flags;
@@ -3246,7 +3246,7 @@ PHP_METHOD(Phar, compressFiles)
{
char *error;
php_uint32 flags;
- long method;
+ zend_long method;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &method) == FAILURE) {
@@ -3889,7 +3889,7 @@ PHP_METHOD(Phar, getStub)
php_stream_rewind(fp);
carry_on:
- buf = STR_ALLOC(len, 0);
+ buf = zend_string_alloc(len, 0);
if (len != php_stream_read(fp, buf->val, len)) {
if (fp != phar_obj->archive->fp) {
@@ -3897,7 +3897,7 @@ carry_on:
}
zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
"Unable to read stub");
- STR_RELEASE(buf);
+ zend_string_release(buf);
return;
}
@@ -4429,7 +4429,7 @@ PHP_METHOD(PharFileInfo, getCompressedSize)
PHP_METHOD(PharFileInfo, isCompressed)
{
/* a number that is not Phar::GZ or Phar::BZ2 */
- long method = 9021976;
+ zend_long method = 9021976;
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
@@ -4512,7 +4512,7 @@ PHP_METHOD(PharFileInfo, getPharFlags)
PHP_METHOD(PharFileInfo, chmod)
{
char *error;
- long perms;
+ zend_long perms;
PHAR_ENTRY_OBJECT();
if (entry_obj->entry->is_temp_dir) {
@@ -4774,7 +4774,7 @@ PHP_METHOD(PharFileInfo, getContent)
*/
PHP_METHOD(PharFileInfo, compress)
{
- long method;
+ zend_long method;
char *error;
PHAR_ENTRY_OBJECT();
@@ -5267,7 +5267,7 @@ zend_function_entry phar_exception_methods[] = {
/* }}} */
#define REGISTER_PHAR_CLASS_CONST_LONG(class_name, const_name, value) \
- zend_declare_class_constant_long(class_name, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
+ zend_declare_class_constant_long(class_name, const_name, sizeof(const_name)-1, (zend_long)value TSRMLS_CC);
#define phar_exception_get_default() zend_exception_get_default(TSRMLS_C)
diff --git a/ext/phar/stream.c b/ext/phar/stream.c
index 5aa6aa43ea..eb2fa607ee 100644
--- a/ext/phar/stream.c
+++ b/ext/phar/stream.c
@@ -377,7 +377,7 @@ static size_t phar_stream_read(php_stream *stream, char *buf, size_t count TSRML
got = php_stream_read(data->fp, buf, MIN(count, entry->uncompressed_filesize - data->position));
data->position = php_stream_tell(data->fp) - data->zero;
- stream->eof = (data->position == (off_t) entry->uncompressed_filesize);
+ stream->eof = (data->position == (zend_off_t) entry->uncompressed_filesize);
return got;
}
@@ -386,12 +386,12 @@ static size_t phar_stream_read(php_stream *stream, char *buf, size_t count TSRML
/**
* Used for fseek($fp) on a phar file handle
*/
-static int phar_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
+static int phar_stream_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset TSRMLS_DC) /* {{{ */
{
phar_entry_data *data = (phar_entry_data *)stream->abstract;
phar_entry_info *entry;
int res;
- off_t temp;
+ zend_off_t temp;
if (data->internal_file->link) {
entry = phar_get_link_source(data->internal_file TSRMLS_CC);
@@ -412,7 +412,7 @@ static int phar_stream_seek(php_stream *stream, off_t offset, int whence, off_t
default:
temp = 0;
}
- if (temp > data->zero + (off_t) entry->uncompressed_filesize) {
+ if (temp > data->zero + (zend_off_t) entry->uncompressed_filesize) {
*newoffset = -1;
return -1;
}
@@ -440,7 +440,7 @@ static size_t phar_stream_write(php_stream *stream, const char *buf, size_t coun
return -1;
}
data->position = php_stream_tell(data->fp);
- if (data->position > (off_t)data->internal_file->uncompressed_filesize) {
+ if (data->position > (zend_off_t)data->internal_file->uncompressed_filesize) {
data->internal_file->uncompressed_filesize = data->position;
}
data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize;
@@ -906,7 +906,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
memcmp(str_key->val, resource_from->path+1, from_len) == 0 &&
IS_SLASH(str_key->val[from_len])) {
- new_str_key = STR_ALLOC(str_key->len + to_len - from_len, 0);
+ new_str_key = zend_string_alloc(str_key->len + to_len - from_len, 0);
memcpy(new_str_key->val, resource_to->path + 1, to_len);
memcpy(new_str_key->val + to_len, str_key->val + from_len, str_key->len - from_len);
new_str_key->val[new_str_key->len] = 0;
@@ -918,8 +918,8 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
entry->filename = estrndup(new_str_key->val, new_str_key->len);
entry->filename_len = new_str_key->len;
- STR_RELEASE(str_key);
- b->h = STR_HASH_VAL(new_str_key);
+ zend_string_release(str_key);
+ b->h = zend_string_hash_val(new_str_key);
b->key = new_str_key;
}
} ZEND_HASH_FOREACH_END();
@@ -931,13 +931,13 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
memcmp(str_key->val, resource_from->path+1, from_len) == 0 &&
(str_key->len == from_len || IS_SLASH(str_key->val[from_len]))) {
- new_str_key = STR_ALLOC(str_key->len + to_len - from_len, 0);
+ new_str_key = zend_string_alloc(str_key->len + to_len - from_len, 0);
memcpy(new_str_key->val, resource_to->path + 1, to_len);
memcpy(new_str_key->val + to_len, str_key->val + from_len, str_key->len - from_len);
new_str_key->val[new_str_key->len] = 0;
- STR_RELEASE(str_key);
- b->h = STR_HASH_VAL(new_str_key);
+ zend_string_release(str_key);
+ b->h = zend_string_hash_val(new_str_key);
b->key = new_str_key;
}
} ZEND_HASH_FOREACH_END();
@@ -949,13 +949,13 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
memcmp(str_key->val, resource_from->path+1, from_len) == 0 &&
(str_key->len == from_len || IS_SLASH(str_key->val[from_len]))) {
- new_str_key = STR_ALLOC(str_key->len + to_len - from_len, 0);
+ new_str_key = zend_string_alloc(str_key->len + to_len - from_len, 0);
memcpy(new_str_key->val, resource_to->path + 1, to_len);
memcpy(new_str_key->val + to_len, str_key->val + from_len, str_key->len - from_len);
new_str_key->val[new_str_key->len] = 0;
- STR_RELEASE(str_key);
- b->h = STR_HASH_VAL(new_str_key);
+ zend_string_release(str_key);
+ b->h = zend_string_hash_val(new_str_key);
b->key = new_str_key;
}
} ZEND_HASH_FOREACH_END();
diff --git a/ext/phar/stream.h b/ext/phar/stream.h
index 2b78696560..0171010179 100644
--- a/ext/phar/stream.h
+++ b/ext/phar/stream.h
@@ -34,7 +34,7 @@ static size_t phar_stream_write(php_stream *stream, const char *buf, size_t coun
static size_t phar_stream_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
static int phar_stream_close(php_stream *stream, int close_handle TSRMLS_DC);
static int phar_stream_flush(php_stream *stream TSRMLS_DC);
-static int phar_stream_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
+static int phar_stream_seek( php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset TSRMLS_DC);
static int phar_stream_stat( php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
END_EXTERN_C()
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
index 6d210cbf5d..985abd14a9 100644
--- a/ext/phar/tar.c
+++ b/ext/phar/tar.c
@@ -256,7 +256,7 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias,
phar_tar_number(hdr->size, sizeof(hdr->size));
if (((!old && hdr->prefix[0] == 0) || old) && strlen(hdr->name) == sizeof(".phar/signature.bin")-1 && !strncmp(hdr->name, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
- off_t curloc;
+ zend_off_t curloc;
if (size > 511) {
if (error) {
@@ -921,7 +921,7 @@ static int phar_tar_setupmetadata(zval *zv, void *argument TSRMLS_DC) /* {{{ */
}
/* }}} */
-int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
+int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
{
phar_entry_info entry = {0};
static const char newstub[] = "<?php // tar-based phar archive stub file\n__HALT_COMPILER();";
@@ -1004,7 +1004,7 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defau
if (str) {
len = str->len;
user_stub = estrndup(str->val, str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
user_stub = NULL;
len = 0;
diff --git a/ext/phar/util.c b/ext/phar/util.c
index 4bac776511..e550b9fbcf 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -38,7 +38,7 @@
#include <openssl/ssl.h>
#include <openssl/pkcs12.h>
#else
-static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC);
+static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC);
#endif
/* for links to relative location, prepend cwd of the entry */
@@ -117,10 +117,10 @@ php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC) /*
}
/* }}} */
-int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_links TSRMLS_DC) /* {{{ */
+int phar_seek_efp(phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, int follow_links TSRMLS_DC) /* {{{ */
{
php_stream *fp = phar_get_efp(entry, follow_links TSRMLS_CC);
- off_t temp, eoffset;
+ zend_off_t temp, eoffset;
if (!fp) {
return -1;
@@ -154,7 +154,7 @@ int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t positi
temp = 0;
}
- if (temp > eoffset + (off_t) entry->uncompressed_filesize) {
+ if (temp > eoffset + (zend_off_t) entry->uncompressed_filesize) {
return -1;
}
@@ -693,7 +693,7 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
php_stream_filter *filter;
phar_archive_data *phar = entry->phar;
char *filtername;
- off_t loc;
+ zend_off_t loc;
php_stream *ufp;
phar_entry_data dummy;
@@ -786,7 +786,7 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
php_stream_flush(ufp);
php_stream_filter_remove(filter, 1 TSRMLS_CC);
- if (php_stream_tell(ufp) - loc != (off_t) entry->uncompressed_filesize) {
+ if (php_stream_tell(ufp) - loc != (zend_off_t) entry->uncompressed_filesize) {
spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
return FAILURE;
}
@@ -1388,7 +1388,7 @@ static int phar_hex_str(const char *digest, size_t digest_len, char **signature
/* }}} */
#ifndef PHAR_HAVE_OPENSSL
-static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC) /* {{{ */
+static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC) /* {{{ */
{
zend_fcall_info fci;
zend_fcall_info_cache fcc;
@@ -1479,7 +1479,7 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error TSRMLS_DC) /* {{{ */
{
int read_size, len;
- off_t read_len;
+ zend_off_t read_len;
unsigned char buf[1024];
php_stream_rewind(fp);
@@ -1526,7 +1526,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, pubkey ? pubkey->val : NULL, pubkey ? pubkey->len : 0, &sig, &tempsig TSRMLS_CC)) {
if (pubkey) {
- STR_RELEASE(pubkey);
+ zend_string_release(pubkey);
}
if (error) {
@@ -1537,7 +1537,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
}
if (pubkey) {
- STR_RELEASE(pubkey);
+ zend_string_release(pubkey);
}
sig_len = tempsig;
@@ -1545,7 +1545,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
in = BIO_new_mem_buf(pubkey ? pubkey->val : NULL, pubkey ? pubkey->len : 0);
if (NULL == in) {
- STR_RELEASE(pubkey);
+ zend_string_release(pubkey);
if (error) {
spprintf(error, 0, "openssl signature could not be processed");
}
@@ -1554,7 +1554,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
key = PEM_read_bio_PUBKEY(in, NULL,NULL, NULL);
BIO_free(in);
- STR_RELEASE(pubkey);
+ zend_string_release(pubkey);
if (NULL == key) {
if (error) {
@@ -1576,7 +1576,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
while (read_size && (len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
EVP_VerifyUpdate (&md_ctx, buf, len);
- read_len -= (off_t)len;
+ read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
@@ -1616,7 +1616,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA512Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
@@ -1649,7 +1649,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA256Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
@@ -1690,7 +1690,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA1Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
@@ -1723,7 +1723,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_MD5Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index 10becce09f..a314498813 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -167,7 +167,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
{
phar_zip_dir_end locator;
char buf[sizeof(locator) + 65536];
- long size;
+ zend_long size;
php_uint16 i;
phar_archive_data *mydata = NULL;
phar_entry_info entry = {0};
@@ -241,7 +241,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
mydata->metadata_len = 0;
/* if not valid serialized data, it is a regular string */
- ZVAL_STR(&mydata->metadata, STR_INIT(metadata, PHAR_GET_16(locator.comment_len), mydata->is_persistent));
+ ZVAL_STR(&mydata->metadata, zend_string_init(metadata, PHAR_GET_16(locator.comment_len), mydata->is_persistent));
}
} else {
ZVAL_UNDEF(&mydata->metadata);
@@ -338,7 +338,7 @@ foundit:
/* add each central directory item to the manifest */
for (i = 0; i < PHAR_GET_16(locator.count); ++i) {
phar_zip_central_dir_file zipentry;
- off_t beforeus = php_stream_tell(fp);
+ zend_off_t beforeus = php_stream_tell(fp);
if (sizeof(zipentry) != php_stream_read(fp, (char *) &zipentry, sizeof(zipentry))) {
PHAR_ZIP_FAIL("unable to read central directory entry, truncated");
@@ -393,7 +393,7 @@ foundit:
if (entry.filename_len == sizeof(".phar/signature.bin")-1 && !strncmp(entry.filename, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
size_t read;
php_stream *sigfile;
- off_t now;
+ zend_off_t now;
char *sig;
now = php_stream_tell(fp);
@@ -448,7 +448,7 @@ foundit:
phar_add_virtual_dirs(mydata, entry.filename, entry.filename_len TSRMLS_CC);
if (PHAR_GET_16(zipentry.extra_len)) {
- off_t loc = php_stream_tell(fp);
+ zend_off_t loc = php_stream_tell(fp);
if (FAILURE == phar_zip_process_extra(fp, &entry, PHAR_GET_16(zipentry.extra_len) TSRMLS_CC)) {
pefree(entry.filename, entry.is_persistent);
PHAR_ZIP_FAIL("Unable to process extra field header for file in central directory");
@@ -529,7 +529,7 @@ foundit:
entry.metadata_len = 0;
/* if not valid serialized data, it is a regular string */
- ZVAL_STR(&entry.metadata, STR_INIT(buf, PHAR_GET_16(zipentry.comment_len), entry.is_persistent));
+ ZVAL_STR(&entry.metadata, zend_string_init(buf, PHAR_GET_16(zipentry.comment_len), entry.is_persistent));
}
} else {
ZVAL_UNDEF(&entry.metadata);
@@ -537,7 +537,7 @@ foundit:
if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename, ".phar/alias.txt", sizeof(".phar/alias.txt")-1)) {
php_stream_filter *filter;
- off_t saveloc;
+ zend_off_t saveloc;
/* verify local file header */
phar_zip_file_header local;
@@ -586,7 +586,7 @@ foundit:
if (str) {
entry.uncompressed_filesize = str->len;
actual_alias = estrndup(str->val, str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
actual_alias = NULL;
entry.uncompressed_filesize = 0;
@@ -618,7 +618,7 @@ foundit:
if (str) {
entry.uncompressed_filesize = str->len;
actual_alias = estrndup(str->val, str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
actual_alias = NULL;
entry.uncompressed_filesize = 0;
@@ -640,7 +640,7 @@ foundit:
if (str) {
entry.uncompressed_filesize = str->len;
actual_alias = estrndup(str->val, str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
actual_alias = NULL;
entry.uncompressed_filesize = 0;
@@ -790,7 +790,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg TSRMLS_D
phar_zip_central_dir_file central;
struct _phar_zip_pass *p;
php_uint32 newcrc32;
- off_t offset;
+ zend_off_t offset;
int not_really_modified = 0;
p = (struct _phar_zip_pass*) arg;
@@ -1108,7 +1108,7 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas
char *signature, sigbuf[8];
phar_entry_info entry = {0};
php_stream *newfile;
- off_t tell, st;
+ zend_off_t tell, st;
newfile = php_stream_fopen_tmpfile();
if (newfile == NULL) {
@@ -1177,7 +1177,7 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas
}
/* }}} */
-int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
+int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
{
char *pos;
smart_str main_metadata_str = {0};
@@ -1274,7 +1274,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
if (str) {
len = str->len;
user_stub = estrndup(str->val, str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
user_stub = NULL;
len = 0;
diff --git a/ext/posix/posix.c b/ext/posix/posix.c
index 301507f655..97ec81174f 100644
--- a/ext/posix/posix.c
+++ b/ext/posix/posix.c
@@ -380,7 +380,7 @@ ZEND_GET_MODULE(posix)
RETURN_LONG(func_name());
#define PHP_POSIX_SINGLE_ARG_FUNC(func_name) \
- long val; \
+ zend_long val; \
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) RETURN_FALSE; \
if (func_name(val) < 0) { \
POSIX_G(last_error) = errno; \
@@ -393,7 +393,7 @@ ZEND_GET_MODULE(posix)
PHP_FUNCTION(posix_kill)
{
- long pid, sig;
+ zend_long pid, sig;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &pid, &sig) == FAILURE) {
RETURN_FALSE;
@@ -558,7 +558,7 @@ PHP_FUNCTION(posix_setsid)
Set process group id for job control (POSIX.1, 4.3.3) */
PHP_FUNCTION(posix_setpgid)
{
- long pid, pgid;
+ zend_long pid, pgid;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &pid, &pgid) == FAILURE) {
RETURN_FALSE;
@@ -578,7 +578,7 @@ PHP_FUNCTION(posix_setpgid)
#ifdef HAVE_GETPGID
PHP_FUNCTION(posix_getpgid)
{
- long val;
+ zend_long val;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) {
RETURN_FALSE;
}
@@ -597,7 +597,7 @@ PHP_FUNCTION(posix_getpgid)
#ifdef HAVE_GETSID
PHP_FUNCTION(posix_getsid)
{
- long val;
+ zend_long val;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) {
RETURN_FALSE;
}
@@ -724,7 +724,7 @@ PHP_FUNCTION(posix_ttyname)
char *p;
int fd;
#if defined(ZTS) && defined(HAVE_TTYNAME_R) && defined(_SC_TTY_NAME_MAX)
- long buflen;
+ zend_long buflen;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &z_fd) == FAILURE) {
@@ -738,7 +738,7 @@ PHP_FUNCTION(posix_ttyname)
}
break;
default:
- convert_to_long_ex(z_fd);
+ convert_to_int_ex(z_fd);
fd = Z_LVAL_P(z_fd);
}
#if defined(ZTS) && defined(HAVE_TTYNAME_R) && defined(_SC_TTY_NAME_MAX)
@@ -783,7 +783,7 @@ PHP_FUNCTION(posix_isatty)
}
break;
default:
- convert_to_long_ex(z_fd);
+ convert_to_int_ex(z_fd);
fd = Z_LVAL_P(z_fd);
}
@@ -836,7 +836,7 @@ PHP_FUNCTION(posix_mkfifo)
{
char *path;
int path_len;
- long mode;
+ zend_long mode;
int result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pl", &path, &path_len, &mode) == FAILURE) {
@@ -865,8 +865,8 @@ PHP_FUNCTION(posix_mknod)
{
char *path;
int path_len;
- long mode;
- long major = 0, minor = 0;
+ zend_long mode;
+ zend_long major = 0, minor = 0;
int result;
dev_t php_dev;
@@ -947,7 +947,7 @@ int php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ */
Determine accessibility of a file (POSIX.1 5.6.3) */
PHP_FUNCTION(posix_access)
{
- long mode = 0;
+ zend_long mode = 0;
int filename_len, ret;
char *filename, *path;
@@ -1039,7 +1039,7 @@ PHP_FUNCTION(posix_getgrnam)
Group database access (POSIX.1, 9.2.1) */
PHP_FUNCTION(posix_getgrgid)
{
- long gid;
+ zend_long gid;
#if defined(ZTS) && defined(HAVE_GETGRGID_R) && defined(_SC_GETGR_R_SIZE_MAX)
int ret;
struct group _g;
@@ -1158,7 +1158,7 @@ PHP_FUNCTION(posix_getpwnam)
User database access (POSIX.1, 9.2.2) */
PHP_FUNCTION(posix_getpwuid)
{
- long uid;
+ zend_long uid;
#if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWUID_R)
struct passwd _pw;
struct passwd *retpwptr = NULL;
@@ -1336,7 +1336,7 @@ PHP_FUNCTION(posix_get_last_error)
Retrieve the system error message associated with the given errno. */
PHP_FUNCTION(posix_strerror)
{
- long error;
+ zend_long error;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error) == FAILURE) {
RETURN_FALSE;
@@ -1353,7 +1353,7 @@ PHP_FUNCTION(posix_strerror)
Calculate the group access list for the user specified in name. */
PHP_FUNCTION(posix_initgroups)
{
- long basegid;
+ zend_long basegid;
char *name;
int name_len;
diff --git a/ext/pspell/pspell.c b/ext/pspell/pspell.c
index f95ecc8b58..ff97306ecf 100644
--- a/ext/pspell/pspell.c
+++ b/ext/pspell/pspell.c
@@ -265,7 +265,7 @@ static PHP_FUNCTION(pspell_new)
{
char *language, *spelling = NULL, *jargon = NULL, *encoding = NULL;
int language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0;
- long mode = 0L, speed = 0L;
+ zend_long mode = Z_I(0), speed = Z_I(0);
int argc = ZEND_NUM_ARGS();
zval *ind;
@@ -362,7 +362,7 @@ static PHP_FUNCTION(pspell_new_personal)
{
char *personal, *language, *spelling = NULL, *jargon = NULL, *encoding = NULL;
int personal_len, language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0;
- long mode = 0L, speed = 0L;
+ zend_long mode = Z_I(0), speed = Z_I(0);
int argc = ZEND_NUM_ARGS();
zval *ind;
@@ -465,7 +465,7 @@ static PHP_FUNCTION(pspell_new_personal)
Load a dictionary based on the given config */
static PHP_FUNCTION(pspell_new_config)
{
- long conf;
+ zend_long conf;
zval *ind;
PspellCanHaveError *ret;
PspellManager *manager;
@@ -496,7 +496,7 @@ static PHP_FUNCTION(pspell_new_config)
static PHP_FUNCTION(pspell_check)
{
int word_len;
- long scin;
+ zend_long scin;
char *word;
PspellManager *manager;
@@ -518,7 +518,7 @@ static PHP_FUNCTION(pspell_check)
Returns array of suggestions */
static PHP_FUNCTION(pspell_suggest)
{
- long scin;
+ zend_long scin;
char *word;
int word_len;
PspellManager *manager;
@@ -552,7 +552,7 @@ static PHP_FUNCTION(pspell_suggest)
static PHP_FUNCTION(pspell_store_replacement)
{
int miss_len, corr_len;
- long scin;
+ zend_long scin;
char *miss, *corr;
PspellManager *manager;
@@ -577,7 +577,7 @@ static PHP_FUNCTION(pspell_store_replacement)
static PHP_FUNCTION(pspell_add_to_personal)
{
int word_len;
- long scin;
+ zend_long scin;
char *word;
PspellManager *manager;
@@ -607,7 +607,7 @@ static PHP_FUNCTION(pspell_add_to_personal)
static PHP_FUNCTION(pspell_add_to_session)
{
int word_len;
- long scin;
+ zend_long scin;
char *word;
PspellManager *manager;
@@ -636,7 +636,7 @@ static PHP_FUNCTION(pspell_add_to_session)
Clears the current session */
static PHP_FUNCTION(pspell_clear_session)
{
- long scin;
+ zend_long scin;
PspellManager *manager;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &scin) == FAILURE) {
@@ -659,7 +659,7 @@ static PHP_FUNCTION(pspell_clear_session)
Saves the current (personal) wordlist */
static PHP_FUNCTION(pspell_save_wordlist)
{
- long scin;
+ zend_long scin;
PspellManager *manager;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &scin) == FAILURE) {
@@ -752,7 +752,7 @@ static PHP_FUNCTION(pspell_config_create)
Consider run-together words as valid components */
static PHP_FUNCTION(pspell_config_runtogether)
{
- long conf;
+ zend_long conf;
zend_bool runtogether;
PspellConfig *config;
@@ -772,7 +772,7 @@ static PHP_FUNCTION(pspell_config_runtogether)
Select mode for config (PSPELL_FAST, PSPELL_NORMAL or PSPELL_BAD_SPELLERS) */
static PHP_FUNCTION(pspell_config_mode)
{
- long conf, mode;
+ zend_long conf, mode;
PspellConfig *config;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &conf, &mode) == FAILURE) {
@@ -799,7 +799,7 @@ static PHP_FUNCTION(pspell_config_mode)
static PHP_FUNCTION(pspell_config_ignore)
{
char ignore_str[MAX_LENGTH_OF_LONG + 1];
- long conf, ignore = 0L;
+ zend_long conf, ignore = 0L;
PspellConfig *config;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &conf, &ignore) == FAILURE) {
@@ -817,7 +817,7 @@ static PHP_FUNCTION(pspell_config_ignore)
static void pspell_config_path(INTERNAL_FUNCTION_PARAMETERS, char *option)
{
- long conf;
+ zend_long conf;
char *value;
int value_len;
PspellConfig *config;
@@ -865,7 +865,7 @@ static PHP_FUNCTION(pspell_config_data_dir)
Use a personal dictionary with replacement pairs for this config */
static PHP_FUNCTION(pspell_config_repl)
{
- long conf;
+ zend_long conf;
char *repl;
int repl_len;
PspellConfig *config;
@@ -892,7 +892,7 @@ static PHP_FUNCTION(pspell_config_repl)
Save replacement pairs when personal list is saved for this config */
static PHP_FUNCTION(pspell_config_save_repl)
{
- long conf;
+ zend_long conf;
zend_bool save;
PspellConfig *config;
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 22b727b6a4..10bd44ce5d 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -284,7 +284,7 @@ PHP_FUNCTION(readline_info)
} else if (!strcasecmp(what, "done")) {
oldval = rl_done;
if (value) {
- convert_to_long_ex(value);
+ convert_to_int_ex(value);
rl_done = Z_LVAL_P(value);
}
RETVAL_LONG(oldval);
@@ -304,7 +304,7 @@ PHP_FUNCTION(readline_info)
} else if (!strcasecmp(what, "erase_empty_line")) {
oldval = rl_erase_empty_line;
if (value) {
- convert_to_long_ex(value);
+ convert_to_int_ex(value);
rl_erase_empty_line = Z_LVAL_PP(value);
}
RETVAL_LONG(oldval);
@@ -322,7 +322,7 @@ PHP_FUNCTION(readline_info)
} else if (!strcasecmp(what, "attempted_completion_over")) {
oldval = rl_attempted_completion_over;
if (value) {
- convert_to_long_ex(value);
+ convert_to_int_ex(value);
rl_attempted_completion_over = Z_LVAL_P(value);
}
RETVAL_LONG(oldval);
@@ -521,10 +521,10 @@ PHP_FUNCTION(readline_completion_function)
if (!zend_is_callable(arg, 0, &name TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not callable", name->val);
- STR_RELEASE(name);
+ zend_string_release(name);
RETURN_FALSE;
}
- STR_RELEASE(name);
+ zend_string_release(name);
zval_dtor(&_readline_completion);
ZVAL_DUP(&_readline_completion, arg);
@@ -571,10 +571,10 @@ PHP_FUNCTION(readline_callback_handler_install)
if (!zend_is_callable(callback, 0, &name TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not callable", name->val);
- STR_RELEASE(name);
+ zend_string_release(name);
RETURN_FALSE;
}
- STR_RELEASE(name);
+ zend_string_release(name);
if (Z_TYPE(_prepped_callback) != IS_UNDEF) {
rl_callback_handler_remove();
diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c
index 0ca9daf8ff..2279f7aaa1 100644
--- a/ext/readline/readline_cli.c
+++ b/ext/readline/readline_cli.c
@@ -530,10 +530,10 @@ TODO:
class_name_end = strstr(text, "::");
if (class_name_end) {
class_name_len = class_name_end - text;
- class_name = STR_ALLOC(class_name_len, 0);
+ class_name = zend_string_alloc(class_name_len, 0);
zend_str_tolower_copy(class_name->val, text, class_name_len);
if ((ce = zend_lookup_class(class_name TSRMLS_CC)) == NULL) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
return NULL;
}
lc_text = zend_str_tolower_dup(class_name_end + 2, textlen - 2 - class_name_len);
@@ -564,7 +564,7 @@ TODO:
}
efree(lc_text);
if (class_name_end) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
}
if (ce && retval) {
int len = class_name_len + 2 + strlen(retval) + 1;
@@ -631,13 +631,13 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
if (param) {
zend_string *cmd;
param++;
- cmd = STR_INIT(&line[1], param - &line[1] - 1, 0);
+ cmd = zend_string_init(&line[1], param - &line[1] - 1, 0);
zend_alter_ini_entry_ex(cmd, param, strlen(param), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
- STR_RELEASE(cmd);
+ zend_string_release(cmd);
add_history(line);
- STR_RELEASE(prompt);
+ zend_string_release(prompt);
/* TODO: This might be wrong! */
prompt = cli_get_prompt("php", '>' TSRMLS_CC);
continue;
@@ -659,7 +659,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
}
free(line);
- STR_RELEASE(prompt);
+ zend_string_release(prompt);
if (!cli_is_valid_code(code, pos, &prompt TSRMLS_CC)) {
continue;
@@ -697,7 +697,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
}
free(history_file);
efree(code);
- STR_RELEASE(prompt);
+ zend_string_release(prompt);
return EG(exit_status);
}
/* }}} */
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index e4ad9416f0..94cb3fb273 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -121,7 +121,7 @@ typedef struct _string {
static void string_init(string *str)
{
- str->buf= STR_ALLOC(1024, 0);
+ str->buf= zend_string_alloc(1024, 0);
str->alloced = 1024;
str->buf->val[0] = '\0';
str->buf->len = 0;
@@ -140,7 +140,7 @@ static string *string_printf(string *str, const char *format, ...)
if (str->alloced < nlen) {
int old_len = str->buf->len;
str->alloced = nlen;
- str->buf = STR_REALLOC(str->buf, str->alloced, 0);
+ str->buf = zend_string_realloc(str->buf, str->alloced, 0);
str->buf->len = old_len;
}
memcpy(str->buf->val + str->buf->len, s_tmp, len + 1);
@@ -157,7 +157,7 @@ static string *string_write(string *str, char *buf, int len)
if (str->alloced < nlen) {
int old_len = str->buf->len;
str->alloced = nlen;
- str->buf = STR_REALLOC(str->buf, str->alloced, 0);
+ str->buf = zend_string_realloc(str->buf, str->alloced, 0);
str->buf->len = old_len;
}
memcpy(str->buf->val + str->buf->len, buf, len);
@@ -176,7 +176,7 @@ static string *string_append(string *str, string *append)
static void string_free(string *str)
{
- STR_RELEASE(str->buf);
+ zend_string_release(str->buf);
str->alloced = 0;
str->buf = NULL;
}
@@ -192,8 +192,8 @@ typedef struct _property_reference {
/* Struct for parameters */
typedef struct _parameter_reference {
- zend_uint offset;
- zend_uint required;
+ uint32_t offset;
+ uint32_t required;
struct _zend_arg_info *arg_info;
zend_function *fptr;
} parameter_reference;
@@ -270,7 +270,7 @@ static zend_function *_copy_function(zend_function *fptr TSRMLS_DC) /* {{{ */
zend_function *copy_fptr;
copy_fptr = emalloc(sizeof(zend_function));
memcpy(copy_fptr, fptr, sizeof(zend_function));
- copy_fptr->internal_function.function_name = STR_COPY(fptr->internal_function.function_name);
+ copy_fptr->internal_function.function_name = zend_string_copy(fptr->internal_function.function_name);
return copy_fptr;
} else {
/* no copy needed */
@@ -285,7 +285,7 @@ static void _free_function(zend_function *fptr TSRMLS_DC) /* {{{ */
&& fptr->type == ZEND_INTERNAL_FUNCTION
&& (fptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0)
{
- STR_RELEASE(fptr->internal_function.function_name);
+ zend_string_release(fptr->internal_function.function_name);
efree(fptr);
}
}
@@ -312,7 +312,7 @@ static void reflection_free_objects_storage(zend_object *object TSRMLS_DC) /* {{
break;
case REF_TYPE_DYNAMIC_PROPERTY:
prop_reference = (property_reference*)intern->ptr;
- STR_RELEASE(prop_reference->prop.name);
+ zend_string_release(prop_reference->prop.name);
efree(intern->ptr);
break;
case REF_TYPE_OTHER:
@@ -406,7 +406,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
}
if (ce->num_interfaces) {
- zend_uint i;
+ uint32_t i;
if (ce->ce_flags & ZEND_ACC_INTERFACE) {
string_printf(str, " extends %s", ce->interfaces[0]->name->val);
@@ -435,7 +435,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
HashPosition pos;
zval *value;
zend_string *key;
- ulong num_index;
+ zend_ulong num_index;
zend_hash_internal_pointer_reset_ex(&ce->constants_table, &pos);
@@ -565,7 +565,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
while ((prop = zend_hash_get_current_data_ptr_ex(properties, &pos)) != NULL) {
zend_string *prop_name;
- ulong index;
+ zend_ulong index;
if (zend_hash_get_current_key_ex(properties, &prop_name, &index, 0, &pos) == HASH_KEY_IS_STRING) {
if (prop_name->len && prop_name->val[0]) { /* skip all private and protected properties */
@@ -602,7 +602,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
{
zend_string *key;
- ulong num_index;
+ zend_ulong num_index;
uint len = mptr->common.function_name->len;
/* Do not display old-style inherited constructors */
@@ -655,12 +655,12 @@ static void _const_string(string *str, char *name, zval *value, char *indent TSR
string_printf(str, "%s Constant [ %s %s ] { %s }\n",
indent, type, name, value_str->val);
- STR_RELEASE(value_str);
+ zend_string_release(value_str);
}
/* }}} */
/* {{{ _get_recv_opcode */
-static zend_op* _get_recv_op(zend_op_array *op_array, zend_uint offset)
+static zend_op* _get_recv_op(zend_op_array *op_array, uint32_t offset)
{
zend_op *op = op_array->opcodes;
zend_op *end = op + op_array->last;
@@ -679,7 +679,7 @@ static zend_op* _get_recv_op(zend_op_array *op_array, zend_uint offset)
/* }}} */
/* {{{ _parameter_string */
-static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg_info *arg_info, zend_uint offset, zend_uint required, char* indent TSRMLS_DC)
+static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg_info *arg_info, uint32_t offset, uint32_t required, char* indent TSRMLS_DC)
{
string_printf(str, "Parameter #%d [ ", offset);
if (offset >= required) {
@@ -739,7 +739,7 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
} else {
zend_string *zv_str = zval_get_string(&zv);
string_write(str, zv_str->val, zv_str->len);
- STR_RELEASE(zv_str);
+ zend_string_release(zv_str);
}
zval_ptr_dtor(&zv);
}
@@ -752,7 +752,7 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
static void _function_parameter_string(string *str, zend_function *fptr, char* indent TSRMLS_DC)
{
struct _zend_arg_info *arg_info = fptr->common.arg_info;
- zend_uint i, required = fptr->common.required_num_args;
+ uint32_t i, required = fptr->common.required_num_args;
if (!arg_info) {
return;
@@ -773,8 +773,8 @@ static void _function_parameter_string(string *str, zend_function *fptr, char* i
/* {{{ _function_closure_string */
static void _function_closure_string(string *str, zend_function *fptr, char* indent TSRMLS_DC)
{
- zend_uint i, count;
- ulong num_index;
+ uint32_t i, count;
+ zend_ulong num_index;
zend_string *key;
HashTable *static_variables;
HashPosition pos;
@@ -834,7 +834,7 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry
string_printf(str, ", inherits %s", fptr->common.scope->name->val);
} else if (fptr->common.scope->parent) {
lc_name_len = fptr->common.function_name->len;
- lc_name = STR_ALLOC(lc_name_len, 0);
+ lc_name = zend_string_alloc(lc_name_len, 0);
zend_str_tolower_copy(lc_name->val, fptr->common.function_name->val, lc_name_len);
if ((overwrites = zend_hash_find_ptr(&fptr->common.scope->parent->function_table, lc_name)) != NULL) {
if (fptr->common.scope != overwrites->common.scope) {
@@ -1178,7 +1178,7 @@ PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object TSR
reflection_object *intern;
zval name;
- ZVAL_STR(&name, STR_COPY(ce->name));
+ ZVAL_STR(&name, zend_string_copy(ce->name));
reflection_instantiate(reflection_class_ptr, object TSRMLS_CC);
intern = Z_REFLECTION_P(object);
intern->ptr = ce;
@@ -1197,10 +1197,10 @@ static void reflection_extension_factory(zval *object, const char *name_str TSRM
zend_string *lcname;
struct _zend_module_entry *module;
- lcname = STR_ALLOC(name_len, 0);
+ lcname = zend_string_alloc(name_len, 0);
zend_str_tolower_copy(lcname->val, name_str, name_len);
module = zend_hash_find_ptr(&module_registry, lcname);
- STR_FREE(lcname);
+ zend_string_free(lcname);
if (!module) {
return;
}
@@ -1216,7 +1216,7 @@ static void reflection_extension_factory(zval *object, const char *name_str TSRM
/* }}} */
/* {{{ reflection_parameter_factory */
-static void reflection_parameter_factory(zend_function *fptr, zval *closure_object, struct _zend_arg_info *arg_info, zend_uint offset, zend_uint required, zval *object TSRMLS_DC)
+static void reflection_parameter_factory(zend_function *fptr, zval *closure_object, struct _zend_arg_info *arg_info, uint32_t offset, uint32_t required, zval *object TSRMLS_DC)
{
reflection_object *intern;
parameter_reference *reference;
@@ -1251,7 +1251,7 @@ static void reflection_function_factory(zend_function *function, zval *closure_o
reflection_object *intern;
zval name;
- ZVAL_STR(&name, STR_COPY(function->common.function_name));
+ ZVAL_STR(&name, zend_string_copy(function->common.function_name));
reflection_instantiate(reflection_function_ptr, object TSRMLS_CC);
intern = Z_REFLECTION_P(object);
@@ -1273,9 +1273,9 @@ static void reflection_method_factory(zend_class_entry *ce, zend_function *metho
zval name;
zval classname;
- ZVAL_STR(&name, STR_COPY((method->common.scope && method->common.scope->trait_aliases)?
+ ZVAL_STR(&name, zend_string_copy((method->common.scope && method->common.scope->trait_aliases)?
zend_resolve_method_name(ce, method) : method->common.function_name));
- ZVAL_STR(&classname, STR_COPY(method->common.scope->name));
+ ZVAL_STR(&classname, zend_string_copy(method->common.scope->name));
reflection_instantiate(reflection_method_ptr, object TSRMLS_CC);
intern = Z_REFLECTION_P(object);
intern->ptr = method;
@@ -1319,7 +1319,7 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info
}
ZVAL_STRING(&name, prop_name);
- ZVAL_STR(&classname, STR_COPY(prop->ce->name));
+ ZVAL_STR(&classname, zend_string_copy(prop->ce->name));
reflection_instantiate(reflection_property_ptr, object TSRMLS_CC);
intern = Z_REFLECTION_P(object);
@@ -1532,7 +1532,7 @@ ZEND_METHOD(reflection, export)
Returns an array of modifier names */
ZEND_METHOD(reflection, getModifierNames)
{
- long modifiers;
+ zend_long modifiers;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &modifiers) == FAILURE) {
return;
@@ -1622,7 +1622,7 @@ ZEND_METHOD(reflection_function, __construct)
return;
}
- ZVAL_STR(&name, STR_COPY(fptr->common.function_name));
+ ZVAL_STR(&name, zend_string_copy(fptr->common.function_name));
reflection_update_property(object, "name", &name);
intern->ptr = fptr;
intern->ref_type = REF_TYPE_FUNCTION;
@@ -1790,7 +1790,7 @@ ZEND_METHOD(reflection_function, getFileName)
}
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr->type == ZEND_USER_FUNCTION) {
- RETURN_STR(STR_COPY(fptr->op_array.filename));
+ RETURN_STR(zend_string_copy(fptr->op_array.filename));
}
RETURN_FALSE;
}
@@ -1844,7 +1844,7 @@ ZEND_METHOD(reflection_function, getDocComment)
}
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) {
- RETURN_STR(STR_COPY(fptr->op_array.doc_comment));
+ RETURN_STR(zend_string_copy(fptr->op_array.doc_comment));
}
RETURN_FALSE;
}
@@ -2033,7 +2033,7 @@ ZEND_METHOD(reflection_function, getParameters)
{
reflection_object *intern;
zend_function *fptr;
- zend_uint i;
+ uint32_t i;
struct _zend_arg_info *arg_info;
METHOD_NOTSTATIC(reflection_function_abstract_ptr);
@@ -2221,10 +2221,10 @@ ZEND_METHOD(reflection_parameter, __construct)
arg_info = fptr->common.arg_info;
if (Z_TYPE_P(parameter) == IS_LONG) {
position= Z_LVAL_P(parameter);
- if (position < 0 || (zend_uint)position >= fptr->common.num_args) {
+ if (position < 0 || (uint32_t)position >= fptr->common.num_args) {
if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) {
if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
- STR_RELEASE(fptr->common.function_name);
+ zend_string_release(fptr->common.function_name);
}
efree(fptr);
}
@@ -2235,7 +2235,7 @@ ZEND_METHOD(reflection_parameter, __construct)
/* returns out of this function */
}
} else {
- zend_uint i;
+ uint32_t i;
position= -1;
convert_to_string_ex(parameter);
@@ -2248,7 +2248,7 @@ ZEND_METHOD(reflection_parameter, __construct)
if (position == -1) {
if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) {
if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
- STR_RELEASE(fptr->common.function_name);
+ zend_string_release(fptr->common.function_name);
}
efree(fptr);
}
@@ -2269,7 +2269,7 @@ ZEND_METHOD(reflection_parameter, __construct)
ref = (parameter_reference*) emalloc(sizeof(parameter_reference));
ref->arg_info = &arg_info[position];
- ref->offset = (zend_uint)position;
+ ref->offset = (uint32_t)position;
ref->required = fptr->common.required_num_args;
ref->fptr = fptr;
/* TODO: copy fptr */
@@ -2396,9 +2396,9 @@ ZEND_METHOD(reflection_parameter, getClass)
}
ce = ce->parent;
} else {
- zend_string *name = STR_INIT(param->arg_info->class_name, param->arg_info->class_name_len, 0);
+ zend_string *name = zend_string_init(param->arg_info->class_name, param->arg_info->class_name_len, 0);
ce = zend_lookup_class(name TSRMLS_CC);
- STR_FREE(name);
+ zend_string_free(name);
if (!ce) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Class %s does not exist", param->arg_info->class_name);
@@ -2626,7 +2626,7 @@ ZEND_METHOD(reflection_parameter, getDefaultValueConstantName)
precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param);
if (precv && Z_TYPE_P(precv->op2.zv) == IS_CONSTANT) {
- RETURN_STR(STR_COPY(Z_STR_P(precv->op2.zv)));
+ RETURN_STR(zend_string_copy(Z_STR_P(precv->op2.zv)));
}
}
/* }}} */
@@ -2739,9 +2739,9 @@ ZEND_METHOD(reflection_method, __construct)
}
efree(lcname);
- ZVAL_STR(&name, STR_COPY(mptr->common.scope->name));
+ ZVAL_STR(&name, zend_string_copy(mptr->common.scope->name));
reflection_update_property(object, "class", &name);
- ZVAL_STR(&name, STR_COPY(mptr->common.function_name));
+ ZVAL_STR(&name, zend_string_copy(mptr->common.function_name));
reflection_update_property(object, "name", &name);
intern->ptr = mptr;
intern->ref_type = REF_TYPE_FUNCTION;
@@ -3304,7 +3304,7 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob
}
if (Z_TYPE_P(argument) == IS_OBJECT) {
- ZVAL_STR(&classname, STR_COPY(Z_OBJCE_P(argument)->name));
+ ZVAL_STR(&classname, zend_string_copy(Z_OBJCE_P(argument)->name));
reflection_update_property(object, "name", &classname);
intern->ptr = Z_OBJCE_P(argument);
if (is_object) {
@@ -3320,7 +3320,7 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob
return;
}
- ZVAL_STR(&classname, STR_COPY(ce->name));
+ ZVAL_STR(&classname, zend_string_copy(ce->name));
reflection_update_property(object, "name", &classname);
intern->ptr = ce;
@@ -3343,7 +3343,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
zend_property_info *prop_info;
zval *prop, prop_copy;
zend_string *key;
- ulong num_index;
+ zend_ulong num_index;
ZEND_HASH_FOREACH_KEY_PTR(&ce->properties_info, num_index, key, prop_info) {
if (((prop_info->flags & ZEND_ACC_SHADOW) &&
@@ -3548,7 +3548,7 @@ ZEND_METHOD(reflection_class, getFileName)
}
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->type == ZEND_USER_CLASS) {
- RETURN_STR(STR_COPY(ce->info.user.filename));
+ RETURN_STR(zend_string_copy(ce->info.user.filename));
}
RETURN_FALSE;
}
@@ -3602,7 +3602,7 @@ ZEND_METHOD(reflection_class, getDocComment)
}
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->type == ZEND_USER_CLASS && ce->info.user.doc_comment) {
- RETURN_STR(STR_COPY(ce->info.user.doc_comment));
+ RETURN_STR(zend_string_copy(ce->info.user.doc_comment));
}
RETURN_FALSE;
}
@@ -3744,7 +3744,7 @@ ZEND_METHOD(reflection_class, getMethods)
{
reflection_object *intern;
zend_class_entry *ce;
- long filter = 0;
+ zend_long filter = 0;
int argc = ZEND_NUM_ARGS();
METHOD_NOTSTATIC(reflection_class_ptr);
@@ -3794,7 +3794,7 @@ ZEND_METHOD(reflection_class, hasProperty)
RETURN_TRUE;
} else {
if (Z_TYPE(intern->obj) != IS_UNDEF && Z_OBJ_HANDLER(intern->obj, has_property)) {
- ZVAL_STR(&property, STR_COPY(name));
+ ZVAL_STR(&property, zend_string_copy(name));
if (Z_OBJ_HANDLER(intern->obj, has_property)(&intern->obj, &property, 2, NULL TSRMLS_CC)) {
zval_ptr_dtor(&property);
RETURN_TRUE;
@@ -3833,7 +3833,7 @@ ZEND_METHOD(reflection_class, getProperty)
if (zend_hash_exists(Z_OBJ_HT(intern->obj)->get_properties(&intern->obj TSRMLS_CC), name)) {
zend_property_info property_info_tmp;
property_info_tmp.flags = ZEND_ACC_IMPLICIT_PUBLIC;
- property_info_tmp.name = STR_COPY(name);
+ property_info_tmp.name = zend_string_copy(name);
property_info_tmp.doc_comment = NULL;
property_info_tmp.ce = ce;
@@ -3847,7 +3847,7 @@ ZEND_METHOD(reflection_class, getProperty)
str_name_len = name->len;
if ((tmp = strstr(name->val, "::")) != NULL) {
classname_len = tmp - name->val;
- classname = STR_ALLOC(classname_len, 0);
+ classname = zend_string_alloc(classname_len, 0);
zend_str_tolower_copy(classname->val, name->val, classname_len);
classname->val[classname_len] = '\0';
str_name_len = name->len - (classname_len + 2);
@@ -3858,10 +3858,10 @@ ZEND_METHOD(reflection_class, getProperty)
if (!EG(exception)) {
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Class %s does not exist", classname->val);
}
- STR_FREE(classname);
+ zend_string_free(classname);
return;
}
- STR_FREE(classname);
+ zend_string_free(classname);
if (!instanceof_function(ce, ce2 TSRMLS_CC)) {
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Fully qualified property name %s::%s does not specify a base class of %s", ce2->name->val, str_name, ce->name->val);
@@ -3934,7 +3934,7 @@ ZEND_METHOD(reflection_class, getProperties)
{
reflection_object *intern;
zend_class_entry *ce;
- long filter = 0;
+ zend_long filter = 0;
int argc = ZEND_NUM_ARGS();
METHOD_NOTSTATIC(reflection_class_ptr);
@@ -4352,7 +4352,7 @@ ZEND_METHOD(reflection_class, getInterfaces)
array_init(return_value);
if (ce->num_interfaces) {
- zend_uint i;
+ uint32_t i;
for (i=0; i < ce->num_interfaces; i++) {
zval interface;
@@ -4369,7 +4369,7 @@ ZEND_METHOD(reflection_class, getInterfaceNames)
{
reflection_object *intern;
zend_class_entry *ce;
- zend_uint i;
+ uint32_t i;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -4380,7 +4380,7 @@ ZEND_METHOD(reflection_class, getInterfaceNames)
array_init(return_value);
for (i=0; i < ce->num_interfaces; i++) {
- add_next_index_str(return_value, STR_COPY(ce->interfaces[i]->name));
+ add_next_index_str(return_value, zend_string_copy(ce->interfaces[i]->name));
}
}
/* }}} */
@@ -4391,7 +4391,7 @@ ZEND_METHOD(reflection_class, getTraits)
{
reflection_object *intern;
zend_class_entry *ce;
- zend_uint i;
+ uint32_t i;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -4414,7 +4414,7 @@ ZEND_METHOD(reflection_class, getTraitNames)
{
reflection_object *intern;
zend_class_entry *ce;
- zend_uint i;
+ uint32_t i;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -4424,7 +4424,7 @@ ZEND_METHOD(reflection_class, getTraitNames)
array_init(return_value);
for (i=0; i < ce->num_traits; i++) {
- add_next_index_str(return_value, STR_COPY(ce->traits[i]->name));
+ add_next_index_str(return_value, zend_string_copy(ce->traits[i]->name));
}
}
/* }}} */
@@ -4444,14 +4444,14 @@ ZEND_METHOD(reflection_class, getTraitAliases)
array_init(return_value);
if (ce->trait_aliases) {
- zend_uint i = 0;
+ uint32_t i = 0;
while (ce->trait_aliases[i]) {
zend_string *mname;
zend_trait_method_reference *cur_ref = ce->trait_aliases[i]->trait_method;
if (ce->trait_aliases[i]->alias) {
- mname = STR_ALLOC(cur_ref->ce->name->len + cur_ref->method_name->len + 2, 0);
+ mname = zend_string_alloc(cur_ref->ce->name->len + cur_ref->method_name->len + 2, 0);
snprintf(mname->val, mname->len + 1, "%s::%s", cur_ref->ce->name->val, cur_ref->method_name->val);
add_assoc_str_ex(return_value, ce->trait_aliases[i]->alias->val, ce->trait_aliases[i]->alias->len, mname);
}
@@ -4797,10 +4797,10 @@ ZEND_METHOD(reflection_property, __construct)
if (dynam_prop == 0) {
zend_unmangle_property_name(property_info->name->val, property_info->name->len, &class_name, &prop_name);
- ZVAL_STR(&cname, STR_COPY(property_info->ce->name));
+ ZVAL_STR(&cname, zend_string_copy(property_info->ce->name));
ZVAL_STRING(&propname, prop_name);
} else {
- ZVAL_STR(&cname, STR_COPY(ce->name));
+ ZVAL_STR(&cname, zend_string_copy(ce->name));
ZVAL_STRINGL(&propname, name_str, name_len);
}
reflection_update_property(object, "class", &cname);
@@ -5084,7 +5084,7 @@ ZEND_METHOD(reflection_property, getDocComment)
}
GET_REFLECTION_OBJECT_PTR(ref);
if (ref->prop.doc_comment) {
- RETURN_STR(STR_COPY(ref->prop.doc_comment));
+ RETURN_STR(zend_string_copy(ref->prop.doc_comment));
}
RETURN_FALSE;
}
@@ -5316,7 +5316,7 @@ static int add_extension_class(zval *zv TSRMLS_DC, int num_args, va_list args, z
zend_reflection_class_factory(ce, &zclass TSRMLS_CC);
zend_hash_update(Z_ARRVAL_P(class_array), ce->name, &zclass);
} else {
- add_next_index_str(class_array, STR_COPY(ce->name));
+ add_next_index_str(class_array, zend_string_copy(ce->name));
}
}
return ZEND_HASH_APPLY_KEEP;
@@ -5411,7 +5411,7 @@ ZEND_METHOD(reflection_extension, getDependencies)
len += strlen(dep->version) + 1;
}
- relation = STR_ALLOC(len, 0);
+ relation = zend_string_alloc(len, 0);
snprintf(relation->val, relation->len + 1, "%s%s%s%s%s",
rel_type,
dep->rel ? " " : "",
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 3366985279..b5c9354c87 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -187,7 +187,7 @@ static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC)
DIR *dir;
char dentry[sizeof(struct dirent) + MAXPATHLEN];
struct dirent *entry = (struct dirent *) &dentry;
- struct stat sbuf;
+ zend_stat_t sbuf;
char buf[MAXPATHLEN];
time_t now;
int nrdels = 0;
@@ -238,7 +238,7 @@ static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC)
static int ps_files_key_exists(ps_files *data, const char *key TSRMLS_DC)
{
char buf[MAXPATHLEN];
- struct stat sbuf;
+ zend_stat_t sbuf;
if (!key || !ps_files_path_create(buf, sizeof(buf), data, key)) {
return FAILURE;
@@ -283,7 +283,7 @@ PS_OPEN_FUNC(files)
if (argc > 1) {
errno = 0;
- dirdepth = (size_t) strtol(argv[0], NULL, 10);
+ dirdepth = (size_t) ZEND_STRTOL(argv[0], NULL, 10);
if (errno == ERANGE) {
php_error(E_WARNING, "The first parameter in session.save_path is invalid");
return FAILURE;
@@ -292,7 +292,7 @@ PS_OPEN_FUNC(files)
if (argc > 2) {
errno = 0;
- filemode = strtol(argv[1], NULL, 8);
+ filemode = ZEND_STRTOL(argv[1], NULL, 8);
if (errno == ERANGE || filemode < 0 || filemode > 07777) {
php_error(E_WARNING, "The second parameter in session.save_path is invalid");
return FAILURE;
@@ -335,7 +335,7 @@ PS_CLOSE_FUNC(files)
PS_READ_FUNC(files)
{
- long n;
+ zend_long n;
struct stat sbuf;
PS_FILES_DATA;
@@ -344,7 +344,7 @@ PS_READ_FUNC(files)
ps_files_key_exists(data, key? key->val : NULL TSRMLS_CC) == FAILURE) {
/* key points to PS(id), but cannot change here. */
if (key) {
- STR_RELEASE(PS(id));
+ zend_string_release(PS(id));
PS(id) = NULL;
}
PS(id) = PS(mod)->s_create_sid((void **)&data TSRMLS_CC);
@@ -374,7 +374,7 @@ PS_READ_FUNC(files)
return SUCCESS;
}
- *val = STR_ALLOC(sbuf.st_size, 0);
+ *val = zend_string_alloc(sbuf.st_size, 0);
#if defined(HAVE_PREAD)
n = pread(data->fd, (*val)->val, (*val)->len, 0);
@@ -389,7 +389,7 @@ PS_READ_FUNC(files)
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "read returned less bytes than requested");
}
- STR_RELEASE(*val);
+ zend_string_release(*val);
return FAILURE;
}
@@ -398,7 +398,7 @@ PS_READ_FUNC(files)
PS_WRITE_FUNC(files)
{
- long n;
+ zend_long n;
PS_FILES_DATA;
ps_files_open(data, key->val TSRMLS_CC);
@@ -481,7 +481,7 @@ PS_CREATE_SID_FUNC(files)
/* Check collision */
if (data && ps_files_key_exists(data, sid? sid->val : NULL TSRMLS_CC) == SUCCESS) {
if (sid) {
- STR_RELEASE(sid);
+ zend_string_release(sid);
sid = NULL;
}
if (!(maxfail--)) {
diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c
index 9e09dff83b..5d69712543 100644
--- a/ext/session/mod_user.c
+++ b/ext/session/mod_user.c
@@ -44,7 +44,7 @@ ps_module ps_mod_user = {
#define SESS_ZVAL_STR(vl, a) \
{ \
- ZVAL_STR(a, STR_COPY(vl)); \
+ ZVAL_STR(a, zend_string_copy(vl)); \
}
static void ps_call_handler(zval *func, int argc, zval *argv, zval *retval TSRMLS_DC)
@@ -150,7 +150,7 @@ PS_READ_FUNC(user)
if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) == IS_STRING) {
- *val = STR_COPY(Z_STR(retval));
+ *val = zend_string_copy(Z_STR(retval));
ret = SUCCESS;
}
zval_ptr_dtor(&retval);
@@ -207,7 +207,7 @@ PS_CREATE_SID_FUNC(user)
if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) == IS_STRING) {
- id = STR_COPY(Z_STR(retval));
+ id = zend_string_copy(Z_STR(retval));
}
zval_ptr_dtor(&retval);
} else {
diff --git a/ext/session/mod_user_class.c b/ext/session/mod_user_class.c
index 78b90f49fa..d6d538cc70 100644
--- a/ext/session/mod_user_class.c
+++ b/ext/session/mod_user_class.c
@@ -125,7 +125,7 @@ PHP_METHOD(SessionHandler, destroy)
Wraps the old gc handler */
PHP_METHOD(SessionHandler, gc)
{
- long maxlifetime;
+ zend_long maxlifetime;
int nrdels;
PS_SANITY_CHECK_IS_OPEN;
diff --git a/ext/session/php_session.h b/ext/session/php_session.h
index 403d9e0086..790e116528 100644
--- a/ext/session/php_session.h
+++ b/ext/session/php_session.h
@@ -104,8 +104,8 @@ typedef struct _php_session_rfc1867_progress {
zval sid;
smart_str key;
- long update_step;
- long next_update;
+ zend_long update_step;
+ zend_long next_update;
double next_update_time;
zend_bool cancel_upload;
zend_bool apply_trans_sid;
@@ -125,8 +125,8 @@ typedef struct _php_ps_globals {
char *extern_referer_chk;
char *entropy_file;
char *cache_limiter;
- long entropy_length;
- long cookie_lifetime;
+ zend_long entropy_length;
+ zend_long cookie_lifetime;
char *cookie_path;
char *cookie_domain;
zend_bool cookie_secure;
@@ -135,11 +135,11 @@ typedef struct _php_ps_globals {
ps_module *default_mod;
void *mod_data;
php_session_status session_status;
- long gc_probability;
- long gc_divisor;
- long gc_maxlifetime;
+ zend_long gc_probability;
+ zend_long gc_divisor;
+ zend_long gc_maxlifetime;
int module_number;
- long cache_expire;
+ zend_long cache_expire;
union {
zval names[7];
struct {
@@ -162,11 +162,11 @@ typedef struct _php_ps_globals {
zend_bool use_trans_sid; /* contains the INI value of whether to use trans-sid */
zend_bool apply_trans_sid; /* whether or not to enable trans-sid for the current request */
- long hash_func;
+ zend_long hash_func;
#if defined(HAVE_HASH_EXT) && !defined(COMPILE_DL_HASH)
php_hash_ops *hash_ops;
#endif
- long hash_bits_per_character;
+ zend_long hash_bits_per_character;
int send_cookie;
int define_sid;
zend_bool invalid_session_id; /* allows the driver to report about an invalid session id and request id regeneration */
@@ -176,7 +176,7 @@ typedef struct _php_ps_globals {
zend_bool rfc1867_cleanup; /* session.upload_progress.cleanup */
char *rfc1867_prefix; /* session.upload_progress.prefix */
char *rfc1867_name; /* session.upload_progress.name */
- long rfc1867_freq; /* session.upload_progress.freq */
+ zend_long rfc1867_freq; /* session.upload_progress.freq */
double rfc1867_min_freq; /* session.upload_progress.min_freq */
zend_bool use_strict_mode; /* whether or not PHP accepts unknown session ids */
@@ -254,7 +254,7 @@ PHPAPI void php_session_reset_id(TSRMLS_D);
#define PS_ENCODE_VARS \
zend_string *key; \
- ulong num_key; \
+ zend_ulong num_key; \
zval *struc;
#define PS_ENCODE_LOOP(code) do { \
@@ -262,7 +262,7 @@ PHPAPI void php_session_reset_id(TSRMLS_D);
ZEND_HASH_FOREACH_KEY(_ht, num_key, key) { \
if (key == NULL) { \
php_error_docref(NULL TSRMLS_CC, E_NOTICE, \
- "Skipping numeric key %ld", num_key); \
+ "Skipping numeric key %pd", num_key); \
continue; \
} \
if ((struc = php_get_session_var(key TSRMLS_CC))) { \
diff --git a/ext/session/session.c b/ext/session/session.c
index b03cfaa614..af1d50c255 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -115,7 +115,7 @@ static inline void php_rshutdown_session_globals(TSRMLS_D) /* {{{ */
} zend_end_try();
}
if (PS(id)) {
- STR_RELEASE(PS(id));
+ zend_string_release(PS(id));
}
}
/* }}} */
@@ -181,7 +181,7 @@ PHPAPI zval* php_get_session_var(zend_string *name TSRMLS_DC) /* {{{ */
static void php_session_track_init(TSRMLS_D) /* {{{ */
{
zval session_vars;
- zend_string *var_name = STR_INIT("_SESSION", sizeof("_SESSION") - 1, 0);
+ zend_string *var_name = zend_string_init("_SESSION", sizeof("_SESSION") - 1, 0);
/* Unconditionally destroy existing array -- possible dirty data */
zend_delete_global_variable(var_name TSRMLS_CC);
@@ -193,7 +193,7 @@ static void php_session_track_init(TSRMLS_D) /* {{{ */
ZVAL_NEW_REF(&PS(http_session_vars), &session_vars);
Z_ADDREF_P(&PS(http_session_vars));
zend_hash_update_ind(&EG(symbol_table).ht, var_name, &PS(http_session_vars));
- STR_RELEASE(var_name);
+ zend_string_release(var_name);
}
/* }}} */
@@ -305,7 +305,7 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
}
/* maximum 15+19+19+10 bytes */
- spprintf(&buf, 0, "%.15s%ld%ld%0.8F", remote_addr ? remote_addr : "", tv.tv_sec, (long int)tv.tv_usec, php_combined_lcg(TSRMLS_C) * 10);
+ spprintf(&buf, 0, "%.15s%ld" ZEND_LONG_FMT "%0.8F", remote_addr ? remote_addr : "", tv.tv_sec, (zend_long)tv.tv_usec, php_combined_lcg(TSRMLS_C) * 10);
switch (PS(hash_func)) {
case PS_HASH_FUNC_MD5:
@@ -416,7 +416,7 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The ini setting hash_bits_per_character is out of range (should be 4, 5, or 6) - using 4 for now");
}
- outid = STR_ALLOC((digest_len + 2) * ((8.0f / PS(hash_bits_per_character) + 0.5)), 0);
+ outid = zend_string_alloc((digest_len + 2) * ((8.0f / PS(hash_bits_per_character) + 0.5)), 0);
outid->len = (int)(bin_to_readable((char *)digest, digest_len, outid->val, (char)PS(hash_bits_per_character)) - (char *)&outid->val);
efree(digest);
@@ -514,7 +514,7 @@ static void php_session_initialize(TSRMLS_D) /* {{{ */
PHP_MD5Final(PS(session_data_hash), &context);
php_session_decode(val->val, val->len TSRMLS_CC);
- STR_RELEASE(val);
+ zend_string_release(val);
} else {
memset(PS(session_data_hash),'\0', 16);
}
@@ -551,7 +551,7 @@ static void php_session_save_current_state(TSRMLS_D) /* {{{ */
} else {
ret = SUCCESS;
}
- STR_RELEASE(val);
+ zend_string_release(val);
} else {
ret = PS(mod)->s_write(&PS(mod_data), PS(id), STR_EMPTY_ALLOC() TSRMLS_CC);
}
@@ -705,14 +705,14 @@ static PHP_INI_MH(OnUpdateName) /* {{{ */
static PHP_INI_MH(OnUpdateHashFunc) /* {{{ */
{
- long val;
+ zend_long val;
char *endptr = NULL;
#if defined(HAVE_HASH_EXT) && !defined(COMPILE_DL_HASH)
PS(hash_ops) = NULL;
#endif
- val = strtol(new_value, &endptr, 10);
+ val = ZEND_STRTOL(new_value, &endptr, 10);
if (endptr && (*endptr == '\0')) {
/* Numeric value */
PS(hash_func) = val ? 1 : 0;
@@ -846,7 +846,7 @@ PS_SERIALIZER_DECODE_FUNC(php_serialize) /* {{{ */
const char *endptr = val + vallen;
zval session_vars;
php_unserialize_data_t var_hash;
- zend_string *var_name = STR_INIT("_SESSION", sizeof("_SESSION") - 1, 0);
+ zend_string *var_name = zend_string_init("_SESSION", sizeof("_SESSION") - 1, 0);
ZVAL_NULL(&session_vars);
PHP_VAR_UNSERIALIZE_INIT(var_hash);
@@ -861,7 +861,7 @@ PS_SERIALIZER_DECODE_FUNC(php_serialize) /* {{{ */
ZVAL_NEW_REF(&PS(http_session_vars), &session_vars);
Z_ADDREF_P(&PS(http_session_vars));
zend_hash_update_ind(&EG(symbol_table).ht, var_name, &PS(http_session_vars));
- STR_RELEASE(var_name);
+ zend_string_release(var_name);
return SUCCESS;
}
/* }}} */
@@ -918,7 +918,7 @@ PS_SERIALIZER_DECODE_FUNC(php_binary) /* {{{ */
has_value = *p & PS_BIN_UNDEF ? 0 : 1;
- name = STR_INIT(p + 1, namelen, 0);
+ name = zend_string_init(p + 1, namelen, 0);
p += namelen + 1;
@@ -939,7 +939,7 @@ PS_SERIALIZER_DECODE_FUNC(php_binary) /* {{{ */
}
}
PS_ADD_VARL(name);
- STR_RELEASE(name);
+ zend_string_release(name);
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
@@ -1010,7 +1010,7 @@ PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */
}
namelen = q - p;
- name = STR_INIT(p, namelen, 0);
+ name = zend_string_init(p, namelen, 0);
q++;
if ((tmp = zend_hash_find(&EG(symbol_table).ht, name))) {
@@ -1030,7 +1030,7 @@ PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */
}
PS_ADD_VARL(name);
skip:
- STR_RELEASE(name);
+ zend_string_release(name);
p = q;
}
@@ -1148,7 +1148,7 @@ static inline void strcpy_gmt(char *ubuf, time_t *when) /* {{{ */
static inline void last_modified(TSRMLS_D) /* {{{ */
{
const char *path;
- struct stat sb;
+ zend_stat_t sb;
char buf[MAX_STR + 1];
path = SG(request_info).path_translated;
@@ -1178,7 +1178,7 @@ CACHE_LIMITER_FUNC(public) /* {{{ */
strcpy_gmt(buf + sizeof(EXPIRES) - 1, &now);
ADD_HEADER(buf);
- snprintf(buf, sizeof(buf) , "Cache-Control: public, max-age=%ld", PS(cache_expire) * 60); /* SAFE */
+ snprintf(buf, sizeof(buf) , "Cache-Control: public, max-age=" ZEND_LONG_FMT, PS(cache_expire) * 60); /* SAFE */
ADD_HEADER(buf);
last_modified(TSRMLS_C);
@@ -1189,7 +1189,7 @@ CACHE_LIMITER_FUNC(private_no_expire) /* {{{ */
{
char buf[MAX_STR + 1];
- snprintf(buf, sizeof(buf), "Cache-Control: private, max-age=%ld, pre-check=%ld", PS(cache_expire) * 60, PS(cache_expire) * 60); /* SAFE */
+ snprintf(buf, sizeof(buf), "Cache-Control: private, max-age=" ZEND_LONG_FMT ", pre-check=" ZEND_LONG_FMT, PS(cache_expire) * 60, PS(cache_expire) * 60); /* SAFE */
ADD_HEADER(buf);
last_modified(TSRMLS_C);
@@ -1266,12 +1266,13 @@ static void php_session_remove_cookie(TSRMLS_D) {
zend_llist *l = &SG(sapi_headers).headers;
zend_llist_element *next;
zend_llist_element *current;
- char *session_cookie, *e_session_name;
+ char *session_cookie;
+ zend_string *e_session_name;
int session_cookie_len, len = sizeof("Set-Cookie")-1;
e_session_name = php_url_encode(PS(session_name), strlen(PS(session_name)));
- spprintf(&session_cookie, 0, "Set-Cookie: %s=", e_session_name);
- efree(e_session_name);
+ spprintf(&session_cookie, 0, "Set-Cookie: %s=", e_session_name->val);
+ zend_string_free(e_session_name);
session_cookie_len = strlen(session_cookie);
current = l->head;
@@ -1326,8 +1327,8 @@ static void php_session_send_cookie(TSRMLS_D) /* {{{ */
smart_str_appendc(&ncookie, '=');
smart_str_appendl(&ncookie, e_id->val, e_id->len);
- STR_RELEASE(e_session_name);
- STR_RELEASE(e_id);
+ zend_string_release(e_session_name);
+ zend_string_release(e_id);
if (PS(cookie_lifetime) > 0) {
struct timeval tv;
@@ -1340,7 +1341,7 @@ static void php_session_send_cookie(TSRMLS_D) /* {{{ */
date_fmt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, t, 0 TSRMLS_CC);
smart_str_appends(&ncookie, COOKIE_EXPIRES);
smart_str_appendl(&ncookie, date_fmt->val, date_fmt->len);
- STR_RELEASE(date_fmt);
+ zend_string_release(date_fmt);
smart_str_appends(&ncookie, COOKIE_MAX_AGE);
smart_str_append_long(&ncookie, PS(cookie_lifetime));
@@ -1412,7 +1413,7 @@ static void ppid2sid(zval *ppid TSRMLS_DC) {
PS(send_cookie) = 1;
} else {
convert_to_string(ppid);
- PS(id) = STR_INIT(Z_STRVAL_P(ppid), Z_STRLEN_P(ppid), 0);
+ PS(id) = zend_string_init(Z_STRVAL_P(ppid), Z_STRLEN_P(ppid), 0);
PS(send_cookie) = 0;
}
}
@@ -1546,7 +1547,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */
p += lensess + 1;
if ((q = strpbrk(p, "/?\\"))) {
- PS(id) = STR_INIT(p, q - p, 0);
+ PS(id) = zend_string_init(p, q - p, 0);
PS(send_cookie) = 0;
}
}
@@ -1562,7 +1563,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */
Z_STRLEN_P(data) != 0 &&
strstr(Z_STRVAL_P(data), PS(extern_referer_chk)) == NULL
) {
- STR_RELEASE(PS(id));
+ zend_string_release(PS(id));
PS(id) = NULL;
PS(send_cookie) = 1;
if (PS(use_trans_sid) && !PS(use_only_cookies)) {
@@ -1573,7 +1574,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */
/* Finally check session id for dangerous characters
* Security note: session id may be embedded in HTML pages.*/
if (PS(id) && strpbrk(PS(id)->val, "\r\n\t <>'\"\\")) {
- STR_RELEASE(PS(id));
+ zend_string_release(PS(id));
PS(id) = NULL;
}
@@ -1654,30 +1655,30 @@ static PHP_FUNCTION(session_set_cookie_params)
convert_to_string_ex(lifetime);
- ini_name = STR_INIT("session.cookie_lifetime", sizeof("session.cookie_lifetime") - 1, 0);
+ ini_name = zend_string_init("session.cookie_lifetime", sizeof("session.cookie_lifetime") - 1, 0);
zend_alter_ini_entry(ini_name, Z_STRVAL_P(lifetime), Z_STRLEN_P(lifetime), PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
if (path) {
- ini_name = STR_INIT("session.cookie_path", sizeof("session.cookie_path") - 1, 0);
+ ini_name = zend_string_init("session.cookie_path", sizeof("session.cookie_path") - 1, 0);
zend_alter_ini_entry(ini_name, path, path_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
if (domain) {
- ini_name = STR_INIT("session.cookie_domain", sizeof("session.cookie_domain") - 1, 0);
+ ini_name = zend_string_init("session.cookie_domain", sizeof("session.cookie_domain") - 1, 0);
zend_alter_ini_entry(ini_name, domain, domain_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
if (argc > 3) {
- ini_name = STR_INIT("session.cookie_secure", sizeof("session.cookie_secure") - 1, 0);
+ ini_name = zend_string_init("session.cookie_secure", sizeof("session.cookie_secure") - 1, 0);
zend_alter_ini_entry(ini_name, secure ? "1" : "0", 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
if (argc > 4) {
- ini_name = STR_INIT("session.cookie_httponly", sizeof("session.cookie_httponly") - 1, 0);
+ ini_name = zend_string_init("session.cookie_httponly", sizeof("session.cookie_httponly") - 1, 0);
zend_alter_ini_entry(ini_name, httponly ? "1" : "0", 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
}
/* }}} */
@@ -1715,9 +1716,9 @@ static PHP_FUNCTION(session_name)
RETVAL_STRING(PS(session_name));
if (name) {
- ini_name = STR_INIT("session.name", sizeof("session.name") - 1, 0);
+ ini_name = zend_string_init("session.name", sizeof("session.name") - 1, 0);
zend_alter_ini_entry(ini_name, name, name_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
}
/* }}} */
@@ -1753,9 +1754,9 @@ static PHP_FUNCTION(session_module_name)
}
PS(mod_data) = NULL;
- ini_name = STR_INIT("session.save_handler", sizeof("session.save_handler") - 1, 0);
+ ini_name = zend_string_init("session.save_handler", sizeof("session.save_handler") - 1, 0);
zend_alter_ini_entry(ini_name, name, name_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
}
/* }}} */
@@ -1778,7 +1779,7 @@ static PHP_FUNCTION(session_set_save_handler)
zend_string *func_name;
HashPosition pos;
zend_function *default_mptr, *current_mptr;
- ulong func_index;
+ zend_ulong func_index;
php_shutdown_function_entry shutdown_function_entry;
zend_bool register_shutdown = 1;
@@ -1850,9 +1851,9 @@ static PHP_FUNCTION(session_set_save_handler)
}
if (PS(mod) && PS(session_status) == php_session_none && PS(mod) != &ps_mod_user) {
- ini_name = STR_INIT("session.save_handler", sizeof("session.save_handler") - 1, 0);
+ ini_name = zend_string_init("session.save_handler", sizeof("session.save_handler") - 1, 0);
zend_alter_ini_entry(ini_name, "user", sizeof("user") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
RETURN_TRUE;
@@ -1873,16 +1874,16 @@ static PHP_FUNCTION(session_set_save_handler)
for (i = 0; i < argc; i++) {
if (!zend_is_callable(&args[i], 0, &name TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument %d is not a valid callback", i+1);
- STR_RELEASE(name);
+ zend_string_release(name);
RETURN_FALSE;
}
- STR_RELEASE(name);
+ zend_string_release(name);
}
if (PS(mod) && PS(mod) != &ps_mod_user) {
- ini_name = STR_INIT("session.save_handler", sizeof("session.save_handler") - 1, 0);
+ ini_name = zend_string_init("session.save_handler", sizeof("session.save_handler") - 1, 0);
zend_alter_ini_entry(ini_name, "user", sizeof("user")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
for (i = 0; i < argc; i++) {
@@ -1916,9 +1917,9 @@ static PHP_FUNCTION(session_save_path)
zval_dtor(return_value);
RETURN_FALSE;
}
- ini_name = STR_INIT("session.save_path", sizeof("session.save_path") - 1, 0);
+ ini_name = zend_string_init("session.save_path", sizeof("session.save_path") - 1, 0);
zend_alter_ini_entry(ini_name, name, name_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
}
/* }}} */
@@ -1939,9 +1940,9 @@ static PHP_FUNCTION(session_id)
* see: ext/session/tests/session_id_error3.phpt */
int len = strlen(PS(id)->val);
if (UNEXPECTED(len != PS(id)->len)) {
- RETVAL_STR(STR_INIT(PS(id)->val, len, 0));
+ RETVAL_STR(zend_string_init(PS(id)->val, len, 0));
} else {
- RETVAL_STR(STR_COPY(PS(id)));
+ RETVAL_STR(zend_string_copy(PS(id)));
}
} else {
RETVAL_EMPTY_STRING();
@@ -1949,9 +1950,9 @@ static PHP_FUNCTION(session_id)
if (name) {
if (PS(id)) {
- STR_RELEASE(PS(id));
+ zend_string_release(PS(id));
}
- PS(id) = STR_COPY(name);
+ PS(id) = zend_string_copy(name);
}
}
/* }}} */
@@ -1977,8 +1978,8 @@ static PHP_FUNCTION(session_regenerate_id)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Session object destruction failed");
RETURN_FALSE;
}
- STR_RELEASE(PS(id));
- PS(id) = NULL;
+ zend_string_release(PS(id));
+ memset(PS(session_data_hash),'\0', 16);
}
PS(id) = PS(mod)->s_create_sid(&PS(mod_data) TSRMLS_CC);
@@ -2009,9 +2010,9 @@ static PHP_FUNCTION(session_cache_limiter)
RETVAL_STRING(PS(cache_limiter));
if (limiter) {
- ini_name = STR_INIT("session.cache_limiter", sizeof("session.cache_limiter") - 1, 0);
+ ini_name = zend_string_init("session.cache_limiter", sizeof("session.cache_limiter") - 1, 0);
zend_alter_ini_entry(ini_name, limiter, limiter_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
}
/* }}} */
@@ -2031,9 +2032,9 @@ static PHP_FUNCTION(session_cache_expire)
if (expires) {
convert_to_string_ex(expires);
- ini_name = STR_INIT("session.cache_expire", sizeof("session.cache_expire") - 1, 0);
+ ini_name = zend_string_init("session.cache_expire", sizeof("session.cache_expire") - 1, 0);
zend_alter_ini_entry(ini_name, Z_STRVAL_P(expires), Z_STRLEN_P(expires), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
- STR_RELEASE(ini_name);
+ zend_string_release(ini_name);
}
}
/* }}} */
@@ -2431,7 +2432,7 @@ static PHP_MINIT_FUNCTION(session) /* {{{ */
{
zend_class_entry ce;
- zend_register_auto_global(STR_INIT("_SESSION", sizeof("_SESSION") - 1, 1), 0, NULL TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_SESSION", sizeof("_SESSION") - 1, 1), 0, NULL TSRMLS_CC);
PS(module_number) = module_number; /* if we really need this var we need to init it in zts mode as well! */
@@ -2719,7 +2720,7 @@ static int php_session_rfc1867_callback(unsigned int event, void *event_data, vo
array_init(&progress->data);
array_init(&progress->files);
- add_assoc_long_ex(&progress->data, "start_time", sizeof("start_time") - 1, (long)sapi_get_request_time(TSRMLS_C));
+ add_assoc_long_ex(&progress->data, "start_time", sizeof("start_time") - 1, (zend_long)sapi_get_request_time(TSRMLS_C));
add_assoc_long_ex(&progress->data, "content_length", sizeof("content_length") - 1, progress->content_length);
add_assoc_long_ex(&progress->data, "bytes_processed", sizeof("bytes_processed") - 1, data->post_bytes_processed);
add_assoc_bool_ex(&progress->data, "done", sizeof("done") - 1, 0);
@@ -2728,7 +2729,7 @@ static int php_session_rfc1867_callback(unsigned int event, void *event_data, vo
progress->post_bytes_processed = zend_hash_str_find(Z_ARRVAL(progress->data), "bytes_processed", sizeof("bytes_processed") - 1);
php_rinit_session(0 TSRMLS_CC);
- PS(id) = STR_INIT(Z_STRVAL(progress->sid), Z_STRLEN(progress->sid), 0);
+ PS(id) = zend_string_init(Z_STRVAL(progress->sid), Z_STRLEN(progress->sid), 0);
PS(apply_trans_sid) = progress->apply_trans_sid;
PS(send_cookie) = 0;
}
@@ -2742,7 +2743,7 @@ static int php_session_rfc1867_callback(unsigned int event, void *event_data, vo
add_assoc_long_ex(&progress->current_file, "error", sizeof("error") - 1, 0);
add_assoc_bool_ex(&progress->current_file, "done", sizeof("done") - 1, 0);
- add_assoc_long_ex(&progress->current_file, "start_time", sizeof("start_time") - 1, (long)time(NULL));
+ add_assoc_long_ex(&progress->current_file, "start_time", sizeof("start_time") - 1, (zend_long)time(NULL));
add_assoc_long_ex(&progress->current_file, "bytes_processed", sizeof("bytes_processed") - 1, 0);
add_next_index_zval(&progress->files, &progress->current_file);
diff --git a/ext/session/tests/bug67694.phpt b/ext/session/tests/bug67694.phpt
new file mode 100644
index 0000000000..08a296923f
--- /dev/null
+++ b/ext/session/tests/bug67694.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Bug #67694 Regression in session_regenerate_id()
+--INI--
+session.save_handler = files
+session.name=PHPSESSID
+session.auto_start = 0
+session.use_cookies = 0
+session.cache_limiter =
+date.timezone = UTC
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--FILE--
+<?php
+
+$data = date('r');
+
+session_start();
+$id = session_id();
+$_SESSION['init'] = $data;
+
+session_write_close();
+
+session_id($id);
+session_start();
+
+session_regenerate_id(false);
+
+$newid = session_id();
+var_dump($newid != $id);
+
+session_write_close();
+
+unset($_SESSION);
+
+session_id($newid);
+session_start();
+
+var_dump(isset($_SESSION['init']) && $data == $_SESSION['init']);
+--EXPECT--
+bool(true)
+bool(true)
diff --git a/ext/session/tests/session_module_name_variation3.phpt b/ext/session/tests/session_module_name_variation3.phpt
index e32790d54e..b282b4025d 100644
--- a/ext/session/tests/session_module_name_variation3.phpt
+++ b/ext/session/tests/session_module_name_variation3.phpt
@@ -48,4 +48,4 @@ Stack trace:
#2 {main}
thrown in %s on line %d
-Fatal error: session_start(): Failed to initialize storage module: %s in %s/session_module_name_variation3.php on line %d
+Fatal error: session_start(): Failed to initialize storage module: %s in %s%esession_module_name_variation3.php on line %d
diff --git a/ext/shmop/php_shmop.h b/ext/shmop/php_shmop.h
index 2779fe14be..b9eaba6f07 100644
--- a/ext/shmop/php_shmop.h
+++ b/ext/shmop/php_shmop.h
@@ -45,7 +45,7 @@ struct php_shmop
int shmflg;
int shmatflg;
char *addr;
- int size;
+ zend_long size;
};
typedef struct {
diff --git a/ext/shmop/shmop.c b/ext/shmop/shmop.c
index c6569aa4c8..87faa0bdf7 100644
--- a/ext/shmop/shmop.c
+++ b/ext/shmop/shmop.c
@@ -146,7 +146,7 @@ PHP_MINFO_FUNCTION(shmop)
gets and attaches a shared memory segment */
PHP_FUNCTION(shmop_open)
{
- long key, mode, size;
+ zend_long key, mode, size;
struct php_shmop *shmop;
struct shmid_ds shm;
char *flags;
@@ -227,7 +227,7 @@ err:
reads from a shm segment */
PHP_FUNCTION(shmop_read)
{
- long shmid, start, count;
+ zend_long shmid, start, count;
struct php_shmop *shmop;
char *startaddr;
int bytes;
@@ -252,7 +252,7 @@ PHP_FUNCTION(shmop_read)
startaddr = shmop->addr + start;
bytes = count ? count : shmop->size - start;
- return_string = STR_INIT(startaddr, bytes, 0);
+ return_string = zend_string_init(startaddr, bytes, 0);
RETURN_STR(return_string);
}
@@ -262,7 +262,7 @@ PHP_FUNCTION(shmop_read)
closes a shared memory segment */
PHP_FUNCTION(shmop_close)
{
- long shmid;
+ zend_long shmid;
zval *res;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &shmid) == FAILURE) {
@@ -280,7 +280,7 @@ PHP_FUNCTION(shmop_close)
returns the shm size */
PHP_FUNCTION(shmop_size)
{
- long shmid;
+ zend_long shmid;
struct php_shmop *shmop;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &shmid) == FAILURE) {
@@ -299,11 +299,10 @@ PHP_FUNCTION(shmop_write)
{
struct php_shmop *shmop;
int writesize;
- long shmid, offset;
- char *data;
- int data_len;
+ zend_long shmid, offset;
+ zend_string *data;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lsl", &shmid, &data, &data_len, &offset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lSl", &shmid, &data, &offset) == FAILURE) {
return;
}
@@ -319,8 +318,8 @@ PHP_FUNCTION(shmop_write)
RETURN_FALSE;
}
- writesize = (data_len < shmop->size - offset) ? data_len : shmop->size - offset;
- memcpy(shmop->addr + offset, data, writesize);
+ writesize = (data->len < shmop->size - offset) ? data->len : shmop->size - offset;
+ memcpy(shmop->addr + offset, data->val, writesize);
RETURN_LONG(writesize);
}
@@ -330,7 +329,7 @@ PHP_FUNCTION(shmop_write)
mark segment for deletion */
PHP_FUNCTION(shmop_delete)
{
- long shmid;
+ zend_long shmid;
struct php_shmop *shmop;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &shmid) == FAILURE) {
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 014bf2f4f6..a65fd30046 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -138,9 +138,9 @@ static inline int match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name,
}
/* }}} */
-static xmlNodePtr sxe_get_element_by_offset(php_sxe_object *sxe, long offset, xmlNodePtr node, long *cnt) /* {{{ */
+static xmlNodePtr sxe_get_element_by_offset(php_sxe_object *sxe, zend_long offset, xmlNodePtr node, zend_long *cnt) /* {{{ */
{
- long nodendx = 0;
+ zend_long nodendx = 0;
if (sxe->iter.type == SXE_ITER_NONE) {
if (offset == 0) {
@@ -328,7 +328,7 @@ static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, z
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, node, NULL TSRMLS_CC);
}
if (!member || Z_TYPE_P(member) == IS_LONG) {
- long cnt = 0;
+ zend_long cnt = 0;
xmlNodePtr mynode = node;
if (sxe->iter.type == SXE_ITER_CHILD) {
@@ -336,7 +336,7 @@ static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, z
}
if (sxe->iter.type == SXE_ITER_NONE) {
if (member && Z_LVAL_P(member) > 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element %s number %ld when only 0 such elements exist", mynode->name, Z_LVAL_P(member));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element %s number %pd when only 0 such elements exist", mynode->name, Z_LVAL_P(member));
}
} else if (member) {
node = sxe_get_element_by_offset(sxe, Z_LVAL_P(member), node, &cnt);
@@ -347,7 +347,7 @@ static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, z
_node_as_zval(sxe, node, rv, SXE_ITER_NONE, NULL, sxe->iter.nsprefix, sxe->iter.isprefix TSRMLS_CC);
} else if (type == BP_VAR_W || type == BP_VAR_RW) {
if (member && cnt < Z_LVAL_P(member)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element %s number %ld when only %ld such elements exist", mynode->name, Z_LVAL_P(member), cnt);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element %s number %pd when only %pd such elements exist", mynode->name, Z_LVAL_P(member), cnt);
}
node = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, NULL);
_node_as_zval(sxe, node, rv, SXE_ITER_NONE, NULL, sxe->iter.nsprefix, sxe->iter.isprefix TSRMLS_CC);
@@ -456,7 +456,7 @@ static int sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool
int nodendx = 0;
int test = 0;
int new_value = 0;
- long cnt = 0;
+ zend_long cnt = 0;
int retval = SUCCESS;
zval tmp_zv, trim_zv, zval_copy;
@@ -595,7 +595,7 @@ static int sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool
newnode = node;
++counter;
if (member && Z_LVAL_P(member) > 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element %s number %ld when only 0 such elements exist", mynode->name, Z_LVAL_P(member));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element %s number %pd when only 0 such elements exist", mynode->name, Z_LVAL_P(member));
retval = FAILURE;
}
} else if (member) {
@@ -643,14 +643,14 @@ next_iter:
}
} else if (!member || Z_TYPE_P(member) == IS_LONG) {
if (member && cnt < Z_LVAL_P(member)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element %s number %ld when only %ld such elements exist", mynode->name, Z_LVAL_P(member), cnt);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element %s number %pd when only %pd such elements exist", mynode->name, Z_LVAL_P(member), cnt);
retval = FAILURE;
}
newnode = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, value ? (xmlChar *)Z_STRVAL_P(value) : NULL);
}
} else if (attribs) {
if (Z_TYPE_P(member) == IS_LONG) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot change attribute number %ld when only %d attributes exist", Z_LVAL_P(member), nodendx);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot change attribute number %pd when only %d attributes exist", Z_LVAL_P(member), nodendx);
retval = FAILURE;
} else {
newnode = (xmlNodePtr)xmlNewProp(node, (xmlChar *)Z_STRVAL_P(member), value ? (xmlChar *)Z_STRVAL_P(value) : NULL);
@@ -984,7 +984,7 @@ static inline zend_string *sxe_xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr li
zend_string *res;
if (tmp) {
- res = STR_INIT((char*)tmp, strlen((char *)tmp), 0);
+ res = zend_string_init((char*)tmp, strlen((char *)tmp), 0);
xmlFree(tmp);
} else {
res = STR_EMPTY_ALLOC();
@@ -1771,7 +1771,7 @@ static int cast_object(zval *object, int type, char *contents TSRMLS_DC)
convert_to_boolean(object);
break;
case IS_LONG:
- convert_to_long(object);
+ convert_to_int(object);
break;
case IS_DOUBLE:
convert_to_double(object);
@@ -1864,7 +1864,7 @@ SXE_METHOD(__toString)
}
/* }}} */
-static int php_sxe_count_elements_helper(php_sxe_object *sxe, long *count TSRMLS_DC) /* {{{ */
+static int php_sxe_count_elements_helper(php_sxe_object *sxe, zend_long *count TSRMLS_DC) /* {{{ */
{
xmlNodePtr node;
zval data;
@@ -1891,7 +1891,7 @@ static int php_sxe_count_elements_helper(php_sxe_object *sxe, long *count TSRMLS
}
/* }}} */
-static int sxe_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
+static int sxe_count_elements(zval *object, zend_long *count TSRMLS_DC) /* {{{ */
{
php_sxe_object *intern;
intern = Z_SXEOBJ_P(object);
@@ -1903,8 +1903,8 @@ static int sxe_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
zval_ptr_dtor(&intern->tmp);
}
ZVAL_ZVAL(&intern->tmp, &rv, 0, 0);
- convert_to_long(&intern->tmp);
- *count = (long)Z_LVAL(intern->tmp);
+ convert_to_int(&intern->tmp);
+ *count = (zend_long)Z_LVAL(intern->tmp);
return SUCCESS;
}
return FAILURE;
@@ -1917,7 +1917,7 @@ static int sxe_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
Get number of child elements */
SXE_METHOD(count)
{
- long count = 0;
+ zend_long count = 0;
php_sxe_object *sxe = Z_SXEOBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
@@ -2118,7 +2118,7 @@ PHP_FUNCTION(simplexml_load_file)
xmlDocPtr docp;
char *ns = NULL;
int ns_len = 0;
- long options = 0;
+ zend_long options = 0;
zend_class_entry *ce= sxe_class_entry;
zend_bool isprefix = 0;
@@ -2155,7 +2155,7 @@ PHP_FUNCTION(simplexml_load_string)
xmlDocPtr docp;
char *ns = NULL;
int ns_len = 0;
- long options = 0;
+ zend_long options = 0;
zend_class_entry *ce= sxe_class_entry;
zend_bool isprefix = 0;
@@ -2190,7 +2190,7 @@ SXE_METHOD(__construct)
char *data, *ns = NULL;
int data_len, ns_len = 0;
xmlDocPtr docp;
- long options = 0;
+ zend_long options = 0;
zend_bool is_url = 0, isprefix = 0;
zend_error_handling error_handling;
diff --git a/ext/xml/tests/bug62328.phpt b/ext/simplexml/tests/bug62328.phpt
index e4c3c59d37..a6e60e488c 100644
--- a/ext/xml/tests/bug62328.phpt
+++ b/ext/simplexml/tests/bug62328.phpt
@@ -1,9 +1,7 @@
--TEST--
Bug #62328 (implementing __toString and a cast to string fails)
--SKIPIF--
-<?php
-require_once("skipif.inc");
-?>
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
<?php
class UberSimpleXML extends SimpleXMLElement {
diff --git a/ext/skeleton/php_skeleton.h b/ext/skeleton/php_skeleton.h
index d0ba6f04ab..bf73bfcc9b 100644
--- a/ext/skeleton/php_skeleton.h
+++ b/ext/skeleton/php_skeleton.h
@@ -25,7 +25,7 @@ extern zend_module_entry extname_module_entry;
and END macros here:
ZEND_BEGIN_MODULE_GLOBALS(extname)
- long global_value;
+ zend_long global_value;
char *global_string;
ZEND_END_MODULE_GLOBALS(extname)
*/
diff --git a/ext/snmp/php_snmp.h b/ext/snmp/php_snmp.h
index 50bd272204..6e170ffe71 100644
--- a/ext/snmp/php_snmp.h
+++ b/ext/snmp/php_snmp.h
@@ -133,7 +133,7 @@ ZEND_END_MODULE_GLOBALS(snmp)
#endif
#define REGISTER_SNMP_CLASS_CONST_LONG(const_name, value) \
- zend_declare_class_constant_long(php_snmp_ce, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
+ zend_declare_class_constant_long(php_snmp_ce, const_name, sizeof(const_name)-1, (zend_long)value TSRMLS_CC);
#else
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index 3afa0af9f1..bfd77d5b29 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -376,8 +376,8 @@ struct objid_query {
int count;
int offset;
int step;
- long non_repeaters;
- long max_repetitions;
+ zend_long non_repeaters;
+ zend_long max_repetitions;
int valueretrieval;
int array_output;
int oid_increasing_check;
@@ -1429,8 +1429,8 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
char *a1, *a2, *a3, *a4, *a5, *a6, *a7;
int a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len;
zend_bool use_orignames = 0, suffix_keys = 0;
- long timeout = SNMP_DEFAULT_TIMEOUT;
- long retries = SNMP_DEFAULT_RETRIES;
+ zend_long timeout = SNMP_DEFAULT_TIMEOUT;
+ zend_long retries = SNMP_DEFAULT_RETRIES;
int argc = ZEND_NUM_ARGS();
struct objid_query objid_query;
php_snmp_session *session;
@@ -1619,7 +1619,7 @@ PHP_FUNCTION(snmp_get_quick_print)
Return all objects including their respective object id withing the specified one */
PHP_FUNCTION(snmp_set_quick_print)
{
- long a1;
+ zend_long a1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &a1) == FAILURE) {
RETURN_FALSE;
@@ -1634,7 +1634,7 @@ PHP_FUNCTION(snmp_set_quick_print)
Return all values that are enums with their enum value instead of the raw integer */
PHP_FUNCTION(snmp_set_enum_print)
{
- long a1;
+ zend_long a1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &a1) == FAILURE) {
RETURN_FALSE;
@@ -1649,7 +1649,7 @@ PHP_FUNCTION(snmp_set_enum_print)
Set the OID output format. */
PHP_FUNCTION(snmp_set_oid_output_format)
{
- long a1;
+ zend_long a1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &a1) == FAILURE) {
RETURN_FALSE;
@@ -1757,7 +1757,7 @@ PHP_FUNCTION(snmp3_set)
Specify the method how the SNMP values will be returned */
PHP_FUNCTION(snmp_set_valueretrieval)
{
- long method;
+ zend_long method;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &method) == FAILURE) {
RETURN_FALSE;
@@ -1767,7 +1767,7 @@ PHP_FUNCTION(snmp_set_valueretrieval)
SNMP_G(valueretrieval) = method;
RETURN_TRUE;
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown SNMP value retrieval method '%ld'", method);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown SNMP value retrieval method '%pd'", method);
RETURN_FALSE;
}
}
@@ -1813,9 +1813,9 @@ PHP_METHOD(snmp, __construct)
zval *object = getThis();
char *a1, *a2;
int a1_len, a2_len;
- long timeout = SNMP_DEFAULT_TIMEOUT;
- long retries = SNMP_DEFAULT_RETRIES;
- long version = SNMP_DEFAULT_VERSION;
+ zend_long timeout = SNMP_DEFAULT_TIMEOUT;
+ zend_long retries = SNMP_DEFAULT_RETRIES;
+ zend_long version = SNMP_DEFAULT_VERSION;
int argc = ZEND_NUM_ARGS();
zend_error_handling error_handling;
@@ -2097,7 +2097,7 @@ static HashTable *php_snmp_get_properties(zval *object TSRMLS_DC)
HashTable *props;
zval rv;
zend_string *key;
- ulong num_key;
+ zend_ulong num_key;
obj = Z_SNMP_P(object);
props = zend_std_get_properties(object TSRMLS_CC);
@@ -2196,14 +2196,14 @@ static int php_snmp_write_max_oids(php_snmp_object *snmp_object, zval *newval TS
if (Z_TYPE_P(newval) != IS_LONG) {
ztmp = *newval;
zval_copy_ctor(&ztmp);
- convert_to_long(&ztmp);
+ convert_to_int(&ztmp);
newval = &ztmp;
}
if (Z_LVAL_P(newval) > 0) {
snmp_object->max_oids = Z_LVAL_P(newval);
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "max_oids should be positive integer or NULL, got %ld", Z_LVAL_P(newval));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "max_oids should be positive integer or NULL, got %pd", Z_LVAL_P(newval));
}
if (newval == &ztmp) {
@@ -2223,14 +2223,14 @@ static int php_snmp_write_valueretrieval(php_snmp_object *snmp_object, zval *new
if (Z_TYPE_P(newval) != IS_LONG) {
ztmp = *newval;
zval_copy_ctor(&ztmp);
- convert_to_long(&ztmp);
+ convert_to_int(&ztmp);
newval = &ztmp;
}
if (Z_LVAL_P(newval) >= 0 && Z_LVAL_P(newval) <= (SNMP_VALUE_LIBRARY|SNMP_VALUE_PLAIN|SNMP_VALUE_OBJECT)) {
snmp_object->valueretrieval = Z_LVAL_P(newval);
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown SNMP value retrieval method '%ld'", Z_LVAL_P(newval));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown SNMP value retrieval method '%pd'", Z_LVAL_P(newval));
ret = FAILURE;
}
@@ -2266,7 +2266,7 @@ static int php_snmp_write_oid_output_format(php_snmp_object *snmp_object, zval *
int ret = SUCCESS;
if (Z_TYPE_P(newval) != IS_LONG) {
ZVAL_COPY(&ztmp, newval);
- convert_to_long(&ztmp);
+ convert_to_int(&ztmp);
newval = &ztmp;
}
@@ -2280,7 +2280,7 @@ static int php_snmp_write_oid_output_format(php_snmp_object *snmp_object, zval *
snmp_object->oid_output_format = Z_LVAL_P(newval);
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown SNMP output print format '%ld'", Z_LVAL_P(newval));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown SNMP output print format '%pd'", Z_LVAL_P(newval));
ret = FAILURE;
break;
}
@@ -2299,7 +2299,7 @@ static int php_snmp_write_exceptions_enabled(php_snmp_object *snmp_object, zval
int ret = SUCCESS;
if (Z_TYPE_P(newval) != IS_LONG) {
ZVAL_COPY(&ztmp, newval);
- convert_to_long(&ztmp);
+ convert_to_int(&ztmp);
newval = &ztmp;
}
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 8aeab65a1b..7dd6747c25 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -290,7 +290,7 @@ static zend_bool soap_check_zval_ref(zval *data, xmlNodePtr node TSRMLS_DC) {
if (Z_TYPE_P(data) == IS_OBJECT) {
data = (zval*)Z_OBJ_P(data);
}
- if ((node_ptr = zend_hash_index_find_ptr(SOAP_GLOBAL(ref_map), (ulong)data)) != NULL) {
+ if ((node_ptr = zend_hash_index_find_ptr(SOAP_GLOBAL(ref_map), (zend_ulong)data)) != NULL) {
xmlAttrPtr attr = node_ptr->properties;
char *id;
smart_str prefix = {0};
@@ -344,7 +344,7 @@ static zend_bool soap_check_zval_ref(zval *data, xmlNodePtr node TSRMLS_DC) {
smart_str_free(&prefix);
return 1;
} else {
- zend_hash_index_update_ptr(SOAP_GLOBAL(ref_map), (ulong)data, node);
+ zend_hash_index_update_ptr(SOAP_GLOBAL(ref_map), (zend_ulong)data, node);
}
}
return 0;
@@ -355,7 +355,7 @@ static zend_bool soap_check_xml_ref(zval *data, xmlNodePtr node TSRMLS_DC)
zval *data_ptr;
if (SOAP_GLOBAL(ref_map)) {
- if ((data_ptr = zend_hash_index_find(SOAP_GLOBAL(ref_map), (ulong)node)) != NULL) {
+ if ((data_ptr = zend_hash_index_find(SOAP_GLOBAL(ref_map), (zend_ulong)node)) != NULL) {
if (!Z_REFCOUNTED_P(data) ||
!Z_REFCOUNTED_P(data_ptr) ||
Z_COUNTED_P(data) != Z_COUNTED_P(data_ptr)) {
@@ -371,7 +371,7 @@ static zend_bool soap_check_xml_ref(zval *data, xmlNodePtr node TSRMLS_DC)
static void soap_add_xml_ref(zval *data, xmlNodePtr node TSRMLS_DC)
{
if (SOAP_GLOBAL(ref_map)) {
- zend_hash_index_update(SOAP_GLOBAL(ref_map), (ulong)node, data);
+ zend_hash_index_update(SOAP_GLOBAL(ref_map), (zend_ulong)node, data);
}
}
@@ -789,7 +789,7 @@ static zval *to_zval_hexbin(zval *ret, encodeTypePtr type, xmlNodePtr data TSRML
soap_error0(E_ERROR, "Encoding: Violation of encoding rules");
return ret;
}
- str = STR_ALLOC(strlen((char*)data->children->content) / 2, 0);
+ str = zend_string_alloc(strlen((char*)data->children->content) / 2, 0);
for (i = j = 0; i < str->len; i++) {
c = data->children->content[j++];
if (c >= '0' && c <= '9') {
@@ -921,7 +921,7 @@ static xmlNodePtr to_xml_base64(encodeTypePtr type, zval *data, int style, xmlNo
str = php_base64_encode((unsigned char*)Z_STRVAL_P(data), Z_STRLEN_P(data));
text = xmlNewTextLen(BAD_CAST(str->val), str->len);
xmlAddChild(ret, text);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
zval tmp;
@@ -930,7 +930,7 @@ static xmlNodePtr to_xml_base64(encodeTypePtr type, zval *data, int style, xmlNo
str = php_base64_encode((unsigned char*)Z_STRVAL(tmp), Z_STRLEN(tmp));
text = xmlNewTextLen(BAD_CAST(str->val), str->len);
xmlAddChild(ret, text);
- STR_RELEASE(str);
+ zend_string_release(str);
zval_dtor(&tmp);
}
@@ -986,7 +986,7 @@ static zval *to_zval_double(zval *ret, encodeTypePtr type, xmlNodePtr data TSRML
if (data && data->children) {
if (data->children->type == XML_TEXT_NODE && data->children->next == NULL) {
- long lval;
+ zend_long lval;
double dval;
whiteSpace_collapse(data->children->content);
@@ -1024,7 +1024,7 @@ static zval *to_zval_long(zval *ret, encodeTypePtr type, xmlNodePtr data TSRMLS_
if (data && data->children) {
if (data->children->type == XML_TEXT_NODE && data->children->next == NULL) {
- long lval;
+ zend_long lval;
double dval;
whiteSpace_collapse(data->children->content);
@@ -1067,7 +1067,7 @@ static xmlNodePtr to_xml_long(encodeTypePtr type, zval *data, int style, xmlNode
zval_copy_ctor(&tmp);
if (Z_TYPE(tmp) != IS_LONG) {
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
}
convert_to_string(&tmp);
xmlNodeSetContentLen(ret, BAD_CAST(Z_STRVAL(tmp)), Z_STRLEN(tmp));
@@ -2689,7 +2689,7 @@ static xmlNodePtr to_xml_map(encodeTypePtr type, zval *data, int style, xmlNodeP
{
zval *temp_data;
zend_string *key_val;
- ulong int_val;
+ zend_ulong int_val;
xmlNodePtr xmlParam;
xmlNodePtr xparam, item;
xmlNodePtr key;
@@ -2901,7 +2901,7 @@ static xmlNodePtr to_xml_datetime_ex(encodeTypePtr type, zval *data, char *forma
ta = php_localtime_r(&timestamp, &tmbuf);
/*ta = php_gmtime_r(&timestamp, &tmbuf);*/
if (!ta) {
- soap_error1(E_ERROR, "Encoding: Invalid timestamp %ld", Z_LVAL_P(data));
+ soap_error1(E_ERROR, "Encoding: Invalid timestamp %pd", Z_LVAL_P(data));
}
buf = (char *) emalloc(buf_len);
@@ -3498,7 +3498,7 @@ encodePtr get_conversion(int encode)
static int is_map(zval *array)
{
- ulong index;
+ zend_ulong index;
zend_string *key;
int i = 0;
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index bb2a6c7a53..09958ac51f 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -50,7 +50,7 @@ int proxy_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
smart_str_append_const(soap_headers, "Proxy-Authorization: Basic ");
smart_str_appendl(soap_headers, (char*)buf->val, buf->len);
smart_str_append_const(soap_headers, "\r\n");
- STR_RELEASE(buf);
+ zend_string_release(buf);
smart_str_free(&auth);
return 1;
}
@@ -77,7 +77,7 @@ int basic_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
smart_str_append_const(soap_headers, "Authorization: Basic ");
smart_str_appendl(soap_headers, (char*)buf->val, buf->len);
smart_str_append_const(soap_headers, "\r\n");
- STR_RELEASE(buf);
+ zend_string_release(buf);
smart_str_free(&auth);
return 1;
}
@@ -161,7 +161,7 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, ph
char *host;
char *name;
char *protocol;
- long namelen;
+ zend_long namelen;
int port;
int old_error_reporting;
struct timeval tv;
@@ -347,7 +347,7 @@ int make_http_soap_request(zval *this_ptr,
int http_1_1;
int http_status;
int content_type_xml = 0;
- long redirect_max = 20;
+ zend_long redirect_max = 20;
char *content_encoding;
char *http_msg = NULL;
zend_bool old_allow_url_fopen;
@@ -631,7 +631,7 @@ try_again:
unsigned char hash[16];
PHP_MD5Init(&md5ctx);
- snprintf(cnonce, sizeof(cnonce), "%ld", php_rand(TSRMLS_C));
+ snprintf(cnonce, sizeof(cnonce), ZEND_LONG_FMT, php_rand(TSRMLS_C));
PHP_MD5Update(&md5ctx, (unsigned char*)cnonce, strlen(cnonce));
PHP_MD5Final(hash, &md5ctx);
make_digest(cnonce, hash);
@@ -787,7 +787,7 @@ try_again:
smart_str_append_const(&soap_headers, "Authorization: Basic ");
smart_str_appendl(&soap_headers, (char*)buf->val, buf->len);
smart_str_append_const(&soap_headers, "\r\n");
- STR_RELEASE(buf);
+ zend_string_release(buf);
smart_str_free(&auth);
}
}
diff --git a/ext/soap/php_packet_soap.c b/ext/soap/php_packet_soap.c
index 348fbc007d..12fc31786f 100644
--- a/ext/soap/php_packet_soap.c
+++ b/ext/soap/php_packet_soap.c
@@ -236,10 +236,10 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
}
add_soap_fault(this_ptr, faultcode, faultstring ? faultstring->val : NULL, faultactor ? faultactor->val : NULL, &details TSRMLS_CC);
if (faultstring) {
- STR_RELEASE(faultstring);
+ zend_string_release(faultstring);
}
if (faultactor) {
- STR_RELEASE(faultactor);
+ zend_string_release(faultactor);
}
if (Z_REFCOUNTED(details)) {
Z_DELREF(details);
diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c
index 5ba3bd3de5..2c4c6c9189 100644
--- a/ext/soap/php_schema.c
+++ b/ext/soap/php_schema.c
@@ -2169,7 +2169,7 @@ static void schema_attributegroup_fixup(sdlCtx *ctx, sdlAttributePtr attr, HashT
zend_hash_move_forward(tmp->attributes);
} else {
- ulong index;
+ zend_ulong index;
schema_attributegroup_fixup(ctx, tmp_attr, ht);
zend_hash_get_current_key(tmp->attributes, NULL, &index, 0);
@@ -2268,7 +2268,7 @@ static void schema_type_fixup(sdlCtx *ctx, sdlTypePtr type)
}
if (type->attributes) {
zend_string *str_key;
- ulong index;
+ zend_ulong index;
ZEND_HASH_FOREACH_KEY_PTR(type->attributes, index, str_key, attr) {
if (str_key) {
diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c
index 8de779a5f7..456fe59584 100644
--- a/ext/soap/php_sdl.c
+++ b/ext/soap/php_sdl.c
@@ -292,7 +292,7 @@ void sdl_set_uri_credentials(sdlCtx *ctx, char *uri TSRMLS_DC)
zval new_header;
rest += 2;
- ZVAL_STR(&new_header, STR_ALLOC(Z_STRLEN_P(header) - (rest - s), 0));
+ ZVAL_STR(&new_header, zend_string_alloc(Z_STRLEN_P(header) - (rest - s), 0));
memcpy(Z_STRVAL(new_header), Z_STRVAL_P(header), s - Z_STRVAL_P(header));
memcpy(Z_STRVAL(new_header) + (s - Z_STRVAL_P(header)), rest, Z_STRLEN_P(header) - (rest - Z_STRVAL_P(header)) + 1);
ZVAL_COPY(&ctx->old_header, header);
@@ -3151,7 +3151,7 @@ static void delete_psdl(zval *zv)
free(Z_PTR_P(zv));
}
-sdlPtr get_sdl(zval *this_ptr, char *uri, long cache_wsdl TSRMLS_DC)
+sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl TSRMLS_DC)
{
char fn[MAXPATHLEN];
sdlPtr sdl = NULL;
@@ -3250,7 +3250,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, long cache_wsdl TSRMLS_DC)
smart_str_appends(&proxy,Z_STRVAL(str_port));
smart_str_0(&proxy);
zval_dtor(&str_port);
- ZVAL_STR(&str_proxy, STR_COPY(proxy.s));
+ ZVAL_STR(&str_proxy, zend_string_copy(proxy.s));
smart_str_free(&proxy);
if (!context) {
@@ -3289,7 +3289,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, long cache_wsdl TSRMLS_DC)
}
smart_str_0(&headers);
- ZVAL_STR(&str_headers, STR_COPY(headers.s));
+ ZVAL_STR(&str_headers, zend_string_copy(headers.s));
php_stream_context_set_option(context, "http", "header", &str_headers);
smart_str_free(&headers);
zval_ptr_dtor(&str_headers);
diff --git a/ext/soap/php_sdl.h b/ext/soap/php_sdl.h
index 2856ed1c47..a29e2e9a1a 100644
--- a/ext/soap/php_sdl.h
+++ b/ext/soap/php_sdl.h
@@ -254,7 +254,7 @@ struct _sdlAttribute {
};
-sdlPtr get_sdl(zval *this_ptr, char *uri, long cache_wsdl TSRMLS_DC);
+sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl TSRMLS_DC);
encodePtr get_encoder_from_prefix(sdlPtr sdl, xmlNodePtr data, const xmlChar *type);
encodePtr get_encoder(sdlPtr sdl, const char *ns, const char *type);
diff --git a/ext/soap/php_soap.h b/ext/soap/php_soap.h
index d721af6234..efa0ac0baf 100644
--- a/ext/soap/php_soap.h
+++ b/ext/soap/php_soap.h
@@ -171,8 +171,8 @@ ZEND_BEGIN_MODULE_GLOBALS(soap)
char cache_mode;
char cache_enabled;
char* cache_dir;
- long cache_ttl;
- long cache_limit;
+ zend_long cache_ttl;
+ zend_long cache_limit;
HashTable *mem_cache;
xmlCharEncodingHandlerPtr encoding;
HashTable *class_map;
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index a1d2ca4f48..58c0f1e5d1 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -956,7 +956,7 @@ PHP_METHOD(SoapFault, __toString)
zval_ptr_dtor(&fci.function_name);
- str = strpprintf(0, "SoapFault exception: [%s] %s in %s:%ld\nStack trace:\n%s",
+ str = strpprintf(0, "SoapFault exception: [%s] %s in %s:%pd\nStack trace:\n%s",
Z_STRVAL_P(faultcode), Z_STRVAL_P(faultstring), Z_STRVAL_P(file), Z_LVAL_P(line),
Z_STRLEN(trace) ? Z_STRVAL(trace) : "#0 {main}\n");
@@ -1121,7 +1121,7 @@ PHP_METHOD(SoapServer, SoapServer)
zval *wsdl = NULL, *options = NULL;
zend_resource *res;
int version = SOAP_1_1;
- long cache_wsdl;
+ zend_long cache_wsdl;
HashTable *typemap_ht = NULL;
SOAP_SERVER_BEGIN_CODE();
@@ -1248,7 +1248,7 @@ PHP_METHOD(SoapServer, SoapServer)
PHP_METHOD(SoapServer, setPersistence)
{
soapServicePtr service;
- long value;
+ zend_long value;
SOAP_SERVER_BEGIN_CODE();
@@ -1260,7 +1260,7 @@ PHP_METHOD(SoapServer, setPersistence)
value == SOAP_PERSISTENCE_REQUEST) {
service->soap_class.persistance = value;
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to set persistence with bogus value (%ld)", value);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to set persistence with bogus value (%pd)", value);
return;
}
} else {
@@ -1367,7 +1367,7 @@ PHP_METHOD(SoapServer, getFunctions)
zval *name;
ZEND_HASH_FOREACH_VAL(service->soap_functions.ft, name) {
- add_next_index_str(return_value, STR_COPY(Z_STR_P(name)));
+ add_next_index_str(return_value, zend_string_copy(Z_STR_P(name)));
} ZEND_HASH_FOREACH_END();
}
if (ft != NULL) {
@@ -1375,7 +1375,7 @@ PHP_METHOD(SoapServer, getFunctions)
ZEND_HASH_FOREACH_PTR(ft, f) {
if ((service->type != SOAP_OBJECT && service->type != SOAP_CLASS) || (f->common.fn_flags & ZEND_ACC_PUBLIC)) {
- add_next_index_str(return_value, STR_COPY(f->common.function_name));
+ add_next_index_str(return_value, zend_string_copy(f->common.function_name));
}
} ZEND_HASH_FOREACH_END();
}
@@ -1421,7 +1421,7 @@ PHP_METHOD(SoapServer, addFunction)
return;
}
- key = STR_ALLOC(Z_STRLEN_P(tmp_function), 0);
+ key = zend_string_alloc(Z_STRLEN_P(tmp_function), 0);
zend_str_tolower_copy(key->val, Z_STRVAL_P(tmp_function), Z_STRLEN_P(tmp_function));
if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) {
@@ -1429,17 +1429,17 @@ PHP_METHOD(SoapServer, addFunction)
return;
}
- ZVAL_STR(&function_copy, STR_COPY(f->common.function_name));
+ ZVAL_STR(&function_copy, zend_string_copy(f->common.function_name));
zend_hash_update(service->soap_functions.ft, key, &function_copy);
- STR_RELEASE(key);
+ zend_string_release(key);
} ZEND_HASH_FOREACH_END();
}
} else if (Z_TYPE_P(function_name) == IS_STRING) {
zend_string *key;
zend_function *f;
- key = STR_ALLOC(Z_STRLEN_P(function_name), 0);
+ key = zend_string_alloc(Z_STRLEN_P(function_name), 0);
zend_str_tolower_copy(key->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name));
if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) {
@@ -1452,9 +1452,9 @@ PHP_METHOD(SoapServer, addFunction)
zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0);
}
- ZVAL_STR(&function_copy, STR_COPY(f->common.function_name));
+ ZVAL_STR(&function_copy, zend_string_copy(f->common.function_name));
zend_hash_update(service->soap_functions.ft, key, &function_copy);
- STR_RELEASE(key);
+ zend_string_release(key);
} else if (Z_TYPE_P(function_name) == IS_LONG) {
if (Z_LVAL_P(function_name) == SOAP_FUNCTIONS_ALL) {
if (service->soap_functions.ft != NULL) {
@@ -1558,7 +1558,7 @@ PHP_METHOD(SoapServer, handle)
if (SG(request_info).request_body && 0 == php_stream_rewind(SG(request_info).request_body)) {
zval *server_vars, *encoding;
php_stream_filter *zf = NULL;
- zend_string *server = STR_INIT("_SERVER", sizeof("_SERVER")-1, 0);
+ zend_string *server = zend_string_init("_SERVER", sizeof("_SERVER")-1, 0);
zend_is_auto_global(server TSRMLS_CC);
if ((server_vars = zend_hash_find(&EG(symbol_table).ht, server)) != NULL &&
@@ -1582,16 +1582,16 @@ PHP_METHOD(SoapServer, handle)
php_stream_filter_append(&SG(request_info).request_body->readfilters, zf);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't uncompress compressed request");
- STR_RELEASE(server);
+ zend_string_release(server);
return;
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Request is compressed with unknown compression '%s'",Z_STRVAL_P(encoding));
- STR_RELEASE(server);
+ zend_string_release(server);
return;
}
}
- STR_RELEASE(server);
+ zend_string_release(server);
doc_request = soap_xmlParseFile("php://input" TSRMLS_CC);
@@ -1713,7 +1713,7 @@ PHP_METHOD(SoapServer, handle)
if (zend_hash_str_exists(&Z_OBJCE(tmp_soap)->function_table, php_strtolower(class_name, class_name_len), class_name_len)) {
zval c_ret, constructor;
- ZVAL_STR(&constructor, STR_COPY(service->soap_class.ce->name));
+ ZVAL_STR(&constructor, zend_string_copy(service->soap_class.ce->name));
if (call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");
}
@@ -2079,7 +2079,7 @@ static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeade
xmlDocDumpMemory(doc_return, &buf, &size);
- server = STR_INIT("_SERVER", sizeof("_SERVER") - 1, 0);
+ server = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
zend_is_auto_global(server TSRMLS_CC);
if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF &&
(agent_name = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT")-1)) != NULL &&
@@ -2088,7 +2088,7 @@ static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeade
use_http_error_status = 0;
}
}
- STR_RELEASE(server);
+ zend_string_release(server);
/*
Want to return HTTP 500 but apache wants to over write
our fault code with their own handling... Figure this out later
@@ -2330,7 +2330,7 @@ PHP_METHOD(SoapClient, SoapClient)
zval *wsdl, *options = NULL;
int soap_version = SOAP_1_1;
php_stream_context *context = NULL;
- long cache_wsdl;
+ zend_long cache_wsdl;
sdlPtr sdl = NULL;
HashTable *typemap_ht = NULL;
zval *this_ptr = getThis();
@@ -2355,7 +2355,7 @@ PHP_METHOD(SoapClient, SoapClient)
/* Fetching non-WSDL mode options */
if ((tmp = zend_hash_str_find(ht, "uri", sizeof("uri")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- add_property_str(this_ptr, "uri", STR_COPY(Z_STR_P(tmp)));
+ add_property_str(this_ptr, "uri", zend_string_copy(Z_STR_P(tmp)));
} else {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'uri' option is required in nonWSDL mode");
}
@@ -2381,7 +2381,7 @@ PHP_METHOD(SoapClient, SoapClient)
if ((tmp = zend_hash_str_find(ht, "location", sizeof("location")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- add_property_str(this_ptr, "location", STR_COPY(Z_STR_P(tmp)));
+ add_property_str(this_ptr, "location", zend_string_copy(Z_STR_P(tmp)));
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'location' option is required in nonWSDL mode");
}
@@ -2394,10 +2394,10 @@ PHP_METHOD(SoapClient, SoapClient)
}
if ((tmp = zend_hash_str_find(ht, "login", sizeof("login")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- add_property_str(this_ptr, "_login", STR_COPY(Z_STR_P(tmp)));
+ add_property_str(this_ptr, "_login", zend_string_copy(Z_STR_P(tmp)));
if ((tmp = zend_hash_str_find(ht, "password", sizeof("password")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- add_property_str(this_ptr, "_password", STR_COPY(Z_STR_P(tmp)));
+ add_property_str(this_ptr, "_password", zend_string_copy(Z_STR_P(tmp)));
}
if ((tmp = zend_hash_str_find(ht, "authentication", sizeof("authentication")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG &&
@@ -2407,7 +2407,7 @@ PHP_METHOD(SoapClient, SoapClient)
}
if ((tmp = zend_hash_str_find(ht, "proxy_host", sizeof("proxy_host")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- add_property_str(this_ptr, "_proxy_host", STR_COPY(Z_STR_P(tmp)));
+ add_property_str(this_ptr, "_proxy_host", zend_string_copy(Z_STR_P(tmp)));
if ((tmp = zend_hash_str_find(ht, "proxy_port", sizeof("proxy_port")-1)) != NULL) {
if (Z_TYPE_P(tmp) != IS_LONG) {
ZVAL_LONG(&tmp2, zval_get_long(tmp));
@@ -2417,10 +2417,10 @@ PHP_METHOD(SoapClient, SoapClient)
}
if ((tmp = zend_hash_str_find(ht, "proxy_login", sizeof("proxy_login")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- add_property_str(this_ptr, "_proxy_login", STR_COPY(Z_STR_P(tmp)));
+ add_property_str(this_ptr, "_proxy_login", zend_string_copy(Z_STR_P(tmp)));
if ((tmp = zend_hash_str_find(ht, "proxy_password", sizeof("proxy_password")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- add_property_str(this_ptr, "_proxy_password", STR_COPY(Z_STR_P(tmp)));
+ add_property_str(this_ptr, "_proxy_password", zend_string_copy(Z_STR_P(tmp)));
}
}
}
@@ -2465,7 +2465,7 @@ PHP_METHOD(SoapClient, SoapClient)
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid 'encoding' option - '%s'", Z_STRVAL_P(tmp));
} else {
xmlCharEncCloseFunc(encoding);
- add_property_str(this_ptr, "_encoding", STR_COPY(Z_STR_P(tmp)));
+ add_property_str(this_ptr, "_encoding", zend_string_copy(Z_STR_P(tmp)));
}
}
if ((tmp = zend_hash_str_find(ht, "classmap", sizeof("classmap")-1)) != NULL &&
@@ -2511,7 +2511,7 @@ PHP_METHOD(SoapClient, SoapClient)
if ((tmp = zend_hash_str_find(ht, "user_agent", sizeof("user_agent")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- add_property_str(this_ptr, "_user_agent", STR_COPY(Z_STR_P(tmp)));
+ add_property_str(this_ptr, "_user_agent", zend_string_copy(Z_STR_P(tmp)));
}
if ((tmp = zend_hash_str_find(ht, "keep_alive", sizeof("keep_alive")-1)) != NULL &&
@@ -2606,7 +2606,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
ret = FALSE;
} else if ((trace = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace")-1)) != NULL &&
Z_LVAL_P(trace) > 0) {
- add_property_str(this_ptr, "__last_response", STR_COPY(Z_STR_P(response)));
+ add_property_str(this_ptr, "__last_response", zend_string_copy(Z_STR_P(response)));
}
zval_ptr_dtor(&func);
zval_ptr_dtor(&params[4]);
@@ -3015,7 +3015,7 @@ PHP_METHOD(SoapClient, __getLastRequest)
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(getThis()), "__last_request", sizeof("__last_request")-1)) != NULL) {
- RETURN_STR(STR_COPY(Z_STR_P(tmp)));
+ RETURN_STR(zend_string_copy(Z_STR_P(tmp)));
}
RETURN_NULL();
}
@@ -3033,7 +3033,7 @@ PHP_METHOD(SoapClient, __getLastResponse)
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(getThis()), "__last_response", sizeof("__last_response")-1)) != NULL) {
- RETURN_STR(STR_COPY(Z_STR_P(tmp)));
+ RETURN_STR(zend_string_copy(Z_STR_P(tmp)));
}
RETURN_NULL();
}
@@ -3051,7 +3051,7 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(getThis()), "__last_request_headers", sizeof("__last_request_headers")-1)) != NULL) {
- RETURN_STR(STR_COPY(Z_STR_P(tmp)));
+ RETURN_STR(zend_string_copy(Z_STR_P(tmp)));
}
RETURN_NULL();
}
@@ -3069,7 +3069,7 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(getThis()), "__last_response_headers", sizeof("__last_response_headers")-1)) != NULL) {
- RETURN_STR(STR_COPY(Z_STR_P(tmp)));
+ RETURN_STR(zend_string_copy(Z_STR_P(tmp)));
}
RETURN_NULL();
}
@@ -3082,8 +3082,8 @@ PHP_METHOD(SoapClient, __doRequest)
{
char *buf, *location, *action;
int buf_size, location_size, action_size;
- long version;
- long one_way = 0;
+ zend_long version;
+ zend_long one_way = 0;
zval *this_ptr = getThis();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssl|l",
@@ -3223,7 +3223,7 @@ PHP_METHOD(SoapClient, __setLocation)
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "location", sizeof("location")-1)) != NULL && Z_TYPE_P(tmp) == IS_STRING) {
- RETVAL_STR(STR_COPY(Z_STR_P(tmp)));
+ RETVAL_STR(zend_string_copy(Z_STR_P(tmp)));
} else {
RETVAL_NULL();
}
@@ -3801,7 +3801,7 @@ static int serialize_response_call2(xmlNodePtr body, sdlFunctionPtr function, ch
int i = 0;
zend_string *param_name;
//???
- ulong param_index = i;
+ zend_ulong param_index = i;
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(ret), param_index, param_name, data) {
parameter = get_param(function, param_name->val, param_index, TRUE);
@@ -3988,7 +3988,7 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function
} else {
xmlNodeSetContentLen(node, BAD_CAST(str->val), (int)str->len);
}
- STR_RELEASE(str);
+ zend_string_release(str);
}
if ((tmp = zend_hash_str_find(prop, "faultstring", sizeof("faultstring")-1)) != NULL) {
xmlNodePtr node = master_to_xml(get_conversion(IS_STRING), tmp, SOAP_LITERAL, param TSRMLS_CC);
@@ -4012,7 +4012,7 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function
} else {
xmlNodeSetContentLen(node, BAD_CAST(str->val), (int)str->len);
}
- STR_RELEASE(str);
+ zend_string_release(str);
}
if ((tmp = zend_hash_str_find(prop, "faultstring", sizeof("faultstring")-1)) != NULL) {
xmlNodePtr node = xmlNewChild(param, ns, BAD_CAST("Reason"), NULL);
diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c
index 66d1938f07..69ea21f9df 100644
--- a/ext/sockets/conversions.c
+++ b/ext/sockets/conversions.c
@@ -303,9 +303,9 @@ static void to_zval_read_aggregation(const char *structure,
}
/* CONVERSIONS for integers */
-static long from_zval_integer_common(const zval *arr_value, ser_context *ctx)
+static zend_long from_zval_integer_common(const zval *arr_value, ser_context *ctx)
{
- long ret = 0;
+ zend_long ret = 0;
zval lzval;
ZVAL_NULL(&lzval);
@@ -323,12 +323,12 @@ long_case:
/* if not long we're operating on lzval */
case IS_DOUBLE:
double_case:
- convert_to_long(&lzval);
+ convert_to_int(&lzval);
goto long_case;
case IS_OBJECT:
case IS_STRING: {
- long lval;
+ zend_long lval;
double dval;
convert_to_string(&lzval);
@@ -363,7 +363,7 @@ double_case:
}
void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ zend_long lval;
int ival;
lval = from_zval_integer_common(arr_value, ctx);
@@ -382,7 +382,7 @@ void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx)
}
static void from_zval_write_uint32(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ zend_long lval;
uint32_t ival;
lval = from_zval_integer_common(arr_value, ctx);
@@ -401,7 +401,7 @@ static void from_zval_write_uint32(const zval *arr_value, char *field, ser_conte
}
static void from_zval_write_net_uint16(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ zend_long lval;
uint16_t ival;
lval = from_zval_integer_common(arr_value, ctx);
@@ -420,7 +420,7 @@ static void from_zval_write_net_uint16(const zval *arr_value, char *field, ser_c
}
static void from_zval_write_sa_family(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ zend_long lval;
sa_family_t ival;
lval = from_zval_integer_common(arr_value, ctx);
@@ -439,7 +439,7 @@ static void from_zval_write_sa_family(const zval *arr_value, char *field, ser_co
}
static void from_zval_write_pid_t(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ zend_long lval;
pid_t ival;
lval = from_zval_integer_common(arr_value, ctx);
@@ -458,7 +458,7 @@ static void from_zval_write_pid_t(const zval *arr_value, char *field, ser_contex
}
static void from_zval_write_uid_t(const zval *arr_value, char *field, ser_context *ctx)
{
- long lval;
+ zend_long lval;
uid_t ival;
lval = from_zval_integer_common(arr_value, ctx);
@@ -565,7 +565,7 @@ 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;
- zend_string *str = STR_ALLOC(size - 1, 0);
+ zend_string *str = zend_string_alloc(size - 1, 0);
memset(str->val, '\0', size);
ZVAL_STR(zv, str);
@@ -623,7 +623,7 @@ 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;
- zend_string *str = STR_ALLOC(size - 1, 0);
+ zend_string *str = zend_string_alloc(size - 1, 0);
memset(str->val, '\0', size);
@@ -984,8 +984,8 @@ static void to_zval_read_cmsg_data(const char *cmsghdr_c, zval *zv, res_context
}
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);
+ "expected a length of at least %pd, but got %pd",
+ (zend_long)CMSG_LEN(entry->size), (zend_long)cmsg->cmsg_len);
return;
}
@@ -1072,7 +1072,7 @@ static void to_zval_read_name(const char *sockaddr_p, zval *zv, res_context *ctx
}
static void from_zval_write_msghdr_buffer_size(const zval *elem, char *msghdr_c, ser_context *ctx)
{
- long lval;
+ zend_long lval;
struct msghdr *msghdr = (struct msghdr *)msghdr_c;
lval = from_zval_integer_common(elem, ctx);
@@ -1081,8 +1081,8 @@ static void from_zval_write_msghdr_buffer_size(const zval *elem, char *msghdr_c,
}
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);
+ do_from_zval_err(ctx, "the buffer size must be between 1 and %pd; "
+ "given %pd", (zend_long)MAX_USER_BUFF_SIZE, lval);
return;
}
@@ -1224,7 +1224,7 @@ static void to_zval_read_iov(const char *msghdr_c, zval *zv, res_context *ctx)
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);
- zend_string *buf = STR_ALLOC(len, 0);
+ zend_string *buf = zend_string_alloc(len, 0);
memcpy(buf->val, msghdr->msg_iov[i].iov_base, buf->len);
buf->val[buf->len] = '\0';
@@ -1260,7 +1260,7 @@ static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context
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));
+ "larger than %u; given %pd", UINT_MAX, Z_LVAL_P(zv));
} else {
ret = (unsigned)Z_LVAL_P(zv);
}
@@ -1431,7 +1431,7 @@ void to_zval_read_fd_array(const char *data, zval *zv, res_context *ctx)
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);
+ "offset (%pd vs %pd)", (zend_long)*cmsg_len, (zend_long)data_offset);
return;
}
num_elems = (*cmsg_len - data_offset) / sizeof(int);
diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c
index 2bc86b1dba..4834bb39e0 100644
--- a/ext/sockets/multicast.c
+++ b/ext/sockets/multicast.c
@@ -93,7 +93,7 @@ static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC)
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));
+ " given %pd", UINT_MAX, Z_LVAL_P(val));
ret = FAILURE;
} else {
*out = Z_LVAL_P(val);
@@ -288,7 +288,7 @@ int php_do_setsockopt_ip_mcast(php_socket *php_sock,
goto ipv4_loop_ttl;
case IP_MULTICAST_TTL:
- convert_to_long_ex(arg4);
+ convert_to_int_ex(arg4);
if (Z_LVAL_P(arg4) < 0L || Z_LVAL_P(arg4) > 255L) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Expected a value between 0 and 255");
@@ -353,7 +353,7 @@ int php_do_setsockopt_ipv6_mcast(php_socket *php_sock,
ov = (int) Z_TYPE_P(arg4) == IS_TRUE;
goto ipv6_loop_hops;
case IPV6_MULTICAST_HOPS:
- convert_to_long_ex(arg4);
+ convert_to_int_ex(arg4);
if (Z_LVAL_P(arg4) < -1L || Z_LVAL_P(arg4) > 255L) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Expected a value between -1 and 255");
diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c
index 72c7286eb5..018605fb75 100644
--- a/ext/sockets/sendrecvmsg.c
+++ b/ext/sockets/sendrecvmsg.c
@@ -71,7 +71,7 @@ inline ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)
#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 " \
+ php_error_docref0(NULL TSRMLS_CC, E_WARNING, "The value %pd does not fit inside " \
"the boundaries of a native integer", (l)); \
return; \
} \
@@ -167,7 +167,7 @@ PHP_FUNCTION(socket_sendmsg)
{
zval *zsocket,
*zmsg;
- long flags = 0;
+ zend_long flags = 0;
php_socket *php_sock;
struct msghdr *msghdr;
zend_llist *allocations;
@@ -209,7 +209,7 @@ PHP_FUNCTION(socket_recvmsg)
{
zval *zsocket,
*zmsg;
- long flags = 0;
+ zend_long flags = 0;
php_socket *php_sock;
ssize_t res;
struct msghdr *msghdr;
@@ -268,12 +268,12 @@ PHP_FUNCTION(socket_recvmsg)
RETURN_FALSE;
}
- RETURN_LONG((long)res);
+ RETURN_LONG((zend_long)res);
}
PHP_FUNCTION(socket_cmsg_space)
{
- long level,
+ zend_long level,
type,
n = 0;
ancillary_reg_entry *entry;
@@ -295,16 +295,16 @@ PHP_FUNCTION(socket_cmsg_space)
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 "
+ php_error_docref0(NULL TSRMLS_CC, E_WARNING, "The pair level %pd/type %pd 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) {
+ if (entry->var_el_size > 0 && n > (ZEND_LONG_MAX - (zend_long)entry->size -
+ (zend_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);
+ "third argument (%pd) is too large", n);
return;
}
diff --git a/ext/sockets/sockaddr_conv.c b/ext/sockets/sockaddr_conv.c
index 1c1a90d58f..f9de9f1361 100644
--- a/ext/sockets/sockaddr_conv.c
+++ b/ext/sockets/sockaddr_conv.c
@@ -61,7 +61,7 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_
}
if (scope++) {
- long lval = 0;
+ zend_long lval = 0;
double dval = 0;
unsigned scope_id = 0;
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index dd7f27260f..e8e03ae0e3 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -793,7 +793,7 @@ static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC) /
php_socket *php_sock;
zval new_hash;
int num = 0;
- ulong num_key;
+ zend_ulong num_key;
zend_string *key;
if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0;
@@ -836,7 +836,7 @@ PHP_FUNCTION(socket_select)
fd_set rfds, wfds, efds;
PHP_SOCKET max_fd = 0;
int retval, sets = 0;
- long usec = 0;
+ zend_long usec = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!a/!a/!z!|l", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE) {
return;
@@ -864,7 +864,7 @@ PHP_FUNCTION(socket_select)
if (Z_TYPE_P(sec) != IS_LONG) {
tmp = *sec;
zval_copy_ctor(&tmp);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
sec = &tmp;
}
@@ -905,7 +905,7 @@ PHP_FUNCTION(socket_select)
PHP_FUNCTION(socket_create_listen)
{
php_socket *php_sock;
- long port, backlog = 128;
+ zend_long port, backlog = 128;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &port, &backlog) == FAILURE) {
return;
@@ -1027,7 +1027,7 @@ PHP_FUNCTION(socket_listen)
{
zval *arg1;
php_socket *php_sock;
- long backlog = 0;
+ zend_long backlog = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &arg1, &backlog) == FAILURE) {
return;
@@ -1076,7 +1076,7 @@ PHP_FUNCTION(socket_write)
zval *arg1;
php_socket *php_sock;
int retval, str_len;
- long length = 0;
+ zend_long length = 0;
char *str;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, &str, &str_len, &length) == FAILURE) {
@@ -1112,7 +1112,7 @@ PHP_FUNCTION(socket_read)
php_socket *php_sock;
zend_string *tmpbuf;
int retval;
- long length, type = PHP_BINARY_READ;
+ zend_long length, type = PHP_BINARY_READ;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &length, &type) == FAILURE) {
return;
@@ -1123,7 +1123,7 @@ PHP_FUNCTION(socket_read)
RETURN_FALSE;
}
- tmpbuf = STR_ALLOC(length, 0);
+ tmpbuf = zend_string_alloc(length, 0);
ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket);
@@ -1147,14 +1147,14 @@ PHP_FUNCTION(socket_read)
PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
}
- STR_FREE(tmpbuf);
+ zend_string_free(tmpbuf);
RETURN_FALSE;
} else if (!retval) {
- STR_FREE(tmpbuf);
+ zend_string_free(tmpbuf);
RETURN_EMPTY_STRING();
}
- tmpbuf = STR_REALLOC(tmpbuf, retval, 0);
+ tmpbuf = zend_string_realloc(tmpbuf, retval, 0);
tmpbuf->len = retval;
tmpbuf->val[tmpbuf->len] = '\0' ;
@@ -1326,7 +1326,7 @@ PHP_FUNCTION(socket_getpeername)
Creates an endpoint for communication in the domain specified by domain, of type specified by type */
PHP_FUNCTION(socket_create)
{
- long arg1, arg2, arg3;
+ zend_long arg1, arg2, arg3;
php_socket *php_sock = php_create_socket();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &arg1, &arg2, &arg3) == FAILURE) {
@@ -1339,12 +1339,12 @@ PHP_FUNCTION(socket_create)
&& arg1 != AF_INET6
#endif
&& arg1 != AF_INET) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket domain [%ld] specified for argument 1, assuming AF_INET", arg1);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket domain [%pd] specified for argument 1, assuming AF_INET", arg1);
arg1 = AF_INET;
}
if (arg2 > 10) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket type [%ld] specified for argument 2, assuming SOCK_STREAM", arg2);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket type [%pd] specified for argument 2, assuming SOCK_STREAM", arg2);
arg2 = SOCK_STREAM;
}
@@ -1373,7 +1373,7 @@ PHP_FUNCTION(socket_connect)
php_socket *php_sock;
char *addr;
int retval, addr_len;
- long port = 0;
+ zend_long port = 0;
int argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "rs|l", &arg1, &addr, &addr_len, &port) == FAILURE) {
@@ -1457,7 +1457,7 @@ PHP_FUNCTION(socket_connect)
Returns a string describing an error */
PHP_FUNCTION(socket_strerror)
{
- long arg1;
+ zend_long arg1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &arg1) == FAILURE) {
return;
@@ -1477,8 +1477,8 @@ PHP_FUNCTION(socket_bind)
php_socket *php_sock;
char *addr;
int addr_len;
- long port = 0;
- long retval = 0;
+ zend_long port = 0;
+ zend_long retval = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, &addr, &addr_len, &port) == FAILURE) {
return;
@@ -1558,7 +1558,7 @@ PHP_FUNCTION(socket_recv)
zend_string *recv_buf;
php_socket *php_sock;
int retval;
- long len, flags;
+ zend_long len, flags;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/ll", &php_sock_res, &buf, &len, &flags) == FAILURE) {
return;
@@ -1571,7 +1571,7 @@ PHP_FUNCTION(socket_recv)
RETURN_FALSE;
}
- recv_buf = STR_ALLOC(len, 0);
+ recv_buf = zend_string_alloc(len, 0);
if ((retval = recv(php_sock->bsd_socket, recv_buf->val, len, flags)) < 1) {
efree(recv_buf);
@@ -1603,7 +1603,7 @@ PHP_FUNCTION(socket_send)
zval *arg1;
php_socket *php_sock;
int buf_len, retval;
- long len, flags;
+ zend_long len, flags;
char *buf;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsll", &arg1, &buf, &buf_len, &len, &flags) == FAILURE) {
@@ -1637,7 +1637,7 @@ PHP_FUNCTION(socket_recvfrom)
#endif
socklen_t slen;
int retval;
- long arg3, arg4;
+ zend_long arg3, arg4;
char *address;
zend_string *recv_buf;
@@ -1652,7 +1652,7 @@ PHP_FUNCTION(socket_recvfrom)
RETURN_FALSE;
}
- recv_buf = STR_ALLOC(arg3 + 1, 0);
+ recv_buf = zend_string_alloc(arg3 + 1, 0);
switch (php_sock->type) {
case AF_UNIX:
@@ -1662,7 +1662,7 @@ PHP_FUNCTION(socket_recvfrom)
if (retval < 0) {
PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
- STR_FREE(recv_buf);
+ zend_string_free(recv_buf);
RETURN_FALSE;
}
recv_buf->len = retval;
@@ -1681,7 +1681,7 @@ PHP_FUNCTION(socket_recvfrom)
sin.sin_family = AF_INET;
if (arg6 == NULL) {
- STR_FREE(recv_buf);
+ zend_string_free(recv_buf);
WRONG_PARAM_COUNT;
}
@@ -1689,7 +1689,7 @@ PHP_FUNCTION(socket_recvfrom)
if (retval < 0) {
PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
- STR_FREE(recv_buf);
+ zend_string_free(recv_buf);
RETURN_FALSE;
}
recv_buf->len = retval;
@@ -1720,7 +1720,7 @@ PHP_FUNCTION(socket_recvfrom)
if (retval < 0) {
PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
- STR_FREE(recv_buf);
+ zend_string_free(recv_buf);
RETURN_FALSE;
}
recv_buf->len = retval;
@@ -1759,7 +1759,7 @@ PHP_FUNCTION(socket_sendto)
struct sockaddr_in6 sin6;
#endif
int retval, buf_len, addr_len;
- long len, flags, port = 0;
+ zend_long len, flags, port = 0;
char *buf, *addr;
int argc = ZEND_NUM_ARGS();
@@ -1837,7 +1837,7 @@ PHP_FUNCTION(socket_get_option)
socklen_t optlen;
php_socket *php_sock;
int other_val;
- long level, optname;
+ zend_long level, optname;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &arg1, &level, &optname) == FAILURE) {
return;
@@ -1945,7 +1945,7 @@ PHP_FUNCTION(socket_set_option)
#else
struct timeval tv;
#endif
- long level, optname;
+ zend_long level, optname;
void *opt_ptr;
HashTable *opt_ht;
zval *l_onoff, *l_linger;
@@ -2000,8 +2000,8 @@ PHP_FUNCTION(socket_set_option)
RETURN_FALSE;
}
- convert_to_long_ex(l_onoff);
- convert_to_long_ex(l_linger);
+ convert_to_int_ex(l_onoff);
+ convert_to_int_ex(l_linger);
lv.l_onoff = (unsigned short)Z_LVAL_P(l_onoff);
lv.l_linger = (unsigned short)Z_LVAL_P(l_linger);
@@ -2028,8 +2028,8 @@ PHP_FUNCTION(socket_set_option)
RETURN_FALSE;
}
- convert_to_long_ex(sec);
- convert_to_long_ex(usec);
+ convert_to_int_ex(sec);
+ convert_to_int_ex(usec);
#ifndef PHP_WIN32
tv.tv_sec = Z_LVAL_P(sec);
tv.tv_usec = Z_LVAL_P(usec);
@@ -2057,7 +2057,7 @@ PHP_FUNCTION(socket_set_option)
default:
default_case:
- convert_to_long_ex(arg4);
+ convert_to_int_ex(arg4);
ov = Z_LVAL_P(arg4);
optlen = sizeof(ov);
@@ -2083,7 +2083,7 @@ PHP_FUNCTION(socket_create_pair)
zval retval[2], *fds_array_zval;
php_socket *php_sock[2];
PHP_SOCKET fds_array[2];
- long domain, type, protocol;
+ zend_long domain, type, protocol;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllz/", &domain, &type, &protocol, &fds_array_zval) == FAILURE) {
return;
@@ -2097,12 +2097,12 @@ PHP_FUNCTION(socket_create_pair)
&& domain != AF_INET6
#endif
&& domain != AF_UNIX) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket domain [%ld] specified for argument 1, assuming AF_INET", domain);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket domain [%pd] specified for argument 1, assuming AF_INET", domain);
domain = AF_INET;
}
if (type > 10) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket type [%ld] specified for argument 2, assuming SOCK_STREAM", type);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid socket type [%pd] specified for argument 2, assuming SOCK_STREAM", type);
type = SOCK_STREAM;
}
@@ -2143,7 +2143,7 @@ PHP_FUNCTION(socket_create_pair)
PHP_FUNCTION(socket_shutdown)
{
zval *arg1;
- long how_shutdown = 2;
+ zend_long how_shutdown = 2;
php_socket *php_sock;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &arg1, &how_shutdown) == FAILURE) {
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index f9a642410f..ad3bb85313 100644
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -66,11 +66,11 @@ static zend_class_entry * spl_find_ce_by_name(zend_string *name, zend_bool autol
zend_class_entry *ce;
if (!autoload) {
- zend_string *lc_name = STR_ALLOC(name->len, 0);
+ zend_string *lc_name = zend_string_alloc(name->len, 0);
zend_str_tolower_copy(lc_name->val, name->val, name->len);
ce = zend_hash_find_ptr(EG(class_table), lc_name);
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
} else {
ce = zend_lookup_class(name TSRMLS_CC);
}
@@ -275,7 +275,7 @@ static int spl_autoload(zend_string *class_name, zend_string *lc_name, const cha
if (!file_handle.opened_path) {
file_handle.opened_path = estrndup(class_file, class_file_len);
}
- opened_path = STR_INIT(file_handle.opened_path, strlen(file_handle.opened_path), 0);
+ opened_path = zend_string_init(file_handle.opened_path, strlen(file_handle.opened_path), 0);
ZVAL_NULL(&dummy);
if (zend_hash_add(&EG(included_files), opened_path, &dummy)) {
new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);
@@ -284,7 +284,7 @@ static int spl_autoload(zend_string *class_name, zend_string *lc_name, const cha
new_op_array = NULL;
zend_file_handle_dtor(&file_handle TSRMLS_CC);
}
- STR_RELEASE(opened_path);
+ zend_string_release(opened_path);
if (new_op_array) {
ZVAL_UNDEF(&result);
zend_execute(new_op_array, &result TSRMLS_CC);
@@ -323,7 +323,7 @@ PHP_FUNCTION(spl_autoload)
pos_len = file_exts->len;
}
- lc_name = STR_ALLOC(class_name->len, 0);
+ lc_name = zend_string_alloc(class_name->len, 0);
zend_str_tolower_copy(lc_name->val, class_name->val, class_name->len);
while (pos && *pos && !EG(exception)) {
pos1 = strchr(pos, ',');
@@ -339,7 +339,7 @@ PHP_FUNCTION(spl_autoload)
pos = pos1 ? pos1 + 1 : NULL;
pos_len = pos1? pos_len - pos1_len - 1 : 0;
}
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
if (!found && !SPL_G(autoload_running)) {
/* For internal errors, we generate E_ERROR, for direct calls an exception is thrown.
@@ -370,15 +370,15 @@ PHP_FUNCTION(spl_autoload_extensions)
}
if (file_exts) {
if (SPL_G(autoload_extensions)) {
- STR_RELEASE(SPL_G(autoload_extensions));
+ zend_string_release(SPL_G(autoload_extensions));
}
- SPL_G(autoload_extensions) = STR_COPY(file_exts);
+ SPL_G(autoload_extensions) = zend_string_copy(file_exts);
}
if (SPL_G(autoload_extensions) == NULL) {
RETURN_STRINGL(SPL_DEFAULT_FILE_EXTENSIONS, sizeof(SPL_DEFAULT_FILE_EXTENSIONS) - 1);
} else {
- STR_ADDREF(SPL_G(autoload_extensions));
+ zend_string_addref(SPL_G(autoload_extensions));
RETURN_STR(SPL_G(autoload_extensions));
}
} /* }}} */
@@ -417,7 +417,7 @@ PHP_FUNCTION(spl_autoload_call)
if (SPL_G(autoload_functions)) {
int l_autoload_running = SPL_G(autoload_running);
SPL_G(autoload_running) = 1;
- lc_name = STR_ALLOC(Z_STRLEN_P(class_name), 0);
+ lc_name = zend_string_alloc(Z_STRLEN_P(class_name), 0);
zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(class_name), Z_STRLEN_P(class_name));
ZEND_HASH_FOREACH_STR_KEY_PTR(SPL_G(autoload_functions), func_name, alfi) {
zend_call_method(Z_ISUNDEF(alfi->obj)? NULL : &alfi->obj, alfi->ce, &alfi->func_ptr, func_name->val, func_name->len, retval, 1, class_name, NULL TSRMLS_CC);
@@ -431,7 +431,7 @@ PHP_FUNCTION(spl_autoload_call)
}
} ZEND_HASH_FOREACH_END();
zend_exception_restore(TSRMLS_C);
- STR_FREE(lc_name);
+ zend_string_free(lc_name);
SPL_G(autoload_running) = l_autoload_running;
} else {
/* do not use or overwrite &EG(autoload_func) here */
@@ -480,7 +480,7 @@ PHP_FUNCTION(spl_autoload_register)
if (error) {
efree(error);
}
- STR_RELEASE(func_name);
+ zend_string_release(func_name);
RETURN_FALSE;
} else if (do_throw) {
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Passed array does not specify %s %smethod (%s)", alfi.func_ptr ? "a callable" : "an existing", !obj_ptr ? "static " : "", error);
@@ -488,7 +488,7 @@ PHP_FUNCTION(spl_autoload_register)
if (error) {
efree(error);
}
- STR_RELEASE(func_name);
+ zend_string_release(func_name);
RETURN_FALSE;
} else if (Z_TYPE_P(zcallable) == IS_STRING) {
if (do_throw) {
@@ -497,7 +497,7 @@ PHP_FUNCTION(spl_autoload_register)
if (error) {
efree(error);
}
- STR_RELEASE(func_name);
+ zend_string_release(func_name);
RETURN_FALSE;
} else {
if (do_throw) {
@@ -506,7 +506,7 @@ PHP_FUNCTION(spl_autoload_register)
if (error) {
efree(error);
}
- STR_RELEASE(func_name);
+ zend_string_release(func_name);
RETURN_FALSE;
}
} else if (fcc.function_handler->type == ZEND_INTERNAL_FUNCTION &&
@@ -517,7 +517,7 @@ PHP_FUNCTION(spl_autoload_register)
if (error) {
efree(error);
}
- STR_RELEASE(func_name);
+ zend_string_release(func_name);
RETURN_FALSE;
}
alfi.ce = fcc.calling_scope;
@@ -530,16 +530,16 @@ PHP_FUNCTION(spl_autoload_register)
if (Z_TYPE_P(zcallable) == IS_OBJECT) {
ZVAL_COPY(&alfi.closure, zcallable);
- lc_name = STR_ALLOC(func_name->len + sizeof(zend_uint), 0);
+ lc_name = zend_string_alloc(func_name->len + sizeof(uint32_t), 0);
zend_str_tolower_copy(lc_name->val, func_name->val, func_name->len);
- memcpy(lc_name->val + func_name->len, &Z_OBJ_HANDLE_P(zcallable), sizeof(zend_uint));
+ memcpy(lc_name->val + func_name->len, &Z_OBJ_HANDLE_P(zcallable), sizeof(uint32_t));
lc_name->val[lc_name->len] = '\0';
} else {
ZVAL_UNDEF(&alfi.closure);
- lc_name = STR_ALLOC(func_name->len, 0);
+ lc_name = zend_string_alloc(func_name->len, 0);
zend_str_tolower_copy(lc_name->val, func_name->val, func_name->len);
}
- STR_RELEASE(func_name);
+ zend_string_release(func_name);
if (SPL_G(autoload_functions) && zend_hash_exists(SPL_G(autoload_functions), lc_name)) {
if (!Z_ISUNDEF(alfi.closure)) {
@@ -550,8 +550,8 @@ PHP_FUNCTION(spl_autoload_register)
if (obj_ptr && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) {
/* add object id to the hash to ensure uniqueness, for more reference look at bug #40091 */
- lc_name = STR_REALLOC(lc_name, lc_name->len + sizeof(zend_uint), 0);
- memcpy(lc_name->val + lc_name->len - sizeof(zend_uint), &obj_ptr->handle, sizeof(zend_uint));
+ lc_name = zend_string_realloc(lc_name, lc_name->len + sizeof(uint32_t), 0);
+ memcpy(lc_name->val + lc_name->len - sizeof(uint32_t), &obj_ptr->handle, sizeof(uint32_t));
lc_name->val[lc_name->len] = '\0';
ZVAL_OBJ(&alfi.obj, obj_ptr);
Z_ADDREF(alfi.obj);
@@ -594,7 +594,7 @@ PHP_FUNCTION(spl_autoload_register)
HT_MOVE_TAIL_TO_HEAD(SPL_G(autoload_functions));
}
skip:
- STR_RELEASE(lc_name);
+ zend_string_release(lc_name);
}
if (SPL_G(autoload_functions)) {
@@ -629,7 +629,7 @@ PHP_FUNCTION(spl_autoload_unregister)
efree(error);
}
if (func_name) {
- STR_RELEASE(func_name);
+ zend_string_release(func_name);
}
RETURN_FALSE;
}
@@ -639,15 +639,15 @@ PHP_FUNCTION(spl_autoload_unregister)
}
if (Z_TYPE_P(zcallable) == IS_OBJECT) {
- lc_name = STR_ALLOC(func_name->len + sizeof(zend_uint), 0);
+ lc_name = zend_string_alloc(func_name->len + sizeof(uint32_t), 0);
zend_str_tolower_copy(lc_name->val, func_name->val, func_name->len);
- memcpy(lc_name->val + func_name->len, &Z_OBJ_HANDLE_P(zcallable), sizeof(zend_uint));
+ memcpy(lc_name->val + func_name->len, &Z_OBJ_HANDLE_P(zcallable), sizeof(uint32_t));
lc_name->val[lc_name->len] = '\0';
} else {
- lc_name = STR_ALLOC(func_name->len, 0);
+ lc_name = zend_string_alloc(func_name->len, 0);
zend_str_tolower_copy(lc_name->val, func_name->val, func_name->len);
}
- STR_RELEASE(func_name);
+ zend_string_release(func_name);
if (SPL_G(autoload_functions)) {
if (lc_name->len == sizeof("spl_autoload_call") - 1 && !strcmp(lc_name->val, "spl_autoload_call")) {
@@ -661,8 +661,8 @@ PHP_FUNCTION(spl_autoload_unregister)
/* remove specific */
success = zend_hash_del(SPL_G(autoload_functions), lc_name);
if (success != SUCCESS && obj_ptr) {
- lc_name = STR_REALLOC(lc_name, lc_name->len + sizeof(zend_uint), 0);
- memcpy(lc_name->val + lc_name->len - sizeof(zend_uint), &obj_ptr->handle, sizeof(zend_uint));
+ lc_name = zend_string_realloc(lc_name, lc_name->len + sizeof(uint32_t), 0);
+ memcpy(lc_name->val + lc_name->len - sizeof(uint32_t), &obj_ptr->handle, sizeof(uint32_t));
lc_name->val[lc_name->len] = '\0';
success = zend_hash_del(SPL_G(autoload_functions), lc_name);
}
@@ -677,7 +677,7 @@ PHP_FUNCTION(spl_autoload_unregister)
}
}
- STR_RELEASE(lc_name);
+ zend_string_release(lc_name);
RETURN_BOOL(success == SUCCESS);
} /* }}} */
@@ -718,15 +718,15 @@ PHP_FUNCTION(spl_autoload_functions)
Z_ADDREF(alfi->obj);
add_next_index_zval(&tmp, &alfi->obj);
} else {
- add_next_index_str(&tmp, STR_COPY(alfi->ce->name));
+ add_next_index_str(&tmp, zend_string_copy(alfi->ce->name));
}
- add_next_index_str(&tmp, STR_COPY(alfi->func_ptr->common.function_name));
+ add_next_index_str(&tmp, zend_string_copy(alfi->func_ptr->common.function_name));
add_next_index_zval(return_value, &tmp);
} else {
if (strncmp(alfi->func_ptr->common.function_name->val, "__lambda_func", sizeof("__lambda_func") - 1)) {
- add_next_index_str(return_value, STR_COPY(alfi->func_ptr->common.function_name));
+ add_next_index_str(return_value, zend_string_copy(alfi->func_ptr->common.function_name));
} else {
- add_next_index_str(return_value, STR_COPY(key));
+ add_next_index_str(return_value, zend_string_copy(key));
}
}
} ZEND_HASH_FOREACH_END();
@@ -734,7 +734,7 @@ PHP_FUNCTION(spl_autoload_functions)
}
array_init(return_value);
- add_next_index_str(return_value, STR_COPY(EG(autoload_func)->common.function_name));
+ add_next_index_str(return_value, zend_string_copy(EG(autoload_func)->common.function_name));
} /* }}} */
/* {{{ proto string spl_object_hash(object obj)
@@ -742,22 +742,18 @@ PHP_FUNCTION(spl_autoload_functions)
PHP_FUNCTION(spl_object_hash)
{
zval *obj;
- char hash[33];
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
- php_spl_object_hash(obj, hash TSRMLS_CC);
-
- RETURN_STRING(hash);
+ RETURN_NEW_STR(php_spl_object_hash(obj TSRMLS_CC));
}
/* }}} */
-PHPAPI void php_spl_object_hash(zval *obj, char *result TSRMLS_DC) /* {{{*/
+PHPAPI zend_string *php_spl_object_hash(zval *obj TSRMLS_DC) /* {{{*/
{
intptr_t hash_handle, hash_handlers;
- char *hex;
if (!SPL_G(hash_mask_init)) {
if (!BG(mt_rand_is_seeded)) {
@@ -772,10 +768,7 @@ PHPAPI void php_spl_object_hash(zval *obj, char *result TSRMLS_DC) /* {{{*/
hash_handle = SPL_G(hash_mask_handle)^(intptr_t)Z_OBJ_HANDLE_P(obj);
hash_handlers = SPL_G(hash_mask_handlers)^(intptr_t)Z_OBJ_HT_P(obj);
- spprintf(&hex, 32, "%016lx%016lx", hash_handle, hash_handlers);
-
- strlcpy(result, hex, 33);
- efree(hex);
+ return strpprintf(32, "%016lx%016lx", hash_handle, hash_handlers);
}
/* }}} */
@@ -934,7 +927,7 @@ PHP_RINIT_FUNCTION(spl) /* {{{ */
PHP_RSHUTDOWN_FUNCTION(spl) /* {{{ */
{
if (SPL_G(autoload_extensions)) {
- STR_RELEASE(SPL_G(autoload_extensions));
+ zend_string_release(SPL_G(autoload_extensions));
SPL_G(autoload_extensions) = NULL;
}
if (SPL_G(autoload_functions)) {
diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h
index b186255f57..c2b1837e8d 100644
--- a/ext/spl/php_spl.h
+++ b/ext/spl/php_spl.h
@@ -79,7 +79,7 @@ PHP_FUNCTION(class_parents);
PHP_FUNCTION(class_implements);
PHP_FUNCTION(class_uses);
-PHPAPI void php_spl_object_hash(zval *obj, char* md5str TSRMLS_DC);
+PHPAPI zend_string *php_spl_object_hash(zval *obj TSRMLS_DC);
#endif /* PHP_SPL_H */
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 720a704e92..4b3a6eef15 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -66,7 +66,7 @@ typedef struct _spl_array_object {
zval array;
zval retval;
HashPosition pos;
- ulong pos_h;
+ zend_ulong pos_h;
int ar_flags;
int is_self;
zend_function *fptr_offset_get;
@@ -300,7 +300,7 @@ static zend_object *spl_array_object_clone(zval *zobject TSRMLS_DC)
static zval *spl_array_get_dimension_ptr(int check_inherited, zval *object, zval *offset, int type TSRMLS_DC) /* {{{ */
{
zval *retval;
- long index;
+ zend_long index;
zend_string *offset_key;
spl_array_object *intern = Z_SPLARRAY_P(object);
HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
@@ -360,11 +360,11 @@ fetch_dim_string:
}
return retval;
case IS_RESOURCE:
- zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_RES_P(offset)->handle, Z_RES_P(offset)->handle);
+ zend_error(E_STRICT, "Resource ID#%pd used as offset, casting to integer (%pd)", Z_RES_P(offset)->handle, Z_RES_P(offset)->handle);
index = Z_RES_P(offset)->handle;
goto num_index;
case IS_DOUBLE:
- index = (long)Z_DVAL_P(offset);
+ index = (zend_long)Z_DVAL_P(offset);
goto num_index;
case IS_FALSE:
index = 0;
@@ -378,13 +378,13 @@ num_index:
if ((retval = zend_hash_index_find(ht, index)) == NULL) {
switch (type) {
case BP_VAR_R:
- zend_error(E_NOTICE, "Undefined offset: %ld", index);
+ zend_error(E_NOTICE, "Undefined offset: %pd", index);
case BP_VAR_UNSET:
case BP_VAR_IS:
retval = &EG(uninitialized_zval);
break;
case BP_VAR_RW:
- zend_error(E_NOTICE, "Undefined offset: %ld", index);
+ zend_error(E_NOTICE, "Undefined offset: %pd", index);
case BP_VAR_W: {
zval value;
ZVAL_UNDEF(&value);
@@ -450,7 +450,7 @@ static zval *spl_array_read_dimension(zval *object, zval *offset, int type, zval
static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval *offset, zval *value TSRMLS_DC) /* {{{ */
{
spl_array_object *intern = Z_SPLARRAY_P(object);
- long index;
+ zend_long index;
HashTable *ht;
if (check_inherited && intern->fptr_offset_set) {
@@ -493,7 +493,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
zend_symtable_update_ind(ht, Z_STR_P(offset), value);
return;
case IS_DOUBLE:
- index = (long)Z_DVAL_P(offset);
+ index = (zend_long)Z_DVAL_P(offset);
goto num_index;
case IS_RESOURCE:
index = Z_RES_HANDLE_P(offset);
@@ -535,7 +535,7 @@ static void spl_array_write_dimension(zval *object, zval *offset, zval *value TS
static void spl_array_unset_dimension_ex(int check_inherited, zval *object, zval *offset TSRMLS_DC) /* {{{ */
{
- long index;
+ zend_long index;
HashTable *ht;
spl_array_object *intern = Z_SPLARRAY_P(object);
@@ -585,7 +585,7 @@ static void spl_array_unset_dimension_ex(int check_inherited, zval *object, zval
}
break;
case IS_DOUBLE:
- index = (long)Z_DVAL_P(offset);
+ index = (zend_long)Z_DVAL_P(offset);
goto num_index;
case IS_RESOURCE:
index = Z_RES_HANDLE_P(offset);
@@ -605,7 +605,7 @@ num_index:
return;
}
if (zend_hash_index_del(ht, index) == FAILURE) {
- zend_error(E_NOTICE,"Undefined offset: %ld", index);
+ zend_error(E_NOTICE,"Undefined offset: %pd", index);
}
break;
default:
@@ -623,7 +623,7 @@ static void spl_array_unset_dimension(zval *object, zval *offset TSRMLS_DC) /* {
static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *offset, int check_empty TSRMLS_DC) /* {{{ */
{
spl_array_object *intern = Z_SPLARRAY_P(object);
- long index;
+ zend_long index;
zval rv, *value = NULL, *tmp;
if (check_inherited && intern->fptr_offset_has) {
@@ -664,7 +664,7 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
break;
case IS_DOUBLE:
- index = (long)Z_DVAL_P(offset);
+ index = (zend_long)Z_DVAL_P(offset);
goto num_index;
case IS_RESOURCE:
index = Z_RES_HANDLE_P(offset);
@@ -874,7 +874,7 @@ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /*
base = (Z_OBJ_HT_P(obj) == &spl_handler_ArrayIterator) ? spl_ce_ArrayIterator : spl_ce_ArrayObject;
zname = spl_gen_private_prop_name(base, "storage", sizeof("storage")-1 TSRMLS_CC);
zend_symtable_update(intern->debug_info, zname, storage);
- STR_RELEASE(zname);
+ zend_string_release(zname);
}
return intern->debug_info;
@@ -969,7 +969,7 @@ static int spl_array_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
static int spl_array_skip_protected(spl_array_object *intern, HashTable *aht TSRMLS_DC) /* {{{ */
{
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
zval *data;
if (Z_TYPE(intern->array) == IS_OBJECT) {
@@ -1141,7 +1141,7 @@ static void spl_array_it_rewind(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
/* }}} */
/* {{{ spl_array_set_array */
-static void spl_array_set_array(zval *object, spl_array_object *intern, zval *array, long ar_flags, int just_array TSRMLS_DC) {
+static void spl_array_set_array(zval *object, spl_array_object *intern, zval *array, zend_long ar_flags, int just_array TSRMLS_DC) {
if (Z_TYPE_P(array) == IS_ARRAY) {
SEPARATE_ZVAL_IF_NOT_REF(array);
@@ -1223,7 +1223,7 @@ SPL_METHOD(Array, __construct)
zval *object = getThis();
spl_array_object *intern;
zval *array;
- long ar_flags = 0;
+ zend_long ar_flags = 0;
zend_class_entry *ce_get_iterator = spl_ce_Iterator;
zend_error_handling error_handling;
@@ -1286,7 +1286,7 @@ SPL_METHOD(Array, getIteratorClass)
return;
}
- STR_ADDREF(intern->ce_get_iterator->name);
+ zend_string_addref(intern->ce_get_iterator->name);
RETURN_STR(intern->ce_get_iterator->name);
}
/* }}} */
@@ -1312,7 +1312,7 @@ SPL_METHOD(Array, setFlags)
{
zval *object = getThis();
spl_array_object *intern = Z_SPLARRAY_P(object);
- long ar_flags = 0;
+ zend_long ar_flags = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ar_flags) == FAILURE) {
return;
@@ -1381,7 +1381,7 @@ SPL_METHOD(Array, rewind)
Seek to position. */
SPL_METHOD(Array, seek)
{
- long opos, position;
+ zend_long opos, position;
zval *object = getThis();
spl_array_object *intern = Z_SPLARRAY_P(object);
HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
@@ -1408,10 +1408,10 @@ SPL_METHOD(Array, seek)
return; /* ok */
}
}
- zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Seek position %ld is out of range", opos);
+ zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Seek position %pd is out of range", opos);
} /* }}} */
-int static spl_array_object_count_elements_helper(spl_array_object *intern, long *count TSRMLS_DC) /* {{{ */
+int static spl_array_object_count_elements_helper(spl_array_object *intern, zend_long *count TSRMLS_DC) /* {{{ */
{
HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
HashPosition pos;
@@ -1439,7 +1439,7 @@ int static spl_array_object_count_elements_helper(spl_array_object *intern, long
}
} /* }}} */
-int spl_array_object_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
+int spl_array_object_count_elements(zval *object, zend_long *count TSRMLS_DC) /* {{{ */
{
spl_array_object *intern = Z_SPLARRAY_P(object);
@@ -1449,8 +1449,8 @@ int spl_array_object_count_elements(zval *object, long *count TSRMLS_DC) /* {{{
if (Z_TYPE(rv) != IS_UNDEF) {
zval_ptr_dtor(&intern->retval);
ZVAL_ZVAL(&intern->retval, &rv, 0, 0);
- convert_to_long(&intern->retval);
- *count = (long)Z_LVAL(intern->retval);
+ convert_to_int(&intern->retval);
+ *count = (zend_long)Z_LVAL(intern->retval);
return SUCCESS;
}
*count = 0;
@@ -1464,7 +1464,7 @@ int spl_array_object_count_elements(zval *object, long *count TSRMLS_DC) /* {{{
Return the number of elements in the Iterator. */
SPL_METHOD(Array, count)
{
- long count;
+ zend_long count;
spl_array_object *intern = Z_SPLARRAY_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
@@ -1781,7 +1781,7 @@ SPL_METHOD(Array, unserialize)
php_unserialize_data_t var_hash;
zval members, zflags;
HashTable *aht;
- long flags;
+ zend_long flags;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &buf_len) == FAILURE) {
return;
@@ -1861,7 +1861,7 @@ SPL_METHOD(Array, unserialize)
outexcept:
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Error at offset %ld of %d bytes", (long)((char*)p - buf), buf_len);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Error at offset %pd of %d bytes", (zend_long)((char*)p - buf), buf_len);
return;
} /* }}} */
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index f9fe83e26d..28a5532721 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -596,7 +596,7 @@ static HashTable *spl_filesystem_object_get_debug_info(zval *object, int *is_tem
path = spl_filesystem_object_get_pathname(intern, &path_len TSRMLS_CC);
ZVAL_STRINGL(&tmp, path, path_len);
zend_symtable_update(rv, pnstr, &tmp);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
if (intern->file_name) {
pnstr = spl_gen_private_prop_name(spl_ce_SplFileInfo, "fileName", sizeof("fileName")-1 TSRMLS_CC);
@@ -608,7 +608,7 @@ static HashTable *spl_filesystem_object_get_debug_info(zval *object, int *is_tem
ZVAL_STRINGL(&tmp, intern->file_name, intern->file_name_len);
}
zend_symtable_update(rv, pnstr, &tmp);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
}
if (intern->type == SPL_FS_DIR) {
#ifdef HAVE_GLOB
@@ -619,7 +619,7 @@ static HashTable *spl_filesystem_object_get_debug_info(zval *object, int *is_tem
ZVAL_BOOL(&tmp, 0);
}
zend_symtable_update(rv, pnstr, &tmp);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
#endif
pnstr = spl_gen_private_prop_name(spl_ce_RecursiveDirectoryIterator, "subPathName", sizeof("subPathName")-1 TSRMLS_CC);
if (intern->u.dir.sub_path) {
@@ -628,24 +628,24 @@ static HashTable *spl_filesystem_object_get_debug_info(zval *object, int *is_tem
ZVAL_EMPTY_STRING(&tmp);
}
zend_symtable_update(rv, pnstr, &tmp);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
}
if (intern->type == SPL_FS_FILE) {
pnstr = spl_gen_private_prop_name(spl_ce_SplFileObject, "openMode", sizeof("openMode")-1 TSRMLS_CC);
ZVAL_STRINGL(&tmp, intern->u.file.open_mode, intern->u.file.open_mode_len);
zend_symtable_update(rv, pnstr, &tmp);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
stmp[1] = '\0';
stmp[0] = intern->u.file.delimiter;
pnstr = spl_gen_private_prop_name(spl_ce_SplFileObject, "delimiter", sizeof("delimiter")-1 TSRMLS_CC);
ZVAL_STRINGL(&tmp, stmp, 1);
zend_symtable_update(rv, pnstr, &tmp);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
stmp[0] = intern->u.file.enclosure;
pnstr = spl_gen_private_prop_name(spl_ce_SplFileObject, "enclosure", sizeof("enclosure")-1 TSRMLS_CC);
ZVAL_STRINGL(&tmp, stmp, 1);
zend_symtable_update(rv, pnstr, &tmp);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
}
return rv;
@@ -658,9 +658,9 @@ zend_function *spl_filesystem_object_get_method_check(zend_object **object, zend
if (fsobj->u.dir.entry.d_name[0] == '\0' && fsobj->orig_path == NULL) {
zend_function *func;
- zend_string *tmp = STR_INIT("_bad_state_ex", sizeof("_bad_state_ex") - 1, 0);
+ zend_string *tmp = zend_string_init("_bad_state_ex", sizeof("_bad_state_ex") - 1, 0);
func = zend_get_std_object_handlers()->get_method(object, tmp, NULL TSRMLS_CC);
- STR_RELEASE(tmp);
+ zend_string_release(tmp);
return func;
}
@@ -671,12 +671,12 @@ zend_function *spl_filesystem_object_get_method_check(zend_object **object, zend
#define DIT_CTOR_FLAGS 0x00000001
#define DIT_CTOR_GLOB 0x00000002
-void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, long ctor_flags) /* {{{ */
+void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, zend_long ctor_flags) /* {{{ */
{
spl_filesystem_object *intern;
char *path;
int parsed, len;
- long flags;
+ zend_long flags;
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC);
@@ -813,7 +813,7 @@ SPL_METHOD(DirectoryIterator, seek)
{
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
zval retval;
- long pos;
+ zend_long pos;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &pos) == FAILURE) {
return;
@@ -935,10 +935,10 @@ SPL_METHOD(SplFileInfo, getExtension)
if (p) {
idx = p - ret->val;
RETVAL_STRINGL(ret->val + idx + 1, ret->len - idx - 1);
- STR_RELEASE(ret);
+ zend_string_release(ret);
return;
} else {
- STR_RELEASE(ret);
+ zend_string_release(ret);
RETURN_EMPTY_STRING();
}
}
@@ -963,9 +963,9 @@ SPL_METHOD(DirectoryIterator, getExtension)
if (p) {
idx = p - fname->val;
RETVAL_STRINGL(fname->val + idx + 1, fname->len - idx - 1);
- STR_RELEASE(fname);
+ zend_string_release(fname);
} else {
- STR_RELEASE(fname);
+ zend_string_release(fname);
RETURN_EMPTY_STRING();
}
}
@@ -1453,7 +1453,7 @@ SPL_METHOD(FilesystemIterator, getFlags)
SPL_METHOD(FilesystemIterator, setFlags)
{
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
- long flags;
+ zend_long flags;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) {
return;
@@ -2025,7 +2025,7 @@ static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent TS
{
char *buf;
size_t line_len = 0;
- long line_add = (intern->u.file.current_line || !Z_ISUNDEF(intern->u.file.current_zval)) ? 1 : 0;
+ zend_long line_add = (intern->u.file.current_line || !Z_ISUNDEF(intern->u.file.current_zval)) ? 1 : 0;
spl_filesystem_file_free_line(intern TSRMLS_CC);
@@ -2319,7 +2319,7 @@ SPL_METHOD(SplFileObject, __construct)
Construct a new temp file object */
SPL_METHOD(SplTempFileObject, __construct)
{
- long max_memory = PHP_STREAM_MAX_MEM;
+ zend_long max_memory = PHP_STREAM_MAX_MEM;
char tmp_fname[48];
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
zend_error_handling error_handling;
@@ -2335,7 +2335,7 @@ SPL_METHOD(SplTempFileObject, __construct)
intern->file_name = "php://memory";
intern->file_name_len = 12;
} else if (ZEND_NUM_ARGS()) {
- intern->file_name_len = slprintf(tmp_fname, sizeof(tmp_fname), "php://temp/maxmemory:%ld", max_memory);
+ intern->file_name_len = slprintf(tmp_fname, sizeof(tmp_fname), "php://temp/maxmemory:%pd", max_memory);
intern->file_name = tmp_fname;
} else {
intern->file_name = "php://temp";
@@ -2511,7 +2511,7 @@ SPL_METHOD(SplFileObject, getFlags)
Set maximum line length */
SPL_METHOD(SplFileObject, setMaxLineLen)
{
- long max_len;
+ zend_long max_len;
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
@@ -2537,7 +2537,7 @@ SPL_METHOD(SplFileObject, getMaxLineLen)
return;
}
- RETURN_LONG((long)intern->u.file.max_line_len);
+ RETURN_LONG((zend_long)intern->u.file.max_line_len);
} /* }}} */
/* {{{ proto bool SplFileObject::hasChildren()
@@ -2740,7 +2740,7 @@ SPL_METHOD(SplFileObject, fflush)
SPL_METHOD(SplFileObject, ftell)
{
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
- long ret;
+ zend_long ret;
if(!intern->u.file.stream) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "Object not initialized");
@@ -2761,7 +2761,7 @@ SPL_METHOD(SplFileObject, ftell)
SPL_METHOD(SplFileObject, fseek)
{
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
- long pos, whence = SEEK_SET;
+ zend_long pos, whence = SEEK_SET;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &pos, &whence) == FAILURE) {
return;
@@ -2869,7 +2869,7 @@ SPL_METHOD(SplFileObject, fwrite)
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
char *str;
int str_len;
- long length = 0;
+ zend_long length = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len, &length) == FAILURE) {
return;
@@ -2893,7 +2893,7 @@ SPL_METHOD(SplFileObject, fwrite)
SPL_METHOD(SplFileObject, fread)
{
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
- long length = 0;
+ zend_long length = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &length) == FAILURE) {
return;
@@ -2909,7 +2909,7 @@ SPL_METHOD(SplFileObject, fread)
RETURN_FALSE;
}
- ZVAL_STR(return_value, STR_ALLOC(length, 0));
+ ZVAL_STR(return_value, zend_string_alloc(length, 0));
Z_STRLEN_P(return_value) = php_stream_read(intern->u.file.stream, Z_STRVAL_P(return_value), length);
/* needed because recv/read/gzread doesnt put a null at the end*/
@@ -2926,7 +2926,7 @@ FileFunction(fstat)
SPL_METHOD(SplFileObject, ftruncate)
{
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
- long size;
+ zend_long size;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &size) == FAILURE) {
return;
@@ -2950,7 +2950,7 @@ SPL_METHOD(SplFileObject, ftruncate)
SPL_METHOD(SplFileObject, seek)
{
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
- long line_pos;
+ zend_long line_pos;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &line_pos) == FAILURE) {
return;
@@ -2961,7 +2961,7 @@ SPL_METHOD(SplFileObject, seek)
}
if (line_pos < 0) {
- zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Can't seek file %s to negative line %ld", intern->file_name, line_pos);
+ zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Can't seek file %s to negative line %pd", intern->file_name, line_pos);
RETURN_FALSE;
}
diff --git a/ext/spl/spl_directory.h b/ext/spl/spl_directory.h
index 3276d51463..dd747e5863 100644
--- a/ext/spl/spl_directory.h
+++ b/ext/spl/spl_directory.h
@@ -68,7 +68,7 @@ struct _spl_filesystem_object {
char *file_name;
int file_name_len;
SPL_FS_OBJ_TYPE type;
- long flags;
+ zend_long flags;
zend_class_entry *file_class;
zend_class_entry *info_class;
union {
@@ -93,7 +93,7 @@ struct _spl_filesystem_object {
char *current_line;
size_t current_line_len;
size_t max_line_len;
- long current_line_num;
+ zend_long current_line_num;
zval zresource;
zend_function *func_getCurr;
char delimiter;
diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c
index 09d874645d..825951e5f2 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -143,9 +143,9 @@ static spl_ptr_llist *spl_ptr_llist_init(spl_ptr_llist_ctor_func ctor, spl_ptr_l
}
/* }}} */
-static long spl_ptr_llist_count(spl_ptr_llist *llist) /* {{{ */
+static zend_long spl_ptr_llist_count(spl_ptr_llist *llist) /* {{{ */
{
- return (long)llist->count;
+ return (zend_long)llist->count;
}
/* }}} */
@@ -167,7 +167,7 @@ static void spl_ptr_llist_destroy(spl_ptr_llist *llist TSRMLS_DC) /* {{{ */
}
/* }}} */
-static spl_ptr_llist_element *spl_ptr_llist_offset(spl_ptr_llist *llist, long offset, int backward) /* {{{ */
+static spl_ptr_llist_element *spl_ptr_llist_offset(spl_ptr_llist *llist, zend_long offset, int backward) /* {{{ */
{
spl_ptr_llist_element *current;
@@ -474,7 +474,7 @@ static zend_object *spl_dllist_object_clone(zval *zobject TSRMLS_DC) /* {{{ */
}
/* }}} */
-static int spl_dllist_object_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
+static int spl_dllist_object_count_elements(zval *object, zend_long *count TSRMLS_DC) /* {{{ */
{
spl_dllist_object *intern = Z_SPLDLLIST_P(object);
@@ -484,8 +484,8 @@ static int spl_dllist_object_count_elements(zval *object, long *count TSRMLS_DC)
if (!Z_ISUNDEF(rv)) {
zval_ptr_dtor(&intern->retval);
ZVAL_ZVAL(&intern->retval, &rv, 0, 0);
- convert_to_long(&intern->retval);
- *count = (long) Z_LVAL(intern->retval);
+ convert_to_int(&intern->retval);
+ *count = (zend_long) Z_LVAL(intern->retval);
return SUCCESS;
}
*count = 0;
@@ -522,7 +522,7 @@ static HashTable* spl_dllist_object_get_debug_info(zval *obj, int *is_temp TSRML
pnstr = spl_gen_private_prop_name(spl_ce_SplDoublyLinkedList, "flags", sizeof("flags")-1 TSRMLS_CC);
ZVAL_LONG(&tmp, intern->flags);
zend_hash_add(intern->debug_info, pnstr, &tmp);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
array_init(&dllist_array);
@@ -540,7 +540,7 @@ static HashTable* spl_dllist_object_get_debug_info(zval *obj, int *is_temp TSRML
pnstr = spl_gen_private_prop_name(spl_ce_SplDoublyLinkedList, "dllist", sizeof("dllist")-1 TSRMLS_CC);
zend_hash_add(intern->debug_info, pnstr, &dllist_array);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
}
return intern->debug_info;
@@ -673,7 +673,7 @@ SPL_METHOD(SplDoublyLinkedList, bottom)
Return the number of elements in the datastructure. */
SPL_METHOD(SplDoublyLinkedList, count)
{
- long count;
+ zend_long count;
spl_dllist_object *intern = Z_SPLDLLIST_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
@@ -689,7 +689,7 @@ SPL_METHOD(SplDoublyLinkedList, count)
Return true if the SplDoublyLinkedList is empty. */
SPL_METHOD(SplDoublyLinkedList, isEmpty)
{
- long count;
+ zend_long count;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -704,7 +704,7 @@ SPL_METHOD(SplDoublyLinkedList, isEmpty)
Set the mode of iteration */
SPL_METHOD(SplDoublyLinkedList, setIteratorMode)
{
- long value;
+ zend_long value;
spl_dllist_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) == FAILURE) {
@@ -747,14 +747,14 @@ SPL_METHOD(SplDoublyLinkedList, offsetExists)
{
zval *zindex;
spl_dllist_object *intern;
- long index;
+ zend_long index;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zindex) == FAILURE) {
return;
}
intern = Z_SPLDLLIST_P(getThis());
- index = spl_offset_convert_to_long(zindex TSRMLS_CC);
+ index = spl_offset_convert_to_int(zindex TSRMLS_CC);
RETURN_BOOL(index >= 0 && index < intern->llist->count);
} /* }}} */
@@ -764,7 +764,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetExists)
SPL_METHOD(SplDoublyLinkedList, offsetGet)
{
zval *zindex;
- long index;
+ zend_long index;
spl_dllist_object *intern;
spl_ptr_llist_element *element;
@@ -773,7 +773,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetGet)
}
intern = Z_SPLDLLIST_P(getThis());
- index = spl_offset_convert_to_long(zindex TSRMLS_CC);
+ index = spl_offset_convert_to_int(zindex TSRMLS_CC);
if (index < 0 || index >= intern->llist->count) {
zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid or out of range", 0 TSRMLS_CC);
@@ -808,10 +808,10 @@ SPL_METHOD(SplDoublyLinkedList, offsetSet)
spl_ptr_llist_push(intern->llist, value TSRMLS_CC);
} else {
/* $obj[$foo] = ... */
- long index;
+ zend_long index;
spl_ptr_llist_element *element;
- index = spl_offset_convert_to_long(zindex TSRMLS_CC);
+ index = spl_offset_convert_to_int(zindex TSRMLS_CC);
if (index < 0 || index >= intern->llist->count) {
zval_ptr_dtor(value);
@@ -849,7 +849,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetSet)
SPL_METHOD(SplDoublyLinkedList, offsetUnset)
{
zval *zindex;
- long index;
+ zend_long index;
spl_dllist_object *intern;
spl_ptr_llist_element *element;
spl_ptr_llist *llist;
@@ -859,7 +859,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetUnset)
}
intern = Z_SPLDLLIST_P(getThis());
- index = spl_offset_convert_to_long(zindex TSRMLS_CC);
+ index = spl_offset_convert_to_int(zindex TSRMLS_CC);
llist = intern->llist;
if (index < 0 || index >= intern->llist->count) {
@@ -1209,7 +1209,7 @@ SPL_METHOD(SplDoublyLinkedList, unserialize)
error:
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Error at offset %ld of %d bytes", (long)((char*)p - buf), buf_len);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Error at offset %pd of %d bytes", (zend_long)((char*)p - buf), buf_len);
return;
} /* }}} */
@@ -1221,14 +1221,14 @@ SPL_METHOD(SplDoublyLinkedList, add)
zval *zindex, *value;
spl_dllist_object *intern;
spl_ptr_llist_element *element;
- long index;
+ zend_long index;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &zindex, &value) == FAILURE) {
return;
}
intern = Z_SPLDLLIST_P(getThis());
- index = spl_offset_convert_to_long(zindex TSRMLS_CC);
+ index = spl_offset_convert_to_int(zindex TSRMLS_CC);
if (index < 0 || index > intern->llist->count) {
zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid or out of range", 0 TSRMLS_CC);
diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c
index 0cfcb8ee18..cb069efcb1 100644
--- a/ext/spl/spl_engine.c
+++ b/ext/spl/spl_engine.c
@@ -40,9 +40,9 @@ PHPAPI void spl_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC)
}
/* }}} */
-PHPAPI long spl_offset_convert_to_long(zval *offset TSRMLS_DC) /* {{{ */
+PHPAPI zend_long spl_offset_convert_to_int(zval *offset TSRMLS_DC) /* {{{ */
{
- ulong idx;
+ zend_ulong idx;
switch (Z_TYPE_P(offset)) {
case IS_STRING:
@@ -51,7 +51,7 @@ PHPAPI long spl_offset_convert_to_long(zval *offset TSRMLS_DC) /* {{{ */
}
break;
case IS_DOUBLE:
- return (long)Z_DVAL_P(offset);
+ return (zend_long)Z_DVAL_P(offset);
case IS_LONG:
return Z_LVAL_P(offset);
case IS_FALSE:
diff --git a/ext/spl/spl_engine.h b/ext/spl/spl_engine.h
index 8c72ca9691..aed8967bd4 100644
--- a/ext/spl/spl_engine.h
+++ b/ext/spl/spl_engine.h
@@ -27,7 +27,7 @@
PHPAPI void spl_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC);
-PHPAPI long spl_offset_convert_to_long(zval *offset TSRMLS_DC);
+PHPAPI zend_long spl_offset_convert_to_int(zval *offset TSRMLS_DC);
/* {{{ spl_instantiate_arg_ex1 */
static inline int spl_instantiate_arg_ex1(zend_class_entry *pce, zval *retval, zval *arg1 TSRMLS_DC)
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index 62aaffbc3c..acdd9dd137 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -43,7 +43,7 @@ ZEND_GET_MODULE(spl_fixedarray)
#endif
typedef struct _spl_fixedarray { /* {{{ */
- long size;
+ zend_long size;
zval *elements;
} spl_fixedarray;
/* }}} */
@@ -81,7 +81,7 @@ static inline spl_fixedarray_object *spl_fixed_array_from_obj(zend_object *obj)
#define Z_SPLFIXEDARRAY_P(zv) spl_fixed_array_from_obj(Z_OBJ_P((zv)))
-static void spl_fixedarray_init(spl_fixedarray *array, long size TSRMLS_DC) /* {{{ */
+static void spl_fixedarray_init(spl_fixedarray *array, zend_long size TSRMLS_DC) /* {{{ */
{
if (size > 0) {
array->size = 0; /* reset size in case ecalloc() fails */
@@ -94,7 +94,7 @@ static void spl_fixedarray_init(spl_fixedarray *array, long size TSRMLS_DC) /* {
}
/* }}} */
-static void spl_fixedarray_resize(spl_fixedarray *array, long size TSRMLS_DC) /* {{{ */
+static void spl_fixedarray_resize(spl_fixedarray *array, zend_long size TSRMLS_DC) /* {{{ */
{
if (size == array->size) {
/* nothing to do */
@@ -109,7 +109,7 @@ static void spl_fixedarray_resize(spl_fixedarray *array, long size TSRMLS_DC) /*
/* clearing the array */
if (size == 0) {
- long i;
+ zend_long i;
for (i = 0; i < array->size; i++) {
zval_ptr_dtor(&(array->elements[i]));
@@ -123,7 +123,7 @@ static void spl_fixedarray_resize(spl_fixedarray *array, long size TSRMLS_DC) /*
array->elements = safe_erealloc(array->elements, size, sizeof(zval), 0);
memset(array->elements + array->size, '\0', sizeof(zval) * (size - array->size));
} else { /* size < array->size */
- long i;
+ zend_long i;
for (i = size; i < array->size; i++) {
zval_ptr_dtor(&(array->elements[i]));
@@ -194,7 +194,7 @@ static HashTable* spl_fixedarray_object_get_properties(zval *obj TSRMLS_DC) /* {
static void spl_fixedarray_object_free_storage(zend_object *object TSRMLS_DC) /* {{{ */
{
spl_fixedarray_object *intern = spl_fixed_array_from_obj(object);
- long i;
+ zend_long i;
if (intern->array) {
for (i = 0; i < intern->array->size; i++) {
@@ -328,7 +328,7 @@ static zend_object *spl_fixedarray_object_clone(zval *zobject TSRMLS_DC) /* {{{
static inline zval *spl_fixedarray_object_read_dimension_helper(spl_fixedarray_object *intern, zval *offset TSRMLS_DC) /* {{{ */
{
- long index;
+ zend_long index;
/* we have to return NULL on error here to avoid memleak because of
* ZE duplicating uninitialized_zval_ptr */
@@ -338,7 +338,7 @@ static inline zval *spl_fixedarray_object_read_dimension_helper(spl_fixedarray_o
}
if (Z_TYPE_P(offset) != IS_LONG) {
- index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ index = spl_offset_convert_to_int(offset TSRMLS_CC);
} else {
index = Z_LVAL_P(offset);
}
@@ -384,7 +384,7 @@ static zval *spl_fixedarray_object_read_dimension(zval *object, zval *offset, in
static inline void spl_fixedarray_object_write_dimension_helper(spl_fixedarray_object *intern, zval *offset, zval *value TSRMLS_DC) /* {{{ */
{
- long index;
+ zend_long index;
if (!offset) {
/* '$array[] = value' syntax is not supported */
@@ -393,7 +393,7 @@ static inline void spl_fixedarray_object_write_dimension_helper(spl_fixedarray_o
}
if (Z_TYPE_P(offset) != IS_LONG) {
- index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ index = spl_offset_convert_to_int(offset TSRMLS_CC);
} else {
index = Z_LVAL_P(offset);
}
@@ -438,10 +438,10 @@ static void spl_fixedarray_object_write_dimension(zval *object, zval *offset, zv
static inline void spl_fixedarray_object_unset_dimension_helper(spl_fixedarray_object *intern, zval *offset TSRMLS_DC) /* {{{ */
{
- long index;
+ zend_long index;
if (Z_TYPE_P(offset) != IS_LONG) {
- index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ index = spl_offset_convert_to_int(offset TSRMLS_CC);
} else {
index = Z_LVAL_P(offset);
}
@@ -476,11 +476,11 @@ static void spl_fixedarray_object_unset_dimension(zval *object, zval *offset TSR
static inline int spl_fixedarray_object_has_dimension_helper(spl_fixedarray_object *intern, zval *offset, int check_empty TSRMLS_DC) /* {{{ */
{
- long index;
+ zend_long index;
int retval;
if (Z_TYPE_P(offset) != IS_LONG) {
- index = spl_offset_convert_to_long(offset TSRMLS_CC);
+ index = spl_offset_convert_to_int(offset TSRMLS_CC);
} else {
index = Z_LVAL_P(offset);
}
@@ -528,7 +528,7 @@ static int spl_fixedarray_object_has_dimension(zval *object, zval *offset, int c
}
/* }}} */
-static int spl_fixedarray_object_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
+static int spl_fixedarray_object_count_elements(zval *object, zend_long *count TSRMLS_DC) /* {{{ */
{
spl_fixedarray_object *intern;
@@ -539,8 +539,8 @@ static int spl_fixedarray_object_count_elements(zval *object, long *count TSRMLS
if (!Z_ISUNDEF(rv)) {
zval_ptr_dtor(&intern->retval);
ZVAL_ZVAL(&intern->retval, &rv, 0, 0);
- convert_to_long(&intern->retval);
- *count = (long) Z_LVAL(intern->retval);
+ convert_to_int(&intern->retval);
+ *count = (zend_long) Z_LVAL(intern->retval);
return SUCCESS;
}
} else if (intern->array) {
@@ -559,7 +559,7 @@ SPL_METHOD(SplFixedArray, __construct)
{
zval *object = getThis();
spl_fixedarray_object *intern;
- long size = 0;
+ zend_long size = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &size) == FAILURE) {
return;
@@ -684,11 +684,11 @@ SPL_METHOD(SplFixedArray, fromArray)
if (num > 0 && save_indexes) {
zval *element;
zend_string *str_index;
- ulong num_index, max_index = 0;
- long tmp;
+ zend_ulong num_index, max_index = 0;
+ zend_long tmp;
ZEND_HASH_FOREACH_KEY(Z_ARRVAL_P(data), num_index, str_index) {
- if (str_index != NULL || (long)num_index < 0) {
+ if (str_index != NULL || (zend_long)num_index < 0) {
efree(array);
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "array must contain only positive integer keys");
return;
@@ -714,7 +714,7 @@ SPL_METHOD(SplFixedArray, fromArray)
} else if (num > 0 && !save_indexes) {
zval *element;
- long i = 0;
+ zend_long i = 0;
spl_fixedarray_init(array, num TSRMLS_CC);
@@ -759,7 +759,7 @@ SPL_METHOD(SplFixedArray, setSize)
{
zval *object = getThis();
spl_fixedarray_object *intern;
- long size;
+ zend_long size;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &size) == FAILURE) {
return;
diff --git a/ext/spl/spl_functions.c b/ext/spl/spl_functions.c
index 97a9509caa..13440355ce 100644
--- a/ext/spl/spl_functions.c
+++ b/ext/spl/spl_functions.c
@@ -84,7 +84,7 @@ void spl_add_class_name(zval *list, zend_class_entry *pce, int allow, int ce_fla
if ((tmp = zend_hash_find(Z_ARRVAL_P(list), pce->name)) == NULL) {
zval t;
- STR_ADDREF(pce->name);
+ zend_string_addref(pce->name);
ZVAL_STR(&t, pce->name);
zend_hash_add(Z_ARRVAL_P(list), pce->name, &t);
}
@@ -95,7 +95,7 @@ void spl_add_class_name(zval *list, zend_class_entry *pce, int allow, int ce_fla
/* {{{ spl_add_interfaces */
void spl_add_interfaces(zval *list, zend_class_entry * pce, int allow, int ce_flags TSRMLS_DC)
{
- zend_uint num_interfaces;
+ uint32_t num_interfaces;
for (num_interfaces = 0; num_interfaces < pce->num_interfaces; num_interfaces++) {
spl_add_class_name(list, pce->interfaces[num_interfaces], allow, ce_flags TSRMLS_CC);
@@ -106,7 +106,7 @@ void spl_add_interfaces(zval *list, zend_class_entry * pce, int allow, int ce_fl
/* {{{ spl_add_traits */
void spl_add_traits(zval *list, zend_class_entry * pce, int allow, int ce_flags TSRMLS_DC)
{
- zend_uint num_traits;
+ uint32_t num_traits;
for (num_traits = 0; num_traits < pce->num_traits; num_traits++) {
spl_add_class_name(list, pce->traits[num_traits], allow, ce_flags TSRMLS_CC);
diff --git a/ext/spl/spl_functions.h b/ext/spl/spl_functions.h
index 1d116ff783..88ae478a02 100644
--- a/ext/spl/spl_functions.h
+++ b/ext/spl/spl_functions.h
@@ -47,7 +47,7 @@ typedef zend_object* (*create_object_func_t)(zend_class_entry *class_type TSRMLS
spl_register_property(spl_ce_ ## class_name, prop_name, sizeof(prop_name)-1, prop_flags TSRMLS_CC);
#define REGISTER_SPL_CLASS_CONST_LONG(class_name, const_name, value) \
- zend_declare_class_constant_long(spl_ce_ ## class_name, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
+ zend_declare_class_constant_long(spl_ce_ ## class_name, const_name, sizeof(const_name)-1, (zend_long)value TSRMLS_CC);
void spl_register_std_class(zend_class_entry ** ppce, char * class_name, create_object_func_t ctor, const zend_function_entry * function_list TSRMLS_DC);
void spl_register_sub_class(zend_class_entry ** ppce, zend_class_entry * parent_ce, char * class_name, create_object_func_t ctor, const zend_function_entry * function_list TSRMLS_DC);
diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c
index 90d78db6ee..0910686c4f 100644
--- a/ext/spl/spl_heap.c
+++ b/ext/spl/spl_heap.c
@@ -105,7 +105,7 @@ static void spl_ptr_heap_zval_ctor(zval *elem TSRMLS_DC) { /* {{{ */
}
/* }}} */
-static int spl_ptr_heap_cmp_cb_helper(zval *object, spl_heap_object *heap_object, zval *a, zval *b, long *result TSRMLS_DC) { /* {{{ */
+static int spl_ptr_heap_cmp_cb_helper(zval *object, spl_heap_object *heap_object, zval *a, zval *b, zend_long *result TSRMLS_DC) { /* {{{ */
zval zresult;
zend_call_method_with_2_params(object, heap_object->std.ce, &heap_object->fptr_cmp, "compare", &zresult, a, b);
@@ -114,7 +114,7 @@ static int spl_ptr_heap_cmp_cb_helper(zval *object, spl_heap_object *heap_object
return FAILURE;
}
- convert_to_long(&zresult);
+ convert_to_int(&zresult);
*result = Z_LVAL(zresult);
zval_ptr_dtor(&zresult);
@@ -155,7 +155,7 @@ static int spl_ptr_heap_zval_max_cmp(zval *a, zval *b, zval *object TSRMLS_DC) {
if (object) {
spl_heap_object *heap_object = Z_SPLHEAP_P(object);
if (heap_object->fptr_cmp) {
- long lval = 0;
+ zend_long lval = 0;
if (spl_ptr_heap_cmp_cb_helper(object, heap_object, a, b, &lval TSRMLS_CC) == FAILURE) {
/* exception or call failure */
return 0;
@@ -179,7 +179,7 @@ static int spl_ptr_heap_zval_min_cmp(zval *a, zval *b, zval *object TSRMLS_DC) {
if (object) {
spl_heap_object *heap_object = Z_SPLHEAP_P(object);
if (heap_object->fptr_cmp) {
- long lval = 0;
+ zend_long lval = 0;
if (spl_ptr_heap_cmp_cb_helper(object, heap_object, a, b, &lval TSRMLS_CC) == FAILURE) {
/* exception or call failure */
return 0;
@@ -210,7 +210,7 @@ static int spl_ptr_pqueue_zval_cmp(zval *a, zval *b, zval *object TSRMLS_DC) { /
if (object) {
spl_heap_object *heap_object = Z_SPLHEAP_P(object);
if (heap_object->fptr_cmp) {
- long lval = 0;
+ zend_long lval = 0;
if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, a_priority_p, b_priority_p, &lval TSRMLS_CC) == FAILURE) {
/* exception or call failure */
return 0;
@@ -483,7 +483,7 @@ static zend_object *spl_heap_object_clone(zval *zobject TSRMLS_DC) /* {{{ */
}
/* }}} */
-static int spl_heap_object_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
+static int spl_heap_object_count_elements(zval *object, zend_long *count TSRMLS_DC) /* {{{ */
{
spl_heap_object *intern = Z_SPLHEAP_P(object);
@@ -493,8 +493,8 @@ static int spl_heap_object_count_elements(zval *object, long *count TSRMLS_DC) /
if (!Z_ISUNDEF(rv)) {
zval_ptr_dtor(&intern->retval);
ZVAL_ZVAL(&intern->retval, &rv, 0, 0);
- convert_to_long(&intern->retval);
- *count = (long) Z_LVAL(intern->retval);
+ convert_to_int(&intern->retval);
+ *count = (zend_long) Z_LVAL(intern->retval);
return SUCCESS;
}
*count = 0;
@@ -531,12 +531,12 @@ static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zv
pnstr = spl_gen_private_prop_name(ce, "flags", sizeof("flags")-1 TSRMLS_CC);
ZVAL_LONG(&tmp, intern->flags);
zend_hash_update(intern->debug_info, pnstr, &tmp);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
pnstr = spl_gen_private_prop_name(ce, "isCorrupted", sizeof("isCorrupted")-1 TSRMLS_CC);
ZVAL_BOOL(&tmp, intern->heap->flags&SPL_HEAP_CORRUPTED);
zend_hash_update(intern->debug_info, pnstr, &tmp);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
array_init(&heap_array);
@@ -549,7 +549,7 @@ static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zv
pnstr = spl_gen_private_prop_name(ce, "heap", sizeof("heap")-1 TSRMLS_CC);
zend_hash_update(intern->debug_info, pnstr, &heap_array);
- STR_RELEASE(pnstr);
+ zend_string_release(pnstr);
}
return intern->debug_info;
@@ -572,7 +572,7 @@ static HashTable* spl_pqueue_object_get_debug_info(zval *obj, int *is_temp TSRML
Return the number of elements in the heap. */
SPL_METHOD(SplHeap, count)
{
- long count;
+ zend_long count;
spl_heap_object *intern = Z_SPLHEAP_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
@@ -765,7 +765,7 @@ SPL_METHOD(SplPriorityQueue, top)
Set the flags of extraction*/
SPL_METHOD(SplPriorityQueue, setExtractFlags)
{
- long value;
+ zend_long value;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) == FAILURE) {
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index e503f9b581..b8eb7ef662 100644
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -473,7 +473,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
spl_recursive_it_object *intern;
zval *iterator;
zend_class_entry *ce_iterator;
- long mode, flags;
+ zend_long mode, flags;
int inc_refcount = 1;
zend_error_handling error_handling;
@@ -703,7 +703,7 @@ SPL_METHOD(RecursiveIteratorIterator, getDepth)
SPL_METHOD(RecursiveIteratorIterator, getSubIterator)
{
spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
- long level = object->level;
+ zend_long level = object->level;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &level) == FAILURE) {
return;
@@ -846,7 +846,7 @@ SPL_METHOD(RecursiveIteratorIterator, nextElement)
SPL_METHOD(RecursiveIteratorIterator, setMaxDepth)
{
spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
- long max_depth = -1;
+ zend_long max_depth = -1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &max_depth) == FAILURE) {
return;
@@ -879,7 +879,7 @@ static union _zend_function *spl_recursive_it_get_method(zend_object **zobject,
{
union _zend_function *function_handler;
spl_recursive_it_object *object = spl_recursive_it_from_obj(*zobject);
- long level = object->level;
+ zend_long level = object->level;
zval *zobj;
if (!object->iterators) {
@@ -1088,7 +1088,7 @@ SPL_METHOD(RecursiveTreeIterator, __construct)
Sets prefix parts as used in getPrefix() */
SPL_METHOD(RecursiveTreeIterator, setPrefixPart)
{
- long part;
+ zend_long part;
char* prefix;
int prefix_len;
spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
@@ -1222,7 +1222,7 @@ SPL_METHOD(RecursiveTreeIterator, current)
}
spl_recursive_tree_iterator_get_postfix(object, &postfix TSRMLS_CC);
- str = STR_ALLOC(Z_STRLEN(prefix) + Z_STRLEN(entry) + Z_STRLEN(postfix), 0);
+ str = zend_string_alloc(Z_STRLEN(prefix) + Z_STRLEN(entry) + Z_STRLEN(postfix), 0);
ptr = str->val;
memcpy(ptr, Z_STRVAL(prefix), Z_STRLEN(prefix));
@@ -1278,7 +1278,7 @@ SPL_METHOD(RecursiveTreeIterator, key)
spl_recursive_tree_iterator_get_prefix(object, &prefix TSRMLS_CC);
spl_recursive_tree_iterator_get_postfix(object, &postfix TSRMLS_CC);
- str = STR_ALLOC(Z_STRLEN(prefix) + Z_STRLEN(key) + Z_STRLEN(postfix), 0);
+ str = zend_string_alloc(Z_STRLEN(prefix) + Z_STRLEN(key) + Z_STRLEN(postfix), 0);
ptr = str->val;
memcpy(ptr, Z_STRVAL(prefix), Z_STRLEN(prefix));
@@ -1387,7 +1387,7 @@ int spl_dual_it_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS)
}
p = EG(argument_stack).top_element-2;
- arg_count = (ulong) *p;
+ arg_count = (zend_ulong) *p;
func_params = safe_emalloc(sizeof(zval **), arg_count, 0);
@@ -1475,7 +1475,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
}
case DIT_CachingIterator:
case DIT_RecursiveCachingIterator: {
- long flags = CIT_CALL_TOSTRING;
+ zend_long flags = CIT_CALL_TOSTRING;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|l", &zobject, ce_inner, &flags) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
@@ -1539,7 +1539,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
case DIT_RegexIterator:
case DIT_RecursiveRegexIterator: {
zend_string *regex;
- long mode = REGIT_MODE_MATCH;
+ zend_long mode = REGIT_MODE_MATCH;
intern->u.regex.use_flags = ZEND_NUM_ARGS() >= 5;
intern->u.regex.flags = 0;
@@ -1549,12 +1549,12 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
return NULL;
}
if (mode < 0 || mode >= REGIT_MODE_MAX) {
- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Illegal mode %ld", mode);
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Illegal mode %pd", mode);
zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
intern->u.regex.mode = mode;
- intern->u.regex.regex = STR_COPY(regex);
+ intern->u.regex.regex = zend_string_copy(regex);
intern->u.regex.pce = pcre_get_compiled_regex_cache(regex TSRMLS_CC);
if (intern->u.regex.pce == NULL) {
/* pcre_get_compiled_regex_cache has already sent error */
@@ -2136,7 +2136,7 @@ SPL_METHOD(RegexIterator, getRegex)
return;
}
- RETURN_STR(STR_COPY(intern->u.regex.regex));
+ RETURN_STR(zend_string_copy(intern->u.regex.regex));
} /* }}} */
/* {{{ proto bool RegexIterator::getMode()
@@ -2159,14 +2159,14 @@ SPL_METHOD(RegexIterator, getMode)
SPL_METHOD(RegexIterator, setMode)
{
spl_dual_it_object *intern;
- long mode;
+ zend_long mode;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) {
return;
}
if (mode < 0 || mode >= REGIT_MODE_MAX) {
- zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Illegal mode %ld", mode);
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Illegal mode %pd", mode);
return;/* NULL */
}
@@ -2195,7 +2195,7 @@ SPL_METHOD(RegexIterator, getFlags)
SPL_METHOD(RegexIterator, setFlags)
{
spl_dual_it_object *intern;
- long flags;
+ zend_long flags;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) {
return;
@@ -2230,7 +2230,7 @@ SPL_METHOD(RegexIterator, getPregFlags)
SPL_METHOD(RegexIterator, setPregFlags)
{
spl_dual_it_object *intern;
- long preg_flags;
+ zend_long preg_flags;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &preg_flags) == FAILURE) {
return;
@@ -2264,7 +2264,7 @@ SPL_METHOD(RecursiveRegexIterator, getChildren)
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception)) {
- ZVAL_STR(&regex, STR_COPY(intern->u.regex.regex));
+ ZVAL_STR(&regex, zend_string_copy(intern->u.regex.regex));
spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), return_value, &retval, &regex TSRMLS_CC);
zval_ptr_dtor(&regex);
}
@@ -2319,7 +2319,7 @@ static void spl_dual_it_free_storage(zend_object *_object TSRMLS_DC)
object->u.regex.pce->refcount--;
}
if (object->u.regex.regex) {
- STR_RELEASE(object->u.regex.regex);
+ zend_string_release(object->u.regex.regex);
}
}
#endif
@@ -2472,17 +2472,17 @@ static inline int spl_limit_it_valid(spl_dual_it_object *intern TSRMLS_DC)
}
}
-static inline void spl_limit_it_seek(spl_dual_it_object *intern, long pos TSRMLS_DC)
+static inline void spl_limit_it_seek(spl_dual_it_object *intern, zend_long pos TSRMLS_DC)
{
zval zpos;
spl_dual_it_free(intern TSRMLS_CC);
if (pos < intern->u.limit.offset) {
- zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Cannot seek to %ld which is below the offset %ld", pos, intern->u.limit.offset);
+ zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Cannot seek to %pd which is below the offset %pd", pos, intern->u.limit.offset);
return;
}
if (pos >= intern->u.limit.offset + intern->u.limit.count && intern->u.limit.count != -1) {
- zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Cannot seek to %ld which is behind offset %ld plus count %ld", pos, intern->u.limit.offset, intern->u.limit.count);
+ zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Cannot seek to %pd which is behind offset %pd plus count %pd", pos, intern->u.limit.offset, intern->u.limit.count);
return;
}
if (pos != intern->current.pos && instanceof_function(intern->inner.ce, spl_ce_SeekableIterator TSRMLS_CC)) {
@@ -2560,7 +2560,7 @@ SPL_METHOD(LimitIterator, next)
SPL_METHOD(LimitIterator, seek)
{
spl_dual_it_object *intern;
- long pos;
+ zend_long pos;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &pos) == FAILURE) {
return;
@@ -2792,7 +2792,7 @@ SPL_METHOD(CachingIterator, __toString)
return;
}
if (Z_TYPE(intern->u.caching.zstr) == IS_STRING) {
- RETURN_STR(STR_COPY(Z_STR_P(&intern->u.caching.zstr)));
+ RETURN_STR(zend_string_copy(Z_STR_P(&intern->u.caching.zstr)));
} else {
RETURN_NULL();
}
@@ -2938,7 +2938,7 @@ SPL_METHOD(CachingIterator, getFlags)
SPL_METHOD(CachingIterator, setFlags)
{
spl_dual_it_object *intern;
- long flags;
+ zend_long flags;
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
@@ -3574,7 +3574,7 @@ PHP_FUNCTION(iterator_to_array)
static int spl_iterator_count_apply(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ */
{
- (*(long*)puser)++;
+ (*(zend_long*)puser)++;
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
@@ -3584,7 +3584,7 @@ static int spl_iterator_count_apply(zend_object_iterator *iter, void *puser TSRM
PHP_FUNCTION(iterator_count)
{
zval *obj;
- long count = 0;
+ zend_long count = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, zend_ce_traversable) == FAILURE) {
RETURN_FALSE;
@@ -3599,7 +3599,7 @@ PHP_FUNCTION(iterator_count)
typedef struct {
zval *obj;
zval *args;
- long count;
+ zend_long count;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
} spl_iterator_apply_info;
diff --git a/ext/spl/spl_iterators.h b/ext/spl/spl_iterators.h
index f51fc3a990..7435ce7f27 100644
--- a/ext/spl/spl_iterators.h
+++ b/ext/spl/spl_iterators.h
@@ -139,11 +139,11 @@ typedef struct _spl_dual_it_object {
dual_it_type dit_type;
union {
struct {
- long offset;
- long count;
+ zend_long offset;
+ zend_long count;
} limit;
struct {
- long flags; /* CIT_* */
+ zend_long flags; /* CIT_* */
zval zstr;
zval zchildren;
zval zcache;
@@ -155,9 +155,9 @@ typedef struct _spl_dual_it_object {
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
struct {
int use_flags;
- long flags;
+ zend_long flags;
regex_mode mode;
- long preg_flags;
+ zend_long preg_flags;
pcre_cache_entry *pce;
zend_string *regex;
} regex;
diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c
index bdfff35506..afc184f71b 100644
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -81,9 +81,9 @@ PHPAPI zend_object_handlers spl_handler_SplObjectStorage;
typedef struct _spl_SplObjectStorage { /* {{{ */
HashTable storage;
- long index;
+ zend_long index;
HashPosition pos;
- long flags;
+ zend_long flags;
zend_function *fptr_get_hash;
HashTable *debug_info;
zend_object std;
@@ -133,7 +133,7 @@ static zend_string *spl_object_storage_get_hash(spl_SplObjectStorage *intern, zv
return NULL;
}
} else {
- zend_string *hash = STR_ALLOC(sizeof(zend_object*), 0);
+ zend_string *hash = zend_string_alloc(sizeof(zend_object*), 0);
memcpy(hash->val, (void*)&Z_OBJ_P(obj), sizeof(zend_object*));
hash->val[hash->len] = '\0';
return hash;
@@ -170,7 +170,7 @@ static zend_string *spl_object_storage_get_hash(spl_SplObjectStorage *intern, zv
}
static void spl_object_storage_free_hash(spl_SplObjectStorage *intern, zend_string *hash) {
- STR_RELEASE(hash);
+ zend_string_release(hash);
/*
if (intern->fptr_get_hash) {
} else {
@@ -311,7 +311,7 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp TSRMLS_D
spl_SplObjectStorageElement *element;
HashTable *props;
zval tmp, storage;
- char md5str[33];
+ zend_string *md5str;
zend_string *zname;
*is_temp = 0;
@@ -330,19 +330,20 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp TSRMLS_D
array_init(&storage);
ZEND_HASH_FOREACH_PTR(&intern->storage, element) {
- php_spl_object_hash(&element->obj, md5str TSRMLS_CC);
+ md5str = php_spl_object_hash(&element->obj TSRMLS_CC);
array_init(&tmp);
/* Incrementing the refcount of obj and inf would confuse the garbage collector.
* Prefer to null the destructor */
Z_ARRVAL_P(&tmp)->pDestructor = NULL;
add_assoc_zval_ex(&tmp, "obj", sizeof("obj") - 1, &element->obj);
add_assoc_zval_ex(&tmp, "inf", sizeof("inf") - 1, &element->inf);
- add_assoc_zval_ex(&storage, md5str, 32, &tmp);
+ zend_hash_update(Z_ARRVAL(storage), md5str, &tmp);
+ zend_string_release(md5str);
} ZEND_HASH_FOREACH_END();
zname = spl_gen_private_prop_name(spl_ce_SplObjectStorage, "storage", sizeof("storage")-1 TSRMLS_CC);
zend_symtable_update(intern->debug_info, zname, &storage);
- STR_RELEASE(zname);
+ zend_string_release(zname);
}
return intern->debug_info;
@@ -469,16 +470,12 @@ SPL_METHOD(SplObjectStorage, detach)
SPL_METHOD(SplObjectStorage, getHash)
{
zval *obj;
- char *hash;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
-
- hash = emalloc(33);
- php_spl_object_hash(obj, hash TSRMLS_CC);
- RETVAL_STRING(hash);
+ RETURN_NEW_STR(php_spl_object_hash(obj TSRMLS_CC));
} /* }}} */
@@ -603,14 +600,14 @@ SPL_METHOD(SplObjectStorage, contains)
SPL_METHOD(SplObjectStorage, count)
{
spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
- long mode = COUNT_NORMAL;
+ zend_long mode = COUNT_NORMAL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &mode) == FAILURE) {
return;
}
if (mode == COUNT_RECURSIVE) {
- long ret = zend_hash_num_elements(&intern->storage);
+ zend_long ret = zend_hash_num_elements(&intern->storage);
zval *element;
ZEND_HASH_FOREACH_VAL(&intern->storage, element) {
@@ -800,7 +797,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
php_unserialize_data_t var_hash;
zval entry, pmembers, pcount, inf;
spl_SplObjectStorageElement *element;
- long count;
+ zend_long count;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &buf_len) == FAILURE) {
return;
@@ -909,7 +906,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
outexcept:
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Error at offset %ld of %d bytes", (long)((char*)p - buf), buf_len);
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Error at offset %pd of %d bytes", (zend_long)((char*)p - buf), buf_len);
return;
} /* }}} */
@@ -986,7 +983,7 @@ typedef enum {
SPL_METHOD(MultipleIterator, __construct)
{
spl_SplObjectStorage *intern;
- long flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC;
+ zend_long flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC;
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
@@ -1118,7 +1115,7 @@ SPL_METHOD(MultipleIterator, valid)
spl_SplObjectStorage *intern;
spl_SplObjectStorageElement *element;
zval *it, retval;
- long expect, valid;
+ zend_long expect, valid;
intern = Z_SPLOBJSTORAGE_P(getThis());
diff --git a/ext/sqlite3/php_sqlite3_structs.h b/ext/sqlite3/php_sqlite3_structs.h
index e988ac20d0..5a291a9a50 100644
--- a/ext/sqlite3/php_sqlite3_structs.h
+++ b/ext/sqlite3/php_sqlite3_structs.h
@@ -38,9 +38,9 @@
/* Structure for SQLite Statement Parameter. */
struct php_sqlite3_bound_param {
- long param_number;
+ zend_long param_number;
zend_string *name;
- long type;
+ zend_long type;
zval parameter;
};
@@ -91,7 +91,7 @@ static inline php_sqlite3_db_object *php_sqlite3_db_from_obj(zend_object *obj) {
/* Structure for SQLite Database object. */
typedef struct _php_sqlite3_agg_context {
zval zval_context;
- long row_count;
+ zend_long row_count;
} php_sqlite3_agg_context;
typedef struct _php_sqlite3_stmt_object php_sqlite3_stmt;
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 54c80972c9..129997e799 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -103,7 +103,7 @@ PHP_METHOD(sqlite3, open)
zval *object = getThis();
char *filename, *encryption_key, *fullpath;
int filename_len, encryption_key_len = 0;
- long flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
+ zend_long flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
zend_error_handling error_handling;
db_obj = Z_SQLITE3_DB_P(object);
@@ -218,17 +218,17 @@ PHP_METHOD(sqlite3, exec)
{
php_sqlite3_db_object *db_obj;
zval *object = getThis();
- char *sql, *errtext = NULL;
- int sql_len;
+ zend_string *sql;
+ char *errtext = NULL;
db_obj = Z_SQLITE3_DB_P(object);
SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &sql, &sql_len)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &sql)) {
return;
}
- if (sqlite3_exec(db_obj->db, sql, NULL, NULL, &errtext) != SQLITE_OK) {
+ if (sqlite3_exec(db_obj->db, sql->val, NULL, NULL, &errtext) != SQLITE_OK) {
php_sqlite3_error(db_obj, "%s", errtext);
sqlite3_free(errtext);
RETURN_FALSE;
@@ -315,7 +315,7 @@ PHP_METHOD(sqlite3, busyTimeout)
{
php_sqlite3_db_object *db_obj;
zval *object = getThis();
- long ms;
+ zend_long ms;
int return_code;
db_obj = Z_SQLITE3_DB_P(object);
@@ -432,15 +432,15 @@ PHP_METHOD(sqlite3, changes)
Returns a string that has been properly escaped. */
PHP_METHOD(sqlite3, escapeString)
{
- char *sql, *ret;
- int sql_len;
+ zend_string *sql;
+ char *ret;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &sql, &sql_len)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &sql)) {
return;
}
- if (sql_len) {
- ret = sqlite3_mprintf("%q", sql);
+ if (sql->len) {
+ ret = sqlite3_mprintf("%q", sql->val);
if (ret) {
RETVAL_STRING(ret);
sqlite3_free(ret);
@@ -458,19 +458,19 @@ PHP_METHOD(sqlite3, prepare)
php_sqlite3_db_object *db_obj;
php_sqlite3_stmt *stmt_obj;
zval *object = getThis();
- char *sql;
- int sql_len, errcode;
+ zend_string *sql;
+ int errcode;
php_sqlite3_free_list *free_item;
db_obj = Z_SQLITE3_DB_P(object);
SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &sql, &sql_len)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &sql)) {
return;
}
- if (!sql_len) {
+ if (!sql->len) {
RETURN_FALSE;
}
@@ -479,7 +479,7 @@ PHP_METHOD(sqlite3, prepare)
stmt_obj->db_obj = db_obj;
ZVAL_COPY(&stmt_obj->db_obj_zval, object);
- errcode = sqlite3_prepare_v2(db_obj->db, sql, sql_len, &(stmt_obj->stmt), NULL);
+ errcode = sqlite3_prepare_v2(db_obj->db, sql->val, sql->len, &(stmt_obj->stmt), NULL);
if (errcode != SQLITE_OK) {
php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", errcode, sqlite3_errmsg(db_obj->db));
zval_dtor(return_value);
@@ -505,23 +505,24 @@ PHP_METHOD(sqlite3, query)
php_sqlite3_stmt *stmt_obj;
zval *object = getThis();
zval stmt;
- char *sql, *errtext = NULL;
- int sql_len, return_code;
+ zend_string *sql;
+ char *errtext = NULL;
+ int return_code;
db_obj = Z_SQLITE3_DB_P(object);
SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &sql, &sql_len)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &sql)) {
return;
}
- if (!sql_len) {
+ if (!sql->len) {
RETURN_FALSE;
}
/* If there was no return value then just execute the query */
if (!USED_RET()) {
- if (sqlite3_exec(db_obj->db, sql, NULL, NULL, &errtext) != SQLITE_OK) {
+ if (sqlite3_exec(db_obj->db, sql->val, NULL, NULL, &errtext) != SQLITE_OK) {
php_sqlite3_error(db_obj, "%s", errtext);
sqlite3_free(errtext);
}
@@ -533,7 +534,7 @@ PHP_METHOD(sqlite3, query)
stmt_obj->db_obj = db_obj;
ZVAL_COPY(&stmt_obj->db_obj_zval, object);
- return_code = sqlite3_prepare_v2(db_obj->db, sql, sql_len, &(stmt_obj->stmt), NULL);
+ return_code = sqlite3_prepare_v2(db_obj->db, sql->val, sql->len, &(stmt_obj->stmt), NULL);
if (return_code != SQLITE_OK) {
php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", return_code, sqlite3_errmsg(db_obj->db));
zval_ptr_dtor(&stmt);
@@ -608,32 +609,33 @@ PHP_METHOD(sqlite3, querySingle)
{
php_sqlite3_db_object *db_obj;
zval *object = getThis();
- char *sql, *errtext = NULL;
- int sql_len, return_code;
+ zend_string *sql;
+ char *errtext = NULL;
+ int return_code;
zend_bool entire_row = 0;
sqlite3_stmt *stmt;
db_obj = Z_SQLITE3_DB_P(object);
SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &sql, &sql_len, &entire_row)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &sql, &entire_row)) {
return;
}
- if (!sql_len) {
+ if (!sql->len) {
RETURN_FALSE;
}
/* If there was no return value then just execute the query */
if (!USED_RET()) {
- if (sqlite3_exec(db_obj->db, sql, NULL, NULL, &errtext) != SQLITE_OK) {
+ if (sqlite3_exec(db_obj->db, sql->val, NULL, NULL, &errtext) != SQLITE_OK) {
php_sqlite3_error(db_obj, "%s", errtext);
sqlite3_free(errtext);
}
return;
}
- return_code = sqlite3_prepare_v2(db_obj->db, sql, sql_len, &stmt, NULL);
+ return_code = sqlite3_prepare_v2(db_obj->db, sql->val, sql->len, &stmt, NULL);
if (return_code != SQLITE_OK) {
php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", return_code, sqlite3_errmsg(db_obj->db));
RETURN_FALSE;
@@ -717,7 +719,7 @@ static int sqlite3_do_callback(struct php_sqlite3_fci *fc, zval *cb, int argc, s
for (i = 0; i < argc; i++) {
switch (sqlite3_value_type(argv[i])) {
case SQLITE_INTEGER:
-#if LONG_MAX > 2147483647
+#if ZEND_LONG_MAX > 2147483647
ZVAL_LONG(&zargs[i + is_agg], sqlite3_value_int64(argv[i]));
#else
ZVAL_LONG(&zargs[i + is_agg], sqlite3_value_int(argv[i]));
@@ -763,7 +765,7 @@ static int sqlite3_do_callback(struct php_sqlite3_fci *fc, zval *cb, int argc, s
if (!Z_ISUNDEF(retval)) {
switch (Z_TYPE(retval)) {
case IS_LONG:
-#if LONG_MAX > 2147483647
+#if ZEND_LONG_MAX > 2147483647
sqlite3_result_int64(context, Z_LVAL(retval));
#else
sqlite3_result_int(context, Z_LVAL(retval));
@@ -897,7 +899,7 @@ PHP_METHOD(sqlite3, createFunction)
int sql_func_len;
zval *callback_func;
zend_string *callback_name;
- long sql_func_num_args = -1;
+ zend_long sql_func_num_args = -1;
db_obj = Z_SQLITE3_DB_P(object);
SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
@@ -912,10 +914,10 @@ PHP_METHOD(sqlite3, createFunction)
if (!zend_is_callable(callback_func, 0, &callback_name TSRMLS_CC)) {
php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val);
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
RETURN_FALSE;
}
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
func = (php_sqlite3_func *)ecalloc(1, sizeof(*func));
@@ -947,7 +949,7 @@ PHP_METHOD(sqlite3, createAggregate)
zend_string *callback_name;
int sql_func_len;
zval *step_callback, *fini_callback;
- long sql_func_num_args = -1;
+ zend_long sql_func_num_args = -1;
db_obj = Z_SQLITE3_DB_P(object);
SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
@@ -962,17 +964,17 @@ PHP_METHOD(sqlite3, createAggregate)
if (!zend_is_callable(step_callback, 0, &callback_name TSRMLS_CC)) {
php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val);
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
RETURN_FALSE;
}
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
if (!zend_is_callable(fini_callback, 0, &callback_name TSRMLS_CC)) {
php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val);
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
RETURN_FALSE;
}
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
func = (php_sqlite3_func *)ecalloc(1, sizeof(*func));
@@ -1019,10 +1021,10 @@ PHP_METHOD(sqlite3, createCollation)
if (!zend_is_callable(callback_func, 0, &callback_name TSRMLS_CC)) {
php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val);
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
RETURN_FALSE;
}
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
collation = (php_sqlite3_collation *)ecalloc(1, sizeof(*collation));
if (sqlite3_create_collation(db_obj->db, collation_name, SQLITE_UTF8, collation, php_sqlite3_callback_compare) == SQLITE_OK) {
@@ -1091,7 +1093,7 @@ static int php_sqlite3_stream_flush(php_stream *stream TSRMLS_DC)
}
/* {{{ */
-static int php_sqlite3_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
+static int php_sqlite3_stream_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC)
{
php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream->abstract;
@@ -1185,7 +1187,7 @@ PHP_METHOD(sqlite3, openBlob)
zval *object = getThis();
char *table, *column, *dbname = "main";
int table_len, column_len, dbname_len;
- long rowid, flags = 0;
+ zend_long rowid, flags = 0;
sqlite3_blob *blob = NULL;
php_stream_sqlite3_data *sqlite3_stream;
php_stream *stream;
@@ -1359,19 +1361,19 @@ static int register_bound_parameter_to_sqlite(struct php_sqlite3_bound_param *pa
if (param->name) {
if (param->name->val[0] != ':') {
/* pre-increment for character + 1 for null */
- zend_string *temp = STR_ALLOC(param->name->len + 1, 0);
+ zend_string *temp = zend_string_alloc(param->name->len + 1, 0);
temp->val[0] = ':';
memmove(temp->val + 1, param->name->val, param->name->len + 1);
param->name = temp;
} else {
- param->name = STR_INIT(param->name->val, param->name->len, 0);
+ param->name = zend_string_init(param->name->val, param->name->len, 0);
}
/* do lookup*/
param->param_number = sqlite3_bind_parameter_index(stmt->stmt, param->name->val);
}
if (param->param_number < 1) {
- STR_RELEASE(param->name);
+ zend_string_release(param->name);
return 0;
}
@@ -1396,8 +1398,8 @@ PHP_METHOD(sqlite3stmt, bindParam)
php_sqlite3_stmt *stmt_obj;
zval *object = getThis();
struct php_sqlite3_bound_param param = {0};
- stmt_obj = Z_SQLITE3_STMT_P(object);
zval *parameter;
+ stmt_obj = Z_SQLITE3_STMT_P(object);
param.param_number = -1;
param.type = SQLITE3_TEXT;
@@ -1430,8 +1432,8 @@ PHP_METHOD(sqlite3stmt, bindValue)
php_sqlite3_stmt *stmt_obj;
zval *object = getThis();
struct php_sqlite3_bound_param param = {0};
- stmt_obj = Z_SQLITE3_STMT_P(object);
zval *parameter;
+ stmt_obj = Z_SQLITE3_STMT_P(object);
param.param_number = -1;
param.type = SQLITE3_TEXT;
@@ -1493,8 +1495,8 @@ PHP_METHOD(sqlite3stmt, execute)
switch (param->type) {
case SQLITE_INTEGER:
- convert_to_long(parameter);
-#if LONG_MAX > 2147483647
+ convert_to_int(parameter);
+#if ZEND_LONG_MAX > 2147483647
sqlite3_bind_int64(stmt_obj->stmt, param->param_number, Z_LVAL_P(parameter));
#else
sqlite3_bind_int(stmt_obj->stmt, param->param_number, Z_LVAL_P(parameter));
@@ -1525,7 +1527,7 @@ PHP_METHOD(sqlite3stmt, execute)
sqlite3_bind_blob(stmt_obj->stmt, param->param_number, buffer->val, buffer->len, SQLITE_TRANSIENT);
if (stream) {
- STR_RELEASE(buffer);
+ zend_string_release(buffer);
}
break;
}
@@ -1540,7 +1542,7 @@ PHP_METHOD(sqlite3stmt, execute)
break;
default:
- php_sqlite3_error(stmt_obj->db_obj, "Unknown parameter type: %ld for parameter %ld", param->type, param->param_number);
+ php_sqlite3_error(stmt_obj->db_obj, "Unknown parameter type: %pd for parameter %pd", param->type, param->param_number);
RETURN_FALSE;
}
} ZEND_HASH_FOREACH_END();
@@ -1584,15 +1586,15 @@ PHP_METHOD(sqlite3stmt, __construct)
php_sqlite3_db_object *db_obj;
zval *object = getThis();
zval *db_zval;
- char *sql;
- int sql_len, errcode;
+ zend_string *sql;
+ int errcode;
zend_error_handling error_handling;
php_sqlite3_free_list *free_item;
stmt_obj = Z_SQLITE3_STMT_P(object);
zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &db_zval, php_sqlite3_sc_entry, &sql, &sql_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OS", &db_zval, php_sqlite3_sc_entry, &sql) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
@@ -1603,14 +1605,14 @@ PHP_METHOD(sqlite3stmt, __construct)
zend_restore_error_handling(&error_handling TSRMLS_CC);
- if (!sql_len) {
+ if (!sql->len) {
RETURN_FALSE;
}
stmt_obj->db_obj = db_obj;
ZVAL_COPY(&stmt_obj->db_obj_zval, db_zval);
- errcode = sqlite3_prepare_v2(db_obj->db, sql, sql_len, &(stmt_obj->stmt), NULL);
+ errcode = sqlite3_prepare_v2(db_obj->db, sql->val, sql->len, &(stmt_obj->stmt), NULL);
if (errcode != SQLITE_OK) {
php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", errcode, sqlite3_errmsg(db_obj->db));
zval_dtor(return_value);
@@ -1651,7 +1653,7 @@ PHP_METHOD(sqlite3result, columnName)
{
php_sqlite3_result *result_obj;
zval *object = getThis();
- long column = 0;
+ zend_long column = 0;
char *column_name;
result_obj = Z_SQLITE3_RESULT_P(object);
@@ -1676,7 +1678,7 @@ PHP_METHOD(sqlite3result, columnType)
{
php_sqlite3_result *result_obj;
zval *object = getThis();
- long column = 0;
+ zend_long column = 0;
result_obj = Z_SQLITE3_RESULT_P(object);
SQLITE3_CHECK_INITIALIZED(result_obj->db_obj, result_obj->stmt_obj->initialised, SQLite3Result)
@@ -1700,7 +1702,7 @@ PHP_METHOD(sqlite3result, fetchArray)
php_sqlite3_result *result_obj;
zval *object = getThis();
int i, ret;
- long mode = PHP_SQLITE3_BOTH;
+ zend_long mode = PHP_SQLITE3_BOTH;
result_obj = Z_SQLITE3_RESULT_P(object);
SQLITE3_CHECK_INITIALIZED(result_obj->db_obj, result_obj->stmt_obj->initialised, SQLite3Result)
@@ -2168,7 +2170,7 @@ static void sqlite3_param_dtor(zval *data) /* {{{ */
struct php_sqlite3_bound_param *param = (struct php_sqlite3_bound_param*)Z_PTR_P(data);
if (param->name) {
- STR_RELEASE(param->name);
+ zend_string_release(param->name);
}
if (!Z_ISNULL(param->parameter)) {
diff --git a/ext/standard/array.c b/ext/standard/array.c
index a177ee7e0f..2663b404ac 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -141,7 +141,7 @@ PHP_MSHUTDOWN_FUNCTION(array) /* {{{ */
}
/* }}} */
-static void php_set_compare_func(int sort_type TSRMLS_DC) /* {{{ */
+static void php_set_compare_func(zend_long sort_type TSRMLS_DC) /* {{{ */
{
switch (sort_type & ~PHP_SORT_FLAG_CASE) {
case PHP_SORT_NUMERIC:
@@ -218,7 +218,7 @@ static int php_array_reverse_key_compare(const void *a, const void *b TSRMLS_DC)
PHP_FUNCTION(krsort)
{
zval *array;
- long sort_type = PHP_SORT_REGULAR;
+ zend_long sort_type = PHP_SORT_REGULAR;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
@@ -238,7 +238,7 @@ PHP_FUNCTION(krsort)
PHP_FUNCTION(ksort)
{
zval *array;
- long sort_type = PHP_SORT_REGULAR;
+ zend_long sort_type = PHP_SORT_REGULAR;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
@@ -253,9 +253,9 @@ PHP_FUNCTION(ksort)
}
/* }}} */
-PHPAPI int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */
+PHPAPI zend_long php_count_recursive(zval *array, zend_long mode TSRMLS_DC) /* {{{ */
{
- long cnt = 0;
+ zend_long cnt = 0;
zval *element;
if (Z_TYPE_P(array) == IS_ARRAY) {
@@ -288,8 +288,8 @@ PHPAPI int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */
PHP_FUNCTION(count)
{
zval *array;
- long mode = COUNT_NORMAL;
- long cnt;
+ zend_long mode = COUNT_NORMAL;
+ zend_long cnt;
zval *element;
#ifndef FAST_ZPP
@@ -403,8 +403,8 @@ static int php_array_natural_general_compare(const void *a, const void *b, int f
int result = strnatcmp_ex(str1->val, str1->len, str2->val, str2->len, fold_case);
- STR_RELEASE(str1);
- STR_RELEASE(str2);
+ zend_string_release(str1);
+ zend_string_release(str2);
return result;
}
/* }}} */
@@ -464,7 +464,7 @@ PHP_FUNCTION(natcasesort)
PHP_FUNCTION(asort)
{
zval *array;
- long sort_type = PHP_SORT_REGULAR;
+ zend_long sort_type = PHP_SORT_REGULAR;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
@@ -484,7 +484,7 @@ PHP_FUNCTION(asort)
PHP_FUNCTION(arsort)
{
zval *array;
- long sort_type = PHP_SORT_REGULAR;
+ zend_long sort_type = PHP_SORT_REGULAR;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
@@ -504,7 +504,7 @@ PHP_FUNCTION(arsort)
PHP_FUNCTION(sort)
{
zval *array;
- long sort_type = PHP_SORT_REGULAR;
+ zend_long sort_type = PHP_SORT_REGULAR;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
@@ -524,7 +524,7 @@ PHP_FUNCTION(sort)
PHP_FUNCTION(rsort)
{
zval *array;
- long sort_type = PHP_SORT_REGULAR;
+ zend_long sort_type = PHP_SORT_REGULAR;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
@@ -557,7 +557,7 @@ static int php_array_user_compare(const void *a, const void *b TSRMLS_DC) /* {{{
BG(user_compare_fci).retval = &retval;
BG(user_compare_fci).no_separation = 0;
if (zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache) TSRMLS_CC) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
- long ret = zval_get_long(&retval);
+ zend_long ret = zval_get_long(&retval);
zval_ptr_dtor(&retval);
zval_ptr_dtor(&args[1]);
zval_ptr_dtor(&args[0]);
@@ -695,7 +695,7 @@ static int php_array_user_key_compare(const void *a, const void *b TSRMLS_DC) /*
Bucket *s;
zval args[2];
zval retval;
- long result;
+ zend_long result;
ZVAL_NULL(&args[0]);
ZVAL_NULL(&args[1]);
@@ -706,12 +706,12 @@ static int php_array_user_key_compare(const void *a, const void *b TSRMLS_DC) /*
if (f->key == NULL) {
ZVAL_LONG(&args[0], f->h);
} else {
- ZVAL_STR(&args[0], STR_COPY(f->key));
+ ZVAL_STR(&args[0], zend_string_copy(f->key));
}
if (s->key == NULL) {
ZVAL_LONG(&args[1], s->h);
} else {
- ZVAL_STR(&args[1], STR_COPY(s->key));
+ ZVAL_STR(&args[1], zend_string_copy(s->key));
}
BG(user_compare_fci).param_count = 2;
@@ -1230,7 +1230,7 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{
*array, /* array to check in */
*entry, /* pointer to array entry */
res; /* comparison result */
- ulong num_idx;
+ zend_ulong num_idx;
zend_string *str_idx;
zend_bool strict = 0; /* strict comparison or not */
@@ -1256,7 +1256,7 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{
RETURN_TRUE;
} else {
if (str_idx) {
- RETVAL_STR(STR_COPY(str_idx));
+ RETVAL_STR(zend_string_copy(str_idx));
} else {
RETVAL_LONG(num_idx);
}
@@ -1271,7 +1271,7 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{
RETURN_TRUE;
} else {
if (str_idx) {
- RETVAL_STR(STR_COPY(str_idx));
+ RETVAL_STR(zend_string_copy(str_idx));
} else {
RETVAL_LONG(num_idx);
}
@@ -1339,7 +1339,7 @@ static int php_valid_var_name(char *var_name, int var_name_len) /* {{{ */
PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, int var_name_len, zend_bool add_underscore TSRMLS_DC) /* {{{ */
{
- ZVAL_NEW_STR(result, STR_ALLOC(Z_STRLEN_P(prefix) + (add_underscore ? 1 : 0) + var_name_len, 0));
+ ZVAL_NEW_STR(result, zend_string_alloc(Z_STRLEN_P(prefix) + (add_underscore ? 1 : 0) + var_name_len, 0));
memcpy(Z_STRVAL_P(result), Z_STRVAL_P(prefix), Z_STRLEN_P(prefix));
if (add_underscore) {
@@ -1357,10 +1357,10 @@ PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, int va
PHP_FUNCTION(extract)
{
zval *var_array, *prefix = NULL;
- long extract_type = EXTR_OVERWRITE;
+ zend_long extract_type = EXTR_OVERWRITE;
zval *entry;
zend_string *var_name;
- ulong num_key;
+ zend_ulong num_key;
int var_exists, count = 0;
int extract_refs = 0;
zend_array *symbol_table;
@@ -1424,7 +1424,7 @@ PHP_FUNCTION(extract)
if (var_exists && var_name->len == sizeof("this")-1 && !strcmp(var_name->val, "this") && EG(scope) && EG(scope)->name->len != 0) {
break;
}
- ZVAL_STR(&final_name, STR_COPY(var_name));
+ ZVAL_STR(&final_name, zend_string_copy(var_name));
break;
case EXTR_PREFIX_IF_EXISTS:
@@ -1435,7 +1435,7 @@ PHP_FUNCTION(extract)
case EXTR_PREFIX_SAME:
if (!var_exists && var_name->len != 0) {
- ZVAL_STR(&final_name, STR_COPY(var_name));
+ ZVAL_STR(&final_name, zend_string_copy(var_name));
}
/* break omitted intentionally */
@@ -1450,14 +1450,14 @@ PHP_FUNCTION(extract)
if (!php_valid_var_name(var_name->val, var_name->len)) {
php_prefix_varname(&final_name, prefix, var_name->val, var_name->len, 1 TSRMLS_CC);
} else {
- ZVAL_STR(&final_name, STR_COPY(var_name));
+ ZVAL_STR(&final_name, zend_string_copy(var_name));
}
}
break;
default:
if (!var_exists) {
- ZVAL_STR(&final_name, STR_COPY(var_name));
+ ZVAL_STR(&final_name, zend_string_copy(var_name));
}
break;
}
@@ -1554,7 +1554,7 @@ PHP_FUNCTION(compact)
PHP_FUNCTION(array_fill)
{
zval *val;
- long start_key, num;
+ zend_long start_key, num;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llz", &start_key, &num, &val) == FAILURE) {
return;
@@ -1612,7 +1612,7 @@ PHP_FUNCTION(array_fill_keys)
zval_add_ref(val);
zend_symtable_update(Z_ARRVAL_P(return_value), key, val);
- STR_RELEASE(key);
+ zend_string_release(key);
}
} ZEND_HASH_FOREACH_END();
}
@@ -1652,7 +1652,7 @@ PHP_FUNCTION(range)
if (Z_TYPE_P(zlow) == IS_STRING && Z_TYPE_P(zhigh) == IS_STRING && Z_STRLEN_P(zlow) >= 1 && Z_STRLEN_P(zhigh) >= 1) {
int type1, type2;
unsigned char low, high;
- long lstep = (long) step;
+ zend_long lstep = (zend_long) step;
type1 = is_numeric_string(Z_STRVAL_P(zlow), Z_STRLEN_P(zlow), NULL, NULL, 0);
type2 = is_numeric_string(Z_STRVAL_P(zhigh), Z_STRLEN_P(zhigh), NULL, NULL, 0);
@@ -1673,7 +1673,7 @@ PHP_FUNCTION(range)
}
for (; low >= high; low -= (unsigned int)lstep) {
if (CG(one_char_string)[low]) {
- ZVAL_INT_STR(&tmp, CG(one_char_string)[low]);
+ ZVAL_INTERNED_STR(&tmp, CG(one_char_string)[low]);
} else {
ZVAL_STRINGL(&tmp, (char*)&low, 1);
}
@@ -1689,7 +1689,7 @@ PHP_FUNCTION(range)
}
for (; low <= high; low += (unsigned int)lstep) {
if (CG(one_char_string)[low]) {
- ZVAL_INT_STR(&tmp, CG(one_char_string)[low]);
+ ZVAL_INTERNED_STR(&tmp, CG(one_char_string)[low]);
} else {
ZVAL_STRINGL(&tmp, (char*)&low, 1);
}
@@ -1700,7 +1700,7 @@ PHP_FUNCTION(range)
}
} else {
if (CG(one_char_string)[low]) {
- ZVAL_INT_STR(&tmp, CG(one_char_string)[low]);
+ ZVAL_INTERNED_STR(&tmp, CG(one_char_string)[low]);
} else {
ZVAL_STRINGL(&tmp, (char*)&low, 1);
}
@@ -1709,7 +1709,7 @@ PHP_FUNCTION(range)
} else if (Z_TYPE_P(zlow) == IS_DOUBLE || Z_TYPE_P(zhigh) == IS_DOUBLE || is_step_double) {
double low, high, value;
- long i;
+ zend_long i;
double_str:
low = zval_get_double(zlow);
high = zval_get_double(zhigh);
@@ -1742,11 +1742,11 @@ double_str:
}
} else {
double low, high;
- long lstep;
+ zend_long lstep;
long_str:
low = zval_get_double(zlow);
high = zval_get_double(zhigh);
- lstep = (long) step;
+ lstep = (zend_long) step;
Z_TYPE_INFO(tmp) = IS_LONG;
if (low > high) { /* Negative steps */
@@ -1755,7 +1755,7 @@ long_str:
goto err;
}
for (; low >= high; low -= lstep) {
- Z_LVAL(tmp) = (long)low;
+ Z_LVAL(tmp) = (zend_long)low;
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
}
} else if (high > low) { /* Positive steps */
@@ -1764,11 +1764,11 @@ long_str:
goto err;
}
for (; low <= high; low += lstep) {
- Z_LVAL(tmp) = (long)low;
+ Z_LVAL(tmp) = (zend_long)low;
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
}
} else {
- Z_LVAL(tmp) = (long)low;
+ Z_LVAL(tmp) = (zend_long)low;
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
}
}
@@ -1824,7 +1824,7 @@ static void php_array_data_shuffle(zval *array TSRMLS_DC) /* {{{ */
for (j = 0; j < n_elems; j++) {
p = hash->arData + j;
if (p->key && !IS_INTERNED(p->key)) {
- STR_RELEASE(p->key);
+ zend_string_release(p->key);
}
p->h = j;
p->key = NULL;
@@ -1995,7 +1995,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
zval *stack, /* Input stack */
*val; /* Value to be popped */
zend_string *key = NULL;
- ulong index;
+ zend_ulong index;
#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &stack) == FAILURE) {
@@ -2145,7 +2145,7 @@ PHP_FUNCTION(array_splice)
HashTable old_hash;
uint idx;
Bucket *p; /* Bucket used for traversing hash */
- long i,
+ zend_long i,
offset,
length = 0,
repl_num = 0; /* Number of replacement elements */
@@ -2190,7 +2190,7 @@ PHP_FUNCTION(array_splice)
/* ..and the length */
if (length < 0) {
size = num_in - offset + length;
- } else if (((unsigned long) offset + (unsigned long) length) > (unsigned) num_in) {
+ } else if (((zend_ulong) offset + (zend_ulong) length) > (unsigned) num_in) {
size = num_in - offset;
}
@@ -2222,13 +2222,13 @@ PHP_FUNCTION(array_slice)
zval *input, /* Input array */
*z_length = NULL, /* How many elements to get */
*entry; /* An array entry */
- long offset, /* Offset to get elements from */
+ zend_long offset, /* Offset to get elements from */
length = 0;
zend_bool preserve_keys = 0; /* Whether to preserve keys while copying to the new array or not */
int num_in, /* Number of elements in the input array */
pos; /* Current position in the array */
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|zb", &input, &offset, &z_length, &preserve_keys) == FAILURE) {
@@ -2265,7 +2265,7 @@ PHP_FUNCTION(array_slice)
/* ..and the length */
if (length < 0) {
length = num_in - offset + length;
- } else if (((unsigned long) offset + (unsigned long) length) > (unsigned) num_in) {
+ } else if (((zend_ulong) offset + (zend_ulong) length) > (unsigned) num_in) {
length = num_in - offset;
}
@@ -2404,7 +2404,7 @@ PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src TSRMLS_DC
{
zval *src_entry, *dest_entry, *src_zval, *dest_zval;
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
int ret;
ZEND_HASH_FOREACH_KEY_VAL(src, num_key, string_key, src_entry) {
@@ -2564,7 +2564,7 @@ PHP_FUNCTION(array_keys)
new_val; /* New value */
int add_key; /* Flag to indicate whether a key should be added */
zend_bool strict = 0; /* do strict comparison */
- ulong num_idx;
+ zend_ulong num_idx;
zend_string *str_idx;
int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) = is_equal_function;
@@ -2602,7 +2602,7 @@ PHP_FUNCTION(array_keys)
if (add_key) {
if (str_idx) {
- ZVAL_STR(&new_val, STR_COPY(str_idx));
+ ZVAL_STR(&new_val, zend_string_copy(str_idx));
} else {
ZVAL_LONG(&new_val, num_idx);
}
@@ -2684,7 +2684,7 @@ zend_bool array_column_param_helper(zval *param,
const char *name TSRMLS_DC) {
switch (Z_TYPE_P(param)) {
case IS_DOUBLE:
- convert_to_long_ex(param);
+ convert_to_int_ex(param);
/* fallthrough */
case IS_LONG:
return 1;
@@ -2775,7 +2775,7 @@ PHP_FUNCTION(array_reverse)
zval *input, /* Input array */
*entry; /* An entry in the input array */
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
zend_bool preserve_keys = 0; /* whether to preserve keys */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|b", &input, &preserve_keys) == FAILURE) {
@@ -2810,10 +2810,10 @@ PHP_FUNCTION(array_pad)
zval *pads; /* Array to pass to splice */
HashTable *new_hash;/* Return value from splice */
HashTable old_hash;
- long pad_size; /* Size to pad to */
- long pad_size_abs; /* Absolute value of pad_size */
- int input_size; /* Size of the input array */
- int num_pads; /* How many pads do we need */
+ zend_long pad_size; /* Size to pad to */
+ zend_long pad_size_abs; /* Absolute value of pad_size */
+ zend_long input_size; /* Size of the input array */
+ zend_long num_pads; /* How many pads do we need */
int do_pad; /* Whether we should do padding at all */
int i;
@@ -2823,7 +2823,7 @@ PHP_FUNCTION(array_pad)
/* Do some initial calculations */
input_size = zend_hash_num_elements(Z_ARRVAL_P(input));
- pad_size_abs = abs(pad_size);
+ pad_size_abs = ZEND_ABS(pad_size);
if (pad_size_abs < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "You may only pad up to 1048576 elements at a time");
zval_dtor(return_value);
@@ -2841,7 +2841,7 @@ PHP_FUNCTION(array_pad)
/* Populate the pads array */
num_pads = pad_size_abs - input_size;
- if (num_pads > 1048576) {
+ if (num_pads > Z_I(1048576)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "You may only pad up to 1048576 elements at a time");
zval_dtor(return_value);
RETURN_FALSE;
@@ -2874,7 +2874,7 @@ PHP_FUNCTION(array_pad)
PHP_FUNCTION(array_flip)
{
zval *array, *entry, data;
- ulong num_idx;
+ zend_ulong num_idx;
zend_string *str_idx;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
@@ -2886,14 +2886,14 @@ PHP_FUNCTION(array_flip)
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
if (Z_TYPE_P(entry) == IS_LONG) {
if (str_idx) {
- ZVAL_STR(&data, STR_COPY(str_idx));
+ ZVAL_STR(&data, zend_string_copy(str_idx));
} else {
ZVAL_LONG(&data, num_idx);
}
zend_hash_index_update(Z_ARRVAL_P(return_value), Z_LVAL_P(entry), &data);
} else if (Z_TYPE_P(entry) == IS_STRING) {
if (str_idx) {
- ZVAL_STR(&data, STR_COPY(str_idx));
+ ZVAL_STR(&data, zend_string_copy(str_idx));
} else {
ZVAL_LONG(&data, num_idx);
}
@@ -2912,8 +2912,8 @@ PHP_FUNCTION(array_change_key_case)
zval *array, *entry;
zend_string *string_key;
zend_string *new_key;
- ulong num_key;
- long change_to_upper=0;
+ zend_ulong num_key;
+ zend_long change_to_upper=0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &change_to_upper) == FAILURE) {
return;
@@ -2927,14 +2927,14 @@ PHP_FUNCTION(array_change_key_case)
if (!string_key) {
zend_hash_index_update(Z_ARRVAL_P(return_value), num_key, entry);
} else {
- new_key = STR_INIT(string_key->val, string_key->len, 0);
+ new_key = zend_string_init(string_key->val, string_key->len, 0);
if (change_to_upper) {
php_strtoupper(new_key->val, new_key->len);
} else {
php_strtolower(new_key->val, new_key->len);
}
zend_hash_update(Z_ARRVAL_P(return_value), new_key, entry);
- STR_RELEASE(new_key);
+ zend_string_release(new_key);
}
} ZEND_HASH_FOREACH_END();
}
@@ -2953,7 +2953,7 @@ PHP_FUNCTION(array_unique)
};
struct bucketindex *arTmp, *cmpdata, *lastkept;
unsigned int i;
- long sort_type = PHP_SORT_STRING;
+ zend_long sort_type = PHP_SORT_STRING;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) {
return;
@@ -3035,7 +3035,7 @@ static int zval_compare(zval *a, zval *b TSRMLS_DC) /* {{{ */
return ZEND_NORMALIZE_BOOL(Z_DVAL(result));
}
- convert_to_long(&result);
+ convert_to_int(&result);
return ZEND_NORMALIZE_BOOL(Z_LVAL(result));
}
/* }}} */
@@ -3061,7 +3061,7 @@ static int zval_user_compare(zval *a, zval *b TSRMLS_DC) /* {{{ */
BG(user_compare_fci).no_separation = 0;
if (zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache) TSRMLS_CC) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
- long ret = zval_get_long(&retval);
+ zend_long ret = zval_get_long(&retval);
zval_ptr_dtor(&retval);
return ret < 0 ? -1 : ret > 0 ? 1 : 0;;
} else {
@@ -4141,10 +4141,10 @@ PHP_FUNCTION(array_multisort)
PHP_FUNCTION(array_rand)
{
zval *input;
- long randval, num_req = 1;
+ zend_long randval, num_req = 1;
int num_avail;
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &input, &num_req) == FAILURE) {
return;
@@ -4176,14 +4176,14 @@ PHP_FUNCTION(array_rand)
/* If we are returning a single result, just do it. */
if (Z_TYPE_P(return_value) != IS_ARRAY) {
if (string_key) {
- RETURN_STR(STR_COPY(string_key));
+ RETURN_STR(zend_string_copy(string_key));
} else {
RETURN_LONG(num_key);
}
} else {
/* Append the result to the return value. */
if (string_key) {
- add_next_index_str(return_value, STR_COPY(string_key));
+ add_next_index_str(return_value, zend_string_copy(string_key));
} else {
add_next_index_long(return_value, num_key);
}
@@ -4247,7 +4247,7 @@ PHP_FUNCTION(array_product)
if (Z_TYPE(entry_n) == IS_LONG && Z_TYPE_P(return_value) == IS_LONG) {
dval = (double)Z_LVAL_P(return_value) * (double)Z_LVAL(entry_n);
- if ( (double)LONG_MIN <= dval && dval <= (double)LONG_MAX ) {
+ if ( (double)ZEND_LONG_MIN <= dval && dval <= (double)ZEND_LONG_MAX ) {
Z_LVAL_P(return_value) *= Z_LVAL(entry_n);
continue;
}
@@ -4298,14 +4298,18 @@ PHP_FUNCTION(array_reduce)
fci.no_separation = 0;
ZEND_HASH_FOREACH_VAL(htbl, operand) {
- ZVAL_COPY_VALUE(&args[0], &result);
- ZVAL_COPY_VALUE(&args[1], operand);
+ ZVAL_COPY(&args[0], &result);
+ ZVAL_COPY(&args[1], operand);
fci.params = args;
if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
+ zval_ptr_dtor(&args[1]);
+ zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&result);
ZVAL_COPY_VALUE(&result, &retval);
} else {
+ zval_ptr_dtor(&args[1]);
+ zval_ptr_dtor(&args[0]);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "An error occurred while invoking the reduction callback");
return;
}
@@ -4324,11 +4328,11 @@ PHP_FUNCTION(array_filter)
zval args[2];
zval retval;
zend_bool have_callback = 0;
- long use_type = 0;
+ zend_long use_type = 0;
zend_string *string_key;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
- ulong num_key;
+ zend_ulong num_key;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|fl", &array, &fci, &fci_cache, &use_type) == FAILURE) {
return;
@@ -4359,9 +4363,9 @@ PHP_FUNCTION(array_filter)
}
} else {
if (use_type == ARRAY_FILTER_USE_BOTH) {
- ZVAL_STR(&args[1], STR_COPY(string_key));
+ ZVAL_STR(&args[1], zend_string_copy(string_key));
} else if (use_type == ARRAY_FILTER_USE_KEY) {
- ZVAL_STR(&args[0], STR_COPY(string_key));
+ ZVAL_STR(&args[0], zend_string_copy(string_key));
}
}
}
@@ -4432,9 +4436,9 @@ PHP_FUNCTION(array_map)
RETVAL_NULL();
if (n_arrays == 1) {
- ulong num_key;
+ zend_ulong num_key;
zend_string *str_key;
- zval *zv;
+ zval *zv, arg;
if (Z_TYPE(arrays[0]) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument #%d should be an array", 2);
@@ -4453,20 +4457,18 @@ PHP_FUNCTION(array_map)
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL(arrays[0]), num_key, str_key, zv) {
fci.retval = &result;
fci.param_count = 1;
- fci.params = zv;
+ fci.params = &arg;
fci.no_separation = 0;
- if (Z_REFCOUNTED_P(zv)) {
- Z_ADDREF_P(zv);
- }
+ ZVAL_COPY(&arg, zv);
if (zend_call_function(&fci, &fci_cache TSRMLS_CC) != SUCCESS || Z_TYPE(result) == IS_UNDEF) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "An error occurred while invoking the map callback");
zval_dtor(return_value);
- zval_ptr_dtor(zv);
+ zval_ptr_dtor(&arg);
RETURN_NULL();
} else {
- zval_ptr_dtor(zv);
+ zval_ptr_dtor(&arg);
}
if (str_key) {
zend_hash_add_new(Z_ARRVAL_P(return_value), str_key, &result);
@@ -4475,7 +4477,7 @@ PHP_FUNCTION(array_map)
}
} ZEND_HASH_FOREACH_END();
} else {
- zend_uint *array_pos = (HashPosition *)ecalloc(n_arrays, sizeof(HashPosition));
+ uint32_t *array_pos = (HashPosition *)ecalloc(n_arrays, sizeof(HashPosition));
for (i = 0; i < n_arrays; i++) {
if (Z_TYPE(arrays[i]) != IS_ARRAY) {
@@ -4503,7 +4505,7 @@ PHP_FUNCTION(array_map)
for (i = 0; i < n_arrays; i++) {
/* If this array still has elements, add the current one to the
* parameter list, otherwise use null value. */
- zend_uint pos = array_pos[i];
+ uint32_t pos = array_pos[i];
while (1) {
if (pos >= Z_ARRVAL(arrays[i])->nNumUsed) {
ZVAL_NULL(&zv);
@@ -4529,7 +4531,7 @@ PHP_FUNCTION(array_map)
for (i = 0; i < n_arrays; i++) {
/* If this array still has elements, add the current one to the
* parameter list, otherwise use null value. */
- zend_uint pos = array_pos[i];
+ uint32_t pos = array_pos[i];
while (1) {
if (pos >= Z_ARRVAL(arrays[i])->nNumUsed) {
ZVAL_NULL(&params[i]);
@@ -4620,9 +4622,9 @@ PHP_FUNCTION(array_key_exists)
PHP_FUNCTION(array_chunk)
{
int argc = ZEND_NUM_ARGS(), num_in;
- long size, current = 0;
+ zend_long size, current = 0;
zend_string *str_key;
- ulong num_key;
+ zend_ulong num_key;
zend_bool preserve_keys = 0;
zval *input = NULL;
zval chunk;
@@ -4686,7 +4688,7 @@ PHP_FUNCTION(array_chunk)
PHP_FUNCTION(array_combine)
{
zval *values, *keys;
- zend_uint pos_values = 0;
+ uint32_t pos_values = 0;
zval *entry_keys, *entry_values;
int num_keys, num_values;
@@ -4722,7 +4724,7 @@ PHP_FUNCTION(array_combine)
zval_add_ref(entry_values);
zend_symtable_update(Z_ARRVAL_P(return_value), key, entry_values);
- STR_RELEASE(key);
+ zend_string_release(key);
}
pos_values++;
break;
diff --git a/ext/standard/assert.c b/ext/standard/assert.c
index e64e2e1ecb..abd7c4079e 100644
--- a/ext/standard/assert.c
+++ b/ext/standard/assert.c
@@ -25,10 +25,10 @@
/* }}} */
ZEND_BEGIN_MODULE_GLOBALS(assert)
- long active;
- long bail;
- long warning;
- long quiet_eval;
+ zend_long active;
+ zend_long bail;
+ zend_long warning;
+ zend_long quiet_eval;
zval callback;
char *cb;
ZEND_END_MODULE_GLOBALS(assert)
@@ -256,7 +256,7 @@ PHP_FUNCTION(assert)
PHP_FUNCTION(assert_options)
{
zval *value = NULL;
- long what;
+ zend_long what;
int oldint;
int ac = ZEND_NUM_ARGS();
zend_string *key;
@@ -270,10 +270,10 @@ PHP_FUNCTION(assert_options)
oldint = ASSERTG(active);
if (ac == 2) {
zend_string *value_str = zval_get_string(value);
- key = STR_INIT("assert.active", sizeof("assert.active")-1, 0);
+ key = zend_string_init("assert.active", sizeof("assert.active")-1, 0);
zend_alter_ini_entry_ex(key, value_str->val, value_str->len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
- STR_RELEASE(key);
- STR_RELEASE(value_str);
+ zend_string_release(key);
+ zend_string_release(value_str);
}
RETURN_LONG(oldint);
break;
@@ -282,10 +282,10 @@ PHP_FUNCTION(assert_options)
oldint = ASSERTG(bail);
if (ac == 2) {
zend_string *value_str = zval_get_string(value);
- key = STR_INIT("assert.bail", sizeof("assert.bail")-1, 0);
+ key = zend_string_init("assert.bail", sizeof("assert.bail")-1, 0);
zend_alter_ini_entry_ex(key, value_str->val, value_str->len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
- STR_RELEASE(key);
- STR_RELEASE(value_str);
+ zend_string_release(key);
+ zend_string_release(value_str);
}
RETURN_LONG(oldint);
break;
@@ -294,10 +294,10 @@ PHP_FUNCTION(assert_options)
oldint = ASSERTG(quiet_eval);
if (ac == 2) {
zend_string *value_str = zval_get_string(value);
- key = STR_INIT("assert.quiet_eval", sizeof("assert.quiet_eval")-1, 0);
+ key = zend_string_init("assert.quiet_eval", sizeof("assert.quiet_eval")-1, 0);
zend_alter_ini_entry_ex(key, value_str->val, value_str->len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
- STR_RELEASE(key);
- STR_RELEASE(value_str);
+ zend_string_release(key);
+ zend_string_release(value_str);
}
RETURN_LONG(oldint);
break;
@@ -306,10 +306,10 @@ PHP_FUNCTION(assert_options)
oldint = ASSERTG(warning);
if (ac == 2) {
zend_string *value_str = zval_get_string(value);
- key = STR_INIT("assert.warning", sizeof("assert.warning")-1, 0);
+ key = zend_string_init("assert.warning", sizeof("assert.warning")-1, 0);
zend_alter_ini_entry_ex(key, value_str->val, value_str->len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
- STR_RELEASE(key);
- STR_RELEASE(value_str);
+ zend_string_release(key);
+ zend_string_release(value_str);
}
RETURN_LONG(oldint);
break;
@@ -331,7 +331,7 @@ PHP_FUNCTION(assert_options)
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown value %ld", what);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown value %pd", what);
break;
}
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
index 3bc96267b2..544514161b 100644
--- a/ext/standard/base64.c
+++ b/ext/standard/base64.c
@@ -53,7 +53,7 @@ static const short base64_reverse_table[256] = {
};
/* }}} */
-PHPAPI zend_string *php_base64_encode(const unsigned char *str, int length) /* {{{ */
+PHPAPI zend_string *php_base64_encode(const unsigned char *str, size_t length) /* {{{ */
{
const unsigned char *current = str;
unsigned char *p;
@@ -63,7 +63,7 @@ PHPAPI zend_string *php_base64_encode(const unsigned char *str, int length) /* {
return NULL;
}
- result = STR_ALLOC(((length + 2) / 3) * 4 * sizeof(char), 0);
+ result = zend_string_alloc(((length + 2) / 3) * 4 * sizeof(char), 0);
p = (unsigned char *)result->val;
while (length > 2) { /* keep going until we have less than 24 bits */
@@ -131,20 +131,20 @@ void php_base64_init(void)
*/
/* }}} */
-PHPAPI zend_string *php_base64_decode(const unsigned char *str, int length) /* {{{ */
+PHPAPI zend_string *php_base64_decode(const unsigned char *str, size_t length) /* {{{ */
{
return php_base64_decode_ex(str, length, 0);
}
/* }}} */
-PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, int length, zend_bool strict) /* {{{ */
+PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length, zend_bool strict) /* {{{ */
{
const unsigned char *current = str;
int ch, i = 0, j = 0, k;
/* this sucks for threaded environments */
zend_string *result;
- result = STR_ALLOC(length, 0);
+ result = zend_string_alloc(length, 0);
/* run through the whole string, converting as we go */
while ((ch = *current++) != '\0' && length-- > 0) {
@@ -158,7 +158,7 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, int length, z
continue;
}
}
- STR_FREE(result);
+ zend_string_free(result);
return NULL;
}
continue;
@@ -168,7 +168,7 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, int length, z
if ((!strict && ch < 0) || ch == -1) { /* a space or some other separator character, we simply skip over */
continue;
} else if (ch == -2) {
- STR_FREE(result);
+ zend_string_free(result);
return NULL;
}
@@ -196,7 +196,7 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, int length, z
if (ch == base64_pad) {
switch(i % 4) {
case 1:
- STR_FREE(result);
+ zend_string_free(result);
return NULL;
case 2:
k++;
diff --git a/ext/standard/base64.h b/ext/standard/base64.h
index e58565702a..43324e4911 100644
--- a/ext/standard/base64.h
+++ b/ext/standard/base64.h
@@ -24,9 +24,9 @@
PHP_FUNCTION(base64_decode);
PHP_FUNCTION(base64_encode);
-PHPAPI extern zend_string *php_base64_encode(const unsigned char *, int);
-PHPAPI extern zend_string *php_base64_decode_ex(const unsigned char *, int, zend_bool);
-PHPAPI extern zend_string *php_base64_decode(const unsigned char *, int);
+PHPAPI extern zend_string *php_base64_encode(const unsigned char *, size_t);
+PHPAPI extern zend_string *php_base64_decode_ex(const unsigned char *, size_t, zend_bool);
+PHPAPI extern zend_string *php_base64_decode(const unsigned char *, size_t);
#endif /* BASE64_H */
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 17bdae5719..dbccaae265 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -99,7 +99,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef INADDR_NONE
-#define INADDR_NONE ((unsigned long int) -1)
+#define INADDR_NONE ((zend_ulong) -1)
#endif
#include "zend_globals.h"
@@ -395,7 +395,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_array_merge, 0, 0, 2)
ZEND_ARG_INFO(0, arr1) /* ARRAY_INFO(0, arg, 0) */
ZEND_ARG_VARIADIC_INFO(0, arrays)
ZEND_END_ARG_INFO()
-
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_array_merge_recursive, 0, 0, 2)
ZEND_ARG_INFO(0, arr1) /* ARRAY_INFO(0, arg, 0) */
ZEND_ARG_VARIADIC_INFO(0, arrays)
@@ -3914,7 +3914,7 @@ PHP_FUNCTION(ip2long)
#ifdef HAVE_INET_PTON
struct in_addr ip;
#else
- unsigned long int ip;
+ zend_ulong ip;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addr, &addr_len) == FAILURE) {
@@ -3950,7 +3950,7 @@ PHP_FUNCTION(long2ip)
/* "It's a long but it's not, PHP ints are signed */
char *ip;
int ip_len;
- unsigned long n;
+ zend_ulong n;
struct in_addr myaddr;
#ifdef HAVE_INET_PTON
char str[40];
@@ -4252,7 +4252,7 @@ PHP_FUNCTION(getopt)
argv[pos++] = estrdup(arg_str->val);
- STR_RELEASE(arg_str);
+ zend_string_release(arg_str);
} ZEND_HASH_FOREACH_END();
/* The C Standard requires argv[argc] to be NULL - this might
@@ -4297,7 +4297,7 @@ PHP_FUNCTION(getopt)
opts->opt_char = 0;
opts++;
- STR_RELEASE(arg_str);
+ zend_string_release(arg_str);
} ZEND_HASH_FOREACH_END();
} else {
opts = (opt_struct*) erealloc(opts, sizeof(opt_struct) * (len + 1));
@@ -4386,7 +4386,7 @@ PHP_FUNCTION(flush)
Delay for a given number of seconds */
PHP_FUNCTION(sleep)
{
- long num;
+ zend_long num;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) {
RETURN_FALSE;
@@ -4409,7 +4409,7 @@ PHP_FUNCTION(sleep)
PHP_FUNCTION(usleep)
{
#if HAVE_USLEEP
- long num;
+ zend_long num;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num) == FAILURE) {
return;
@@ -4428,7 +4428,7 @@ PHP_FUNCTION(usleep)
Delay for a number of seconds and nano seconds */
PHP_FUNCTION(time_nanosleep)
{
- long tv_sec, tv_nsec;
+ zend_long tv_sec, tv_nsec;
struct timespec php_req, php_rem;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &tv_sec, &tv_nsec) == FAILURE) {
@@ -4525,9 +4525,9 @@ static int add_config_entry_cb(zval *entry TSRMLS_DC, int num_args, va_list args
if (Z_TYPE_P(entry) == IS_STRING) {
if (hash_key->key) {
- add_assoc_str_ex(retval, hash_key->key->val, hash_key->key->len, STR_COPY(Z_STR_P(entry)));
+ add_assoc_str_ex(retval, hash_key->key->val, hash_key->key->len, zend_string_copy(Z_STR_P(entry)));
} else {
- add_index_str(retval, hash_key->h, STR_COPY(Z_STR_P(entry)));
+ add_index_str(retval, hash_key->h, zend_string_copy(Z_STR_P(entry)));
}
} else if (Z_TYPE_P(entry) == IS_ARRAY) {
array_init(&tmp);
@@ -4626,7 +4626,7 @@ PHP_FUNCTION(error_log)
char *message, *opt = NULL, *headers = NULL;
int message_len, opt_len = 0, headers_len = 0;
int opt_err = 0, argc = ZEND_NUM_ARGS();
- long erropt = 0;
+ zend_long erropt = 0;
if (zend_parse_parameters(argc TSRMLS_CC, "s|lps", &message, &message_len, &erropt, &opt, &opt_len, &headers, &headers_len) == FAILURE) {
return;
@@ -4858,12 +4858,12 @@ static int user_shutdown_function_call(zval *zv TSRMLS_DC) /* {{{ */
if (!zend_is_callable(&shutdown_function_entry->arguments[0], 0, &function_name TSRMLS_CC)) {
php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", function_name->val);
if (function_name) {
- STR_RELEASE(function_name);
+ zend_string_release(function_name);
}
return 0;
}
if (function_name) {
- STR_RELEASE(function_name);
+ zend_string_release(function_name);
}
if (call_user_function(EG(function_table), NULL,
@@ -5019,7 +5019,7 @@ PHP_FUNCTION(register_shutdown_function)
zend_hash_next_index_insert_mem(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry));
}
if (callback_name) {
- STR_RELEASE(callback_name);
+ zend_string_release(callback_name);
}
}
/* }}} */
@@ -5375,13 +5375,13 @@ PHP_FUNCTION(set_include_path)
RETVAL_FALSE;
}
- key = STR_INIT("include_path", sizeof("include_path") - 1, 0);
+ key = zend_string_init("include_path", sizeof("include_path") - 1, 0);
if (zend_alter_ini_entry_ex(key, new_value, new_value_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == FAILURE) {
- STR_RELEASE(key);
+ zend_string_release(key);
zval_dtor(return_value);
RETURN_FALSE;
}
- STR_RELEASE(key);
+ zend_string_release(key);
}
/* }}} */
@@ -5414,9 +5414,9 @@ PHP_FUNCTION(restore_include_path)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
- key = STR_INIT("include_path", sizeof("include_path")-1, 0);
+ key = zend_string_init("include_path", sizeof("include_path")-1, 0);
zend_restore_ini_entry(key, PHP_INI_STAGE_RUNTIME);
- STR_FREE(key);
+ zend_string_free(key);
}
/* }}} */
@@ -5477,9 +5477,9 @@ PHP_FUNCTION(ignore_user_abort)
old_setting = PG(ignore_user_abort);
if (arg) {
- zend_string *key = STR_INIT("ignore_user_abort", sizeof("ignore_user_abort"), 0);
+ zend_string *key = zend_string_init("ignore_user_abort", sizeof("ignore_user_abort"), 0);
zend_alter_ini_entry_ex(key, arg, arg_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
- STR_RELEASE(key);
+ zend_string_release(key);
}
RETURN_LONG(old_setting);
@@ -5526,7 +5526,7 @@ PHP_FUNCTION(getservbyport)
{
char *proto;
int proto_len;
- long port;
+ zend_long port;
struct servent *serv;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &port, &proto, &proto_len) == FAILURE) {
@@ -5573,7 +5573,7 @@ PHP_FUNCTION(getprotobyname)
Returns protocol name associated with protocol number proto */
PHP_FUNCTION(getprotobynumber)
{
- long proto;
+ zend_long proto;
struct protoent *ent;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &proto) == FAILURE) {
@@ -5616,10 +5616,10 @@ PHP_FUNCTION(register_tick_function)
if (!zend_is_callable(&tick_fe.arguments[0], 0, &function_name TSRMLS_CC)) {
efree(tick_fe.arguments);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid tick callback '%s' passed", function_name->val);
- STR_RELEASE(function_name);
+ zend_string_release(function_name);
RETURN_FALSE;
} else if (function_name) {
- STR_RELEASE(function_name);
+ zend_string_release(function_name);
}
if (Z_TYPE(tick_fe.arguments[0]) != IS_ARRAY && Z_TYPE(tick_fe.arguments[0]) != IS_OBJECT) {
@@ -5778,7 +5778,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
}
if (!(Z_STRLEN_P(arg1) > 1 && Z_STRVAL_P(arg1)[0] == '0') && is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) == IS_LONG) {
- ulong key = (ulong) zend_atol(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
+ zend_ulong key = (zend_ulong) zend_atol(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
if ((find_hash = zend_hash_index_find(Z_ARRVAL_P(arr), key)) == NULL) {
array_init(&hash);
find_hash = zend_hash_index_update(Z_ARRVAL_P(arr), key, &hash);
@@ -5839,7 +5839,7 @@ PHP_FUNCTION(parse_ini_file)
char *filename = NULL;
int filename_len = 0;
zend_bool process_sections = 0;
- long scanner_mode = ZEND_INI_SCANNER_NORMAL;
+ zend_long scanner_mode = ZEND_INI_SCANNER_NORMAL;
zend_file_handle fh;
zend_ini_parser_cb_t ini_parser_cb;
@@ -5880,7 +5880,7 @@ PHP_FUNCTION(parse_ini_string)
char *string = NULL, *str = NULL;
int str_len = 0;
zend_bool process_sections = 0;
- long scanner_mode = ZEND_INI_SCANNER_NORMAL;
+ zend_long scanner_mode = ZEND_INI_SCANNER_NORMAL;
zend_ini_parser_cb_t ini_parser_cb;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bl", &str, &str_len, &process_sections, &scanner_mode) == FAILURE) {
diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h
index 3cabf87d1a..64a6c5363c 100644
--- a/ext/standard/basic_functions.h
+++ b/ext/standard/basic_functions.h
@@ -167,7 +167,7 @@ typedef struct _php_basic_globals {
char *locale_string;
char *strtok_last;
char strtok_table[256];
- ulong strtok_len;
+ zend_ulong strtok_len;
char str_ebuf[40];
zend_fcall_info array_walk_fci;
zend_fcall_info_cache array_walk_fci_cache;
@@ -178,9 +178,9 @@ typedef struct _php_basic_globals {
zval active_ini_file_section;
/* pageinfo.c */
- long page_uid;
- long page_gid;
- long page_inode;
+ zend_long page_uid;
+ zend_long page_gid;
+ zend_long page_inode;
time_t page_mtime;
/* filestat.c && main/streams/streams.c */
diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c
index f494cc86b1..320d1f90a7 100644
--- a/ext/standard/browscap.c
+++ b/ext/standard/browscap.c
@@ -61,7 +61,7 @@ static void browscap_entry_dtor_request(zval *zvalue) /* {{{ */
zend_hash_destroy(Z_ARRVAL_P(zvalue));
efree(Z_ARR_P(zvalue));
} else if (Z_TYPE_P(zvalue) == IS_STRING) {
- STR_RELEASE(Z_STR_P(zvalue));
+ zend_string_release(Z_STR_P(zvalue));
}
}
/* }}} */
@@ -71,7 +71,7 @@ static void browscap_entry_dtor_persistent(zval *zvalue) /* {{{ */ {
zend_hash_destroy(Z_ARRVAL_P(zvalue));
free(Z_ARR_P(zvalue));
} else if (Z_TYPE_P(zvalue) == IS_STRING) {
- STR_RELEASE(Z_STR_P(zvalue));
+ zend_string_release(Z_STR_P(zvalue));
}
}
/* }}} */
@@ -83,7 +83,7 @@ static void convert_browscap_pattern(zval *pattern, int persistent) /* {{{ */
zend_string *res;
char *lc_pattern;
- res = STR_SAFE_ALLOC(Z_STRLEN_P(pattern), 2, 4, persistent);
+ res = zend_string_safe_alloc(Z_STRLEN_P(pattern), 2, 4, persistent);
t = res->val;
lc_pattern = zend_str_tolower_dup(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern));
@@ -167,7 +167,7 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callb
(Z_STRLEN_P(arg2) == 3 && !strncasecmp(Z_STRVAL_P(arg2), "yes", sizeof("yes") - 1)) ||
(Z_STRLEN_P(arg2) == 4 && !strncasecmp(Z_STRVAL_P(arg2), "true", sizeof("true") - 1))
) {
- ZVAL_NEW_STR(&new_property, STR_INIT("1", sizeof("1")-1, persistent));
+ ZVAL_NEW_STR(&new_property, zend_string_init("1", sizeof("1")-1, persistent));
} else if (
(Z_STRLEN_P(arg2) == 2 && !strncasecmp(Z_STRVAL_P(arg2), "no", sizeof("no") - 1)) ||
(Z_STRLEN_P(arg2) == 3 && !strncasecmp(Z_STRVAL_P(arg2), "off", sizeof("off") - 1)) ||
@@ -175,14 +175,14 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callb
(Z_STRLEN_P(arg2) == 5 && !strncasecmp(Z_STRVAL_P(arg2), "false", sizeof("false") - 1))
) {
// TODO: USE STR_EMPTY_ALLOC()?
- ZVAL_NEW_STR(&new_property, STR_INIT("", sizeof("")-1, persistent));
+ ZVAL_NEW_STR(&new_property, zend_string_init("", sizeof("")-1, persistent));
} else { /* Other than true/false setting */
- ZVAL_STR(&new_property, STR_DUP(Z_STR_P(arg2), persistent));
+ ZVAL_STR(&new_property, zend_string_dup(Z_STR_P(arg2), persistent));
}
- new_key = STR_DUP(Z_STR_P(arg1), persistent);
+ new_key = zend_string_dup(Z_STR_P(arg1), persistent);
zend_str_tolower(new_key->val, new_key->len);
zend_hash_update(Z_ARRVAL(bdata->current_section), new_key, &new_property);
- STR_RELEASE(new_key);
+ zend_string_release(new_key);
}
break;
case ZEND_INI_PARSER_SECTION: {
@@ -208,7 +208,7 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callb
zend_hash_update(bdata->htab, Z_STR_P(arg1), &bdata->current_section);
ZVAL_STR(&processed, Z_STR_P(arg1));
- ZVAL_STR(&unprocessed, STR_DUP(Z_STR_P(arg1), persistent));
+ ZVAL_STR(&unprocessed, zend_string_dup(Z_STR_P(arg1), persistent));
convert_browscap_pattern(&processed, persistent);
zend_hash_str_update(Z_ARRVAL(bdata->current_section), "browser_name_regex", sizeof("browser_name_regex")-1, &processed);
@@ -465,9 +465,9 @@ PHP_FUNCTION(get_browser)
}
if (agent_name == NULL) {
- zend_string *key = STR_INIT("_SERVER", sizeof("_SERVER") - 1, 0);
+ zend_string *key = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
zend_is_auto_global(key TSRMLS_CC);
- STR_RELEASE(key);
+ zend_string_release(key);
if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF ||
(http_user_agent = zend_hash_str_find(HASH_OF(&PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT")-1)) == NULL
) {
diff --git a/ext/standard/credits.c b/ext/standard/credits.c
index 3cb6eef724..6df81ca029 100644
--- a/ext/standard/credits.c
+++ b/ext/standard/credits.c
@@ -69,6 +69,7 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) /* {{{ */
CREDIT_LINE("Streams Abstraction Layer", "Wez Furlong, Sara Golemon");
CREDIT_LINE("PHP Data Objects Layer", "Wez Furlong, Marcus Boerger, Sterling Hughes, George Schlossnagle, Ilia Alshanetsky");
CREDIT_LINE("Output Handler", "Zeev Suraski, Thies C. Arntzen, Marcus Boerger, Michael Wallner");
+ CREDIT_LINE("Consistent 64 bit support", "Anthony Ferrara, Anatol Belski");
php_info_print_table_end();
}
diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c
index 2a2304be20..5c9fcbafe8 100644
--- a/ext/standard/crypt.c
+++ b/ext/standard/crypt.c
@@ -136,7 +136,7 @@ PHP_MSHUTDOWN_FUNCTION(crypt) /* {{{ */
static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-static void php_to64(char *s, long v, int n) /* {{{ */
+static void php_to64(char *s, zend_long v, int n) /* {{{ */
{
while (--n >= 0) {
*s++ = itoa64[v&0x3f];
@@ -160,7 +160,7 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
out = php_md5_crypt_r(password, salt, output);
if (out) {
- return STR_INIT(out, strlen(out), 0);
+ return zend_string_init(out, strlen(out), 0);
}
return NULL;
} else if (salt[0]=='$' && salt[1]=='6' && salt[2]=='$') {
@@ -173,7 +173,7 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
efree(output);
return NULL;
} else {
- result = STR_INIT(output, strlen(output), 0);
+ result = zend_string_init(output, strlen(output), 0);
memset(output, 0, PHP_MAX_SALT_LEN);
efree(output);
return result;
@@ -188,7 +188,7 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
efree(output);
return NULL;
} else {
- result = STR_INIT(output, strlen(output), 0);
+ result = zend_string_init(output, strlen(output), 0);
memset(output, 0, PHP_MAX_SALT_LEN);
efree(output);
return result;
@@ -210,7 +210,7 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
memset(output, 0, PHP_MAX_SALT_LEN + 1);
return NULL;
} else {
- result = STR_INIT(output, strlen(output), 0);
+ result = zend_string_init(output, strlen(output), 0);
memset(output, 0, PHP_MAX_SALT_LEN + 1);
return result;
}
@@ -222,7 +222,7 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
if (!crypt_res) {
return NULL;
} else {
- result = STR_INIT(crypt_res, strlen(crypt_res), 0);
+ result = zend_string_init(crypt_res, strlen(crypt_res), 0);
return result;
}
}
@@ -243,7 +243,7 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
if (!crypt_res) {
return FAILURE;
} else {
- result = STR_INIT(crypt_res, strlen(crypt_res), 0);
+ result = zend_string_init(crypt_res, strlen(crypt_res), 0);
return result;
}
}
diff --git a/ext/standard/crypt_sha256.c b/ext/standard/crypt_sha256.c
index ccfa66bd60..e53f488805 100644
--- a/ext/standard/crypt_sha256.c
+++ b/ext/standard/crypt_sha256.c
@@ -372,7 +372,7 @@ char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int b
if (strncmp(salt, sha256_rounds_prefix, sizeof(sha256_rounds_prefix) - 1) == 0) {
const char *num = salt + sizeof(sha256_rounds_prefix) - 1;
char *endp;
- unsigned long int srounds = strtoul(num, &endp, 10);
+ zend_ulong srounds = ZEND_STRTOUL(num, &endp, 10);
if (*endp == '$') {
salt = endp + 1;
rounds = MAX(ROUNDS_MIN, MIN(srounds, ROUNDS_MAX));
diff --git a/ext/standard/crypt_sha512.c b/ext/standard/crypt_sha512.c
index ebabed9d24..a673bfac1c 100644
--- a/ext/standard/crypt_sha512.c
+++ b/ext/standard/crypt_sha512.c
@@ -405,7 +405,7 @@ php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
if (strncmp(salt, sha512_rounds_prefix, sizeof(sha512_rounds_prefix) - 1) == 0) {
const char *num = salt + sizeof(sha512_rounds_prefix) - 1;
char *endp;
- unsigned long int srounds = strtoul(num, &endp, 10);
+ zend_ulong srounds = ZEND_STRTOUL(num, &endp, 10);
if (*endp == '$') {
salt = endp + 1;
diff --git a/ext/standard/cyr_convert.c b/ext/standard/cyr_convert.c
index 326e9e21b8..503f3659ed 100644
--- a/ext/standard/cyr_convert.c
+++ b/ext/standard/cyr_convert.c
@@ -279,7 +279,7 @@ PHP_FUNCTION(convert_cyr_string)
return;
}
- str = STR_INIT(input, input_len, 0);
+ str = zend_string_init(input, input_len, 0);
php_convert_cyr_string(str->val, str->len, fr_cs[0], to_cs[0] TSRMLS_CC);
RETVAL_NEW_STR(str);
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
index 16cc8db054..4d96384e9c 100644
--- a/ext/standard/dir.c
+++ b/ext/standard/dir.c
@@ -273,7 +273,7 @@ PHP_FUNCTION(closedir)
FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a valid Directory resource", dirp->res->handle);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%pd is not a valid Directory resource", dirp->res->handle);
RETURN_FALSE;
}
@@ -387,7 +387,7 @@ PHP_FUNCTION(rewinddir)
FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a valid Directory resource", dirp->res->handle);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%pd is not a valid Directory resource", dirp->res->handle);
RETURN_FALSE;
}
@@ -406,7 +406,7 @@ PHP_NAMED_FUNCTION(php_if_readdir)
FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a valid Directory resource", dirp->res->handle);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%pd is not a valid Directory resource", dirp->res->handle);
RETURN_FALSE;
}
@@ -430,7 +430,7 @@ PHP_FUNCTION(glob)
#endif
char *pattern = NULL;
int pattern_len;
- long flags = 0;
+ zend_long flags = 0;
glob_t globbuf;
int n;
int ret;
@@ -524,7 +524,7 @@ no_results:
* able to filter directories out.
*/
if (flags & GLOB_ONLYDIR) {
- struct stat s;
+ zend_stat_t s;
if (0 != VCWD_STAT(globbuf.gl_pathv[n], &s)) {
continue;
@@ -553,7 +553,7 @@ PHP_FUNCTION(scandir)
{
char *dirn;
int dirn_len;
- long flags = 0;
+ zend_long flags = 0;
zend_string **namelist;
int n, i;
zval *zcontext = NULL;
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index cabe3d72f1..852ebaab22 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -203,10 +203,10 @@ static zend_string *php_gethostbyaddr(char *ip)
#endif
if (!hp || hp->h_name == NULL || hp->h_name[0] == '\0') {
- return STR_INIT(ip, strlen(ip), 0);
+ return zend_string_init(ip, strlen(ip), 0);
}
- return STR_INIT(hp->h_name, strlen(hp->h_name), 0);
+ return zend_string_init(hp->h_name, strlen(hp->h_name), 0);
}
/* }}} */
@@ -263,13 +263,13 @@ static zend_string *php_gethostbyname(char *name)
hp = gethostbyname(name);
if (!hp || !*(hp->h_addr_list)) {
- return STR_INIT(name, strlen(name), 0);
+ return zend_string_init(name, strlen(name), 0);
}
memcpy(&in.s_addr, *(hp->h_addr_list), sizeof(in.s_addr));
address = inet_ntoa(in);
- return STR_INIT(address, strlen(address), 0);
+ return zend_string_init(address, strlen(address), 0);
}
/* }}} */
@@ -411,8 +411,14 @@ PHP_FUNCTION(dns_check_record)
#if HAVE_FULL_DNS_FUNCS
+#define CHECKCP(n) do { \
+ if (cp + n > end) { \
+ return NULL; \
+ } \
+} while (0)
+
/* {{{ php_parserr */
-static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, int raw, zval *subarray)
+static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_to_fetch, int store, int raw, zval *subarray)
{
u_short type, class, dlen;
u_long ttl;
@@ -424,16 +430,18 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
ZVAL_UNDEF(subarray);
- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, sizeof(name) - 2);
+ n = dn_expand(answer->qb2, end, cp, name, sizeof(name) - 2);
if (n < 0) {
return NULL;
}
cp += n;
+ CHECKCP(10);
GETSHORT(type, cp);
GETSHORT(class, cp);
GETLONG(ttl, cp);
GETSHORT(dlen, cp);
+ CHECKCP(dlen);
if (type_to_fetch != T_ANY && type != type_to_fetch) {
cp += dlen;
return cp;
@@ -459,12 +467,14 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
switch (type) {
case DNS_T_A:
+ CHECKCP(4);
add_assoc_string(subarray, "type", "A");
snprintf(name, sizeof(name), "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]);
add_assoc_string(subarray, "ip", name);
cp += dlen;
break;
case DNS_T_MX:
+ CHECKCP(2);
add_assoc_string(subarray, "type", "MX");
GETSHORT(n, cp);
add_assoc_long(subarray, "pri", n);
@@ -483,7 +493,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
if (type == DNS_T_PTR) {
add_assoc_string(subarray, "type", "PTR");
}
- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2);
+ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2);
if (n < 0) {
return NULL;
}
@@ -493,38 +503,45 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
case DNS_T_HINFO:
/* See RFC 1010 for values */
add_assoc_string(subarray, "type", "HINFO");
+ CHECKCP(1);
n = *cp & 0xFF;
cp++;
+ CHECKCP(n);
add_assoc_stringl(subarray, "cpu", (char*)cp, n);
cp += n;
+ CHECKCP(1);
n = *cp & 0xFF;
cp++;
+ CHECKCP(n);
add_assoc_stringl(subarray, "os", (char*)cp, n);
cp += n;
break;
case DNS_T_TXT:
{
- int ll = 0;
+ int l1 = 0, l2 = 0;
zval entries;
zend_string *tp;
add_assoc_string(subarray, "type", "TXT");
- tp = STR_ALLOC(dlen, 0);
+ tp = zend_string_alloc(dlen, 0);
array_init(&entries);
- while (ll < dlen) {
- n = cp[ll];
- if ((ll + n) >= dlen) {
+ while (l1 < dlen) {
+ n = cp[l1];
+ if ((l1 + n) >= dlen) {
// Invalid chunk length, truncate
- n = dlen - (ll + 1);
+ n = dlen - (l1 + 1);
+ }
+ if (n) {
+ memcpy(tp->val + l2 , cp + l1 + 1, n);
+ add_next_index_stringl(&entries, cp + l1 + 1, n);
}
- memcpy(tp->val + ll , cp + ll + 1, n);
- add_next_index_stringl(&entries, (char*)cp + ll + 1, n);
- ll = ll + n + 1;
+ l1 = l1 + n + 1;
+ l2 = l2 + n;
}
- tp->val[dlen] = '\0';
- tp->len = dlen;
+ tp->val[l2] = '\0';
+ tp->len = l2;
cp += dlen;
add_assoc_str(subarray, "txt", tp);
@@ -533,18 +550,19 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
break;
case DNS_T_SOA:
add_assoc_string(subarray, "type", "SOA");
- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) -2);
+ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) -2);
if (n < 0) {
return NULL;
}
cp += n;
add_assoc_string(subarray, "mname", name);
- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) -2);
+ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) -2);
if (n < 0) {
return NULL;
}
cp += n;
add_assoc_string(subarray, "rname", name);
+ CHECKCP(5*4);
GETLONG(n, cp);
add_assoc_long(subarray, "serial", n);
GETLONG(n, cp);
@@ -558,6 +576,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
break;
case DNS_T_AAAA:
tp = (u_char*)name;
+ CHECKCP(8*2);
for(i=0; i < 8; i++) {
GETSHORT(s, cp);
if (s != 0) {
@@ -592,6 +611,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
case DNS_T_A6:
p = cp;
add_assoc_string(subarray, "type", "A6");
+ CHECKCP(1);
n = ((int)cp[0]) & 0xFF;
cp++;
add_assoc_long(subarray, "masklen", n);
@@ -627,6 +647,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
cp++;
}
for (i = (n + 8) / 16; i < 8; i++) {
+ CHECKCP(2);
GETSHORT(s, cp);
if (s != 0) {
if (tp > (u_char *)name) {
@@ -656,7 +677,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
tp[0] = '\0';
add_assoc_string(subarray, "ipv6", name);
if (cp < p + dlen) {
- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2);
+ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2);
if (n < 0) {
return NULL;
}
@@ -665,6 +686,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
}
break;
case DNS_T_SRV:
+ CHECKCP(3*2);
add_assoc_string(subarray, "type", "SRV");
GETSHORT(n, cp);
add_assoc_long(subarray, "pri", n);
@@ -672,7 +694,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
add_assoc_long(subarray, "weight", n);
GETSHORT(n, cp);
add_assoc_long(subarray, "port", n);
- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2);
+ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2);
if (n < 0) {
return NULL;
}
@@ -680,21 +702,35 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
add_assoc_string(subarray, "target", name);
break;
case DNS_T_NAPTR:
+ CHECKCP(2*2);
add_assoc_string(subarray, "type", "NAPTR");
GETSHORT(n, cp);
add_assoc_long(subarray, "order", n);
GETSHORT(n, cp);
add_assoc_long(subarray, "pref", n);
+
+ CHECKCP(1);
n = (cp[0] & 0xFF);
- add_assoc_stringl(subarray, "flags", (char*)++cp, n);
+ cp++;
+ CHECKCP(n);
+ add_assoc_stringl(subarray, "flags", (char*)cp, n);
cp += n;
+
+ CHECKCP(1);
n = (cp[0] & 0xFF);
- add_assoc_stringl(subarray, "services", (char*)++cp, n);
+ cp++;
+ CHECKCP(n);
+ add_assoc_stringl(subarray, "services", (char*)cp, n);
cp += n;
+
+ CHECKCP(1);
n = (cp[0] & 0xFF);
- add_assoc_stringl(subarray, "regex", (char*)++cp, n);
+ cp++;
+ CHECKCP(n);
+ add_assoc_stringl(subarray, "regex", (char*)cp, n);
cp += n;
- n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2);
+
+ n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2);
if (n < 0) {
return NULL;
}
@@ -887,7 +923,7 @@ PHP_FUNCTION(dns_get_record)
while (an-- && cp && cp < end) {
zval retval;
- cp = php_parserr(cp, &answer, type_to_fetch, store_results, raw, &retval);
+ cp = php_parserr(cp, end, &answer, type_to_fetch, store_results, raw, &retval);
if (Z_TYPE(retval) != IS_UNDEF && store_results) {
add_next_index_zval(return_value, &retval);
}
@@ -900,7 +936,7 @@ PHP_FUNCTION(dns_get_record)
while (ns-- > 0 && cp && cp < end) {
zval retval;
- cp = php_parserr(cp, &answer, DNS_T_ANY, authns != NULL, raw, &retval);
+ cp = php_parserr(cp, end, &answer, DNS_T_ANY, authns != NULL, raw, &retval);
if (Z_TYPE(retval) != IS_UNDEF) {
add_next_index_zval(authns, &retval);
}
@@ -912,7 +948,7 @@ PHP_FUNCTION(dns_get_record)
while (ar-- > 0 && cp && cp < end) {
zval retval;
- cp = php_parserr(cp, &answer, DNS_T_ANY, 1, raw, &retval);
+ cp = php_parserr(cp, end, &answer, DNS_T_ANY, 1, raw, &retval);
if (Z_TYPE(retval) != IS_UNDEF) {
add_next_index_zval(addtl, &retval);
}
diff --git a/ext/standard/dns_win32.c b/ext/standard/dns_win32.c
index f255ebba63..7decf91c5c 100644
--- a/ext/standard/dns_win32.c
+++ b/ext/standard/dns_win32.c
@@ -219,7 +219,7 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
txt_len += strlen(data_txt->pStringArray[i]) + 1;
}
- txt = STR_SAFE_ALLOC(txt_len, 2, 0, 0);
+ txt = zend_string_safe_alloc(txt_len, 2, 0, 0);
txt_dst = txt->val;
for (i = 0; i < count; i++) {
int len = strlen(data_txt->pStringArray[i]);
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index 6720231089..fe0443d59c 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -247,7 +247,7 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str)
TSRMLS_FETCH();
- cmd = STR_ALLOC(2 * l, 0);
+ cmd = zend_string_alloc(2 * l, 0);
for (x = 0, y = 0; x < l; x++) {
int mb_len = php_mblen(str + x, (l - x));
@@ -320,7 +320,7 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str)
if ((estimate - y) > 4096) {
/* realloc if the estimate was way overill
* Arbitrary cutoff point of 4096 */
- cmd = STR_REALLOC(cmd, y, 0);
+ cmd = zend_string_realloc(cmd, y, 0);
}
cmd->len = y;
@@ -339,7 +339,7 @@ PHPAPI zend_string *php_escape_shell_arg(char *str)
TSRMLS_FETCH();
- cmd = STR_ALLOC(4 * l + 2, 0); /* worst case */
+ cmd = zend_string_alloc(4 * l + 2, 0); /* worst case */
#ifdef PHP_WIN32
cmd->val[y++] = '"';
@@ -387,7 +387,7 @@ PHPAPI zend_string *php_escape_shell_arg(char *str)
if ((estimate - y) > 4096) {
/* realloc if the estimate was way overill
* Arbitrary cutoff point of 4096 */
- cmd = STR_REALLOC(cmd, y, 0);
+ cmd = zend_string_realloc(cmd, y, 0);
}
cmd->len = y;
return cmd;
@@ -470,7 +470,7 @@ PHP_FUNCTION(shell_exec)
Change the priority of the current process */
PHP_FUNCTION(proc_nice)
{
- long pri;
+ zend_long pri;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &pri) == FAILURE) {
RETURN_FALSE;
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 4551bef8cf..28fc790ea9 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -342,7 +342,7 @@ PHP_FUNCTION(flock)
zval *arg1, *arg3 = NULL;
int act;
php_stream *stream;
- long operation = 0;
+ zend_long operation = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z/", &arg1, &operation, &arg3) == FAILURE) {
return;
@@ -526,8 +526,8 @@ PHP_FUNCTION(file_get_contents)
int filename_len;
zend_bool use_include_path = 0;
php_stream *stream;
- long offset = -1;
- long maxlen = PHP_STREAM_COPY_ALL;
+ zend_long offset = -1;
+ zend_long maxlen = PHP_STREAM_COPY_ALL;
zval *zcontext = NULL;
php_stream_context *context = NULL;
zend_string *contents;
@@ -552,13 +552,13 @@ PHP_FUNCTION(file_get_contents)
}
if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position " ZEND_LONG_FMT " in the stream", offset);
php_stream_close(stream);
RETURN_FALSE;
}
if (maxlen > INT_MAX) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "maxlen truncated from %ld to %d bytes", maxlen, INT_MAX);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "maxlen truncated from %pd to %d bytes", maxlen, INT_MAX);
maxlen = INT_MAX;
}
if ((contents = php_stream_copy_to_mem(stream, maxlen, 0)) != NULL) {
@@ -579,12 +579,13 @@ PHP_FUNCTION(file_put_contents)
char *filename;
int filename_len;
zval *data;
- long numbytes = 0;
- long flags = 0;
+ zend_long numbytes = 0;
+ zend_long flags = 0;
zval *zcontext = NULL;
php_stream_context *context = NULL;
php_stream *srcstream = NULL;
char mode[3] = "wb";
+ char ret_ok = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pz/|lr!", &filename, &filename_len, &data, &flags, &zcontext) == FAILURE) {
return;
@@ -629,11 +630,11 @@ PHP_FUNCTION(file_put_contents)
case IS_RESOURCE: {
size_t len;
if (php_stream_copy_to_stream_ex(srcstream, stream, PHP_STREAM_COPY_ALL, &len) != SUCCESS) {
- numbytes = -1;
+ ret_ok = 0;
} else {
- if (len > LONG_MAX) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "content truncated from %lu to %ld bytes", (unsigned long) len, LONG_MAX);
- len = LONG_MAX;
+ if (len > ZEND_LONG_MAX) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "content truncated from %zu to " ZEND_LONG_FMT " bytes", len, ZEND_LONG_MAX);
+ len = ZEND_LONG_MAX;
}
numbytes = len;
}
@@ -650,7 +651,7 @@ PHP_FUNCTION(file_put_contents)
if (Z_STRLEN_P(data)) {
numbytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRLEN_P(data));
if (numbytes != Z_STRLEN_P(data)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %ld of %d bytes written, possibly out of free disk space", numbytes, Z_STRLEN_P(data));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %pl of %zd bytes written, possibly out of free disk space", numbytes, Z_STRLEN_P(data));
numbytes = -1;
}
}
@@ -658,7 +659,7 @@ PHP_FUNCTION(file_put_contents)
case IS_ARRAY:
if (zend_hash_num_elements(Z_ARRVAL_P(data))) {
- int bytes_written;
+ size_t bytes_written;
zval *tmp;
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), tmp) {
@@ -666,18 +667,14 @@ PHP_FUNCTION(file_put_contents)
if (str->len) {
numbytes += str->len;
bytes_written = php_stream_write(stream, str->val, str->len);
- if (bytes_written < 0 || bytes_written != str->len) {
- if (bytes_written < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %d bytes to %s", str->len, filename);
- } else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", bytes_written, str->len);
- }
- numbytes = -1;
- STR_RELEASE(str);
+ if (bytes_written != str->len) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %zd bytes to %s", str->len, filename);
+ ret_ok = 0;
+ zend_string_release(str);
break;
}
}
- STR_RELEASE(str);
+ zend_string_release(str);
} ZEND_HASH_FOREACH_END();
}
break;
@@ -689,7 +686,7 @@ PHP_FUNCTION(file_put_contents)
if (zend_std_cast_object_tostring(data, &out, IS_STRING TSRMLS_CC) == SUCCESS) {
numbytes = php_stream_write(stream, Z_STRVAL(out), Z_STRLEN(out));
if (numbytes != Z_STRLEN(out)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %ld of %d bytes written, possibly out of free disk space", numbytes, Z_STRLEN(out));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %pd of %zd bytes written, possibly out of free disk space", numbytes, Z_STRLEN(out));
numbytes = -1;
}
zval_dtor(&out);
@@ -697,12 +694,12 @@ PHP_FUNCTION(file_put_contents)
}
}
default:
- numbytes = -1;
+ ret_ok = 0;
break;
}
php_stream_close(stream);
- if (numbytes < 0) {
+ if (!ret_ok) {
RETURN_FALSE;
}
@@ -721,7 +718,7 @@ PHP_FUNCTION(file)
char *p, *s, *e;
register int i = 0;
char eol_marker = '\n';
- long flags = 0;
+ zend_long flags = 0;
zend_bool use_include_path;
zend_bool include_new_line;
zend_bool skip_blank_lines;
@@ -735,7 +732,7 @@ PHP_FUNCTION(file)
return;
}
if (flags < 0 || flags > (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES | PHP_FILE_NO_DEFAULT_CONTEXT)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "'%ld' flag is not supported", flags);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "'" ZEND_LONG_FMT "' flag is not supported", flags);
RETURN_FALSE;
}
@@ -798,7 +795,7 @@ parse_eol:
}
if (target_buf) {
- STR_FREE(target_buf);
+ zend_string_free(target_buf);
}
php_stream_close(stream);
}
@@ -835,7 +832,7 @@ PHP_FUNCTION(tempnam)
RETVAL_STRING(opened_path);
efree(opened_path);
}
- STR_RELEASE(p);
+ zend_string_release(p);
}
/* }}} */
@@ -906,7 +903,7 @@ PHPAPI PHP_FUNCTION(fclose)
PHP_STREAM_TO_ZVAL(stream, arg1);
if ((stream->flags & PHP_STREAM_FLAG_NO_FCLOSE) != 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a valid stream resource", stream->res->handle);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%pd is not a valid stream resource", stream->res->handle);
RETURN_FALSE;
}
@@ -1010,7 +1007,7 @@ PHPAPI PHP_FUNCTION(feof)
PHPAPI PHP_FUNCTION(fgets)
{
zval *arg1;
- long len = 1024;
+ zend_long len = 1024;
char *buf = NULL;
int argc = ZEND_NUM_ARGS();
size_t line_len = 0;
@@ -1094,7 +1091,7 @@ PHPAPI PHP_FUNCTION(fgetc)
PHPAPI PHP_FUNCTION(fgetss)
{
zval *fd;
- long bytes = 0;
+ zend_long bytes = 0;
size_t len = 0;
size_t actual_len, retval_len;
char *buf = NULL, *retval;
@@ -1200,7 +1197,7 @@ PHPAPI PHP_FUNCTION(fwrite)
int arg2len;
int ret;
int num_bytes;
- long arg3 = 0;
+ zend_long arg3 = 0;
char *buffer = NULL;
php_stream *stream;
@@ -1276,7 +1273,7 @@ PHPAPI PHP_FUNCTION(rewind)
PHPAPI PHP_FUNCTION(ftell)
{
zval *arg1;
- long ret;
+ zend_long ret;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
@@ -1298,7 +1295,7 @@ PHPAPI PHP_FUNCTION(ftell)
PHPAPI PHP_FUNCTION(fseek)
{
zval *arg1;
- long arg2, whence = SEEK_SET;
+ zend_long arg2, whence = SEEK_SET;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &arg2, &whence) == FAILURE) {
@@ -1315,7 +1312,7 @@ PHPAPI PHP_FUNCTION(fseek)
*/
/* DEPRECATED APIs: Use php_stream_mkdir() instead */
-PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC)
+PHPAPI int php_mkdir_ex(const char *dir, zend_long mode, int options TSRMLS_DC)
{
int ret;
@@ -1330,7 +1327,7 @@ PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC)
return ret;
}
-PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC)
+PHPAPI int php_mkdir(const char *dir, zend_long mode TSRMLS_DC)
{
return php_mkdir_ex(dir, mode, REPORT_ERRORS TSRMLS_CC);
}
@@ -1343,7 +1340,7 @@ PHP_FUNCTION(mkdir)
char *dir;
int dir_len;
zval *zcontext = NULL;
- long mode = 0777;
+ zend_long mode = 0777;
zend_bool recursive = 0;
php_stream_context *context;
@@ -1409,7 +1406,7 @@ PHP_FUNCTION(readfile)
Return or change the umask */
PHP_FUNCTION(umask)
{
- long arg1 = 0;
+ zend_long arg1 = 0;
int oldumask;
oldumask = umask(077);
@@ -1524,7 +1521,7 @@ PHP_FUNCTION(unlink)
PHP_NAMED_FUNCTION(php_if_ftruncate)
{
zval *fp;
- long size;
+ zend_long size;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &fp, &size) == FAILURE) {
@@ -1767,7 +1764,7 @@ safe_to_copy:
PHPAPI PHP_FUNCTION(fread)
{
zval *arg1;
- long len;
+ zend_long len;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &len) == FAILURE) {
@@ -1781,7 +1778,7 @@ PHPAPI PHP_FUNCTION(fread)
RETURN_FALSE;
}
- ZVAL_NEW_STR(return_value, STR_ALLOC(len, 0));
+ ZVAL_NEW_STR(return_value, zend_string_alloc(len, 0));
Z_STRLEN_P(return_value) = php_stream_read(stream, Z_STRVAL_P(return_value), len);
/* needed because recv/read/gzread doesnt put a null at the end*/
@@ -1891,8 +1888,8 @@ PHP_FUNCTION(fputcsv)
}
/* }}} */
-/* {{{ PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC) */
-PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC)
+/* {{{ PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC) */
+PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC)
{
int count, i = 0, ret;
zval *field_tmp;
@@ -1935,7 +1932,7 @@ PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char en
if (++i != count) {
smart_str_appendl(&csvline, &delimiter, 1);
}
- STR_RELEASE(field_str);
+ zend_string_release(field_str);
} ZEND_HASH_FOREACH_END();
smart_str_appendc(&csvline, '\n');
@@ -1959,7 +1956,7 @@ PHP_FUNCTION(fgetcsv)
/* first section exactly as php_fgetss */
- long len = 0;
+ zend_long len = 0;
size_t buf_len;
char *buf;
php_stream *stream;
@@ -2457,7 +2454,7 @@ PHP_FUNCTION(fnmatch)
{
char *pattern, *filename;
int pattern_len, filename_len;
- long flags = 0;
+ zend_long flags = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pp|l", &pattern, &pattern_len, &filename, &filename_len, &flags) == FAILURE) {
return;
diff --git a/ext/standard/file.h b/ext/standard/file.h
index 9c044aff1e..4551d5ec44 100644
--- a/ext/standard/file.h
+++ b/ext/standard/file.h
@@ -77,10 +77,10 @@ PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC);
PHPAPI int php_copy_file(const char *src, const char *dest TSRMLS_DC);
PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_chk TSRMLS_DC);
PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC);
-PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC);
-PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC);
+PHPAPI int php_mkdir_ex(const char *dir, zend_long mode, int options TSRMLS_DC);
+PHPAPI int php_mkdir(const char *dir, zend_long mode TSRMLS_DC);
PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char escape_char, size_t buf_len, char *buf, zval *return_value TSRMLS_DC);
-PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC);
+PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC);
#define META_DEF_BUFSIZE 8192
@@ -117,8 +117,8 @@ php_meta_tags_token php_next_meta_token(php_meta_tags_data * TSRMLS_DC);
typedef struct {
int pclose_ret;
size_t def_chunk_size;
- long auto_detect_line_endings;
- long default_socket_timeout;
+ zend_long auto_detect_line_endings;
+ zend_long default_socket_timeout;
char *user_agent; /* for the http wrapper */
char *from_address; /* for the ftp and http wrappers */
const char *user_stream_current_filename; /* for simple recursion protection */
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
index 9fb35ef344..a081fdf4f0 100644
--- a/ext/standard/filestat.c
+++ b/ext/standard/filestat.c
@@ -158,7 +158,7 @@ static int php_disk_total_space(char *path, double *space TSRMLS_DC) /* {{{ */
/* i know - this is ugly, but i works <thies@thieso.net> */
bytestotal = TotalNumberOfBytes.HighPart *
- (double) (((unsigned long)1) << 31) * 2.0 +
+ (double) (((zend_ulong)1) << 31) * 2.0 +
TotalNumberOfBytes.LowPart;
} else { /* If it's not available, we just use GetDiskFreeSpace */
if (GetDiskFreeSpace(path,
@@ -290,7 +290,7 @@ static int php_disk_free_space(char *path, double *space TSRMLS_DC) /* {{{ */
/* i know - this is ugly, but i works <thies@thieso.net> */
bytesfree = FreeBytesAvailableToCaller.HighPart *
- (double) (((unsigned long)1) << 31) * 2.0 +
+ (double) (((zend_ulong)1) << 31) * 2.0 +
FreeBytesAvailableToCaller.LowPart;
} else { /* If it's not available, we just use GetDiskFreeSpace */
if (GetDiskFreeSpace(path,
@@ -668,7 +668,7 @@ PHP_FUNCTION(chmod)
{
char *filename;
int filename_len;
- long mode;
+ zend_long mode;
int ret;
mode_t imode;
php_stream_wrapper *wrapper;
@@ -714,7 +714,7 @@ PHP_FUNCTION(touch)
{
char *filename;
int filename_len;
- long filetime = 0, fileatime = 0;
+ zend_long filetime = 0, fileatime = 0;
int ret, argc = ZEND_NUM_ARGS();
FILE *file;
struct utimbuf newtimebuf;
@@ -850,7 +850,7 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
{
zval stat_dev, stat_ino, stat_mode, stat_nlink, stat_uid, stat_gid, stat_rdev,
stat_size, stat_atime, stat_mtime, stat_ctime, stat_blksize, stat_blocks;
- struct stat *stat_sb;
+ zend_stat_t *stat_sb;
php_stream_statbuf ssb;
int flags = 0, rmask=S_IROTH, wmask=S_IWOTH, xmask=S_IXOTH; /* access rights defaults to other */
char *stat_sb_names[13] = {
@@ -962,21 +962,21 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
switch (type) {
case FS_PERMS:
- RETURN_LONG((long)ssb.sb.st_mode);
+ RETURN_LONG((zend_long)ssb.sb.st_mode);
case FS_INODE:
- RETURN_LONG((long)ssb.sb.st_ino);
+ RETURN_LONG((zend_long)ssb.sb.st_ino);
case FS_SIZE:
- RETURN_LONG((long)ssb.sb.st_size);
+ RETURN_LONG((zend_long)ssb.sb.st_size);
case FS_OWNER:
- RETURN_LONG((long)ssb.sb.st_uid);
+ RETURN_LONG((zend_long)ssb.sb.st_uid);
case FS_GROUP:
- RETURN_LONG((long)ssb.sb.st_gid);
+ RETURN_LONG((zend_long)ssb.sb.st_gid);
case FS_ATIME:
- RETURN_LONG((long)ssb.sb.st_atime);
+ RETURN_LONG((zend_long)ssb.sb.st_atime);
case FS_MTIME:
- RETURN_LONG((long)ssb.sb.st_mtime);
+ RETURN_LONG((zend_long)ssb.sb.st_mtime);
case FS_CTIME:
- RETURN_LONG((long)ssb.sb.st_ctime);
+ RETURN_LONG((zend_long)ssb.sb.st_ctime);
case FS_TYPE:
if (S_ISLNK(ssb.sb.st_mode)) {
RETURN_STRING("link");
@@ -1223,7 +1223,7 @@ PHP_FUNCTION(realpath_cache_get)
array_init(&entry);
/* bucket->key is unsigned long */
- if (LONG_MAX >= bucket->key) {
+ if (ZEND_LONG_MAX >= bucket->key) {
add_assoc_long(&entry, "key", bucket->key);
} else {
add_assoc_double(&entry, "key", (double)bucket->key);
diff --git a/ext/standard/filters.c b/ext/standard/filters.c
index d40321f959..f7ddbf5a39 100644
--- a/ext/standard/filters.c
+++ b/ext/standard/filters.c
@@ -1224,7 +1224,7 @@ static php_conv_err_t php_conv_get_string_prop_ex(const HashTable *ht, char **pr
*pretval_len = str->len;
memcpy(*pretval, str->val, str->len + 1);
- STR_RELEASE(str);
+ zend_string_release(str);
} else {
return PHP_CONV_ERR_NOT_FOUND;
}
@@ -1232,7 +1232,7 @@ static php_conv_err_t php_conv_get_string_prop_ex(const HashTable *ht, char **pr
}
#if IT_WAS_USED
-static php_conv_err_t php_conv_get_long_prop_ex(const HashTable *ht, long *pretval, char *field_name, size_t field_name_len)
+static php_conv_err_t php_conv_get_long_prop_ex(const HashTable *ht, zend_long *pretval, char *field_name, size_t field_name_len)
{
zval **tmpval;
@@ -1244,7 +1244,7 @@ static php_conv_err_t php_conv_get_long_prop_ex(const HashTable *ht, long *pretv
if (Z_TYPE_PP(tmpval) != IS_LONG) {
tmp = *ztval;
zval_copy_ctor(&tmp);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
ztval = &tmp;
}
*pretval = Z_LVAL_P(ztval);
@@ -1255,7 +1255,7 @@ static php_conv_err_t php_conv_get_long_prop_ex(const HashTable *ht, long *pretv
}
#endif
-static php_conv_err_t php_conv_get_ulong_prop_ex(const HashTable *ht, unsigned long *pretval, char *field_name, size_t field_name_len)
+static php_conv_err_t php_conv_get_ulong_prop_ex(const HashTable *ht, zend_ulong *pretval, char *field_name, size_t field_name_len)
{
zval *tmpval;
@@ -1266,7 +1266,7 @@ static php_conv_err_t php_conv_get_ulong_prop_ex(const HashTable *ht, unsigned l
if (Z_TYPE_P(tmpval) != IS_LONG) {
ZVAL_DUP(&tmp, tmpval);;
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
tmpval = &tmp;
}
if (Z_LVAL_P(tmpval) < 0) {
@@ -1306,7 +1306,7 @@ static php_conv_err_t php_conv_get_bool_prop_ex(const HashTable *ht, int *pretva
#if IT_WAS_USED
static int php_conv_get_int_prop_ex(const HashTable *ht, int *pretval, char *field_name, size_t field_name_len)
{
- long l;
+ zend_long l;
php_conv_err_t err;
*pretval = 0;
@@ -1320,7 +1320,7 @@ static int php_conv_get_int_prop_ex(const HashTable *ht, int *pretval, char *fie
static int php_conv_get_uint_prop_ex(const HashTable *ht, unsigned int *pretval, char *field_name, size_t field_name_len)
{
- unsigned long l;
+ zend_ulong l;
php_conv_err_t err;
*pretval = 0;
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index edd704b068..587474346a 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -52,11 +52,11 @@ static char HEXCHARS[] = "0123456789ABCDEF";
/* php_spintf_appendchar() {{{ */
inline static void
-php_sprintf_appendchar(zend_string **buffer, int *pos, char add TSRMLS_DC)
+php_sprintf_appendchar(zend_string **buffer, size_t *pos, char add TSRMLS_DC)
{
if (!*buffer || (*pos + 1) >= (*buffer)->len) {
PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(TSRMLS_C), (*buffer)->len));
- *buffer = STR_REALLOC(*buffer, (*buffer)->len << 1, 0);
+ *buffer = zend_string_realloc(*buffer, (*buffer)->len << 1, 0);
}
PRINTF_DEBUG(("sprintf: appending '%c', pos=\n", add, *pos));
(*buffer)->val[(*pos)++] = add;
@@ -65,22 +65,18 @@ php_sprintf_appendchar(zend_string **buffer, int *pos, char add TSRMLS_DC)
/* php_spintf_appendstring() {{{ */
inline static void
-php_sprintf_appendstring(zend_string **buffer, int *pos, char *add,
- int min_width, int max_width, char padding,
- int alignment, int len, int neg, int expprec, int always_sign)
+php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add,
+ size_t min_width, size_t max_width, char padding,
+ size_t alignment, size_t len, int neg, int expprec, int always_sign)
{
- register int npad;
- int req_size;
- int copy_len;
- int m_width;
+ register size_t npad;
+ size_t req_size;
+ size_t copy_len;
+ size_t m_width;
copy_len = (expprec ? MIN(max_width, len) : len);
- npad = min_width - copy_len;
+ npad = (min_width < copy_len) ? 0 : min_width - copy_len;
- if (npad < 0) {
- npad = 0;
- }
-
PRINTF_DEBUG(("sprintf: appendstring(%x, %d, %d, \"%s\", %d, '%c', %d)\n",
*buffer, *pos, (*buffer)->len, add, min_width, padding, alignment));
m_width = MAX(min_width, copy_len);
@@ -92,15 +88,15 @@ php_sprintf_appendstring(zend_string **buffer, int *pos, char *add,
req_size = *pos + m_width + 1;
if (!*buffer || req_size > (*buffer)->len) {
- int size = (*buffer)->len;
+ size_t size = (*buffer)->len;
while (req_size > size) {
- if (size > INT_MAX/2) {
- zend_error_noreturn(E_ERROR, "Field width %d is too long", req_size);
+ if (size > ZEND_SIZE_MAX/2) {
+ zend_error_noreturn(E_ERROR, "Field width %zd is too long", req_size);
}
size <<= 1;
}
PRINTF_DEBUG(("sprintf ereallocing buffer to %d bytes\n", size));
- *buffer = STR_REALLOC(*buffer, size, 0);
+ *buffer = zend_string_realloc(*buffer, size, 0);
}
if (alignment == ALIGN_RIGHT) {
if ((neg || always_sign) && padding=='0') {
@@ -126,21 +122,21 @@ php_sprintf_appendstring(zend_string **buffer, int *pos, char *add,
/* php_spintf_appendint() {{{ */
inline static void
-php_sprintf_appendint(zend_string **buffer, int *pos, long number,
- int width, char padding, int alignment,
+php_sprintf_appendint(zend_string **buffer, size_t *pos, zend_long number,
+ size_t width, char padding, size_t alignment,
int always_sign)
{
char numbuf[NUM_BUF_SIZE];
- register unsigned long magn, nmagn;
+ register zend_ulong magn, nmagn;
register unsigned int i = NUM_BUF_SIZE - 1, neg = 0;
PRINTF_DEBUG(("sprintf: appendint(%x, %x, %x, %d, %d, '%c', %d)\n",
*buffer, pos, &(*buffer)->len, number, width, padding, alignment));
if (number < 0) {
neg = 1;
- magn = ((unsigned long) -(number + 1)) + 1;
+ magn = ((zend_ulong) -(number + 1)) + 1;
} else {
- magn = (unsigned long) number;
+ magn = (zend_ulong) number;
}
/* Can't right-pad 0's on integers */
@@ -170,17 +166,17 @@ php_sprintf_appendint(zend_string **buffer, int *pos, long number,
/* php_spintf_appenduint() {{{ */
inline static void
-php_sprintf_appenduint(zend_string **buffer, int *pos,
- unsigned long number,
- int width, char padding, int alignment)
+php_sprintf_appenduint(zend_string **buffer, size_t *pos,
+ zend_ulong number,
+ size_t width, char padding, size_t alignment)
{
char numbuf[NUM_BUF_SIZE];
- register unsigned long magn, nmagn;
+ register zend_ulong magn, nmagn;
register unsigned int i = NUM_BUF_SIZE - 1;
PRINTF_DEBUG(("sprintf: appenduint(%x, %x, %x, %d, %d, '%c', %d)\n",
*buffer, pos, &(*buffer)->len, number, width, padding, alignment));
- magn = (unsigned long) number;
+ magn = (zend_ulong) number;
/* Can't right-pad 0's on integers */
if (alignment == 0 && padding == '0') padding = ' ';
@@ -202,17 +198,18 @@ php_sprintf_appenduint(zend_string **buffer, int *pos,
/* php_spintf_appenddouble() {{{ */
inline static void
-php_sprintf_appenddouble(zend_string **buffer, int *pos,
+php_sprintf_appenddouble(zend_string **buffer, size_t *pos,
double number,
- int width, char padding,
- int alignment, int precision,
+ size_t width, char padding,
+ size_t alignment, int precision,
int adjust, char fmt,
int always_sign
TSRMLS_DC)
{
char num_buf[NUM_BUF_SIZE];
char *s = NULL;
- int s_len = 0, is_negative = 0;
+ size_t s_len = 0;
+ int is_negative = 0;
#ifdef HAVE_LOCALE_H
struct lconv *lconv;
#endif
@@ -293,13 +290,13 @@ php_sprintf_appenddouble(zend_string **buffer, int *pos,
/* php_spintf_appendd2n() {{{ */
inline static void
-php_sprintf_append2n(zend_string **buffer, int *pos, long number,
- int width, char padding, int alignment, int n,
+php_sprintf_append2n(zend_string **buffer, size_t *pos, zend_long number,
+ size_t width, char padding, size_t alignment, int n,
char *chartable, int expprec)
{
char numbuf[NUM_BUF_SIZE];
- register unsigned long num;
- register unsigned int i = NUM_BUF_SIZE - 1;
+ register zend_ulong num;
+ register zend_ulong i = NUM_BUF_SIZE - 1;
register int andbits = (1 << n) - 1;
PRINTF_DEBUG(("sprintf: append2n(%x, %x, %x, %d, %d, '%c', %d, %d, %x)\n",
@@ -307,7 +304,7 @@ php_sprintf_append2n(zend_string **buffer, int *pos, long number,
chartable));
PRINTF_DEBUG(("sprintf: append2n 2^%d andbits=%x\n", n, andbits));
- num = (unsigned long) number;
+ num = (zend_ulong) number;
numbuf[i] = '\0';
do {
@@ -324,11 +321,11 @@ php_sprintf_append2n(zend_string **buffer, int *pos, long number,
/* php_spintf_getnumber() {{{ */
inline static int
-php_sprintf_getnumber(char *buffer, int *pos)
+php_sprintf_getnumber(char *buffer, size_t *pos)
{
char *endptr;
- register long num = strtol(&buffer[*pos], &endptr, 10);
- register int i = 0;
+ register zend_long num = ZEND_STRTOL(&buffer[*pos], &endptr, 10);
+ register size_t i = 0;
if (endptr != NULL) {
i = (endptr - &buffer[*pos]);
@@ -373,7 +370,8 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
{
zval *newargs = NULL;
zval *args, *z_format;
- int argc, size = 240, inpos = 0, outpos = 0, temppos;
+ int argc;
+ size_t size = 240, inpos = 0, outpos = 0, temppos;
int alignment, currarg, adjusting, argnum, width, precision;
char *format, padding;
zend_string *result;
@@ -417,7 +415,7 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
format = Z_STRVAL(args[format_offset]);
format_len = Z_STRLEN(args[format_offset]);
- result = STR_ALLOC(size, 0);
+ result = zend_string_alloc(size, 0);
currarg = 1;
@@ -563,7 +561,7 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
alignment,
str->len,
0, expprec, 0);
- STR_RELEASE(str);
+ zend_string_release(str);
break;
}
@@ -680,13 +678,13 @@ PHP_FUNCTION(vsprintf)
PHP_FUNCTION(user_printf)
{
zend_string *result;
- int rlen;
+ size_t rlen;
if ((result=php_formatted_print(ZEND_NUM_ARGS(), 0, 0 TSRMLS_CC))==NULL) {
RETURN_FALSE;
}
rlen = PHPWRITE(result->val, result->len);
- STR_FREE(result);
+ zend_string_free(result);
RETURN_LONG(rlen);
}
/* }}} */
@@ -696,13 +694,13 @@ PHP_FUNCTION(user_printf)
PHP_FUNCTION(vprintf)
{
zend_string *result;
- int rlen;
+ size_t rlen;
if ((result=php_formatted_print(ZEND_NUM_ARGS(), 1, 0 TSRMLS_CC))==NULL) {
RETURN_FALSE;
}
rlen = PHPWRITE(result->val, result->len);
- STR_FREE(result);
+ zend_string_free(result);
RETURN_LONG(rlen);
}
/* }}} */
@@ -732,7 +730,7 @@ PHP_FUNCTION(fprintf)
php_stream_write(stream, result->val, result->len);
RETVAL_LONG(result->len);
- STR_FREE(result);
+ zend_string_free(result);
}
/* }}} */
@@ -761,7 +759,7 @@ PHP_FUNCTION(vfprintf)
php_stream_write(stream, result->val, result->len);
RETVAL_LONG(result->len);
- STR_FREE(result);
+ zend_string_free(result);
}
/* }}} */
diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c
index 300df8c1c0..319a0437d6 100644
--- a/ext/standard/fsock.c
+++ b/ext/standard/fsock.c
@@ -33,16 +33,16 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
char *host;
int host_len;
- long port = -1;
+ zend_long port = -1;
zval *zerrno = NULL, *zerrstr = NULL;
double timeout = FG(default_socket_timeout);
- unsigned long conv;
+ zend_ulong conv;
struct timeval tv;
char *hashkey = NULL;
php_stream *stream = NULL;
int err;
char *hostname = NULL;
- long hostname_len;
+ zend_long hostname_len;
zend_string *errstr = NULL;
RETVAL_FALSE;
@@ -52,11 +52,11 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
if (persistent) {
- spprintf(&hashkey, 0, "pfsockopen__%s:%ld", host, port);
+ spprintf(&hashkey, 0, "pfsockopen__%s:" ZEND_LONG_FMT, host, port);
}
if (port > 0) {
- hostname_len = spprintf(&hostname, 0, "%s:%ld", host, port);
+ hostname_len = spprintf(&hostname, 0, "%s:" ZEND_LONG_FMT, host, port);
} else {
hostname_len = host_len;
hostname = host;
@@ -83,7 +83,7 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
efree(hostname);
}
if (stream == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect to %s:%ld (%s)", host, port, errstr == NULL ? "Unknown error" : errstr->val);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect to %s:" ZEND_LONG_FMT " (%s)", host, port, errstr == NULL ? "Unknown error" : errstr->val);
}
if (hashkey) {
@@ -100,14 +100,14 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
zval_dtor(zerrstr);
ZVAL_STR(zerrstr, errstr);
} else if (!zerrstr && errstr) {
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
}
RETURN_FALSE;
}
if (errstr) {
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
}
php_stream_to_zval(stream, return_value);
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c
index 31b96fb68c..cb96c190db 100644
--- a/ext/standard/ftp_fopen_wrapper.c
+++ b/ext/standard/ftp_fopen_wrapper.c
@@ -531,10 +531,10 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa
(tmpzval = php_stream_context_get_option(context, "ftp", "resume_pos")) != NULL &&
Z_TYPE_P(tmpzval) == IS_LONG &&
Z_LVAL_P(tmpzval) > 0) {
- php_stream_printf(stream TSRMLS_CC, "REST %ld\r\n", Z_LVAL_P(tmpzval));
+ php_stream_printf(stream TSRMLS_CC, "REST %pd\r\n", Z_LVAL_P(tmpzval));
result = GET_FTP_RESULT(stream);
if (result < 300 || result > 399) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to resume from offset %ld", Z_LVAL_P(tmpzval));
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to resume from offset %pd", Z_LVAL_P(tmpzval));
goto errexit;
}
}
@@ -632,7 +632,7 @@ static size_t php_ftp_dirstream_read(php_stream *stream, char *buf, size_t count
tmp_len = MIN(sizeof(ent->d_name), basename->len - 1);
memcpy(ent->d_name, basename->val, tmp_len);
ent->d_name[tmp_len - 1] = '\0';
- STR_RELEASE(basename);
+ zend_string_release(basename);
/* Trim off trailing whitespace characters */
tmp_len--;
diff --git a/ext/standard/head.c b/ext/standard/head.c
index ad82b9fbbf..b53740563d 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -97,7 +97,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
encoded_value = php_url_encode(value, value_len);
len += encoded_value->len;
} else if (value) {
- encoded_value = STR_INIT(value, value_len, 0);
+ encoded_value = zend_string_init(value, value_len, 0);
len += encoded_value->len;
}
@@ -118,7 +118,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
*/
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; Max-Age=0", name, dt->val);
- STR_FREE(dt);
+ zend_string_free(dt);
} else {
snprintf(cookie, len + 100, "Set-Cookie: %s=%s", name, value ? encoded_value->val : "");
if (expires > 0) {
@@ -129,14 +129,14 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
/* check to make sure that the year does not exceed 4 digits in length */
p = zend_memrchr(dt->val, '-', dt->len);
if (!p || *(p + 5) != ' ') {
- STR_FREE(dt);
+ zend_string_free(dt);
efree(cookie);
- STR_FREE(encoded_value);
+ zend_string_free(encoded_value);
zend_error(E_WARNING, "Expiry date cannot have a year greater than 9999");
return FAILURE;
}
strlcat(cookie, dt->val, len + 100);
- STR_FREE(dt);
+ zend_string_free(dt);
snprintf(tsdelta, sizeof(tsdelta), "%li", (long) difftime(expires, time(NULL)));
strlcat(cookie, COOKIE_MAX_AGE, len + 100);
@@ -145,7 +145,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
}
if (encoded_value) {
- STR_FREE(encoded_value);
+ zend_string_free(encoded_value);
}
if (path && path_len > 0) {
@@ -178,7 +178,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
PHP_FUNCTION(setcookie)
{
char *name, *value = NULL, *path = NULL, *domain = NULL;
- long expires = 0;
+ zend_long expires = 0;
zend_bool secure = 0, httponly = 0;
int name_len, value_len = 0, path_len = 0, domain_len = 0;
@@ -201,7 +201,7 @@ PHP_FUNCTION(setcookie)
PHP_FUNCTION(setrawcookie)
{
char *name, *value = NULL, *path = NULL, *domain = NULL;
- long expires = 0;
+ zend_long expires = 0;
zend_bool secure = 0, httponly = 0;
int name_len, value_len = 0, path_len = 0, domain_len = 0;
@@ -289,7 +289,7 @@ PHP_FUNCTION(headers_list)
Sets a response code, or returns the current HTTP response code */
PHP_FUNCTION(http_response_code)
{
- long response_code = 0;
+ zend_long response_code = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &response_code) == FAILURE) {
return;
@@ -297,7 +297,7 @@ PHP_FUNCTION(http_response_code)
if (response_code)
{
- long old_response_code;
+ zend_long old_response_code;
old_response_code = SG(sapi_headers).http_response_code;
SG(sapi_headers).http_response_code = response_code;
diff --git a/ext/standard/html.c b/ext/standard/html.c
index 360639ea76..a9e5fbfe9d 100644
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@ -790,7 +790,7 @@ static inline int numeric_entity_is_allowed(unsigned uni_cp, int document_type)
*/
static inline int process_numeric_entity(const char **buf, unsigned *code_point)
{
- long code_l;
+ zend_long code_l;
int hexadecimal = (**buf == 'x' || **buf == 'X'); /* TODO: XML apparently disallows "X" */
char *endptr;
@@ -804,7 +804,7 @@ static inline int process_numeric_entity(const char **buf, unsigned *code_point)
return FAILURE;
}
- code_l = strtol(*buf, &endptr, hexadecimal ? 16 : 10);
+ code_l = ZEND_STRTOL(*buf, &endptr, hexadecimal ? 16 : 10);
/* we're guaranteed there were valid digits, so *endptr > buf */
*buf = endptr;
@@ -813,7 +813,7 @@ static inline int process_numeric_entity(const char **buf, unsigned *code_point)
/* many more are invalid, but that depends on whether it's HTML
* (and which version) or XML. */
- if (code_l > 0x10FFFFL)
+ if (code_l > Z_I(0x10FFFF))
return FAILURE;
if (code_point != NULL)
@@ -856,7 +856,7 @@ static inline int process_named_entity_html(const char **buf, const char **start
static inline int resolve_named_entity_html(const char *start, size_t length, const entity_ht *ht, unsigned *uni_cp1, unsigned *uni_cp2)
{
const entity_cp_map *s;
- ulong hash = zend_inline_hash_func(start, length);
+ zend_ulong hash = zend_inline_hash_func(start, length);
s = ht->buckets[hash % ht->num_elems];
while (s->entity) {
@@ -1112,11 +1112,11 @@ PHPAPI zend_string *php_unescape_html_entities(unsigned char *old, size_t oldlen
if (oldlen > new_size) {
/* overflow, refuse to do anything */
- ret = STR_INIT((char*)old, oldlen, 0);
+ ret = zend_string_init((char*)old, oldlen, 0);
retlen = oldlen;
goto empty_source;
}
- ret = STR_ALLOC(new_size, 0);
+ ret = zend_string_alloc(new_size, 0);
ret->val[0] = '\0';
ret->len = oldlen;
retlen = oldlen;
@@ -1275,7 +1275,7 @@ PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldle
}
}
- replaced = STR_ALLOC(maxlen, 0);
+ replaced = zend_string_alloc(maxlen, 0);
len = 0;
cursor = 0;
while (cursor < oldlen) {
@@ -1288,7 +1288,7 @@ PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldle
/* guarantee we have at least 40 bytes to write.
* In HTML5, entities may take up to 33 bytes */
if (len > maxlen - 40) { /* maxlen can never be smaller than 128 */
- replaced = STR_SAFE_REALLOC(replaced, maxlen, 1, 128, 0);
+ replaced = zend_string_safe_realloc(replaced, maxlen, 1, 128, 0);
maxlen += 128;
}
@@ -1301,7 +1301,7 @@ PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldle
len += replacement_len;
continue;
} else {
- STR_FREE(replaced);
+ zend_string_free(replaced);
return STR_EMPTY_ALLOC();
}
} else { /* SUCCESS */
@@ -1420,7 +1420,7 @@ encode_amp:
/* at this point maxlen - len >= 40 */
if (maxlen - len < ent_len + 2 /* & and ; */) {
/* ent_len < oldlen, which is certainly <= SIZE_MAX/2 */
- replaced = STR_SAFE_REALLOC(replaced, maxlen, 1, ent_len + 128, 0);
+ replaced = zend_string_safe_realloc(replaced, maxlen, 1, ent_len + 128, 0);
maxlen += ent_len + 128;
}
replaced->val[len++] = '&';
@@ -1442,30 +1442,30 @@ encode_amp:
*/
static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
{
- char *str, *hint_charset = NULL;
- int str_len, hint_charset_len = 0;
- long flags = ENT_COMPAT;
+ zend_string *str, *hint_charset = NULL;
+ char *default_charset;
+ zend_long flags = ENT_COMPAT;
zend_string *replaced;
zend_bool double_encode = 1;
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls!b", &str, &str_len, &flags, &hint_charset, &hint_charset_len, &double_encode) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|lS!b", &str, &flags, &hint_charset, &double_encode) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(1, 4)
- Z_PARAM_STRING(str, str_len)
+ Z_PARAM_STR(str)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(flags)
- Z_PARAM_STRING_EX(hint_charset, hint_charset_len, 1, 0)
+ Z_PARAM_STR_EX(hint_charset, 1, 0)
Z_PARAM_BOOL(double_encode);
ZEND_PARSE_PARAMETERS_END();
#endif
if (!hint_charset) {
- hint_charset = get_default_charset(TSRMLS_C);
+ default_charset = get_default_charset(TSRMLS_C);
}
- replaced = php_escape_html_entities_ex((unsigned char*)str, str_len, all, (int) flags, hint_charset, double_encode TSRMLS_CC);
+ replaced = php_escape_html_entities_ex((unsigned char*)str->val, str->len, all, (int) flags, (hint_charset ? hint_charset->val : default_charset), double_encode TSRMLS_CC);
RETVAL_STR(replaced);
}
/* }}} */
@@ -1506,7 +1506,7 @@ PHP_FUNCTION(htmlspecialchars_decode)
{
char *str;
int str_len;
- long quote_style = ENT_COMPAT;
+ zend_long quote_style = ENT_COMPAT;
zend_string *replaced;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len, &quote_style) == FAILURE) {
@@ -1525,30 +1525,30 @@ PHP_FUNCTION(htmlspecialchars_decode)
Convert all HTML entities to their applicable characters */
PHP_FUNCTION(html_entity_decode)
{
- char *str, *hint_charset = NULL;
- int str_len, hint_charset_len = 0;
+ zend_string *str, *hint_charset = NULL;
+ char *default_charset;
size_t new_len = 0;
- long quote_style = ENT_COMPAT;
+ zend_long quote_style = ENT_COMPAT;
zend_string *replaced;
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &str, &str_len,
- &quote_style, &hint_charset, &hint_charset_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|lS", &str,
+ &quote_style, &hint_charset) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(1, 3)
- Z_PARAM_STRING(str, str_len)
+ Z_PARAM_STR(str)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(quote_style)
- Z_PARAM_STRING(hint_charset, hint_charset_len)
+ Z_PARAM_STR(hint_charset)
ZEND_PARSE_PARAMETERS_END();
#endif
if (!hint_charset) {
- hint_charset = get_default_charset(TSRMLS_C);
+ default_charset = get_default_charset(TSRMLS_C);
}
- replaced = php_unescape_html_entities((unsigned char*)str, str_len, 1 /*all*/, quote_style, hint_charset TSRMLS_CC);
+ replaced = php_unescape_html_entities((unsigned char*)str->val, str->len, 1 /*all*/, quote_style, (hint_charset ? hint_charset->val : default_charset) TSRMLS_CC);
if (replaced) {
RETURN_STR(replaced);
@@ -1626,7 +1626,7 @@ static inline void write_s3row_data(
Returns the internal translation table used by htmlspecialchars and htmlentities */
PHP_FUNCTION(get_html_translation_table)
{
- long all = HTML_SPECIALCHARS,
+ zend_long all = HTML_SPECIALCHARS,
flags = ENT_COMPAT;
int doctype;
entity_table_opt entity_table;
diff --git a/ext/standard/http.c b/ext/standard/http.c
index 34b8e79389..609a6ffa65 100644
--- a/ext/standard/http.c
+++ b/ext/standard/http.c
@@ -35,7 +35,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
char *newprefix, *p;
const char *prop_name;
int arg_sep_len, newprefix_len, prop_len;
- ulong idx;
+ zend_ulong idx;
zval *zdata = NULL, copyzval;
if (!ht) {
@@ -95,7 +95,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
memcpy(p, ekey->val, ekey->len);
p += ekey->len;
- STR_FREE(ekey);
+ zend_string_free(ekey);
if (key_suffix) {
memcpy(p, key_suffix, key_suffix_len);
@@ -109,7 +109,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
char *ekey;
int ekey_len;
/* Is an integer key */
- ekey_len = spprintf(&ekey, 0, "%ld", idx);
+ ekey_len = spprintf(&ekey, 0, "%pd", idx);
newprefix_len = key_prefix_len + num_prefix_len + ekey_len + key_suffix_len + 3 /* %5B */;
newprefix = emalloc(newprefix_len + 1);
p = newprefix;
@@ -160,7 +160,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
ekey = php_url_encode(prop_name, prop_len);
}
smart_str_appendl(formstr, ekey->val, ekey->len);
- STR_FREE(ekey);
+ zend_string_free(ekey);
} else {
char *ekey;
int ekey_len;
@@ -168,7 +168,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
if (num_prefix) {
smart_str_appendl(formstr, num_prefix, num_prefix_len);
}
- ekey_len = spprintf(&ekey, 0, "%ld", idx);
+ ekey_len = spprintf(&ekey, 0, "%pd", idx);
smart_str_appendl(formstr, ekey, ekey_len);
efree(ekey);
}
@@ -183,14 +183,14 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
ekey = php_url_encode(Z_STRVAL_P(zdata), Z_STRLEN_P(zdata));
}
smart_str_appendl(formstr, ekey->val, ekey->len);
- STR_FREE(ekey);
+ zend_string_free(ekey);
}
break;
case IS_LONG:
{
char *ekey;
int ekey_len;
- ekey_len = spprintf(&ekey, 0, "%ld", Z_LVAL_P(zdata));
+ ekey_len = spprintf(&ekey, 0, "%pd", Z_LVAL_P(zdata));
smart_str_appendl(formstr, ekey, ekey_len);
efree(ekey);
}
@@ -223,7 +223,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
}
smart_str_appendl(formstr, ekey->val, ekey->len);
zval_ptr_dtor(&copyzval);
- STR_FREE(ekey);
+ zend_string_free(ekey);
}
}
}
@@ -241,7 +241,7 @@ PHP_FUNCTION(http_build_query)
char *prefix = NULL, *arg_sep=NULL;
int arg_sep_len = 0, prefix_len = 0;
smart_str formstr = {0};
- long enc_type = PHP_QUERY_RFC1738;
+ zend_long enc_type = PHP_QUERY_RFC1738;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ssl", &formdata, &prefix, &prefix_len, &arg_sep, &arg_sep_len, &enc_type) != SUCCESS) {
RETURN_FALSE;
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index 73952dda31..4bf86a4947 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -218,7 +218,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
if (errstr) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", errstr->val);
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
errstr = NULL;
}
@@ -537,7 +537,7 @@ finish:
php_stream_notify_info(context, PHP_STREAM_NOTIFY_AUTH_REQUIRED, NULL, 0);
}
- STR_FREE(stmp);
+ zend_string_free(stmp);
}
/* if the user has configured who they are, send a From: line */
@@ -749,7 +749,7 @@ finish:
/* create filter to decode response body */
if (!(options & STREAM_ONLY_GET_HEADERS)) {
- long decode = 1;
+ zend_long decode = 1;
if (context && (tmpzval = php_stream_context_get_option(context, "http", "auto_decode")) != NULL) {
decode = zend_is_true(tmpzval TSRMLS_CC);
diff --git a/ext/standard/image.c b/ext/standard/image.c
index 0ec4cd3885..79e26c6310 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -237,7 +237,7 @@ static struct gfxinfo *php_handle_swc(php_stream * stream TSRMLS_DC)
} while ((status==Z_BUF_ERROR)&&(factor<maxfactor));
if (bufz) {
- STR_RELEASE(bufz);
+ zend_string_release(bufz);
}
if (status == Z_OK) {
@@ -1160,7 +1160,7 @@ PHPAPI char * php_image_type_to_mime_type(int image_type)
Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype */
PHP_FUNCTION(image_type_to_mime_type)
{
- long p_image_type;
+ zend_long p_image_type;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &p_image_type) == FAILURE) {
return;
@@ -1174,7 +1174,7 @@ PHP_FUNCTION(image_type_to_mime_type)
Get file extension for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype */
PHP_FUNCTION(image_type_to_extension)
{
- long image_type;
+ zend_long image_type;
zend_bool inc_dot=1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|b", &image_type, &inc_dot) == FAILURE) {
diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c
index fb63703792..4a6a39d4ed 100644
--- a/ext/standard/incomplete_class.c
+++ b/ext/standard/incomplete_class.c
@@ -42,7 +42,7 @@ static void incomplete_class_message(zval *object, int error_type TSRMLS_DC)
if (class_name) {
php_error_docref(NULL TSRMLS_CC, error_type, INCOMPLETE_CLASS_MSG, class_name->val);
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
} else {
php_error_docref(NULL TSRMLS_CC, error_type, INCOMPLETE_CLASS_MSG, "unknown");
}
@@ -141,7 +141,7 @@ PHPAPI zend_string *php_lookup_class_name(zval *object)
object_properties = Z_OBJPROP_P(object);
if ((val = zend_hash_str_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER)-1)) != NULL) {
- return STR_COPY(Z_STR_P(val));
+ return zend_string_copy(Z_STR_P(val));
}
return NULL;
@@ -150,7 +150,7 @@ PHPAPI zend_string *php_lookup_class_name(zval *object)
/* {{{ php_store_class_name
*/
-PHPAPI void php_store_class_name(zval *object, const char *name, zend_uint len)
+PHPAPI void php_store_class_name(zval *object, const char *name, uint32_t len)
{
zval val;
TSRMLS_FETCH();
diff --git a/ext/standard/info.c b/ext/standard/info.c
index 47249466b0..d0d1d114e6 100644
--- a/ext/standard/info.c
+++ b/ext/standard/info.c
@@ -69,7 +69,7 @@ static int php_info_print_html_esc(const char *str, int len) /* {{{ */
new_str = php_escape_html_entities((unsigned char *) str, len, 0, ENT_QUOTES, "utf-8" TSRMLS_CC);
written = php_output_write(new_str->val, new_str->len TSRMLS_CC);
- STR_FREE(new_str);
+ zend_string_free(new_str);
return written;
}
/* }}} */
@@ -196,10 +196,10 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
{
zval *data, *tmp, tmp2;
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
zend_string *key;
- key = STR_INIT(name, name_length, 0);
+ key = zend_string_init(name, name_length, 0);
zend_is_auto_global(key TSRMLS_CC);
if ((data = zend_hash_find(&EG(symbol_table).ht, key)) != NULL && (Z_TYPE_P(data) == IS_ARRAY)) {
@@ -219,7 +219,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
php_info_print(string_key->val);
}
} else {
- php_info_printf("%ld", num_key);
+ php_info_printf("%pd", num_key);
}
php_info_print("\"]");
if (!sapi_module.phpinfo_as_text) {
@@ -264,7 +264,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
}
} ZEND_HASH_FOREACH_END();
}
- STR_FREE(key);
+ zend_string_free(key);
}
/* }}} */
@@ -655,7 +655,7 @@ PHPAPI zend_string *php_get_uname(char mode)
php_uname = PHP_UNAME;
#endif
#endif
- return STR_INIT(php_uname, strlen(php_uname), 0);
+ return zend_string_init(php_uname, strlen(php_uname), 0);
}
/* }}} */
@@ -833,7 +833,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
zend_html_puts(zend_version, strlen(zend_version) TSRMLS_CC);
}
php_info_print_box_end();
- STR_FREE(php_uname);
+ zend_string_free(php_uname);
}
zend_ini_sort_entries(TSRMLS_C);
@@ -1166,7 +1166,7 @@ void register_phpinfo_constants(INIT_FUNC_ARGS)
Output a page of useful information about PHP and the current request */
PHP_FUNCTION(phpinfo)
{
- long flag = PHP_INFO_ALL;
+ zend_long flag = PHP_INFO_ALL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) {
return;
@@ -1210,7 +1210,7 @@ PHP_FUNCTION(phpversion)
Prints the list of people who've contributed to the PHP project */
PHP_FUNCTION(phpcredits)
{
- long flag = PHP_CREDITS_ALL;
+ zend_long flag = PHP_CREDITS_ALL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) {
return;
diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c
index cea43dd8d3..daf667df87 100644
--- a/ext/standard/iptc.c
+++ b/ext/standard/iptc.c
@@ -179,7 +179,7 @@ PHP_FUNCTION(iptcembed)
{
char *iptcdata, *jpeg_file;
int iptcdata_len, jpeg_file_len;
- long spool = 0;
+ zend_long spool = 0;
FILE *fp;
unsigned int marker, done = 0;
int inx;
@@ -334,8 +334,8 @@ PHP_FUNCTION(iptcparse)
if((inx+6) >= str_len) {
break;
}
- len = (((long) buffer[ inx + 2 ]) << 24) + (((long) buffer[ inx + 3 ]) << 16) +
- (((long) buffer[ inx + 4 ]) << 8) + (((long) buffer[ inx + 5 ]));
+ len = (((zend_long) buffer[ inx + 2 ]) << 24) + (((zend_long) buffer[ inx + 3 ]) << 16) +
+ (((zend_long) buffer[ inx + 4 ]) << 8) + (((zend_long) buffer[ inx + 5 ]));
inx += 6;
} else { /* short tag */
len = (((unsigned short) buffer[ inx ])<<8) | (unsigned short)buffer[ inx+1 ];
diff --git a/ext/standard/levenshtein.c b/ext/standard/levenshtein.c
index 786ca052d7..03e7e0075d 100644
--- a/ext/standard/levenshtein.c
+++ b/ext/standard/levenshtein.c
@@ -95,7 +95,7 @@ PHP_FUNCTION(levenshtein)
char *str1, *str2;
char *callback_name;
int str1_len, str2_len, callback_len;
- long cost_ins, cost_rep, cost_del;
+ zend_long cost_ins, cost_rep, cost_del;
int distance = -1;
switch (argc) {
diff --git a/ext/standard/link_win32.c b/ext/standard/link_win32.c
index 41ce9d20df..07466d2966 100644
--- a/ext/standard/link_win32.c
+++ b/ext/standard/link_win32.c
@@ -88,7 +88,7 @@ PHP_FUNCTION(linkinfo)
{
char *link;
int link_len;
- struct stat sb;
+ zend_stat_t sb;
int ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &link, &link_len) == FAILURE) {
diff --git a/ext/standard/mail.c b/ext/standard/mail.c
index 815f83118f..e45f9f7c90 100644
--- a/ext/standard/mail.c
+++ b/ext/standard/mail.c
@@ -72,7 +72,7 @@
*p = ' '; \
} \
-extern long php_getuid(TSRMLS_D);
+extern zend_long php_getuid(TSRMLS_D);
/* {{{ proto int ezmlm_hash(string addr)
Calculate EZMLM list hash value. */
@@ -182,7 +182,7 @@ PHP_FUNCTION(mail)
}
if (extra_cmd) {
- STR_RELEASE(extra_cmd);
+ zend_string_release(extra_cmd);
}
if (to_r != to) {
efree(to_r);
@@ -259,7 +259,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
l = spprintf(&tmp, 0, "[%s] mail() on [%s:%d]: To: %s -- Headers: %s\n", date_str->val, zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : "");
- STR_FREE(date_str);
+ zend_string_free(date_str);
if (hdr) {
php_mail_log_crlf_to_spaces(tmp);
@@ -285,11 +285,11 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
f = php_basename(tmp, strlen(tmp), NULL, 0 TSRMLS_CC);
if (headers != NULL) {
- spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n%s", php_getuid(TSRMLS_C), f->val, headers);
+ spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\n%s", php_getuid(TSRMLS_C), f->val, headers);
} else {
- spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s", php_getuid(TSRMLS_C), f->val);
+ spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(TSRMLS_C), f->val);
}
- STR_RELEASE(f);
+ zend_string_release(f);
}
if (!sendmail_path) {
diff --git a/ext/standard/math.c b/ext/standard/math.c
index a392eb607c..8a99faa665 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -286,8 +286,8 @@ PHP_FUNCTION(abs)
if (Z_TYPE_P(value) == IS_DOUBLE) {
RETURN_DOUBLE(fabs(Z_DVAL_P(value)));
} else if (Z_TYPE_P(value) == IS_LONG) {
- if (Z_LVAL_P(value) == LONG_MIN) {
- RETURN_DOUBLE(-(double)LONG_MIN);
+ if (Z_LVAL_P(value) == ZEND_LONG_MIN) {
+ RETURN_DOUBLE(-(double)ZEND_LONG_MIN);
} else {
RETURN_LONG(Z_LVAL_P(value) < 0 ? -Z_LVAL_P(value) : Z_LVAL_P(value));
}
@@ -342,8 +342,8 @@ PHP_FUNCTION(round)
{
zval *value;
int places = 0;
- long precision = 0;
- long mode = PHP_ROUND_HALF_UP;
+ zend_long precision = 0;
+ zend_long mode = PHP_ROUND_HALF_UP;
double return_val;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ll", &value, &precision, &mode) == FAILURE) {
@@ -926,9 +926,9 @@ PHP_FUNCTION(rad2deg)
/*
* Convert a string representation of a base(2-36) number to a long.
*/
-PHPAPI long _php_math_basetolong(zval *arg, int base)
+PHPAPI zend_long _php_math_basetolong(zval *arg, int base)
{
- long num = 0, digit, onum;
+ zend_long num = 0, digit, onum;
int i;
char c, *s;
@@ -959,7 +959,7 @@ PHPAPI long _php_math_basetolong(zval *arg, int base)
TSRMLS_FETCH();
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number '%s' is too big to fit in long", s);
- return LONG_MAX;
+ return ZEND_LONG_MAX;
}
}
@@ -973,12 +973,12 @@ PHPAPI long _php_math_basetolong(zval *arg, int base)
*/
PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret)
{
- long num = 0;
+ zend_long num = 0;
double fnum = 0;
int i;
int mode = 0;
char c, *s;
- long cutoff;
+ zend_long cutoff;
int cutlim;
if (Z_TYPE_P(arg) != IS_STRING || base < 2 || base > 36) {
@@ -987,8 +987,8 @@ PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret)
s = Z_STRVAL_P(arg);
- cutoff = LONG_MAX / base;
- cutlim = LONG_MAX % base;
+ cutoff = ZEND_LONG_MAX / base;
+ cutlim = ZEND_LONG_MAX % base;
for (i = Z_STRLEN_P(arg); i > 0; i--) {
c = *s++;
@@ -1038,9 +1038,9 @@ PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret)
PHPAPI zend_string * _php_math_longtobase(zval *arg, int base TSRMLS_DC)
{
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
- char buf[(sizeof(unsigned long) << 3) + 1];
+ char buf[(sizeof(zend_ulong) << 3) + 1];
char *ptr, *end;
- unsigned long value;
+ zend_ulong value;
if (Z_TYPE_P(arg) != IS_LONG || base < 2 || base > 36) {
return STR_EMPTY_ALLOC();
@@ -1056,7 +1056,7 @@ PHPAPI zend_string * _php_math_longtobase(zval *arg, int base TSRMLS_DC)
value /= base;
} while (ptr > buf && value);
- return STR_INIT(ptr, end - ptr, 0);
+ return zend_string_init(ptr, end - ptr, 0);
}
/* }}} */
@@ -1092,7 +1092,7 @@ PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base TSRMLS_DC)
fvalue /= base;
} while (ptr > buf && fabs(fvalue) >= 1);
- return STR_INIT(ptr, end - ptr, 0);
+ return zend_string_init(ptr, end - ptr, 0);
}
return _php_math_longtobase(arg, base TSRMLS_CC);
@@ -1157,7 +1157,7 @@ PHP_FUNCTION(decbin)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
- convert_to_long_ex(arg);
+ convert_to_int_ex(arg);
result = _php_math_longtobase(arg, 2 TSRMLS_CC);
RETURN_STR(result);
}
@@ -1173,7 +1173,7 @@ PHP_FUNCTION(decoct)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
- convert_to_long_ex(arg);
+ convert_to_int_ex(arg);
result = _php_math_longtobase(arg, 8 TSRMLS_CC);
RETURN_STR(result);
}
@@ -1189,7 +1189,7 @@ PHP_FUNCTION(dechex)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
- convert_to_long_ex(arg);
+ convert_to_int_ex(arg);
result = _php_math_longtobase(arg, 16 TSRMLS_CC);
RETURN_STR(result);
}
@@ -1200,7 +1200,7 @@ PHP_FUNCTION(dechex)
PHP_FUNCTION(base_convert)
{
zval *number, temp;
- long frombase, tobase;
+ zend_long frombase, tobase;
zend_string *result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zll", &number, &frombase, &tobase) == FAILURE) {
@@ -1209,11 +1209,11 @@ PHP_FUNCTION(base_convert)
convert_to_string_ex(number);
if (frombase < 2 || frombase > 36) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid `from base' (%ld)", frombase);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid `from base' (%pd)", frombase);
RETURN_FALSE;
}
if (tobase < 2 || tobase > 36) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid `to base' (%ld)", tobase);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid `to base' (%pd)", tobase);
RETURN_FALSE;
}
@@ -1292,7 +1292,7 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_poin
if (is_negative) {
reslen++;
}
- res = STR_ALLOC(reslen, 0);
+ res = zend_string_alloc(reslen, 0);
s = tmpbuf->val + tmpbuf->len - 1;
t = res->val + reslen;
@@ -1341,7 +1341,7 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_poin
}
res->len = reslen;
- STR_RELEASE(tmpbuf);
+ zend_string_release(tmpbuf);
return res;
}
@@ -1350,7 +1350,7 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_poin
PHP_FUNCTION(number_format)
{
double num;
- long dec = 0;
+ zend_long dec = 0;
char *thousand_sep = NULL, *dec_point = NULL;
char thousand_sep_chr = ',', dec_point_chr = '.';
int thousand_sep_len = 0, dec_point_len = 0;
@@ -1422,7 +1422,7 @@ PHP_FUNCTION(fmod)
Returns the integer division of the numerator by the divisor */
PHP_FUNCTION(intdiv)
{
- long numerator, divisor;
+ zend_long numerator, divisor;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &numerator, &divisor) == FAILURE) {
return;
@@ -1431,7 +1431,7 @@ PHP_FUNCTION(intdiv)
if (divisor == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
RETURN_BOOL(0);
- } else if (divisor == -1 && numerator == LONG_MIN) {
+ } else if (divisor == -1 && numerator == ZEND_LONG_MIN) {
/* Prevent overflow error/crash
We don't return a float here as that violates function contract */
RETURN_LONG(0);
diff --git a/ext/standard/md5.c b/ext/standard/md5.c
index d2545e913a..68161da326 100644
--- a/ext/standard/md5.c
+++ b/ext/standard/md5.c
@@ -46,20 +46,19 @@ PHPAPI void make_digest_ex(char *md5str, const unsigned char *digest, int len) /
Calculate the md5 hash of a string */
PHP_NAMED_FUNCTION(php_if_md5)
{
- char *arg;
- int arg_len;
+ zend_string *arg;
zend_bool raw_output = 0;
char md5str[33];
PHP_MD5_CTX context;
unsigned char digest[16];
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &raw_output) == FAILURE) {
return;
}
md5str[0] = '\0';
PHP_MD5Init(&context);
- PHP_MD5Update(&context, arg, arg_len);
+ PHP_MD5Update(&context, arg->val, arg->len);
PHP_MD5Final(digest, &context);
if (raw_output) {
RETURN_STRINGL(digest, 16);
@@ -82,7 +81,7 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
unsigned char buf[1024];
unsigned char digest[16];
PHP_MD5_CTX context;
- int n;
+ size_t n;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|b", &arg, &arg_len, &raw_output) == FAILURE) {
diff --git a/ext/standard/metaphone.c b/ext/standard/metaphone.c
index 9d22868b8c..f2feb72ebf 100644
--- a/ext/standard/metaphone.c
+++ b/ext/standard/metaphone.c
@@ -25,27 +25,25 @@
#include "php.h"
#include "php_metaphone.h"
-static int metaphone(unsigned char *word, int word_len, long max_phonemes, zend_string **phoned_word, int traditional);
+static int metaphone(unsigned char *word, size_t word_len, zend_long max_phonemes, zend_string **phoned_word, int traditional);
/* {{{ proto string metaphone(string text[, int phones])
Break english phrases down into their phonemes */
PHP_FUNCTION(metaphone)
{
- char *str;
+ zend_string *str;
zend_string *result = NULL;
- int str_len;
- long phones = 0;
+ zend_long phones = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len,
- &phones) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|l", &str, &phones) == FAILURE) {
return;
}
- if (metaphone((unsigned char *)str, str_len, phones, &result, 1) == 0) {
+ if (metaphone((unsigned char *)str->val, str->len, phones, &result, 1) == 0) {
RETVAL_STR(result);
} else {
if (result) {
- STR_FREE(result);
+ zend_string_free(result);
}
RETURN_FALSE;
}
@@ -144,7 +142,7 @@ static char Lookahead(char *word, int how_far)
* could be one though; or more too). */
#define Phonize(c) { \
if (p_idx >= max_buffer_len) { \
- *phoned_word = STR_REALLOC(*phoned_word, 2 * sizeof(char) + max_buffer_len, 0); \
+ *phoned_word = zend_string_realloc(*phoned_word, 2 * sizeof(char) + max_buffer_len, 0); \
max_buffer_len += 2; \
} \
(*phoned_word)->val[p_idx++] = c; \
@@ -153,7 +151,7 @@ static char Lookahead(char *word, int how_far)
/* Slap a null character on the end of the phoned word */
#define End_Phoned_Word { \
if (p_idx == max_buffer_len) { \
- *phoned_word = STR_REALLOC(*phoned_word, 1 * sizeof(char) + max_buffer_len, 0); \
+ *phoned_word = zend_string_realloc(*phoned_word, 1 * sizeof(char) + max_buffer_len, 0); \
max_buffer_len += 1; \
} \
(*phoned_word)->val[p_idx] = '\0'; \
@@ -167,11 +165,11 @@ static char Lookahead(char *word, int how_far)
/* {{{ metaphone
*/
-static int metaphone(unsigned char *word, int word_len, long max_phonemes, zend_string **phoned_word, int traditional)
+static int metaphone(unsigned char *word, size_t word_len, zend_long max_phonemes, zend_string **phoned_word, int traditional)
{
int w_idx = 0; /* point in the phonization we're at. */
int p_idx = 0; /* end of the phoned phrase */
- int max_buffer_len = 0; /* maximum length of the destination buffer */
+ size_t max_buffer_len = 0; /* maximum length of the destination buffer */
/*-- Parameter checks --*/
/* Negative phoneme length is meaningless */
@@ -189,10 +187,10 @@ static int metaphone(unsigned char *word, int word_len, long max_phonemes, zend_
/*-- Allocate memory for our phoned_phrase --*/
if (max_phonemes == 0) { /* Assume largest possible */
max_buffer_len = word_len;
- *phoned_word = STR_ALLOC(sizeof(char) * word_len + 1, 0);
+ *phoned_word = zend_string_alloc(sizeof(char) * word_len + 1, 0);
} else {
max_buffer_len = max_phonemes;
- *phoned_word = STR_ALLOC(sizeof(char) * max_phonemes + 1, 0);
+ *phoned_word = zend_string_alloc(sizeof(char) * max_phonemes + 1, 0);
}
diff --git a/ext/standard/microtime.c b/ext/standard/microtime.c
index f8e19c74ca..e20223b011 100644
--- a/ext/standard/microtime.c
+++ b/ext/standard/microtime.c
@@ -111,7 +111,7 @@ PHP_FUNCTION(gettimeofday)
PHP_FUNCTION(getrusage)
{
struct rusage usg;
- long pwho = 0;
+ zend_long pwho = 0;
int who = RUSAGE_SELF;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &pwho) == FAILURE) {
diff --git a/ext/standard/pack.c b/ext/standard/pack.c
index c77a1a40c6..59f878e217 100644
--- a/ext/standard/pack.c
+++ b/ext/standard/pack.c
@@ -84,12 +84,12 @@ static int little_endian_long_map[4];
/* {{{ php_pack
*/
-static void php_pack(zval *val, int size, int *map, char *output)
+static void php_pack(zval *val, size_t size, int *map, char *output)
{
int i;
char *v;
- convert_to_long_ex(val);
+ convert_to_int_ex(val);
v = (char *) &Z_LVAL_P(val);
for (i = 0; i < size; i++) {
@@ -329,7 +329,7 @@ PHP_FUNCTION(pack)
(str->len < arg_cp) ? str->len : arg_cp);
outputpos += arg;
- STR_RELEASE(str);
+ zend_string_release(str);
break;
}
@@ -372,7 +372,7 @@ PHP_FUNCTION(pack)
}
outputpos++;
- STR_RELEASE(str);
+ zend_string_release(str);
break;
}
@@ -480,9 +480,9 @@ PHP_FUNCTION(pack)
/* {{{ php_unpack
*/
-static long php_unpack(char *data, int size, int issigned, int *map)
+static zend_long php_unpack(char *data, size_t size, int issigned, int *map)
{
- long result;
+ zend_long result;
char *cresult = (char *) &result;
int i;
@@ -512,19 +512,20 @@ static long php_unpack(char *data, int size, int issigned, int *map)
Unpack binary string into named array elements according to format argument */
PHP_FUNCTION(unpack)
{
- char *format, *input, *formatarg, *inputarg;
- int formatlen, formatarg_len, inputarg_len;
- int inputpos, inputlen, i;
+ char *format, *input;
+ zend_string *formatarg, *inputarg;
+ size_t formatlen, inputpos, inputlen;
+ int i;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &formatarg, &formatarg_len,
- &inputarg, &inputarg_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &formatarg,
+ &inputarg) == FAILURE) {
return;
}
- format = formatarg;
- formatlen = formatarg_len;
- input = inputarg;
- inputlen = inputarg_len;
+ format = formatarg->val;
+ formatlen = formatarg->len;
+ input = inputarg->val;
+ inputlen = inputarg->len;
inputpos = 0;
array_init(return_value);
@@ -656,11 +657,11 @@ PHP_FUNCTION(unpack)
inputpos = 0;
}
- if ((inputpos + size) <= inputlen) {
+ if ((size >=0 && (inputpos + size) <= inputlen) || (size < 0 && -size <= (inputlen - inputpos))) {
switch ((int) type) {
case 'a': {
/* a will not strip any trailing whitespace or null padding */
- int len = inputlen - inputpos; /* Remaining string */
+ size_t len = inputlen - inputpos; /* Remaining string */
/* If size was given take minimum of len and size */
if ((size >= 0) && (len > size)) {
@@ -675,7 +676,7 @@ PHP_FUNCTION(unpack)
case 'A': {
/* 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 */
+ size_t len = inputlen - inputpos; /* Remaining string */
/* If size was given take minimum of len and size */
if ((size >= 0) && (len > size)) {
@@ -702,7 +703,7 @@ PHP_FUNCTION(unpack)
case 'Z': {
/* Z will strip everything after the first null character */
char pad = '\0';
- int s,
+ size_t s,
len = inputlen - inputpos; /* Remaining string */
/* If size was given take minimum of len and size */
@@ -726,11 +727,11 @@ PHP_FUNCTION(unpack)
case 'h':
case 'H': {
- int len = (inputlen - inputpos) * 2; /* Remaining */
+ size_t len = (inputlen - inputpos) * 2; /* Remaining */
int nibbleshift = (type == 'h') ? 0 : 4;
int first = 1;
char *buf;
- int ipos, opos;
+ size_t ipos, opos;
/* If size was given take minimum of len and size */
if (size >= 0 && len > (size * 2)) {
@@ -770,7 +771,7 @@ PHP_FUNCTION(unpack)
case 'c':
case 'C': {
int issigned = (type == 'c') ? (input[inputpos] & 0x80) : 0;
- long v = php_unpack(&input[inputpos], 1, issigned, byte_map);
+ zend_long v = php_unpack(&input[inputpos], 1, issigned, byte_map);
add_assoc_long(return_value, n, v);
break;
}
@@ -779,7 +780,7 @@ PHP_FUNCTION(unpack)
case 'S':
case 'n':
case 'v': {
- long v;
+ zend_long v;
int issigned = 0;
int *map = machine_endian_short_map;
@@ -798,7 +799,7 @@ PHP_FUNCTION(unpack)
case 'i':
case 'I': {
- long v;
+ zend_long v;
int issigned = 0;
if (type == 'i') {
@@ -816,7 +817,7 @@ PHP_FUNCTION(unpack)
case 'V': {
int issigned = 0;
int *map = machine_endian_long_map;
- long v = 0;
+ zend_long v = 0;
if (type == 'l' || type == 'L') {
issigned = input[inputpos + (machine_little_endian ? 3 : 0)] & 0x80;
@@ -828,12 +829,12 @@ PHP_FUNCTION(unpack)
map = little_endian_long_map;
}
- if (sizeof(long) > 4 && issigned) {
+ if (SIZEOF_ZEND_INT > 4 && issigned) {
v = ~INT_MAX;
}
v |= php_unpack(&input[inputpos], 4, issigned, map);
- if (sizeof(long) > 4) {
+ if (SIZEOF_ZEND_INT > 4) {
if (type == 'l') {
v = (signed int) v;
} else {
@@ -903,8 +904,10 @@ PHP_FUNCTION(unpack)
}
}
- formatlen--; /* Skip '/' separator, does no harm if inputlen == 0 */
- format++;
+ if (formatlen > 0) {
+ formatlen--; /* Skip '/' separator, does no harm if inputlen == 0 */
+ format++;
+ }
}
}
/* }}} */
diff --git a/ext/standard/pageinfo.c b/ext/standard/pageinfo.c
index a9a4e58de0..61a4ae6ec2 100644
--- a/ext/standard/pageinfo.c
+++ b/ext/standard/pageinfo.c
@@ -59,7 +59,7 @@
*/
PHPAPI void php_statpage(TSRMLS_D)
{
- struct stat *pstat;
+ zend_stat_t *pstat;
pstat = sapi_get_stat(TSRMLS_C);
@@ -79,14 +79,14 @@ PHPAPI void php_statpage(TSRMLS_D)
/* {{{ php_getuid
*/
-long php_getuid(TSRMLS_D)
+zend_long php_getuid(TSRMLS_D)
{
php_statpage(TSRMLS_C);
return (BG(page_uid));
}
/* }}} */
-long php_getgid(TSRMLS_D)
+zend_long php_getgid(TSRMLS_D)
{
php_statpage(TSRMLS_C);
return (BG(page_gid));
@@ -96,7 +96,7 @@ long php_getgid(TSRMLS_D)
Get PHP script owner's UID */
PHP_FUNCTION(getmyuid)
{
- long uid;
+ zend_long uid;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -115,7 +115,7 @@ PHP_FUNCTION(getmyuid)
Get PHP script owner's GID */
PHP_FUNCTION(getmygid)
{
- long gid;
+ zend_long gid;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -134,7 +134,7 @@ PHP_FUNCTION(getmygid)
Get current process ID */
PHP_FUNCTION(getmypid)
{
- int pid;
+ zend_long pid;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -144,7 +144,7 @@ PHP_FUNCTION(getmypid)
if (pid < 0) {
RETURN_FALSE;
} else {
- RETURN_LONG((long) pid);
+ RETURN_LONG(pid);
}
}
/* }}} */
@@ -166,7 +166,7 @@ PHP_FUNCTION(getmyinode)
}
/* }}} */
-PHPAPI long php_getlastmod(TSRMLS_D)
+PHPAPI time_t php_getlastmod(TSRMLS_D)
{
php_statpage(TSRMLS_C);
return BG(page_mtime);
@@ -176,7 +176,7 @@ PHPAPI long php_getlastmod(TSRMLS_D)
Get time of last page modification */
PHP_FUNCTION(getlastmod)
{
- long lm;
+ zend_long lm;
if (zend_parse_parameters_none() == FAILURE) {
return;
diff --git a/ext/standard/pageinfo.h b/ext/standard/pageinfo.h
index c3c1846058..204fb85c19 100644
--- a/ext/standard/pageinfo.h
+++ b/ext/standard/pageinfo.h
@@ -28,8 +28,8 @@ PHP_FUNCTION(getmyinode);
PHP_FUNCTION(getlastmod);
PHPAPI void php_statpage(TSRMLS_D);
-PHPAPI long php_getlastmod(TSRMLS_D);
-extern long php_getuid(TSRMLS_D);
-extern long php_getgid(TSRMLS_D);
+PHPAPI time_t php_getlastmod(TSRMLS_D);
+extern zend_long php_getuid(TSRMLS_D);
+extern zend_long php_getgid(TSRMLS_D);
#endif
diff --git a/ext/standard/password.c b/ext/standard/password.c
index aa50ab1f00..73d468d126 100644
--- a/ext/standard/password.c
+++ b/ext/standard/password.c
@@ -89,20 +89,20 @@ static int php_password_salt_to64(const char *str, const size_t str_len, const s
buffer = php_base64_encode((unsigned char*) str, (int) str_len);
if (buffer->len < out_len) {
/* Too short of an encoded string generated */
- STR_RELEASE(buffer);
+ zend_string_release(buffer);
return FAILURE;
}
for (pos = 0; pos < out_len; pos++) {
if (buffer->val[pos] == '+') {
ret[pos] = '.';
} else if (buffer->val[pos] == '=') {
- STR_FREE(buffer);
+ zend_string_free(buffer);
return FAILURE;
} else {
ret[pos] = buffer->val[pos];
}
}
- STR_FREE(buffer);
+ zend_string_free(buffer);
return SUCCESS;
}
/* }}} */
@@ -195,8 +195,8 @@ PHP_FUNCTION(password_get_info)
switch (algo) {
case PHP_PASSWORD_BCRYPT:
{
- long cost = PHP_PASSWORD_BCRYPT_COST;
- sscanf(hash, "$2y$%ld$", &cost);
+ zend_long cost = PHP_PASSWORD_BCRYPT_COST;
+ sscanf(hash, "$2y$" ZEND_LONG_FMT "$", &cost);
add_assoc_long(&options, "cost", cost);
}
break;
@@ -214,7 +214,7 @@ PHP_FUNCTION(password_get_info)
PHP_FUNCTION(password_needs_rehash)
{
- long new_algo = 0;
+ zend_long new_algo = 0;
php_password_algo algo;
int hash_len;
char *hash;
@@ -239,13 +239,13 @@ PHP_FUNCTION(password_needs_rehash)
switch (algo) {
case PHP_PASSWORD_BCRYPT:
{
- long new_cost = PHP_PASSWORD_BCRYPT_COST, cost = 0;
+ zend_long new_cost = PHP_PASSWORD_BCRYPT_COST, cost = 0;
if (options && (option_buffer = zend_symtable_str_find(options, "cost", sizeof("cost")-1)) != NULL) {
if (Z_TYPE_P(option_buffer) != IS_LONG) {
zval cast_option_buffer;
ZVAL_DUP(&cast_option_buffer, option_buffer);
- convert_to_long(&cast_option_buffer);
+ convert_to_int(&cast_option_buffer);
new_cost = Z_LVAL(cast_option_buffer);
zval_dtor(&cast_option_buffer);
} else {
@@ -253,7 +253,7 @@ PHP_FUNCTION(password_needs_rehash)
}
}
- sscanf(hash, "$2y$%ld$", &cost);
+ sscanf(hash, "$2y$" ZEND_LONG_FMT "$", &cost);
if (cost != new_cost) {
RETURN_TRUE;
}
@@ -283,7 +283,7 @@ PHP_FUNCTION(password_verify)
}
if (ret->len != hash_len || hash_len < 13) {
- STR_FREE(ret);
+ zend_string_free(ret);
RETURN_FALSE;
}
@@ -295,7 +295,7 @@ PHP_FUNCTION(password_verify)
status |= (ret->val[i] ^ hash[i]);
}
- STR_FREE(ret);
+ zend_string_free(ret);
RETURN_BOOL(status == 0);
@@ -307,7 +307,7 @@ Hash a password */
PHP_FUNCTION(password_hash)
{
char *hash_format, *hash, *salt, *password;
- long algo = 0;
+ zend_long algo = 0;
int password_len = 0, hash_len;
size_t salt_len = 0, required_salt_len = 0, hash_format_len;
HashTable *options = 0;
@@ -321,13 +321,13 @@ PHP_FUNCTION(password_hash)
switch (algo) {
case PHP_PASSWORD_BCRYPT:
{
- long cost = PHP_PASSWORD_BCRYPT_COST;
+ zend_long cost = PHP_PASSWORD_BCRYPT_COST;
if (options && (option_buffer = zend_symtable_str_find(options, "cost", sizeof("cost")-1)) != NULL) {
if (Z_TYPE_P(option_buffer) != IS_LONG) {
zval cast_option_buffer;
ZVAL_DUP(&cast_option_buffer, option_buffer);
- convert_to_long(&cast_option_buffer);
+ convert_to_int(&cast_option_buffer);
cost = Z_LVAL(cast_option_buffer);
zval_dtor(&cast_option_buffer);
} else {
@@ -336,7 +336,7 @@ PHP_FUNCTION(password_hash)
}
if (cost < 4 || cost > 31) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid bcrypt cost parameter specified: %ld", cost);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid bcrypt cost parameter specified: " ZEND_LONG_FMT, cost);
RETURN_NULL();
}
@@ -348,7 +348,7 @@ PHP_FUNCTION(password_hash)
break;
case PHP_PASSWORD_UNKNOWN:
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown password hashing algorithm: %ld", algo);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown password hashing algorithm: " ZEND_LONG_FMT, algo);
RETURN_NULL();
}
@@ -443,7 +443,7 @@ PHP_FUNCTION(password_hash)
efree(hash);
if (result->len < 13) {
- STR_FREE(result);
+ zend_string_free(result);
RETURN_FALSE;
}
diff --git a/ext/standard/php_array.h b/ext/standard/php_array.h
index d123ddfe41..c001ee5509 100644
--- a/ext/standard/php_array.h
+++ b/ext/standard/php_array.h
@@ -107,7 +107,7 @@ PHPAPI HashTable* php_splice(HashTable *, int, int, zval *, int, HashTable *);
PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS_DC);
PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src TSRMLS_DC);
PHPAPI int php_multisort_compare(const void *a, const void *b TSRMLS_DC);
-PHPAPI int php_count_recursive(zval *array, long mode TSRMLS_DC);
+PHPAPI zend_long php_count_recursive(zval *array, zend_long mode TSRMLS_DC);
#define PHP_SORT_REGULAR 0
#define PHP_SORT_NUMERIC 1
diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c
index 9628c0d69d..3859e5b9a4 100644
--- a/ext/standard/php_fopen_wrapper.c
+++ b/ext/standard/php_fopen_wrapper.c
@@ -65,7 +65,7 @@ php_stream_ops php_stream_output_ops = {
typedef struct php_stream_input { /* {{{ */
php_stream *body;
- off_t position;
+ zend_off_t position;
} php_stream_input_t;
/* }}} */
@@ -118,7 +118,7 @@ static int php_stream_input_flush(php_stream *stream TSRMLS_DC) /* {{{ */
}
/* }}} */
-static int php_stream_input_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
+static int php_stream_input_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset TSRMLS_DC) /* {{{ */
{
php_stream_input_t *input = stream->abstract;
@@ -178,7 +178,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
int mode_rw = 0;
php_stream * stream = NULL;
char *p, *token, *pathdup;
- long max_memory;
+ zend_long max_memory;
FILE *file = NULL;
if (!strncasecmp(path, "php://", 6)) {
@@ -190,7 +190,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
max_memory = PHP_STREAM_MAX_MEM;
if (!strncasecmp(path, "/maxmemory:", 11)) {
path += 11;
- max_memory = strtol(path, NULL, 10);
+ max_memory = ZEND_STRTOL(path, NULL, 10);
if (max_memory < 0) {
php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Max memory must be >= 0");
return NULL;
@@ -286,7 +286,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
} else if (!strncasecmp(path, "fd/", 3)) {
const char *start;
char *end;
- long fildes_ori;
+ zend_long fildes_ori;
int dtablesize;
if (strcmp(sapi_module.name, "cli")) {
@@ -304,7 +304,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
}
start = &path[3];
- fildes_ori = strtol(start, &end, 10);
+ fildes_ori = ZEND_STRTOL(start, &end, 10);
if (end == start || *end != '\0') {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC,
"php://fd/ stream must be specified in the form php://fd/<orig fd>");
@@ -326,7 +326,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
fd = dup(fildes_ori);
if (fd == -1) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC,
- "Error duping file descriptor %ld; possibly it doesn't exist: "
+ "Error duping file descriptor " ZEND_LONG_FMT "; possibly it doesn't exist: "
"[%d]: %s", fildes_ori, errno, strerror(errno));
return NULL;
}
@@ -380,9 +380,9 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
#if defined(S_IFSOCK) && !defined(WIN32) && !defined(__BEOS__)
do {
- struct stat st;
+ zend_stat_t st;
memset(&st, 0, sizeof(st));
- if (fstat(fd, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
+ if (zend_fstat(fd, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
stream = php_stream_sock_open_from_socket(fd, NULL);
if (stream) {
stream->ops = &php_stream_socket_ops;
diff --git a/ext/standard/php_incomplete_class.h b/ext/standard/php_incomplete_class.h
index 804ca05206..efca24acce 100644
--- a/ext/standard/php_incomplete_class.h
+++ b/ext/standard/php_incomplete_class.h
@@ -32,7 +32,7 @@
Z_OBJCE_P(struc) == BG(incomplete_class)) { \
class_name = php_lookup_class_name(struc); \
if (!class_name) { \
- class_name = STR_INIT(INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1, 0); \
+ class_name = zend_string_init(INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1, 0); \
} \
incomplete_class = 1; \
} else { \
@@ -40,7 +40,7 @@
}
#define PHP_CLEANUP_CLASS_ATTRIBUTES() \
- STR_RELEASE(class_name)
+ zend_string_release(class_name)
#define PHP_CLASS_ATTRIBUTES \
zend_string *class_name; \
@@ -55,7 +55,7 @@ extern "C" {
PHPAPI zend_class_entry *php_create_incomplete_class(TSRMLS_D);
PHPAPI zend_string *php_lookup_class_name(zval *object);
-PHPAPI void php_store_class_name(zval *object, const char *name, zend_uint len);
+PHPAPI void php_store_class_name(zval *object, const char *name, uint32_t len);
#ifdef __cplusplus
};
diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h
index a2dca282c5..afdf54166f 100644
--- a/ext/standard/php_math.h
+++ b/ext/standard/php_math.h
@@ -25,7 +25,7 @@
PHPAPI zend_string *_php_math_number_format(double, int, char, char);
PHPAPI zend_string *_php_math_number_format_ex(double, int, char *, size_t, char *, size_t);
PHPAPI zend_string * _php_math_longtobase(zval *arg, int base TSRMLS_DC);
-PHPAPI long _php_math_basetolong(zval *arg, int base);
+PHPAPI zend_long _php_math_basetolong(zval *arg, int base);
PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret);
PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base TSRMLS_DC);
diff --git a/ext/standard/php_rand.h b/ext/standard/php_rand.h
index 0e8abb3613..6ec0f38706 100644
--- a/ext/standard/php_rand.h
+++ b/ext/standard/php_rand.h
@@ -42,19 +42,19 @@
#endif
#define RAND_RANGE(__n, __min, __max, __tmax) \
- (__n) = (__min) + (long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0)))
+ (__n) = (__min) + (zend_long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0)))
/* MT Rand */
-#define PHP_MT_RAND_MAX ((long) (0x7FFFFFFF)) /* (1<<31) - 1 */
+#define PHP_MT_RAND_MAX ((zend_long) (0x7FFFFFFF)) /* (1<<31) - 1 */
#ifdef PHP_WIN32
-#define GENERATE_SEED() (((long) (time(0) * GetCurrentProcessId())) ^ ((long) (1000000.0 * php_combined_lcg(TSRMLS_C))))
+#define GENERATE_SEED() (((zend_long) (time(0) * GetCurrentProcessId())) ^ ((zend_long) (1000000.0 * php_combined_lcg(TSRMLS_C))))
#else
-#define GENERATE_SEED() (((long) (time(0) * getpid())) ^ ((long) (1000000.0 * php_combined_lcg(TSRMLS_C))))
+#define GENERATE_SEED() (((zend_long) (time(0) * getpid())) ^ ((zend_long) (1000000.0 * php_combined_lcg(TSRMLS_C))))
#endif
-PHPAPI void php_srand(long seed TSRMLS_DC);
-PHPAPI long php_rand(TSRMLS_D);
+PHPAPI void php_srand(zend_long seed TSRMLS_DC);
+PHPAPI zend_long php_rand(TSRMLS_D);
PHPAPI void php_mt_srand(php_uint32 seed TSRMLS_DC);
PHPAPI php_uint32 php_mt_rand(TSRMLS_D);
diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h
index 71bcf0b223..c153fa884c 100644
--- a/ext/standard/php_smart_str.h
+++ b/ext/standard/php_smart_str.h
@@ -62,7 +62,7 @@
(d)->a = newlen < SMART_STR_START_SIZE \
? SMART_STR_START_SIZE \
: newlen + SMART_STR_PREALLOC; \
- (d)->s = STR_ALLOC((d)->a, (what)); \
+ (d)->s = zend_string_alloc((d)->a, (what)); \
(d)->s->len = 0; \
} else { \
newlen = (d)->s->len + (n); \
@@ -108,7 +108,7 @@
#define smart_str_free_ex(buf, what) do { \
smart_str *__s = (smart_str *) (buf); \
if (__s->s) { \
- STR_RELEASE(__s->s); \
+ zend_string_release(__s->s); \
__s->s = NULL; \
} \
__s->a = 0; \
@@ -130,15 +130,15 @@
* #define f(..) ({char *r;..;__r;})
*/
-static inline char *smart_str_print_long(char *buf, long num) {
+static inline char *smart_str_print_long(char *buf, zend_long num) {
char *r;
- _zend_print_signed_to_buf(buf, num, long, r);
+ _zend_print_signed_to_buf(buf, num, zend_long, r);
return r;
}
-static inline char *smart_str_print_unsigned(char *buf, long num) {
+static inline char *smart_str_print_unsigned(char *buf, zend_long num) {
char *r;
- _zend_print_unsigned_to_buf(buf, num, unsigned long, r);
+ _zend_print_unsigned_to_buf(buf, num, zend_ulong, r);
return r;
}
@@ -150,13 +150,13 @@ static inline char *smart_str_print_unsigned(char *buf, long num) {
} while (0)
#define smart_str_append_unsigned_ex(dest, num, type) \
- smart_str_append_generic_ex((dest), (num), (type), unsigned long, _unsigned)
+ smart_str_append_generic_ex((dest), (num), (type), zend_ulong, _unsigned)
#define smart_str_append_long_ex(dest, num, type) \
- smart_str_append_generic_ex((dest), (num), (type), unsigned long, _signed)
+ smart_str_append_generic_ex((dest), (num), (type), zend_ulong, _signed)
#define smart_str_append_off_t_ex(dest, num, type) \
- smart_str_append_generic_ex((dest), (num), (type), off_t, _signed)
+ smart_str_append_generic_ex((dest), (num), (type), zend_off_t, _signed)
#define smart_str_append_ex(dest, src, what) \
smart_str_appendl_ex((dest), ((smart_str *)(src))->s->val, \
diff --git a/ext/standard/php_smart_string.h b/ext/standard/php_smart_string.h
index 02ba9fe84e..91530d94d3 100644
--- a/ext/standard/php_smart_string.h
+++ b/ext/standard/php_smart_string.h
@@ -119,13 +119,13 @@
__dest->len = __nl; \
} while (0)
-static inline char *smart_string_print_long(char *buf, long num) {
+static inline char *smart_string_print_long(char *buf, zend_long num) {
char *r;
_zend_print_signed_to_buf(buf, num, unsigned long, r);
return r;
}
-static inline char *smart_string_print_unsigned(char *buf, long num) {
+static inline char *smart_string_print_unsigned(char *buf, zend_long num) {
char *r;
_zend_print_unsigned_to_buf(buf, num, unsigned long, r);
return r;
diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h
index 0f4240ea57..e0ffff5e23 100644
--- a/ext/standard/php_string.h
+++ b/ext/standard/php_string.h
@@ -120,25 +120,25 @@ PHPAPI struct lconv *localeconv_r(struct lconv *out);
PHPAPI char *php_strtoupper(char *s, size_t len);
PHPAPI char *php_strtolower(char *s, size_t len);
-PHPAPI char *php_strtr(char *str, int len, char *str_from, char *str_to, int trlen);
-PHPAPI zend_string *php_addslashes(char *str, int length, int should_free TSRMLS_DC);
-PHPAPI zend_string *php_addcslashes(const char *str, int length, int freeit, char *what, int wlength TSRMLS_DC);
-PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC);
-PHPAPI void php_stripcslashes(char *str, int *len);
+PHPAPI char *php_strtr(char *str, size_t len, char *str_from, char *str_to, size_t trlen);
+PHPAPI zend_string *php_addslashes(char *str, size_t length, int should_free TSRMLS_DC);
+PHPAPI zend_string *php_addcslashes(const char *str, size_t length, int freeit, char *what, size_t wlength TSRMLS_DC);
+PHPAPI void php_stripslashes(char *str, size_t *len TSRMLS_DC);
+PHPAPI void php_stripcslashes(char *str, size_t *len);
PHPAPI zend_string *php_basename(const char *s, size_t len, char *suffix, size_t sufflen TSRMLS_DC);
PHPAPI size_t php_dirname(char *str, size_t len);
PHPAPI char *php_stristr(char *s, char *t, size_t s_len, size_t t_len);
-PHPAPI zend_string *php_str_to_str_ex(char *haystack, int length, char *needle,
- int needle_len, char *str, int str_len, int case_sensitivity, int *replace_count);
-PHPAPI zend_string *php_str_to_str(char *haystack, int length, char *needle,
- int needle_len, char *str, int str_len);
-PHPAPI char *php_trim(char *c, int len, char *what, int what_len, zval *return_value, int mode TSRMLS_DC);
-PHPAPI size_t php_strip_tags(char *rbuf, int len, int *state, char *allow, int allow_len);
-PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow, int allow_len, zend_bool allow_tag_spaces);
-PHPAPI int php_char_to_str_ex(char *str, uint len, char from, char *to, int to_len, zval *result, int case_sensitivity, int *replace_count);
-PHPAPI int php_char_to_str(char *str, uint len, char from, char *to, int to_len, zval *result);
+PHPAPI zend_string *php_str_to_str_ex(char *haystack, size_t length, char *needle,
+ size_t needle_len, char *str, size_t str_len, int case_sensitivity, size_t *replace_count);
+PHPAPI zend_string *php_str_to_str(char *haystack, size_t length, char *needle,
+ size_t needle_len, char *str, size_t str_len);
+PHPAPI char *php_trim(char *c, size_t len, char *what, size_t what_len, zval *return_value, int mode TSRMLS_DC);
+PHPAPI size_t php_strip_tags(char *rbuf, size_t len, int *state, char *allow, size_t allow_len);
+PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, int *stateptr, char *allow, size_t allow_len, zend_bool allow_tag_spaces);
+PHPAPI size_t php_char_to_str_ex(char *str, size_t len, char from, char *to, size_t to_len, zval *result, int case_sensitivity, size_t *replace_count);
+PHPAPI size_t php_char_to_str(char *str, size_t len, char from, char *to, size_t to_len, zval *result);
PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC);
-PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, long limit);
+PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, zend_long limit);
PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end);
PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end);
diff --git a/ext/standard/php_uuencode.h b/ext/standard/php_uuencode.h
index fedfe660e9..f1dda2de45 100644
--- a/ext/standard/php_uuencode.h
+++ b/ext/standard/php_uuencode.h
@@ -24,8 +24,8 @@
PHP_FUNCTION(convert_uudecode);
PHP_FUNCTION(convert_uuencode);
-PHPAPI zend_string *php_uudecode(char *src, int src_len);
-PHPAPI zend_string *php_uuencode(char *src, int src_len);
+PHPAPI zend_string *php_uudecode(char *src, size_t src_len);
+PHPAPI zend_string *php_uuencode(char *src, size_t src_len);
#endif /* PHP_UUENCODE_H */
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index dea8c16c07..fc58b9f7b8 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -110,7 +110,7 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
ZEND_HASH_FOREACH_STR_KEY_VAL(target_hash, string_key, element) {
zend_string *str = zval_get_string(element);
uint el_len = str->len;
- STR_RELEASE(str);
+ zend_string_release(str);
if (el_len == 0) {
continue;
@@ -162,7 +162,7 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
p += str->len + 1;
}
next_element:
- STR_RELEASE(str);
+ zend_string_release(str);
} ZEND_HASH_FOREACH_END();
assert((uint)(p - env.envp) <= sizeenv);
@@ -260,7 +260,7 @@ PHP_FUNCTION(proc_terminate)
{
zval *zproc;
struct php_process_handle *proc;
- long sig_no = SIGTERM;
+ zend_long sig_no = SIGTERM;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zproc, &sig_no) == FAILURE) {
RETURN_FALSE;
@@ -328,7 +328,7 @@ PHP_FUNCTION(proc_get_status)
array_init(return_value);
add_assoc_string(return_value, "command", proc->command);
- add_assoc_long(return_value, "pid", (long) proc->child);
+ add_assoc_long(return_value, "pid", (zend_long) proc->child);
#ifdef PHP_WIN32
@@ -427,7 +427,7 @@ PHP_FUNCTION(proc_open)
int i;
zval *descitem = NULL;
zend_string *str_index;
- ulong nindex;
+ zend_ulong nindex;
struct php_proc_open_descriptor_item descriptors[PHP_PROC_OPEN_MAX_DESCRIPTORS];
#ifdef PHP_WIN32
PROCESS_INFORMATION pi;
@@ -534,7 +534,7 @@ PHP_FUNCTION(proc_open)
#else
descriptors[ndesc].childend = dup(fd);
if (descriptors[ndesc].childend < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to dup File-Handle for descriptor %ld - %s", nindex, strerror(errno));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to dup File-Handle for descriptor %pd - %s", nindex, strerror(errno));
goto exit_fail;
}
#endif
diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c
index aa3d256c3a..8abccaf820 100644
--- a/ext/standard/quot_print.c
+++ b/ext/standard/quot_print.c
@@ -96,7 +96,7 @@ PHPAPI zend_string *php_quot_print_decode(const unsigned char *str, size_t lengt
i--;
}
- retval = STR_ALLOC(buf_size, 0);
+ retval = zend_string_alloc(buf_size, 0);
i = length; p1 = str; p2 = (unsigned char*)retval->val;
decoded_len = 0;
@@ -147,12 +147,12 @@ PHPAPI zend_string *php_quot_print_decode(const unsigned char *str, size_t lengt
PHPAPI zend_string *php_quot_print_encode(const unsigned char *str, size_t length) /* {{{ */
{
- unsigned long lp = 0;
+ zend_ulong lp = 0;
unsigned char c, *d;
char *hex = "0123456789ABCDEF";
zend_string *ret;
- ret = STR_SAFE_ALLOC(3, (length + (((3 * length)/(PHP_QPRINT_MAXL-9)) + 1)), 0, 0);
+ ret = zend_string_safe_alloc(3, (length + (((3 * length)/(PHP_QPRINT_MAXL-9)) + 1)), 0, 0);
d = (unsigned char*)ret->val;
while (length--) {
@@ -187,7 +187,7 @@ PHPAPI zend_string *php_quot_print_encode(const unsigned char *str, size_t lengt
}
}
*d = '\0';
- ret = STR_REALLOC(ret, d - (unsigned char*)ret->val, 0);
+ ret = zend_string_realloc(ret, d - (unsigned char*)ret->val, 0);
return ret;
}
/* }}} */
@@ -201,21 +201,22 @@ PHPAPI zend_string *php_quot_print_encode(const unsigned char *str, size_t lengt
Convert a quoted-printable string to an 8 bit string */
PHP_FUNCTION(quoted_printable_decode)
{
- char *arg1, *str_in;
+ zend_string *arg1;
+ char *str_in;
zend_string *str_out;
- int arg1_len, i = 0, j = 0, k;
+ size_t i = 0, j = 0, k;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg1, &arg1_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &arg1) == FAILURE) {
return;
}
- if (arg1_len == 0) {
+ if (arg1->len == 0) {
/* shortcut */
RETURN_EMPTY_STRING();
}
- str_in = arg1;
- str_out = STR_ALLOC(arg1_len, 0);
+ str_in = arg1->val;
+ str_out = zend_string_alloc(arg1->len, 0);
while (str_in[i]) {
switch (str_in[i]) {
case '=':
@@ -263,19 +264,18 @@ PHP_FUNCTION(quoted_printable_decode)
/* {{{ proto string quoted_printable_encode(string str) */
PHP_FUNCTION(quoted_printable_encode)
{
- char *str;
+ zend_string *str;
zend_string *new_str;
- int str_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) != SUCCESS) {
return;
}
- if (!str_len) {
+ if (!str->len) {
RETURN_EMPTY_STRING();
}
- new_str = php_quot_print_encode((unsigned char *)str, (size_t)str_len);
+ new_str = php_quot_print_encode((unsigned char *)str->val, (size_t)str->len);
RETURN_STR(new_str);
}
/* }}} */
diff --git a/ext/standard/rand.c b/ext/standard/rand.c
index 702fec2311..fdc86632cd 100644
--- a/ext/standard/rand.c
+++ b/ext/standard/rand.c
@@ -38,7 +38,7 @@
/* {{{ php_srand
*/
-PHPAPI void php_srand(long seed TSRMLS_DC)
+PHPAPI void php_srand(zend_long seed TSRMLS_DC)
{
#ifdef ZTS
BG(rand_seed) = (unsigned int) seed;
@@ -59,9 +59,9 @@ PHPAPI void php_srand(long seed TSRMLS_DC)
/* {{{ php_rand
*/
-PHPAPI long php_rand(TSRMLS_D)
+PHPAPI zend_long php_rand(TSRMLS_D)
{
- long ret;
+ zend_long ret;
if (!BG(rand_is_seeded)) {
php_srand(GENERATE_SEED() TSRMLS_CC);
@@ -229,7 +229,7 @@ PHPAPI php_uint32 php_mt_rand(TSRMLS_D)
Seeds random number generator */
PHP_FUNCTION(srand)
{
- long seed = 0;
+ zend_long seed = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &seed) == FAILURE)
return;
@@ -245,7 +245,7 @@ PHP_FUNCTION(srand)
Seeds Mersenne Twister random number generator */
PHP_FUNCTION(mt_srand)
{
- long seed = 0;
+ zend_long seed = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &seed) == FAILURE)
return;
@@ -288,9 +288,9 @@ PHP_FUNCTION(mt_srand)
Returns a random number */
PHP_FUNCTION(rand)
{
- long min;
- long max;
- long number;
+ zend_long min;
+ zend_long max;
+ zend_long number;
int argc = ZEND_NUM_ARGS();
if (argc != 0 && zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE)
@@ -309,16 +309,16 @@ PHP_FUNCTION(rand)
Returns a random number from Mersenne Twister */
PHP_FUNCTION(mt_rand)
{
- long min;
- long max;
- long number;
+ zend_long min;
+ zend_long max;
+ zend_long number;
int argc = ZEND_NUM_ARGS();
if (argc != 0) {
if (zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE) {
return;
} else if (max < min) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(%ld) is smaller than min(%ld)", max, min);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(" ZEND_LONG_FMT ") is smaller than min(" ZEND_LONG_FMT ")", max, min);
RETURN_FALSE;
}
}
@@ -335,7 +335,7 @@ PHP_FUNCTION(mt_rand)
* Update:
* I talked with Cokus via email and it won't ruin the algorithm
*/
- number = (long) (php_mt_rand(TSRMLS_C) >> 1);
+ number = (zend_long) (php_mt_rand(TSRMLS_C) >> 1);
if (argc == 2) {
RAND_RANGE(number, min, max, PHP_MT_RAND_MAX);
}
diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c
index f5f97161f2..7ae0df6df5 100644
--- a/ext/standard/scanf.c
+++ b/ext/standard/scanf.c
@@ -356,7 +356,7 @@ PHPAPI int ValidateFormat(char *format, int numVars, int *totalSubs)
* must not be a mixture of XPG3 specs and non-XPG3 specs
* in the same format string.
*/
- value = strtoul(format-1, &end, 10);
+ value = ZEND_STRTOUL(format-1, &end, 10);
if (*end != '$') {
goto notXpg;
}
@@ -403,7 +403,7 @@ xpgCheckDone:
* Parse any width specifier.
*/
if (isdigit(UCHAR(*ch))) {
- value = strtoul(format-1, &format, 10);
+ value = ZEND_STRTOUL(format-1, &format, 10);
flags |= SCAN_WIDTH;
ch = format++;
}
@@ -582,7 +582,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
{
int numVars, nconversions, totalVars = -1;
int i, result;
- long value;
+ zend_long value;
int objIndex;
char *end, *baseString;
zval *current;
@@ -590,7 +590,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
int base = 0;
int underflow = 0;
size_t width;
- long (*fn)() = NULL;
+ zend_long (*fn)() = NULL;
char *ch, sch;
int flags;
char buf[64]; /* Temporary buffer to hold scanned number
@@ -708,7 +708,7 @@ literal:
flags |= SCAN_SUPPRESS;
ch = format++;
} else if ( isdigit(UCHAR(*ch))) {
- value = strtoul(format-1, &end, 10);
+ value = ZEND_STRTOUL(format-1, &end, 10);
if (*end == '$') {
format = end+1;
ch = format++;
@@ -720,7 +720,7 @@ literal:
* Parse any width specifier.
*/
if ( isdigit(UCHAR(*ch))) {
- width = strtoul(format-1, &format, 10);
+ width = ZEND_STRTOUL(format-1, &format, 10);
ch = format++;
} else {
width = 0;
@@ -744,7 +744,7 @@ literal:
} else if (numVars) {
current = Z_REFVAL(args[objIndex++]);
zval_ptr_dtor(current);
- ZVAL_LONG(current, (long)(string - baseString) );
+ ZVAL_LONG(current, (zend_long)(string - baseString) );
} else {
add_index_long(return_value, objIndex++, string - baseString);
}
@@ -756,29 +756,29 @@ literal:
case 'D':
op = 'i';
base = 10;
- fn = (long (*)())strtol;
+ fn = (zend_long (*)())ZEND_STRTOL_PTR;
break;
case 'i':
op = 'i';
base = 0;
- fn = (long (*)())strtol;
+ fn = (zend_long (*)())ZEND_STRTOL_PTR;
break;
case 'o':
op = 'i';
base = 8;
- fn = (long (*)())strtol;
+ fn = (zend_long (*)())ZEND_STRTOL_PTR;
break;
case 'x':
case 'X':
op = 'i';
base = 16;
- fn = (long (*)())strtol;
+ fn = (zend_long (*)())ZEND_STRTOL_PTR;
break;
case 'u':
op = 'i';
base = 10;
flags |= SCAN_UNSIGNED;
- fn = (long (*)())strtoul;
+ fn = (zend_long (*)())ZEND_STRTOUL_PTR;
break;
case 'f':
@@ -1049,9 +1049,9 @@ addToInt:
*/
if (!(flags & SCAN_SUPPRESS)) {
*end = '\0';
- value = (long) (*fn)(buf, NULL, base);
+ value = (zend_long) (*fn)(buf, NULL, base);
if ((flags & SCAN_UNSIGNED) && (value < 0)) {
- snprintf(buf, sizeof(buf), "%lu", value); /* INTL: ISO digit */
+ snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, value); /* INTL: ISO digit */
if (numVars && objIndex >= argCount) {
break;
} else if (numVars) {
@@ -1190,7 +1190,7 @@ done:
scan_set_error_return( numVars, return_value );
result = SCAN_ERROR_EOF;
} else if (numVars) {
- convert_to_long(return_value );
+ convert_to_int(return_value );
Z_LVAL_P(return_value) = nconversions;
} else if (nconversions < totalVars) {
/* TODO: not all elements converted. we need to prune the list - cc */
diff --git a/ext/standard/sha1.c b/ext/standard/sha1.c
index 84a7d258c1..2f596eed44 100644
--- a/ext/standard/sha1.c
+++ b/ext/standard/sha1.c
@@ -34,20 +34,19 @@ PHPAPI void make_sha1_digest(char *sha1str, unsigned char *digest)
Calculate the sha1 hash of a string */
PHP_FUNCTION(sha1)
{
- char *arg;
- int arg_len;
+ zend_string *arg;
zend_bool raw_output = 0;
char sha1str[41];
PHP_SHA1_CTX context;
unsigned char digest[20];
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &raw_output) == FAILURE) {
return;
}
sha1str[0] = '\0';
PHP_SHA1Init(&context);
- PHP_SHA1Update(&context, arg, arg_len);
+ PHP_SHA1Update(&context, arg->val, arg->len);
PHP_SHA1Final(digest, &context);
if (raw_output) {
RETURN_STRINGL(digest, 20);
@@ -181,7 +180,7 @@ PHPAPI void PHP_SHA1Init(PHP_SHA1_CTX * context)
context.
*/
PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX * context, const unsigned char *input,
- unsigned int inputLen)
+ size_t inputLen)
{
unsigned int i, index, partLen;
diff --git a/ext/standard/sha1.h b/ext/standard/sha1.h
index ea63a234cf..f852386a62 100644
--- a/ext/standard/sha1.h
+++ b/ext/standard/sha1.h
@@ -31,7 +31,7 @@ typedef struct {
} PHP_SHA1_CTX;
PHPAPI void PHP_SHA1Init(PHP_SHA1_CTX *);
-PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, unsigned int);
+PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, size_t);
PHPAPI void PHP_SHA1Final(unsigned char[20], PHP_SHA1_CTX *);
PHPAPI void make_sha1_digest(char *sha1str, unsigned char *digest);
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index 652512ce07..a0448803f4 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -51,7 +51,7 @@ static php_stream_context *decode_context_param(zval *contextresource TSRMLS_DC)
Creates a pair of connected, indistinguishable socket streams */
PHP_FUNCTION(stream_socket_pair)
{
- long domain, type, protocol;
+ zend_long domain, type, protocol;
php_stream *s1, *s2;
php_socket_t pair[2];
@@ -96,7 +96,7 @@ PHP_FUNCTION(stream_socket_client)
char *hashkey = NULL;
php_stream *stream = NULL;
int err;
- long flags = PHP_STREAM_CLIENT_CONNECT;
+ zend_long flags = PHP_STREAM_CLIENT_CONNECT;
zend_string *errstr = NULL;
php_stream_context *context = NULL;
@@ -141,7 +141,7 @@ PHP_FUNCTION(stream_socket_client)
zend_string *quoted_host = php_addslashes(host, host_len, 0 TSRMLS_CC);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect to %s (%s)", quoted_host->val, errstr == NULL ? "Unknown error" : errstr->val);
- STR_RELEASE(quoted_host);
+ zend_string_release(quoted_host);
}
if (hashkey) {
@@ -157,13 +157,13 @@ PHP_FUNCTION(stream_socket_client)
zval_dtor(zerrstr);
ZVAL_STR(zerrstr, errstr);
} else if (errstr) {
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
}
RETURN_FALSE;
}
if (errstr) {
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
}
php_stream_to_zval(stream, return_value);
@@ -180,7 +180,7 @@ PHP_FUNCTION(stream_socket_server)
zval *zerrno = NULL, *zerrstr = NULL, *zcontext = NULL;
php_stream *stream = NULL;
int err = 0;
- long flags = STREAM_XPORT_BIND | STREAM_XPORT_LISTEN;
+ zend_long flags = STREAM_XPORT_BIND | STREAM_XPORT_LISTEN;
zend_string *errstr = NULL;
php_stream_context *context = NULL;
@@ -222,13 +222,13 @@ PHP_FUNCTION(stream_socket_server)
zval_dtor(zerrstr);
ZVAL_STR(zerrstr, errstr);
} else if (errstr) {
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
}
RETURN_FALSE;
}
if (errstr) {
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
}
php_stream_to_zval(stream, return_value);
@@ -284,7 +284,7 @@ PHP_FUNCTION(stream_socket_accept)
}
if (errstr) {
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
}
}
/* }}} */
@@ -321,7 +321,7 @@ PHP_FUNCTION(stream_socket_sendto)
{
php_stream *stream;
zval *zstream;
- long flags = 0;
+ zend_long flags = 0;
char *data, *target_addr = NULL;
int datalen, target_addr_len = 0;
php_sockaddr_storage sa;
@@ -351,9 +351,9 @@ PHP_FUNCTION(stream_socket_recvfrom)
php_stream *stream;
zval *zstream, *zremote = NULL;
zend_string *remote_addr = NULL;
- long to_read = 0;
+ zend_long to_read = 0;
zend_string *read_buf;
- long flags = 0;
+ zend_long flags = 0;
int recvd;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|lz/", &zstream, &to_read, &flags, &zremote) == FAILURE) {
@@ -372,7 +372,7 @@ PHP_FUNCTION(stream_socket_recvfrom)
RETURN_FALSE;
}
- read_buf = STR_ALLOC(to_read, 0);
+ read_buf = zend_string_alloc(to_read, 0);
recvd = php_stream_xport_recvfrom(stream, read_buf->val, to_read, flags, NULL, NULL,
zremote ? &remote_addr : NULL
@@ -387,7 +387,7 @@ PHP_FUNCTION(stream_socket_recvfrom)
RETURN_NEW_STR(read_buf);
}
- STR_FREE(read_buf);
+ zend_string_free(read_buf);
RETURN_FALSE;
}
/* }}} */
@@ -398,7 +398,7 @@ PHP_FUNCTION(stream_get_contents)
{
php_stream *stream;
zval *zsrc;
- long maxlen = PHP_STREAM_COPY_ALL,
+ zend_long maxlen = PHP_STREAM_COPY_ALL,
desiredpos = -1L;
zend_string *contents;
@@ -423,13 +423,13 @@ PHP_FUNCTION(stream_get_contents)
if (seek_res != 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
- "Failed to seek to position %ld in the stream", desiredpos);
+ "Failed to seek to position %pd in the stream", desiredpos);
RETURN_FALSE;
}
}
if (maxlen > INT_MAX) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "maxlen truncated from %ld to %d bytes", maxlen, INT_MAX);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "maxlen truncated from %pd to %d bytes", maxlen, INT_MAX);
maxlen = INT_MAX;
}
if ((contents = php_stream_copy_to_mem(stream, maxlen, 0))) {
@@ -446,7 +446,7 @@ PHP_FUNCTION(stream_copy_to_stream)
{
php_stream *src, *dest;
zval *zsrc, *zdest;
- long maxlen = PHP_STREAM_COPY_ALL, pos = 0;
+ zend_long maxlen = PHP_STREAM_COPY_ALL, pos = 0;
size_t len;
int ret;
@@ -458,7 +458,7 @@ PHP_FUNCTION(stream_copy_to_stream)
php_stream_from_zval(dest, zdest);
if (pos > 0 && php_stream_seek(src, pos, SEEK_SET) < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position " ZEND_LONG_FMT " in the stream", pos);
RETURN_FALSE;
}
@@ -541,7 +541,7 @@ PHP_FUNCTION(stream_get_transports)
if ((stream_xport_hash = php_stream_xport_get_hash())) {
array_init(return_value);
ZEND_HASH_FOREACH_STR_KEY(stream_xport_hash, stream_xport) {
- add_next_index_str(return_value, STR_COPY(stream_xport));
+ add_next_index_str(return_value, zend_string_copy(stream_xport));
} ZEND_HASH_FOREACH_END();
} else {
RETURN_FALSE;
@@ -564,7 +564,7 @@ PHP_FUNCTION(stream_get_wrappers)
array_init(return_value);
ZEND_HASH_FOREACH_STR_KEY(url_stream_wrappers_hash, stream_protocol) {
if (stream_protocol) {
- add_next_index_str(return_value, STR_COPY(stream_protocol));
+ add_next_index_str(return_value, zend_string_copy(stream_protocol));
}
} ZEND_HASH_FOREACH_END();
} else {
@@ -619,7 +619,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
php_stream *stream;
int ret = 0;
zend_string *key;
- ulong num_ind;
+ zend_ulong num_ind;
if (Z_TYPE_P(stream_array) != IS_ARRAY) {
return 0;
@@ -723,7 +723,7 @@ PHP_FUNCTION(stream_select)
fd_set rfds, wfds, efds;
php_socket_t max_fd = 0;
int retval, sets = 0;
- long usec = 0;
+ zend_long usec = 0;
int set_count, max_set_count = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!a/!a/!z!|l", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE)
@@ -763,7 +763,7 @@ PHP_FUNCTION(stream_select)
/* If seconds is not set to null, build the timeval, else we wait indefinitely */
if (sec != NULL) {
- convert_to_long_ex(sec);
+ convert_to_int_ex(sec);
if (Z_LVAL_P(sec) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The seconds parameter must be greater than 0");
@@ -1118,7 +1118,7 @@ static void apply_filter_to_stream(int append, INTERNAL_FUNCTION_PARAMETERS)
php_stream *stream;
char *filtername;
int filternamelen;
- long read_write = 0;
+ zend_long read_write = 0;
zval *filterparams = NULL;
php_stream_filter *filter = NULL;
int ret;
@@ -1242,7 +1242,7 @@ PHP_FUNCTION(stream_get_line)
{
char *str = NULL;
int str_len = 0;
- long max_length;
+ zend_long max_length;
zval *zstream;
zend_string *buf;
php_stream *stream;
@@ -1276,7 +1276,7 @@ PHP_FUNCTION(stream_set_blocking)
{
zval *arg1;
int block;
- long arg2;
+ zend_long arg2;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &arg2) == FAILURE) {
@@ -1302,7 +1302,7 @@ PHP_FUNCTION(stream_set_blocking)
PHP_FUNCTION(stream_set_timeout)
{
zval *socket;
- long seconds, microseconds = 0;
+ zend_long seconds, microseconds = 0;
struct timeval t;
php_stream *stream;
int argc = ZEND_NUM_ARGS();
@@ -1337,7 +1337,7 @@ PHP_FUNCTION(stream_set_write_buffer)
{
zval *arg1;
int ret;
- long arg2;
+ zend_long arg2;
size_t buff;
php_stream *stream;
@@ -1365,7 +1365,7 @@ PHP_FUNCTION(stream_set_write_buffer)
PHP_FUNCTION(stream_set_chunk_size)
{
int ret;
- long csize;
+ zend_long csize;
zval *zstream;
php_stream *stream;
@@ -1374,7 +1374,7 @@ PHP_FUNCTION(stream_set_chunk_size)
}
if (csize <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "The chunk size must be a positive integer, given %ld", csize);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The chunk size must be a positive integer, given " ZEND_LONG_FMT, csize);
RETURN_FALSE;
}
/* stream.chunk_size is actually a size_t, but php_stream_set_option
@@ -1390,7 +1390,7 @@ PHP_FUNCTION(stream_set_chunk_size)
ret = php_stream_set_option(stream, PHP_STREAM_OPTION_SET_CHUNK_SIZE, (int)csize, NULL);
- RETURN_LONG(ret > 0 ? (long)ret : (long)EOF);
+ RETURN_LONG(ret > 0 ? (zend_long)ret : (zend_long)EOF);
}
/* }}} */
@@ -1400,7 +1400,7 @@ PHP_FUNCTION(stream_set_read_buffer)
{
zval *arg1;
int ret;
- long arg2;
+ zend_long arg2;
size_t buff;
php_stream *stream;
@@ -1427,7 +1427,7 @@ PHP_FUNCTION(stream_set_read_buffer)
Enable or disable a specific kind of crypto on the stream */
PHP_FUNCTION(stream_socket_enable_crypto)
{
- long cryptokind = 0;
+ zend_long cryptokind = 0;
zval *zstream, *zsessstream = NULL;
php_stream *stream, *sessstream = NULL;
zend_bool enable, cryptokindnull;
@@ -1558,7 +1558,7 @@ PHP_FUNCTION(stream_supports_lock)
disallowed. */
PHP_FUNCTION(stream_socket_shutdown)
{
- long how;
+ zend_long how;
zval *zstream;
php_stream *stream;
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 82b98eb094..325c66affa 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -115,7 +115,7 @@ void register_string_constants(INIT_FUNC_ARGS)
}
/* }}} */
-int php_tag_find(char *tag, int len, char *set);
+int php_tag_find(char *tag, size_t len, char *set);
/* this is read-only, so it's ok */
static char hexconvtab[] = "0123456789abcdef";
@@ -132,7 +132,7 @@ static zend_string *php_bin2hex(const unsigned char *old, const size_t oldlen)
zend_string *result;
size_t i, j;
- result = STR_SAFE_ALLOC(oldlen, 2 * sizeof(char), 0, 0);
+ result = zend_string_safe_alloc(oldlen, 2 * sizeof(char), 0, 0);
for (i = j = 0; i < oldlen; i++) {
result->val[j++] = hexconvtab[old[i] >> 4];
@@ -149,7 +149,7 @@ static zend_string *php_bin2hex(const unsigned char *old, const size_t oldlen)
static zend_string *php_hex2bin(const unsigned char *old, const size_t oldlen)
{
size_t target_length = oldlen >> 1;
- zend_string *str = STR_ALLOC(target_length, 0);
+ zend_string *str = zend_string_alloc(target_length, 0);
unsigned char *ret = (unsigned char *)str->val;
size_t i, j;
@@ -164,7 +164,7 @@ static zend_string *php_hex2bin(const unsigned char *old, const size_t oldlen)
} else if (c >= 'A' && c <= 'F') {
d = (c - 'A' + 10) << 4;
} else {
- STR_FREE(str);
+ zend_string_free(str);
return NULL;
}
c = old[j++];
@@ -175,7 +175,7 @@ static zend_string *php_hex2bin(const unsigned char *old, const size_t oldlen)
} else if (c >= 'A' && c <= 'F') {
d |= c - 'A' + 10;
} else {
- STR_FREE(str);
+ zend_string_free(str);
return NULL;
}
ret[i] = d;
@@ -237,14 +237,13 @@ PHP_MSHUTDOWN_FUNCTION(localeconv)
PHP_FUNCTION(bin2hex)
{
zend_string *result;
- char *data;
- int datalen;
+ zend_string *data;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &datalen) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &data) == FAILURE) {
return;
}
- result = php_bin2hex((unsigned char *)data, datalen);
+ result = php_bin2hex((unsigned char *)data->val, data->len);
if (!result) {
RETURN_FALSE;
@@ -282,39 +281,38 @@ PHP_FUNCTION(hex2bin)
static void php_spn_common_handler(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{ */
{
- char *s11, *s22;
- int len1, len2;
- long start = 0, len = 0;
+ zend_string *s11, *s22;
+ zend_long start = 0, len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ll", &s11, &len1,
- &s22, &len2, &start, &len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|ll", &s11,
+ &s22, &start, &len) == FAILURE) {
return;
}
if (ZEND_NUM_ARGS() < 4) {
- len = len1;
+ len = s11->len;
}
/* look at substr() function for more information */
if (start < 0) {
- start += len1;
+ start += (zend_long)s11->len;
if (start < 0) {
start = 0;
}
- } else if (start > len1) {
+ } else if ((size_t)start > s11->len) {
RETURN_FALSE;
}
if (len < 0) {
- len += (len1 - start);
+ len += (s11->len - start);
if (len < 0) {
len = 0;
}
}
- if (len > len1 - start) {
- len = len1 - start;
+ if (len > (zend_long)s11->len - start) {
+ len = s11->len - start;
}
if(len == 0) {
@@ -322,15 +320,15 @@ static void php_spn_common_handler(INTERNAL_FUNCTION_PARAMETERS, int behavior) /
}
if (behavior == STR_STRSPN) {
- RETURN_LONG(php_strspn(s11 + start /*str1_start*/,
- s22 /*str2_start*/,
- s11 + start + len /*str1_end*/,
- s22 + len2 /*str2_end*/));
+ RETURN_LONG(php_strspn(s11->val + start /*str1_start*/,
+ s22->val /*str2_start*/,
+ s11->val + start + len /*str1_end*/,
+ s22->val + s22->len /*str2_end*/));
} else if (behavior == STR_STRCSPN) {
- RETURN_LONG(php_strcspn(s11 + start /*str1_start*/,
- s22 /*str2_start*/,
- s11 + start + len /*str1_end*/,
- s22 + len2 /*str2_end*/));
+ RETURN_LONG(php_strcspn(s11->val + start /*str1_start*/,
+ s22->val /*str2_start*/,
+ s11->val + start + len /*str1_end*/,
+ s22->val + s22->len /*str2_end*/));
}
}
@@ -526,7 +524,7 @@ PHP_MINIT_FUNCTION(nl_langinfo)
Query language and locale information */
PHP_FUNCTION(nl_langinfo)
{
- long item;
+ zend_long item;
char *value;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &item) == FAILURE) {
@@ -694,7 +692,7 @@ PHP_FUNCTION(nl_langinfo)
#endif
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Item '%ld' is not valid", item);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Item '" ZEND_LONG_FMT "' is not valid", item);
RETURN_FALSE;
}
/* }}} */
@@ -714,15 +712,14 @@ PHP_FUNCTION(nl_langinfo)
Compares two strings using the current locale */
PHP_FUNCTION(strcoll)
{
- char *s1, *s2;
- int s1len, s2len;
+ zend_string *s1, *s2;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &s1, &s1len, &s2, &s2len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &s1, &s2) == FAILURE) {
return;
}
- RETURN_LONG(strcoll((const char *) s1,
- (const char *) s2));
+ RETURN_LONG(strcoll((const char *) s1->val,
+ (const char *) s2->val));
}
/* }}} */
#endif
@@ -732,7 +729,7 @@ PHP_FUNCTION(strcoll)
* it needs to be incrementing.
* Returns: FAILURE/SUCCESS whether the input was correct (i.e. no range errors)
*/
-static inline int php_charmask(unsigned char *input, int len, char *mask TSRMLS_DC)
+static inline int php_charmask(unsigned char *input, size_t len, char *mask TSRMLS_DC)
{
unsigned char *end;
unsigned char c;
@@ -781,9 +778,9 @@ static inline int php_charmask(unsigned char *input, int len, char *mask TSRMLS_
* mode 3 : trim left and right
* what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0')
*/
-PHPAPI char *php_trim(char *c, int len, char *what, int what_len, zval *return_value, int mode TSRMLS_DC)
+PHPAPI char *php_trim(char *c, size_t len, char *what, size_t what_len, zval *return_value, int mode TSRMLS_DC)
{
- register int i;
+ register zend_long i;
int trimmed = 0;
char mask[256];
@@ -828,23 +825,22 @@ PHPAPI char *php_trim(char *c, int len, char *what, int what_len, zval *return_v
*/
static void php_do_trim(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
- char *str;
- char *what = NULL;
- int str_len, what_len = 0;
+ zend_string *str;
+ zend_string *what = NULL;
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &what, &what_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|S", &str, &what) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(1, 2)
- Z_PARAM_STRING(str, str_len)
+ Z_PARAM_STR(str)
Z_PARAM_OPTIONAL
- Z_PARAM_STRING(what, what_len)
+ Z_PARAM_STR(what)
ZEND_PARSE_PARAMETERS_END();
#endif
- php_trim(str, str_len, what, what_len, return_value, mode TSRMLS_CC);
+ php_trim(str->val, str->len, (what ? what->val : NULL), (what ? what->len : 0), return_value, mode TSRMLS_CC);
}
/* }}} */
@@ -876,23 +872,33 @@ PHP_FUNCTION(ltrim)
Wraps buffer to selected number of characters using string break char */
PHP_FUNCTION(wordwrap)
{
- const char *text, *breakchar = "\n";
- int textlen, breakcharlen = 1, newtextlen, chk;
+ zend_string *text, *breakchar = NULL, *breakchar_save = NULL;
+ size_t newtextlen, chk;
size_t alloced;
- long current = 0, laststart = 0, lastspace = 0;
- long linelength = 75;
+ zend_long current = 0, laststart = 0, lastspace = 0;
+ zend_long linelength = 75;
zend_bool docut = 0;
zend_string *newtext;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lsb", &text, &textlen, &linelength, &breakchar, &breakcharlen, &docut) == FAILURE) {
+ breakchar = breakchar_save = zend_string_init("\n", 1, 1);
+ if (!breakchar) {
return;
}
- if (textlen == 0) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|lSb", &text, &linelength, &breakchar, &docut) == FAILURE) {
+ zend_string_free(breakchar);
+ return;
+ }
+
+ if (breakchar != breakchar_save) {
+ zend_string_free(breakchar_save);
+ }
+
+ if (text->len == 0) {
RETURN_EMPTY_STRING();
}
- if (breakcharlen == 0) {
+ if (breakchar->len == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Break string cannot be empty");
RETURN_FALSE;
}
@@ -904,21 +910,21 @@ PHP_FUNCTION(wordwrap)
/* Special case for a single-character break as it needs no
additional storage space */
- if (breakcharlen == 1 && !docut) {
- newtext = STR_INIT(text, textlen, 0);
+ if (breakchar->len == 1 && !docut) {
+ newtext = zend_string_init(text->val, text->len, 0);
laststart = lastspace = 0;
- for (current = 0; current < textlen; current++) {
- if (text[current] == breakchar[0]) {
+ for (current = 0; current < text->len; current++) {
+ if (text->val[current] == breakchar->val[0]) {
laststart = lastspace = current + 1;
- } else if (text[current] == ' ') {
+ } else if (text->val[current] == ' ') {
if (current - laststart >= linelength) {
- newtext->val[current] = breakchar[0];
+ newtext->val[current] = breakchar->val[0];
laststart = current + 1;
}
lastspace = current;
} else if (current - laststart >= linelength && laststart != lastspace) {
- newtext->val[lastspace] = breakchar[0];
+ newtext->val[lastspace] = breakchar->val[0];
laststart = lastspace + 1;
}
}
@@ -927,44 +933,44 @@ PHP_FUNCTION(wordwrap)
} else {
/* Multiple character line break or forced cut */
if (linelength > 0) {
- chk = (int)(textlen/linelength + 1);
- newtext = STR_ALLOC(chk * breakcharlen + textlen, 0);
- alloced = textlen + chk * breakcharlen + 1;
+ chk = (size_t)(text->len/linelength + 1);
+ newtext = zend_string_alloc(chk * breakchar->len + text->len, 0);
+ alloced = text->len + chk * breakchar->len + 1;
} else {
- chk = textlen;
- alloced = textlen * (breakcharlen + 1) + 1;
- newtext = STR_ALLOC(textlen * (breakcharlen + 1), 0);
+ chk = text->len;
+ alloced = text->len * (breakchar->len + 1) + 1;
+ newtext = zend_string_alloc(text->len * (breakchar->len + 1), 0);
}
/* now keep track of the actual new text length */
newtextlen = 0;
laststart = lastspace = 0;
- for (current = 0; current < textlen; current++) {
+ for (current = 0; current < text->len; current++) {
if (chk <= 0) {
- alloced += (int) (((textlen - current + 1)/linelength + 1) * breakcharlen) + 1;
- newtext = STR_REALLOC(newtext, alloced, 0);
- chk = (int) ((textlen - current)/linelength) + 1;
+ alloced += (size_t) (((text->len - current + 1)/linelength + 1) * breakchar->len) + 1;
+ newtext = zend_string_realloc(newtext, alloced, 0);
+ chk = (size_t) ((text->len - current)/linelength) + 1;
}
/* when we hit an existing break, copy to new buffer, and
* fix up laststart and lastspace */
- if (text[current] == breakchar[0]
- && current + breakcharlen < textlen
- && !strncmp(text+current, breakchar, breakcharlen)) {
- memcpy(newtext->val + newtextlen, text + laststart, current - laststart + breakcharlen);
- newtextlen += current - laststart + breakcharlen;
- current += breakcharlen - 1;
+ if (text->val[current] == breakchar->val[0]
+ && current + breakchar->len < text->len
+ && !strncmp(text->val+current, breakchar->val, breakchar->len)) {
+ memcpy(newtext->val + newtextlen, text->val + laststart, current - laststart + breakchar->len);
+ newtextlen += current - laststart + breakchar->len;
+ current += breakchar->len - 1;
laststart = lastspace = current + 1;
chk--;
}
/* if it is a space, check if it is at the line boundary,
* copy and insert a break, or just keep track of it */
- else if (text[current] == ' ') {
+ else if (text->val[current] == ' ') {
if (current - laststart >= linelength) {
- memcpy(newtext->val + newtextlen, text + laststart, current - laststart);
+ memcpy(newtext->val + newtextlen, text->val + laststart, current - laststart);
newtextlen += current - laststart;
- memcpy(newtext->val + newtextlen, breakchar, breakcharlen);
- newtextlen += breakcharlen;
+ memcpy(newtext->val + newtextlen, breakchar->val, breakchar->len);
+ newtextlen += breakchar->len;
laststart = current + 1;
chk--;
}
@@ -975,10 +981,10 @@ PHP_FUNCTION(wordwrap)
* copy and insert a break. */
else if (current - laststart >= linelength
&& docut && laststart >= lastspace) {
- memcpy(newtext->val + newtextlen, text + laststart, current - laststart);
+ memcpy(newtext->val + newtextlen, text->val + laststart, current - laststart);
newtextlen += current - laststart;
- memcpy(newtext->val + newtextlen, breakchar, breakcharlen);
- newtextlen += breakcharlen;
+ memcpy(newtext->val + newtextlen, breakchar->val, breakchar->len);
+ newtextlen += breakchar->len;
laststart = lastspace = current;
chk--;
}
@@ -987,10 +993,10 @@ PHP_FUNCTION(wordwrap)
* up the laststart */
else if (current - laststart >= linelength
&& laststart < lastspace) {
- memcpy(newtext->val + newtextlen, text + laststart, lastspace - laststart);
+ memcpy(newtext->val + newtextlen, text->val + laststart, lastspace - laststart);
newtextlen += lastspace - laststart;
- memcpy(newtext->val + newtextlen, breakchar, breakcharlen);
- newtextlen += breakcharlen;
+ memcpy(newtext->val + newtextlen, breakchar->val, breakchar->len);
+ newtextlen += breakchar->len;
laststart = lastspace = lastspace + 1;
chk--;
}
@@ -998,13 +1004,13 @@ PHP_FUNCTION(wordwrap)
/* copy over any stragglers */
if (laststart != current) {
- memcpy(newtext->val + newtextlen, text + laststart, current - laststart);
+ memcpy(newtext->val + newtextlen, text->val + laststart, current - laststart);
newtextlen += current - laststart;
}
newtext->val[newtextlen] = '\0';
/* free unused memory */
- newtext = STR_REALLOC(newtext, newtextlen, 0);
+ newtext = zend_string_realloc(newtext, newtextlen, 0);
RETURN_NEW_STR(newtext);
}
@@ -1013,7 +1019,7 @@ PHP_FUNCTION(wordwrap)
/* {{{ php_explode
*/
-PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, long limit)
+PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, zend_long limit)
{
char *p1, *p2, *endp;
@@ -1039,7 +1045,7 @@ PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, long limit)
/* {{{ php_explode_negative_limit
*/
-PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_value, long limit)
+PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_value, zend_long limit)
{
#define EXPLODE_ALLOC_STEP 64
char *p1, *p2, *endp;
@@ -1055,8 +1061,8 @@ PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_valu
by doing nothing we return empty array
*/
} else {
- int allocated = EXPLODE_ALLOC_STEP, found = 0;
- long i, to_return;
+ size_t allocated = EXPLODE_ALLOC_STEP, found = 0;
+ zend_long i, to_return;
char **positions = emalloc(allocated * sizeof(char *));
positions[found++] = p1;
@@ -1085,7 +1091,7 @@ PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_valu
PHP_FUNCTION(explode)
{
zend_string *str, *delim;
- long limit = LONG_MAX; /* No limit */
+ zend_long limit = ZEND_LONG_MAX; /* No limit */
zval zdelim, zstr;
#ifndef FAST_ZPP
@@ -1167,7 +1173,7 @@ again:
case IS_DOUBLE: {
char *stmp;
- int str_len = spprintf(&stmp, 0, "%.*G", (int) EG(precision), Z_DVAL_P(tmp));
+ size_t str_len = spprintf(&stmp, 0, "%.*G", (int) EG(precision), Z_DVAL_P(tmp));
smart_str_appendl(&implstr, stmp, str_len);
efree(stmp);
}
@@ -1180,7 +1186,7 @@ again:
default:
str = zval_get_string(tmp);
smart_str_appendl(&implstr, str->val, str->len);
- STR_RELEASE(str);
+ zend_string_release(str);
break;
}
@@ -1255,26 +1261,24 @@ PHP_FUNCTION(implode)
Tokenize a string */
PHP_FUNCTION(strtok)
{
- char *str, *tok = NULL;
- int str_len, tok_len = 0;
+ zend_string *str, *tok = NULL;
char *token;
char *token_end;
char *p;
char *pe;
int skipped = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &tok, &tok_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|S", &str, &tok) == FAILURE) {
return;
}
if (ZEND_NUM_ARGS() == 1) {
tok = str;
- tok_len = str_len;
} else {
zval_ptr_dtor(&BG(strtok_zval));
- ZVAL_STRINGL(&BG(strtok_zval), str, str_len);
+ ZVAL_STRINGL(&BG(strtok_zval), str->val, str->len);
BG(strtok_last) = BG(strtok_string) = Z_STRVAL(BG(strtok_zval));
- BG(strtok_len) = str_len;
+ BG(strtok_len) = str->len;
}
p = BG(strtok_last); /* Where we start to search */
@@ -1284,8 +1288,8 @@ PHP_FUNCTION(strtok)
RETURN_FALSE;
}
- token = tok;
- token_end = token + tok_len;
+ token = tok->val;
+ token_end = token + tok->len;
while (token < token_end) {
STRTOK_TABLE(token++) = 1;
@@ -1320,7 +1324,7 @@ return_token:
/* Restore table -- usually faster then memset'ing the table on every invocation */
restore:
- token = tok;
+ token = tok->val;
while (token < token_end) {
STRTOK_TABLE(token++) = 0;
@@ -1349,15 +1353,14 @@ PHPAPI char *php_strtoupper(char *s, size_t len)
Makes a string uppercase */
PHP_FUNCTION(strtoupper)
{
- char *arg;
- int arglen;
+ zend_string *arg;
zend_string *result;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arglen) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &arg) == FAILURE) {
return;
}
- result = STR_INIT(arg, arglen, 0);
+ result = zend_string_init(arg->val, arg->len, 0);
php_strtoupper(result->val, result->len);
RETURN_NEW_STR(result);
}
@@ -1384,21 +1387,20 @@ PHPAPI char *php_strtolower(char *s, size_t len)
Makes a string lowercase */
PHP_FUNCTION(strtolower)
{
- char *str;
- int arglen;
+ zend_string *str;
zend_string *result;
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &arglen) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_STRING(str, arglen)
+ Z_PARAM_STR(str)
ZEND_PARSE_PARAMETERS_END();
#endif
- result = STR_INIT(str, arglen, 0);
+ result = zend_string_init(str->val, str->len, 0);
php_strtolower(result->val, result->len);
RETURN_NEW_STR(result);
}
@@ -1479,7 +1481,7 @@ quit_loop:
len = cend - comp;
- ret = STR_INIT(comp, len, 0);
+ ret = zend_string_init(comp, len, 0);
return ret;
}
/* }}} */
@@ -1519,7 +1521,7 @@ PHP_FUNCTION(dirname)
return;
}
- ret = STR_INIT(str, str_len, 0);
+ ret = zend_string_init(str, str_len, 0);
ret->len = zend_dirname(ret->val, str_len);
RETURN_NEW_STR(ret);
@@ -1533,7 +1535,7 @@ PHP_FUNCTION(pathinfo)
zval tmp;
char *path, *dirname;
int path_len, have_basename;
- long opt = PHP_PATHINFO_ALL;
+ zend_long opt = PHP_PATHINFO_ALL;
zend_string *ret = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &path, &path_len, &opt) == FAILURE) {
@@ -1555,7 +1557,7 @@ PHP_FUNCTION(pathinfo)
if (have_basename) {
ret = php_basename(path, path_len, NULL, 0 TSRMLS_CC);
- add_assoc_str(&tmp, "basename", STR_COPY(ret));
+ add_assoc_str(&tmp, "basename", zend_string_copy(ret));
}
if ((opt & PHP_PATHINFO_EXTENSION) == PHP_PATHINFO_EXTENSION) {
@@ -1590,7 +1592,7 @@ PHP_FUNCTION(pathinfo)
}
if (ret) {
- STR_RELEASE(ret);
+ zend_string_release(ret);
}
if (opt == PHP_PATHINFO_ALL) {
@@ -1678,7 +1680,7 @@ static int php_needle_char(zval *needle, char *target TSRMLS_DC)
{
zval holder = *needle;
zval_copy_ctor(&(holder));
- convert_to_long(&(holder));
+ convert_to_int(&(holder));
if(Z_TYPE(holder) != IS_LONG) {
return FAILURE;
}
@@ -1698,19 +1700,18 @@ static int php_needle_char(zval *needle, char *target TSRMLS_DC)
PHP_FUNCTION(stristr)
{
zval *needle;
- char *haystack;
- int haystack_len;
+ zend_string *haystack;
char *found = NULL;
- int found_offset;
+ size_t found_offset;
char *haystack_dup;
char needle_char[2];
zend_bool part = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|b", &haystack, &haystack_len, &needle, &part) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|b", &haystack, &needle, &part) == FAILURE) {
return;
}
- haystack_dup = estrndup(haystack, haystack_len);
+ haystack_dup = estrndup(haystack->val, haystack->len);
if (Z_TYPE_P(needle) == IS_STRING) {
char *orig_needle;
@@ -1720,7 +1721,7 @@ PHP_FUNCTION(stristr)
RETURN_FALSE;
}
orig_needle = estrndup(Z_STRVAL_P(needle), Z_STRLEN_P(needle));
- found = php_stristr(haystack_dup, orig_needle, haystack_len, Z_STRLEN_P(needle));
+ found = php_stristr(haystack_dup, orig_needle, haystack->len, Z_STRLEN_P(needle));
efree(orig_needle);
} else {
if (php_needle_char(needle, needle_char TSRMLS_CC) != SUCCESS) {
@@ -1729,15 +1730,15 @@ PHP_FUNCTION(stristr)
}
needle_char[1] = 0;
- found = php_stristr(haystack_dup, needle_char, haystack_len, 1);
+ found = php_stristr(haystack_dup, needle_char, haystack->len, 1);
}
if (found) {
found_offset = found - haystack_dup;
if (part) {
- RETVAL_STRINGL(haystack, found_offset);
+ RETVAL_STRINGL(haystack->val, found_offset);
} else {
- RETVAL_STRINGL(haystack + found_offset, haystack_len - found_offset);
+ RETVAL_STRINGL(haystack->val + found_offset, haystack->len - found_offset);
}
} else {
RETVAL_FALSE;
@@ -1752,14 +1753,13 @@ PHP_FUNCTION(stristr)
PHP_FUNCTION(strstr)
{
zval *needle;
- char *haystack;
- int haystack_len;
+ zend_string *haystack;
char *found = NULL;
char needle_char[2];
- long found_offset;
+ zend_long found_offset;
zend_bool part = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|b", &haystack, &haystack_len, &needle, &part) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|b", &haystack, &needle, &part) == FAILURE) {
return;
}
@@ -1769,22 +1769,22 @@ PHP_FUNCTION(strstr)
RETURN_FALSE;
}
- found = (char*)php_memnstr(haystack, Z_STRVAL_P(needle), Z_STRLEN_P(needle), haystack + haystack_len);
+ found = (char*)php_memnstr(haystack->val, Z_STRVAL_P(needle), Z_STRLEN_P(needle), haystack->val + haystack->len);
} else {
if (php_needle_char(needle, needle_char TSRMLS_CC) != SUCCESS) {
RETURN_FALSE;
}
needle_char[1] = 0;
- found = (char*)php_memnstr(haystack, needle_char, 1, haystack + haystack_len);
+ found = (char*)php_memnstr(haystack->val, needle_char, 1, haystack->val + haystack->len);
}
if (found) {
- found_offset = found - haystack;
+ found_offset = found - haystack->val;
if (part) {
- RETURN_STRINGL(haystack, found_offset);
+ RETURN_STRINGL(haystack->val, found_offset);
} else {
- RETURN_STRINGL(found, haystack_len - found_offset);
+ RETURN_STRINGL(found, haystack->len - found_offset);
}
}
RETURN_FALSE;
@@ -1800,26 +1800,25 @@ PHP_FUNCTION(strstr)
PHP_FUNCTION(strpos)
{
zval *needle;
- char *haystack;
+ zend_string *haystack;
char *found = NULL;
char needle_char[2];
- long offset = 0;
- int haystack_len;
+ zend_long offset = 0;
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|l", &haystack, &haystack_len, &needle, &offset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|l", &haystack, &needle, &offset) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(2, 3)
- Z_PARAM_STRING(haystack, haystack_len)
+ Z_PARAM_STR(haystack)
Z_PARAM_ZVAL(needle)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(offset)
ZEND_PARSE_PARAMETERS_END();
#endif
- if (offset < 0 || offset > haystack_len) {
+ if (offset < 0 || offset > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string");
RETURN_FALSE;
}
@@ -1830,24 +1829,24 @@ PHP_FUNCTION(strpos)
RETURN_FALSE;
}
- found = (char*)php_memnstr(haystack + offset,
+ found = (char*)php_memnstr(haystack->val + offset,
Z_STRVAL_P(needle),
Z_STRLEN_P(needle),
- haystack + haystack_len);
+ haystack->val + haystack->len);
} else {
if (php_needle_char(needle, needle_char TSRMLS_CC) != SUCCESS) {
RETURN_FALSE;
}
needle_char[1] = 0;
- found = (char*)php_memnstr(haystack + offset,
+ found = (char*)php_memnstr(haystack->val + offset,
needle_char,
1,
- haystack + haystack_len);
+ haystack->val + haystack->len);
}
if (found) {
- RETURN_LONG(found - haystack);
+ RETURN_LONG(found - haystack->val);
} else {
RETURN_FALSE;
}
@@ -1859,38 +1858,37 @@ PHP_FUNCTION(strpos)
PHP_FUNCTION(stripos)
{
char *found = NULL;
- char *haystack;
- int haystack_len;
- long offset = 0;
+ zend_string *haystack;
+ zend_long offset = 0;
char *needle_dup = NULL, *haystack_dup;
char needle_char[2];
zval *needle;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|l", &haystack, &haystack_len, &needle, &offset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|l", &haystack, &needle, &offset) == FAILURE) {
return;
}
- if (offset < 0 || offset > haystack_len) {
+ if (offset < 0 || offset > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string");
RETURN_FALSE;
}
- if (haystack_len == 0) {
+ if (haystack->len == 0) {
RETURN_FALSE;
}
- haystack_dup = estrndup(haystack, haystack_len);
- php_strtolower(haystack_dup, haystack_len);
+ haystack_dup = estrndup(haystack->val, haystack->len);
+ php_strtolower(haystack_dup, haystack->len);
if (Z_TYPE_P(needle) == IS_STRING) {
- if (Z_STRLEN_P(needle) == 0 || Z_STRLEN_P(needle) > haystack_len) {
+ if (Z_STRLEN_P(needle) == 0 || Z_STRLEN_P(needle) > haystack->len) {
efree(haystack_dup);
RETURN_FALSE;
}
needle_dup = estrndup(Z_STRVAL_P(needle), Z_STRLEN_P(needle));
php_strtolower(needle_dup, Z_STRLEN_P(needle));
- found = (char*)php_memnstr(haystack_dup + offset, needle_dup, Z_STRLEN_P(needle), haystack_dup + haystack_len);
+ found = (char*)php_memnstr(haystack_dup + offset, needle_dup, Z_STRLEN_P(needle), haystack_dup + haystack->len);
} else {
if (php_needle_char(needle, needle_char TSRMLS_CC) != SUCCESS) {
efree(haystack_dup);
@@ -1901,7 +1899,7 @@ PHP_FUNCTION(stripos)
found = (char*)php_memnstr(haystack_dup + offset,
needle_char,
sizeof(needle_char) - 1,
- haystack_dup + haystack_len);
+ haystack_dup + haystack->len);
}
efree(haystack_dup);
@@ -1922,18 +1920,19 @@ PHP_FUNCTION(stripos)
PHP_FUNCTION(strrpos)
{
zval *zneedle;
- char *needle, *haystack;
- int needle_len, haystack_len;
- long offset = 0;
+ char *needle;
+ zend_string *haystack;
+ size_t needle_len;
+ zend_long offset = 0;
char *p, *e, ord_needle[2];
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|l", &haystack, &haystack_len, &zneedle, &offset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|l", &haystack, &zneedle, &offset) == FAILURE) {
RETURN_FALSE;
}
#else
ZEND_PARSE_PARAMETERS_START(2, 3)
- Z_PARAM_STRING(haystack, haystack_len)
+ Z_PARAM_STR(haystack)
Z_PARAM_ZVAL(zneedle)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(offset)
@@ -1952,28 +1951,28 @@ PHP_FUNCTION(strrpos)
needle_len = 1;
}
- if ((haystack_len == 0) || (needle_len == 0)) {
+ if ((haystack->len == 0) || (needle_len == 0)) {
RETURN_FALSE;
}
if (offset >= 0) {
- if (offset > haystack_len) {
+ if (offset > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
- p = haystack + offset;
- e = haystack + haystack_len - needle_len;
+ p = haystack->val + offset;
+ e = haystack->val + haystack->len - needle_len;
} else {
- if (offset < -INT_MAX || -offset > haystack_len) {
+ if (offset < -INT_MAX || -offset > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
- p = haystack;
+ p = haystack->val;
if (needle_len > -offset) {
- e = haystack + haystack_len - needle_len;
+ e = haystack->val + haystack->len - needle_len;
} else {
- e = haystack + haystack_len + offset;
+ e = haystack->val + haystack->len + offset;
}
}
@@ -2004,13 +2003,14 @@ PHP_FUNCTION(strrpos)
PHP_FUNCTION(strripos)
{
zval *zneedle;
- char *needle, *haystack;
- int needle_len, haystack_len;
- long offset = 0;
+ char *needle;
+ zend_string *haystack;
+ size_t needle_len;
+ zend_long offset = 0;
char *p, *e, ord_needle[2];
char *needle_dup, *haystack_dup;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|l", &haystack, &haystack_len, &zneedle, &offset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|l", &haystack, &zneedle, &offset) == FAILURE) {
RETURN_FALSE;
}
@@ -2026,7 +2026,7 @@ PHP_FUNCTION(strripos)
needle_len = 1;
}
- if ((haystack_len == 0) || (needle_len == 0)) {
+ if ((haystack->len == 0) || (needle_len == 0)) {
RETURN_FALSE;
}
@@ -2034,19 +2034,19 @@ PHP_FUNCTION(strripos)
/* Single character search can shortcut memcmps
Can also avoid tolower emallocs */
if (offset >= 0) {
- if (offset > haystack_len) {
+ if (offset > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
- p = haystack + offset;
- e = haystack + haystack_len - 1;
+ p = haystack->val + offset;
+ e = haystack->val + haystack->len - 1;
} else {
- p = haystack;
- if (offset < -INT_MAX || -offset > haystack_len) {
+ p = haystack->val;
+ if (offset < -INT_MAX || -offset > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
- e = haystack + haystack_len + offset;
+ e = haystack->val + haystack->len + offset;
}
/* Borrow that ord_needle buffer to avoid repeatedly tolower()ing needle */
*ord_needle = tolower(*needle);
@@ -2061,20 +2061,20 @@ PHP_FUNCTION(strripos)
needle_dup = estrndup(needle, needle_len);
php_strtolower(needle_dup, needle_len);
- haystack_dup = estrndup(haystack, haystack_len);
- php_strtolower(haystack_dup, haystack_len);
+ haystack_dup = estrndup(haystack->val, haystack->len);
+ php_strtolower(haystack_dup, haystack->len);
if (offset >= 0) {
- if (offset > haystack_len) {
+ if (offset > haystack->len) {
efree(needle_dup);
efree(haystack_dup);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
p = haystack_dup + offset;
- e = haystack_dup + haystack_len - needle_len;
+ e = haystack_dup + haystack->len - needle_len;
} else {
- if (offset < -INT_MAX || -offset > haystack_len) {
+ if (offset < -INT_MAX || -offset > haystack->len) {
efree(needle_dup);
efree(haystack_dup);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
@@ -2082,9 +2082,9 @@ PHP_FUNCTION(strripos)
}
p = haystack_dup;
if (needle_len > -offset) {
- e = haystack_dup + haystack_len - needle_len;
+ e = haystack_dup + haystack->len - needle_len;
} else {
- e = haystack_dup + haystack_len + offset;
+ e = haystack_dup + haystack->len + offset;
}
}
@@ -2108,29 +2108,28 @@ PHP_FUNCTION(strripos)
PHP_FUNCTION(strrchr)
{
zval *needle;
- char *haystack;
+ zend_string *haystack;
const char *found = NULL;
- long found_offset;
- int haystack_len;
+ zend_long found_offset;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &haystack, &haystack_len, &needle) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz", &haystack, &needle) == FAILURE) {
return;
}
if (Z_TYPE_P(needle) == IS_STRING) {
- found = zend_memrchr(haystack, *Z_STRVAL_P(needle), haystack_len);
+ found = zend_memrchr(haystack->val, *Z_STRVAL_P(needle), haystack->len);
} else {
char needle_chr;
if (php_needle_char(needle, &needle_chr TSRMLS_CC) != SUCCESS) {
RETURN_FALSE;
}
- found = zend_memrchr(haystack, needle_chr, haystack_len);
+ found = zend_memrchr(haystack->val, needle_chr, haystack->len);
}
if (found) {
- found_offset = found - haystack;
- RETURN_STRINGL(found, haystack_len - found_offset);
+ found_offset = found - haystack->val;
+ RETURN_STRINGL(found, haystack->len - found_offset);
} else {
RETURN_FALSE;
}
@@ -2139,12 +2138,12 @@ PHP_FUNCTION(strrchr)
/* {{{ php_chunk_split
*/
-static zend_string *php_chunk_split(char *src, int srclen, char *end, int endlen, int chunklen)
+static zend_string *php_chunk_split(char *src, size_t srclen, char *end, size_t endlen, size_t chunklen)
{
char *p, *q;
- int chunks; /* complete chunks! */
- int restlen;
- int out_len;
+ size_t chunks; /* complete chunks! */
+ size_t restlen;
+ size_t out_len;
zend_string *dest;
chunks = srclen / chunklen;
@@ -2163,7 +2162,7 @@ static zend_string *php_chunk_split(char *src, int srclen, char *end, int endlen
}
out_len += srclen + 1;
- dest = STR_ALLOC(out_len * sizeof(char), 0);
+ dest = zend_string_alloc(out_len * sizeof(char), 0);
for (p = src, q = dest->val; p < (src + srclen - chunklen + 1); ) {
memcpy(q, p, chunklen);
@@ -2191,14 +2190,13 @@ static zend_string *php_chunk_split(char *src, int srclen, char *end, int endlen
Returns split line */
PHP_FUNCTION(chunk_split)
{
- char *str;
+ zend_string *str;
char *end = "\r\n";
int endlen = 2;
- long chunklen = 76;
- int str_len;
+ zend_long chunklen = 76;
zend_string *result;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &str, &str_len, &chunklen, &end, &endlen) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|ls", &str, &chunklen, &end, &endlen) == FAILURE) {
return;
}
@@ -2207,20 +2205,20 @@ PHP_FUNCTION(chunk_split)
RETURN_FALSE;
}
- if (chunklen > str_len) {
+ if (chunklen > str->len) {
/* to maintain BC, we must return original string + ending */
- result = STR_ALLOC(endlen + str_len, 0);
- memcpy(result->val, str, str_len);
- memcpy(result->val + str_len, end, endlen);
+ result = zend_string_alloc(endlen + str->len, 0);
+ memcpy(result->val, str->val, str->len);
+ memcpy(result->val + str->len, end, endlen);
result->val[result->len] = '\0';
RETURN_NEW_STR(result);
}
- if (!str_len) {
+ if (!str->len) {
RETURN_EMPTY_STRING();
}
- result = php_chunk_split(str, str_len, end, endlen, chunklen);
+ result = php_chunk_split(str->val, str->len, end, endlen, chunklen);
if (result) {
RETURN_STR(result);
@@ -2234,18 +2232,17 @@ PHP_FUNCTION(chunk_split)
Returns part of a string */
PHP_FUNCTION(substr)
{
- char *str;
- long l = 0, f;
- int str_len;
+ zend_string *str;
+ zend_long l = 0, f;
int argc = ZEND_NUM_ARGS();
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|l", &str, &str_len, &f, &l) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl|l", &str, &f, &l) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(2, 3)
- Z_PARAM_STRING(str, str_len)
+ Z_PARAM_STR(str)
Z_PARAM_LONG(f)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(l)
@@ -2253,22 +2250,22 @@ PHP_FUNCTION(substr)
#endif
if (argc > 2) {
- if ((l < 0 && -l > str_len)) {
+ if ((l < 0 && -l > str->len)) {
RETURN_FALSE;
- } else if (l > str_len) {
- l = str_len;
+ } else if (l > (zend_long)str->len) {
+ l = str->len;
}
} else {
- l = str_len;
+ l = str->len;
}
- if (f > str_len) {
+ if (f > (zend_long)str->len) {
RETURN_FALSE;
- } else if (f < 0 && -f > str_len) {
+ } else if (f < 0 && -f > str->len) {
f = 0;
}
- if (l < 0 && (l + str_len - f) < 0) {
+ if (l < 0 && (l + (zend_long)str->len - f) < 0) {
RETURN_FALSE;
}
@@ -2276,7 +2273,7 @@ PHP_FUNCTION(substr)
* of the string
*/
if (f < 0) {
- f = str_len + f;
+ f = (zend_long)str->len + f;
if (f < 0) {
f = 0;
}
@@ -2286,21 +2283,21 @@ PHP_FUNCTION(substr)
* needed to stop that many chars from the end of the string
*/
if (l < 0) {
- l = (str_len - f) + l;
+ l = ((zend_long)str->len - f) + l;
if (l < 0) {
l = 0;
}
}
- if (f >= str_len) {
+ if (f >= (zend_long)str->len) {
RETURN_FALSE;
}
- if ((f + l) > str_len) {
- l = str_len - f;
+ if ((f + l) > (zend_long)str->len) {
+ l = str->len - f;
}
- RETURN_STRINGL(str + f, l);
+ RETURN_STRINGL(str->val + f, l);
}
/* }}} */
@@ -2312,8 +2309,8 @@ PHP_FUNCTION(substr_replace)
zval *from;
zval *len = NULL;
zval *repl;
- int l = 0;
- int f;
+ zend_long l = 0; /* l and f should be size_t, however this needs much closer below logic investigation.*/
+ zend_long f;
int argc = ZEND_NUM_ARGS();
zend_string *result;
@@ -2331,7 +2328,7 @@ PHP_FUNCTION(substr_replace)
convert_to_string_ex(repl);
}
if (Z_TYPE_P(from) != IS_ARRAY) {
- convert_to_long_ex(from);
+ convert_to_int_ex(from);
}
if (argc > 3) {
@@ -2350,19 +2347,19 @@ PHP_FUNCTION(substr_replace)
(argc == 4 && Z_TYPE_P(from) != Z_TYPE_P(len))
) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "'from' and 'len' should be of same type - numerical or array ");
- RETURN_STR(STR_COPY(Z_STR_P(str)));
+ RETURN_STR(zend_string_copy(Z_STR_P(str)));
}
if (argc == 4 && Z_TYPE_P(from) == IS_ARRAY) {
if (zend_hash_num_elements(Z_ARRVAL_P(from)) != zend_hash_num_elements(Z_ARRVAL_P(len))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "'from' and 'len' should have the same number of elements");
- RETURN_STR(STR_COPY(Z_STR_P(str)));
+ RETURN_STR(zend_string_copy(Z_STR_P(str)));
}
}
}
if (Z_TYPE_P(str) != IS_ARRAY) {
if (Z_TYPE_P(from) != IS_ARRAY) {
- int repl_len = 0;
+ size_t repl_len = 0;
f = Z_LVAL_P(from);
@@ -2406,7 +2403,7 @@ PHP_FUNCTION(substr_replace)
repl_len = Z_STRLEN_P(repl);
}
- result = STR_ALLOC(Z_STRLEN_P(str) - l + repl_len, 0);
+ result = zend_string_alloc(Z_STRLEN_P(str) - l + repl_len, 0);
memcpy(result->val, Z_STRVAL_P(str), f);
if (repl_len) {
@@ -2417,12 +2414,12 @@ PHP_FUNCTION(substr_replace)
RETURN_NEW_STR(result);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Functionality of 'from' and 'len' as arrays is not implemented");
- RETURN_STR(STR_COPY(Z_STR_P(str)));
+ RETURN_STR(zend_string_copy(Z_STR_P(str)));
}
} else { /* str is array of strings */
zend_string *str_index = NULL;
- ulong num_index;
- int result_len;
+ size_t result_len;
+ zend_ulong num_index;
array_init(return_value);
@@ -2538,7 +2535,7 @@ PHP_FUNCTION(substr_replace)
result_len += Z_STRLEN_P(repl_str);
zend_hash_move_forward_ex(Z_ARRVAL_P(repl), &pos_repl);
- result = STR_ALLOC(result_len, 0);
+ result = zend_string_alloc(result_len, 0);
memcpy(result->val, Z_STRVAL_P(orig_str), f);
memcpy((result->val + f), Z_STRVAL_P(repl_str), Z_STRLEN_P(repl_str));
@@ -2547,7 +2544,7 @@ PHP_FUNCTION(substr_replace)
zval_dtor(repl_str);
}
} else {
- result = STR_ALLOC(result_len, 0);
+ result = zend_string_alloc(result_len, 0);
memcpy(result->val, Z_STRVAL_P(orig_str), f);
memcpy((result->val + f), Z_STRVAL_P(orig_str) + f + l, Z_STRLEN_P(orig_str) - f - l);
@@ -2555,7 +2552,7 @@ PHP_FUNCTION(substr_replace)
} else {
result_len += Z_STRLEN_P(repl);
- result = STR_ALLOC(result_len, 0);
+ result = zend_string_alloc(result_len, 0);
memcpy(result->val, Z_STRVAL_P(orig_str), f);
memcpy((result->val + f), Z_STRVAL_P(repl), Z_STRLEN_P(repl));
@@ -2587,26 +2584,25 @@ PHP_FUNCTION(substr_replace)
Quotes meta characters */
PHP_FUNCTION(quotemeta)
{
- char *old;
+ zend_string *old;
char *old_end;
char *p, *q;
char c;
- int old_len;
zend_string *str;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &old, &old_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &old) == FAILURE) {
return;
}
- old_end = old + old_len;
+ old_end = old->val + old->len;
- if (old == old_end) {
+ if (old->val == old_end) {
RETURN_FALSE;
}
- str = STR_ALLOC(2 * old_len, 0);
+ str = zend_string_alloc(2 * old->len, 0);
- for (p = old, q = str->val; p != old_end; p++) {
+ for (p = old->val, q = str->val; p != old_end; p++) {
c = *p;
switch (c) {
case '.':
@@ -2629,7 +2625,7 @@ PHP_FUNCTION(quotemeta)
*q = '\0';
- RETURN_NEW_STR(STR_REALLOC(str, q - str->val, 0));
+ RETURN_NEW_STR(zend_string_realloc(str, q - str->val, 0));
}
/* }}} */
@@ -2658,7 +2654,7 @@ PHP_FUNCTION(ord)
Converts ASCII code to a character */
PHP_FUNCTION(chr)
{
- long c;
+ zend_long c;
char temp[2];
if (ZEND_NUM_ARGS() != 1) {
@@ -2690,24 +2686,23 @@ static void php_ucfirst(char *str)
Makes a string's first character uppercase */
PHP_FUNCTION(ucfirst)
{
- char *str;
- int str_len;
+ zend_string *str;
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_STRING(str, str_len)
+ Z_PARAM_STR(str)
ZEND_PARSE_PARAMETERS_END();
#endif
- if (!str_len) {
+ if (!str->len) {
RETURN_EMPTY_STRING();
}
- ZVAL_STRINGL(return_value, str, str_len);
+ ZVAL_STRINGL(return_value, str->val, str->len);
php_ucfirst(Z_STRVAL_P(return_value));
}
/* }}} */
@@ -2726,18 +2721,17 @@ static void php_lcfirst(char *str)
Make a string's first character lowercase */
PHP_FUNCTION(lcfirst)
{
- char *str;
- int str_len;
+ zend_string *str;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) {
return;
}
- if (!str_len) {
+ if (!str->len) {
RETURN_EMPTY_STRING();
}
- ZVAL_STRINGL(return_value, str, str_len);
+ ZVAL_STRINGL(return_value, str->val, str->len);
php_lcfirst(Z_STRVAL_P(return_value));
}
/* }}} */
@@ -2746,30 +2740,31 @@ PHP_FUNCTION(lcfirst)
Uppercase the first character of every word in a string */
PHP_FUNCTION(ucwords)
{
- char *str, *delims = " \t\r\n\f\v";
+ zend_string *str;
+ char *delims = " \t\r\n\f\v";
register char *r, *r_end;
- int str_len, delims_len = 6;
+ int delims_len = 6;
char mask[256];
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &delims, &delims_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|s", &str, &delims, &delims_len) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(1, 2)
- Z_PARAM_STRING(str, str_len)
+ Z_PARAM_STR(str)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(delims, delims_len)
ZEND_PARSE_PARAMETERS_END();
#endif
- if (!str_len) {
+ if (!str->len) {
RETURN_EMPTY_STRING();
}
php_charmask((unsigned char *)delims, delims_len, mask TSRMLS_CC);
- ZVAL_STRINGL(return_value, str, str_len);
+ ZVAL_STRINGL(return_value, str->val, str->len);
r = Z_STRVAL_P(return_value);
*r = toupper((unsigned char) *r);
@@ -2783,9 +2778,9 @@ PHP_FUNCTION(ucwords)
/* {{{ php_strtr
*/
-PHPAPI char *php_strtr(char *str, int len, char *str_from, char *str_to, int trlen)
+PHPAPI char *php_strtr(char *str, size_t len, char *str_from, char *str_to, size_t trlen)
{
- int i;
+ size_t i;
unsigned char xlat[256];
if ((trlen < 1) || (len < 1)) {
@@ -2816,14 +2811,14 @@ static int php_strtr_key_compare(const void *a, const void *b TSRMLS_DC) /* {{{
/* }}} */
/* {{{ php_strtr_array */
-static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *pats TSRMLS_DC)
+static void php_strtr_array(zval *return_value, char *str, size_t slen, HashTable *pats TSRMLS_DC)
{
- ulong num_key;
+ zend_ulong num_key;
zend_string *str_key;
- int len, pos, found;
+ size_t len, pos, found;
int num_keys = 0;
- int minlen = 128*1024;
- int maxlen = 0;
+ size_t minlen = 128*1024;
+ size_t maxlen = 0;
HashTable str_hash, num_hash;
zval *entry, tmp, dummy;
char *key;
@@ -2920,7 +2915,7 @@ static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *
smart_str_appendl(&result, str->val, str->len);
pos += len;
found = 1;
- STR_RELEASE(str);
+ zend_string_release(str);
break;
}
} ZEND_HASH_FOREACH_END();
@@ -2945,7 +2940,7 @@ static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *
smart_str_appendl(&result, str->val, str->len);
pos += len;
found = 1;
- STR_RELEASE(str);
+ zend_string_release(str);
break;
}
}
@@ -3018,21 +3013,20 @@ PHP_FUNCTION(strtr)
Reverse a string */
PHP_FUNCTION(strrev)
{
- char *str;
+ zend_string *str;
char *e, *p;
- int str_len;
zend_string *n;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) {
return;
}
- n = STR_ALLOC(str_len, 0);
+ n = zend_string_alloc(str->len, 0);
p = n->val;
- e = str + str_len;
+ e = str->val + str->len;
- while (--e>=str) {
+ while (--e>=str->val) {
*p++ = *e;
}
@@ -3044,12 +3038,12 @@ PHP_FUNCTION(strrev)
/* {{{ php_similar_str
*/
-static void php_similar_str(const char *txt1, int len1, const char *txt2, int len2, int *pos1, int *pos2, int *max)
+static void php_similar_str(const char *txt1, size_t len1, const char *txt2, size_t len2, size_t *pos1, size_t *pos2, size_t *max)
{
char *p, *q;
char *end1 = (char *) txt1 + len1;
char *end2 = (char *) txt2 + len2;
- int l;
+ size_t l;
*max = 0;
for (p = (char *) txt1; p < end1; p++) {
@@ -3067,10 +3061,10 @@ static void php_similar_str(const char *txt1, int len1, const char *txt2, int le
/* {{{ php_similar_char
*/
-static int php_similar_char(const char *txt1, int len1, const char *txt2, int len2)
+static size_t php_similar_char(const char *txt1, size_t len1, const char *txt2, size_t len2)
{
- int sum;
- int pos1 = 0, pos2 = 0, max;
+ size_t sum;
+ size_t pos1 = 0, pos2 = 0, max;
php_similar_str(txt1, len1, txt2, len2, &pos1, &pos2, &max);
if ((sum = max)) {
@@ -3092,13 +3086,12 @@ static int php_similar_char(const char *txt1, int len1, const char *txt2, int le
Calculates the similarity between two strings */
PHP_FUNCTION(similar_text)
{
- char *t1, *t2;
+ zend_string *t1, *t2;
zval *percent = NULL;
int ac = ZEND_NUM_ARGS();
- int sim;
- int t1_len, t2_len;
+ size_t sim;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|z/", &t1, &t1_len, &t2, &t2_len, &percent) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|z/", &t1, &t2, &percent) == FAILURE) {
return;
}
@@ -3106,7 +3099,7 @@ PHP_FUNCTION(similar_text)
convert_to_double_ex(percent);
}
- if (t1_len + t2_len == 0) {
+ if (t1->len + t2->len == 0) {
if (ac > 2) {
Z_DVAL_P(percent) = 0;
}
@@ -3114,10 +3107,10 @@ PHP_FUNCTION(similar_text)
RETURN_LONG(0);
}
- sim = php_similar_char(t1, t1_len, t2, t2_len);
+ sim = php_similar_char(t1->val, t1->len, t2->val, t2->len);
if (ac > 2) {
- Z_DVAL_P(percent) = sim * 200.0 / (t1_len + t2_len);
+ Z_DVAL_P(percent) = sim * 200.0 / (t1->len + t2->len);
}
RETURN_LONG(sim);
@@ -3127,10 +3120,10 @@ PHP_FUNCTION(similar_text)
/* {{{ php_stripslashes
*
* be careful, this edits the string in-place */
-PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC)
+PHPAPI void php_stripslashes(char *str, size_t *len TSRMLS_DC)
{
char *s, *t;
- int l;
+ size_t l;
if (len != NULL) {
l = *len;
@@ -3171,22 +3164,21 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC)
Escapes all chars mentioned in charlist with backslash. It creates octal representations if asked to backslash characters with 8th bit set or with ASCII<32 (except '\n', '\r', '\t' etc...) */
PHP_FUNCTION(addcslashes)
{
- char *str, *what;
- int str_len, what_len;
+ zend_string *str, *what;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &str, &str_len, &what, &what_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &str, &what) == FAILURE) {
return;
}
- if (str_len == 0) {
+ if (str->len == 0) {
RETURN_EMPTY_STRING();
}
- if (what_len == 0) {
- RETURN_STRINGL(str, str_len);
+ if (what->len == 0) {
+ RETURN_STRINGL(str->val, str->len);
}
- RETURN_STR(php_addcslashes(str, str_len, 0, what, what_len TSRMLS_CC));
+ RETURN_STR(php_addcslashes(str->val, str->len, 0, what->val, what->len TSRMLS_CC));
}
/* }}} */
@@ -3194,24 +3186,23 @@ PHP_FUNCTION(addcslashes)
Escapes single quote, double quotes and backslash characters in a string with backslashes */
PHP_FUNCTION(addslashes)
{
- char *str;
- int str_len;
+ zend_string *str;
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_STRING(str, str_len)
+ Z_PARAM_STR(str)
ZEND_PARSE_PARAMETERS_END();
#endif
- if (str_len == 0) {
+ if (str->len == 0) {
RETURN_EMPTY_STRING();
}
- RETURN_STR(php_addslashes(str, str_len, 0 TSRMLS_CC));
+ RETURN_STR(php_addslashes(str->val, str->len, 0 TSRMLS_CC));
}
/* }}} */
@@ -3219,14 +3210,13 @@ PHP_FUNCTION(addslashes)
Strips backslashes from a string. Uses C-style conventions */
PHP_FUNCTION(stripcslashes)
{
- char *str;
- int str_len;
+ zend_string *str;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) {
return;
}
- ZVAL_STRINGL(return_value, str, str_len);
+ ZVAL_STRINGL(return_value, str->val, str->len);
php_stripcslashes(Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value));
}
/* }}} */
@@ -3235,14 +3225,13 @@ PHP_FUNCTION(stripcslashes)
Strips backslashes from a string */
PHP_FUNCTION(stripslashes)
{
- char *str;
- int str_len;
+ zend_string *str;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) {
return;
}
- ZVAL_STRINGL(return_value, str, str_len);
+ ZVAL_STRINGL(return_value, str->val, str->len);
php_stripslashes(Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value) TSRMLS_CC);
}
/* }}} */
@@ -3268,10 +3257,10 @@ char *php_strerror(int errnum)
/* {{{ php_stripcslashes
*/
-PHPAPI void php_stripcslashes(char *str, int *len)
+PHPAPI void php_stripcslashes(char *str, size_t *len)
{
char *source, *target, *end;
- int nlen = *len, i;
+ size_t nlen = *len, i;
char numtmp[4];
for (source=str, end=str+nlen, target=str; source < end; source++) {
@@ -3331,14 +3320,14 @@ PHPAPI void php_stripcslashes(char *str, int *len)
/* {{{ php_addcslashes
*/
-PHPAPI zend_string *php_addcslashes(const char *str, int length, int should_free, char *what, int wlength TSRMLS_DC)
+PHPAPI zend_string *php_addcslashes(const char *str, size_t length, int should_free, char *what, size_t wlength TSRMLS_DC)
{
char flags[256];
char *source, *target;
char *end;
char c;
- int newlen;
- zend_string *new_str = STR_ALLOC(4 * (length? length : (length = strlen(str))), 0);
+ size_t newlen;
+ zend_string *new_str = zend_string_alloc(4 * (length? length : (length = strlen(str))), 0);
if (!wlength) {
wlength = strlen(what);
@@ -3370,7 +3359,7 @@ PHPAPI zend_string *php_addcslashes(const char *str, int length, int should_free
*target = 0;
newlen = target - new_str->val;
if (newlen < length * 4) {
- new_str = STR_REALLOC(new_str, newlen, 0);
+ new_str = zend_string_realloc(new_str, newlen, 0);
}
if (should_free) {
efree((char*)str);
@@ -3381,7 +3370,7 @@ PHPAPI zend_string *php_addcslashes(const char *str, int length, int should_free
/* {{{ php_addslashes
*/
-PHPAPI zend_string *php_addslashes(char *str, int length, int should_free TSRMLS_DC)
+PHPAPI zend_string *php_addslashes(char *str, size_t length, int should_free TSRMLS_DC)
{
/* maximum string length, worst case situation */
char *source, *target;
@@ -3392,7 +3381,7 @@ PHPAPI zend_string *php_addslashes(char *str, int length, int should_free TSRMLS
return STR_EMPTY_ALLOC();
}
- new_str = STR_ALLOC(2 * (length ? length : (length = strlen(str))), 0);
+ new_str = zend_string_alloc(2 * (length ? length : (length = strlen(str))), 0);
source = str;
end = source + length;
target = new_str->val;
@@ -3420,7 +3409,7 @@ PHPAPI zend_string *php_addslashes(char *str, int length, int should_free TSRMLS
if (should_free) {
efree(str);
}
- new_str = STR_REALLOC(new_str, target - new_str->val, 0);
+ new_str = zend_string_realloc(new_str, target - new_str->val, 0);
return new_str;
}
@@ -3434,10 +3423,10 @@ PHPAPI zend_string *php_addslashes(char *str, int length, int should_free TSRMLS
/* {{{ php_char_to_str_ex
*/
-PHPAPI int php_char_to_str_ex(char *str, uint len, char from, char *to, int to_len, zval *result, int case_sensitivity, int *replace_count)
+PHPAPI size_t php_char_to_str_ex(char *str, size_t len, char from, char *to, size_t to_len, zval *result, int case_sensitivity, size_t *replace_count)
{
- int char_count = 0;
- int replaced = 0;
+ size_t char_count = 0;
+ size_t replaced = 0;
char *source, *target, *tmp, *source_end=str+len, *tmp_end = NULL;
if (case_sensitivity) {
@@ -3460,9 +3449,9 @@ PHPAPI int php_char_to_str_ex(char *str, uint len, char from, char *to, int to_l
}
if (to_len > 0) {
- ZVAL_NEW_STR(result, STR_SAFE_ALLOC(char_count, to_len - 1, len, 0));
+ ZVAL_NEW_STR(result, zend_string_safe_alloc(char_count, to_len - 1, len, 0));
} else {
- ZVAL_NEW_STR(result, STR_ALLOC(len - char_count, 0));
+ ZVAL_NEW_STR(result, zend_string_alloc(len - char_count, 0));
}
target = Z_STRVAL_P(result);
@@ -3507,7 +3496,7 @@ PHPAPI int php_char_to_str_ex(char *str, uint len, char from, char *to, int to_l
/* {{{ php_char_to_str
*/
-PHPAPI int php_char_to_str(char *str, uint len, char from, char *to, int to_len, zval *result)
+PHPAPI size_t php_char_to_str(char *str, size_t len, char from, char *to, size_t to_len, zval *result)
{
return php_char_to_str_ex(str, len, from, to, to_len, result, 1, NULL);
}
@@ -3515,8 +3504,8 @@ PHPAPI int php_char_to_str(char *str, uint len, char from, char *to, int to_len,
/* {{{ php_str_to_str_ex
*/
-PHPAPI zend_string *php_str_to_str_ex(char *haystack, int length,
- char *needle, int needle_len, char *str, int str_len, int case_sensitivity, int *replace_count)
+PHPAPI zend_string *php_str_to_str_ex(char *haystack, size_t length,
+ char *needle, size_t needle_len, char *str, size_t str_len, int case_sensitivity, size_t *replace_count)
{
zend_string *new_str;
@@ -3525,7 +3514,7 @@ PHPAPI zend_string *php_str_to_str_ex(char *haystack, int length,
char *e, *s, *p, *r;
if (needle_len == str_len) {
- new_str = STR_INIT(haystack, length, 0);
+ new_str = zend_string_init(haystack, length, 0);
if (case_sensitivity) {
end = new_str->val + length;
@@ -3560,9 +3549,9 @@ PHPAPI zend_string *php_str_to_str_ex(char *haystack, int length,
}
if (str_len < needle_len) {
- new_str = STR_ALLOC(length, 0);
+ new_str = zend_string_alloc(length, 0);
} else {
- int count = 0;
+ size_t count = 0;
char *o, *n, *endp;
if (case_sensitivity) {
@@ -3586,10 +3575,10 @@ PHPAPI zend_string *php_str_to_str_ex(char *haystack, int length,
if (needle_dup) {
efree(needle_dup);
}
- new_str = STR_INIT(haystack, length, 0);
+ new_str = zend_string_init(haystack, length, 0);
return new_str;
} else {
- new_str = STR_ALLOC(count * (str_len - needle_len) + length, 0);
+ new_str = zend_string_alloc(count * (str_len - needle_len) + length, 0);
}
}
@@ -3639,12 +3628,12 @@ PHPAPI zend_string *php_str_to_str_ex(char *haystack, int length,
*e = '\0';
- new_str = STR_REALLOC(new_str, e - s, 0);
+ new_str = zend_string_realloc(new_str, e - s, 0);
return new_str;
}
} else if (needle_len > length) {
nothing_todo:
- new_str = STR_INIT(haystack, length, 0);
+ new_str = zend_string_init(haystack, length, 0);
return new_str;
} else {
if (case_sensitivity && memcmp(haystack, needle, length)) {
@@ -3667,7 +3656,7 @@ nothing_todo:
efree(l_needle);
}
- new_str = STR_INIT(str, str_len, 0);
+ new_str = zend_string_init(str, str_len, 0);
if (replace_count) {
(*replace_count)++;
@@ -3680,7 +3669,7 @@ nothing_todo:
/* {{{ php_str_to_str
*/
-PHPAPI zend_string *php_str_to_str(char *haystack, int length, char *needle, int needle_len, char *str, int str_len)
+PHPAPI zend_string *php_str_to_str(char *haystack, size_t length, char *needle, size_t needle_len, char *str, size_t str_len)
{
return php_str_to_str_ex(haystack, length, needle, needle_len, str, str_len, 1, NULL);
}
@@ -3688,14 +3677,14 @@ PHPAPI zend_string *php_str_to_str(char *haystack, int length, char *needle, int
/* {{{ php_str_replace_in_subject
*/
-static void php_str_replace_in_subject(zval *search, zval *replace, zval *subject, zval *result, int case_sensitivity, int *replace_count TSRMLS_DC)
+static void php_str_replace_in_subject(zval *search, zval *replace, zval *subject, zval *result, int case_sensitivity, size_t *replace_count TSRMLS_DC)
{
zval *search_entry,
*replace_entry = NULL,
temp_result,
tmp_subject;
char *replace_value = NULL;
- int replace_len = 0;
+ size_t replace_len = 0;
HashPosition pos;
/* Make sure we're dealing with strings. */
@@ -3774,7 +3763,7 @@ static void php_str_replace_in_subject(zval *search, zval *replace, zval *subjec
replace_value, replace_len, case_sensitivity, replace_count));
}
- STR_FREE(Z_STR_P(result));
+ zend_string_free(Z_STR_P(result));
Z_STR_P(result) = Z_STR(temp_result);
Z_TYPE_INFO_P(result) = Z_TYPE_INFO(temp_result);
@@ -3812,8 +3801,8 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit
zval *subject, *search, *replace, *subject_entry, *zcount = NULL;
zval result;
zend_string *string_key;
- ulong num_key;
- int count = 0;
+ zend_ulong num_key;
+ zend_long count = 0;
int argc = ZEND_NUM_ARGS();
#ifndef FAST_ZPP
@@ -3898,7 +3887,7 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
char *str;
char *heb_str, *tmp, *target;
int block_start, block_end, block_type, block_length, i;
- long max_chars=0;
+ zend_long max_chars=0;
int begin, end, char_count, orig_begin;
int str_len;
zend_string *broken_str;
@@ -3993,7 +3982,7 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
} while (block_end < str_len-1);
- broken_str = STR_ALLOC(str_len, 0);
+ broken_str = zend_string_alloc(str_len, 0);
begin = end = str_len-1;
target = broken_str->val;
@@ -4053,7 +4042,7 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines)
if (convert_newlines) {
php_char_to_str(broken_str->val, broken_str->len,'\n', "<br />\n", 7, return_value);
- STR_FREE(broken_str);
+ zend_string_free(broken_str);
} else {
RETURN_NEW_STR(broken_str);
}
@@ -4081,19 +4070,19 @@ PHP_FUNCTION(hebrevc)
PHP_FUNCTION(nl2br)
{
/* in brief this inserts <br /> or <br> before matched regexp \n\r?|\r\n? */
- char *tmp, *str;
+ char *tmp;
+ zend_string *str;
char *end, *target;
- int repl_cnt = 0;
- int str_len;
+ size_t repl_cnt = 0;
zend_bool is_xhtml = 1;
zend_string *result;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &str, &str_len, &is_xhtml) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &str, &is_xhtml) == FAILURE) {
return;
}
- tmp = str;
- end = str + str_len;
+ tmp = str->val;
+ end = str->val + str->len;
/* it is really faster to scan twice and allocate mem once instead of scanning once
and constantly reallocing */
@@ -4114,18 +4103,19 @@ PHP_FUNCTION(nl2br)
}
if (repl_cnt == 0) {
- RETURN_STRINGL(str, str_len);
+ RETURN_STRINGL(str->val, str->len);
}
{
size_t repl_len = is_xhtml ? (sizeof("<br />") - 1) : (sizeof("<br>") - 1);
- result = STR_ALLOC(repl_cnt * repl_len + str_len, 0);
+ result = zend_string_alloc(repl_cnt * repl_len + str->len, 0);
target = result->val;
}
- while (str < end) {
- switch (*str) {
+ tmp = str->val;
+ while (tmp < end) {
+ switch (*tmp) {
case '\r':
case '\n':
*target++ = '<';
@@ -4139,15 +4129,15 @@ PHP_FUNCTION(nl2br)
*target++ = '>';
- if ((*str == '\r' && *(str+1) == '\n') || (*str == '\n' && *(str+1) == '\r')) {
- *target++ = *str++;
+ if ((*tmp == '\r' && *(tmp+1) == '\n') || (*tmp == '\n' && *(tmp+1) == '\r')) {
+ *target++ = *tmp++;
}
/* lack of a break; is intentional */
default:
- *target++ = *str;
+ *target++ = *tmp;
}
- str++;
+ tmp++;
}
*target = '\0';
@@ -4161,13 +4151,12 @@ PHP_FUNCTION(nl2br)
PHP_FUNCTION(strip_tags)
{
zend_string *buf;
- char *str;
+ zend_string *str;
zval *allow=NULL;
char *allowed_tags=NULL;
int allowed_tags_len=0;
- int str_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &str, &str_len, &allow) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|z", &str, &allow) == FAILURE) {
return;
}
@@ -4184,8 +4173,8 @@ PHP_FUNCTION(strip_tags)
}
}
- buf = STR_INIT(str, str_len, 0);
- buf->len = php_strip_tags_ex(buf->val, str_len, NULL, allowed_tags, allowed_tags_len, 0);
+ buf = zend_string_init(str->val, str->len, 0);
+ buf->len = php_strip_tags_ex(buf->val, str->len, NULL, allowed_tags, allowed_tags_len, 0);
// TODO: reimplement to avoid reallocation ???
if (allow && IS_INTERNED(Z_STR_P(allow))) {
@@ -4284,7 +4273,7 @@ PHP_FUNCTION(setlocale)
if (retval) {
/* Remember if locale was changed */
if (loc) {
-//??? STR_FREE(BG(locale_string));
+//??? zend_string_free(BG(locale_string));
if (BG(locale_string)) {
efree(BG(locale_string));
}
@@ -4352,7 +4341,7 @@ PHP_FUNCTION(parse_str)
* 0 start tag
* 1 first non-whitespace char seen
*/
-int php_tag_find(char *tag, int len, char *set) {
+int php_tag_find(char *tag, size_t len, char *set) {
char c, *n, *t;
int state=0, done=0;
char *norm;
@@ -4407,7 +4396,7 @@ int php_tag_find(char *tag, int len, char *set) {
}
/* }}} */
-PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, int allow_len) /* {{{ */
+PHPAPI size_t php_strip_tags(char *rbuf, size_t len, int *stateptr, char *allow, size_t allow_len) /* {{{ */
{
return php_strip_tags_ex(rbuf, len, stateptr, allow, allow_len, 0);
}
@@ -4433,7 +4422,7 @@ PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, in
swm: Added ability to strip <?xml tags without assuming it PHP
code.
*/
-PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow, int allow_len, zend_bool allow_tag_spaces)
+PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, int *stateptr, char *allow, size_t allow_len, zend_bool allow_tag_spaces)
{
char *tbuf, *buf, *p, *tp, *rp, c, lc;
int br, i=0, depth=0, in_q = 0;
@@ -4711,11 +4700,12 @@ reg_char:
Parse a CSV string into an array */
PHP_FUNCTION(str_getcsv)
{
- char *str, delim = ',', enc = '"', esc = '\\';
+ zend_string *str;
+ char delim = ',', enc = '"', esc = '\\';
char *delim_str = NULL, *enc_str = NULL, *esc_str = NULL;
- int str_len = 0, delim_len = 0, enc_len = 0, esc_len = 0;
+ int delim_len = 0, enc_len = 0, esc_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sss", &str, &str_len, &delim_str, &delim_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|sss", &str, &delim_str, &delim_len,
&enc_str, &enc_len, &esc_str, &esc_len) == FAILURE) {
return;
}
@@ -4724,7 +4714,7 @@ PHP_FUNCTION(str_getcsv)
enc = enc_len ? enc_str[0] : enc;
esc = esc_len ? esc_str[0] : esc;
- php_fgetcsv(NULL, delim, enc, esc, str_len, str, return_value TSRMLS_CC);
+ php_fgetcsv(NULL, delim, enc, esc, str->len, str->val, return_value TSRMLS_CC);
}
/* }}} */
@@ -4732,13 +4722,12 @@ PHP_FUNCTION(str_getcsv)
Returns the input string repeat mult times */
PHP_FUNCTION(str_repeat)
{
- char *input_str; /* Input string */
- int input_len;
- long mult; /* Multiplier */
+ zend_string *input_str; /* Input string */
+ zend_long mult; /* Multiplier */
zend_string *result; /* Resulting string */
size_t result_len; /* Length of the resulting string */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &input_str, &input_len, &mult) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl", &input_str, &mult) == FAILURE) {
return;
}
@@ -4749,22 +4738,22 @@ PHP_FUNCTION(str_repeat)
/* Don't waste our time if it's empty */
/* ... or if the multiplier is zero */
- if (input_len == 0 || mult == 0)
+ if (input_str->len == 0 || mult == 0)
RETURN_EMPTY_STRING();
/* Initialize the result string */
- result = STR_SAFE_ALLOC(input_len, mult, 0, 0);
- result_len = input_len * mult;
+ result = zend_string_safe_alloc(input_str->len, mult, 0, 0);
+ result_len = input_str->len * mult;
/* Heavy optimization for situations where input string is 1 byte long */
- if (input_len == 1) {
- memset(result->val, *(input_str), mult);
+ if (input_str->len == 1) {
+ memset(result->val, *(input_str->val), mult);
} else {
char *s, *e, *ee;
- int l=0;
- memcpy(result->val, input_str, input_len);
+ ptrdiff_t l=0;
+ memcpy(result->val, input_str->val, input_str->len);
s = result->val;
- e = result->val + input_len;
+ e = result->val + input_str->len;
ee = result->val + result_len;
while (e<ee) {
@@ -4784,15 +4773,16 @@ PHP_FUNCTION(str_repeat)
Returns info about what characters are used in input */
PHP_FUNCTION(count_chars)
{
- char *input;
+ zend_string *input;
int chars[256];
- long mymode=0;
+ zend_long mymode=0;
unsigned char *buf;
- int len, inx;
+ int inx;
char retstr[256];
- int retlen=0;
+ size_t retlen=0;
+ size_t tmp = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &input, &len, &mymode) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|l", &input, &mymode) == FAILURE) {
return;
}
@@ -4801,13 +4791,13 @@ PHP_FUNCTION(count_chars)
RETURN_FALSE;
}
- buf = (unsigned char *) input;
+ buf = (unsigned char *) input->val;
memset((void*) chars, 0, sizeof(chars));
- while (len > 0) {
+ while (tmp < input->len) {
chars[*buf]++;
buf++;
- len--;
+ tmp++;
}
if (mymode < 3) {
@@ -4852,15 +4842,14 @@ PHP_FUNCTION(count_chars)
*/
static void php_strnatcmp(INTERNAL_FUNCTION_PARAMETERS, int fold_case)
{
- char *s1, *s2;
- int s1_len, s2_len;
+ zend_string *s1, *s2;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &s1, &s1_len, &s2, &s2_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &s1, &s2) == FAILURE) {
return;
}
- RETURN_LONG(strnatcmp_ex(s1, s1_len,
- s2, s2_len,
+ RETURN_LONG(strnatcmp_ex(s1->val, s1->len,
+ s2->val, s2->len,
fold_case));
}
/* }}} */
@@ -4872,8 +4861,8 @@ PHPAPI int string_natural_compare_function_ex(zval *result, zval *op1, zval *op2
ZVAL_LONG(result, strnatcmp_ex(str1->val, str1->len, str2->val, str2->len, case_insensitive));
- STR_RELEASE(str1);
- STR_RELEASE(str2);
+ zend_string_release(str1);
+ zend_string_release(str2);
return SUCCESS;
}
/* }}} */
@@ -4994,7 +4983,7 @@ PHP_FUNCTION(strnatcasecmp)
PHP_FUNCTION(substr_count)
{
char *haystack, *needle;
- long offset = 0, length = 0;
+ zend_long offset = 0, length = 0;
int ac = ZEND_NUM_ARGS();
int count = 0;
int haystack_len, needle_len;
@@ -5018,7 +5007,7 @@ PHP_FUNCTION(substr_count)
}
if (offset > haystack_len) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset value %ld exceeds string length", offset);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset value " ZEND_LONG_FMT " exceeds string length", offset);
RETURN_FALSE;
}
p += offset;
@@ -5030,7 +5019,7 @@ PHP_FUNCTION(substr_count)
RETURN_FALSE;
}
if (length > (haystack_len - offset)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length value %ld exceeds string length", length);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length value " ZEND_LONG_FMT " exceeds string length", length);
RETURN_FALSE;
}
endp = p + length;
@@ -5059,30 +5048,37 @@ PHP_FUNCTION(substr_count)
PHP_FUNCTION(str_pad)
{
/* Input arguments */
- char *input; /* Input string */
- int input_len;
- long pad_length; /* Length to pad to */
+ zend_string *input; /* Input string */
+ zend_long pad_length; /* Length to pad to */
/* Helper variables */
size_t num_pad_chars; /* Number of padding characters (total - input size) */
- char *pad_str_val = " "; /* Pointer to padding string */
- int pad_str_len = 1; /* Length of the padding string */
- long pad_type_val = STR_PAD_RIGHT; /* The padding type value */
+ zend_string *pad_str, *pad_str_save; /* Pointer to padding string */
+ zend_long pad_type_val = STR_PAD_RIGHT; /* The padding type value */
int i, left_pad=0, right_pad=0;
zend_string *result = NULL; /* Resulting string */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|sl", &input, &input_len, &pad_length,
- &pad_str_val, &pad_str_len, &pad_type_val) == FAILURE) {
+ pad_str = pad_str_save = zend_string_init(" ", 1, 1);
+ if (!pad_str) {
+ return;
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl|Sl", &input, &pad_length, &pad_str, &pad_type_val) == FAILURE) {
+ zend_string_free(pad_str);
return;
}
+ if (pad_str != pad_str_save) {
+ zend_string_free(pad_str_save);
+ }
+
/* If resulting string turns out to be shorter than input string,
we simply copy the input and return. */
- if (pad_length <= 0 || (pad_length - input_len) <= 0) {
- RETURN_STRINGL(input, input_len);
+ if (pad_length < 0 || pad_length <= input->len) {
+ RETURN_STRINGL(input->val, input->len);
}
- if (pad_str_len == 0) {
+ if (pad_str->len == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding string cannot be empty");
return;
}
@@ -5092,13 +5088,13 @@ PHP_FUNCTION(str_pad)
return;
}
- num_pad_chars = pad_length - input_len;
+ num_pad_chars = pad_length - input->len;
if (num_pad_chars >= INT_MAX) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Padding length is too long");
return;
}
- result = STR_ALLOC(input_len + num_pad_chars, 0);
+ result = zend_string_alloc(input->len + num_pad_chars, 0);
result->len = 0;
/* We need to figure out the left/right padding lengths. */
@@ -5121,15 +5117,15 @@ PHP_FUNCTION(str_pad)
/* First we pad on the left. */
for (i = 0; i < left_pad; i++)
- result->val[result->len++] = pad_str_val[i % pad_str_len];
+ result->val[result->len++] = pad_str->val[i % pad_str->len];
/* Then we copy the input string. */
- memcpy(result->val + result->len, input, input_len);
- result->len += input_len;
+ memcpy(result->val + result->len, input->val, input->len);
+ result->len += input->len;
/* Finally, we pad on the right. */
for (i = 0; i < right_pad; i++)
- result->val[result->len++] = pad_str_val[i % pad_str_len];
+ result->val[result->len++] = pad_str->val[i % pad_str->len];
result->val[result->len] = '\0';
@@ -5165,22 +5161,21 @@ static char rot13_to[] = "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM";
Perform the rot13 transform on a string */
PHP_FUNCTION(str_rot13)
{
- char *arg;
- int arglen;
+ zend_string *arg;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arglen) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &arg) == FAILURE) {
return;
}
- RETVAL_STRINGL(arg, arglen);
+ RETVAL_STRINGL(arg->val, arg->len);
php_strtr(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), rot13_from, rot13_to, 52);
}
/* }}} */
-static void php_string_shuffle(char *str, long len TSRMLS_DC) /* {{{ */
+static void php_string_shuffle(char *str, zend_long len TSRMLS_DC) /* {{{ */
{
- long n_elems, rnd_idx, n_left;
+ zend_long n_elems, rnd_idx, n_left;
char temp;
/* The implementation is stolen from array_data_shuffle */
/* Thus the characteristics of the randomization are the same */
@@ -5208,16 +5203,15 @@ static void php_string_shuffle(char *str, long len TSRMLS_DC) /* {{{ */
Shuffles string. One permutation of all possible is created */
PHP_FUNCTION(str_shuffle)
{
- char *arg;
- int arglen;
+ zend_string *arg;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arglen) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &arg) == FAILURE) {
return;
}
- RETVAL_STRINGL(arg, arglen);
+ RETVAL_STRINGL(arg->val, arg->len);
if (Z_STRLEN_P(return_value) > 1) {
- php_string_shuffle(Z_STRVAL_P(return_value), (long) Z_STRLEN_P(return_value) TSRMLS_CC);
+ php_string_shuffle(Z_STRVAL_P(return_value), (zend_long) Z_STRLEN_P(return_value) TSRMLS_CC);
}
}
/* }}} */
@@ -5235,11 +5229,12 @@ PHP_FUNCTION(str_shuffle)
*/
PHP_FUNCTION(str_word_count)
{
- char *str, *char_list = NULL, *p, *e, *s, ch[256];
- int str_len, char_list_len = 0, word_count = 0;
- long type = 0;
+ zend_string *str;
+ char *char_list = NULL, *p, *e, *s, ch[256];
+ int char_list_len = 0, word_count = 0;
+ zend_long type = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &str, &str_len, &type, &char_list, &char_list_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|ls", &str, &type, &char_list, &char_list_len) == FAILURE) {
return;
}
@@ -5247,18 +5242,18 @@ PHP_FUNCTION(str_word_count)
case 1:
case 2:
array_init(return_value);
- if (!str_len) {
+ if (!str->len) {
return;
}
break;
case 0:
- if (!str_len) {
+ if (!str->len) {
RETURN_LONG(0);
}
/* nothing to be done */
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid format value %ld", type);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid format value " ZEND_LONG_FMT, type);
RETURN_FALSE;
}
@@ -5266,8 +5261,8 @@ PHP_FUNCTION(str_word_count)
php_charmask((unsigned char *)char_list, char_list_len, ch TSRMLS_CC);
}
- p = str;
- e = str + str_len;
+ p = str->val;
+ e = str->val + str->len;
/* first character cannot be ' or -, unless explicitly allowed by the user */
if ((*p == '\'' && (!char_list || !ch['\''])) || (*p == '-' && (!char_list || !ch['-']))) {
@@ -5290,7 +5285,7 @@ PHP_FUNCTION(str_word_count)
add_next_index_stringl(return_value, s, p - s);
break;
case 2:
- add_index_stringl(return_value, (s - str), s, p - s);
+ add_index_stringl(return_value, (s - str->val), s, p - s);
break;
default:
word_count++;
@@ -5336,14 +5331,14 @@ PHP_FUNCTION(money_format)
}
}
- str = STR_ALLOC(format_len + 1024, 0);
+ str = zend_string_alloc(format_len + 1024, 0);
if ((str->len = strfmon(str->val, str->len, format, value)) < 0) {
- STR_FREE(str);
+ zend_string_free(str);
RETURN_FALSE;
}
str->val[str->len] = '\0';
- RETURN_NEW_STR(STR_REALLOC(str, str->len, 0));
+ RETURN_NEW_STR(zend_string_realloc(str, str->len, 0));
}
/* }}} */
#endif
@@ -5352,13 +5347,12 @@ PHP_FUNCTION(money_format)
Convert a string to an array. If split_length is specified, break the string down into chunks each split_length characters long. */
PHP_FUNCTION(str_split)
{
- char *str;
- int str_len;
- long split_length = 1;
+ zend_string *str;
+ zend_long split_length = 1;
char *p;
- int n_reg_segments;
+ size_t n_reg_segments;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len, &split_length) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|l", &str, &split_length) == FAILURE) {
return;
}
@@ -5367,23 +5361,25 @@ PHP_FUNCTION(str_split)
RETURN_FALSE;
}
- array_init_size(return_value, ((str_len - 1) / split_length) + 1);
- if (split_length >= str_len) {
- add_next_index_stringl(return_value, str, str_len);
+ if (0 == str->len || split_length >= str->len) {
+ array_init_size(return_value, 1);
+ add_next_index_stringl(return_value, str->val, str->len);
return;
}
- n_reg_segments = str_len / split_length;
- p = str;
+ array_init_size(return_value, ((str->len - 1) / split_length) + 1);
+
+ n_reg_segments = str->len / split_length;
+ p = str->val;
while (n_reg_segments-- > 0) {
add_next_index_stringl(return_value, p, split_length);
p += split_length;
}
- if (p != (str + str_len)) {
- add_next_index_stringl(return_value, p, (str + str_len - p));
+ if (p != (str->val + str->len)) {
+ add_next_index_stringl(return_value, p, (str->val + str->len - p));
}
}
/* }}} */
@@ -5392,23 +5388,22 @@ PHP_FUNCTION(str_split)
Search a string for any of a set of characters */
PHP_FUNCTION(strpbrk)
{
- char *haystack, *char_list;
- int haystack_len, char_list_len;
+ zend_string *haystack, *char_list;
char *haystack_ptr, *cl_ptr;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &haystack, &haystack_len, &char_list, &char_list_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &haystack, &char_list) == FAILURE) {
RETURN_FALSE;
}
- if (!char_list_len) {
+ if (!char_list->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The character list cannot be empty");
RETURN_FALSE;
}
- for (haystack_ptr = haystack; haystack_ptr < (haystack + haystack_len); ++haystack_ptr) {
- for (cl_ptr = char_list; cl_ptr < (char_list + char_list_len); ++cl_ptr) {
+ for (haystack_ptr = haystack->val; haystack_ptr < (haystack->val + haystack->len); ++haystack_ptr) {
+ for (cl_ptr = char_list->val; cl_ptr < (char_list->val + char_list->len); ++cl_ptr) {
if (*cl_ptr == *haystack_ptr) {
- RETURN_STRINGL(haystack_ptr, (haystack + haystack_len - haystack_ptr));
+ RETURN_STRINGL(haystack_ptr, (haystack->val + haystack->len - haystack_ptr));
}
}
}
@@ -5421,13 +5416,12 @@ PHP_FUNCTION(strpbrk)
Binary safe optionally case insensitive comparison of 2 strings from an offset, up to length characters */
PHP_FUNCTION(substr_compare)
{
- char *s1, *s2;
- int s1_len, s2_len;
- long offset, len=0;
+ zend_string *s1, *s2;
+ zend_long offset, len=0;
zend_bool cs=0;
- uint cmp_len;
+ size_t cmp_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl|lb", &s1, &s1_len, &s2, &s2_len, &offset, &len, &cs) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSl|lb", &s1, &s2, &offset, &len, &cs) == FAILURE) {
RETURN_FALSE;
}
@@ -5441,21 +5435,21 @@ PHP_FUNCTION(substr_compare)
}
if (offset < 0) {
- offset = s1_len + offset;
+ offset = s1->len + offset;
offset = (offset < 0) ? 0 : offset;
}
- if (offset >= s1_len) {
+ if (offset >= s1->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot exceed initial string length");
RETURN_FALSE;
}
- cmp_len = (uint) (len ? len : MAX(s2_len, (s1_len - offset)));
+ cmp_len = (size_t) (len ? len : MAX(s2->len, (s1->len - offset)));
if (!cs) {
- RETURN_LONG(zend_binary_strncmp(s1 + offset, (s1_len - offset), s2, s2_len, cmp_len));
+ RETURN_LONG(zend_binary_strncmp(s1->val + offset, (s1->len - offset), s2->val, s2->len, cmp_len));
} else {
- RETURN_LONG(zend_binary_strncasecmp_l(s1 + offset, (s1_len - offset), s2, s2_len, cmp_len));
+ RETURN_LONG(zend_binary_strncasecmp_l(s1->val + offset, (s1->len - offset), s2->val, s2->len, cmp_len));
}
}
/* }}} */
diff --git a/ext/standard/syslog.c b/ext/standard/syslog.c
index acbffe49ad..046393b6bb 100644
--- a/ext/standard/syslog.c
+++ b/ext/standard/syslog.c
@@ -135,7 +135,7 @@ PHP_MSHUTDOWN_FUNCTION(syslog)
PHP_FUNCTION(openlog)
{
char *ident;
- long option, facility;
+ zend_long option, facility;
int ident_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sll", &ident,
@@ -175,7 +175,7 @@ PHP_FUNCTION(closelog)
Generate a system log message */
PHP_FUNCTION(syslog)
{
- long priority;
+ zend_long priority;
char *message;
int message_len;
diff --git a/ext/standard/tests/http/bug60570.phpt b/ext/standard/tests/http/bug60570.phpt
index d1784b0554..29c6a46f17 100644
--- a/ext/standard/tests/http/bug60570.phpt
+++ b/ext/standard/tests/http/bug60570.phpt
@@ -19,7 +19,7 @@ function do_test() {
$pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
- $a = $b = null;
+ $a = $b = count(get_resources());
$i = 3;
while ($i--) {
@@ -28,7 +28,7 @@ function do_test() {
unset($context);
$b = $a;
- $a = memory_get_usage();
+ $a = count(get_resources());
}
http_server_kill($pid);
diff --git a/ext/standard/tests/strings/bug55871.phpt b/ext/standard/tests/strings/bug55871.phpt
index 7b743fdfc1..249d1bd3a3 100644
--- a/ext/standard/tests/strings/bug55871.phpt
+++ b/ext/standard/tests/strings/bug55871.phpt
@@ -1,5 +1,5 @@
--TEST--
-Bug #55871 (Interruption in substr_replace())
+Bug #55871 (Interruption in substr_replace()) (PHP7)
--FILE--
<?php
class test1 {
@@ -25,23 +25,29 @@ class test3 {
$my_var = str_repeat('A', 40);
$out = substr_replace(array(&$my_var), array(new test1), 40, 0);
-var_dump($out);
+var_dump($out, $my_var);
$my_var = str_repeat('A', 40);
$out = substr_replace(array(&$my_var), array(new test2), 40, 0);
-var_dump($out);
+var_dump($out, $my_var);
$my_var = str_repeat('A', 40);
$out = substr_replace(array(&$my_var), array(new test3), 40, 0);
-var_dump($out);
+var_dump($out, $my_var);
--EXPECTF--
-
-Warning: substr_replace(): Argument was modified while replacing in %s on line %d
-array(0) {
+array(1) {
+ [0]=>
+ string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
-
-Warning: substr_replace(): Argument was modified while replacing in %s on line %d
-array(0) {
+array(1) {
+ [0]=>
+ string(0) ""
}
-
-Warning: substr_replace(): Argument was modified while replacing in %s on line %d
-array(0) {
+array(1) {
+ [0]=>
+ string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+}
+int(134512640)
+array(1) {
+ [0]=>
+ string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
+string(48) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
diff --git a/ext/standard/tests/strings/setlocale_variation2.phpt b/ext/standard/tests/strings/setlocale_variation2.phpt
index 038ba58c5e..10ae22fe0c 100644
--- a/ext/standard/tests/strings/setlocale_variation2.phpt
+++ b/ext/standard/tests/strings/setlocale_variation2.phpt
@@ -18,8 +18,11 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
/* setlocale() to set all available locales in the system and check the success count */
echo "*** Testing setlocale() : usage variations ***\n";
-function good_locale($locale) {
- return $locale !== 'tt_RU@iqtelif.UTF-8';
+function good_locale($locale) {
+ /**
+ * Note: no_NO is a bogus locale and should not be used, see https://bugzilla.redhat.com/show_bug.cgi?id=532487
+ **/
+ return $locale !== 'tt_RU@iqtelif.UTF-8' && substr($locale, 0, 5) !== "no_NO";
}
/* Prototype : array list_system_locales( void )
diff --git a/ext/standard/type.c b/ext/standard/type.c
index 2a2988dee5..0ac849d81e 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -103,9 +103,9 @@ PHP_FUNCTION(settype)
ZVAL_DEREF(var);
SEPARATE_ZVAL_NOREF(var);
if (!strcasecmp(type, "integer")) {
- convert_to_long(var);
+ convert_to_int(var);
} else if (!strcasecmp(type, "int")) {
- convert_to_long(var);
+ convert_to_int(var);
} else if (!strcasecmp(type, "float")) {
convert_to_double(var);
} else if (!strcasecmp(type, "double")) { /* deprecated */
@@ -138,7 +138,7 @@ PHP_FUNCTION(settype)
PHP_FUNCTION(intval)
{
zval *num;
- long base = 10;
+ zend_long base = 10;
if (ZEND_NUM_ARGS() != 1 && ZEND_NUM_ARGS() != 2) {
WRONG_PARAM_COUNT;
@@ -156,7 +156,7 @@ PHP_FUNCTION(intval)
#endif
RETVAL_ZVAL(num, 1, 0);
- convert_to_long_base(return_value, base);
+ convert_to_int_base(return_value, base);
}
/* }}} */
@@ -401,7 +401,7 @@ PHP_FUNCTION(is_callable)
//??? is it necessary to be consistent with old PHP ("\0" support)
if (UNEXPECTED(name->len) != strlen(name->val)) {
ZVAL_STRINGL(callable_name, name->val, strlen(name->val));
- STR_RELEASE(name);
+ zend_string_release(name);
} else {
ZVAL_STR(callable_name, name);
}
diff --git a/ext/standard/url.c b/ext/standard/url.c
index 3b9b22af90..6534d7a034 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -186,10 +186,10 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
}
if (pp - p > 0 && pp - p < 6 && (*pp == '/' || *pp == '\0')) {
- long port;
+ zend_long port;
memcpy(port_buf, p, (pp - p));
port_buf[pp - p] = '\0';
- port = strtol(port_buf, NULL, 10);
+ port = ZEND_STRTOL(port_buf, NULL, 10);
if (port > 0 && port <= 65535) {
ret->port = (unsigned short) port;
} else {
@@ -280,10 +280,10 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
efree(ret);
return NULL;
} else if (e - p > 0) {
- long port;
+ zend_long port;
memcpy(port_buf, p, (e - p));
port_buf[e - p] = '\0';
- port = strtol(port_buf, NULL, 10);
+ port = ZEND_STRTOL(port_buf, NULL, 10);
if (port > 0 && port <= 65535) {
ret->port = (unsigned short)port;
} else {
@@ -377,7 +377,7 @@ PHP_FUNCTION(parse_url)
char *str;
int str_len;
php_url *resource;
- long key = -1;
+ zend_long key = -1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len, &key) == FAILURE) {
return;
@@ -416,7 +416,7 @@ PHP_FUNCTION(parse_url)
if (resource->fragment != NULL) RETVAL_STRING(resource->fragment);
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid URL component identifier %ld", key);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid URL component identifier " ZEND_LONG_FMT, key);
RETVAL_FALSE;
}
goto done;
@@ -494,7 +494,7 @@ PHPAPI zend_string *php_url_encode(char const *s, int len)
from = (unsigned char *)s;
end = (unsigned char *)s + len;
- start = STR_ALLOC(3 * len, 0);
+ start = zend_string_alloc(3 * len, 0);
to = (unsigned char*)start->val;
while (from < end) {
@@ -525,7 +525,7 @@ PHPAPI zend_string *php_url_encode(char const *s, int len)
}
*to = '\0';
- start = STR_REALLOC(start, to - (unsigned char*)start->val, 0);
+ start = zend_string_realloc(start, to - (unsigned char*)start->val, 0);
return start;
}
@@ -567,7 +567,7 @@ PHP_FUNCTION(urldecode)
ZEND_PARSE_PARAMETERS_END();
#endif
- out_str = STR_INIT(in_str->val, in_str->len, 0);
+ out_str = zend_string_init(in_str->val, in_str->len, 0);
out_str->len = php_url_decode(out_str->val, out_str->len);
RETURN_NEW_STR(out_str);
@@ -612,7 +612,7 @@ PHPAPI zend_string *php_raw_url_encode(char const *s, int len)
register int x, y;
zend_string *str;
- str = STR_ALLOC(3 * len, 0);
+ str = zend_string_alloc(3 * len, 0);
for (x = 0, y = 0; len--; x++, y++) {
str->val[y] = (unsigned char) s[x];
#ifndef CHARSET_EBCDIC
@@ -632,7 +632,7 @@ PHPAPI zend_string *php_raw_url_encode(char const *s, int len)
}
}
str->val[y] = '\0';
- str = STR_REALLOC(str, y, 0);
+ str = zend_string_realloc(str, y, 0);
return str;
}
@@ -674,7 +674,7 @@ PHP_FUNCTION(rawurldecode)
ZEND_PARSE_PARAMETERS_END();
#endif
- out_str = STR_INIT(in_str->val, in_str->len, 0);
+ out_str = zend_string_init(in_str->val, in_str->len, 0);
out_str->len = php_raw_url_decode(out_str->val, out_str->len);
RETURN_NEW_STR(out_str);
@@ -719,7 +719,7 @@ PHP_FUNCTION(get_headers)
php_stream *stream;
zval *prev_val, *hdr = NULL, *h;
HashTable *hashT;
- long format = 0;
+ zend_long format = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &url, &url_len, &format) == FAILURE) {
return;
@@ -755,7 +755,7 @@ PHP_FUNCTION(get_headers)
}
if (!format) {
no_name_header:
- add_next_index_str(return_value, STR_COPY(Z_STR_P(hdr)));
+ add_next_index_str(return_value, zend_string_copy(Z_STR_P(hdr)));
} else {
char c;
char *s, *p;
diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c
index fc865b64a7..48910515f7 100644
--- a/ext/standard/url_scanner_ex.c
+++ b/ext/standard/url_scanner_ex.c
@@ -1057,7 +1057,7 @@ PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int va
smart_str_appends(&BG(url_adapt_state_ex).form_app, "\" />");
if (urlencode) {
- STR_FREE(encoded);
+ zend_string_free(encoded);
}
smart_str_free(&val);
diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re
index 240e504d6d..cfee6c31a7 100644
--- a/ext/standard/url_scanner_ex.re
+++ b/ext/standard/url_scanner_ex.re
@@ -509,7 +509,7 @@ PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int va
smart_str_appends(&BG(url_adapt_state_ex).form_app, "\" />");
if (urlencode) {
- STR_FREE(encoded);
+ zend_string_free(encoded);
}
smart_str_free(&val);
diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c
index 7dce126ac3..560fd9b910 100644
--- a/ext/standard/user_filters.c
+++ b/ext/standard/user_filters.c
@@ -220,7 +220,7 @@ php_stream_filter_status_t userfilter_filter(
zval_ptr_dtor(&func_name);
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
- convert_to_long(&retval);
+ convert_to_int(&retval);
ret = Z_LVAL(retval);
} else if (call_result == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to call filter function");
@@ -397,7 +397,7 @@ static php_stream_filter_factory user_filter_factory = {
static void filter_item_dtor(zval *zv)
{
struct php_user_filter_data *fdat = Z_PTR_P(zv);
- STR_RELEASE(fdat->classname);
+ zend_string_release(fdat->classname);
efree(fdat);
}
@@ -547,7 +547,7 @@ PHP_FUNCTION(stream_get_filters)
if (filters_hash) {
ZEND_HASH_FOREACH_STR_KEY(filters_hash, filter_name) {
if (filter_name) {
- add_next_index_str(return_value, STR_COPY(filter_name));
+ add_next_index_str(return_value, zend_string_copy(filter_name));
}
} ZEND_HASH_FOREACH_END();
}
@@ -584,13 +584,13 @@ PHP_FUNCTION(stream_filter_register)
}
fdat = ecalloc(1, sizeof(struct php_user_filter_data));
- fdat->classname = STR_COPY(classname);
+ fdat->classname = zend_string_copy(classname);
if (zend_hash_add_ptr(BG(user_filter_map), filtername, fdat) != NULL &&
php_stream_filter_register_factory_volatile(filtername->val, &user_filter_factory TSRMLS_CC) == SUCCESS) {
RETVAL_TRUE;
} else {
- STR_RELEASE(classname);
+ zend_string_release(classname);
efree(fdat);
}
}
diff --git a/ext/standard/uuencode.c b/ext/standard/uuencode.c
index 0689de5636..40ab379a30 100644
--- a/ext/standard/uuencode.c
+++ b/ext/standard/uuencode.c
@@ -65,14 +65,14 @@
#define PHP_UU_DEC(c) (((c) - ' ') & 077)
-PHPAPI zend_string *php_uuencode(char *src, int src_len) /* {{{ */
+PHPAPI zend_string *php_uuencode(char *src, size_t src_len) /* {{{ */
{
- int len = 45;
+ size_t len = 45;
char *p, *s, *e, *ee;
zend_string *dest;
/* encoded length is ~ 38% greater than the original */
- dest = STR_ALLOC((size_t)ceil(src_len * 1.38) + 46, 0);
+ dest = zend_string_alloc((size_t)ceil(src_len * 1.38) + 46, 0);
p = dest->val;
s = src;
e = src + src_len;
@@ -122,18 +122,18 @@ PHPAPI zend_string *php_uuencode(char *src, int src_len) /* {{{ */
*p++ = '\n';
*p = '\0';
- dest = STR_REALLOC(dest, p - dest->val, 0);
+ dest = zend_string_realloc(dest, p - dest->val, 0);
return dest;
}
/* }}} */
-PHPAPI zend_string *php_uudecode(char *src, int src_len) /* {{{ */
+PHPAPI zend_string *php_uudecode(char *src, size_t src_len) /* {{{ */
{
- int len, total_len=0;
+ size_t len, total_len=0;
char *s, *e, *p, *ee;
zend_string *dest;
- dest = STR_ALLOC((size_t) ceil(src_len * 0.75), 0);
+ dest = zend_string_alloc((size_t) ceil(src_len * 0.75), 0);
p = dest->val;
s = src;
e = src + src_len;
@@ -189,7 +189,7 @@ PHPAPI zend_string *php_uudecode(char *src, int src_len) /* {{{ */
return dest;
err:
- STR_FREE(dest);
+ zend_string_free(dest);
return NULL;
}
@@ -199,14 +199,13 @@ err:
uuencode a string */
PHP_FUNCTION(convert_uuencode)
{
- char *src;
- int src_len;
+ zend_string *src;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &src, &src_len) == FAILURE || src_len < 1) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &src) == FAILURE || src->len < 1) {
RETURN_FALSE;
}
- RETURN_STR(php_uuencode(src, src_len));
+ RETURN_STR(php_uuencode(src->val, src->len));
}
/* }}} */
@@ -214,15 +213,14 @@ PHP_FUNCTION(convert_uuencode)
decode a uuencoded string */
PHP_FUNCTION(convert_uudecode)
{
- char *src;
- int src_len;
+ zend_string *src;
zend_string *dest;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &src, &src_len) == FAILURE || src_len < 1) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &src) == FAILURE || src->len < 1) {
RETURN_FALSE;
}
- if ((dest = php_uudecode(src, src_len)) == NULL) {
+ if ((dest = php_uudecode(src->val, src->len)) == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The given parameter is not a valid uuencoded string");
RETURN_FALSE;
}
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 96b1ee40ec..b5ece11332 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -54,10 +54,10 @@ static uint zend_obj_num_elements(HashTable *ht)
return num;
}
-static void php_array_element_dump(zval *zv, ulong index, zend_string *key, int level TSRMLS_DC) /* {{{ */
+static void php_array_element_dump(zval *zv, zend_ulong index, zend_string *key, int level TSRMLS_DC) /* {{{ */
{
if (key == NULL) { /* numeric key */
- php_printf("%*c[%ld]=>\n", level + 1, ' ', index);
+ php_printf("%*c[" ZEND_LONG_FMT "]=>\n", level + 1, ' ', index);
} else { /* string key */
php_printf("%*c[\"", level + 1, ' ');
PHPWRITE(key->val, key->len);
@@ -67,12 +67,12 @@ static void php_array_element_dump(zval *zv, ulong index, zend_string *key, int
}
/* }}} */
-static void php_object_property_dump(zval *zv, ulong index, zend_string *key, int level TSRMLS_DC) /* {{{ */
+static void php_object_property_dump(zval *zv, zend_ulong index, zend_string *key, int level TSRMLS_DC) /* {{{ */
{
const char *prop_name, *class_name;
if (key == NULL) { /* numeric key */
- php_printf("%*c[%ld]=>\n", level + 1, ' ', index);
+ php_printf("%*c[" ZEND_LONG_FMT "]=>\n", level + 1, ' ', index);
} else { /* string key */
int unmangle = zend_unmangle_property_name(key->val, key->len, &class_name, &prop_name);
php_printf("%*c[", level + 1, ' ');
@@ -100,7 +100,7 @@ PHPAPI void php_var_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
zend_string *class_name;
int is_temp;
int is_ref = 0;
- ulong num;
+ zend_ulong num;
zend_string *key;
zval *val;
@@ -120,7 +120,7 @@ again:
php_printf("%sNULL\n", COMMON);
break;
case IS_LONG:
- php_printf("%sint(%ld)\n", COMMON, Z_LVAL_P(struc));
+ php_printf("%sint(" ZEND_LONG_FMT ")\n", COMMON, Z_LVAL_P(struc));
break;
case IS_DOUBLE:
php_printf("%sfloat(%.*G)\n", COMMON, (int) EG(precision), Z_DVAL_P(struc));
@@ -166,12 +166,12 @@ again:
if (Z_OBJ_HANDLER_P(struc, get_class_name)) {
class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc), 0 TSRMLS_CC);
php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name->val, Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0);
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
} else {
php_printf("%sobject(unknown class)#%d (%d) {\n", COMMON, Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0);
}
if (myht) {
- ulong num;
+ zend_ulong num;
zend_string *key;
zval *val;
@@ -191,7 +191,7 @@ again:
break;
case IS_RESOURCE: {
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(struc) TSRMLS_CC);
- php_printf("%sresource(%ld) of type (%s)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown");
+ php_printf("%sresource(%pd) of type (%s)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown");
break;
}
case IS_REFERENCE:
@@ -227,10 +227,10 @@ PHP_FUNCTION(var_dump)
}
/* }}} */
-static void zval_array_element_dump(zval *zv, ulong index, zend_string *key, int level TSRMLS_DC) /* {{{ */
+static void zval_array_element_dump(zval *zv, zend_ulong index, zend_string *key, int level TSRMLS_DC) /* {{{ */
{
if (key == NULL) { /* numeric key */
- php_printf("%*c[%ld]=>\n", level + 1, ' ', index);
+ php_printf("%*c[" ZEND_LONG_FMT "]=>\n", level + 1, ' ', index);
} else { /* string key */
php_printf("%*c[\"", level + 1, ' ');
PHPWRITE(key->val, key->len);
@@ -240,12 +240,12 @@ static void zval_array_element_dump(zval *zv, ulong index, zend_string *key, int
}
/* }}} */
-static void zval_object_property_dump(zval *zv, ulong index, zend_string *key, int level TSRMLS_DC) /* {{{ */
+static void zval_object_property_dump(zval *zv, zend_ulong index, zend_string *key, int level TSRMLS_DC) /* {{{ */
{
const char *prop_name, *class_name;
if (key == NULL) { /* numeric key */
- php_printf("%*c[%ld]=>\n", level + 1, ' ', index);
+ php_printf("%*c[" ZEND_LONG_FMT "]=>\n", level + 1, ' ', index);
} else { /* string key */
zend_unmangle_property_name(key->val, key->len, &class_name, &prop_name);
php_printf("%*c[", level + 1, ' ');
@@ -271,7 +271,7 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
zend_string *class_name;
int is_temp = 0;
int is_ref = 0;
- ulong index;
+ zend_ulong index;
zend_string *key;
zval *val;
@@ -291,7 +291,7 @@ again:
php_printf("%sNULL\n", COMMON);
break;
case IS_LONG:
- php_printf("%slong(%ld)\n", COMMON, Z_LVAL_P(struc));
+ php_printf("%slong(" ZEND_LONG_FMT ")\n", COMMON, Z_LVAL_P(struc));
break;
case IS_DOUBLE:
php_printf("%sdouble(%.*G)\n", COMMON, (int) EG(precision), Z_DVAL_P(struc));
@@ -336,7 +336,7 @@ again:
}
class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc), 0 TSRMLS_CC);
php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name->val, Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0, Z_REFCOUNT_P(struc));
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
if (myht) {
ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, val) {
zval_object_property_dump(val, index, key, level TSRMLS_CC);
@@ -354,7 +354,7 @@ again:
break;
case IS_RESOURCE: {
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(struc) TSRMLS_CC);
- php_printf("%sresource(%ld) of type (%s) refcount(%u)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown", Z_REFCOUNT_P(struc));
+ php_printf("%sresource(" ZEND_LONG_FMT ") of type (%s) refcount(%u)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown", Z_REFCOUNT_P(struc));
break;
}
case IS_REFERENCE:
@@ -398,11 +398,11 @@ PHP_FUNCTION(debug_zval_dump)
efree(tmp_spaces); \
} while(0);
-static void php_array_element_export(zval *zv, ulong index, zend_string *key, int level, smart_str *buf TSRMLS_DC) /* {{{ */
+static void php_array_element_export(zval *zv, zend_ulong index, zend_string *key, int level, smart_str *buf TSRMLS_DC) /* {{{ */
{
if (key == NULL) { /* numeric key */
buffer_append_spaces(buf, level+1);
- smart_str_append_long(buf, (long) index);
+ smart_str_append_long(buf, (zend_long) index);
smart_str_appendl(buf, " => ", 4);
} else { /* string key */
@@ -416,8 +416,8 @@ static void php_array_element_export(zval *zv, ulong index, zend_string *key, in
smart_str_appendl(buf, tmp_str->val, tmp_str->len);
smart_str_appendl(buf, "' => ", 5);
- STR_FREE(ckey);
- STR_FREE(tmp_str);
+ zend_string_free(ckey);
+ zend_string_free(tmp_str);
}
php_var_export_ex(zv, level + 2, buf TSRMLS_CC);
@@ -426,7 +426,7 @@ static void php_array_element_export(zval *zv, ulong index, zend_string *key, in
}
/* }}} */
-static void php_object_element_export(zval *zv, ulong index, zend_string *key, int level, smart_str *buf TSRMLS_DC) /* {{{ */
+static void php_object_element_export(zval *zv, zend_ulong index, zend_string *key, int level, smart_str *buf TSRMLS_DC) /* {{{ */
{
buffer_append_spaces(buf, level + 2);
if (key != NULL) {
@@ -441,9 +441,9 @@ static void php_object_element_export(zval *zv, ulong index, zend_string *key, i
smart_str_appendc(buf, '\'');
smart_str_appendl(buf, pname_esc->val, pname_esc->len);
smart_str_appendc(buf, '\'');
- STR_RELEASE(pname_esc);
+ zend_string_release(pname_esc);
} else {
- smart_str_append_long(buf, (long) index);
+ smart_str_append_long(buf, (zend_long) index);
}
smart_str_appendl(buf, " => ", 4);
php_var_export_ex(zv, level + 2, buf TSRMLS_CC);
@@ -456,10 +456,10 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf TSRMLS_DC)
{
HashTable *myht;
char *tmp_str;
- int tmp_len;
+ size_t tmp_len;
zend_string *class_name;
zend_string *ztmp, *ztmp2;
- ulong index;
+ zend_ulong index;
zend_string *key;
zval *val;
@@ -490,8 +490,8 @@ again:
smart_str_appendl(buf, ztmp2->val, ztmp2->len);
smart_str_appendc(buf, '\'');
- STR_FREE(ztmp);
- STR_FREE(ztmp2);
+ zend_string_free(ztmp);
+ zend_string_free(ztmp2);
break;
case IS_ARRAY:
myht = Z_ARRVAL_P(struc);
@@ -539,7 +539,7 @@ again:
smart_str_appendl(buf, class_name->val, class_name->len);
smart_str_appendl(buf, "::__set_state(array(\n", 21);
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
if (myht) {
ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, val) {
php_object_element_export(val, index, key, level, buf TSRMLS_CC);
@@ -613,16 +613,16 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var_ptr, zval *var
}
if ((Z_TYPE_P(var) == IS_OBJECT) && Z_OBJ_HT_P(var)->get_class_entry) {
p = smart_str_print_long(id + sizeof(id) - 1,
- (long) Z_OBJ_P(var));
+ (zend_long) Z_OBJ_P(var));
*(--p) = 'O';
len = id + sizeof(id) - 1 - p;
} else if (var_ptr != var) {
p = smart_str_print_long(id + sizeof(id) - 1,
- (long) Z_REF_P(var_ptr));
+ (zend_long) Z_REF_P(var_ptr));
*(--p) = 'R';
len = id + sizeof(id) - 1 - p;
} else {
- p = smart_str_print_long(id + sizeof(id) - 1, (long) var);
+ p = smart_str_print_long(id + sizeof(id) - 1, (zend_long) var);
len = id + sizeof(id) - 1 - p;
}
@@ -635,7 +635,7 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var_ptr, zval *var
zend_hash_next_index_insert(var_hash, &var_no);
}
#if 0
- fprintf(stderr, "- had var (%d): %lu\n", Z_TYPE_P(var), **(ulong**)var_old);
+ fprintf(stderr, "- had var (%d): %lu\n", Z_TYPE_P(var), **(zend_ulong**)var_old);
#endif
return FAILURE;
}
@@ -650,7 +650,7 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var_ptr, zval *var
}
/* }}} */
-static inline void php_var_serialize_long(smart_str *buf, long val) /* {{{ */
+static inline void php_var_serialize_long(smart_str *buf, zend_long val) /* {{{ */
{
smart_str_appendl(buf, "i:", 2);
smart_str_append_long(buf, val);
@@ -746,26 +746,26 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
}
}
php_var_serialize_string(buf, priv_name->val, priv_name->len);
- STR_FREE(priv_name);
+ zend_string_free(priv_name);
php_var_serialize_intern(buf, d, var_hash TSRMLS_CC);
break;
}
- STR_FREE(priv_name);
+ zend_string_free(priv_name);
prot_name = zend_mangle_property_name("*", 1, Z_STRVAL_P(name), Z_STRLEN_P(name), ce->type & ZEND_INTERNAL_CLASS);
if ((d = zend_hash_find(propers, prot_name)) != NULL) {
if (Z_TYPE_P(d) == IS_INDIRECT) {
d = Z_INDIRECT_P(d);
if (Z_TYPE_P(d) == IS_UNDEF) {
- STR_FREE(prot_name);
+ zend_string_free(prot_name);
break;
}
}
php_var_serialize_string(buf, prot_name->val, prot_name->len);
- STR_FREE(prot_name);
+ zend_string_free(prot_name);
php_var_serialize_intern(buf, d, var_hash TSRMLS_CC);
break;
}
- STR_FREE(prot_name);
+ zend_string_free(prot_name);
php_var_serialize_string(buf, Z_STRVAL_P(name), Z_STRLEN_P(name));
php_var_serialize_intern(buf, nvalp, var_hash TSRMLS_CC);
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "\"%s\" returned as member variable from __sleep() but does not exist", Z_STRVAL_P(name));
@@ -855,7 +855,7 @@ again:
if (ce && ce->serialize != NULL) {
/* has custom handler */
unsigned char *serialized_data = NULL;
- zend_uint serialized_length;
+ uint32_t serialized_length;
if (ce->serialize(struc, &serialized_data, &serialized_length, (zend_serialize_data *)var_hash TSRMLS_CC) == SUCCESS) {
smart_str_appendl(buf, "C:", 2);
@@ -928,7 +928,7 @@ again:
if (i > 0) {
zend_string *key;
zval *data;
- ulong index;
+ zend_ulong index;
ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, data) {
@@ -1031,7 +1031,7 @@ PHP_FUNCTION(unserialize)
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
zval_dtor(return_value);
if (!EG(exception)) {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Error at offset %ld of %d bytes", (long)((char*)p - buf), buf_len);
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Error at offset " ZEND_LONG_FMT " of %d bytes", (zend_long)((char*)p - buf), buf_len);
}
RETURN_FALSE;
}
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
index b6fcd79c2d..3ae0aaf633 100644
--- a/ext/standard/var_unserializer.c
+++ b/ext/standard/var_unserializer.c
@@ -30,13 +30,13 @@
typedef struct {
zval *data[VAR_ENTRIES_MAX];
- long used_slots;
+ zend_long used_slots;
void *next;
} var_entries;
typedef struct {
zval data[VAR_ENTRIES_MAX];
- long used_slots;
+ zend_long used_slots;
void *next;
} var_dtor_entries;
@@ -119,7 +119,7 @@ PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval *rva
PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval *nzval)
{
- long i;
+ zend_long i;
var_entries *var_hash = (*var_hashx)->first;
#if VAR_ENTRIES_DBG
fprintf(stderr, "var_replace(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(nzval));
@@ -136,7 +136,7 @@ PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval *nz
}
}
-static zval *var_access(php_unserialize_data_t *var_hashx, long id)
+static zval *var_access(php_unserialize_data_t *var_hashx, zend_long id)
{
var_entries *var_hash = (*var_hashx)->first;
#if VAR_ENTRIES_DBG
@@ -158,7 +158,7 @@ static zval *var_access(php_unserialize_data_t *var_hashx, long id)
PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
{
void *next;
- long i;
+ zend_long i;
var_entries *var_hash = (*var_hashx)->first;
var_dtor_entries *var_dtor_hash = (*var_hashx)->first_dtor;
#if VAR_ENTRIES_DBG
@@ -186,17 +186,17 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t maxlen)
{
size_t i, j;
- zend_string *str = STR_ALLOC(len, 0);
+ zend_string *str = zend_string_alloc(len, 0);
unsigned char *end = *(unsigned char **)p+maxlen;
if (end < *p) {
- STR_FREE(str);
+ zend_string_free(str);
return NULL;
}
for (i = 0; i < len; i++) {
if (*p >= end) {
- STR_FREE(str);
+ zend_string_free(str);
return NULL;
}
if (**p != '\\') {
@@ -213,7 +213,7 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t
} else if (**p >= 'A' && **p <= 'F') {
ch = (ch << 4) + (**p -'A'+10);
} else {
- STR_FREE(str);
+ zend_string_free(str);
return NULL;
}
}
@@ -238,10 +238,10 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t
-static inline long parse_iv2(const unsigned char *p, const unsigned char **q)
+static inline zend_long parse_iv2(const unsigned char *p, const unsigned char **q)
{
char cursor;
- long result = 0;
+ zend_long result = 0;
int neg = 0;
switch (*p) {
@@ -266,7 +266,7 @@ static inline long parse_iv2(const unsigned char *p, const unsigned char **q)
return result;
}
-static inline long parse_iv(const unsigned char *p)
+static inline zend_long parse_iv(const unsigned char *p)
{
return parse_iv2(p, NULL);
}
@@ -296,7 +296,7 @@ static inline size_t parse_uiv(const unsigned char *p)
#define UNSERIALIZE_PARAMETER zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash TSRMLS_DC
#define UNSERIALIZE_PASSTHRU rval, p, max, var_hash TSRMLS_CC
-static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long elements, int objprops)
+static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, zend_long elements, int objprops)
{
while (elements-- > 0) {
zval key, *data, d, *old_data;
@@ -380,14 +380,14 @@ static inline int finish_nested_data(UNSERIALIZE_PARAMETER)
static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
{
- long datalen;
+ zend_long datalen;
datalen = parse_iv2((*p) + 2, p);
(*p) += 2;
if (datalen < 0 || (*p) + datalen >= max) {
- zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %ld present", datalen, (long)(max - (*p)));
+ zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %pd present", datalen, (zend_long)(max - (*p)));
return 0;
}
@@ -403,9 +403,9 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
return finish_nested_data(UNSERIALIZE_PASSTHRU);
}
-static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
+static inline zend_long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
{
- long elements;
+ zend_long elements;
elements = parse_iv2((*p) + 2, p);
@@ -426,7 +426,7 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
#ifdef PHP_WIN32
# pragma optimize("", off)
#endif
-static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
+static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements)
{
zval retval;
zval fname;
@@ -625,7 +625,7 @@ yy20:
#line 681 "ext/standard/var_unserializer.re"
{
size_t len, len2, len3, maxlen;
- long elements;
+ zend_long elements;
char *str;
zend_string *class_name;
zend_class_entry *ce;
@@ -669,7 +669,7 @@ yy20:
return 0;
}
- class_name = STR_INIT(str, len, 0);
+ class_name = zend_string_init(str, len, 0);
do {
/* Try to find class directly */
@@ -678,7 +678,7 @@ yy20:
if (ce) {
BG(serialize_lock)--;
if (EG(exception)) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
return 0;
}
break;
@@ -686,7 +686,7 @@ yy20:
BG(serialize_lock)--;
if (EG(exception)) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
return 0;
}
@@ -700,12 +700,12 @@ yy20:
/* Call unserialize callback */
ZVAL_STRING(&user_func, PG(unserialize_callback_func));
- ZVAL_STR(&args[0], STR_COPY(class_name));
+ ZVAL_STR(&args[0], zend_string_copy(class_name));
BG(serialize_lock)++;
if (call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) {
BG(serialize_lock)--;
if (EG(exception)) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
zval_ptr_dtor(&user_func);
zval_ptr_dtor(&args[0]);
return 0;
@@ -720,7 +720,7 @@ yy20:
BG(serialize_lock)--;
zval_ptr_dtor(&retval);
if (EG(exception)) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
zval_ptr_dtor(&user_func);
zval_ptr_dtor(&args[0]);
return 0;
@@ -748,7 +748,7 @@ yy20:
if (ret && incomplete_class) {
php_store_class_name(rval, class_name->val, len2);
}
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
return ret;
}
@@ -757,7 +757,7 @@ yy20:
if (incomplete_class) {
php_store_class_name(rval, class_name->val, len2);
}
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
@@ -817,7 +817,7 @@ yy34:
++YYCURSOR;
#line 652 "ext/standard/var_unserializer.re"
{
- long elements = parse_iv(start + 2);
+ zend_long elements = parse_iv(start + 2);
/* use iv() not uiv() in order to check data range */
*p = YYCURSOR;
@@ -874,7 +874,7 @@ yy41:
}
if (*(YYCURSOR) != '"') {
- STR_FREE(str);
+ zend_string_free(str);
*p = YYCURSOR;
return 0;
}
@@ -1023,7 +1023,7 @@ yy63:
++YYCURSOR;
#line 588 "ext/standard/var_unserializer.re"
{
-#if SIZEOF_LONG == 4
+#if SIZEOF_ZEND_INT == 4
use_double:
#endif
*p = YYCURSOR;
@@ -1134,14 +1134,14 @@ yy79:
++YYCURSOR;
#line 546 "ext/standard/var_unserializer.re"
{
-#if SIZEOF_LONG == 4
+#if SIZEOF_ZEND_INT == 4
int digits = YYCURSOR - start - 3;
if (start[2] == '-' || start[2] == '+') {
digits--;
}
- /* Use double for large long values that were serialized on a 64-bit system */
+ /* Use double for large zend_long values that were serialized on a 64-bit system */
if (digits >= MAX_LENGTH_OF_LONG - 1) {
if (digits == MAX_LENGTH_OF_LONG - 1) {
int cmp = strncmp((char*)YYCURSOR - MAX_LENGTH_OF_LONG, long_min_digits, MAX_LENGTH_OF_LONG - 1);
@@ -1206,7 +1206,7 @@ yy91:
++YYCURSOR;
#line 511 "ext/standard/var_unserializer.re"
{
- long id;
+ zend_long id;
*p = YYCURSOR;
if (!var_hash) return 0;
@@ -1252,7 +1252,7 @@ yy97:
++YYCURSOR;
#line 489 "ext/standard/var_unserializer.re"
{
- long id;
+ zend_long id;
*p = YYCURSOR;
if (!var_hash) return 0;
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
index 5636429c8b..054580ac41 100644
--- a/ext/standard/var_unserializer.re
+++ b/ext/standard/var_unserializer.re
@@ -28,13 +28,13 @@
typedef struct {
zval *data[VAR_ENTRIES_MAX];
- long used_slots;
+ zend_long used_slots;
void *next;
} var_entries;
typedef struct {
zval data[VAR_ENTRIES_MAX];
- long used_slots;
+ zend_long used_slots;
void *next;
} var_dtor_entries;
@@ -117,7 +117,7 @@ PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval *rva
PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval *nzval)
{
- long i;
+ zend_long i;
var_entries *var_hash = (*var_hashx)->first;
#if VAR_ENTRIES_DBG
fprintf(stderr, "var_replace(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(nzval));
@@ -134,7 +134,7 @@ PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval *nz
}
}
-static zval *var_access(php_unserialize_data_t *var_hashx, long id)
+static zval *var_access(php_unserialize_data_t *var_hashx, zend_long id)
{
var_entries *var_hash = (*var_hashx)->first;
#if VAR_ENTRIES_DBG
@@ -156,7 +156,7 @@ static zval *var_access(php_unserialize_data_t *var_hashx, long id)
PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
{
void *next;
- long i;
+ zend_long i;
var_entries *var_hash = (*var_hashx)->first;
var_dtor_entries *var_dtor_hash = (*var_hashx)->first_dtor;
#if VAR_ENTRIES_DBG
@@ -184,17 +184,17 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t maxlen)
{
size_t i, j;
- zend_string *str = STR_ALLOC(len, 0);
+ zend_string *str = zend_string_alloc(len, 0);
unsigned char *end = *(unsigned char **)p+maxlen;
if (end < *p) {
- STR_FREE(str);
+ zend_string_free(str);
return NULL;
}
for (i = 0; i < len; i++) {
if (*p >= end) {
- STR_FREE(str);
+ zend_string_free(str);
return NULL;
}
if (**p != '\\') {
@@ -211,7 +211,7 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t
} else if (**p >= 'A' && **p <= 'F') {
ch = (ch << 4) + (**p -'A'+10);
} else {
- STR_FREE(str);
+ zend_string_free(str);
return NULL;
}
}
@@ -242,10 +242,10 @@ object = [OC];
-static inline long parse_iv2(const unsigned char *p, const unsigned char **q)
+static inline zend_long parse_iv2(const unsigned char *p, const unsigned char **q)
{
char cursor;
- long result = 0;
+ zend_long result = 0;
int neg = 0;
switch (*p) {
@@ -270,7 +270,7 @@ static inline long parse_iv2(const unsigned char *p, const unsigned char **q)
return result;
}
-static inline long parse_iv(const unsigned char *p)
+static inline zend_long parse_iv(const unsigned char *p)
{
return parse_iv2(p, NULL);
}
@@ -300,7 +300,7 @@ static inline size_t parse_uiv(const unsigned char *p)
#define UNSERIALIZE_PARAMETER zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash TSRMLS_DC
#define UNSERIALIZE_PASSTHRU rval, p, max, var_hash TSRMLS_CC
-static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long elements, int objprops)
+static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, zend_long elements, int objprops)
{
while (elements-- > 0) {
zval key, *data, d, *old_data;
@@ -384,14 +384,14 @@ static inline int finish_nested_data(UNSERIALIZE_PARAMETER)
static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
{
- long datalen;
+ zend_long datalen;
datalen = parse_iv2((*p) + 2, p);
(*p) += 2;
if (datalen < 0 || (*p) + datalen >= max) {
- zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %ld present", datalen, (long)(max - (*p)));
+ zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %pd present", datalen, (zend_long)(max - (*p)));
return 0;
}
@@ -407,9 +407,9 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
return finish_nested_data(UNSERIALIZE_PASSTHRU);
}
-static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
+static inline zend_long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
{
- long elements;
+ zend_long elements;
elements = parse_iv2((*p) + 2, p);
@@ -430,7 +430,7 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
#ifdef PHP_WIN32
# pragma optimize("", off)
#endif
-static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
+static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements)
{
zval retval;
zval fname;
@@ -487,7 +487,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
/*!re2c
"R:" iv ";" {
- long id;
+ zend_long id;
*p = YYCURSOR;
if (!var_hash) return 0;
@@ -509,7 +509,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
}
"r:" iv ";" {
- long id;
+ zend_long id;
*p = YYCURSOR;
if (!var_hash) return 0;
@@ -544,14 +544,14 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
}
"i:" iv ";" {
-#if SIZEOF_LONG == 4
+#if SIZEOF_ZEND_INT == 4
int digits = YYCURSOR - start - 3;
if (start[2] == '-' || start[2] == '+') {
digits--;
}
- /* Use double for large long values that were serialized on a 64-bit system */
+ /* Use double for large zend_long values that were serialized on a 64-bit system */
if (digits >= MAX_LENGTH_OF_LONG - 1) {
if (digits == MAX_LENGTH_OF_LONG - 1) {
int cmp = strncmp((char*)YYCURSOR - MAX_LENGTH_OF_LONG, long_min_digits, MAX_LENGTH_OF_LONG - 1);
@@ -586,7 +586,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
}
"d:" (iv | nv | nvexp) ";" {
-#if SIZEOF_LONG == 4
+#if SIZEOF_ZEND_INT == 4
use_double:
#endif
*p = YYCURSOR;
@@ -637,7 +637,7 @@ use_double:
}
if (*(YYCURSOR) != '"') {
- STR_FREE(str);
+ zend_string_free(str);
*p = YYCURSOR;
return 0;
}
@@ -650,7 +650,7 @@ use_double:
}
"a:" uiv ":" "{" {
- long elements = parse_iv(start + 2);
+ zend_long elements = parse_iv(start + 2);
/* use iv() not uiv() in order to check data range */
*p = YYCURSOR;
@@ -680,7 +680,7 @@ use_double:
object ":" uiv ":" ["] {
size_t len, len2, len3, maxlen;
- long elements;
+ zend_long elements;
char *str;
zend_string *class_name;
zend_class_entry *ce;
@@ -724,7 +724,7 @@ object ":" uiv ":" ["] {
return 0;
}
- class_name = STR_INIT(str, len, 0);
+ class_name = zend_string_init(str, len, 0);
do {
/* Try to find class directly */
@@ -733,7 +733,7 @@ object ":" uiv ":" ["] {
if (ce) {
BG(serialize_lock)--;
if (EG(exception)) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
return 0;
}
break;
@@ -741,7 +741,7 @@ object ":" uiv ":" ["] {
BG(serialize_lock)--;
if (EG(exception)) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
return 0;
}
@@ -755,12 +755,12 @@ object ":" uiv ":" ["] {
/* Call unserialize callback */
ZVAL_STRING(&user_func, PG(unserialize_callback_func));
- ZVAL_STR(&args[0], STR_COPY(class_name));
+ ZVAL_STR(&args[0], zend_string_copy(class_name));
BG(serialize_lock)++;
if (call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) {
BG(serialize_lock)--;
if (EG(exception)) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
zval_ptr_dtor(&user_func);
zval_ptr_dtor(&args[0]);
return 0;
@@ -775,7 +775,7 @@ object ":" uiv ":" ["] {
BG(serialize_lock)--;
zval_ptr_dtor(&retval);
if (EG(exception)) {
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
zval_ptr_dtor(&user_func);
zval_ptr_dtor(&args[0]);
return 0;
@@ -803,7 +803,7 @@ object ":" uiv ":" ["] {
if (ret && incomplete_class) {
php_store_class_name(rval, class_name->val, len2);
}
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
return ret;
}
@@ -812,7 +812,7 @@ object ":" uiv ":" ["] {
if (incomplete_class) {
php_store_class_name(rval, class_name->val, len2);
}
- STR_RELEASE(class_name);
+ zend_string_release(class_name);
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c
index 97aa204892..e6bb6a0a23 100644
--- a/ext/sybase_ct/php_sybase_ct.c
+++ b/ext/sybase_ct/php_sybase_ct.c
@@ -281,8 +281,8 @@ static void _free_sybase_result(sybase_result *result)
if (result->fields) {
for (i=0; i<result->num_fields; i++) {
- STR_FREE(result->fields[i].name);
- STR_FREE(result->fields[i].column_source);
+ zend_string_free(result->fields[i].name);
+ zend_string_free(result->fields[i].column_source);
}
efree(result->fields);
}
@@ -390,7 +390,7 @@ static CS_RETCODE CS_PUBLIC _client_message_handler(CS_CONTEXT *context, CS_CONN
if (CS_SEVERITY(errmsg->msgnumber) >= SybCtG(min_client_severity)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sybase: Client message: %s (severity %ld)", errmsg->msgstring, (long)CS_SEVERITY(errmsg->msgnumber));
}
- STR_FREE(SybCtG(server_message));
+ zend_string_free(SybCtG(server_message));
SybCtG(server_message) = estrdup(errmsg->msgstring);
@@ -470,7 +470,7 @@ static CS_RETCODE CS_PUBLIC _server_message_handler(CS_CONTEXT *context, CS_CONN
TSRMLS_FETCH();
/* Remember the last server message in any case */
- STR_FREE(SybCtG(server_message));
+ zend_string_free(SybCtG(server_message));
SybCtG(server_message) = estrdup(srvmsg->text);
/* Retrieve sybase link */
@@ -620,7 +620,7 @@ PHP_RSHUTDOWN_FUNCTION(sybase)
zval_ptr_dtor(&SybCtG(callback_name));
SybCtG(callback_name)= NULL;
}
- STR_FREE(SybCtG(server_message));
+ zend_string_free(SybCtG(server_message));
SybCtG(server_message) = NULL;
return SUCCESS;
}
@@ -2076,7 +2076,7 @@ PHP_FUNCTION(sybase_result)
break;
}
default:
- convert_to_long(field);
+ convert_to_int(field);
field_offset = Z_LVAL_P(field);
if (field_offset < 0 || field_offset >= result->num_fields) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sybase: Bad column offset specified");
diff --git a/ext/sysvmsg/php_sysvmsg.h b/ext/sysvmsg/php_sysvmsg.h
index df8c4d4235..53ac7fc0ee 100644
--- a/ext/sysvmsg/php_sysvmsg.h
+++ b/ext/sysvmsg/php_sysvmsg.h
@@ -52,11 +52,11 @@ PHP_FUNCTION(msg_queue_exists);
typedef struct {
key_t key;
- long id;
+ zend_long id;
} sysvmsg_queue_t;
struct php_msgbuf {
- long mtype;
+ zend_long mtype;
char mtext[1];
};
diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c
index b1cbedbbc1..4c63d1902d 100644
--- a/ext/sysvmsg/sysvmsg.c
+++ b/ext/sysvmsg/sysvmsg.c
@@ -171,19 +171,19 @@ PHP_FUNCTION(msg_set_queue)
/* now pull out members of data and set them in the stat buffer */
if ((item = zend_hash_str_find(Z_ARRVAL_P(data), "msg_perm.uid", sizeof("msg_perm.uid") - 1)) != NULL) {
- convert_to_long_ex(item);
+ convert_to_int_ex(item);
stat.msg_perm.uid = Z_LVAL_P(item);
}
if ((item = zend_hash_str_find(Z_ARRVAL_P(data), "msg_perm.gid", sizeof("msg_perm.gid") - 1)) != NULL) {
- convert_to_long_ex(item);
+ convert_to_int_ex(item);
stat.msg_perm.gid = Z_LVAL_P(item);
}
if ((item = zend_hash_str_find(Z_ARRVAL_P(data), "msg_perm.mode", sizeof("msg_perm.mode") - 1)) != NULL) {
- convert_to_long_ex(item);
+ convert_to_int_ex(item);
stat.msg_perm.mode = Z_LVAL_P(item);
}
if ((item = zend_hash_str_find(Z_ARRVAL_P(data), "msg_qbytes", sizeof("msg_qbytes") - 1)) != NULL) {
- convert_to_long_ex(item);
+ convert_to_int_ex(item);
stat.msg_qbytes = Z_LVAL_P(item);
}
if (msgctl(mq->id, IPC_SET, &stat) == 0) {
@@ -230,7 +230,7 @@ PHP_FUNCTION(msg_stat_queue)
Check whether a message queue exists */
PHP_FUNCTION(msg_queue_exists)
{
- long key;
+ zend_long key;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &key) == FAILURE) {
return;
@@ -248,8 +248,8 @@ PHP_FUNCTION(msg_queue_exists)
Attach to a message queue */
PHP_FUNCTION(msg_get_queue)
{
- long key;
- long perms = 0666;
+ zend_long key;
+ zend_long perms = 0666;
sysvmsg_queue_t *mq;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &key, &perms) == FAILURE) {
@@ -299,8 +299,8 @@ PHP_FUNCTION(msg_remove_queue)
PHP_FUNCTION(msg_receive)
{
zval *out_message, *queue, *out_msgtype, *zerrcode = NULL;
- long desiredmsgtype, maxsize, flags = 0;
- long realflags = 0;
+ zend_long desiredmsgtype, maxsize, flags = 0;
+ zend_long realflags = 0;
zend_bool do_unserialize = 1;
sysvmsg_queue_t *mq = NULL;
struct php_msgbuf *messagebuffer = NULL; /* buffer to transmit */
@@ -386,7 +386,7 @@ PHP_FUNCTION(msg_receive)
PHP_FUNCTION(msg_send)
{
zval *message, *queue, *zerror=NULL;
- long msgtype;
+ zend_long msgtype;
zend_bool do_serialize = 1, blocking = 1;
sysvmsg_queue_t * mq = NULL;
struct php_msgbuf * messagebuffer = NULL; /* buffer to transmit */
@@ -425,7 +425,7 @@ PHP_FUNCTION(msg_send)
break;
case IS_LONG:
- message_len = spprintf(&p, 0, "%ld", Z_LVAL_P(message));
+ message_len = spprintf(&p, 0, "%pd", Z_LVAL_P(message));
break;
case IS_FALSE:
message_len = spprintf(&p, 0, "0");
diff --git a/ext/sysvsem/sysvsem.c b/ext/sysvsem/sysvsem.c
index 75c5f8baa5..6f7948519e 100644
--- a/ext/sysvsem/sysvsem.c
+++ b/ext/sysvsem/sysvsem.c
@@ -187,7 +187,7 @@ PHP_MINIT_FUNCTION(sysvsem)
Return an id for the semaphore with the given key, and allow max_acquire (default 1) processes to acquire it simultaneously */
PHP_FUNCTION(sem_get)
{
- long key, max_acquire = 1, perm = 0666, auto_release = 1;
+ zend_long key, max_acquire = 1, perm = 0666, auto_release = 1;
int semid;
struct sembuf sop[3];
int count;
diff --git a/ext/sysvshm/php_sysvshm.h b/ext/sysvshm/php_sysvshm.h
index ba8849d2c4..0d174002b1 100644
--- a/ext/sysvshm/php_sysvshm.h
+++ b/ext/sysvshm/php_sysvshm.h
@@ -34,27 +34,27 @@ extern zend_module_entry sysvshm_module_entry;
typedef struct {
int le_shm;
- long init_mem;
+ zend_long init_mem;
} sysvshm_module;
typedef struct {
- long key;
- long length;
- long next;
+ zend_long key;
+ zend_long length;
+ zend_long next;
char mem;
} sysvshm_chunk;
typedef struct {
char magic[8];
- long start;
- long end;
- long free;
- long total;
+ zend_long start;
+ zend_long end;
+ zend_long free;
+ zend_long total;
} sysvshm_chunk_head;
typedef struct {
key_t key; /* key set by user */
- long id; /* returned by shmget */
+ zend_long id; /* returned by shmget */
sysvshm_chunk_head *ptr; /* memory address of shared memory */
} sysvshm_shm;
diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c
index bb908a4113..2a0d0e8246 100644
--- a/ext/sysvshm/sysvshm.c
+++ b/ext/sysvshm/sysvshm.c
@@ -116,9 +116,9 @@ ZEND_GET_MODULE(sysvshm)
THREAD_LS sysvshm_module php_sysvshm;
-static int php_put_shm_data(sysvshm_chunk_head *ptr, long key, const char *data, long len);
-static long php_check_shm_data(sysvshm_chunk_head *ptr, long key);
-static int php_remove_shm_data(sysvshm_chunk_head *ptr, long shm_varpos);
+static int php_put_shm_data(sysvshm_chunk_head *ptr, zend_long key, const char *data, zend_long len);
+static zend_long php_check_shm_data(sysvshm_chunk_head *ptr, zend_long key);
+static int php_remove_shm_data(sysvshm_chunk_head *ptr, zend_long shm_varpos);
/* {{{ php_release_sysvshm
*/
@@ -150,7 +150,7 @@ PHP_FUNCTION(shm_attach)
sysvshm_shm *shm_list_ptr;
char *shm_ptr;
sysvshm_chunk_head *chunk_ptr;
- long shm_key, shm_id, shm_size = php_sysvshm.init_mem, shm_flag = 0666;
+ zend_long shm_key, shm_id, shm_size = php_sysvshm.init_mem, shm_flag = 0666;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|ll", &shm_key, &shm_size, &shm_flag)) {
return;
@@ -166,19 +166,19 @@ PHP_FUNCTION(shm_attach)
/* get the id from a specified key or create new shared memory */
if ((shm_id = shmget(shm_key, 0, 0)) < 0) {
if (shm_size < sizeof(sysvshm_chunk_head)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed for key 0x%lx: memorysize too small", shm_key);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed for key 0x%px: memorysize too small", shm_key);
efree(shm_list_ptr);
RETURN_FALSE;
}
if ((shm_id = shmget(shm_key, shm_size, shm_flag | IPC_CREAT | IPC_EXCL)) < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed for key 0x%lx: %s", shm_key, strerror(errno));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed for key 0x%px: %s", shm_key, strerror(errno));
efree(shm_list_ptr);
RETURN_FALSE;
}
}
if ((shm_ptr = shmat(shm_id, NULL, 0)) == (void *) -1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed for key 0x%lx: %s", shm_key, strerror(errno));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed for key 0x%px: %s", shm_key, strerror(errno));
efree(shm_list_ptr);
RETURN_FALSE;
}
@@ -243,7 +243,7 @@ PHP_FUNCTION(shm_put_var)
{
zval *shm_id, *arg_var;
int ret;
- long shm_key;
+ zend_long shm_key;
sysvshm_shm *shm_list_ptr;
smart_str shm_var = {0};
php_serialize_data_t var_hash;
@@ -282,10 +282,10 @@ PHP_FUNCTION(shm_put_var)
PHP_FUNCTION(shm_get_var)
{
zval *shm_id;
- long shm_key;
+ zend_long shm_key;
sysvshm_shm *shm_list_ptr;
char *shm_data;
- long shm_varpos;
+ zend_long shm_varpos;
sysvshm_chunk *shm_var;
php_unserialize_data_t var_hash;
@@ -299,7 +299,7 @@ PHP_FUNCTION(shm_get_var)
shm_varpos = php_check_shm_data((shm_list_ptr->ptr), shm_key);
if (shm_varpos < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "variable key %ld doesn't exist", shm_key);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "variable key %pd doesn't exist", shm_key);
RETURN_FALSE;
}
shm_var = (sysvshm_chunk*) ((char *)shm_list_ptr->ptr + shm_varpos);
@@ -319,7 +319,7 @@ PHP_FUNCTION(shm_get_var)
PHP_FUNCTION(shm_has_var)
{
zval *shm_id;
- long shm_key;
+ zend_long shm_key;
sysvshm_shm *shm_list_ptr;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &shm_id, &shm_key)) {
@@ -335,7 +335,7 @@ PHP_FUNCTION(shm_has_var)
PHP_FUNCTION(shm_remove_var)
{
zval *shm_id;
- long shm_key, shm_varpos;
+ zend_long shm_key, shm_varpos;
sysvshm_shm *shm_list_ptr;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &shm_id, &shm_key)) {
@@ -346,7 +346,7 @@ PHP_FUNCTION(shm_remove_var)
shm_varpos = php_check_shm_data((shm_list_ptr->ptr), shm_key);
if (shm_varpos < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "variable key %ld doesn't exist", shm_key);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "variable key %pd doesn't exist", shm_key);
RETURN_FALSE;
}
php_remove_shm_data((shm_list_ptr->ptr), shm_varpos);
@@ -356,13 +356,13 @@ PHP_FUNCTION(shm_remove_var)
/* {{{ php_put_shm_data
* inserts an ascii-string into shared memory */
-static int php_put_shm_data(sysvshm_chunk_head *ptr, long key, const char *data, long len)
+static int php_put_shm_data(sysvshm_chunk_head *ptr, zend_long key, const char *data, zend_long len)
{
sysvshm_chunk *shm_var;
- long total_size;
- long shm_varpos;
+ zend_long total_size;
+ zend_long shm_varpos;
- total_size = ((long) (len + sizeof(sysvshm_chunk) - 1) / sizeof(long)) * sizeof(long) + sizeof(long); /* long alligment */
+ total_size = ((zend_long) (len + sizeof(sysvshm_chunk) - 1) / sizeof(zend_long)) * sizeof(zend_long) + sizeof(zend_long); /* zend_long alligment */
if ((shm_varpos = php_check_shm_data(ptr, key)) > 0) {
php_remove_shm_data(ptr, shm_varpos);
@@ -385,9 +385,9 @@ static int php_put_shm_data(sysvshm_chunk_head *ptr, long key, const char *data,
/* {{{ php_check_shm_data
*/
-static long php_check_shm_data(sysvshm_chunk_head *ptr, long key)
+static zend_long php_check_shm_data(sysvshm_chunk_head *ptr, zend_long key)
{
- long pos;
+ zend_long pos;
sysvshm_chunk *shm_var;
pos = ptr->start;
@@ -412,10 +412,10 @@ static long php_check_shm_data(sysvshm_chunk_head *ptr, long key)
/* {{{ php_remove_shm_data
*/
-static int php_remove_shm_data(sysvshm_chunk_head *ptr, long shm_varpos)
+static int php_remove_shm_data(sysvshm_chunk_head *ptr, zend_long shm_varpos)
{
sysvshm_chunk *chunk_ptr, *next_chunk_ptr;
- long memcpy_len;
+ zend_long memcpy_len;
chunk_ptr = (sysvshm_chunk *) ((char *) ptr + shm_varpos);
next_chunk_ptr = (sysvshm_chunk *) ((char *) ptr + shm_varpos + chunk_ptr->next);
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c
index 5617dca7d6..ed7f00715b 100644
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -526,7 +526,7 @@ static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value TSRMLS
case TidyInteger:
if (Z_TYPE(conv) != IS_LONG) {
zval_copy_ctor(&conv);
- convert_to_long(&conv);
+ convert_to_int(&conv);
}
if (tidyOptSetInt(doc, tidyOptGetId(opt), Z_LVAL(conv))) {
return SUCCESS;
@@ -536,7 +536,7 @@ static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value TSRMLS
case TidyBoolean:
if (Z_TYPE(conv) != IS_LONG) {
zval_copy_ctor(&conv);
- convert_to_long(&conv);
+ convert_to_int(&conv);
}
if (tidyOptSetBool(doc, tidyOptGetId(opt), Z_LVAL(conv))) {
return SUCCESS;
@@ -627,7 +627,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil
}
if (is_file) {
- STR_RELEASE(data);
+ zend_string_release(data);
}
tidyBufFree(errbuf);
@@ -1264,7 +1264,7 @@ static PHP_FUNCTION(tidy_parse_file)
RETVAL_FALSE;
}
- STR_RELEASE(contents);
+ zend_string_release(contents);
}
/* }}} */
@@ -1577,7 +1577,7 @@ static TIDY_DOC_METHOD(__construct)
php_tidy_parse_string(obj, contents->val, contents->len, enc TSRMLS_CC);
- STR_RELEASE(contents);
+ zend_string_release(contents);
}
}
@@ -1612,7 +1612,7 @@ static TIDY_DOC_METHOD(parseFile)
RETVAL_TRUE;
}
- STR_RELEASE(contents);
+ zend_string_release(contents);
}
static TIDY_DOC_METHOD(parseString)
diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c
index 1a5411ca27..1847b0537d 100644
--- a/ext/tokenizer/tokenizer.c
+++ b/ext/tokenizer/tokenizer.c
@@ -185,7 +185,7 @@ PHP_FUNCTION(token_get_all)
return;
}
- ZVAL_STR(&source_zval, STR_COPY(source));
+ ZVAL_STR(&source_zval, zend_string_copy(source));
zend_save_lexical_state(&original_lex_state TSRMLS_CC);
if (zend_prepare_string_for_scanning(&source_zval, "" TSRMLS_CC) == FAILURE) {
@@ -206,7 +206,7 @@ PHP_FUNCTION(token_get_all)
*/
PHP_FUNCTION(token_name)
{
- long type;
+ zend_long type;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) {
return;
diff --git a/ext/tokenizer/tokenizer_data_gen.sh b/ext/tokenizer/tokenizer_data_gen.sh
index 9a675c4f97..1ed76e3617 100755
--- a/ext/tokenizer/tokenizer_data_gen.sh
+++ b/ext/tokenizer/tokenizer_data_gen.sh
@@ -45,8 +45,8 @@ echo '/*
echo 'void tokenizer_register_constants(INIT_FUNC_ARGS) {' >> $OUTFILE
-$AWK '/^#define T_/ { print " REGISTER_LONG_CONSTANT(\"" $2 "\", " $2 ", CONST_CS | CONST_PERSISTENT);" }' < $INFILE >> $OUTFILE
-echo ' REGISTER_LONG_CONSTANT("T_DOUBLE_COLON", T_PAAMAYIM_NEKUDOTAYIM, CONST_CS | CONST_PERSISTENT);' >> $OUTFILE
+$AWK '/^#define T_/ { print " REGISTER_INT_CONSTANT(\"" $2 "\", " $2 ", CONST_CS | CONST_PERSISTENT);" }' < $INFILE >> $OUTFILE
+echo ' REGISTER_INT_CONSTANT("T_DOUBLE_COLON", T_PAAMAYIM_NEKUDOTAYIM, CONST_CS | CONST_PERSISTENT);' >> $OUTFILE
echo '}' >> $OUTFILE
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index 0b853f34f2..e141a02688 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -275,7 +275,7 @@ PS_SERIALIZER_ENCODE_FUNC(wddx)
php_wddx_add_chunk_static(packet, WDDX_STRUCT_E);
php_wddx_packet_end(packet);
smart_str_0(packet);
- str = STR_COPY(packet->s);
+ str = zend_string_copy(packet->s);
php_wddx_destructor(packet);
return str;
@@ -300,15 +300,15 @@ PS_SERIALIZER_DECODE_FUNC(wddx)
if ((ret = php_wddx_deserialize_ex(val, vallen, &retval)) == SUCCESS) {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL(retval), idx, key, ent) {
if (key == NULL) {
- key = zend_long_to_str(idx);
+ key = zend_longo_str(idx);
} else {
- STR_ADDREF(key);
+ zend_string_addref(key);
}
if (php_set_session_var(key, ent, NULL TSRMLS_CC)) {
if (Z_REFCOUNTED_P(ent)) Z_ADDREF_P(ent);
}
PS_ADD_VAR(key);
- STR_RELEASE(key);
+ zend_string_release(key);
} ZEND_HASH_FOREACH_END();
}
@@ -396,7 +396,7 @@ static void php_wddx_serialize_string(wddx_packet *packet, zval *var TSRMLS_DC)
php_wddx_add_chunk_ex(packet, buf->val, buf->len);
- STR_RELEASE(buf);
+ zend_string_release(buf);
}
php_wddx_add_chunk_static(packet, WDDX_STRING_E);
}
@@ -508,13 +508,13 @@ static void php_wddx_serialize_object(wddx_packet *packet, zval *obj)
zend_string *tmp;
zend_unmangle_property_name(key->val, key->len, &class_name, &prop_name);
- tmp = STR_INIT(prop_name, strlen(prop_name), 0);
+ tmp = zend_string_init(prop_name, strlen(prop_name), 0);
php_wddx_serialize_var(packet, ent, tmp TSRMLS_CC);
- STR_RELEASE(tmp);
+ zend_string_release(tmp);
} else {
- key = zend_long_to_str(idx);
+ key = zend_longo_str(idx);
php_wddx_serialize_var(packet, ent, key TSRMLS_CC);
- STR_RELEASE(key);
+ zend_string_release(key);
}
} ZEND_HASH_FOREACH_END();
php_wddx_add_chunk_static(packet, WDDX_STRUCT_E);
@@ -568,9 +568,9 @@ static void php_wddx_serialize_array(wddx_packet *packet, zval *arr)
if (key) {
php_wddx_serialize_var(packet, ent, key TSRMLS_CC);
} else {
- key = zend_long_to_str(idx);
+ key = zend_longo_str(idx);
php_wddx_serialize_var(packet, ent, key TSRMLS_CC);
- STR_RELEASE(key);
+ zend_string_release(key);
}
} else {
php_wddx_serialize_var(packet, ent, NULL TSRMLS_CC);
@@ -600,7 +600,7 @@ void php_wddx_serialize_var(wddx_packet *packet, zval *var, zend_string *name TS
snprintf(tmp_buf, name_esc->len + sizeof(WDDX_VAR_S), WDDX_VAR_S, name_esc->val);
php_wddx_add_chunk(packet, tmp_buf);
efree(tmp_buf);
- STR_RELEASE(name_esc);
+ zend_string_release(name_esc);
}
if (Z_TYPE_P(var) == IS_INDIRECT) {
@@ -923,7 +923,7 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
zend_bool incomplete_class = 0;
zend_str_tolower(Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));
- STR_FORGET_HASH_VAL(Z_STR(ent1->data));
+ zend_string_forget_hash_val(Z_STR(ent1->data));
if ((pce = zend_hash_find_ptr(EG(class_table), Z_STR(ent1->data))) == NULL) {
incomplete_class = 1;
pce = PHP_IC_ENTRY;
@@ -996,7 +996,7 @@ static void php_wddx_process_data(void *user_data, const XML_Char *s, int len)
zval_ptr_dtor(&ent->data);
ZVAL_STRINGL(&ent->data, (char *)s, len);
} else {
- Z_STR(ent->data) = STR_REALLOC(Z_STR(ent->data), Z_STRLEN(ent->data) + len, 0);
+ Z_STR(ent->data) = zend_string_realloc(Z_STR(ent->data), Z_STRLEN(ent->data) + len, 0);
memcpy(Z_STRVAL(ent->data) + Z_STRLEN(ent->data) - len, (char *)s, len);
Z_STRVAL(ent->data)[Z_STRLEN(ent->data)] = '\0';
}
@@ -1097,7 +1097,7 @@ PHP_FUNCTION(wddx_serialize_value)
php_wddx_packet_end(packet);
smart_str_0(packet);
- RETVAL_STR(STR_COPY(packet->s));
+ RETVAL_STR(zend_string_copy(packet->s));
php_wddx_destructor(packet);
}
/* }}} */
@@ -1136,7 +1136,7 @@ PHP_FUNCTION(wddx_serialize_vars)
php_wddx_packet_end(packet);
smart_str_0(packet);
- RETVAL_STR(STR_COPY(packet->s));
+ RETVAL_STR(zend_string_copy(packet->s));
php_wddx_destructor(packet);
}
/* }}} */
@@ -1203,7 +1203,7 @@ PHP_FUNCTION(wddx_packet_end)
php_wddx_packet_end(packet);
smart_str_0(packet);
- RETVAL_STR(STR_COPY(packet->s));
+ RETVAL_STR(zend_string_copy(packet->s));
zend_list_close(Z_RES_P(packet_id));
}
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index 2886d6c686..a2bcb105f9 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -383,7 +383,7 @@ static void _xml_xmlchar_zval(const XML_Char *s, int len, const XML_Char *encodi
if (len == 0) {
len = _xml_xmlcharlen(s);
}
- ZVAL_STRINGL(ret, (char *)s, len);
+ ZVAL_STR(ret, xml_utf8_decode(s, len, encoding));
}
/* }}} */
@@ -571,12 +571,12 @@ PHPAPI zend_string *xml_utf8_encode(const char *s, int len, const XML_Char *enco
if (encoder == NULL) {
/* If no encoder function was specified, return the data as-is.
*/
- str = STR_INIT(s, len, 0);
+ str = zend_string_init(s, len, 0);
return str;
}
/* This is the theoretical max (will never get beyond len * 2 as long
* as we are converting from single-byte characters, though) */
- str = STR_ALLOC(len * 4, 0);
+ str = zend_string_alloc(len * 4, 0);
str->len = 0;
while (pos > 0) {
c = encoder ? encoder((unsigned char)(*s)) : (unsigned short)(*s);
@@ -599,7 +599,7 @@ PHPAPI zend_string *xml_utf8_encode(const char *s, int len, const XML_Char *enco
s++;
}
str->val[str->len] = '\0';
- str = STR_REALLOC(str, str->len, 0);
+ str = zend_string_realloc(str, str->len, 0);
return str;
}
/* }}} */
@@ -621,11 +621,11 @@ PHPAPI zend_string *xml_utf8_decode(const XML_Char *s, int len, const XML_Char *
/* If the target encoding was unknown, or no decoder function
* was specified, return the UTF-8-encoded data as-is.
*/
- str = STR_INIT((char *)s, len, 0);
+ str = zend_string_init((char *)s, len, 0);
return str;
}
- str = STR_ALLOC(len, 0);
+ str = zend_string_alloc(len, 0);
str->len = 0;
while (pos < (size_t)len) {
int status = FAILURE;
@@ -639,7 +639,7 @@ PHPAPI zend_string *xml_utf8_decode(const XML_Char *s, int len, const XML_Char *
}
str->val[str->len] = '\0';
if (str->len < len) {
- str = STR_REALLOC(str, str->len, 0);
+ str = zend_string_realloc(str, str->len, 0);
}
return str;
@@ -737,7 +737,7 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch
attributes += 2;
- STR_RELEASE(att);
+ zend_string_release(att);
}
xml_call_handler(parser, &parser->startElementHandler, parser->startElementPtr, 3, args, &retval);
@@ -775,7 +775,7 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch
atcnt++;
attributes += 2;
- STR_RELEASE(att);
+ zend_string_release(att);
}
if (atcnt) {
@@ -791,7 +791,7 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch
}
}
- STR_RELEASE(tag_name);
+ zend_string_release(tag_name);
}
}
/* }}} */
@@ -835,7 +835,7 @@ void _xml_endElementHandler(void *userData, const XML_Char *name)
parser->lastwasopen = 0;
}
- STR_RELEASE(tag_name);
+ zend_string_release(tag_name);
if ((parser->ltags) && (parser->level <= XML_MAXLEVEL)) {
efree(parser->ltags[parser->level-1]);
@@ -888,10 +888,10 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
/* check if the current tag already has a value - if yes append to that! */
if ((myval = zend_hash_str_find(Z_ARRVAL_P(parser->ctag), "value", sizeof("value") - 1))) {
int newlen = Z_STRLEN_P(myval) + decoded_value->len;
- Z_STR_P(myval) = STR_REALLOC(Z_STR_P(myval), newlen, 0);
+ Z_STR_P(myval) = zend_string_realloc(Z_STR_P(myval), newlen, 0);
strncpy(Z_STRVAL_P(myval) + Z_STRLEN_P(myval) - decoded_value->len,
decoded_value->val, decoded_value->len + 1);
- STR_RELEASE(decoded_value);
+ zend_string_release(decoded_value);
} else {
add_assoc_str(parser->ctag, "value", decoded_value);
}
@@ -905,10 +905,10 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
if (!strcmp(Z_STRVAL_P(mytype), "cdata")) {
if ((myval = zend_hash_str_find(Z_ARRVAL_P(curtag), "value", sizeof("value") - 1))) {
int newlen = Z_STRLEN_P(myval) + decoded_value->len;
- Z_STR_P(myval) = STR_REALLOC(Z_STR_P(myval), newlen, 0);
+ Z_STR_P(myval) = zend_string_realloc(Z_STR_P(myval), newlen, 0);
strncpy(Z_STRVAL_P(myval) + Z_STRLEN_P(myval) - decoded_value->len,
decoded_value->val, decoded_value->len + 1);
- STR_RELEASE(decoded_value);
+ zend_string_release(decoded_value);
return;
}
}
@@ -933,7 +933,7 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
}
}
} else {
- STR_RELEASE(decoded_value);
+ zend_string_release(decoded_value);
}
}
}
@@ -1041,7 +1041,7 @@ int _xml_externalEntityRefHandler(XML_Parser parserPtr,
_xml_xmlchar_zval(publicId, 0, parser->target_encoding, &args[4]);
xml_call_handler(parser, &parser->externalEntityRefHandler, parser->externalEntityRefPtr, 5, args, &retval);
if (!Z_ISUNDEF(retval)) {
- convert_to_long(&retval);
+ convert_to_int(&retval);
ret = Z_LVAL(retval);
} else {
ret = 0;
@@ -1366,7 +1366,7 @@ PHP_FUNCTION(xml_parse)
zval *pind;
char *data;
int data_len, ret;
- long isFinal = 0;
+ zend_long isFinal = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &pind, &data, &data_len, &isFinal) == FAILURE) {
return;
@@ -1447,7 +1447,7 @@ PHP_FUNCTION(xml_get_error_code)
Get XML parser error string */
PHP_FUNCTION(xml_error_string)
{
- long code;
+ zend_long code;
char *str;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &code) == FAILURE) {
@@ -1544,7 +1544,7 @@ PHP_FUNCTION(xml_parser_set_option)
{
xml_parser *parser;
zval *pind, *val;
- long opt;
+ zend_long opt;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &pind, &opt, &val) == FAILURE) {
return;
@@ -1554,15 +1554,15 @@ PHP_FUNCTION(xml_parser_set_option)
switch (opt) {
case PHP_XML_OPTION_CASE_FOLDING:
- convert_to_long_ex(val);
+ convert_to_int_ex(val);
parser->case_folding = Z_LVAL_P(val);
break;
case PHP_XML_OPTION_SKIP_TAGSTART:
- convert_to_long_ex(val);
+ convert_to_int_ex(val);
parser->toffset = Z_LVAL_P(val);
break;
case PHP_XML_OPTION_SKIP_WHITE:
- convert_to_long_ex(val);
+ convert_to_int_ex(val);
parser->skipwhite = Z_LVAL_P(val);
break;
case PHP_XML_OPTION_TARGET_ENCODING: {
@@ -1591,7 +1591,7 @@ PHP_FUNCTION(xml_parser_get_option)
{
xml_parser *parser;
zval *pind;
- long opt;
+ zend_long opt;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &pind, &opt) == FAILURE) {
return;
diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c
index 443fca3355..0b55caa357 100644
--- a/ext/xmlreader/php_xmlreader.c
+++ b/ext/xmlreader/php_xmlreader.c
@@ -561,7 +561,7 @@ Get value of an attribute at index from current element */
PHP_METHOD(xmlreader, getAttributeNo)
{
zval *id;
- long attr_pos;
+ zend_long attr_pos;
char *retchar = NULL;
xmlreader_object *intern;
@@ -618,7 +618,7 @@ Indicates whether given property (one of the parser option constants) is set or
PHP_METHOD(xmlreader, getParserProperty)
{
zval *id;
- long property;
+ zend_long property;
int retval = -1;
xmlreader_object *intern;
@@ -697,7 +697,7 @@ Returns TRUE on success and FALSE on failure */
PHP_METHOD(xmlreader, moveToAttributeNo)
{
zval *id;
- long attr_pos;
+ zend_long attr_pos;
int retval;
xmlreader_object *intern;
@@ -847,7 +847,7 @@ PHP_METHOD(xmlreader, open)
{
zval *id;
int source_len = 0, encoding_len = 0;
- long options = 0;
+ zend_long options = 0;
xmlreader_object *intern = NULL;
char *source, *valid_file = NULL;
char *encoding = NULL;
@@ -978,7 +978,7 @@ Properties must be set after open() or XML() and before the first read() is call
PHP_METHOD(xmlreader, setParserProperty)
{
zval *id;
- long property;
+ zend_long property;
int retval = -1;
zend_bool value;
xmlreader_object *intern;
@@ -1030,7 +1030,7 @@ PHP_METHOD(xmlreader, XML)
{
zval *id;
int source_len = 0, encoding_len = 0;
- long options = 0;
+ zend_long options = 0;
xmlreader_object *intern = NULL;
char *source, *uri = NULL, *encoding = NULL;
int resolved_path_len, ret = 0;
diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c
index e4be0f032c..42430b13df 100644
--- a/ext/xmlrpc/xmlrpc-epi-php.c
+++ b/ext/xmlrpc/xmlrpc-epi-php.c
@@ -504,8 +504,10 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep
if (in_val) {
zval val;
+ XMLRPC_VALUE_TYPE type;
+
ZVAL_UNDEF(&val);
- XMLRPC_VALUE_TYPE type = get_zval_xmlrpc_type(in_val, &val);
+ type = get_zval_xmlrpc_type(in_val, &val);
if (!Z_ISUNDEF(val)) {
switch (type) {
@@ -526,7 +528,7 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep
xReturn = XMLRPC_CreateValueBoolean(key, Z_TYPE(val) == IS_TRUE);
break;
case xmlrpc_int:
- convert_to_long(&val);
+ convert_to_int(&val);
xReturn = XMLRPC_CreateValueInt(key, Z_LVAL(val));
break;
case xmlrpc_double:
@@ -943,7 +945,7 @@ static void php_xmlrpc_introspection_callback(XMLRPC_SERVER server, void* data)
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid callback '%s' passed", php_function_name->val);
}
- STR_RELEASE(php_function_name);
+ zend_string_release(php_function_name);
} ZEND_HASH_FOREACH_END();
/* so we don't call the same callbacks ever again */
@@ -1116,6 +1118,7 @@ PHP_FUNCTION(xmlrpc_server_add_introspection_data)
{
zval *handle, *desc;
xmlrpc_server_data* server;
+ XMLRPC_VALUE xDesc;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra", &handle, &desc) == FAILURE) {
return;
@@ -1123,7 +1126,7 @@ PHP_FUNCTION(xmlrpc_server_add_introspection_data)
ZEND_FETCH_RESOURCE(server, xmlrpc_server_data*, handle, -1, "xmlrpc server", le_xmlrpc_server);
- XMLRPC_VALUE xDesc = PHP_to_XMLRPC(desc TSRMLS_CC);
+ xDesc = PHP_to_XMLRPC(desc TSRMLS_CC);
if (xDesc) {
int retval = XMLRPC_ServerAddIntrospectionData(server->server_ptr, xDesc);
XMLRPC_CleanupValue(xDesc);
diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c
index d743a29113..027fd33108 100644
--- a/ext/xmlwriter/php_xmlwriter.c
+++ b/ext/xmlwriter/php_xmlwriter.c
@@ -635,7 +635,7 @@ static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, i
dir_len = php_dirname(file_dirname, strlen(source));
if (dir_len > 0) {
- struct stat buf;
+ zend_stat_t buf;
if (php_sys_stat(file_dirname, &buf) != 0) {
xmlFreeURI(uri);
return NULL;
diff --git a/ext/xsl/php_xsl.h b/ext/xsl/php_xsl.h
index f6ad3712dc..375cb32fb0 100644
--- a/ext/xsl/php_xsl.h
+++ b/ext/xsl/php_xsl.h
@@ -64,7 +64,7 @@ typedef struct _xsl_object {
HashTable *node_list;
php_libxml_node_object *doc;
char *profiling;
- long securityPrefs;
+ zend_long securityPrefs;
int securityPrefsSet;
zend_object std;
} xsl_object;
diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c
index af01da1513..04aef6083e 100644
--- a/ext/xsl/xsltprocessor.c
+++ b/ext/xsl/xsltprocessor.c
@@ -138,7 +138,7 @@ static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params TSRMLS
zval *value;
char *xpath_expr;
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
char **params = NULL;
int i = 0;
@@ -292,7 +292,12 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
- fci.params = args;
+ if (fci.param_count > 0) {
+ fci.params = args;
+ } else {
+ fci.params = NULL;
+ }
+
obj = valuePop(ctxt);
if (obj->stringval == NULL) {
@@ -357,7 +362,7 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
zval_ptr_dtor(&retval);
}
}
- STR_RELEASE(callable);
+ zend_string_release(callable);
zval_ptr_dtor(&handler);
if (fci.param_count > 0) {
for (i = 0; i < nargs - 1; i++) {
@@ -432,7 +437,7 @@ PHP_FUNCTION(xsl_xsltprocessor_import_stylesheet)
ZVAL_STRING(&member, "cloneDocument");
cloneDocu = std_hnd->read_property(id, &member, BP_VAR_IS, NULL, &rv TSRMLS_CC);
if (Z_TYPE_P(cloneDocu) != IS_NULL) {
- convert_to_long(cloneDocu);
+ convert_to_int(cloneDocu);
clone_docu = Z_LVAL_P(cloneDocu);
}
zval_ptr_dtor(&member);
@@ -531,7 +536,7 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl
ZVAL_STRING(&member, "doXInclude");
doXInclude = std_hnd->read_property(id, &member, BP_VAR_IS, NULL, &rv TSRMLS_CC);
if (Z_TYPE_P(doXInclude) != IS_NULL) {
- convert_to_long(doXInclude);
+ convert_to_int(doXInclude);
ctxt->xinclude = Z_LVAL_P(doXInclude);
}
zval_ptr_dtor(&member);
@@ -760,7 +765,7 @@ PHP_FUNCTION(xsl_xsltprocessor_set_parameter)
zval *id;
zval *array_value, *entry, new_string;
xsl_object *intern;
- ulong idx;
+ zend_ulong idx;
char *namespace;
int namespace_len;
zend_string *string_key, *name, *value;
@@ -785,7 +790,7 @@ PHP_FUNCTION(xsl_xsltprocessor_set_parameter)
intern = Z_XSL_P(id);
- ZVAL_STR(&new_string, STR_COPY(value));
+ ZVAL_STR(&new_string, zend_string_copy(value));
zend_hash_update(intern->parameter, name, &new_string);
RETURN_TRUE;
@@ -815,7 +820,7 @@ PHP_FUNCTION(xsl_xsltprocessor_get_parameter)
intern = Z_XSL_P(id);
if ((value = zend_hash_find(intern->parameter, name)) != NULL) {
convert_to_string_ex(value);
- RETURN_STR(STR_COPY(Z_STR_P(value)));
+ RETURN_STR(zend_string_copy(Z_STR_P(value)));
} else {
RETURN_FALSE;
}
@@ -914,7 +919,7 @@ PHP_FUNCTION(xsl_xsltprocessor_set_security_prefs)
{
zval *id;
xsl_object *intern;
- long securityPrefs, oldSecurityPrefs;
+ zend_long securityPrefs, oldSecurityPrefs;
DOM_GET_THIS(id);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &securityPrefs) == FAILURE) {
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 633644e4e9..4af78340c4 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -187,7 +187,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname_fullpath)) {
efree(file_dirname_fullpath);
- STR_RELEASE(file_basename);
+ zend_string_release(file_basename);
CWD_STATE_FREE(new_state.cwd);
return 0;
}
@@ -199,7 +199,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
if (!ret) {
efree(file_dirname_fullpath);
if (!is_dir_only) {
- STR_RELEASE(file_basename);
+ zend_string_release(file_basename);
CWD_STATE_FREE(new_state.cwd);
}
return 0;
@@ -216,13 +216,13 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
len = spprintf(&fullpath, 0, "%s/%s", file_dirname_fullpath, file_basename->val);
if (!len) {
efree(file_dirname_fullpath);
- STR_RELEASE(file_basename);
+ zend_string_release(file_basename);
CWD_STATE_FREE(new_state.cwd);
return 0;
} else if (len > MAXPATHLEN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Full extraction path exceed MAXPATHLEN (%i)", MAXPATHLEN);
efree(file_dirname_fullpath);
- STR_RELEASE(file_basename);
+ zend_string_release(file_basename);
CWD_STATE_FREE(new_state.cwd);
return 0;
}
@@ -234,7 +234,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
if (ZIP_OPENBASEDIR_CHECKPATH(fullpath)) {
efree(fullpath);
efree(file_dirname_fullpath);
- STR_RELEASE(file_basename);
+ zend_string_release(file_basename);
CWD_STATE_FREE(new_state.cwd);
return 0;
}
@@ -264,7 +264,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
done:
efree(fullpath);
- STR_RELEASE(file_basename);
+ zend_string_release(file_basename);
efree(file_dirname_fullpath);
CWD_STATE_FREE(new_state.cwd);
@@ -311,15 +311,15 @@ static int php_zip_add_file(struct zip *za, const char *filename, size_t filenam
}
/* }}} */
-static int php_zip_parse_options(zval *options, long *remove_all_path, char **remove_path, int *remove_path_len, char **add_path, int *add_path_len TSRMLS_DC) /* {{{ */
+static int php_zip_parse_options(zval *options, zend_long *remove_all_path, char **remove_path, int *remove_path_len, char **add_path, int *add_path_len TSRMLS_DC) /* {{{ */
{
zval *option;
if ((option = zend_hash_str_find(HASH_OF(options), "remove_all_path", sizeof("remove_all_path") - 1)) != NULL) {
- long opt;
+ zend_long opt;
if (Z_TYPE_P(option) != IS_LONG) {
zval tmp;
ZVAL_DUP(&tmp, option);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
opt = Z_LVAL(tmp);
} else {
opt = Z_LVAL_P(option);
@@ -481,7 +481,7 @@ static char * php_zipobj_get_zip_comment(struct zip *za, int *len TSRMLS_DC) /*
#endif /* }}} */
-int php_zip_glob(char *pattern, int pattern_len, long flags, zval *return_value TSRMLS_DC) /* {{{ */
+int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_value TSRMLS_DC) /* {{{ */
{
#ifdef HAVE_GLOB
char cwd[MAXPATHLEN];
@@ -565,7 +565,7 @@ int php_zip_glob(char *pattern, int pattern_len, long flags, zval *return_value
* able to filter directories out.
*/
if (flags & GLOB_ONLYDIR) {
- struct stat s;
+ zend_stat_t s;
if (0 != VCWD_STAT(globbuf.gl_pathv[n], &s)) {
continue;
@@ -637,7 +637,7 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val
/* only the files, directories are ignored */
for (i = 0; i < files_cnt; i++) {
- struct stat s;
+ zend_stat_t s;
char fullpath[MAXPATHLEN];
int ovector[3];
int matches;
@@ -645,14 +645,14 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val
if ((namelist_len == 1 && namelist[i]->val[0] == '.') ||
(namelist_len == 2 && namelist[i]->val[0] == '.' && namelist[i]->val[1] == '.')) {
- STR_RELEASE(namelist[i]);
+ zend_string_release(namelist[i]);
continue;
}
if ((path_len + namelist_len + 1) >= MAXPATHLEN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "add_path string too long (max: %i, %i given)",
MAXPATHLEN - 1, (path_len + namelist_len + 1));
- STR_RELEASE(namelist[i]);
+ zend_string_release(namelist[i]);
break;
}
@@ -660,24 +660,24 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val
if (0 != VCWD_STAT(fullpath, &s)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot read <%s>", fullpath);
- STR_RELEASE(namelist[i]);
+ zend_string_release(namelist[i]);
continue;
}
if (S_IFDIR == (s.st_mode & S_IFMT)) {
- STR_RELEASE(namelist[i]);
+ zend_string_release(namelist[i]);
continue;
}
matches = pcre_exec(re, NULL, namelist[i]->val, namelist[i]->len, 0, 0, ovector, 3);
/* 0 means that the vector is too small to hold all the captured substring offsets */
if (matches < 0) {
- STR_RELEASE(namelist[i]);
+ zend_string_release(namelist[i]);
continue;
}
add_next_index_string(return_value, fullpath);
- STR_RELEASE(namelist[i]);
+ zend_string_release(namelist[i]);
}
efree(namelist);
}
@@ -1244,7 +1244,7 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_close)
static PHP_NAMED_FUNCTION(zif_zip_entry_read)
{
zval * zip_entry;
- long len = 0;
+ zend_long len = 0;
zip_read_rsrc * zr_rsrc;
zend_string *buffer;
int n = 0;
@@ -1260,14 +1260,14 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_read)
}
if (zr_rsrc->zf) {
- buffer = STR_ALLOC(len, 0);
+ buffer = zend_string_alloc(len, 0);
n = zip_fread(zr_rsrc->zf, buffer->val, buffer->len);
if (n > 0) {
buffer->val[n] = '\0';
buffer->len = n;
RETURN_STR(buffer);
} else {
- STR_FREE(buffer);
+ zend_string_free(buffer);
RETURN_EMPTY_STRING()
}
} else {
@@ -1296,10 +1296,10 @@ static void php_zip_entry_get_info(INTERNAL_FUNCTION_PARAMETERS, int opt) /* {{{
RETURN_STRING((char *)zr_rsrc->sb.name);
break;
case 1:
- RETURN_LONG((long) (zr_rsrc->sb.comp_size));
+ RETURN_LONG((zend_long) (zr_rsrc->sb.comp_size));
break;
case 2:
- RETURN_LONG((long) (zr_rsrc->sb.size));
+ RETURN_LONG((zend_long) (zr_rsrc->sb.size));
break;
case 3:
switch (zr_rsrc->sb.comp_method) {
@@ -1333,7 +1333,7 @@ static void php_zip_entry_get_info(INTERNAL_FUNCTION_PARAMETERS, int opt) /* {{{
default:
RETURN_FALSE;
}
- RETURN_LONG((long) (zr_rsrc->sb.comp_method));
+ RETURN_LONG((zend_long) (zr_rsrc->sb.comp_method));
break;
}
@@ -1378,7 +1378,7 @@ static ZIPARCHIVE_METHOD(open)
{
struct zip *intern;
int err = 0;
- long flags = 0;
+ zend_long flags = 0;
char *resolved_path;
zend_string *filename;
zval *self = getThis();
@@ -1423,7 +1423,7 @@ static ZIPARCHIVE_METHOD(open)
intern = zip_open(resolved_path, flags, &err);
if (!intern || err) {
efree(resolved_path);
- RETURN_LONG((long)err);
+ RETURN_LONG((zend_long)err);
}
ze_obj->filename = resolved_path;
ze_obj->filename_len = strlen(resolved_path);
@@ -1576,8 +1576,8 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
char *remove_path = NULL;
char *add_path = NULL;
int add_path_len, remove_path_len = 0, path_len = 0;
- long remove_all_path = 0;
- long flags = 0;
+ zend_long remove_all_path = 0;
+ zend_long flags = 0;
zval *options = NULL;
int found;
zend_string *pattern;
@@ -1645,7 +1645,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
if (add_path) {
if ((add_path_len + file_stripped_len) > MAXPATHLEN) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Entry name too long (max: %d, %ld given)",
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Entry name too long (max: %d, %pd given)",
MAXPATHLEN - 1, (add_path_len + file_stripped_len));
zval_ptr_dtor(return_value);
RETURN_FALSE;
@@ -1659,7 +1659,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
entry_name_len = Z_STRLEN_P(zval_file);
}
if (basename) {
- STR_RELEASE(basename);
+ zend_string_release(basename);
basename = NULL;
}
if (php_zip_add_file(intern, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file),
@@ -1697,7 +1697,7 @@ static ZIPARCHIVE_METHOD(addFile)
zval *self = getThis();
char *entry_name = NULL;
int entry_name_len = 0;
- long offset_start = 0, offset_len = 0;
+ zend_long offset_start = 0, offset_len = 0;
zend_string *filename;
if (!self) {
@@ -1735,8 +1735,9 @@ static ZIPARCHIVE_METHOD(addFromString)
{
struct zip *intern;
zval *self = getThis();
- char *buffer, *name;
- int buffer_len, name_len;
+ zend_string *buffer;
+ char *name;
+ int name_len;
ze_zip_object *ze_obj;
struct zip_source *zs;
int pos = 0;
@@ -1748,8 +1749,8 @@ static ZIPARCHIVE_METHOD(addFromString)
ZIP_FROM_OBJECT(intern, self);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
- &name, &name_len, &buffer, &buffer_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sS",
+ &name, &name_len, &buffer) == FAILURE) {
return;
}
@@ -1762,10 +1763,10 @@ static ZIPARCHIVE_METHOD(addFromString)
ze_obj->buffers_cnt++;
pos = 0;
}
- ze_obj->buffers[pos] = (char *)emalloc(buffer_len + 1);
- memcpy(ze_obj->buffers[pos], buffer, buffer_len + 1);
+ ze_obj->buffers[pos] = (char *)emalloc(buffer->len + 1);
+ memcpy(ze_obj->buffers[pos], buffer->val, buffer->len + 1);
- zs = zip_source_buffer(intern, ze_obj->buffers[pos], buffer_len, 0);
+ zs = zip_source_buffer(intern, ze_obj->buffers[pos], buffer->len, 0);
if (zs == NULL) {
RETURN_FALSE;
@@ -1796,7 +1797,7 @@ static ZIPARCHIVE_METHOD(statName)
{
struct zip *intern;
zval *self = getThis();
- long flags = 0;
+ zend_long flags = 0;
struct zip_stat sb;
zend_string *name;
@@ -1822,7 +1823,7 @@ static ZIPARCHIVE_METHOD(statIndex)
{
struct zip *intern;
zval *self = getThis();
- long index, flags = 0;
+ zend_long index, flags = 0;
struct zip_stat sb;
@@ -1850,8 +1851,8 @@ static ZIPARCHIVE_METHOD(locateName)
{
struct zip *intern;
zval *self = getThis();
- long flags = 0;
- long idx = -1;
+ zend_long flags = 0;
+ zend_long idx = -1;
zend_string *name;
if (!self) {
@@ -1868,7 +1869,7 @@ static ZIPARCHIVE_METHOD(locateName)
RETURN_FALSE;
}
- idx = (long)zip_name_locate(intern, (const char *)name->val, flags);
+ idx = (zend_long)zip_name_locate(intern, (const char *)name->val, flags);
if (idx >= 0) {
RETURN_LONG(idx);
@@ -1885,7 +1886,7 @@ static ZIPARCHIVE_METHOD(getNameIndex)
struct zip *intern;
zval *self = getThis();
const char *name;
- long flags = 0, index = 0;
+ zend_long flags = 0, index = 0;
if (!self) {
RETURN_FALSE;
@@ -1940,7 +1941,7 @@ static ZIPARCHIVE_METHOD(getArchiveComment)
{
struct zip *intern;
zval *self = getThis();
- long flags = 0;
+ zend_long flags = 0;
const char * comment;
int comment_len = 0;
@@ -1958,7 +1959,7 @@ static ZIPARCHIVE_METHOD(getArchiveComment)
if(comment==NULL) {
RETURN_FALSE;
}
- RETURN_STRINGL((char *)comment, (long)comment_len);
+ RETURN_STRINGL((char *)comment, (zend_long)comment_len);
}
/* }}} */
@@ -2001,7 +2002,7 @@ static ZIPARCHIVE_METHOD(setCommentIndex)
{
struct zip *intern;
zval *self = getThis();
- long index;
+ zend_long index;
int comment_len;
char * comment;
struct zip_stat sb;
@@ -2033,7 +2034,7 @@ static ZIPARCHIVE_METHOD(setExternalAttributesName)
zval *self = getThis();
int name_len;
char *name;
- long flags=0, opsys, attr;
+ zend_long flags=0, opsys, attr;
zip_int64_t idx;
if (!self) {
@@ -2069,7 +2070,7 @@ static ZIPARCHIVE_METHOD(setExternalAttributesIndex)
{
struct zip *intern;
zval *self = getThis();
- long index, flags=0, opsys, attr;
+ zend_long index, flags=0, opsys, attr;
struct zip_stat sb;
if (!self) {
@@ -2100,7 +2101,7 @@ static ZIPARCHIVE_METHOD(getExternalAttributesName)
zval *self = getThis(), *z_opsys, *z_attr;
int name_len;
char *name;
- long flags=0;
+ zend_long flags=0;
zip_uint8_t opsys;
zip_uint32_t attr;
zip_int64_t idx;
@@ -2142,7 +2143,7 @@ static ZIPARCHIVE_METHOD(getExternalAttributesIndex)
{
struct zip *intern;
zval *self = getThis(), *z_opsys, *z_attr;
- long index, flags=0;
+ zend_long index, flags=0;
zip_uint8_t opsys;
zip_uint32_t attr;
struct zip_stat sb;
@@ -2179,7 +2180,7 @@ static ZIPARCHIVE_METHOD(getCommentName)
struct zip *intern;
zval *self = getThis();
int name_len, idx;
- long flags = 0;
+ zend_long flags = 0;
int comment_len = 0;
const char * comment;
char *name;
@@ -2205,7 +2206,7 @@ static ZIPARCHIVE_METHOD(getCommentName)
}
comment = zip_get_file_comment(intern, idx, &comment_len, (int)flags);
- RETURN_STRINGL((char *)comment, (long)comment_len);
+ RETURN_STRINGL((char *)comment, (zend_long)comment_len);
}
/* }}} */
@@ -2215,7 +2216,7 @@ static ZIPARCHIVE_METHOD(getCommentIndex)
{
struct zip *intern;
zval *self = getThis();
- long index, flags = 0;
+ zend_long index, flags = 0;
const char * comment;
int comment_len = 0;
struct zip_stat sb;
@@ -2233,7 +2234,7 @@ static ZIPARCHIVE_METHOD(getCommentIndex)
PHP_ZIP_STAT_INDEX(intern, index, 0, sb);
comment = zip_get_file_comment(intern, index, &comment_len, (int)flags);
- RETURN_STRINGL((char *)comment, (long)comment_len);
+ RETURN_STRINGL((char *)comment, (zend_long)comment_len);
}
/* }}} */
@@ -2243,7 +2244,7 @@ static ZIPARCHIVE_METHOD(deleteIndex)
{
struct zip *intern;
zval *self = getThis();
- long index;
+ zend_long index;
if (!self) {
RETURN_FALSE;
@@ -2307,7 +2308,7 @@ static ZIPARCHIVE_METHOD(renameIndex)
char *new_name;
int new_name_len;
- long index;
+ zend_long index;
if (!self) {
RETURN_FALSE;
@@ -2374,7 +2375,7 @@ static ZIPARCHIVE_METHOD(unchangeIndex)
{
struct zip *intern;
zval *self = getThis();
- long index;
+ zend_long index;
if (!self) {
RETURN_FALSE;
@@ -2574,9 +2575,9 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
struct zip_stat sb;
struct zip_file *zf;
- long index = -1;
- long flags = 0;
- long len = 0;
+ zend_long index = -1;
+ zend_long flags = 0;
+ zend_long len = 0;
zend_string *filename;
zend_string *buffer;
@@ -2618,10 +2619,10 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
RETURN_FALSE;
}
- buffer = STR_ALLOC(len, 0);
+ buffer = zend_string_alloc(len, 0);
n = zip_fread(zf, buffer->val, buffer->len);
if (n < 1) {
- STR_FREE(buffer);
+ zend_string_free(buffer);
RETURN_EMPTY_STRING();
}
diff --git a/ext/zip/php_zip.h b/ext/zip/php_zip.h
index f4ad99f293..15c085271a 100644
--- a/ext/zip/php_zip.h
+++ b/ext/zip/php_zip.h
@@ -70,7 +70,7 @@ typedef struct _ze_zip_read_rsrc {
struct zip_stat sb;
} zip_read_rsrc;
-#define ZIPARCHIVE_ME(name, arg_info, flags) {#name, c_ziparchive_ ##name, arg_info,(zend_uint) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
+#define ZIPARCHIVE_ME(name, arg_info, flags) {#name, c_ziparchive_ ##name, arg_info,(uint32_t) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
#define ZIPARCHIVE_METHOD(name) ZEND_NAMED_FUNCTION(c_ziparchive_ ##name)
/* Extends zend object */
diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c
index 29ec3d022a..44d5507b77 100644
--- a/ext/zip/zip_stream.c
+++ b/ext/zip/zip_stream.c
@@ -152,7 +152,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
fragment++;
if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname)) {
- STR_RELEASE(file_basename);
+ zend_string_release(file_basename);
return -1;
}
@@ -160,7 +160,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
if (za) {
memset(ssb, 0, sizeof(php_stream_statbuf));
if (zip_stat(za, fragment, ZIP_FL_NOCASE, &sb) != 0) {
- STR_RELEASE(file_basename);
+ zend_string_release(file_basename);
return -1;
}
zip_close(za);
@@ -184,7 +184,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
#endif
ssb->sb.st_ino = -1;
}
- STR_RELEASE(file_basename);
+ zend_string_release(file_basename);
return 0;
}
/* }}} */
@@ -296,7 +296,7 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper,
fragment++;
if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname)) {
- STR_RELEASE(file_basename);
+ zend_string_release(file_basename);
return NULL;
}
@@ -320,7 +320,7 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper,
}
}
- STR_RELEASE(file_basename);
+ zend_string_release(file_basename);
if (!stream) {
return NULL;
diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h
index bd2a85bea6..f76e4c2266 100644
--- a/ext/zlib/php_zlib.h
+++ b/ext/zlib/php_zlib.h
@@ -50,11 +50,11 @@ typedef struct _php_zlib_context {
ZEND_BEGIN_MODULE_GLOBALS(zlib)
/* variables for transparent gzip encoding */
int compression_coding;
- long output_compression;
- long output_compression_level;
+ zend_long output_compression;
+ zend_long output_compression_level;
char *output_handler;
php_zlib_context *ob_gzhandler;
- long output_compression_default;
+ zend_long output_compression_default;
zend_bool handler_registered;
ZEND_END_MODULE_GLOBALS(zlib);
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index c38d6eca2c..be22378052 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -70,9 +70,9 @@ static int php_zlib_output_encoding(TSRMLS_D)
zval *enc;
if (!ZLIBG(compression_coding)) {
- zend_string *name = STR_INIT("_SERVER", sizeof("_SERVER") - 1, 0);
+ zend_string *name = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
zend_is_auto_global(name TSRMLS_CC);
- STR_RELEASE(name);
+ zend_string_release(name);
if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY &&
(enc = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_ACCEPT_ENCODING", sizeof("HTTP_ACCEPT_ENCODING") - 1))) {
convert_to_string(enc);
@@ -315,7 +315,7 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod
Z.zfree = php_zlib_free;
if (Z_OK == (status = deflateInit2(&Z, level, Z_DEFLATED, encoding, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY))) {
- out = STR_ALLOC(PHP_ZLIB_BUFFER_SIZE_GUESS(in_len), 0);
+ out = zend_string_alloc(PHP_ZLIB_BUFFER_SIZE_GUESS(in_len), 0);
Z.next_in = (Bytef *) in_buf;
Z.next_out = (Bytef *) out->val;
@@ -327,11 +327,11 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod
if (Z_STREAM_END == status) {
/* size buffer down to actual length */
- out = STR_REALLOC(out, Z.total_out, 0);
+ out = zend_string_realloc(out, Z.total_out, 0);
out->val[out->len] = '\0';
return out;
} else {
- STR_FREE(out);
+ zend_string_free(out);
}
}
@@ -448,7 +448,7 @@ static PHP_FUNCTION(ob_gzhandler)
{
char *in_str;
int in_len;
- long flags = 0;
+ zend_long flags = 0;
php_output_context ctx = {0};
int encoding, rv;
@@ -537,7 +537,7 @@ static PHP_FUNCTION(gzfile)
int flags = REPORT_ERRORS;
char buf[8192] = {0};
register int i = 0;
- long use_include_path = 0;
+ zend_long use_include_path = 0;
php_stream *stream;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &filename, &filename_len, &use_include_path)) {
@@ -578,7 +578,7 @@ static PHP_FUNCTION(gzopen)
int filename_len, mode_len;
int flags = REPORT_ERRORS;
php_stream *stream;
- long use_include_path = 0;
+ zend_long use_include_path = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &filename, &filename_len, &mode, &mode_len, &use_include_path) == FAILURE) {
return;
@@ -606,7 +606,7 @@ static PHP_FUNCTION(readgzfile)
int flags = REPORT_ERRORS;
php_stream *stream;
int size;
- long use_include_path = 0;
+ zend_long use_include_path = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, &filename_len, &use_include_path) == FAILURE) {
return;
@@ -631,8 +631,8 @@ static PHP_FUNCTION(readgzfile)
static PHP_FUNCTION(name) \
{ \
zend_string *in, *out; \
- long level = -1; \
- long encoding = default_encoding; \
+ zend_long level = -1; \
+ zend_long encoding = default_encoding; \
if (default_encoding) { \
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|ll", &in, &level, &encoding)) { \
return; \
@@ -643,7 +643,7 @@ static PHP_FUNCTION(name) \
} \
} \
if (level < -1 || level > 9) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "compression level (%ld) must be within -1..9", level); \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "compression level (%pd) must be within -1..9", level); \
RETURN_FALSE; \
} \
switch (encoding) { \
@@ -667,12 +667,12 @@ static PHP_FUNCTION(name) \
char *in_buf, *out_buf; \
int in_len; \
size_t out_len; \
- long max_len = 0; \
+ zend_long max_len = 0; \
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &in_buf, &in_len, &max_len)) { \
return; \
} \
if (max_len < 0) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "length (%ld) must be greater or equal zero", max_len); \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "length (%pd) must be greater or equal zero", max_len); \
RETURN_FALSE; \
} \
if (SUCCESS != php_zlib_decode(in_buf, in_len, &out_buf, &out_len, encoding, max_len TSRMLS_CC)) { \
diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c
index 0b91edfb02..6be0b02962 100644
--- a/ext/zlib/zlib_filter.c
+++ b/ext/zlib/zlib_filter.c
@@ -302,8 +302,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
data->strm.zalloc = (alloc_func) php_zlib_alloc;
data->strm.zfree = (free_func) php_zlib_free;
- data->strm.avail_out = data->outbuf_len = 0x8000;
- data->inbuf_len = 2048;
+ data->strm.avail_out = data->outbuf_len = data->inbuf_len = 0x8000;
data->strm.next_in = data->inbuf = (Bytef *) pemalloc(data->inbuf_len, persistent);
if (!data->inbuf) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", data->inbuf_len);
@@ -333,9 +332,9 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
/* log-2 base of history window (9 - 15) */
ZVAL_DUP(&tmp, tmpzval);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
if (Z_LVAL(tmp) < -MAX_WBITS || Z_LVAL(tmp) > MAX_WBITS + 32) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for window size. (%ld)", Z_LVAL(tmp));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for window size. (%pd)", Z_LVAL(tmp));
} else {
windowBits = Z_LVAL(tmp);
}
@@ -364,11 +363,11 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
case IS_OBJECT:
if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "memory", sizeof("memory") -1))) {
ZVAL_DUP(&tmp, tmpzval);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
/* Memory Level (1 - 9) */
if (Z_LVAL(tmp) < 1 || Z_LVAL(tmp) > MAX_MEM_LEVEL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for memory level. (%ld)", Z_LVAL(tmp));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for memory level. (%pd)", Z_LVAL(tmp));
} else {
memLevel = Z_LVAL(tmp);
}
@@ -376,11 +375,11 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "window", sizeof("window") - 1))) {
ZVAL_DUP(&tmp, tmpzval);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
/* log-2 base of history window (9 - 15) */
if (Z_LVAL(tmp) < -MAX_WBITS || Z_LVAL(tmp) > MAX_WBITS + 16) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for window size. (%ld)", Z_LVAL(tmp));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for window size. (%pd)", Z_LVAL(tmp));
} else {
windowBits = Z_LVAL(tmp);
}
@@ -399,11 +398,11 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
ZVAL_COPY_VALUE(&tmp, filterparams);
factory_setlevel:
zval_copy_ctor(&tmp);
- convert_to_long(&tmp);
+ convert_to_int(&tmp);
/* Set compression level within reason (-1 == default, 0 == none, 1-9 == least to most compression */
if (Z_LVAL(tmp) < -1 || Z_LVAL(tmp) > 9) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid compression level specified. (%ld)", Z_LVAL(tmp));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid compression level specified. (%pd)", Z_LVAL(tmp));
} else {
level = Z_LVAL(tmp);
}
diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c
index be0ebd4382..713a6ecfb2 100644
--- a/ext/zlib/zlib_fopen_wrapper.c
+++ b/ext/zlib/zlib_fopen_wrapper.c
@@ -56,7 +56,7 @@ static size_t php_gziop_write(php_stream *stream, const char *buf, size_t count
return (wrote < 0) ? 0 : wrote;
}
-static int php_gziop_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
+static int php_gziop_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC)
{
struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *) stream->abstract;
diff --git a/main/SAPI.c b/main/SAPI.c
index f2a0b26779..acf884a842 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -269,7 +269,7 @@ SAPI_API int sapi_read_post_block(char *buffer, size_t buflen TSRMLS_DC)
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
{
if ((SG(post_max_size) > 0) && (SG(request_info).content_length > SG(post_max_size))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes",
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "POST Content-Length of %pd bytes exceeds the limit of %pd bytes",
SG(request_info).content_length, SG(post_max_size));
return;
}
@@ -290,7 +290,7 @@ SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
}
if ((SG(post_max_size) > 0) && (SG(read_post_bytes) > SG(post_max_size))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Actual POST length does not match Content-Length, and exceeds %ld bytes", SG(post_max_size));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Actual POST length does not match Content-Length, and exceeds " ZEND_LONG_FMT " bytes", SG(post_max_size));
break;
}
@@ -789,9 +789,9 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
/* Disable possible output compression for images */
if (!strncmp(ptr, "image/", sizeof("image/")-1)) {
- zend_string *key = STR_INIT("zlib.output_compression", sizeof("zlib.output_compression")-1, 0);
+ zend_string *key = zend_string_init("zlib.output_compression", sizeof("zlib.output_compression")-1, 0);
zend_alter_ini_entry(key, "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(key);
+ zend_string_release(key);
}
mimetype = estrdup(ptr);
@@ -817,10 +817,10 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
* do disable compression altogether. This contributes to making scripts
* portable between setups that have and don't have zlib compression
* enabled globally. See req #44164 */
- zend_string *key = STR_INIT("zlib.output_compression", sizeof("zlib.output_compression")-1, 0);
+ zend_string *key = zend_string_init("zlib.output_compression", sizeof("zlib.output_compression")-1, 0);
zend_alter_ini_entry(key,
"0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(key);
+ zend_string_release(key);
} else if (!STRCASECMP(header_line, "Location")) {
if ((SG(sapi_headers).http_response_code < 300 ||
SG(sapi_headers).http_response_code > 399) &&
@@ -1004,7 +1004,7 @@ SAPI_API int sapi_flush(TSRMLS_D)
}
}
-SAPI_API struct stat *sapi_get_stat(TSRMLS_D)
+SAPI_API zend_stat_t *sapi_get_stat(TSRMLS_D)
{
if (sapi_module.get_stat) {
return sapi_module.get_stat(TSRMLS_C);
diff --git a/main/SAPI.h b/main/SAPI.h
index ac3db56bad..d4bc075f84 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -31,6 +31,7 @@
#include "win32/php_stdint.h"
#endif
#include <sys/stat.h>
+#include "php.h"
#define SAPI_OPTION_NO_CHDIR 1
#define SAPI_POST_BLOCK_SIZE 0x4000
@@ -81,7 +82,7 @@ typedef struct {
const char *request_method;
char *query_string;
char *cookie_data;
- long content_length;
+ zend_long content_length;
char *path_translated;
char *request_uri;
@@ -124,11 +125,11 @@ typedef struct _sapi_globals_struct {
int64_t read_post_bytes;
unsigned char post_read;
unsigned char headers_sent;
- struct stat global_stat;
+ zend_stat_t global_stat;
char *default_mimetype;
char *default_charset;
HashTable *rfc1867_uploaded_files;
- long post_max_size;
+ zend_long post_max_size;
int options;
zend_bool sapi_started;
double global_request_time;
@@ -169,7 +170,7 @@ END_EXTERN_C()
typedef struct {
char *line; /* If you allocated this, you need to free it yourself */
uint line_len;
- long response_code; /* long due to zend_parse_parameters compatibility */
+ zend_long response_code; /* long due to zend_parse_parameters compatibility */
} sapi_header_line;
typedef enum { /* Parameter: */
@@ -200,7 +201,7 @@ SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zva
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);
SAPI_API int sapi_flush(TSRMLS_D);
-SAPI_API struct stat *sapi_get_stat(TSRMLS_D);
+SAPI_API zend_stat_t *sapi_get_stat(TSRMLS_D);
SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC);
SAPI_API char *sapi_get_default_content_type(TSRMLS_D);
@@ -227,9 +228,9 @@ struct _sapi_module_struct {
int (*activate)(TSRMLS_D);
int (*deactivate)(TSRMLS_D);
- int (*ub_write)(const char *str, unsigned int str_length TSRMLS_DC);
+ size_t (*ub_write)(const char *str, size_t str_length TSRMLS_DC);
void (*flush)(void *server_context TSRMLS_DC);
- struct stat *(*get_stat)(TSRMLS_D);
+ zend_stat_t *(*get_stat)(TSRMLS_D);
char *(*getenv)(char *name, size_t name_len TSRMLS_DC);
void (*sapi_error)(int type, const char *error_msg, ...);
@@ -238,7 +239,7 @@ struct _sapi_module_struct {
int (*send_headers)(sapi_headers_struct *sapi_headers TSRMLS_DC);
void (*send_header)(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC);
- int (*read_post)(char *buffer, uint count_bytes TSRMLS_DC);
+ size_t (*read_post)(char *buffer, size_t count_bytes TSRMLS_DC);
char *(*read_cookies)(TSRMLS_D);
void (*register_server_variables)(zval *track_vars_array TSRMLS_DC);
@@ -265,7 +266,7 @@ struct _sapi_module_struct {
int (*get_target_uid)(uid_t * TSRMLS_DC);
int (*get_target_gid)(gid_t * TSRMLS_DC);
- 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)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len TSRMLS_DC);
void (*ini_defaults)(HashTable *configuration_hash);
int phpinfo_as_text;
@@ -299,7 +300,7 @@ struct _sapi_post_entry {
#define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg TSRMLS_DC)
#define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray TSRMLS_DC)
-#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC)
+#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len TSRMLS_DC)
BEGIN_EXTERN_C()
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
diff --git a/main/main.c b/main/main.c
index 1fd314b582..66cbe2bcbd 100644
--- a/main/main.c
+++ b/main/main.c
@@ -53,6 +53,7 @@
#include <locale.h>
#endif
#include "zend.h"
+#include "zend_types.h"
#include "zend_extensions.h"
#include "php_ini.h"
#include "php_globals.h"
@@ -160,7 +161,9 @@ static php_win32_disable_functions(TSRMLS_D)
*/
static PHP_INI_MH(OnSetPrecision)
{
- int i = atoi(new_value);
+ zend_long i;
+
+ ZEND_ATOL(i, new_value);
if (i >= 0) {
EG(precision) = i;
return SUCCESS;
@@ -279,7 +282,7 @@ static void php_binary_init(TSRMLS_D)
if ((envpath = getenv("PATH")) != NULL) {
char *search_dir, search_path[MAXPATHLEN];
char *last = NULL;
- struct stat s;
+ zend_stat_t s;
path = estrdup(envpath);
search_dir = php_strtok_r(path, ":", &last);
@@ -316,11 +319,11 @@ static PHP_INI_MH(OnUpdateTimeout)
{
if (stage==PHP_INI_STAGE_STARTUP) {
/* Don't set a timeout on startup, only per-request */
- EG(timeout_seconds) = atoi(new_value);
+ ZEND_ATOL(EG(timeout_seconds), new_value);
return SUCCESS;
}
zend_unset_timeout(TSRMLS_C);
- EG(timeout_seconds) = atoi(new_value);
+ ZEND_ATOL(EG(timeout_seconds), new_value);
zend_set_timeout(EG(timeout_seconds), 0);
return SUCCESS;
}
@@ -347,7 +350,7 @@ static int php_get_display_errors_mode(char *value, int value_length)
} else if (value_length == 6 && !strcasecmp(value, "stdout")) {
mode = PHP_DISPLAY_ERRORS_STDOUT;
} else {
- mode = atoi(value);
+ ZEND_ATOL(mode, value);
if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode != PHP_DISPLAY_ERRORS_STDERR) {
mode = PHP_DISPLAY_ERRORS_STDOUT;
}
@@ -689,7 +692,7 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
#endif
php_ignore_value(write(fd, tmp, len));
efree(tmp);
- STR_FREE(error_time_str);
+ zend_string_free(error_time_str);
close(fd);
PG(in_error_log) = 0;
return;
@@ -707,7 +710,7 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
/* {{{ php_write
wrapper for modules to use PHPWRITE */
-PHPAPI int php_write(void *buf, uint size TSRMLS_DC)
+PHPAPI size_t php_write(void *buf, size_t size TSRMLS_DC)
{
return PHPWRITE(buf, size);
}
@@ -715,12 +718,12 @@ PHPAPI int php_write(void *buf, uint size TSRMLS_DC)
/* {{{ php_printf
*/
-PHPAPI int php_printf(const char *format, ...)
+PHPAPI size_t php_printf(const char *format, ...)
{
va_list args;
- int ret;
+ size_t ret;
char *buffer;
- int size;
+ size_t size;
TSRMLS_FETCH();
va_start(args, format);
@@ -891,7 +894,7 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
spprintf(&message, 0, "%s: %s", origin, buffer);
}
if (replace_origin) {
- STR_FREE(replace_origin);
+ zend_string_free(replace_origin);
} else {
efree(origin);
}
@@ -912,7 +915,7 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
}
}
if (replace_buffer) {
- STR_FREE(replace_buffer);
+ zend_string_free(replace_buffer);
} else {
efree(buffer);
}
@@ -1136,7 +1139,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
if (type == E_ERROR || type == E_PARSE) {
zend_string *buf = php_escape_html_entities(buffer, buffer_len, 0, ENT_COMPAT, NULL TSRMLS_CC);
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buf->val, error_filename, error_lineno, STR_PRINT(append_string));
- STR_FREE(buf);
+ zend_string_free(buf);
} else {
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));
}
@@ -1263,7 +1266,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
*/
PHPAPI char *php_get_current_user(TSRMLS_D)
{
- struct stat *pstat;
+ zend_stat_t *pstat;
if (SG(request_info).current_user) {
return SG(request_info).current_user;
@@ -1326,7 +1329,7 @@ PHPAPI char *php_get_current_user(TSRMLS_D)
Sets the maximum time a script can run */
PHP_FUNCTION(set_time_limit)
{
- long new_timeout;
+ zend_long new_timeout;
char *new_timeout_str;
int new_timeout_strlen;
zend_string *key;
@@ -1335,15 +1338,15 @@ PHP_FUNCTION(set_time_limit)
return;
}
- new_timeout_strlen = zend_spprintf(&new_timeout_str, 0, "%ld", new_timeout);
+ new_timeout_strlen = zend_spprintf(&new_timeout_str, 0, ZEND_LONG_FMT, new_timeout);
- key = STR_INIT("max_execution_time", sizeof("max_execution_time")-1, 0);
+ key = zend_string_init("max_execution_time", sizeof("max_execution_time")-1, 0);
if (zend_alter_ini_entry_ex(key, new_timeout_str, new_timeout_strlen, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == SUCCESS) {
RETVAL_TRUE;
} else {
RETVAL_FALSE;
}
- STR_RELEASE(key);
+ zend_string_release(key);
efree(new_timeout_str);
}
/* }}} */
@@ -1497,7 +1500,7 @@ static void php_message_handler_for_zend(long message, const void *data TSRMLS_D
if (EG(error_reporting) & E_WARNING) {
char memory_leak_buf[512];
- snprintf(memory_leak_buf, 512, "=== Total %d memory leaks detected ===\n", *((zend_uint *) data));
+ snprintf(memory_leak_buf, 512, "=== Total %d memory leaks detected ===\n", *((uint32_t *) data));
# if defined(PHP_WIN32)
OutputDebugString(memory_leak_buf);
# else
@@ -1921,7 +1924,7 @@ PHPAPI void php_com_initialize(TSRMLS_D)
/* {{{ php_output_wrapper
*/
-static int php_output_wrapper(const char *str, uint str_length)
+static size_t php_output_wrapper(const char *str, size_t str_length)
{
TSRMLS_FETCH();
return php_output_write(str, str_length TSRMLS_CC);
@@ -2209,9 +2212,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
REGISTER_MAIN_STRINGL_CONSTANT("PHP_SHLIB_SUFFIX", PHP_SHLIB_SUFFIX, sizeof(PHP_SHLIB_SUFFIX)-1, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("PHP_MAXPATHLEN", MAXPATHLEN, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", LONG_MAX, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MIN", LONG_MIN, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", sizeof(long), CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", ZEND_LONG_MAX, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MIN", ZEND_LONG_MIN, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", SIZEOF_ZEND_INT, CONST_PERSISTENT | CONST_CS);
#ifdef PHP_WIN32
REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_MAJOR", EG(windows_version_info).dwMajorVersion, CONST_PERSISTENT | CONST_CS);
@@ -2372,7 +2375,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
const char **p = directives[i].directives;
while(*p) {
- long value;
+ zend_long value;
if (cfg_get_long((char*)*p, &value) == SUCCESS && value) {
zend_error(directives[i].error_level, directives[i].phrase, *p);
@@ -2651,7 +2654,7 @@ PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC)
SG(request_info).auth_password = estrdup(pass);
ret = 0;
}
- STR_FREE(user);
+ zend_string_free(user);
}
}
diff --git a/main/network.c b/main/network.c
index 74855064d7..0b018c2e87 100644
--- a/main/network.c
+++ b/main/network.c
@@ -507,7 +507,7 @@ bound:
}
/* }}} */
-PHPAPI int php_network_parse_network_address_with_port(const char *addr, long addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC)
+PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_long addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC)
{
char *colon;
char *tmp;
@@ -563,7 +563,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, long ad
if (n == 0) {
if (errstr) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to resolve `%s': %s", tmp, errstr->val);
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
}
goto out;
}
@@ -645,10 +645,10 @@ PHPAPI void php_network_populate_name_from_sockaddr(
if (ua->sun_path[0] == '\0') {
/* abstract name */
int len = strlen(ua->sun_path + 1) + 1;
- *textaddr = STR_INIT((char*)ua->sun_path, len, 0);
+ *textaddr = zend_string_init((char*)ua->sun_path, len, 0);
} else {
int len = strlen(ua->sun_path);
- *textaddr = STR_INIT((char*)ua->sun_path, len, 0);
+ *textaddr = zend_string_init((char*)ua->sun_path, len, 0);
}
}
break;
@@ -880,7 +880,7 @@ skip_bind:
}
/* free error string received during previous iteration (if any) */
if (error_string && *error_string) {
- STR_RELEASE(*error_string);
+ zend_string_release(*error_string);
*error_string = NULL;
}
@@ -1006,6 +1006,7 @@ PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize)
buf = estrdup(errstr);
} else {
strncpy(buf, errstr, bufsize);
+ buf[bufsize?(bufsize-1):0] = 0;
}
return buf;
#else
@@ -1030,6 +1031,7 @@ PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize)
buf = estrdup(sysbuf);
} else {
strncpy(buf, sysbuf, bufsize);
+ buf[bufsize?(bufsize-1):0] = 0;
}
if (free_it) {
@@ -1048,7 +1050,7 @@ PHPAPI zend_string *php_socket_error_str(long err)
char *errstr;
errstr = strerror(err);
- return STR_INIT(errstr, strlen(errstr), 0);
+ return zend_string_init(errstr, strlen(errstr), 0);
#else
zend_string *ret;
char *sysbuf;
@@ -1068,7 +1070,7 @@ PHPAPI zend_string *php_socket_error_str(long err)
sysbuf = "Unknown Error";
}
- ret = STR_INIT(sysbuf, strlen(sysbuf), 0);
+ ret = zend_string_init(sysbuf, strlen(sysbuf), 0);
if (free_it) {
LocalFree(sysbuf);
@@ -1108,7 +1110,7 @@ PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short p
int socktype, struct timeval *timeout, const char *persistent_id STREAMS_DC TSRMLS_DC)
{
char *res;
- long reslen;
+ zend_long reslen;
php_stream *stream;
reslen = spprintf(&res, 0, "tcp://%s:%d", host, port);
diff --git a/main/output.c b/main/output.c
index 41b2c65cdf..1a6f6e5bd8 100644
--- a/main/output.c
+++ b/main/output.c
@@ -519,7 +519,7 @@ PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler,
efree(error);
}
if (handler_name) {
- STR_RELEASE(handler_name);
+ zend_string_release(handler_name);
}
}
@@ -532,11 +532,11 @@ PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler,
PHPAPI php_output_handler *php_output_handler_create_internal(const char *name, size_t name_len, php_output_handler_context_func_t output_handler, size_t chunk_size, int flags TSRMLS_DC)
{
php_output_handler *handler;
- zend_string *str = STR_INIT(name, name_len, 1);
+ zend_string *str = zend_string_init(name, name_len, 1);
handler = php_output_handler_init(str, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_INTERNAL TSRMLS_CC);
handler->func.internal = output_handler;
- STR_RELEASE(str);
+ zend_string_release(str);
return handler;
}
@@ -718,7 +718,7 @@ PHPAPI int php_output_handler_hook(php_output_handler_hook_t type, void *arg TSR
PHPAPI void php_output_handler_dtor(php_output_handler *handler TSRMLS_DC)
{
if (handler->name) {
- STR_RELEASE(handler->name);
+ zend_string_release(handler->name);
}
if (handler->buffer.data) {
efree(handler->buffer.data);
@@ -885,7 +885,7 @@ static inline php_output_handler *php_output_handler_init(zend_string *name, siz
php_output_handler *handler;
handler = ecalloc(1, sizeof(php_output_handler));
- handler->name = STR_COPY(name);
+ handler->name = zend_string_copy(name);
handler->size = chunk_size;
handler->flags = flags;
handler->buffer.size = PHP_OUTPUT_HANDLER_INITBUF_SIZE(chunk_size);
@@ -1172,7 +1172,7 @@ static int php_output_stack_apply_list(void *h, void *z)
php_output_handler *handler = *(php_output_handler **) h;
zval *array = (zval *) z;
- add_next_index_str(array, STR_COPY(handler->name));
+ add_next_index_str(array, zend_string_copy(handler->name));
return 0;
}
/* }}} */
@@ -1196,13 +1196,13 @@ static inline zval *php_output_handler_status(php_output_handler *handler, zval
ZEND_ASSERT(entry != NULL);
array_init(entry);
- add_assoc_str(entry, "name", STR_COPY(handler->name));
- add_assoc_long(entry, "type", (long) (handler->flags & 0xf));
- add_assoc_long(entry, "flags", (long) handler->flags);
- add_assoc_long(entry, "level", (long) handler->level);
- add_assoc_long(entry, "chunk_size", (long) handler->size);
- add_assoc_long(entry, "buffer_size", (long) handler->buffer.size);
- add_assoc_long(entry, "buffer_used", (long) handler->buffer.used);
+ add_assoc_str(entry, "name", zend_string_copy(handler->name));
+ add_assoc_long(entry, "type", (zend_long) (handler->flags & 0xf));
+ add_assoc_long(entry, "flags", (zend_long) handler->flags);
+ add_assoc_long(entry, "level", (zend_long) handler->level);
+ add_assoc_long(entry, "chunk_size", (zend_long) handler->size);
+ add_assoc_long(entry, "buffer_size", (zend_long) handler->buffer.size);
+ add_assoc_long(entry, "buffer_used", (zend_long) handler->buffer.used);
return entry;
}
@@ -1316,8 +1316,8 @@ static int php_output_handler_devnull_func(void **handler_context, php_output_co
PHP_FUNCTION(ob_start)
{
zval *output_handler = NULL;
- long chunk_size = 0;
- long flags = PHP_OUTPUT_HANDLER_STDFLAGS;
+ zend_long chunk_size = 0;
+ zend_long flags = PHP_OUTPUT_HANDLER_STDFLAGS;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/ll", &output_handler, &chunk_size, &flags) == FAILURE) {
return;
@@ -1539,7 +1539,7 @@ PHP_FUNCTION(ob_get_status)
Turn implicit flush on/off and is equivalent to calling flush() after every output call */
PHP_FUNCTION(ob_implicit_flush)
{
- long flag = 1;
+ zend_long flag = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) {
return;
diff --git a/main/php.h b/main/php.h
index f9cfd2d7f2..8ee83e424d 100644
--- a/main/php.h
+++ b/main/php.h
@@ -280,8 +280,8 @@ ssize_t pread(int, void *, size_t, off64_t);
BEGIN_EXTERN_C()
void phperror(char *error);
-PHPAPI int php_write(void *buf, uint size TSRMLS_DC);
-PHPAPI int php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
+PHPAPI size_t php_write(void *buf, size_t size TSRMLS_DC);
+PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
2);
PHPAPI int php_get_module_initialized(void);
PHPAPI void php_log_err(char *log_message TSRMLS_DC);
diff --git a/main/php_globals.h b/main/php_globals.h
index 9baabf757c..14d0a03868 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -56,7 +56,7 @@ typedef struct _arg_separators {
struct _php_core_globals {
zend_bool implicit_flush;
- long output_buffering;
+ zend_long output_buffering;
zend_bool sql_safe_mode;
zend_bool enable_dl;
@@ -64,16 +64,16 @@ struct _php_core_globals {
char *output_handler;
char *unserialize_callback_func;
- long serialize_precision;
+ zend_long serialize_precision;
- long memory_limit;
- long max_input_time;
+ zend_long memory_limit;
+ zend_long max_input_time;
zend_bool track_errors;
zend_bool display_errors;
zend_bool display_startup_errors;
zend_bool log_errors;
- long log_errors_max_len;
+ zend_long log_errors_max_len;
zend_bool ignore_repeated_errors;
zend_bool ignore_repeated_source;
zend_bool report_memleaks;
@@ -88,7 +88,7 @@ struct _php_core_globals {
char *sys_temp_dir;
char *upload_tmp_dir;
- long upload_max_filesize;
+ zend_long upload_max_filesize;
char *error_append_string;
char *error_prepend_string;
@@ -126,7 +126,7 @@ struct _php_core_globals {
zend_bool html_errors;
zend_bool xmlrpc_errors;
- long xmlrpc_error_number;
+ zend_long xmlrpc_error_number;
zend_bool activated_auto_globals[8];
@@ -149,12 +149,12 @@ struct _php_core_globals {
#ifdef PHP_WIN32
zend_bool com_initialized;
#endif
- long max_input_nesting_level;
- long max_input_vars;
+ zend_long max_input_nesting_level;
+ zend_long max_input_vars;
zend_bool in_user_include;
char *user_ini_filename;
- long user_ini_cache_ttl;
+ zend_long user_ini_cache_ttl;
char *request_order;
diff --git a/main/php_ini.c b/main/php_ini.c
index cdd4a61fb5..c94e412094 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -200,7 +200,7 @@ PHPAPI void config_zval_dtor(zval *zvalue)
zend_hash_destroy(Z_ARRVAL_P(zvalue));
free(Z_ARR_P(zvalue));
} else if (Z_TYPE_P(zvalue) == IS_STRING) {
- STR_RELEASE(Z_STR_P(zvalue));
+ zend_string_release(Z_STR_P(zvalue));
}
}
/* Reset / free active_ini_sectin global */
@@ -243,7 +243,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
} else {
/* Store in active hash */
entry = zend_hash_update(active_hash, Z_STR_P(arg1), arg2);
- Z_STR_P(entry) = STR_DUP(Z_STR_P(entry), 1);
+ Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1);
}
}
break;
@@ -272,7 +272,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
} else {
entry = zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2);
}
- Z_STR_P(entry) = STR_DUP(Z_STR_P(entry), 1);
+ Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1);
}
break;
@@ -545,7 +545,7 @@ int php_init_config(TSRMLS_D)
/* Check if php_ini_file_name is a file and can be opened */
if (php_ini_file_name && php_ini_file_name[0]) {
- struct stat statbuf;
+ zend_stat_t statbuf;
if (!VCWD_STAT(php_ini_file_name, &statbuf)) {
if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) {
@@ -593,7 +593,7 @@ int php_init_config(TSRMLS_D)
{
zval tmp;
- ZVAL_NEW_STR(&tmp, STR_INIT(fh.filename, strlen(fh.filename), 1));
+ ZVAL_NEW_STR(&tmp, zend_string_init(fh.filename, strlen(fh.filename), 1));
zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp);
if (php_ini_opened_path) {
efree(php_ini_opened_path);
@@ -614,7 +614,7 @@ int php_init_config(TSRMLS_D)
if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
struct dirent **namelist;
int ndir, i;
- struct stat sb;
+ zend_stat_t sb;
char ini_file[MAXPATHLEN];
char *p;
zend_file_handle fh2;
@@ -744,7 +744,7 @@ void php_ini_register_extensions(TSRMLS_D)
*/
PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash TSRMLS_DC)
{
- struct stat sb;
+ zend_stat_t sb;
char ini_file[MAXPATHLEN];
zend_file_handle fh;
@@ -778,7 +778,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int
{
zend_string *str;
zval *data;
- ulong num_index;
+ zend_ulong num_index;
/* Walk through config hash and alter matching ini entries using the values found in the hash */
for (zend_hash_internal_pointer_reset(source_hash);
@@ -875,7 +875,7 @@ PHPAPI zval *cfg_get_entry(const char *name, uint name_length)
/* {{{ cfg_get_long
*/
-PHPAPI int cfg_get_long(const char *varname, long *result)
+PHPAPI int cfg_get_long(const char *varname, zend_long *result)
{
zval *tmp, var;
@@ -884,7 +884,7 @@ PHPAPI int cfg_get_long(const char *varname, long *result)
return FAILURE;
}
ZVAL_DUP(&var, tmp);
- convert_to_long(&var);
+ convert_to_int(&var);
*result = Z_LVAL(var);
return SUCCESS;
}
diff --git a/main/php_ini.h b/main/php_ini.h
index 4159e7591f..5e6f03680a 100644
--- a/main/php_ini.h
+++ b/main/php_ini.h
@@ -29,7 +29,7 @@ int php_init_config(TSRMLS_D);
int php_shutdown_config(void);
void php_ini_register_extensions(TSRMLS_D);
PHPAPI zval *cfg_get_entry(const char *name, uint name_length);
-PHPAPI int cfg_get_long(const char *varname, long *result);
+PHPAPI int cfg_get_long(const char *varname, zend_long *result);
PHPAPI int cfg_get_double(const char *varname, double *result);
PHPAPI int cfg_get_string(const char *varname, char **result);
PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash TSRMLS_DC);
diff --git a/main/php_network.h b/main/php_network.h
index 3a0062c437..1528447c73 100644
--- a/main/php_network.h
+++ b/main/php_network.h
@@ -306,7 +306,7 @@ PHPAPI void php_network_populate_name_from_sockaddr(
TSRMLS_DC);
PHPAPI int php_network_parse_network_address_with_port(const char *addr,
- long addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC);
+ zend_long addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC);
END_EXTERN_C()
#define php_stream_sock_open_from_socket(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_CC TSRMLS_CC)
diff --git a/main/php_streams.h b/main/php_streams.h
index 38215a67b0..ad9ea92c1c 100644
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -26,6 +26,8 @@
#endif
#include <sys/types.h>
#include <sys/stat.h>
+#include "zend.h"
+#include "zend_stream.h"
BEGIN_EXTERN_C()
PHPAPI int php_file_le_stream(void);
@@ -104,7 +106,7 @@ typedef struct _php_stream_filter php_stream_filter;
#include "streams/php_stream_filter_api.h"
typedef struct _php_stream_statbuf {
- struct stat sb; /* regular info */
+ zend_stat_t sb; /* regular info */
/* extended info to go here some day: content-type etc. etc. */
} php_stream_statbuf;
@@ -123,7 +125,7 @@ typedef struct _php_stream_ops {
const char *label; /* label for this ops structure */
/* these are optional */
- int (*seek)(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
+ int (*seek)(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset TSRMLS_DC);
int (*cast)(php_stream *stream, int castas, void **ret TSRMLS_DC);
int (*stat)(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
int (*set_option)(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC);
@@ -209,11 +211,11 @@ struct _php_stream {
int flags; /* PHP_STREAM_FLAG_XXX */
/* buffer */
- off_t position; /* of underlying stream */
+ zend_off_t position; /* of underlying stream */
unsigned char *readbuf;
size_t readbuflen;
- off_t readpos;
- off_t writepos;
+ zend_off_t readpos;
+ zend_off_t writepos;
/* how much data to read when filling buffer */
size_t chunk_size;
@@ -279,11 +281,11 @@ PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC);
#define php_stream_close(stream) _php_stream_free((stream), PHP_STREAM_FREE_CLOSE TSRMLS_CC)
#define php_stream_pclose(stream) _php_stream_free((stream), PHP_STREAM_FREE_CLOSE_PERSISTENT TSRMLS_CC)
-PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC);
+PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence TSRMLS_DC);
#define php_stream_rewind(stream) _php_stream_seek((stream), 0L, SEEK_SET TSRMLS_CC)
#define php_stream_seek(stream, offset, whence) _php_stream_seek((stream), (offset), (whence) TSRMLS_CC)
-PHPAPI off_t _php_stream_tell(php_stream *stream TSRMLS_DC);
+PHPAPI zend_off_t _php_stream_tell(php_stream *stream TSRMLS_DC);
#define php_stream_tell(stream) _php_stream_tell((stream) TSRMLS_CC)
PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC);
diff --git a/main/php_variables.c b/main/php_variables.c
index 3bb6d65aa5..37af78b98d 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -43,13 +43,13 @@ PHPAPI void php_register_variable(char *var, char *strval, zval *track_vars_arra
}
/* binary-safe version */
-PHPAPI void php_register_variable_safe(char *var, char *strval, int str_len, zval *track_vars_array TSRMLS_DC)
+PHPAPI void php_register_variable_safe(char *var, char *strval, size_t str_len, zval *track_vars_array TSRMLS_DC)
{
zval new_entry;
assert(strval != NULL);
/* Prepare value */
- ZVAL_NEW_STR(&new_entry, STR_INIT(strval, str_len, 0));
+ ZVAL_NEW_STR(&new_entry, zend_string_init(strval, str_len, 0));
php_register_variable_ex(var, &new_entry, track_vars_array TSRMLS_CC);
}
@@ -141,7 +141,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
/* do not output the error message to the screen,
this helps us to to avoid "information disclosure" */
if (!PG(display_errors)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variable nesting level exceeded %ld. To increase the limit change max_input_nesting_level in php.ini.", PG(max_input_nesting_level));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variable nesting level exceeded " ZEND_LONG_FMT ". To increase the limit change max_input_nesting_level in php.ini.", PG(max_input_nesting_level));
}
free_alloca(var_orig, use_heap);
return;
@@ -246,7 +246,7 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSR
char *ksep, *vsep;
size_t klen, vlen;
/* FIXME: string-size_t */
- unsigned int new_vlen;
+ size_t new_vlen;
if (var->ptr >= var->end) {
return 0;
@@ -358,7 +358,7 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
zval array;
int free_buffer = 0;
char *strtok_buf = NULL;
- long count = 0;
+ zend_long count = 0;
ZVAL_UNDEF(&array);
switch (arg) {
@@ -442,13 +442,13 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
}
if (++count > PG(max_input_vars)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded " ZEND_LONG_FMT ". To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
break;
}
if (val) { /* have a value */
- int val_len;
- unsigned int new_val_len;
+ size_t val_len;
+ size_t new_val_len;
*val++ = '\0';
php_url_decode(var, strlen(var));
@@ -459,8 +459,8 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
}
efree(val);
} else {
- int val_len;
- unsigned int new_val_len;
+ size_t val_len;
+ size_t new_val_len;
php_url_decode(var, strlen(var));
val_len = 0;
@@ -535,7 +535,7 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
for (i = 0; i < SG(request_info).argc; i++) {
ZVAL_STRING(&tmp, SG(request_info).argv[i]);
if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) {
- STR_FREE(Z_STR(tmp));
+ zend_string_free(Z_STR(tmp));
}
}
} else if (s && *s) {
@@ -549,7 +549,7 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
ZVAL_STRING(&tmp, ss);
count++;
if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) {
- STR_FREE(Z_STR(tmp));
+ zend_string_free(Z_STR(tmp));
}
if (space) {
*space = '+';
@@ -621,7 +621,7 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC)
{
zval *src_entry, *dest_entry;
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
int globals_check = (dest == (&EG(symbol_table).ht));
ZEND_HASH_FOREACH_KEY_VAL(src, num_key, string_key, src_entry) {
@@ -816,13 +816,13 @@ static zend_bool php_auto_globals_create_request(zend_string *name TSRMLS_DC)
void php_startup_auto_globals(TSRMLS_D)
{
- zend_register_auto_global(STR_INIT("_GET", sizeof("_GET")-1, 1), 0, php_auto_globals_create_get TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_POST", sizeof("_POST")-1, 1), 0, php_auto_globals_create_post TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_COOKIE", sizeof("_COOKIE")-1, 1), 0, php_auto_globals_create_cookie TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_SERVER", sizeof("_SERVER")-1, 1), PG(auto_globals_jit), php_auto_globals_create_server TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_ENV", sizeof("_ENV")-1, 1), PG(auto_globals_jit), php_auto_globals_create_env TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_REQUEST", sizeof("_REQUEST")-1, 1), PG(auto_globals_jit), php_auto_globals_create_request TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_FILES", sizeof("_FILES")-1, 1), 0, php_auto_globals_create_files TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_GET", sizeof("_GET")-1, 1), 0, php_auto_globals_create_get TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_POST", sizeof("_POST")-1, 1), 0, php_auto_globals_create_post TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_COOKIE", sizeof("_COOKIE")-1, 1), 0, php_auto_globals_create_cookie TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_SERVER", sizeof("_SERVER")-1, 1), PG(auto_globals_jit), php_auto_globals_create_server TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_ENV", sizeof("_ENV")-1, 1), PG(auto_globals_jit), php_auto_globals_create_env TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_REQUEST", sizeof("_REQUEST")-1, 1), PG(auto_globals_jit), php_auto_globals_create_request TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_FILES", sizeof("_FILES")-1, 1), 0, php_auto_globals_create_files TSRMLS_CC);
}
/*
diff --git a/main/php_variables.h b/main/php_variables.h
index 2331c582e6..70f5e1dc7f 100644
--- a/main/php_variables.h
+++ b/main/php_variables.h
@@ -38,7 +38,7 @@ void php_startup_auto_globals(TSRMLS_D);
extern PHPAPI void (*php_import_environment_variables)(zval *array_ptr TSRMLS_DC);
PHPAPI void php_register_variable(char *var, char *val, zval *track_vars_array TSRMLS_DC);
/* binary-safe version */
-PHPAPI void php_register_variable_safe(char *var, char *val, int val_len, zval *track_vars_array TSRMLS_DC);
+PHPAPI void php_register_variable_safe(char *var, char *val, size_t val_len, zval *track_vars_array TSRMLS_DC);
PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_array TSRMLS_DC);
PHPAPI int php_hash_environment(TSRMLS_D);
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 3347a69ac8..0f2941ef98 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -58,7 +58,7 @@ static php_rfc1867_basename_t php_rfc1867_basename = NULL;
PHPAPI int (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra TSRMLS_DC) = NULL;
-static void safe_php_register_variable(char *var, char *strval, int val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC);
+static void safe_php_register_variable(char *var, char *strval, size_t val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC);
/* The longest property name we use in an uploaded file array */
#define MAX_SIZE_OF_INDEX sizeof("[tmp_name]")
@@ -161,7 +161,7 @@ static zend_bool is_protected_variable(char *varname TSRMLS_DC) /* {{{ */
}
/* }}} */
-static void safe_php_register_variable(char *var, char *strval, int val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC) /* {{{ */
+static void safe_php_register_variable(char *var, char *strval, size_t val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC) /* {{{ */
{
if (override_protection || !is_protected_variable(var TSRMLS_CC)) {
php_register_variable_safe(var, strval, val_len, track_vars_array TSRMLS_CC);
@@ -611,9 +611,9 @@ static void *php_ap_memstr(char *haystack, int haystacklen, char *needle, int ne
}
/* read until a boundary condition */
-static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes, int *end TSRMLS_DC)
+static int multipart_buffer_read(multipart_buffer *self, char *buf, size_t bytes, int *end TSRMLS_DC)
{
- int len, max;
+ size_t len, max;
char *bound;
/* fill buffer if needed */
@@ -657,7 +657,7 @@ static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes, i
XXX: this is horrible memory-usage-wise, but we only expect
to do this on small pieces of form data.
*/
-static char *multipart_buffer_read_body(multipart_buffer *self, unsigned int *len TSRMLS_DC)
+static char *multipart_buffer_read_body(multipart_buffer *self, size_t *len TSRMLS_DC)
{
char buf[FILLUNIT], *out=NULL;
int total_bytes=0, read_bytes=0;
@@ -701,7 +701,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
php_rfc1867_getword_t getword;
php_rfc1867_getword_conf_t getword_conf;
php_rfc1867_basename_t _basename;
- long count = 0;
+ zend_long count = 0;
if (php_rfc1867_encoding_translation(TSRMLS_C) && internal_encoding) {
getword = php_rfc1867_getword;
@@ -714,7 +714,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
}
if (SG(post_max_size) > 0 && SG(request_info).content_length > SG(post_max_size)) {
- sapi_module.sapi_error(E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes", SG(request_info).content_length, SG(post_max_size));
+ sapi_module.sapi_error(E_WARNING, "POST Content-Length of " ZEND_LONG_FMT " bytes exceeds the limit of " ZEND_LONG_FMT " bytes", SG(request_info).content_length, SG(post_max_size));
return;
}
@@ -787,7 +787,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
char buff[FILLUNIT];
char *cd = NULL, *param = NULL, *filename = NULL, *tmp = NULL;
size_t blen = 0, wlen = 0;
- off_t offset;
+ zend_off_t offset;
zend_llist_clean(&header);
@@ -850,9 +850,9 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
/* Normal form variable, safe to read all data into memory */
if (!filename && param) {
- unsigned int value_len;
+ size_t value_len;
char *value = multipart_buffer_read_body(mbuff, &value_len TSRMLS_CC);
- unsigned int new_val_len; /* Dummy variable */
+ size_t new_val_len; /* Dummy variable */
if (!value) {
value = estrdup("");
@@ -889,7 +889,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
safe_php_register_variable(param, value, new_val_len, array_ptr, 0 TSRMLS_CC);
} else {
if (count == PG(max_input_vars) + 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded " ZEND_LONG_FMT ". To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
}
if (php_rfc1867_callback != NULL) {
@@ -1034,14 +1034,14 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
}
}
- if (PG(upload_max_filesize) > 0 && (long)(total_bytes+blen) > PG(upload_max_filesize)) {
+ if (PG(upload_max_filesize) > 0 && (zend_long)(total_bytes+blen) > PG(upload_max_filesize)) {
#if DEBUG_FILE_UPLOAD
- sapi_module.sapi_error(E_NOTICE, "upload_max_filesize of %ld bytes exceeded - file [%s=%s] not saved", PG(upload_max_filesize), param, filename);
+ sapi_module.sapi_error(E_NOTICE, "upload_max_filesize of " ZEND_LONG_FMT " bytes exceeded - file [%s=%s] not saved", PG(upload_max_filesize), param, filename);
#endif
cancel_upload = UPLOAD_ERROR_A;
- } else if (max_file_size && ((long)(total_bytes+blen) > max_file_size)) {
+ } else if (max_file_size && ((zend_long)(total_bytes+blen) > max_file_size)) {
#if DEBUG_FILE_UPLOAD
- sapi_module.sapi_error(E_NOTICE, "MAX_FILE_SIZE of %ld bytes exceeded - file [%s=%s] not saved", max_file_size, param, filename);
+ sapi_module.sapi_error(E_NOTICE, "MAX_FILE_SIZE of " ZEND_LONG_FMT " bytes exceeded - file [%s=%s] not saved", max_file_size, param, filename);
#endif
cancel_upload = UPLOAD_ERROR_B;
} else if (blen > 0) {
@@ -1230,7 +1230,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
if (cancel_upload) {
ZVAL_LONG(&file_size, 0);
} else {
- if (total_bytes > LONG_MAX) {
+ if (total_bytes > ZEND_LONG_MAX) {
#ifdef PHP_WIN32
if (_i64toa_s(total_bytes, file_size_buf, 65, 10)) {
file_size_buf[0] = '0';
diff --git a/main/rfc1867.h b/main/rfc1867.h
index 1d47165851..b76e3598f5 100644
--- a/main/rfc1867.h
+++ b/main/rfc1867.h
@@ -51,7 +51,7 @@ typedef struct _multipart_event_file_start {
typedef struct _multipart_event_file_data {
size_t post_bytes_processed;
- off_t offset;
+ zend_off_t offset;
char *data;
size_t length;
size_t *newlength;
diff --git a/main/snprintf.c b/main/snprintf.c
index 914cac7133..0675538ac5 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -312,7 +312,7 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
*/
/* char * ap_php_conv_10() {{{ */
char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
- register bool_int * is_negative, char *buf_end, register int *len)
+ register bool_int * is_negative, char *buf_end, register size_t *len)
{
register char *p = buf_end;
register u_wide_int magnitude;
@@ -370,7 +370,7 @@ char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
*/
/* PHPAPI char * php_conv_fp() {{{ */
PHPAPI char * php_conv_fp(register char format, register double num,
- boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, int *len)
+ boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, size_t *len)
{
register char *s = buf;
register char *p, *p_orig;
@@ -438,7 +438,7 @@ PHPAPI char * php_conv_fp(register char format, register double num,
if (format != 'F') {
char temp[EXPONENT_LENGTH]; /* for exponent conversion */
- int t_len;
+ size_t t_len;
bool_int exponent_is_negative;
*s++ = format; /* either e or E */
@@ -474,7 +474,7 @@ PHPAPI char * php_conv_fp(register char format, register double num,
* which is a pointer to the END of the buffer + 1 (i.e. if the buffer
* is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
*/
-char * ap_php_conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register int *len) /* {{{ */
+char * ap_php_conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register size_t *len) /* {{{ */
{
register int mask = (1 << nbits) - 1;
register char *p = buf_end;
@@ -584,10 +584,11 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
char *sp;
char *bep;
int cc = 0;
- int i;
+ size_t i;
char *s = NULL;
- int s_len, free_zcopy;
+ size_t s_len;
+ int free_zcopy;
zval *zvp, zcopy;
int min_width = 0;
@@ -758,6 +759,10 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
modifier = LM_SIZE_T;
#endif
break;
+ case 'p':
+ fmt++;
+ modifier = LM_PHP_INT_T;
+ break;
case 'h':
fmt++;
if (*fmt == 'h') {
@@ -823,6 +828,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ i_num = (wide_int) va_arg(ap, zend_ulong);
+ break;
}
/*
* The rest also applies to other integer formats, so fall
@@ -865,6 +873,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ i_num = (wide_int) va_arg(ap, zend_long);
+ break;
}
}
s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative,
@@ -911,6 +922,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ ui_num = (u_wide_int) va_arg(ap, zend_ulong);
+ break;
}
s = ap_php_conv_p2(ui_num, 3, *fmt, &num_buf[NUM_BUF_SIZE], &s_len);
FIX_PRECISION(adjust_precision, precision, s, s_len);
@@ -950,6 +964,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ ui_num = (u_wide_int) va_arg(ap, zend_ulong);
+ break;
}
s = ap_php_conv_p2(ui_num, 4, *fmt, &num_buf[NUM_BUF_SIZE], &s_len);
FIX_PRECISION(adjust_precision, precision, s, s_len);
diff --git a/main/snprintf.h b/main/snprintf.h
index 10f0e24fa5..6cef41f3f4 100644
--- a/main/snprintf.h
+++ b/main/snprintf.h
@@ -87,7 +87,7 @@ PHPAPI int ap_php_asprintf(char **buf, const char *format, ...);
PHPAPI int php_sprintf (char* s, const char* format, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3);
PHPAPI char * php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf);
PHPAPI char * php_conv_fp(register char format, register double num,
- boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, int *len);
+ boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, size_t *len);
END_EXTERN_C()
@@ -137,7 +137,8 @@ typedef enum {
#endif
LM_SIZE_T,
LM_LONG,
- LM_LONG_DOUBLE
+ LM_LONG_DOUBLE,
+ LM_PHP_INT_T
} length_modifier_e;
#ifdef PHP_WIN32
@@ -153,10 +154,10 @@ typedef WIDE_INT wide_int;
typedef unsigned WIDE_INT u_wide_int;
extern char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
- register bool_int * is_negative, char *buf_end, register int *len);
+ register bool_int * is_negative, char *buf_end, register size_t *len);
extern char * ap_php_conv_p2(register u_wide_int num, register int nbits,
- char format, char *buf_end, register int *len);
+ char format, char *buf_end, register size_t *len);
/* The maximum precision that's allowed for float conversion. Does not include
* decimal separator, exponent, sign, terminator. Currently does not affect
diff --git a/main/spprintf.c b/main/spprintf.c
index 079089c0fc..67ab15dce5 100644
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@ -198,7 +198,8 @@ static size_t strnlen(const char *s, size_t maxlen) {
static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt, va_list ap) /* {{{ */
{
char *s = NULL;
- int s_len, free_zcopy;
+ size_t s_len;
+ int free_zcopy;
zval *zvp, zcopy;
int min_width = 0;
@@ -366,6 +367,16 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
modifier = LM_SIZE_T;
#endif
break;
+ case 'p': {
+ char __next = *(fmt+1);
+ if ('d' == __next || 'u' == __next || 'x' == __next || 'o' == __next) {
+ fmt++;
+ modifier = LM_PHP_INT_T;
+ } else {
+ modifier = LM_STD;
+ }
+ }
+ break;
case 'h':
fmt++;
if (*fmt == 'h') {
@@ -431,6 +442,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ i_num = (wide_int) va_arg(ap, zend_ulong);
+ break;
}
/*
* The rest also applies to other integer formats, so fall
@@ -473,6 +487,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ i_num = (wide_int) va_arg(ap, zend_long);
+ break;
}
}
s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative,
@@ -518,6 +535,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ ui_num = (u_wide_int) va_arg(ap, zend_ulong);
+ break;
}
s = ap_php_conv_p2(ui_num, 3, *fmt,
&num_buf[NUM_BUF_SIZE], &s_len);
@@ -558,6 +578,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ ui_num = (u_wide_int) va_arg(ap, zend_ulong);
+ break;
}
s = ap_php_conv_p2(ui_num, 4, *fmt,
&num_buf[NUM_BUF_SIZE], &s_len);
@@ -796,10 +819,10 @@ skip_output:
/*
* This is the general purpose conversion function.
*/
-PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */
+PHPAPI size_t vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */
{
smart_string buf = {0};
- int result;
+ size_t result;
xbuf_format_converter(&buf, 1, format, ap);
@@ -821,9 +844,9 @@ PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap
}
/* }}} */
-PHPAPI int spprintf(char **pbuf, size_t max_len, const char *format, ...) /* {{{ */
+PHPAPI size_t spprintf(char **pbuf, size_t max_len, const char *format, ...) /* {{{ */
{
- int cc;
+ size_t cc;
va_list ap;
va_start(ap, format);
diff --git a/main/spprintf.h b/main/spprintf.h
index ae26a3b9ec..1e4782843f 100644
--- a/main/spprintf.h
+++ b/main/spprintf.h
@@ -37,9 +37,9 @@ There is also snprintf: See difference explained in snprintf.h
#include "snprintf.h"
BEGIN_EXTERN_C()
-PHPAPI int spprintf( char **pbuf, size_t max_len, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
+PHPAPI size_t spprintf( char **pbuf, size_t max_len, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
-PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0);
+PHPAPI size_t vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0);
PHPAPI zend_string *vstrpprintf(size_t max_len, const char *format, va_list ap);
diff --git a/main/streams/cast.c b/main/streams/cast.c
index 78073c6187..cb4f081655 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -76,7 +76,7 @@ static int stream_cookie_writer(void *cookie, const char *buffer, int size)
return php_stream_write((php_stream *)cookie, (char *)buffer, size);
}
-static PHP_FPOS_T stream_cookie_seeker(void *cookie, off_t position, int whence)
+static PHP_FPOS_T stream_cookie_seeker(void *cookie, zend_off_t position, int whence)
{
TSRMLS_FETCH();
@@ -114,7 +114,7 @@ static int stream_cookie_seeker(void *cookie, __off64_t *position, int whence)
{
TSRMLS_FETCH();
- *position = php_stream_seek((php_stream *)cookie, (off_t)*position, whence);
+ *position = php_stream_seek((php_stream *)cookie, (zend_off_t)*position, whence);
if (*position == -1) {
return -1;
@@ -122,7 +122,7 @@ static int stream_cookie_seeker(void *cookie, __off64_t *position, int whence)
return 0;
}
# else
-static int stream_cookie_seeker(void *cookie, off_t position, int whence)
+static int stream_cookie_seeker(void *cookie, zend_off_t position, int whence)
{
TSRMLS_FETCH();
@@ -206,7 +206,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
if (ret && castas != PHP_STREAM_AS_FD_FOR_SELECT) {
php_stream_flush(stream);
if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) {
- off_t dummy;
+ zend_off_t dummy;
stream->ops->seek(stream, stream->position, SEEK_SET, &dummy TSRMLS_CC);
stream->readpos = stream->writepos = 0;
@@ -246,7 +246,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
}
if (*ret != NULL) {
- off_t pos;
+ zend_off_t pos;
stream->fclose_stdiocast = PHP_STREAM_FCLOSE_FOPENCOOKIE;
@@ -254,7 +254,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
* the stdio layer to believe it's real location. */
pos = php_stream_tell(stream);
if (pos > 0) {
- fseek(*ret, pos, SEEK_SET);
+ zend_fseek(*ret, pos, SEEK_SET);
}
goto exit_success;
@@ -334,7 +334,7 @@ exit_success:
* will be accessing the stream. Emit a warning so that the end-user will
* know that they should try something else */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld bytes of buffered data lost during stream conversion!", (long)(stream->writepos - stream->readpos));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, ZEND_LONG_FMT " bytes of buffered data lost during stream conversion!", (zend_long)(stream->writepos - stream->readpos));
}
if (castas == PHP_STREAM_AS_STDIO && ret) {
diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c
index 5a48584f4e..ceb60d5b07 100644
--- a/main/streams/glob_wrapper.c
+++ b/main/streams/glob_wrapper.c
@@ -180,7 +180,7 @@ static int php_glob_stream_close(php_stream *stream, int close_handle TSRMLS_DC)
}
/* {{{ */
-static int php_glob_stream_rewind(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC) /* {{{ */
+static int php_glob_stream_rewind(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC) /* {{{ */
{
glob_s_t *pglob = (glob_s_t *)stream->abstract;
diff --git a/main/streams/memory.c b/main/streams/memory.c
index 5da0c8decd..f08c192581 100644
--- a/main/streams/memory.c
+++ b/main/streams/memory.c
@@ -127,7 +127,7 @@ static int php_stream_memory_flush(php_stream *stream TSRMLS_DC)
/* {{{ */
-static int php_stream_memory_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
+static int php_stream_memory_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC)
{
php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;
assert(ms != NULL);
@@ -442,7 +442,7 @@ static int php_stream_temp_flush(php_stream *stream TSRMLS_DC)
/* {{{ */
-static int php_stream_temp_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
+static int php_stream_temp_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC)
{
php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;
int ret;
@@ -468,7 +468,7 @@ static int php_stream_temp_cast(php_stream *stream, int castas, void **ret TSRML
php_stream *file;
size_t memsize;
char *membuf;
- off_t pos;
+ zend_off_t pos;
assert(ts != NULL);
@@ -584,7 +584,7 @@ PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char
{
php_stream *stream;
php_stream_temp_data *ts;
- off_t newoffs;
+ zend_off_t newoffs;
if ((stream = php_stream_temp_create_rel(mode, max_memory_usage)) != NULL) {
if (length) {
@@ -618,7 +618,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con
php_stream_temp_data *ts;
char *comma, *semi, *sep, *key;
size_t mlen, dlen, plen, vlen;
- off_t newoffs;
+ zend_off_t newoffs;
zval meta;
int base64 = 0, ilen;
zend_string *base64_comma = NULL;
@@ -741,7 +741,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con
ZVAL_COPY_VALUE(&ts->meta, &meta);
}
if (base64_comma) {
- STR_FREE(base64_comma);
+ zend_string_free(base64_comma);
} else {
efree(comma);
}
diff --git a/main/streams/mmap.c b/main/streams/mmap.c
index 050e95f285..a99c8994aa 100644
--- a/main/streams/mmap.c
+++ b/main/streams/mmap.c
@@ -51,7 +51,7 @@ PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC)
return php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_UNMAP, NULL) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0;
}
-PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, off_t readden TSRMLS_DC)
+PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, zend_off_t readden TSRMLS_DC)
{
int ret = 1;
diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h
index b3570be48c..5d200d729a 100644
--- a/main/streams/php_stream_mmap.h
+++ b/main/streams/php_stream_mmap.h
@@ -74,7 +74,7 @@ PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t le
PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC);
#define php_stream_mmap_unmap(stream) _php_stream_mmap_unmap((stream) TSRMLS_CC)
-PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, off_t readden TSRMLS_DC);
+PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, zend_off_t readden TSRMLS_DC);
#define php_stream_mmap_unmap_ex(stream, readden) _php_stream_mmap_unmap_ex((stream), (readden) TSRMLS_CC)
END_EXTERN_C()
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 87312b9ef8..36b56645c2 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -53,6 +53,12 @@ extern int php_get_uid_by_name(const char *name, uid_t *uid TSRMLS_DC);
extern int php_get_gid_by_name(const char *name, gid_t *gid TSRMLS_DC);
#endif
+#if defined(PHP_WIN32)
+# define PLAIN_WRAP_BUF_SIZE(st) (((st) > UINT_MAX) ? UINT_MAX : (unsigned int)(st))
+#else
+# define PLAIN_WRAP_BUF_SIZE(st) (st)
+#endif
+
/* parse standard "fopen" modes into open() flags */
PHPAPI int php_stream_parse_fopen_modes(const char *mode, int *open_flags)
{
@@ -132,7 +138,7 @@ typedef struct {
HANDLE file_mapping;
#endif
- struct stat sb;
+ zend_stat_t sb;
} php_stdio_stream_data;
#define PHP_STDIOP_GET_FD(anfd, data) anfd = (data)->file ? fileno((data)->file) : (data)->fd
@@ -143,7 +149,7 @@ static int do_fstat(php_stdio_stream_data *d, int force)
int r;
PHP_STDIOP_GET_FD(fd, d);
- r = fstat(fd, &d->sb);
+ r = zend_fstat(fd, &d->sb);
d->cached_fstat = r == 0;
return r;
@@ -246,9 +252,9 @@ PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const cha
if (self->is_pipe) {
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
} else {
- stream->position = lseek(self->fd, 0, SEEK_CUR);
+ stream->position = zend_lseek(self->fd, 0, SEEK_CUR);
#ifdef ESPIPE
- if (stream->position == (off_t)-1 && errno == ESPIPE) {
+ if (stream->position == (zend_off_t)-1 && errno == ESPIPE) {
stream->position = 0;
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
self->is_pipe = 1;
@@ -285,7 +291,7 @@ PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STRE
if (self->is_pipe) {
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
} else {
- stream->position = ftell(file);
+ stream->position = zend_ftell(file);
}
}
@@ -342,13 +348,13 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS
assert(data != NULL);
if (data->fd >= 0) {
- ret = read(data->fd, buf, count);
+ ret = read(data->fd, buf, PLAIN_WRAP_BUF_SIZE(count));
if (ret == (size_t)-1 && errno == EINTR) {
/* Read was interrupted, retry once,
If read still fails, giveup with feof==0
so script can retry if desired */
- ret = read(data->fd, buf, count);
+ ret = read(data->fd, buf, PLAIN_WRAP_BUF_SIZE(count));
}
stream->eof = (ret == 0 || (ret == (size_t)-1 && errno != EWOULDBLOCK && errno != EINTR && errno != EBADF));
@@ -356,7 +362,7 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS
} else {
#if HAVE_FLUSHIO
if (!data->is_pipe && data->last_op == 'w')
- fseek(data->file, 0, SEEK_CUR);
+ zend_fseek(data->file, 0, SEEK_CUR);
data->last_op = 'r';
#endif
@@ -445,7 +451,7 @@ static int php_stdiop_flush(php_stream *stream TSRMLS_DC)
return 0;
}
-static int php_stdiop_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC)
+static int php_stdiop_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset TSRMLS_DC)
{
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
int ret;
@@ -458,18 +464,18 @@ static int php_stdiop_seek(php_stream *stream, off_t offset, int whence, off_t *
}
if (data->fd >= 0) {
- off_t result;
+ zend_off_t result;
- result = lseek(data->fd, offset, whence);
- if (result == (off_t)-1)
+ result = zend_lseek(data->fd, offset, whence);
+ if (result == (zend_off_t)-1)
return -1;
*newoffset = result;
return 0;
} else {
- ret = fseek(data->file, offset, whence);
- *newoffset = ftell(data->file);
+ ret = zend_fseek(data->file, offset, whence);
+ *newoffset = zend_ftell(data->file);
return ret;
}
}
@@ -831,7 +837,7 @@ static int php_plain_files_dirstream_close(php_stream *stream, int close_handle
return closedir((DIR *)stream->abstract);
}
-static int php_plain_files_dirstream_rewind(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
+static int php_plain_files_dirstream_rewind(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC)
{
rewinddir((DIR *)stream->abstract);
return 0;
@@ -1096,7 +1102,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
#ifndef PHP_WIN32
# ifdef EXDEV
if (errno == EXDEV) {
- struct stat sb;
+ zend_stat_t sb;
if (php_copy_file(url_from, url_to TSRMLS_CC) == SUCCESS) {
if (VCWD_STAT(url_from, &sb) == 0) {
# if !defined(TSRM_WIN32) && !defined(NETWARE)
@@ -1159,7 +1165,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
} else {
/* we look for directory separator from the end of string, thus hopefuly reducing our work load */
char *e;
- struct stat sb;
+ zend_stat_t sb;
int dir_len = strlen(dir);
int offset = 0;
char buf[MAXPATHLEN];
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 89537bdaeb..88b6aeada1 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -675,7 +675,7 @@ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_D
} else {
/* is there enough data in the buffer ? */
- if (stream->writepos - stream->readpos < (off_t)size) {
+ if (stream->writepos - stream->readpos < (zend_off_t)size) {
size_t justread = 0;
/* reduce buffer memory consumption if possible, to avoid a realloc */
@@ -1101,7 +1101,7 @@ PHPAPI zend_string *php_stream_get_record(php_stream *stream, size_t maxlen, con
}
}
- ret_buf = STR_ALLOC(tent_ret_len, 0);
+ ret_buf = zend_string_alloc(tent_ret_len, 0);
/* php_stream_read will not call ops->read here because the necessary
* data is guaranteedly buffered */
ret_buf->len = php_stream_read(stream, ret_buf->val, tent_ret_len);
@@ -1269,12 +1269,12 @@ PHPAPI size_t _php_stream_printf(php_stream *stream TSRMLS_DC, const char *fmt,
return count;
}
-PHPAPI off_t _php_stream_tell(php_stream *stream TSRMLS_DC)
+PHPAPI zend_off_t _php_stream_tell(php_stream *stream TSRMLS_DC)
{
return stream->position;
}
-PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC)
+PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence TSRMLS_DC)
{
if (stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FOPENCOOKIE) {
/* flush to commit data written to the fopencookie FILE* */
@@ -1445,7 +1445,7 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
}
if (maxlen > 0) {
- result = STR_ALLOC(maxlen, persistent);
+ result = zend_string_alloc(maxlen, persistent);
ptr = result->val;
while ((len < maxlen) && !php_stream_eof(src)) {
ret = php_stream_read(src, ptr, maxlen - len);
@@ -1459,7 +1459,7 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
*ptr = '\0';
result->len = len;
} else {
- STR_FREE(result);
+ zend_string_free(result);
result = NULL;
}
return result;
@@ -1477,13 +1477,13 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
max_len = step;
}
- result = STR_ALLOC(max_len, persistent);
+ result = zend_string_alloc(max_len, persistent);
ptr = result->val;
while ((ret = php_stream_read(src, ptr, max_len - len))) {
len += ret;
if (len + min_room >= max_len) {
- result = STR_REALLOC(result, max_len + step, persistent);
+ result = zend_string_realloc(result, max_len + step, persistent);
max_len += step;
ptr = result->val + len;
} else {
@@ -1491,10 +1491,10 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
}
}
if (len) {
- result = STR_REALLOC(result, len, persistent);
+ result = zend_string_realloc(result, len, persistent);
result->val[len] = '\0';
} else {
- STR_FREE(result);
+ zend_string_free(result);
result = NULL;
}
@@ -2136,7 +2136,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
}
if (stream && stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0 && strchr(mode, 'a') && stream->position == 0) {
- off_t newpos = 0;
+ zend_off_t newpos = 0;
/* if opened for append, we need to revise our idea of the initial file position */
if (0 == stream->ops->seek(stream, 0, SEEK_CUR, &newpos TSRMLS_CC)) {
@@ -2310,7 +2310,7 @@ PHPAPI int _php_stream_scandir(const char *dirname, zend_string **namelist[], in
vector = (zend_string **) safe_erealloc(vector, vector_size, sizeof(char *), 0);
}
- vector[nfiles] = STR_INIT(sdp.d_name, strlen(sdp.d_name), 0);
+ vector[nfiles] = zend_string_init(sdp.d_name, strlen(sdp.d_name), 0);
nfiles++;
if(vector_size < 10 || nfiles == 0) {
diff --git a/main/streams/transports.c b/main/streams/transports.c
index 7792e24fef..a0c8d61aa6 100644
--- a/main/streams/transports.c
+++ b/main/streams/transports.c
@@ -46,7 +46,7 @@ PHPAPI int php_stream_xport_unregister(const char *protocol TSRMLS_DC)
#define ERR_RETURN(out_err, local_err, fmt) \
if (out_err) { *out_err = local_err; } \
else { php_error_docref(NULL TSRMLS_CC, E_WARNING, fmt, local_err ? local_err->val : "Unspecified error"); \
- if (local_err) { STR_RELEASE(local_err); local_err = NULL; } \
+ if (local_err) { zend_string_release(local_err); local_err = NULL; } \
}
PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, int options,
@@ -163,7 +163,7 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, in
if (PHP_STREAM_CONTEXT(stream) && (zbacklog = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "backlog")) != NULL) {
zval *ztmp = zbacklog;
- convert_to_long_ex(ztmp);
+ convert_to_int_ex(ztmp);
backlog = Z_LVAL_P(ztmp);
if (ztmp != zbacklog) {
zval_ptr_dtor(ztmp);
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index c41826155c..26a956c362 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -490,7 +490,7 @@ PHP_FUNCTION(stream_wrapper_register)
zend_string *protocol, *classname;
struct php_user_stream_wrapper * uwrap;
zend_resource *rsrc;
- long flags = 0;
+ zend_long flags = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|l", &protocol, &classname, &flags) == FAILURE) {
RETURN_FALSE;
@@ -608,7 +608,7 @@ static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t
didwrite = 0;
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
- convert_to_long(&retval);
+ convert_to_int(&retval);
didwrite = Z_LVAL(retval);
} else if (call_result == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_WRITE " is not implemented!",
@@ -617,9 +617,9 @@ static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t
/* don't allow strange buffer overruns due to bogus return */
if (didwrite > count) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_WRITE " wrote %ld bytes more data than requested (%ld written, %ld max)",
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_WRITE " wrote " ZEND_LONG_FMT " bytes more data than requested (" ZEND_LONG_FMT " written, " ZEND_LONG_FMT " max)",
us->wrapper->classname,
- (long)(didwrite - count), (long)didwrite, (long)count);
+ (zend_long)(didwrite - count), (zend_long)didwrite, (zend_long)count);
didwrite = count;
}
@@ -654,8 +654,8 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
convert_to_string(&retval);
didread = Z_STRLEN(retval);
if (didread > count) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_READ " - read %ld bytes more data than requested (%ld read, %ld max) - excess data will be lost",
- us->wrapper->classname, (long)(didread - count), (long)didread, (long)count);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_READ " - read " ZEND_LONG_FMT " bytes more data than requested (" ZEND_LONG_FMT " read, " ZEND_LONG_FMT " max) - excess data will be lost",
+ us->wrapper->classname, (zend_long)(didread - count), (zend_long)didread, (zend_long)count);
didread = count;
}
if (didread > 0)
@@ -831,7 +831,7 @@ static int statbuf_from_array(zval *array, php_stream_statbuf *ssb TSRMLS_DC)
#define STAT_PROP_ENTRY_EX(name, name2) \
if (NULL != (elem = zend_hash_str_find(Z_ARRVAL_P(array), #name, sizeof(#name)-1))) { \
SEPARATE_ZVAL(elem); \
- convert_to_long(elem); \
+ convert_to_int(elem); \
ssb->sb.st_##name2 = Z_LVAL_P(elem); \
}
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index dad78beb13..12111511d6 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -39,6 +39,13 @@
# define MSG_PEEK 0
#endif
+#ifdef PHP_WIN32
+/* send/recv family on windows expects int */
+# define XP_SOCK_BUF_SIZE(sz) (((sz) > INT_MAX) ? INT_MAX : (int)(sz))
+#else
+# define XP_SOCK_BUF_SIZE(sz) (sz)
+#endif
+
php_stream_ops php_stream_generic_socket_ops;
PHPAPI php_stream_ops php_stream_socket_ops;
php_stream_ops php_stream_udp_socket_ops;
@@ -67,7 +74,7 @@ static size_t php_sockop_write(php_stream *stream, const char *buf, size_t count
ptimeout = &sock->timeout;
retry:
- didwrite = send(sock->socket, buf, count, (sock->is_blocked && ptimeout) ? MSG_DONTWAIT : 0);
+ didwrite = send(sock->socket, buf, XP_SOCK_BUF_SIZE(count), (sock->is_blocked && ptimeout) ? MSG_DONTWAIT : 0);
if (didwrite <= 0) {
long err = php_socket_errno();
@@ -95,8 +102,8 @@ retry:
} while (err == EINTR);
}
estr = php_socket_strerror(err, NULL, 0);
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "send of %ld bytes failed with errno=%ld %s",
- (long)count, err, estr);
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "send of " ZEND_LONG_FMT " bytes failed with errno=%ld %s",
+ (zend_long)count, err, estr);
efree(estr);
}
@@ -144,7 +151,7 @@ static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data
static size_t php_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
{
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
- int nr_bytes = 0;
+ ssize_t nr_bytes = 0;
if (!sock || sock->socket == -1) {
return 0;
@@ -156,7 +163,7 @@ static size_t php_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS
return 0;
}
- nr_bytes = recv(sock->socket, buf, count, (sock->is_blocked && sock->timeout.tv_sec != -1) ? MSG_DONTWAIT : 0);
+ nr_bytes = recv(sock->socket, buf, XP_SOCK_BUF_SIZE(count), (sock->is_blocked && sock->timeout.tv_sec != -1) ? MSG_DONTWAIT : 0);
stream->eof = (nr_bytes == 0 || (nr_bytes == -1 && php_socket_errno() != EWOULDBLOCK));
@@ -230,7 +237,7 @@ static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC
#if ZEND_WIN32
return 0;
#else
- return fstat(sock->socket, &ssb->sb);
+ return zend_fstat(sock->socket, &ssb->sb);
#endif
}
@@ -240,7 +247,8 @@ static inline int sock_sendto(php_netstream_data_t *sock, const char *buf, size_
{
int ret;
if (addr) {
- ret = sendto(sock->socket, buf, buflen, flags, addr, addrlen);
+ ret = sendto(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags, addr, XP_SOCK_BUF_SIZE(addrlen));
+
return (ret == SOCK_CONN_ERR) ? -1 : ret;
}
return ((ret = send(sock->socket, buf, buflen, flags)) == SOCK_CONN_ERR) ? -1 : ret;
@@ -257,12 +265,12 @@ static inline int sock_recvfrom(php_netstream_data_t *sock, char *buf, size_t bu
int want_addr = textaddr || addr;
if (want_addr) {
- ret = recvfrom(sock->socket, buf, buflen, flags, (struct sockaddr*)&sa, &sl);
+ ret = recvfrom(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags, (struct sockaddr*)&sa, &sl);
ret = (ret == SOCK_CONN_ERR) ? -1 : ret;
php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, sl,
textaddr, addr, addrlen TSRMLS_CC);
} else {
- ret = recv(sock->socket, buf, buflen, flags);
+ ret = recv(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags);
ret = (ret == SOCK_CONN_ERR) ? -1 : ret;
}
diff --git a/sapi/apache2handler/php_apache.h b/sapi/apache2handler/php_apache.h
index 34846048b0..f1033c9539 100644
--- a/sapi/apache2handler/php_apache.h
+++ b/sapi/apache2handler/php_apache.h
@@ -25,6 +25,9 @@
#include "http_config.h"
#include "http_core.h"
+#include "php.h"
+#include "main/php_streams.h"
+
/* Declare this so we can get to it from outside the sapi_apache2.c file */
extern module AP_MODULE_DECLARE_DATA php5_module;
@@ -40,7 +43,7 @@ typedef struct php_struct {
#if defined(NETWARE) && defined(CLIB_STAT_PATCH)
struct stat_libc finfo;
#else
- struct stat finfo;
+ zend_stat_t finfo;
#endif
/* Whether or not we've processed PHP in the output filters yet. */
int request_processed;
diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c
index ebcc3e9bc9..d39a25a74e 100644
--- a/sapi/apache2handler/sapi_apache2.c
+++ b/sapi/apache2handler/sapi_apache2.c
@@ -72,8 +72,8 @@
/* A way to specify the location of the php.ini dir in an apache directive */
char *apache2_php_ini_path_override = NULL;
-static int
-php_apache_sapi_ub_write(const char *str, uint str_length TSRMLS_DC)
+static size_t
+php_apache_sapi_ub_write(const char *str, size_t str_length TSRMLS_DC)
{
request_rec *r;
php_struct *ctx;
@@ -180,8 +180,8 @@ php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
return SAPI_HEADER_SENT_SUCCESSFULLY;
}
-static int
-php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC)
+static apr_size_t
+php_apache_sapi_read_post(char *buf, size_t count_bytes TSRMLS_DC)
{
apr_size_t len, tlen=0;
php_struct *ctx = SG(server_context);
@@ -212,7 +212,7 @@ php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC)
return tlen;
}
-static struct stat*
+static zend_stat_t*
php_apache_sapi_get_stat(TSRMLS_D)
{
php_struct *ctx = SG(server_context);
@@ -270,18 +270,18 @@ php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC)
php_struct *ctx = SG(server_context);
const apr_array_header_t *arr = apr_table_elts(ctx->r->subprocess_env);
char *key, *val;
- int new_val_len;
+ size_t new_val_len;
APR_ARRAY_FOREACH_OPEN(arr, key, val)
if (!val) {
val = "";
}
- if (sapi_module.input_filter(PARSE_SERVER, key, &val, strlen(val), (unsigned int *)&new_val_len TSRMLS_CC)) {
+ if (sapi_module.input_filter(PARSE_SERVER, key, &val, strlen(val), (size_t *)&new_val_len TSRMLS_CC)) {
php_register_variable_safe(key, val, new_val_len, track_vars_array TSRMLS_CC);
}
APR_ARRAY_FOREACH_CLOSE()
- if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &ctx->r->uri, strlen(ctx->r->uri), (unsigned int *)&new_val_len TSRMLS_CC)) {
+ if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &ctx->r->uri, strlen(ctx->r->uri), (size_t *)&new_val_len TSRMLS_CC)) {
php_register_variable_safe("PHP_SELF", ctx->r->uri, new_val_len, track_vars_array TSRMLS_CC);
}
}
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index ff3889dd6c..d02e0c6171 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -274,7 +274,7 @@ static void print_extensions(TSRMLS_D)
static inline size_t sapi_cgi_single_write(const char *str, uint str_length TSRMLS_DC)
{
#ifdef PHP_WRITE_STDOUT
- long ret;
+ int ret;
ret = write(STDOUT_FILENO, str, str_length);
if (ret <= 0) return 0;
@@ -287,10 +287,10 @@ static inline size_t sapi_cgi_single_write(const char *str, uint str_length TSRM
#endif
}
-static int sapi_cgi_ub_write(const char *str, uint str_length TSRMLS_DC)
+static size_t sapi_cgi_ub_write(const char *str, size_t str_length TSRMLS_DC)
{
const char *ptr = str;
- uint remaining = str_length;
+ size_t remaining = str_length;
size_t ret;
while (remaining > 0) {
@@ -306,14 +306,14 @@ static int sapi_cgi_ub_write(const char *str, uint str_length TSRMLS_DC)
return str_length;
}
-static int sapi_fcgi_ub_write(const char *str, uint str_length TSRMLS_DC)
+static size_t sapi_fcgi_ub_write(const char *str, size_t str_length TSRMLS_DC)
{
const char *ptr = str;
- uint remaining = str_length;
+ size_t remaining = str_length;
fcgi_request *request = (fcgi_request*) SG(server_context);
while (remaining > 0) {
- long ret = fcgi_write(request, FCGI_STDOUT, ptr, remaining);
+ zend_long ret = fcgi_write(request, FCGI_STDOUT, ptr, remaining);
if (ret <= 0) {
php_handle_aborted_connection();
@@ -505,9 +505,9 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
# define STDIN_FILENO 0
#endif
-static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
+static size_t sapi_cgi_read_post(char *buffer, size_t count_bytes TSRMLS_DC)
{
- uint read_bytes = 0;
+ size_t read_bytes = 0;
int tmp_read_bytes;
count_bytes = MIN(count_bytes, SG(request_info).content_length - SG(read_post_bytes));
@@ -521,9 +521,9 @@ static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
return read_bytes;
}
-static int sapi_fcgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
+static size_t sapi_fcgi_read_post(char *buffer, size_t count_bytes TSRMLS_DC)
{
- uint read_bytes = 0;
+ size_t read_bytes = 0;
int tmp_read_bytes;
fcgi_request *request = (fcgi_request*) SG(server_context);
size_t remaining = SG(request_info).content_length - SG(read_post_bytes);
@@ -622,7 +622,7 @@ static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, uns
{
zval *array_ptr = (zval*)arg;
int filter_arg = (Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV]))?PARSE_ENV:PARSE_SERVER;
- unsigned int new_val_len;
+ size_t new_val_len;
if (sapi_module.input_filter(filter_arg, var, &val, strlen(val), &new_val_len TSRMLS_CC)) {
php_register_variable_safe(var, val, new_val_len, array_ptr TSRMLS_CC);
@@ -658,7 +658,7 @@ static void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC)
static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC)
{
- unsigned int php_self_len;
+ size_t php_self_len;
char *php_self;
/* In CGI mode, we consider the environment to be a part of the server
@@ -1184,7 +1184,7 @@ static void init_request_info(fcgi_request *request TSRMLS_DC)
#endif
if (CGIG(fix_pathinfo)) {
- struct stat st;
+ zend_stat_t st;
char *real_path = NULL;
char *env_redirect_url = CGI_GETENV("REDIRECT_URL");
char *env_document_root = CGI_GETENV("DOCUMENT_ROOT");
@@ -1238,7 +1238,7 @@ static void init_request_info(fcgi_request *request TSRMLS_DC)
while ((ptr = strrchr(pt, '/')) || (ptr = strrchr(pt, '\\'))) {
*ptr = 0;
- if (stat(pt, &st) == 0 && S_ISREG(st.st_mode)) {
+ if (zend_stat(pt, &st) == 0 && S_ISREG(st.st_mode)) {
/*
* okay, we found the base script!
* work out how many chars we had to strip off;
@@ -1587,7 +1587,7 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */
char buf[128];
char **env, *p, *q, *var, *val, *t = buf;
size_t alloc_size = sizeof(buf);
- unsigned long var_len;
+ zend_ulong var_len;
for (env = environ; env != NULL && *env != NULL; env++) {
val = strchr(*env, '=');
@@ -2416,7 +2416,7 @@ consult the installation file that came with this distribution, or visit \n\
/* handle situations where line is terminated by \r\n */
if (c == '\r') {
if (php_stream_getc((php_stream*)file_handle.handle.stream.handle) != '\n') {
- long pos = php_stream_tell((php_stream*)file_handle.handle.stream.handle);
+ zend_off_t pos = php_stream_tell((php_stream*)file_handle.handle.stream.handle);
php_stream_seek((php_stream*)file_handle.handle.stream.handle, pos - 1, SEEK_SET);
}
}
diff --git a/sapi/cgi/config.w32 b/sapi/cgi/config.w32
index 8d1d431da4..55a2fba48f 100644
--- a/sapi/cgi/config.w32
+++ b/sapi/cgi/config.w32
@@ -4,7 +4,7 @@
ARG_ENABLE('cgi', 'Build CGI version of PHP', 'yes');
if (PHP_CGI == "yes") {
- ADD_FLAG("LDFLAGS_CGI", "/stack:8388608");
+ ADD_FLAG("LDFLAGS_CGI", "/stack:67108864");
SAPI('cgi', 'cgi_main.c fastcgi.c', 'php-cgi.exe');
ADD_FLAG('LIBS_CGI', 'ws2_32.lib kernel32.lib advapi32.lib');
}
diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c
index afbb7d2a37..aaea793133 100644
--- a/sapi/cgi/fastcgi.c
+++ b/sapi/cgi/fastcgi.c
@@ -19,6 +19,7 @@
/* $Id$ */
#include "php.h"
+#include "php_network.h"
#include "fastcgi.h"
#include <string.h>
@@ -1511,7 +1512,7 @@ void fcgi_impersonate(void)
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len)
{
zval zvalue;
- ZVAL_NEW_STR(&zvalue, STR_INIT(value, value_len, 1));
+ ZVAL_NEW_STR(&zvalue, zend_string_init(value, value_len, 1));
zend_hash_str_add(&fcgi_mgmt_vars, name, name_len, &zvalue);
}
diff --git a/sapi/cli/cli.h b/sapi/cli/cli.h
index dc85893a0b..b04f6c91f0 100644
--- a/sapi/cli/cli.h
+++ b/sapi/cli/cli.h
@@ -30,11 +30,11 @@
#endif
-extern PHP_CLI_API size_t sapi_cli_single_write(const char *str, uint str_length TSRMLS_DC);
+extern PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length TSRMLS_DC);
typedef struct {
- size_t (*cli_shell_write)(const char *str, uint str_length TSRMLS_DC);
- int (*cli_shell_ub_write)(const char *str, uint str_length TSRMLS_DC);
+ size_t (*cli_shell_write)(const char *str, size_t str_length TSRMLS_DC);
+ size_t (*cli_shell_ub_write)(const char *str, size_t str_length TSRMLS_DC);
int (*cli_shell_run)(TSRMLS_D);
} cli_shell_callbacks_t;
diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32
index adcbb2b496..438c9e6d62 100644
--- a/sapi/cli/config.w32
+++ b/sapi/cli/config.w32
@@ -11,11 +11,11 @@ if (PHP_CLI == "yes") {
if (PHP_CRT_DEBUG == "yes") {
ADD_FLAG("CFLAGS_CLI", "/D PHP_WIN32_DEBUG_HEAP");
}
- ADD_FLAG("LDFLAGS_CLI", "/stack:8388608");
+ ADD_FLAG("LDFLAGS_CLI", "/stack:67108864");
}
if (PHP_CLI_WIN32 == "yes") {
SAPI('cli_win32', 'cli_win32.c php_cli_process_title.c ps_title.c', 'php-win.exe');
- ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:8388608");
+ ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:67108864");
}
diff --git a/sapi/cli/php.1.in b/sapi/cli/php.1.in
index 4d536df53c..c062f3d20e 100644
--- a/sapi/cli/php.1.in
+++ b/sapi/cli/php.1.in
@@ -1,24 +1,24 @@
-.TH PHP 1 "2014" "The PHP Group" "Scripting Language"
+.TH @program_prefix@php 1 "2014" "The PHP Group" "Scripting Language"
.SH NAME
-php \- PHP Command Line Interface 'CLI'
+@program_prefix@php \- PHP Command Line Interface 'CLI'
.P
-php-cgi \- PHP Common Gateway Interface 'CGI' command
+@program_prefix@php-cgi \- PHP Common Gateway Interface 'CGI' command
.SH SYNOPSIS
-.B php
+.B @program_prefix@php
[options] [
.B \-f\fP ]
.IR file
[[\-\-]
.IR args.\|.\|. ]
.LP
-.B php
+.B @program_prefix@php
[options]
.B \-r
.IR code
[[\-\-]
.IR args.\|.\|. ]
.LP
-.B php
+.B @program_prefix@php
[options] [\-B
.IR begin_code ]
.B \-R
@@ -28,7 +28,7 @@ php-cgi \- PHP Common Gateway Interface 'CGI' command
[[\-\-]
.IR args.\|.\|. ]
.LP
-.B php
+.B @program_prefix@php
[options] [\-B
.IR begin_code ]
.B \-F
@@ -38,13 +38,13 @@ php-cgi \- PHP Common Gateway Interface 'CGI' command
[[\-\-]
.IR args.\|.\|. ]
.LP
-.B php
+.B @program_prefix@php
[options] \-\- [
.IR args.\|.\|. ]
.LP
-\fBphp \fP[options] \fB\-a\fP
+\fB@program_prefix@php \fP[options] \fB\-a\fP
.LP
-.B php
+.B @program_prefix@php
[options] \-S
.IR addr:port
[\-t
@@ -374,35 +374,35 @@ The standard configuration file will only be used when
cannot be found.
.SH EXAMPLES
.TP 5
-\fIphp \-r 'echo "Hello World\\n";'\fP
+\fI@program_prefix@php \-r 'echo "Hello World\\n";'\fP
This command simply writes the text "Hello World" to standard out.
.TP
-\fIphp \-r 'print_r(gd_info());'\fP
+\fI@program_prefix@php \-r 'print_r(gd_info());'\fP
This shows the configuration of your gd extension. You can use this
to easily check which image formats you can use. If you have any
dynamic modules you may want to use the same ini file that php uses
when executed from your webserver. There are more extensions which
have such a function. For dba use:
.RS
-\fIphp \-r 'print_r(dba_handlers(1));'\fP
+\fI@program_prefix@php \-r 'print_r(dba_handlers(1));'\fP
.RE
.TP
-\fIphp \-R 'echo strip_tags($argn)."\\n";'\fP
+\fI@program_prefix@php \-R 'echo strip_tags($argn)."\\n";'\fP
This PHP command strips off the HTML tags line by line and outputs the
result. To see how it works you can first look at the following PHP command
\'\fIphp \-d html_errors=1 \-i\fP\' which uses PHP to output HTML formatted
configuration information. If you then combine those two
\'\fIphp \.\.\.|php \.\.\.\fP\' you'll see what happens.
.TP
-\fIphp \-E 'echo "Lines: $argi\\n";'\fP
+\fI@program_prefix@php \-E 'echo "Lines: $argi\\n";'\fP
Using this PHP command you can count the lines being input.
.TP
-\fIphp \-R '@$l+=count(file($argn));' \-E 'echo "Lines:$l\\n";'\fP
+\fI@program_prefix@php \-R '@$l+=count(file($argn));' \-E 'echo "Lines:$l\\n";'\fP
In this example PHP expects each input line being a file. It counts all lines
of the files specified by each input line and shows the summarized result.
You may combine this with tools like find and change the php scriptlet.
.TP
-\fIphp \-R 'echo "$argn\\n"; fgets(STDIN);'\fP
+\fI@program_prefix@php \-R 'echo "$argn\\n"; fgets(STDIN);'\fP
Since you have access to STDIN from within \-B \-R \-F and \-E you can skip
certain input lines with your code. But note that in such cases $argi only
counts the lines being processed by php itself. Having read this you will
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index ec76f37715..5847849e89 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -252,10 +252,10 @@ static inline int sapi_cli_select(int fd TSRMLS_DC)
return ret != -1;
}
-PHP_CLI_API size_t sapi_cli_single_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */
+PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length TSRMLS_DC) /* {{{ */
{
#ifdef PHP_WRITE_STDOUT
- long ret;
+ zend_long ret;
#else
size_t ret;
#endif
@@ -285,10 +285,10 @@ PHP_CLI_API size_t sapi_cli_single_write(const char *str, uint str_length TSRMLS
}
/* }}} */
-static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */
+static size_t sapi_cli_ub_write(const char *str, size_t str_length TSRMLS_DC) /* {{{ */
{
const char *ptr = str;
- uint remaining = str_length;
+ size_t remaining = str_length;
size_t ret;
if (!str_length) {
@@ -296,7 +296,7 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{
}
if (cli_shell_callbacks.cli_shell_ub_write) {
- int ub_wrote;
+ size_t ub_wrote;
ub_wrote = cli_shell_callbacks.cli_shell_ub_write(str, str_length TSRMLS_CC);
if (ub_wrote > -1) {
return ub_wrote;
@@ -338,7 +338,7 @@ static char *script_filename = "";
static void sapi_cli_register_variables(zval *track_vars_array TSRMLS_DC) /* {{{ */
{
- unsigned int len;
+ size_t len;
char *docroot = "";
/* In CGI mode, we consider the environment to be a part of the server
@@ -425,7 +425,7 @@ static int php_cli_startup(sapi_module_struct *sapi_module) /* {{{ */
/* overwriteable ini defaults must be set in sapi_cli_ini_defaults() */
#define INI_DEFAULT(name,value)\
- ZVAL_NEW_STR(&tmp, STR_INIT(value, sizeof(value)-1, 1));\
+ ZVAL_NEW_STR(&tmp, zend_string_init(value, sizeof(value)-1, 1));\
zend_hash_str_update(configuration_hash, name, sizeof(name)-1, &tmp);\
static void sapi_cli_ini_defaults(HashTable *configuration_hash)
@@ -581,19 +581,19 @@ static void cli_register_file_handles(TSRMLS_D) /* {{{ */
ZVAL_COPY_VALUE(&ic.value, &zin);
ic.flags = CONST_CS;
- ic.name = STR_INIT("STDIN", sizeof("STDIN")-1, 1);
+ ic.name = zend_string_init("STDIN", sizeof("STDIN")-1, 1);
ic.module_number = 0;
zend_register_constant(&ic TSRMLS_CC);
ZVAL_COPY_VALUE(&oc.value, &zout);
oc.flags = CONST_CS;
- oc.name = STR_INIT("STDOUT", sizeof("STDOUT")-1, 1);
+ oc.name = zend_string_init("STDOUT", sizeof("STDOUT")-1, 1);
oc.module_number = 0;
zend_register_constant(&oc TSRMLS_CC);
ZVAL_COPY_VALUE(&ec.value, &zerr);
ec.flags = CONST_CS;
- ec.name = STR_INIT("STDERR", sizeof("STDERR")-1, 1);
+ ec.name = zend_string_init("STDERR", sizeof("STDERR")-1, 1);
ec.module_number = 0;
zend_register_constant(&ec TSRMLS_CC);
}
@@ -963,9 +963,9 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
}
}
- key = STR_INIT("_SERVER", sizeof("_SERVER")-1, 0);
+ key = zend_string_init("_SERVER", sizeof("_SERVER")-1, 0);
zend_is_auto_global(key TSRMLS_CC);
- STR_RELEASE(key);
+ zend_string_release(key);
PG(during_request_startup) = 0;
switch (behavior) {
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index 09cfd02ec9..88a1010db1 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -139,7 +139,7 @@ typedef struct php_cli_server_request {
size_t content_len;
const char *ext;
size_t ext_len;
- struct stat sb;
+ zend_stat_t sb;
} php_cli_server_request;
typedef struct php_cli_server_chunk {
@@ -436,7 +436,7 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */
static void add_response_header(sapi_header_struct *h, zval *return_value TSRMLS_DC) /* {{{ */
{
char *s, *p;
- int len;
+ ptrdiff_t len;
ALLOCA_FLAG(use_heap)
if (h->header_len > 0) {
@@ -539,7 +539,7 @@ static int sapi_cli_server_startup(sapi_module_struct *sapi_module) /* {{{ */
return SUCCESS;
} /* }}} */
-static int sapi_cli_server_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */
+static size_t sapi_cli_server_ub_write(const char *str, size_t str_length TSRMLS_DC) /* {{{ */
{
php_cli_server_client *client = SG(server_context);
if (!client) {
@@ -619,7 +619,7 @@ static char *sapi_cli_server_read_cookies(TSRMLS_D) /* {{{ */
return val;
} /* }}} */
-static int sapi_cli_server_read_post(char *buf, uint count_bytes TSRMLS_DC) /* {{{ */
+static size_t sapi_cli_server_read_post(char *buf, size_t count_bytes TSRMLS_DC) /* {{{ */
{
php_cli_server_client *client = SG(server_context);
if (client->request.content) {
@@ -635,7 +635,7 @@ static int sapi_cli_server_read_post(char *buf, uint count_bytes TSRMLS_DC) /* {
static void sapi_cli_server_register_variable(zval *track_vars_array, const char *key, const char *val TSRMLS_DC) /* {{{ */
{
char *new_val = (char *)val;
- uint new_val_len;
+ size_t new_val_len;
if (sapi_module.input_filter(PARSE_SERVER, (char*)key, &new_val, strlen(val), &new_val_len TSRMLS_CC)) {
php_register_variable_safe((char *)key, new_val, new_val_len, track_vars_array TSRMLS_CC);
}
@@ -789,7 +789,7 @@ static int php_cli_server_poller_ctor(php_cli_server_poller *poller) /* {{{ */
return SUCCESS;
} /* }}} */
-static void php_cli_server_poller_add(php_cli_server_poller *poller, int mode, int fd) /* {{{ */
+static void php_cli_server_poller_add(php_cli_server_poller *poller, int mode, php_socket_t fd) /* {{{ */
{
if (mode & POLLIN) {
PHP_SAFE_FD_SET(fd, &poller->rfds);
@@ -802,7 +802,7 @@ static void php_cli_server_poller_add(php_cli_server_poller *poller, int mode, i
}
} /* }}} */
-static void php_cli_server_poller_remove(php_cli_server_poller *poller, int mode, int fd) /* {{{ */
+static void php_cli_server_poller_remove(php_cli_server_poller *poller, int mode, php_socket_t fd) /* {{{ */
{
if (mode & POLLIN) {
PHP_SAFE_FD_CLR(fd, &poller->rfds);
@@ -830,7 +830,7 @@ static int php_cli_server_poller_poll(php_cli_server_poller *poller, struct time
return php_select(poller->max_fd + 1, &poller->active.rfds, &poller->active.wfds, NULL, tv);
} /* }}} */
-static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, void *opaque, int(*callback)(void *, int fd, int events)) /* {{{ */
+static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, void *opaque, int(*callback)(void *, php_socket_t fd, int events)) /* {{{ */
{
int retval = SUCCESS;
#ifdef PHP_WIN32
@@ -1209,7 +1209,7 @@ static void php_cli_server_logf(const char *format TSRMLS_DC, ...) /* {{{ */
static int php_network_listen_socket(const char *host, int *port, int socktype, int *af, socklen_t *socklen, zend_string **errstr TSRMLS_DC) /* {{{ */
{
- int retval = SOCK_ERR;
+ php_socket_t retval = SOCK_ERR;
int err = 0;
struct sockaddr *sa = NULL, **p, **sal;
@@ -1377,7 +1377,7 @@ static void php_cli_server_request_dtor(php_cli_server_request *req) /* {{{ */
static void php_cli_server_request_translate_vpath(php_cli_server_request *request, const char *document_root, size_t document_root_len) /* {{{ */
{
- struct stat sb;
+ zend_stat_t sb;
static const char *index_files[] = { "index.php", "index.html", NULL };
char *buf = safe_pemalloc(1, request->vpath_len, 1 + document_root_len + 1 + sizeof("index.html"), 1);
char *p = buf, *prev_path = NULL, *q, *vpath;
@@ -1414,7 +1414,7 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque
*p = '\0';
q = p;
while (q > buf) {
- if (!stat(buf, &sb)) {
+ if (!zend_stat(buf, &sb)) {
if (sb.st_mode & S_IFDIR) {
const char **file = index_files;
if (q[-1] != DEFAULT_SLASH) {
@@ -1423,7 +1423,7 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque
while (*file) {
size_t l = strlen(*file);
memmove(q, *file, l + 1);
- if (!stat(buf, &sb) && (sb.st_mode & S_IFREG)) {
+ if (!zend_stat(buf, &sb) && (sb.st_mode & S_IFREG)) {
q += l;
break;
}
@@ -1613,12 +1613,12 @@ static int php_cli_server_client_read_request_on_header_value(php_http_parser *p
}
{
/* strip off the colon */
- zend_string *orig_header_name = STR_INIT(client->current_header_name, client->current_header_name_len, 1);
+ zend_string *orig_header_name = zend_string_init(client->current_header_name, client->current_header_name_len, 1);
char *lc_header_name = zend_str_tolower_dup(client->current_header_name, client->current_header_name_len);
zend_hash_str_add_ptr(&client->request.headers, lc_header_name, client->current_header_name_len, value);
zend_hash_add_ptr(&client->request.headers_original_case, orig_header_name, value);
efree(lc_header_name);
- STR_RELEASE(orig_header_name);
+ zend_string_release(orig_header_name);
}
if (client->current_header_name_allocated) {
@@ -1785,7 +1785,7 @@ static void destroy_request_info(sapi_request_info *request_info) /* {{{ */
{
} /* }}} */
-static int php_cli_server_client_ctor(php_cli_server_client *client, php_cli_server *server, int client_sock, struct sockaddr *addr, socklen_t addr_len TSRMLS_DC) /* {{{ */
+static int php_cli_server_client_ctor(php_cli_server_client *client, php_cli_server *server, php_socket_t client_sock, struct sockaddr *addr, socklen_t addr_len TSRMLS_DC) /* {{{ */
{
client->server = server;
client->sock = client_sock;
@@ -1797,7 +1797,7 @@ static int php_cli_server_client_ctor(php_cli_server_client *client, php_cli_ser
php_network_populate_name_from_sockaddr(addr, addr_len, &addr_str, NULL, 0 TSRMLS_CC);
client->addr_str = pestrndup(addr_str->val, addr_str->len, 1);
client->addr_str_len = addr_str->len;
- STR_RELEASE(addr_str);
+ zend_string_release(addr_str);
}
php_http_parser_init(&client->parser, PHP_HTTP_REQUEST);
client->request_read = 0;
@@ -1919,14 +1919,14 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server
if (errstr) {
pefree(errstr, 1);
}
- STR_FREE(escaped_request_uri);
+ zend_string_free(escaped_request_uri);
return SUCCESS;
fail:
if (errstr) {
pefree(errstr, 1);
}
- STR_FREE(escaped_request_uri);
+ zend_string_free(escaped_request_uri);
return FAILURE;
} /* }}} */
@@ -2233,7 +2233,7 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c
if (server_sock == SOCK_ERR) {
php_cli_server_logf("Failed to listen on %s:%d (reason: %s)" TSRMLS_CC, host, port, errstr ? errstr->val : "?");
if (errstr) {
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
}
retval = FAILURE;
goto out;
@@ -2361,7 +2361,7 @@ typedef struct php_cli_server_do_event_for_each_fd_callback_params {
int(*whandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC);
} php_cli_server_do_event_for_each_fd_callback_params;
-static int php_cli_server_do_event_for_each_fd_callback(void *_params, int fd, int event) /* {{{ */
+static int php_cli_server_do_event_for_each_fd_callback(void *_params, php_socket_t fd, int event) /* {{{ */
{
php_cli_server_do_event_for_each_fd_callback_params *params = _params;
#ifdef ZTS
@@ -2487,9 +2487,9 @@ int do_cli_server(int argc, char **argv TSRMLS_DC) /* {{{ */
}
if (document_root) {
- struct stat sb;
+ zend_stat_t sb;
- if (stat(document_root, &sb)) {
+ if (zend_stat(document_root, &sb)) {
fprintf(stderr, "Directory %s does not exist.\n", document_root);
return 1;
}
diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c
index b4fc5aaf10..230b3a649d 100644
--- a/sapi/embed/php_embed.c
+++ b/sapi/embed/php_embed.c
@@ -44,10 +44,10 @@ static int php_embed_deactivate(TSRMLS_D)
return SUCCESS;
}
-static inline size_t php_embed_single_write(const char *str, uint str_length)
+static inline size_t php_embed_single_write(const char *str, size_t str_length)
{
#ifdef PHP_WRITE_STDOUT
- long ret;
+ zend_long ret;
ret = write(STDOUT_FILENO, str, str_length);
if (ret <= 0) return 0;
@@ -61,10 +61,10 @@ static inline size_t php_embed_single_write(const char *str, uint str_length)
}
-static int php_embed_ub_write(const char *str, uint str_length TSRMLS_DC)
+static size_t php_embed_ub_write(const char *str, size_t str_length TSRMLS_DC)
{
const char *ptr = str;
- uint remaining = str_length;
+ size_t remaining = str_length;
size_t ret;
while (remaining > 0) {
diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c
index 8fbdd36a24..39621b839c 100644
--- a/sapi/fpm/fpm/fastcgi.c
+++ b/sapi/fpm/fpm/fastcgi.c
@@ -1064,13 +1064,13 @@ char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val)
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len)
{
zval zvalue;
- ZVAL_STR(&zvalue, STR_INIT(value, value_len, 1));
+ ZVAL_STR(&zvalue, zend_string_init(value, value_len, 1));
zend_hash_str_add(&fcgi_mgmt_vars, name, name_len, &zvalue);
}
void fcgi_free_mgmt_var_cb(zval *zv)
{
- STR_FREE(Z_STR_P(zv));
+ zend_string_free(Z_STR_P(zv));
}
char *fcgi_get_last_client_ip() /* {{{ */
diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c
index 34e0480101..18ddccb300 100644
--- a/sapi/fpm/fpm/fpm_conf.c
+++ b/sapi/fpm/fpm/fpm_conf.c
@@ -1476,7 +1476,8 @@ static void fpm_conf_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback
int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
{
int error = 0;
- char buf[1024+1];
+ char *buf = NULL, *newbuf = NULL;
+ int bufsize = 0;
int fd, n;
int nb_read = 1;
char c = '*';
@@ -1503,19 +1504,36 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
ini_lineno = 0;
while (nb_read > 0) {
int tmp;
- memset(buf, 0, sizeof(char) * (1024 + 1));
- for (n = 0; n < 1024 && (nb_read = read(fd, &c, sizeof(char))) == sizeof(char) && c != '\n'; n++) {
+ ini_lineno++;
+ ini_filename = filename;
+ for (n = 0; (nb_read = read(fd, &c, sizeof(char))) == sizeof(char) && c != '\n'; n++) {
+ if (n == bufsize) {
+ bufsize += 1024;
+ newbuf = (char*) realloc(buf, sizeof(char) * (bufsize + 2));
+ if (newbuf == NULL) {
+ ini_recursion--;
+ close(fd);
+ free(buf);
+ return -1;
+ }
+ buf = newbuf;
+ }
+
buf[n] = c;
}
+ if (n == 0) {
+ continue;
+ }
+ /* always append newline and null terminate */
buf[n++] = '\n';
- ini_lineno++;
- ini_filename = filename;
+ buf[n] = '\0';
tmp = zend_parse_ini_string(buf, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t)fpm_conf_ini_parser, &error TSRMLS_CC);
ini_filename = filename;
if (error || tmp == FAILURE) {
if (ini_include) free(ini_include);
ini_recursion--;
close(fd);
+ free(buf);
return -1;
}
if (ini_include) {
@@ -1527,16 +1545,17 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
free(tmp);
ini_recursion--;
close(fd);
+ free(buf);
return -1;
}
free(tmp);
}
}
+ free(buf);
ini_recursion--;
close(fd);
return ret;
-
}
/* }}} */
diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c
index e447648462..fa3fc763a5 100644
--- a/sapi/fpm/fpm/fpm_status.c
+++ b/sapi/fpm/fpm/fpm_status.c
@@ -127,7 +127,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
}
/* full status ? */
- _GET_str = STR_INIT("_GET", sizeof("_GET")-1, 0);
+ _GET_str = zend_string_init("_GET", sizeof("_GET")-1, 0);
full = (fpm_php_get_string_from_table(_GET_str, "full" TSRMLS_CC) != NULL);
short_syntax = short_post = NULL;
full_separator = full_pre = full_syntax = full_post = NULL;
@@ -378,7 +378,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
PUTS(buffer);
efree(buffer);
- STR_RELEASE(_GET_str);
+ zend_string_release(_GET_str);
if (short_post) {
PUTS(short_post);
@@ -463,7 +463,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
efree(buffer);
if (tmp_query_string) {
- STR_FREE(tmp_query_string);
+ zend_string_free(tmp_query_string);
}
}
diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h
index eb4faf1f94..7d720f157b 100644
--- a/sapi/phpdbg/phpdbg.h
+++ b/sapi/phpdbg/phpdbg.h
@@ -180,7 +180,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
HashTable registered; /* registered */
HashTable seek; /* seek oplines */
phpdbg_frame_t frame; /* frame */
- zend_uint last_line; /* last executed line */
+ uint32_t last_line; /* last executed line */
phpdbg_lexer_data lexer; /* lexer data */
phpdbg_param_t *parser_stack; /* param stack during lexer / parser phase */
diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c
index a18316a228..86f32b092e 100644
--- a/sapi/phpdbg/phpdbg_bp.c
+++ b/sapi/phpdbg/phpdbg_bp.c
@@ -700,7 +700,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRML
static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, const phpdbg_param_t *param, const char *expr, size_t expr_len, zend_ulong hash TSRMLS_DC) /* {{{ */
{
phpdbg_breakcond_t new_break;
- zend_uint cops = CG(compiler_options);
+ uint32_t cops = CG(compiler_options);
zval pv;
PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_COND);
@@ -1092,7 +1092,7 @@ PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC) /* {{{ */
if ((brake = phpdbg_find_breakbase_ex(num, &table, &position TSRMLS_CC))) {
char *key;
- zend_uint klen;
+ uint32_t klen;
zend_ulong idx;
int type = brake->type;
char *name = NULL;
@@ -1370,7 +1370,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
HashPosition position[2];
HashTable *class_table;
char *class_name = NULL;
- zend_uint class_len = 0;
+ uint32_t class_len = 0;
zend_ulong class_idx = 0L;
phpdbg_writeln(SEPARATE);
@@ -1449,7 +1449,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
HashPosition position[3];
HashTable *class_table, *method_table;
char *class_name = NULL, *method_name = NULL;
- zend_uint class_len = 0, method_len = 0;
+ uint32_t class_len = 0, method_len = 0;
zend_ulong class_idx = 0L, method_idx = 0L;
phpdbg_writeln(SEPARATE);
@@ -1488,7 +1488,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
HashPosition position[2];
HashTable *function_table;
char *function_name = NULL;
- zend_uint function_len = 0;
+ uint32_t function_len = 0;
zend_ulong function_idx = 0L;
phpdbg_writeln(SEPARATE);
@@ -1518,7 +1518,7 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
HashPosition position[2];
HashTable *file_table;
char *file_name = NULL;
- zend_uint file_len = 0;
+ uint32_t file_len = 0;
zend_ulong file_idx = 0L;
phpdbg_writeln(SEPARATE);
diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c
index a45513bee6..72dc484098 100644
--- a/sapi/phpdbg/phpdbg_cmd.c
+++ b/sapi/phpdbg/phpdbg_cmd.c
@@ -699,7 +699,7 @@ PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *
default: {
char *list = NULL;
- zend_uint it = 0;
+ uint32_t it = 0;
size_t pos = 0;
while (it < matches) {
diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c
index a235fe8cb0..5a6a37d5f9 100644
--- a/sapi/phpdbg/phpdbg_frame.c
+++ b/sapi/phpdbg/phpdbg_frame.c
@@ -114,7 +114,7 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
(void **)&class);
} else {
zend_get_object_classname(*class, (const char **)&Z_STRVAL_PP(class),
- (zend_uint *)&Z_STRLEN_PP(class) TSRMLS_CC);
+ (uint32_t *)&Z_STRLEN_PP(class) TSRMLS_CC);
}
if (is_class == SUCCESS) {
diff --git a/sapi/phpdbg/phpdbg_opcode.c b/sapi/phpdbg/phpdbg_opcode.c
index 6b13625fc1..4e693c4414 100644
--- a/sapi/phpdbg/phpdbg_opcode.c
+++ b/sapi/phpdbg/phpdbg_opcode.c
@@ -26,7 +26,7 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
-static inline zend_uint phpdbg_decode_literal(zend_op_array *ops, zend_literal *literal TSRMLS_DC) /* {{{ */
+static inline uint32_t phpdbg_decode_literal(zend_op_array *ops, zend_literal *literal TSRMLS_DC) /* {{{ */
{
int iter = 0;
@@ -40,7 +40,7 @@ static inline zend_uint phpdbg_decode_literal(zend_op_array *ops, zend_literal *
return 0;
} /* }}} */
-static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, zend_uint type, HashTable *vars TSRMLS_DC) /* {{{ */
+static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t type, HashTable *vars TSRMLS_DC) /* {{{ */
{
char *decode = NULL;
diff --git a/sapi/phpdbg/phpdbg_print.c b/sapi/phpdbg/phpdbg_print.c
index 76321a5042..376373e4a1 100644
--- a/sapi/phpdbg/phpdbg_print.c
+++ b/sapi/phpdbg/phpdbg_print.c
@@ -59,7 +59,7 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC)
if (op_array) {
zend_op *opline = &(op_array->opcodes[0]);
- zend_uint opcode = 0,
+ uint32_t opcode = 0,
end = op_array->last-1;
if (method->common.scope) {
diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c
index d91ef3f3f5..9695d911ab 100644
--- a/sapi/phpdbg/phpdbg_prompt.c
+++ b/sapi/phpdbg/phpdbg_prompt.c
@@ -430,7 +430,7 @@ PHPDBG_COMMAND(until) /* {{{ */
PHPDBG_G(flags) |= PHPDBG_IN_UNTIL;
{
- zend_uint next = 0,
+ uint32_t next = 0,
self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes);
zend_op *opline = &EG(active_op_array)->opcodes[self];
@@ -458,7 +458,7 @@ PHPDBG_COMMAND(finish) /* {{{ */
PHPDBG_G(flags) |= PHPDBG_IN_FINISH;
{
- zend_uint next = 0,
+ uint32_t next = 0,
self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes);
for (next = self; next < EG(active_op_array)->last; next++) {
@@ -491,7 +491,7 @@ PHPDBG_COMMAND(leave) /* {{{ */
PHPDBG_G(flags) |= PHPDBG_IN_LEAVE;
{
- zend_uint next = 0,
+ uint32_t next = 0,
self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes);
for (next = self; next < EG(active_op_array)->last; next++) {
@@ -534,7 +534,7 @@ static inline void phpdbg_handle_exception(TSRMLS_D) /* }}} */
/* get filename and linenumber before unsetting exception */
const char *filename = zend_get_executed_filename(TSRMLS_C);
- zend_uint lineno = zend_get_executed_lineno(TSRMLS_C);
+ uint32_t lineno = zend_get_executed_lineno(TSRMLS_C);
/* copy exception */
exception = *EG(exception);
diff --git a/scripts/man1/php-config.1.in b/scripts/man1/php-config.1.in
index 5c60408f42..ae2ee56bbc 100644
--- a/scripts/man1/php-config.1.in
+++ b/scripts/man1/php-config.1.in
@@ -1,12 +1,12 @@
-.TH php\-config 1 "2010" "The PHP Group" "Scripting Language"
+.TH @program_prefix@php\-config 1 "2014" "The PHP Group" "Scripting Language"
.SH NAME
-php\-config \- get information about PHP configuration and compile options
+@program_prefix@php\-config \- get information about PHP configuration and compile options
.SH SYNOPSIS
-.B php\-config
+.B @program_prefix@php\-config
[options]
.LP
.SH DESCRIPTION
-.B php\-config
+.B @program_prefix@php\-config
is a simple shell script for obtaining information about installed PHP configuration.
.SH OPTIONS
.TP 15
@@ -57,15 +57,15 @@ PHP version
.PD 0
.B \-\-vernum
PHP version as integer
-.TP
+.RS
.PD 1
.P
.SH SEE ALSO
-.BR php (1)
+.BR @program_prefix@php (1)
.SH VERSION INFORMATION
This manpage describes \fBphp\fP, version @PHP_VERSION@.
.SH COPYRIGHT
-Copyright \(co 1997\-2010 The PHP Group
+Copyright \(co 1997\-2014 The PHP Group
.LP
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
diff --git a/scripts/man1/phpize.1.in b/scripts/man1/phpize.1.in
index 8f62f867b7..e49adb1b79 100644
--- a/scripts/man1/phpize.1.in
+++ b/scripts/man1/phpize.1.in
@@ -1,12 +1,12 @@
-.TH phpize 1 "2010" "The PHP Group" "Scripting Language"
+.TH @program_prefix@phpize 1 "2014" "The PHP Group" "Scripting Language"
.SH NAME
-phpize \- prepare a PHP extension for compiling
+@program_prefix@phpize \- prepare a PHP extension for compiling
.SH SYNOPSIS
-.B phpize
+.B @program_prefix@phpize
[options]
.LP
.SH DESCRIPTION
-.B phpize
+.B @program_prefix@phpize
is a shell script to prepare PHP extension for compiling.
.SH OPTIONS
.TP 15
@@ -24,15 +24,15 @@ Prints usage information
.PD 1
.B \-v
Prints API version information
-.TP
+.RS
.PD 1
.P
.SH SEE ALSO
-.BR php (1)
+.BR @program_prefix@php (1)
.SH VERSION INFORMATION
This manpage describes \fBphp\fP, version @PHP_VERSION@.
.SH COPYRIGHT
-Copyright \(co 1997\-2010 The PHP Group
+Copyright \(co 1997\-2014 The PHP Group
.LP
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
diff --git a/travis/compile.sh b/travis/compile.sh
index 52748c6db5..20228cda5a 100755
--- a/travis/compile.sh
+++ b/travis/compile.sh
@@ -49,7 +49,6 @@ $TS \
--with-openssl \
--with-gmp \
--enable-bcmath \
---enable-phpdbg \
--enable-calendar \
--enable-ftp \
--with-pspell=/usr \
diff --git a/win32/glob.c b/win32/glob.c
index 8111daba1c..74882ac7d6 100644
--- a/win32/glob.c
+++ b/win32/glob.c
@@ -146,10 +146,10 @@ typedef char Char;
static int compare(const void *, const void *);
static int g_Ctoc(const Char *, char *, u_int);
-static int g_lstat(Char *, struct stat *, glob_t *);
+static int g_lstat(Char *, zend_stat_t *, glob_t *);
static DIR *g_opendir(Char *, glob_t *);
static Char *g_strchr(Char *, int);
-static int g_stat(Char *, struct stat *, glob_t *);
+static int g_stat(Char *, zend_stat_t *, glob_t *);
static int glob0(const Char *, glob_t *);
static int glob1(Char *, Char *, glob_t *, size_t *);
static int glob2(Char *, Char *, Char *, Char *, Char *, Char *,
@@ -559,7 +559,7 @@ glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
glob_t *pglob;
size_t *limitp;
{
- struct stat sb;
+ zend_stat_t sb;
Char *p, *q;
int anymeta;
@@ -856,7 +856,7 @@ g_opendir(str, pglob)
static int
g_lstat(fn, sb, pglob)
register Char *fn;
- struct stat *sb;
+ zend_stat_t *sb;
glob_t *pglob;
{
char buf[MAXPATHLEN];
@@ -871,7 +871,7 @@ g_lstat(fn, sb, pglob)
static int
g_stat(fn, sb, pglob)
register Char *fn;
- struct stat *sb;
+ zend_stat_t *sb;
glob_t *pglob;
{
char buf[MAXPATHLEN];
diff --git a/win32/glob.h b/win32/glob.h
index 3f7a57a0b3..63b8fc2f67 100644
--- a/win32/glob.h
+++ b/win32/glob.h
@@ -47,7 +47,7 @@
# include <sys/cdefs.h>
#endif
-struct stat;
+zend_stat_t;
typedef struct {
int gl_pathc; /* Count of total paths so far. */
int gl_matchc; /* Count of paths matching pattern. */
@@ -65,8 +65,8 @@ typedef struct {
void (*gl_closedir)(void *);
struct dirent *(*gl_readdir)(void *);
void *(*gl_opendir)(const char *);
- int (*gl_lstat)(const char *, struct stat *);
- int (*gl_stat)(const char *, struct stat *);
+ int (*gl_lstat)(const char *, zend_stat_t *);
+ int (*gl_stat)(const char *, zend_stat_t *);
} glob_t;
/* Flags */
diff --git a/win32/php_stdint.h b/win32/php_stdint.h
index 0d63615c6b..858dcb5c33 100644
--- a/win32/php_stdint.h
+++ b/win32/php_stdint.h
@@ -36,6 +36,10 @@
#ifndef _MSC_STDINT_H_ // [
#define _MSC_STDINT_H_
+#ifndef _STDINT
+# define _STDINT
+#endif
+
#if _MSC_VER > 1000
#pragma once
#endif
@@ -130,6 +134,7 @@ typedef uint64_t uintmax_t;
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
// 7.18.2.1 Limits of exact-width integer types
+#if _MSC_VER >= 1700 && !defined(_INTSAFE_H_INCLUDED_)
#define INT8_MIN ((int8_t)_I8_MIN)
#define INT8_MAX _I8_MAX
#define INT16_MIN ((int16_t)_I16_MIN)
@@ -142,6 +147,7 @@ typedef uint64_t uintmax_t;
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define UINT64_MAX _UI64_MAX
+#endif
// 7.18.2.2 Limits of minimum-width integer types
#define INT_LEAST8_MIN INT8_MIN
diff --git a/win32/registry.c b/win32/registry.c
index ade09aa486..8ed838b1d1 100644
--- a/win32/registry.c
+++ b/win32/registry.c
@@ -240,7 +240,7 @@ void UpdateIniFromRegistry(char *path TSRMLS_DC)
if (pht != NULL) {
HashTable *ht = pht;
zend_string *index;
- ulong num;
+ zend_ulong num;
zval *data;
ZEND_HASH_FOREACH_KEY_VAL(ht, num, index, data) {
diff --git a/win32/sendmail.c b/win32/sendmail.c
index c191e0f3aa..3d61d8b6b4 100644
--- a/win32/sendmail.c
+++ b/win32/sendmail.c
@@ -165,7 +165,7 @@ static zend_string *php_win32_mail_trim_header(char *header TSRMLS_DC)
}
ZVAL_STRINGL(&replace, PHP_WIN32_MAIL_UNIFY_REPLACE, strlen(PHP_WIN32_MAIL_UNIFY_REPLACE));
- regex = STR_INIT(PHP_WIN32_MAIL_UNIFY_REPLACE, sizeof(PHP_WIN32_MAIL_UNIFY_REPLACE)-1, 0);
+ regex = zend_string_init(PHP_WIN32_MAIL_UNIFY_REPLACE, sizeof(PHP_WIN32_MAIL_UNIFY_REPLACE)-1, 0);
//zend_string *php_pcre_replace(zend_string *regex, char *subject, int subject_len, zval *replace_val, int is_callable_replace, int limit, int *replace_count TSRMLS_DC);
@@ -178,12 +178,12 @@ static zend_string *php_win32_mail_trim_header(char *header TSRMLS_DC)
if (NULL == result) {
zval_ptr_dtor(&replace);
- STR_FREE(regex);
+ zend_string_free(regex);
return NULL;
}
ZVAL_STRING(&replace, PHP_WIN32_MAIL_RMVDBL_PATTERN);
- regex = STR_INIT(PHP_WIN32_MAIL_RMVDBL_PATTERN, sizeof(PHP_WIN32_MAIL_RMVDBL_PATTERN)-1, 0);
+ regex = zend_string_init(PHP_WIN32_MAIL_RMVDBL_PATTERN, sizeof(PHP_WIN32_MAIL_RMVDBL_PATTERN)-1, 0);
result2 = php_pcre_replace(regex,
result->val, result->len,
@@ -247,7 +247,7 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
/* Create a lowercased header for all the searches so we're finally case
* insensitive when searching for a pattern. */
- if (NULL == (headers_lc = STR_COPY(headers_trim))) {
+ if (NULL == (headers_lc = zend_string_copy(headers_trim))) {
*error = OUT_OF_MEMORY;
return FAILURE;
}
@@ -276,7 +276,7 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
}
} else {
if (headers_lc) {
- STR_FREE(headers_lc);
+ zend_string_free(headers_lc);
}
*error = W32_SM_SENDMAIL_FROM_NOT_SET;
return FAILURE;
@@ -360,6 +360,9 @@ PHPAPI char *GetSMErrorText(int index)
}
}
+PHPAPI zend_string *php_str_to_str(char *haystack, int length, char *needle,
+ int needle_len, char *str, int str_len);
+
/*********************************************************************
// Name: SendText
@@ -635,19 +638,19 @@ static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char
c = *e2;
*e2 = '\0';
if ((res = Post(p)) != SUCCESS) {
- STR_FREE(data_cln);
+ zend_string_free(data_cln);
return(res);
}
*e2 = c;
p = e2;
}
if ((res = Post(p)) != SUCCESS) {
- STR_FREE(data_cln);
+ zend_string_free(data_cln);
return(res);
}
}
- STR_FREE(data_cln);
+ zend_string_free(data_cln);
/*send termination dot */
if ((res = Post("\r\n.\r\n")) != SUCCESS)
@@ -706,7 +709,7 @@ static int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders T
zend_string *dt = php_format_date("r", 1, tNow, 1 TSRMLS_CC);
snprintf(header_buffer, MAIL_BUFFER_SIZE, "Date: %s\r\n", dt->val);
- STR_FREE(dt);
+ zend_string_free(dt);
}
if (!headers_lc || !strstr(headers_lc, "from:")) {
diff --git a/win32/winutil.c b/win32/winutil.c
index 22e2d45304..9984d3addc 100644
--- a/win32/winutil.c
+++ b/win32/winutil.c
@@ -22,7 +22,7 @@
#include "php.h"
#include <wincrypt.h>
-PHPAPI char *php_win32_error_to_msg(int error)
+PHPAPI char *php_win32_error_to_msg(HRESULT error)
{
char *buf = NULL;
diff --git a/win32/winutil.h b/win32/winutil.h
index 773063e5f6..e0193d33f3 100644
--- a/win32/winutil.h
+++ b/win32/winutil.h
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-PHPAPI char *php_win32_error_to_msg(int error);
+PHPAPI char *php_win32_error_to_msg(HRESULT error);
#define php_win_err() php_win32_error_to_msg(GetLastError())
int php_win32_check_trailing_space(const char * path, const int path_len);